@0xmonaco/react 0.7.3 → 0.7.5
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.
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { TransactionResult } from "@0xmonaco/types";
|
|
1
|
+
import type { TransactionResult, WithdrawResult } from "@0xmonaco/types";
|
|
2
2
|
export interface UseVaultReturn {
|
|
3
3
|
/** Approve the vault to spend tokens */
|
|
4
4
|
approve: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<TransactionResult>;
|
|
5
5
|
/** Deposit tokens into the vault */
|
|
6
6
|
deposit: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<TransactionResult>;
|
|
7
|
-
/**
|
|
8
|
-
withdraw: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<
|
|
7
|
+
/** Initiate a withdrawal and submit the pre-signed calldata on-chain */
|
|
8
|
+
withdraw: (assetId: string, amount: bigint, autoWait?: boolean) => Promise<WithdrawResult>;
|
|
9
|
+
/** Retry a withdrawal whose on-chain submission never landed — does NOT create a new one */
|
|
10
|
+
retryWithdrawal: (withdrawalIndex: number, autoWait?: boolean) => Promise<WithdrawResult>;
|
|
9
11
|
/** Get the allowance for a token */
|
|
10
12
|
getAllowance: (assetId: string) => Promise<bigint>;
|
|
11
13
|
/** Check if a token needs approval for an amount */
|
|
@@ -29,6 +29,14 @@ export const useVault = () => {
|
|
|
29
29
|
throw new Error("Amount must be greater than 0");
|
|
30
30
|
return await sdk.vault.withdraw(assetId, amount, autoWait);
|
|
31
31
|
}, [sdk]);
|
|
32
|
+
const retryWithdrawal = useCallback(async (withdrawalIndex, autoWait) => {
|
|
33
|
+
if (!sdk)
|
|
34
|
+
throw new Error("SDK not available");
|
|
35
|
+
if (!Number.isInteger(withdrawalIndex) || withdrawalIndex < 0) {
|
|
36
|
+
throw new Error("withdrawalIndex must be a non-negative integer");
|
|
37
|
+
}
|
|
38
|
+
return await sdk.vault.retryWithdrawal(withdrawalIndex, autoWait);
|
|
39
|
+
}, [sdk]);
|
|
32
40
|
const getAllowance = useCallback(async (assetId) => {
|
|
33
41
|
if (!sdk)
|
|
34
42
|
throw new Error("SDK not available");
|
|
@@ -50,6 +58,7 @@ export const useVault = () => {
|
|
|
50
58
|
approve,
|
|
51
59
|
deposit,
|
|
52
60
|
withdraw,
|
|
61
|
+
retryWithdrawal,
|
|
53
62
|
// Approval and allowance queries
|
|
54
63
|
getAllowance,
|
|
55
64
|
needsApproval,
|