@spacesops/wdk-react-native-core 1.0.0-beta.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +551 -0
- package/dist/__mocks__/react.d.ts +40 -0
- package/dist/__mocks__/react.js +33 -0
- package/dist/__mocks__/react.js.map +1 -0
- package/dist/__mocks__/secureStorage.d.ts +26 -0
- package/dist/__mocks__/secureStorage.js +80 -0
- package/dist/__mocks__/secureStorage.js.map +1 -0
- package/dist/__tests__/hooks/useBalance.test.d.ts +6 -0
- package/dist/__tests__/hooks/useBalance.test.js +217 -0
- package/dist/__tests__/hooks/useBalance.test.js.map +1 -0
- package/dist/__tests__/hooks/useWallet.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWallet.test.js +105 -0
- package/dist/__tests__/hooks/useWallet.test.js.map +1 -0
- package/dist/__tests__/hooks/useWalletManager.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWalletManager.test.js +193 -0
- package/dist/__tests__/hooks/useWalletManager.test.js.map +1 -0
- package/dist/__tests__/hooks/useWdkApp.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWdkApp.test.js +55 -0
- package/dist/__tests__/hooks/useWdkApp.test.js.map +1 -0
- package/dist/__tests__/hooks/useWorklet.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWorklet.test.js +168 -0
- package/dist/__tests__/hooks/useWorklet.test.js.map +1 -0
- package/dist/__tests__/provider/WdkAppProvider.test.d.ts +6 -0
- package/dist/__tests__/provider/WdkAppProvider.test.js +57 -0
- package/dist/__tests__/provider/WdkAppProvider.test.js.map +1 -0
- package/dist/__tests__/services/accountService.test.d.ts +6 -0
- package/dist/__tests__/services/accountService.test.js +216 -0
- package/dist/__tests__/services/accountService.test.js.map +1 -0
- package/dist/__tests__/services/addressService.test.d.ts +6 -0
- package/dist/__tests__/services/addressService.test.js +246 -0
- package/dist/__tests__/services/addressService.test.js.map +1 -0
- package/dist/__tests__/services/balanceService.test.d.ts +6 -0
- package/dist/__tests__/services/balanceService.test.js +333 -0
- package/dist/__tests__/services/balanceService.test.js.map +1 -0
- package/dist/__tests__/services/walletSetupService.test.d.ts +6 -0
- package/dist/__tests__/services/walletSetupService.test.js +304 -0
- package/dist/__tests__/services/walletSetupService.test.js.map +1 -0
- package/dist/__tests__/services/walletSwitchingService.test.d.ts +6 -0
- package/dist/__tests__/services/walletSwitchingService.test.js +209 -0
- package/dist/__tests__/services/walletSwitchingService.test.js.map +1 -0
- package/dist/__tests__/services/workletLifecycleService.test.d.ts +6 -0
- package/dist/__tests__/services/workletLifecycleService.test.js +451 -0
- package/dist/__tests__/services/workletLifecycleService.test.js.map +1 -0
- package/dist/__tests__/setup.d.ts +7 -0
- package/dist/__tests__/setup.js +49 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/__tests__/storage/mmkvStorage.test.d.ts +6 -0
- package/dist/__tests__/storage/mmkvStorage.test.js +213 -0
- package/dist/__tests__/storage/mmkvStorage.test.js.map +1 -0
- package/dist/__tests__/store/walletStore.test.d.ts +4 -0
- package/dist/__tests__/store/walletStore.test.js +86 -0
- package/dist/__tests__/store/walletStore.test.js.map +1 -0
- package/dist/__tests__/store/workletStore.test.d.ts +4 -0
- package/dist/__tests__/store/workletStore.test.js +255 -0
- package/dist/__tests__/store/workletStore.test.js.map +1 -0
- package/dist/__tests__/types/hrpc.test.d.ts +4 -0
- package/dist/__tests__/types/hrpc.test.js +99 -0
- package/dist/__tests__/types/hrpc.test.js.map +1 -0
- package/dist/__tests__/utils/balanceUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/balanceUtils.test.js +133 -0
- package/dist/__tests__/utils/balanceUtils.test.js.map +1 -0
- package/dist/__tests__/utils/errorHandling.test.d.ts +6 -0
- package/dist/__tests__/utils/errorHandling.test.js +119 -0
- package/dist/__tests__/utils/errorHandling.test.js.map +1 -0
- package/dist/__tests__/utils/errorUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/errorUtils.test.js +133 -0
- package/dist/__tests__/utils/errorUtils.test.js.map +1 -0
- package/dist/__tests__/utils/initializationState.test.d.ts +6 -0
- package/dist/__tests__/utils/initializationState.test.js +243 -0
- package/dist/__tests__/utils/initializationState.test.js.map +1 -0
- package/dist/__tests__/utils/jsonUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/jsonUtils.test.js +118 -0
- package/dist/__tests__/utils/jsonUtils.test.js.map +1 -0
- package/dist/__tests__/utils/mmkvKeyManager.test.d.ts +6 -0
- package/dist/__tests__/utils/mmkvKeyManager.test.js +158 -0
- package/dist/__tests__/utils/mmkvKeyManager.test.js.map +1 -0
- package/dist/__tests__/utils/mnemonicUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/mnemonicUtils.test.js +40 -0
- package/dist/__tests__/utils/mnemonicUtils.test.js.map +1 -0
- package/dist/__tests__/utils/raceConditions.test.d.ts +6 -0
- package/dist/__tests__/utils/raceConditions.test.js +239 -0
- package/dist/__tests__/utils/raceConditions.test.js.map +1 -0
- package/dist/__tests__/utils/result.test.d.ts +4 -0
- package/dist/__tests__/utils/result.test.js +66 -0
- package/dist/__tests__/utils/result.test.js.map +1 -0
- package/dist/__tests__/utils/schemas.test.d.ts +4 -0
- package/dist/__tests__/utils/schemas.test.js +66 -0
- package/dist/__tests__/utils/schemas.test.js.map +1 -0
- package/dist/__tests__/utils/storeHelpers.test.d.ts +4 -0
- package/dist/__tests__/utils/storeHelpers.test.js +227 -0
- package/dist/__tests__/utils/storeHelpers.test.js.map +1 -0
- package/dist/__tests__/utils/typeGuards.test.d.ts +4 -0
- package/dist/__tests__/utils/typeGuards.test.js +175 -0
- package/dist/__tests__/utils/typeGuards.test.js.map +1 -0
- package/dist/__tests__/utils/validation.test.d.ts +4 -0
- package/dist/__tests__/utils/validation.test.js +126 -0
- package/dist/__tests__/utils/validation.test.js.map +1 -0
- package/dist/__tests__/utils/walletUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/walletUtils.test.js +156 -0
- package/dist/__tests__/utils/walletUtils.test.js.map +1 -0
- package/dist/hooks/useBalance.d.ts +170 -0
- package/dist/hooks/useBalance.js +442 -0
- package/dist/hooks/useBalance.js.map +1 -0
- package/dist/hooks/useWallet.d.ts +43 -0
- package/dist/hooks/useWallet.js +193 -0
- package/dist/hooks/useWallet.js.map +1 -0
- package/dist/hooks/useWalletManager.d.ts +100 -0
- package/dist/hooks/useWalletManager.js +526 -0
- package/dist/hooks/useWalletManager.js.map +1 -0
- package/dist/hooks/useWdkApp.d.ts +66 -0
- package/dist/hooks/useWdkApp.js +74 -0
- package/dist/hooks/useWdkApp.js.map +1 -0
- package/dist/hooks/useWorklet.d.ts +66 -0
- package/dist/hooks/useWorklet.js +42 -0
- package/dist/hooks/useWorklet.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/WdkAppProvider.d.ts +112 -0
- package/dist/provider/WdkAppProvider.js +558 -0
- package/dist/provider/WdkAppProvider.js.map +1 -0
- package/dist/services/accountService.d.ts +52 -0
- package/dist/services/accountService.js +119 -0
- package/dist/services/accountService.js.map +1 -0
- package/dist/services/addressService.d.ts +22 -0
- package/dist/services/addressService.js +110 -0
- package/dist/services/addressService.js.map +1 -0
- package/dist/services/balanceService.d.ts +114 -0
- package/dist/services/balanceService.js +208 -0
- package/dist/services/balanceService.js.map +1 -0
- package/dist/services/walletSetupService.d.ts +217 -0
- package/dist/services/walletSetupService.js +535 -0
- package/dist/services/walletSetupService.js.map +1 -0
- package/dist/services/walletSwitchingService.d.ts +48 -0
- package/dist/services/walletSwitchingService.js +143 -0
- package/dist/services/walletSwitchingService.js.map +1 -0
- package/dist/services/workletLifecycleService.d.ts +117 -0
- package/dist/services/workletLifecycleService.js +433 -0
- package/dist/services/workletLifecycleService.js.map +1 -0
- package/dist/storage/mmkvStorage.d.ts +44 -0
- package/dist/storage/mmkvStorage.js +348 -0
- package/dist/storage/mmkvStorage.js.map +1 -0
- package/dist/store/walletStore.d.ts +130 -0
- package/dist/store/walletStore.js +204 -0
- package/dist/store/walletStore.js.map +1 -0
- package/dist/store/workletStore.d.ts +121 -0
- package/dist/store/workletStore.js +256 -0
- package/dist/store/workletStore.js.map +1 -0
- package/dist/types/hrpc.d.ts +60 -0
- package/dist/types/hrpc.js +26 -0
- package/dist/types/hrpc.js.map +1 -0
- package/dist/types.d.ts +168 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/balanceUtils.d.ts +30 -0
- package/dist/utils/balanceUtils.js +86 -0
- package/dist/utils/balanceUtils.js.map +1 -0
- package/dist/utils/constants.d.ts +66 -0
- package/dist/utils/constants.js +73 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +47 -0
- package/dist/utils/errorHandling.js +54 -0
- package/dist/utils/errorHandling.js.map +1 -0
- package/dist/utils/errorUtils.d.ts +89 -0
- package/dist/utils/errorUtils.js +264 -0
- package/dist/utils/errorUtils.js.map +1 -0
- package/dist/utils/initializationState.d.ts +129 -0
- package/dist/utils/initializationState.js +220 -0
- package/dist/utils/initializationState.js.map +1 -0
- package/dist/utils/jsonUtils.d.ts +21 -0
- package/dist/utils/jsonUtils.js +67 -0
- package/dist/utils/jsonUtils.js.map +1 -0
- package/dist/utils/logger.d.ts +27 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mmkvKeyManager.d.ts +57 -0
- package/dist/utils/mmkvKeyManager.js +214 -0
- package/dist/utils/mmkvKeyManager.js.map +1 -0
- package/dist/utils/mnemonicUtils.d.ts +17 -0
- package/dist/utils/mnemonicUtils.js +28 -0
- package/dist/utils/mnemonicUtils.js.map +1 -0
- package/dist/utils/operationMutex.d.ts +69 -0
- package/dist/utils/operationMutex.js +150 -0
- package/dist/utils/operationMutex.js.map +1 -0
- package/dist/utils/result.d.ts +34 -0
- package/dist/utils/result.js +43 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/schemas.d.ts +365 -0
- package/dist/utils/schemas.js +152 -0
- package/dist/utils/schemas.js.map +1 -0
- package/dist/utils/storeHelpers.d.ts +112 -0
- package/dist/utils/storeHelpers.js +198 -0
- package/dist/utils/storeHelpers.js.map +1 -0
- package/dist/utils/typeGuards.d.ts +70 -0
- package/dist/utils/typeGuards.js +95 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/dist/utils/validation.d.ts +53 -0
- package/dist/utils/validation.js +152 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/walletStateHelpers.d.ts +62 -0
- package/dist/utils/walletStateHelpers.js +81 -0
- package/dist/utils/walletStateHelpers.js.map +1 -0
- package/dist/utils/walletUtils.d.ts +38 -0
- package/dist/utils/walletUtils.js +87 -0
- package/dist/utils/walletUtils.js.map +1 -0
- package/package.json +79 -0
- package/src/__mocks__/react.ts +34 -0
- package/src/__mocks__/secureStorage.ts +87 -0
- package/src/__tests__/hooks/useBalance.test.ts +286 -0
- package/src/__tests__/hooks/useWallet.test.ts +122 -0
- package/src/__tests__/hooks/useWalletManager.test.ts +271 -0
- package/src/__tests__/hooks/useWdkApp.test.tsx +59 -0
- package/src/__tests__/hooks/useWorklet.test.ts +195 -0
- package/src/__tests__/provider/WdkAppProvider.test.tsx +67 -0
- package/src/__tests__/services/accountService.test.ts +337 -0
- package/src/__tests__/services/addressService.test.ts +312 -0
- package/src/__tests__/services/balanceService.test.ts +411 -0
- package/src/__tests__/services/walletSetupService.test.ts +463 -0
- package/src/__tests__/services/walletSwitchingService.test.ts +258 -0
- package/src/__tests__/services/workletLifecycleService.test.ts +514 -0
- package/src/__tests__/setup.ts +54 -0
- package/src/__tests__/storage/mmkvStorage.test.ts +325 -0
- package/src/__tests__/store/walletStore.test.ts +101 -0
- package/src/__tests__/store/workletStore.test.ts +329 -0
- package/src/__tests__/types/hrpc.test.ts +125 -0
- package/src/__tests__/utils/balanceUtils.test.ts +151 -0
- package/src/__tests__/utils/errorHandling.test.ts +147 -0
- package/src/__tests__/utils/errorUtils.test.ts +170 -0
- package/src/__tests__/utils/initializationState.test.ts +337 -0
- package/src/__tests__/utils/jsonUtils.test.ts +131 -0
- package/src/__tests__/utils/mmkvKeyManager.test.ts +205 -0
- package/src/__tests__/utils/mnemonicUtils.test.ts +48 -0
- package/src/__tests__/utils/raceConditions.test.ts +292 -0
- package/src/__tests__/utils/result.test.ts +73 -0
- package/src/__tests__/utils/schemas.test.ts +82 -0
- package/src/__tests__/utils/storeHelpers.test.ts +323 -0
- package/src/__tests__/utils/typeGuards.test.ts +209 -0
- package/src/__tests__/utils/validation.test.ts +152 -0
- package/src/__tests__/utils/walletUtils.test.ts +195 -0
- package/src/hooks/useBalance.ts +597 -0
- package/src/hooks/useWallet.ts +288 -0
- package/src/hooks/useWalletManager.ts +654 -0
- package/src/hooks/useWdkApp.ts +78 -0
- package/src/hooks/useWorklet.ts +109 -0
- package/src/index.ts +112 -0
- package/src/provider/WdkAppProvider.tsx +764 -0
- package/src/services/accountService.ts +134 -0
- package/src/services/addressService.ts +125 -0
- package/src/services/balanceService.ts +291 -0
- package/src/services/walletSetupService.ts +695 -0
- package/src/services/walletSwitchingService.ts +157 -0
- package/src/services/workletLifecycleService.ts +561 -0
- package/src/storage/mmkvStorage.ts +417 -0
- package/src/store/walletStore.ts +301 -0
- package/src/store/workletStore.ts +340 -0
- package/src/types/hrpc.ts +78 -0
- package/src/types.ts +188 -0
- package/src/utils/balanceUtils.ts +96 -0
- package/src/utils/constants.ts +84 -0
- package/src/utils/errorHandling.md +163 -0
- package/src/utils/errorHandling.ts +61 -0
- package/src/utils/errorUtils.ts +300 -0
- package/src/utils/initializationState.ts +242 -0
- package/src/utils/jsonUtils.ts +75 -0
- package/src/utils/logger.ts +54 -0
- package/src/utils/mmkvKeyManager.ts +256 -0
- package/src/utils/mnemonicUtils.ts +35 -0
- package/src/utils/operationMutex.ts +181 -0
- package/src/utils/result.ts +57 -0
- package/src/utils/schemas.ts +190 -0
- package/src/utils/storeHelpers.ts +236 -0
- package/src/utils/typeGuards.ts +129 -0
- package/src/utils/validation.ts +174 -0
- package/src/utils/walletStateHelpers.ts +104 -0
- package/src/utils/walletUtils.ts +107 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operation Mutex - Prevents concurrent wallet operations
|
|
3
|
+
*
|
|
4
|
+
* This utility provides a mutex/lock mechanism to ensure only one wallet operation
|
|
5
|
+
* can execute at a time, preventing race conditions and state corruption.
|
|
6
|
+
*/
|
|
7
|
+
import { getWalletStore } from '../store/walletStore';
|
|
8
|
+
import { log, logWarn } from './logger';
|
|
9
|
+
/**
|
|
10
|
+
* Try to acquire operation mutex
|
|
11
|
+
*
|
|
12
|
+
* @param operationDescription - Description of the operation (for debugging)
|
|
13
|
+
* @returns MutexResult with acquired status and release function
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const mutex = acquireOperationMutex('switchWallet')
|
|
18
|
+
* if (!mutex.acquired) {
|
|
19
|
+
* throw new Error(`Operation in progress: ${mutex.currentOperation}`)
|
|
20
|
+
* }
|
|
21
|
+
* try {
|
|
22
|
+
* // Perform operation
|
|
23
|
+
* } finally {
|
|
24
|
+
* mutex.release()
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function acquireOperationMutex(operationDescription) {
|
|
29
|
+
const walletStore = getWalletStore();
|
|
30
|
+
const state = walletStore.getState();
|
|
31
|
+
// Check if operation is already in progress
|
|
32
|
+
if (state.isOperationInProgress) {
|
|
33
|
+
logWarn(`[OperationMutex] Operation "${operationDescription}" blocked by: ${state.currentOperation}`);
|
|
34
|
+
return {
|
|
35
|
+
acquired: false,
|
|
36
|
+
currentOperation: state.currentOperation,
|
|
37
|
+
release: () => { }, // No-op release
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Acquire mutex
|
|
41
|
+
walletStore.setState({
|
|
42
|
+
isOperationInProgress: true,
|
|
43
|
+
currentOperation: operationDescription,
|
|
44
|
+
});
|
|
45
|
+
log(`[OperationMutex] Acquired mutex for: ${operationDescription}`);
|
|
46
|
+
// Return release function
|
|
47
|
+
return {
|
|
48
|
+
acquired: true,
|
|
49
|
+
currentOperation: null,
|
|
50
|
+
release: () => {
|
|
51
|
+
const currentState = walletStore.getState();
|
|
52
|
+
// Only release if we're still the current operation
|
|
53
|
+
if (currentState.currentOperation === operationDescription) {
|
|
54
|
+
walletStore.setState({
|
|
55
|
+
isOperationInProgress: false,
|
|
56
|
+
currentOperation: null,
|
|
57
|
+
});
|
|
58
|
+
log(`[OperationMutex] Released mutex for: ${operationDescription}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
logWarn(`[OperationMutex] Attempted to release mutex for "${operationDescription}" but current operation is "${currentState.currentOperation}"`);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Default timeout for operations (30 seconds)
|
|
68
|
+
* Operations that exceed this timeout will be automatically released
|
|
69
|
+
*/
|
|
70
|
+
const DEFAULT_OPERATION_TIMEOUT_MS = 30 * 1000;
|
|
71
|
+
/**
|
|
72
|
+
* Execute an operation with mutex protection
|
|
73
|
+
* Automatically acquires and releases mutex
|
|
74
|
+
* Includes timeout protection to prevent stuck operations
|
|
75
|
+
*
|
|
76
|
+
* @param operationDescription - Description of the operation
|
|
77
|
+
* @param operation - Async operation to execute
|
|
78
|
+
* @param timeoutMs - Optional timeout in milliseconds (default: 30000ms / 30 seconds)
|
|
79
|
+
* @returns Promise with operation result
|
|
80
|
+
* @throws Error if mutex cannot be acquired, operation fails, or timeout is exceeded
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* await withOperationMutex('switchWallet', async () => {
|
|
85
|
+
* await WalletSwitchingService.switchToWallet(walletId)
|
|
86
|
+
* })
|
|
87
|
+
*
|
|
88
|
+
* // With custom timeout
|
|
89
|
+
* await withOperationMutex('longOperation', async () => {
|
|
90
|
+
* await longRunningOperation()
|
|
91
|
+
* }, 60000) // 60 second timeout
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export async function withOperationMutex(operationDescription, operation, timeoutMs = DEFAULT_OPERATION_TIMEOUT_MS) {
|
|
95
|
+
const mutex = acquireOperationMutex(operationDescription);
|
|
96
|
+
if (!mutex.acquired) {
|
|
97
|
+
throw new Error(`Cannot execute "${operationDescription}": Another operation is in progress (${mutex.currentOperation})`);
|
|
98
|
+
}
|
|
99
|
+
// Set up timeout protection
|
|
100
|
+
let timeoutId = null;
|
|
101
|
+
let timeoutExceeded = false;
|
|
102
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
103
|
+
timeoutId = setTimeout(() => {
|
|
104
|
+
timeoutExceeded = true;
|
|
105
|
+
logWarn(`[OperationMutex] Operation "${operationDescription}" exceeded timeout of ${timeoutMs}ms`);
|
|
106
|
+
mutex.release();
|
|
107
|
+
reject(new Error(`Operation "${operationDescription}" exceeded timeout of ${timeoutMs}ms`));
|
|
108
|
+
}, timeoutMs);
|
|
109
|
+
});
|
|
110
|
+
try {
|
|
111
|
+
// Race between operation and timeout
|
|
112
|
+
return await Promise.race([
|
|
113
|
+
operation(),
|
|
114
|
+
timeoutPromise,
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
// If timeout occurred, error is already handled
|
|
119
|
+
if (timeoutExceeded) {
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
// Otherwise, re-throw the operation error
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
finally {
|
|
126
|
+
// Clear timeout if operation completed before timeout
|
|
127
|
+
if (timeoutId) {
|
|
128
|
+
clearTimeout(timeoutId);
|
|
129
|
+
}
|
|
130
|
+
// Only release if timeout didn't already release it
|
|
131
|
+
if (!timeoutExceeded) {
|
|
132
|
+
mutex.release();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Check if an operation is currently in progress
|
|
138
|
+
*/
|
|
139
|
+
export function isOperationInProgress() {
|
|
140
|
+
const walletStore = getWalletStore();
|
|
141
|
+
return walletStore.getState().isOperationInProgress;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get current operation description
|
|
145
|
+
*/
|
|
146
|
+
export function getCurrentOperation() {
|
|
147
|
+
const walletStore = getWalletStore();
|
|
148
|
+
return walletStore.getState().currentOperation;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=operationMutex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operationMutex.js","sourceRoot":"","sources":["../../src/utils/operationMutex.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result Type for Error Handling
|
|
3
|
+
*
|
|
4
|
+
* Provides a consistent pattern for handling operations that can succeed or fail.
|
|
5
|
+
* This eliminates the need for try-catch blocks and provides type-safe error handling.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Result type representing success or failure
|
|
9
|
+
*/
|
|
10
|
+
export type Result<T, E = Error> = {
|
|
11
|
+
success: true;
|
|
12
|
+
data: T;
|
|
13
|
+
error?: never;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: E;
|
|
17
|
+
data?: never;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Create a success result
|
|
21
|
+
*/
|
|
22
|
+
export declare function ok<T>(data: T): Result<T, never>;
|
|
23
|
+
/**
|
|
24
|
+
* Create an error result
|
|
25
|
+
*/
|
|
26
|
+
export declare function err<E>(error: E): Result<never, E>;
|
|
27
|
+
/**
|
|
28
|
+
* Wrap an async function to return a Result instead of throwing
|
|
29
|
+
*/
|
|
30
|
+
export declare function toResult<T, E = Error>(fn: () => Promise<T>): Promise<Result<T, E>>;
|
|
31
|
+
/**
|
|
32
|
+
* Wrap a synchronous function to return a Result instead of throwing
|
|
33
|
+
*/
|
|
34
|
+
export declare function toResultSync<T, E = Error>(fn: () => T): Result<T, E>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result Type for Error Handling
|
|
3
|
+
*
|
|
4
|
+
* Provides a consistent pattern for handling operations that can succeed or fail.
|
|
5
|
+
* This eliminates the need for try-catch blocks and provides type-safe error handling.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Create a success result
|
|
9
|
+
*/
|
|
10
|
+
export function ok(data) {
|
|
11
|
+
return { success: true, data };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create an error result
|
|
15
|
+
*/
|
|
16
|
+
export function err(error) {
|
|
17
|
+
return { success: false, error };
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wrap an async function to return a Result instead of throwing
|
|
21
|
+
*/
|
|
22
|
+
export async function toResult(fn) {
|
|
23
|
+
try {
|
|
24
|
+
const data = await fn();
|
|
25
|
+
return ok(data);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return err(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wrap a synchronous function to return a Result instead of throwing
|
|
33
|
+
*/
|
|
34
|
+
export function toResultSync(fn) {
|
|
35
|
+
try {
|
|
36
|
+
const data = fn();
|
|
37
|
+
return ok(data);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return err(error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../src/utils/result.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,MAAM,UAAU,EAAE,CAAI,IAAO;IAC3B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAI,KAAQ;IAC7B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,EAAoB;IAEpB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,EAAE,EAAE,CAAA;QACvB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAU,CAAC,CAAA;IACxB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,EAAW;IAEX,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,EAAE,CAAA;QACjB,OAAO,EAAE,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CAAC,KAAU,CAAC,CAAA;IACxB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod Schemas for Runtime Validation
|
|
3
|
+
*
|
|
4
|
+
* Provides Zod schemas for all WDK types to replace manual if/else type guards.
|
|
5
|
+
* These schemas provide better error messages and are easier to maintain.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/**
|
|
9
|
+
* Ethereum address schema (0x followed by 40 hex characters)
|
|
10
|
+
*/
|
|
11
|
+
export declare const ethereumAddressSchema: z.ZodString;
|
|
12
|
+
/**
|
|
13
|
+
* Spark address schema (Bech32 format: spark1/sparkt1/sparkrt1 followed by base32 characters)
|
|
14
|
+
*/
|
|
15
|
+
export declare const sparkAddressSchema: z.ZodString;
|
|
16
|
+
/**
|
|
17
|
+
* Address schema (Ethereum or Spark)
|
|
18
|
+
*/
|
|
19
|
+
export declare const addressSchema: z.ZodUnion<[z.ZodString, z.ZodString]>;
|
|
20
|
+
/**
|
|
21
|
+
* Network configuration schema
|
|
22
|
+
*/
|
|
23
|
+
export declare const networkConfigSchema: z.ZodObject<{
|
|
24
|
+
chainId: z.ZodNumber;
|
|
25
|
+
blockchain: z.ZodString;
|
|
26
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
27
|
+
bundlerUrl: z.ZodOptional<z.ZodString>;
|
|
28
|
+
paymasterUrl: z.ZodOptional<z.ZodString>;
|
|
29
|
+
paymasterAddress: z.ZodOptional<z.ZodString>;
|
|
30
|
+
entryPointAddress: z.ZodOptional<z.ZodString>;
|
|
31
|
+
transferMaxFee: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
chainId: number;
|
|
34
|
+
blockchain: string;
|
|
35
|
+
provider?: string | undefined;
|
|
36
|
+
bundlerUrl?: string | undefined;
|
|
37
|
+
paymasterUrl?: string | undefined;
|
|
38
|
+
paymasterAddress?: string | undefined;
|
|
39
|
+
entryPointAddress?: string | undefined;
|
|
40
|
+
transferMaxFee?: number | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
chainId: number;
|
|
43
|
+
blockchain: string;
|
|
44
|
+
provider?: string | undefined;
|
|
45
|
+
bundlerUrl?: string | undefined;
|
|
46
|
+
paymasterUrl?: string | undefined;
|
|
47
|
+
paymasterAddress?: string | undefined;
|
|
48
|
+
entryPointAddress?: string | undefined;
|
|
49
|
+
transferMaxFee?: number | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Network configurations schema
|
|
53
|
+
*/
|
|
54
|
+
export declare const networkConfigsSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
55
|
+
chainId: z.ZodNumber;
|
|
56
|
+
blockchain: z.ZodString;
|
|
57
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
58
|
+
bundlerUrl: z.ZodOptional<z.ZodString>;
|
|
59
|
+
paymasterUrl: z.ZodOptional<z.ZodString>;
|
|
60
|
+
paymasterAddress: z.ZodOptional<z.ZodString>;
|
|
61
|
+
entryPointAddress: z.ZodOptional<z.ZodString>;
|
|
62
|
+
transferMaxFee: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
chainId: number;
|
|
65
|
+
blockchain: string;
|
|
66
|
+
provider?: string | undefined;
|
|
67
|
+
bundlerUrl?: string | undefined;
|
|
68
|
+
paymasterUrl?: string | undefined;
|
|
69
|
+
paymasterAddress?: string | undefined;
|
|
70
|
+
entryPointAddress?: string | undefined;
|
|
71
|
+
transferMaxFee?: number | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
chainId: number;
|
|
74
|
+
blockchain: string;
|
|
75
|
+
provider?: string | undefined;
|
|
76
|
+
bundlerUrl?: string | undefined;
|
|
77
|
+
paymasterUrl?: string | undefined;
|
|
78
|
+
paymasterAddress?: string | undefined;
|
|
79
|
+
entryPointAddress?: string | undefined;
|
|
80
|
+
transferMaxFee?: number | undefined;
|
|
81
|
+
}>>, Record<string, {
|
|
82
|
+
chainId: number;
|
|
83
|
+
blockchain: string;
|
|
84
|
+
provider?: string | undefined;
|
|
85
|
+
bundlerUrl?: string | undefined;
|
|
86
|
+
paymasterUrl?: string | undefined;
|
|
87
|
+
paymasterAddress?: string | undefined;
|
|
88
|
+
entryPointAddress?: string | undefined;
|
|
89
|
+
transferMaxFee?: number | undefined;
|
|
90
|
+
}>, Record<string, {
|
|
91
|
+
chainId: number;
|
|
92
|
+
blockchain: string;
|
|
93
|
+
provider?: string | undefined;
|
|
94
|
+
bundlerUrl?: string | undefined;
|
|
95
|
+
paymasterUrl?: string | undefined;
|
|
96
|
+
paymasterAddress?: string | undefined;
|
|
97
|
+
entryPointAddress?: string | undefined;
|
|
98
|
+
transferMaxFee?: number | undefined;
|
|
99
|
+
}>>;
|
|
100
|
+
/**
|
|
101
|
+
* Token configuration schema
|
|
102
|
+
*/
|
|
103
|
+
export declare const tokenConfigSchema: z.ZodObject<{
|
|
104
|
+
symbol: z.ZodString;
|
|
105
|
+
name: z.ZodString;
|
|
106
|
+
decimals: z.ZodNumber;
|
|
107
|
+
address: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
symbol: string;
|
|
110
|
+
name: string;
|
|
111
|
+
decimals: number;
|
|
112
|
+
address: string | null;
|
|
113
|
+
}, {
|
|
114
|
+
symbol: string;
|
|
115
|
+
name: string;
|
|
116
|
+
decimals: number;
|
|
117
|
+
address: string | null;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Network tokens schema
|
|
121
|
+
*/
|
|
122
|
+
export declare const networkTokensSchema: z.ZodObject<{
|
|
123
|
+
native: z.ZodObject<{
|
|
124
|
+
symbol: z.ZodString;
|
|
125
|
+
name: z.ZodString;
|
|
126
|
+
decimals: z.ZodNumber;
|
|
127
|
+
address: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
symbol: string;
|
|
130
|
+
name: string;
|
|
131
|
+
decimals: number;
|
|
132
|
+
address: string | null;
|
|
133
|
+
}, {
|
|
134
|
+
symbol: string;
|
|
135
|
+
name: string;
|
|
136
|
+
decimals: number;
|
|
137
|
+
address: string | null;
|
|
138
|
+
}>;
|
|
139
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
140
|
+
symbol: z.ZodString;
|
|
141
|
+
name: z.ZodString;
|
|
142
|
+
decimals: z.ZodNumber;
|
|
143
|
+
address: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
symbol: string;
|
|
146
|
+
name: string;
|
|
147
|
+
decimals: number;
|
|
148
|
+
address: string | null;
|
|
149
|
+
}, {
|
|
150
|
+
symbol: string;
|
|
151
|
+
name: string;
|
|
152
|
+
decimals: number;
|
|
153
|
+
address: string | null;
|
|
154
|
+
}>, "many">;
|
|
155
|
+
}, "strip", z.ZodTypeAny, {
|
|
156
|
+
native: {
|
|
157
|
+
symbol: string;
|
|
158
|
+
name: string;
|
|
159
|
+
decimals: number;
|
|
160
|
+
address: string | null;
|
|
161
|
+
};
|
|
162
|
+
tokens: {
|
|
163
|
+
symbol: string;
|
|
164
|
+
name: string;
|
|
165
|
+
decimals: number;
|
|
166
|
+
address: string | null;
|
|
167
|
+
}[];
|
|
168
|
+
}, {
|
|
169
|
+
native: {
|
|
170
|
+
symbol: string;
|
|
171
|
+
name: string;
|
|
172
|
+
decimals: number;
|
|
173
|
+
address: string | null;
|
|
174
|
+
};
|
|
175
|
+
tokens: {
|
|
176
|
+
symbol: string;
|
|
177
|
+
name: string;
|
|
178
|
+
decimals: number;
|
|
179
|
+
address: string | null;
|
|
180
|
+
}[];
|
|
181
|
+
}>;
|
|
182
|
+
/**
|
|
183
|
+
* Token configurations schema
|
|
184
|
+
*/
|
|
185
|
+
export declare const tokenConfigsSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
186
|
+
native: z.ZodObject<{
|
|
187
|
+
symbol: z.ZodString;
|
|
188
|
+
name: z.ZodString;
|
|
189
|
+
decimals: z.ZodNumber;
|
|
190
|
+
address: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
191
|
+
}, "strip", z.ZodTypeAny, {
|
|
192
|
+
symbol: string;
|
|
193
|
+
name: string;
|
|
194
|
+
decimals: number;
|
|
195
|
+
address: string | null;
|
|
196
|
+
}, {
|
|
197
|
+
symbol: string;
|
|
198
|
+
name: string;
|
|
199
|
+
decimals: number;
|
|
200
|
+
address: string | null;
|
|
201
|
+
}>;
|
|
202
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
203
|
+
symbol: z.ZodString;
|
|
204
|
+
name: z.ZodString;
|
|
205
|
+
decimals: z.ZodNumber;
|
|
206
|
+
address: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
207
|
+
}, "strip", z.ZodTypeAny, {
|
|
208
|
+
symbol: string;
|
|
209
|
+
name: string;
|
|
210
|
+
decimals: number;
|
|
211
|
+
address: string | null;
|
|
212
|
+
}, {
|
|
213
|
+
symbol: string;
|
|
214
|
+
name: string;
|
|
215
|
+
decimals: number;
|
|
216
|
+
address: string | null;
|
|
217
|
+
}>, "many">;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
native: {
|
|
220
|
+
symbol: string;
|
|
221
|
+
name: string;
|
|
222
|
+
decimals: number;
|
|
223
|
+
address: string | null;
|
|
224
|
+
};
|
|
225
|
+
tokens: {
|
|
226
|
+
symbol: string;
|
|
227
|
+
name: string;
|
|
228
|
+
decimals: number;
|
|
229
|
+
address: string | null;
|
|
230
|
+
}[];
|
|
231
|
+
}, {
|
|
232
|
+
native: {
|
|
233
|
+
symbol: string;
|
|
234
|
+
name: string;
|
|
235
|
+
decimals: number;
|
|
236
|
+
address: string | null;
|
|
237
|
+
};
|
|
238
|
+
tokens: {
|
|
239
|
+
symbol: string;
|
|
240
|
+
name: string;
|
|
241
|
+
decimals: number;
|
|
242
|
+
address: string | null;
|
|
243
|
+
}[];
|
|
244
|
+
}>>, Record<string, {
|
|
245
|
+
native: {
|
|
246
|
+
symbol: string;
|
|
247
|
+
name: string;
|
|
248
|
+
decimals: number;
|
|
249
|
+
address: string | null;
|
|
250
|
+
};
|
|
251
|
+
tokens: {
|
|
252
|
+
symbol: string;
|
|
253
|
+
name: string;
|
|
254
|
+
decimals: number;
|
|
255
|
+
address: string | null;
|
|
256
|
+
}[];
|
|
257
|
+
}>, Record<string, {
|
|
258
|
+
native: {
|
|
259
|
+
symbol: string;
|
|
260
|
+
name: string;
|
|
261
|
+
decimals: number;
|
|
262
|
+
address: string | null;
|
|
263
|
+
};
|
|
264
|
+
tokens: {
|
|
265
|
+
symbol: string;
|
|
266
|
+
name: string;
|
|
267
|
+
decimals: number;
|
|
268
|
+
address: string | null;
|
|
269
|
+
}[];
|
|
270
|
+
}>>;
|
|
271
|
+
/**
|
|
272
|
+
* Account index schema
|
|
273
|
+
*/
|
|
274
|
+
export declare const accountIndexSchema: z.ZodNumber;
|
|
275
|
+
/**
|
|
276
|
+
* Network name schema
|
|
277
|
+
*/
|
|
278
|
+
export declare const networkNameSchema: z.ZodString;
|
|
279
|
+
/**
|
|
280
|
+
* Balance string schema (valid number string)
|
|
281
|
+
*/
|
|
282
|
+
export declare const balanceStringSchema: z.ZodString;
|
|
283
|
+
/**
|
|
284
|
+
* Wallet addresses schema
|
|
285
|
+
* Maps network -> accountIndex -> address
|
|
286
|
+
*/
|
|
287
|
+
export declare const walletAddressesSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEffects<z.ZodString, number, string>, z.ZodUnion<[z.ZodString, z.ZodString]>>>;
|
|
288
|
+
/**
|
|
289
|
+
* Wallet balances schema
|
|
290
|
+
* Maps network -> accountIndex -> tokenAddress -> balance
|
|
291
|
+
*/
|
|
292
|
+
export declare const walletBalancesSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEffects<z.ZodString, number, string>, z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
293
|
+
/**
|
|
294
|
+
* Balance loading states schema
|
|
295
|
+
* Maps "network-accountIndex-tokenAddress" -> boolean
|
|
296
|
+
*/
|
|
297
|
+
export declare const balanceLoadingStatesSchema: z.ZodRecord<z.ZodString, z.ZodBoolean>;
|
|
298
|
+
/**
|
|
299
|
+
* Balance fetch result schema
|
|
300
|
+
*/
|
|
301
|
+
export declare const balanceFetchResultSchema: z.ZodObject<{
|
|
302
|
+
success: z.ZodBoolean;
|
|
303
|
+
network: z.ZodString;
|
|
304
|
+
accountIndex: z.ZodNumber;
|
|
305
|
+
tokenAddress: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
306
|
+
balance: z.ZodUnion<[z.ZodString, z.ZodNull]>;
|
|
307
|
+
error: z.ZodOptional<z.ZodString>;
|
|
308
|
+
}, "strip", z.ZodTypeAny, {
|
|
309
|
+
success: boolean;
|
|
310
|
+
network: string;
|
|
311
|
+
accountIndex: number;
|
|
312
|
+
tokenAddress: string | null;
|
|
313
|
+
balance: string | null;
|
|
314
|
+
error?: string | undefined;
|
|
315
|
+
}, {
|
|
316
|
+
success: boolean;
|
|
317
|
+
network: string;
|
|
318
|
+
accountIndex: number;
|
|
319
|
+
tokenAddress: string | null;
|
|
320
|
+
balance: string | null;
|
|
321
|
+
error?: string | undefined;
|
|
322
|
+
}>;
|
|
323
|
+
/**
|
|
324
|
+
* Wallet schema
|
|
325
|
+
*/
|
|
326
|
+
export declare const walletSchema: z.ZodObject<{
|
|
327
|
+
accountIndex: z.ZodNumber;
|
|
328
|
+
identifier: z.ZodString;
|
|
329
|
+
name: z.ZodString;
|
|
330
|
+
createdAt: z.ZodNumber;
|
|
331
|
+
updatedAt: z.ZodNumber;
|
|
332
|
+
}, "strip", z.ZodTypeAny, {
|
|
333
|
+
name: string;
|
|
334
|
+
identifier: string;
|
|
335
|
+
accountIndex: number;
|
|
336
|
+
createdAt: number;
|
|
337
|
+
updatedAt: number;
|
|
338
|
+
}, {
|
|
339
|
+
name: string;
|
|
340
|
+
identifier: string;
|
|
341
|
+
accountIndex: number;
|
|
342
|
+
createdAt: number;
|
|
343
|
+
updatedAt: number;
|
|
344
|
+
}>;
|
|
345
|
+
/**
|
|
346
|
+
* Worklet response schemas for runtime validation
|
|
347
|
+
*/
|
|
348
|
+
export declare const workletResponseSchema: z.ZodObject<{
|
|
349
|
+
result: z.ZodString;
|
|
350
|
+
error: z.ZodOptional<z.ZodString>;
|
|
351
|
+
}, "strip", z.ZodTypeAny, {
|
|
352
|
+
result: string;
|
|
353
|
+
error?: string | undefined;
|
|
354
|
+
}, {
|
|
355
|
+
result: string;
|
|
356
|
+
error?: string | undefined;
|
|
357
|
+
}>;
|
|
358
|
+
/**
|
|
359
|
+
* Balance response schema (numeric string)
|
|
360
|
+
*/
|
|
361
|
+
export declare const balanceResponseSchema: z.ZodString;
|
|
362
|
+
/**
|
|
363
|
+
* Account method response schema (union of possible return types)
|
|
364
|
+
*/
|
|
365
|
+
export declare const accountMethodResponseSchema: z.ZodUnion<[z.ZodString, z.ZodString, z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>]>;
|