@0xmonaco/types 0.7.3 → 0.7.4
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.
|
@@ -46,11 +46,16 @@ export declare const DepositSchema: z.ZodObject<{
|
|
|
46
46
|
autoWait: z.ZodOptional<z.ZodBoolean>;
|
|
47
47
|
}, z.core.$strip>;
|
|
48
48
|
/**
|
|
49
|
-
* Withdraw validation schema
|
|
49
|
+
* Withdraw validation schema.
|
|
50
|
+
*
|
|
51
|
+
* The SDK calls the gateway to allocate the `withdrawalIndex` and obtain
|
|
52
|
+
* pre-signed calldata, then submits that calldata via the connected wallet.
|
|
53
|
+
* `autoWait` controls whether the SDK awaits on-chain confirmation.
|
|
50
54
|
*/
|
|
51
55
|
export declare const WithdrawSchema: z.ZodObject<{
|
|
52
56
|
assetId: z.ZodUUID;
|
|
53
57
|
amount: z.ZodUnion<readonly [z.ZodString, z.ZodBigInt]>;
|
|
58
|
+
destination: z.ZodString;
|
|
54
59
|
autoWait: z.ZodOptional<z.ZodBoolean>;
|
|
55
60
|
}, z.core.$strip>;
|
|
56
61
|
/**
|
package/dist/validation/vault.js
CHANGED
|
@@ -59,11 +59,16 @@ export const DepositSchema = z.object({
|
|
|
59
59
|
autoWait: z.boolean().optional(),
|
|
60
60
|
});
|
|
61
61
|
/**
|
|
62
|
-
* Withdraw validation schema
|
|
62
|
+
* Withdraw validation schema.
|
|
63
|
+
*
|
|
64
|
+
* The SDK calls the gateway to allocate the `withdrawalIndex` and obtain
|
|
65
|
+
* pre-signed calldata, then submits that calldata via the connected wallet.
|
|
66
|
+
* `autoWait` controls whether the SDK awaits on-chain confirmation.
|
|
63
67
|
*/
|
|
64
68
|
export const WithdrawSchema = z.object({
|
|
65
69
|
assetId: UUIDSchema,
|
|
66
70
|
amount: PositiveBigIntStringSchema,
|
|
71
|
+
destination: z.string().regex(/^0x[a-fA-F0-9]{40}$/, "destination must be a 0x-prefixed 20-byte hex address"),
|
|
67
72
|
autoWait: z.boolean().optional(),
|
|
68
73
|
});
|
|
69
74
|
/**
|
package/dist/vault/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Types for vault operations including deposits, withdrawals, and balance management.
|
|
5
5
|
*/
|
|
6
6
|
import type { BaseAPI } from "../api/index";
|
|
7
|
-
import type { Balance, TransactionResult } from "./responses";
|
|
7
|
+
import type { Balance, TransactionResult, WithdrawResult } from "./responses";
|
|
8
8
|
/**
|
|
9
9
|
* Vault API interface.
|
|
10
10
|
* Provides methods for managing token deposits and withdrawals.
|
|
@@ -28,13 +28,27 @@ export interface VaultAPI extends BaseAPI {
|
|
|
28
28
|
*/
|
|
29
29
|
deposit(assetId: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Initiates a withdrawal: allocates a `withdrawalIndex` via the API Gateway,
|
|
32
|
+
* receives pre-signed calldata for `executeSignedWithdrawal(...)`, and
|
|
33
|
+
* submits it on-chain through the connected wallet.
|
|
34
|
+
*
|
|
32
35
|
* @param assetId - Asset identifier (UUID) to withdraw
|
|
33
|
-
* @param amount -
|
|
34
|
-
* @param autoWait - Whether to
|
|
35
|
-
* @returns Promise resolving to
|
|
36
|
+
* @param amount - Raw token amount (smallest unit, as bigint)
|
|
37
|
+
* @param autoWait - Whether to await on-chain confirmation (defaults to true)
|
|
38
|
+
* @returns Promise resolving to `{ withdrawalIndex, transaction }`
|
|
39
|
+
*/
|
|
40
|
+
withdraw(assetId: string, amount: bigint, autoWait?: boolean): Promise<WithdrawResult>;
|
|
41
|
+
/**
|
|
42
|
+
* Retries a previously-initiated withdrawal whose on-chain submission never
|
|
43
|
+
* landed (wallet rejected, page reloaded before receipt, stuck mempool).
|
|
44
|
+
* Re-fetches the same signed calldata and resubmits via the connected wallet
|
|
45
|
+
* — does NOT initiate a new withdrawal.
|
|
46
|
+
*
|
|
47
|
+
* @param withdrawalIndex - Index returned by the original `withdraw()` call
|
|
48
|
+
* @param autoWait - Whether to await on-chain confirmation (defaults to true)
|
|
49
|
+
* @returns Promise resolving to `{ withdrawalIndex, ...transaction }`
|
|
36
50
|
*/
|
|
37
|
-
|
|
51
|
+
retryWithdrawal(withdrawalIndex: number, autoWait?: boolean): Promise<WithdrawResult>;
|
|
38
52
|
/**
|
|
39
53
|
* Gets the balance of a token in the vault.
|
|
40
54
|
* @param assetId - Asset identifier (UUID) to check
|
|
@@ -67,4 +81,4 @@ export interface VaultAPI extends BaseAPI {
|
|
|
67
81
|
*/
|
|
68
82
|
setWalletClient(walletClient: unknown): void;
|
|
69
83
|
}
|
|
70
|
-
export type { Balance, TransactionResult } from "./responses";
|
|
84
|
+
export type { Balance, TransactionResult, WithdrawResult } from "./responses";
|
|
@@ -16,6 +16,24 @@ export interface TransactionResult {
|
|
|
16
16
|
/** Transaction receipt (only available when autoWait is enabled) */
|
|
17
17
|
receipt?: import("viem").TransactionReceipt;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Result of initiating a withdrawal.
|
|
21
|
+
*
|
|
22
|
+
* The API gateway allocates a `withdrawalIndex` via the matching engine and
|
|
23
|
+
* returns pre-signed calldata for the vault contract's
|
|
24
|
+
* `executeSignedWithdrawal(...)` function. The SDK submits that calldata on
|
|
25
|
+
* behalf of the connected wallet — the user is the on-chain caller, but the
|
|
26
|
+
* `WITHDRAWAL_SIGNER` signature embedded in the calldata is what the contract
|
|
27
|
+
* authenticates against.
|
|
28
|
+
*
|
|
29
|
+
* Extends [`TransactionResult`] so callers can read `hash`, `status`, `nonce`
|
|
30
|
+
* (and `receipt` when `autoWait` is true) directly off the result, just like
|
|
31
|
+
* `approve` / `deposit`.
|
|
32
|
+
*/
|
|
33
|
+
export interface WithdrawResult extends TransactionResult {
|
|
34
|
+
/** Allocated withdrawal index — matches `executeSignedWithdrawal.index`. */
|
|
35
|
+
withdrawalIndex: number;
|
|
36
|
+
}
|
|
19
37
|
/**
|
|
20
38
|
* Token balance information.
|
|
21
39
|
*/
|