@oydual31/more-vaults-sdk 1.1.13 → 1.1.14
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/dist/{curatorBridge-C0j35Mer.d.cts → curatorBridge-BMSgDsUE.d.cts} +79 -2
- package/dist/{curatorBridge-C0j35Mer.d.ts → curatorBridge-BMSgDsUE.d.ts} +79 -2
- package/dist/react/index.cjs +2 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +2 -0
- package/dist/react/index.js.map +1 -1
- package/dist/viem/index.cjs +126 -5
- package/dist/viem/index.cjs.map +1 -1
- package/dist/viem/index.d.cts +13 -6
- package/dist/viem/index.d.ts +13 -6
- package/dist/viem/index.js +122 -6
- package/dist/viem/index.js.map +1 -1
- package/package.json +1 -1
- package/src/viem/crossChainFlows.ts +53 -1
- package/src/viem/flowStorage.ts +168 -0
- package/src/viem/index.ts +4 -0
- package/src/viem/utils.ts +9 -0
|
@@ -414,6 +414,80 @@ interface VaultPortfolio {
|
|
|
414
414
|
lockedAssets: bigint;
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Storage adapter interface (async — supports localStorage today, remote tomorrow).
|
|
419
|
+
* Implement this interface to plug in any storage backend.
|
|
420
|
+
*/
|
|
421
|
+
interface FlowStorage {
|
|
422
|
+
get(key: string): Promise<string | null>;
|
|
423
|
+
set(key: string, value: string): Promise<void>;
|
|
424
|
+
del(key: string): Promise<void>;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Deposit flow state — discriminated union by phase.
|
|
428
|
+
* Persisted after each phase so the flow can be resumed on reload.
|
|
429
|
+
*/
|
|
430
|
+
type DepositFlowState = {
|
|
431
|
+
phase: 'spoke_sent';
|
|
432
|
+
txHash: string;
|
|
433
|
+
/** Partial composeData from depositFromSpoke (message and from resolved later) */
|
|
434
|
+
composeData: Record<string, unknown>;
|
|
435
|
+
/** As decimal string — bigint not JSON-safe */
|
|
436
|
+
startBlock: string;
|
|
437
|
+
vault: string;
|
|
438
|
+
timestamp: number;
|
|
439
|
+
} | {
|
|
440
|
+
phase: 'compose_found';
|
|
441
|
+
/** Full composeData returned by waitForCompose */
|
|
442
|
+
composeData: Record<string, unknown>;
|
|
443
|
+
timestamp: number;
|
|
444
|
+
} | {
|
|
445
|
+
phase: 'hub_sent';
|
|
446
|
+
guid: string;
|
|
447
|
+
vault: string;
|
|
448
|
+
composerSentGuid?: string;
|
|
449
|
+
tokensLocked?: {
|
|
450
|
+
guid: string;
|
|
451
|
+
vault: string;
|
|
452
|
+
token: string;
|
|
453
|
+
amount: string;
|
|
454
|
+
};
|
|
455
|
+
timestamp: number;
|
|
456
|
+
} | {
|
|
457
|
+
phase: 'done';
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* localStorage-backed FlowStorage adapter.
|
|
461
|
+
* Safe to instantiate in any environment — localStorage is only accessed at call time.
|
|
462
|
+
*/
|
|
463
|
+
declare class LocalStorageAdapter implements FlowStorage {
|
|
464
|
+
get(key: string): Promise<string | null>;
|
|
465
|
+
set(key: string, value: string): Promise<void>;
|
|
466
|
+
del(key: string): Promise<void>;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Returns a LocalStorageAdapter when running in a browser environment,
|
|
470
|
+
* or null in Node.js / non-browser environments.
|
|
471
|
+
*
|
|
472
|
+
* Used internally as the default storage — consumers can override by passing
|
|
473
|
+
* their own FlowStorage implementation, or pass null to disable persistence.
|
|
474
|
+
*/
|
|
475
|
+
declare function getDefaultStorage(): FlowStorage | null;
|
|
476
|
+
/**
|
|
477
|
+
* Persist the current deposit flow state for a wallet.
|
|
478
|
+
*/
|
|
479
|
+
declare function saveDepositFlow(storage: FlowStorage, walletAddress: string, state: DepositFlowState): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* Load a pending deposit flow for a wallet.
|
|
482
|
+
* Returns null if there is no state, the flow is done, or the state is older than 24h.
|
|
483
|
+
*/
|
|
484
|
+
declare function loadDepositFlow(storage: FlowStorage, walletAddress: string): Promise<DepositFlowState | null>;
|
|
485
|
+
/**
|
|
486
|
+
* Clear the persisted deposit flow for a wallet.
|
|
487
|
+
* Call this when the flow completes or is explicitly cancelled.
|
|
488
|
+
*/
|
|
489
|
+
declare function clearDepositFlow(storage: FlowStorage, walletAddress: string): Promise<void>;
|
|
490
|
+
|
|
417
491
|
/**
|
|
418
492
|
* Wait for a transaction receipt with generous timeout and retry logic.
|
|
419
493
|
*
|
|
@@ -606,7 +680,10 @@ declare function waitForAsyncRequest(publicClient: PublicClient, vault: Address,
|
|
|
606
680
|
finalized: boolean;
|
|
607
681
|
refunded: boolean;
|
|
608
682
|
result: bigint;
|
|
609
|
-
}) => void
|
|
683
|
+
}) => void, options?: {
|
|
684
|
+
storage?: FlowStorage | null;
|
|
685
|
+
walletAddress?: Address;
|
|
686
|
+
}): Promise<AsyncRequestFinalResult>;
|
|
610
687
|
/**
|
|
611
688
|
* Detect whether an OFT address is a Stargate V2 pool by calling `stargateType()`.
|
|
612
689
|
*
|
|
@@ -1189,4 +1266,4 @@ declare function quoteCuratorBridgeFee(publicClient: PublicClient, vault: Addres
|
|
|
1189
1266
|
*/
|
|
1190
1267
|
declare function executeCuratorBridge(walletClient: WalletClient, publicClient: PublicClient, vault: Address, token: Address, params: CuratorBridgeParams): Promise<Hash>;
|
|
1191
1268
|
|
|
1192
|
-
export {
|
|
1269
|
+
export { clearDepositFlow as $, type AsyncRequestResult as A, type BatchSwapParams as B, type ComposeData as C, type DepositResult as D, type ERC7540RequestStatus as E, type FlowStorage as F, type OutboundRoute as G, type SpokeBalance as H, type InboundRoute as I, type SwapParams as J, type UserPosition as K, LocalStorageAdapter as L, type MultiChainPortfolio as M, NATIVE_SYMBOL as N, OMNI_FACTORY_ADDRESS as O, type PendingAction as P, type VaultDistribution as Q, type RedeemResult as R, type SpokeDepositResult as S, type VaultMetadata as T, type UserBalances as U, type VaultAddresses as V, type VaultMode as W, type VaultStatus as X, type VaultSummary as Y, type VaultTopology as Z, canDeposit as _, type CuratorVaultStatus as a, detectStargateOft as a0, discoverVaultTopology as a1, encodeBridgeParams as a2, ensureAllowance as a3, executeCuratorBridge as a4, findBridgeRoute as a5, getAllVaultChainIds as a6, getAsyncRequestStatus as a7, getAsyncRequestStatusLabel as a8, getDefaultStorage as a9, getFullVaultTopology as aa, getInboundRoutes as ab, getMaxWithdrawable as ac, getOutboundRoutes as ad, getUserBalances as ae, getUserBalancesForRoutes as af, getUserPosition as ag, getUserPositionMultiChain as ah, getVaultDistribution as ai, getVaultDistributionWithTopology as aj, getVaultMetadata as ak, getVaultStatus as al, getVaultSummary as am, getVaultTopology as an, isAsyncMode as ao, isOnHubChain as ap, loadDepositFlow as aq, previewDeposit as ar, previewRedeem as as, quoteCuratorBridgeFee as at, quoteLzFee as au, quoteRouteDepositFee as av, saveDepositFlow as aw, waitForAsyncRequest as ax, waitForTx as ay, type VaultAnalysis as b, type VaultAssetBreakdown as c, type CuratorAction as d, type SubmitActionsResult as e, type VaultConfiguration as f, type SubVaultInfo as g, type SubVaultPosition as h, type VaultPortfolio as i, ActionType as j, type ActionTypeValue as k, type AssetBalance as l, type AssetInfo as m, type AsyncRequestFinalResult as n, type AsyncRequestStatus as o, type AsyncRequestStatusInfo as p, type BridgeParams as q, type ChainPortfolio as r, type CrossChainRequestInfo as s, type CuratorBridgeParams as t, type DepositBlockReason as u, type DepositEligibility as v, type DepositFlowState as w, type InboundRouteWithBalance as x, type MaxWithdrawable as y, type MultiChainUserPosition as z };
|
|
@@ -414,6 +414,80 @@ interface VaultPortfolio {
|
|
|
414
414
|
lockedAssets: bigint;
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Storage adapter interface (async — supports localStorage today, remote tomorrow).
|
|
419
|
+
* Implement this interface to plug in any storage backend.
|
|
420
|
+
*/
|
|
421
|
+
interface FlowStorage {
|
|
422
|
+
get(key: string): Promise<string | null>;
|
|
423
|
+
set(key: string, value: string): Promise<void>;
|
|
424
|
+
del(key: string): Promise<void>;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Deposit flow state — discriminated union by phase.
|
|
428
|
+
* Persisted after each phase so the flow can be resumed on reload.
|
|
429
|
+
*/
|
|
430
|
+
type DepositFlowState = {
|
|
431
|
+
phase: 'spoke_sent';
|
|
432
|
+
txHash: string;
|
|
433
|
+
/** Partial composeData from depositFromSpoke (message and from resolved later) */
|
|
434
|
+
composeData: Record<string, unknown>;
|
|
435
|
+
/** As decimal string — bigint not JSON-safe */
|
|
436
|
+
startBlock: string;
|
|
437
|
+
vault: string;
|
|
438
|
+
timestamp: number;
|
|
439
|
+
} | {
|
|
440
|
+
phase: 'compose_found';
|
|
441
|
+
/** Full composeData returned by waitForCompose */
|
|
442
|
+
composeData: Record<string, unknown>;
|
|
443
|
+
timestamp: number;
|
|
444
|
+
} | {
|
|
445
|
+
phase: 'hub_sent';
|
|
446
|
+
guid: string;
|
|
447
|
+
vault: string;
|
|
448
|
+
composerSentGuid?: string;
|
|
449
|
+
tokensLocked?: {
|
|
450
|
+
guid: string;
|
|
451
|
+
vault: string;
|
|
452
|
+
token: string;
|
|
453
|
+
amount: string;
|
|
454
|
+
};
|
|
455
|
+
timestamp: number;
|
|
456
|
+
} | {
|
|
457
|
+
phase: 'done';
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* localStorage-backed FlowStorage adapter.
|
|
461
|
+
* Safe to instantiate in any environment — localStorage is only accessed at call time.
|
|
462
|
+
*/
|
|
463
|
+
declare class LocalStorageAdapter implements FlowStorage {
|
|
464
|
+
get(key: string): Promise<string | null>;
|
|
465
|
+
set(key: string, value: string): Promise<void>;
|
|
466
|
+
del(key: string): Promise<void>;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Returns a LocalStorageAdapter when running in a browser environment,
|
|
470
|
+
* or null in Node.js / non-browser environments.
|
|
471
|
+
*
|
|
472
|
+
* Used internally as the default storage — consumers can override by passing
|
|
473
|
+
* their own FlowStorage implementation, or pass null to disable persistence.
|
|
474
|
+
*/
|
|
475
|
+
declare function getDefaultStorage(): FlowStorage | null;
|
|
476
|
+
/**
|
|
477
|
+
* Persist the current deposit flow state for a wallet.
|
|
478
|
+
*/
|
|
479
|
+
declare function saveDepositFlow(storage: FlowStorage, walletAddress: string, state: DepositFlowState): Promise<void>;
|
|
480
|
+
/**
|
|
481
|
+
* Load a pending deposit flow for a wallet.
|
|
482
|
+
* Returns null if there is no state, the flow is done, or the state is older than 24h.
|
|
483
|
+
*/
|
|
484
|
+
declare function loadDepositFlow(storage: FlowStorage, walletAddress: string): Promise<DepositFlowState | null>;
|
|
485
|
+
/**
|
|
486
|
+
* Clear the persisted deposit flow for a wallet.
|
|
487
|
+
* Call this when the flow completes or is explicitly cancelled.
|
|
488
|
+
*/
|
|
489
|
+
declare function clearDepositFlow(storage: FlowStorage, walletAddress: string): Promise<void>;
|
|
490
|
+
|
|
417
491
|
/**
|
|
418
492
|
* Wait for a transaction receipt with generous timeout and retry logic.
|
|
419
493
|
*
|
|
@@ -606,7 +680,10 @@ declare function waitForAsyncRequest(publicClient: PublicClient, vault: Address,
|
|
|
606
680
|
finalized: boolean;
|
|
607
681
|
refunded: boolean;
|
|
608
682
|
result: bigint;
|
|
609
|
-
}) => void
|
|
683
|
+
}) => void, options?: {
|
|
684
|
+
storage?: FlowStorage | null;
|
|
685
|
+
walletAddress?: Address;
|
|
686
|
+
}): Promise<AsyncRequestFinalResult>;
|
|
610
687
|
/**
|
|
611
688
|
* Detect whether an OFT address is a Stargate V2 pool by calling `stargateType()`.
|
|
612
689
|
*
|
|
@@ -1189,4 +1266,4 @@ declare function quoteCuratorBridgeFee(publicClient: PublicClient, vault: Addres
|
|
|
1189
1266
|
*/
|
|
1190
1267
|
declare function executeCuratorBridge(walletClient: WalletClient, publicClient: PublicClient, vault: Address, token: Address, params: CuratorBridgeParams): Promise<Hash>;
|
|
1191
1268
|
|
|
1192
|
-
export {
|
|
1269
|
+
export { clearDepositFlow as $, type AsyncRequestResult as A, type BatchSwapParams as B, type ComposeData as C, type DepositResult as D, type ERC7540RequestStatus as E, type FlowStorage as F, type OutboundRoute as G, type SpokeBalance as H, type InboundRoute as I, type SwapParams as J, type UserPosition as K, LocalStorageAdapter as L, type MultiChainPortfolio as M, NATIVE_SYMBOL as N, OMNI_FACTORY_ADDRESS as O, type PendingAction as P, type VaultDistribution as Q, type RedeemResult as R, type SpokeDepositResult as S, type VaultMetadata as T, type UserBalances as U, type VaultAddresses as V, type VaultMode as W, type VaultStatus as X, type VaultSummary as Y, type VaultTopology as Z, canDeposit as _, type CuratorVaultStatus as a, detectStargateOft as a0, discoverVaultTopology as a1, encodeBridgeParams as a2, ensureAllowance as a3, executeCuratorBridge as a4, findBridgeRoute as a5, getAllVaultChainIds as a6, getAsyncRequestStatus as a7, getAsyncRequestStatusLabel as a8, getDefaultStorage as a9, getFullVaultTopology as aa, getInboundRoutes as ab, getMaxWithdrawable as ac, getOutboundRoutes as ad, getUserBalances as ae, getUserBalancesForRoutes as af, getUserPosition as ag, getUserPositionMultiChain as ah, getVaultDistribution as ai, getVaultDistributionWithTopology as aj, getVaultMetadata as ak, getVaultStatus as al, getVaultSummary as am, getVaultTopology as an, isAsyncMode as ao, isOnHubChain as ap, loadDepositFlow as aq, previewDeposit as ar, previewRedeem as as, quoteCuratorBridgeFee as at, quoteLzFee as au, quoteRouteDepositFee as av, saveDepositFlow as aw, waitForAsyncRequest as ax, waitForTx as ay, type VaultAnalysis as b, type VaultAssetBreakdown as c, type CuratorAction as d, type SubmitActionsResult as e, type VaultConfiguration as f, type SubVaultInfo as g, type SubVaultPosition as h, type VaultPortfolio as i, ActionType as j, type ActionTypeValue as k, type AssetBalance as l, type AssetInfo as m, type AsyncRequestFinalResult as n, type AsyncRequestStatus as o, type AsyncRequestStatusInfo as p, type BridgeParams as q, type ChainPortfolio as r, type CrossChainRequestInfo as s, type CuratorBridgeParams as t, type DepositBlockReason as u, type DepositEligibility as v, type DepositFlowState as w, type InboundRouteWithBalance as x, type MaxWithdrawable as y, type MultiChainUserPosition as z };
|
package/dist/react/index.cjs
CHANGED
|
@@ -1285,6 +1285,8 @@ var UnsupportedAssetError = class extends MoreVaultsError {
|
|
|
1285
1285
|
this.asset = asset;
|
|
1286
1286
|
}
|
|
1287
1287
|
};
|
|
1288
|
+
|
|
1289
|
+
// src/viem/utils.ts
|
|
1288
1290
|
async function waitForTx(publicClient, hash, maxRetries = 3) {
|
|
1289
1291
|
const timeouts = [6e4, 12e4, 18e4];
|
|
1290
1292
|
for (let i = 0; i < maxRetries; i++) {
|