@symmio/trading-react 4.4.0 → 4.5.0

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.
Files changed (175) hide show
  1. package/dist/account-layer/automatic-timelock-attempt.d.ts +11 -0
  2. package/dist/account-layer/automatic-timelock-attempt.d.ts.map +1 -0
  3. package/dist/account-layer/automatic-timelock-attempt.js +41 -0
  4. package/dist/account-layer/automatic-timelock-attempt.js.map +1 -0
  5. package/dist/account-layer/index.d.ts +9 -0
  6. package/dist/account-layer/index.d.ts.map +1 -1
  7. package/dist/account-layer/index.js +41 -32
  8. package/dist/account-layer/use-active-virtual-account-by-key.d.ts +33 -0
  9. package/dist/account-layer/use-active-virtual-account-by-key.d.ts.map +1 -0
  10. package/dist/account-layer/use-active-virtual-account-by-key.js +27 -0
  11. package/dist/account-layer/use-active-virtual-account-by-key.js.map +1 -0
  12. package/dist/account-layer/use-add-margin.d.ts +2 -2
  13. package/dist/account-layer/use-add-margin.d.ts.map +1 -1
  14. package/dist/account-layer/use-add-margin.js +28 -17
  15. package/dist/account-layer/use-add-margin.js.map +1 -1
  16. package/dist/account-layer/use-allocate.d.ts +2 -2
  17. package/dist/account-layer/use-allocate.d.ts.map +1 -1
  18. package/dist/account-layer/use-allocate.js +28 -17
  19. package/dist/account-layer/use-allocate.js.map +1 -1
  20. package/dist/account-layer/use-automatic-timelock-recovery.d.ts +25 -0
  21. package/dist/account-layer/use-automatic-timelock-recovery.d.ts.map +1 -0
  22. package/dist/account-layer/use-automatic-timelock-recovery.js +26 -0
  23. package/dist/account-layer/use-automatic-timelock-recovery.js.map +1 -0
  24. package/dist/account-layer/use-automatic-timelock.d.ts +48 -0
  25. package/dist/account-layer/use-automatic-timelock.d.ts.map +1 -0
  26. package/dist/account-layer/use-automatic-timelock.js +189 -0
  27. package/dist/account-layer/use-automatic-timelock.js.map +1 -0
  28. package/dist/account-layer/use-create-sub-accounts.d.ts +9 -4
  29. package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
  30. package/dist/account-layer/use-create-sub-accounts.js +11 -13
  31. package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
  32. package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts +3 -3
  33. package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
  34. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +32 -21
  35. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
  36. package/dist/account-layer/use-deallocate.d.ts +6 -5
  37. package/dist/account-layer/use-deallocate.d.ts.map +1 -1
  38. package/dist/account-layer/use-deallocate.js +33 -20
  39. package/dist/account-layer/use-deallocate.js.map +1 -1
  40. package/dist/account-layer/use-delete-sub-account.d.ts +2 -2
  41. package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
  42. package/dist/account-layer/use-delete-sub-account.js +30 -19
  43. package/dist/account-layer/use-delete-sub-account.js.map +1 -1
  44. package/dist/account-layer/use-execute-account-calls.d.ts +7 -0
  45. package/dist/account-layer/use-execute-account-calls.d.ts.map +1 -0
  46. package/dist/account-layer/use-execute-account-calls.js +54 -0
  47. package/dist/account-layer/use-execute-account-calls.js.map +1 -0
  48. package/dist/account-layer/use-protected-function.d.ts +22 -0
  49. package/dist/account-layer/use-protected-function.d.ts.map +1 -0
  50. package/dist/account-layer/use-protected-function.js +68 -0
  51. package/dist/account-layer/use-protected-function.js.map +1 -0
  52. package/dist/account-layer/use-remove-margin.d.ts +2 -2
  53. package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
  54. package/dist/account-layer/use-remove-margin.js +31 -20
  55. package/dist/account-layer/use-remove-margin.js.map +1 -1
  56. package/dist/account-layer/use-timelock-policy.d.ts +21 -0
  57. package/dist/account-layer/use-timelock-policy.d.ts.map +1 -0
  58. package/dist/account-layer/use-timelock-policy.js +112 -0
  59. package/dist/account-layer/use-timelock-policy.js.map +1 -0
  60. package/dist/account-layer/use-timelock-route.d.ts +75 -0
  61. package/dist/account-layer/use-timelock-route.d.ts.map +1 -0
  62. package/dist/account-layer/use-timelock-route.js +177 -0
  63. package/dist/account-layer/use-timelock-route.js.map +1 -0
  64. package/dist/account-layer/use-timelock.d.ts +102 -0
  65. package/dist/account-layer/use-timelock.d.ts.map +1 -0
  66. package/dist/account-layer/use-timelock.js +177 -0
  67. package/dist/account-layer/use-timelock.js.map +1 -0
  68. package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts +24 -0
  69. package/dist/account-layer/use-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
  70. package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js +27 -0
  71. package/dist/account-layer/use-virtual-accounts-count-of-sub-account.js.map +1 -0
  72. package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts +25 -0
  73. package/dist/account-layer/use-virtual-accounts-of-sub-account.d.ts.map +1 -0
  74. package/dist/account-layer/use-virtual-accounts-of-sub-account.js +27 -0
  75. package/dist/account-layer/use-virtual-accounts-of-sub-account.js.map +1 -0
  76. package/dist/errors/normalize-protected-write-error.d.ts +5 -0
  77. package/dist/errors/normalize-protected-write-error.d.ts.map +1 -0
  78. package/dist/errors/normalize-protected-write-error.js +43 -0
  79. package/dist/errors/normalize-protected-write-error.js.map +1 -0
  80. package/dist/errors/normalize-symm-error.d.ts.map +1 -1
  81. package/dist/errors/normalize-symm-error.js +56 -43
  82. package/dist/errors/normalize-symm-error.js.map +1 -1
  83. package/dist/errors/symmio-request-error.d.ts +5 -0
  84. package/dist/errors/symmio-request-error.d.ts.map +1 -1
  85. package/dist/errors/symmio-request-error.js +2 -1
  86. package/dist/errors/symmio-request-error.js.map +1 -1
  87. package/dist/gasless/index.d.ts +1 -0
  88. package/dist/gasless/index.d.ts.map +1 -1
  89. package/dist/gasless/index.js +20 -19
  90. package/dist/gasless/invalidate-relay-reads.d.ts +3 -1
  91. package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -1
  92. package/dist/gasless/invalidate-relay-reads.js +115 -60
  93. package/dist/gasless/invalidate-relay-reads.js.map +1 -1
  94. package/dist/gasless/use-approve-operational-fee-allowance.d.ts +37 -0
  95. package/dist/gasless/use-approve-operational-fee-allowance.d.ts.map +1 -0
  96. package/dist/gasless/use-approve-operational-fee-allowance.js +48 -0
  97. package/dist/gasless/use-approve-operational-fee-allowance.js.map +1 -0
  98. package/dist/gasless/use-approve-operational-fee.d.ts +2 -2
  99. package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -1
  100. package/dist/gasless/use-approve-operational-fee.js +28 -17
  101. package/dist/gasless/use-approve-operational-fee.js.map +1 -1
  102. package/dist/gasless/use-relay-gasless-batch.d.ts +5 -4
  103. package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -1
  104. package/dist/gasless/use-relay-gasless-batch.js.map +1 -1
  105. package/dist/index.d.ts +13 -7
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +271 -256
  108. package/dist/instant-layer/index.d.ts +2 -0
  109. package/dist/instant-layer/index.d.ts.map +1 -1
  110. package/dist/instant-layer/index.js +25 -23
  111. package/dist/instant-layer/invalidate-delegation-grant.d.ts +17 -0
  112. package/dist/instant-layer/invalidate-delegation-grant.d.ts.map +1 -0
  113. package/dist/instant-layer/invalidate-delegation-grant.js +26 -0
  114. package/dist/instant-layer/invalidate-delegation-grant.js.map +1 -0
  115. package/dist/instant-layer/use-grant-delegation.d.ts +3 -1
  116. package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
  117. package/dist/instant-layer/use-grant-delegation.js +19 -28
  118. package/dist/instant-layer/use-grant-delegation.js.map +1 -1
  119. package/dist/instant-layer/use-grant-delegations.d.ts +44 -0
  120. package/dist/instant-layer/use-grant-delegations.d.ts.map +1 -0
  121. package/dist/instant-layer/use-grant-delegations.js +36 -0
  122. package/dist/instant-layer/use-grant-delegations.js.map +1 -0
  123. package/dist/instant-layer/use-instant-close-fees.js +8 -8
  124. package/dist/instant-layer/use-instant-open-inputs.js +8 -8
  125. package/dist/instant-layer/use-session-key-selectors.d.ts +5 -2
  126. package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -1
  127. package/dist/instant-layer/use-session-key-selectors.js +9 -5
  128. package/dist/instant-layer/use-session-key-selectors.js.map +1 -1
  129. package/dist/instant-layer/use-simulate-grant-delegations.d.ts +25 -0
  130. package/dist/instant-layer/use-simulate-grant-delegations.d.ts.map +1 -0
  131. package/dist/instant-layer/use-simulate-grant-delegations.js +29 -0
  132. package/dist/instant-layer/use-simulate-grant-delegations.js.map +1 -0
  133. package/dist/provider/symmio-provider.d.ts +31 -4
  134. package/dist/provider/symmio-provider.d.ts.map +1 -1
  135. package/dist/provider/symmio-provider.js +12 -11
  136. package/dist/provider/symmio-provider.js.map +1 -1
  137. package/dist/solvers/timelock-capability-cache.d.ts +9 -0
  138. package/dist/solvers/timelock-capability-cache.d.ts.map +1 -0
  139. package/dist/solvers/timelock-capability-cache.js +79 -0
  140. package/dist/solvers/timelock-capability-cache.js.map +1 -0
  141. package/dist/solvers/use-solver-info.d.ts +5 -2
  142. package/dist/solvers/use-solver-info.d.ts.map +1 -1
  143. package/dist/solvers/use-solver-info.js +35 -11
  144. package/dist/solvers/use-solver-info.js.map +1 -1
  145. package/dist/transactions/write-types.d.ts +13 -1
  146. package/dist/transactions/write-types.d.ts.map +1 -1
  147. package/dist/withdraw/index.d.ts +3 -0
  148. package/dist/withdraw/index.d.ts.map +1 -1
  149. package/dist/withdraw/use-deallocate-debounce-time.d.ts +29 -0
  150. package/dist/withdraw/use-deallocate-debounce-time.d.ts.map +1 -0
  151. package/dist/withdraw/use-deallocate-debounce-time.js +27 -0
  152. package/dist/withdraw/use-deallocate-debounce-time.js.map +1 -0
  153. package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
  154. package/dist/withdraw/use-finalize-withdraw-request.js +13 -12
  155. package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
  156. package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
  157. package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
  158. package/dist/withdraw/use-initiate-withdraw.js +29 -17
  159. package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
  160. package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts +19 -0
  161. package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts.map +1 -0
  162. package/dist/withdraw/use-pending-withdraw-requests-batch.js +27 -0
  163. package/dist/withdraw/use-pending-withdraw-requests-batch.js.map +1 -0
  164. package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
  165. package/dist/withdraw/use-request-cancel-withdraw.js +14 -13
  166. package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
  167. package/dist/withdraw/use-withdraw-cooldown-of.d.ts +33 -0
  168. package/dist/withdraw/use-withdraw-cooldown-of.d.ts.map +1 -0
  169. package/dist/withdraw/use-withdraw-cooldown-of.js +27 -0
  170. package/dist/withdraw/use-withdraw-cooldown-of.js.map +1 -0
  171. package/dist/withdraw/use-withdraw.d.ts +3 -3
  172. package/dist/withdraw/use-withdraw.d.ts.map +1 -1
  173. package/dist/withdraw/use-withdraw.js +57 -31
  174. package/dist/withdraw/use-withdraw.js.map +1 -1
  175. package/package.json +2 -2
@@ -0,0 +1,48 @@
1
+ import { Config, TimelockApprovalCapability, TimelockAuthorization, TimelockBatchAuthorization } from '@symmio/trading-core';
2
+ import { Address } from 'viem';
3
+ import { AutomaticTimelockWriteParameters } from '../transactions/write-types.js';
4
+ /** Resolve an automatic authorization once per mutation variables object. */
5
+ export declare function useAutomaticTimelock(config: Config, options?: AutomaticTimelockWriteParameters["automaticTimelock"], boundAccount?: Address): ((variables: object, parameters: {
6
+ account: Address;
7
+ chainId: number;
8
+ functionName: string;
9
+ slot?: number;
10
+ explicit?: TimelockAuthorization;
11
+ }) => Promise<TimelockAuthorization | undefined> | Promise<{
12
+ capability: TimelockApprovalCapability;
13
+ provider: {
14
+ requestApproval: (request: import('@symmio/trading-core').TimelockApprovalRequestPayload, requestOptions: {
15
+ signal?: AbortSignal;
16
+ } | undefined) => Promise<import('@symmio/trading-core').TimelockApprovalResponse>;
17
+ };
18
+ deadline: bigint;
19
+ onApproval: (approval: import('@symmio/trading-core').ValidatedTimelockApproval) => Promise<void>;
20
+ } | undefined>) & {
21
+ batch: (variables: object, parameters: {
22
+ account: Address;
23
+ chainId: number;
24
+ functionNames: readonly string[];
25
+ }) => Promise<TimelockBatchAuthorization | undefined> | Promise<{
26
+ calls: (TimelockAuthorization | {
27
+ capability: TimelockApprovalCapability;
28
+ provider: {
29
+ requestApproval: (request: import('@symmio/trading-core').TimelockApprovalRequestPayload, requestOptions: {
30
+ signal?: AbortSignal;
31
+ } | undefined) => Promise<import('@symmio/trading-core').TimelockApprovalResponse>;
32
+ };
33
+ deadline: bigint;
34
+ onApproval: (approval: import('@symmio/trading-core').ValidatedTimelockApproval) => Promise<void>;
35
+ } | undefined)[];
36
+ } | undefined>;
37
+ finish: (variables: object, result: {
38
+ receipt?: {
39
+ status: string;
40
+ };
41
+ }) => void;
42
+ fail: (variables: object, error: unknown) => void;
43
+ guard: (variables: object, parameters: {
44
+ account: Address;
45
+ chainId: number;
46
+ }) => Promise<void>;
47
+ };
48
+ //# sourceMappingURL=use-automatic-timelock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-automatic-timelock.d.ts","sourceRoot":"","sources":["../../src/account-layer/use-automatic-timelock.ts"],"names":[],"mappings":"AAEA,OAAO,EAaL,KAAK,MAAM,EAEX,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAOjE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAQpF,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,gCAAgC,CAAC,mBAAmB,CAAQ,EACrE,YAAY,CAAC,EAAE,OAAO,gBAmFT,MAAM,cACL;IACV,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;;;;;;;;;;uBA0IU,MAAM,cACL;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;;;;;;;;;;;;wBAiB1D,MAAM,UAAU;QAAE,OAAO,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;sBAIlD,MAAM,SAAS,OAAO;uBA7Lf,MAAM,cAAc;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;EAyM1F"}
@@ -0,0 +1,189 @@
1
+ "use client";
2
+ import { refreshTimelockInfoAfterUnavailable as e, rememberTimelockCapability as t, timelockCapabilityKey as n } from "../solvers/timelock-capability-cache.js";
3
+ import { automaticAttemptKey as r, deploymentHasAutomaticAttempt as i, finishAutomaticAttempt as a, reserveAutomaticAttempt as o } from "./automatic-timelock-attempt.js";
4
+ import { INSTANT_OPEN_TIMELOCK_ACCOUNT_LAYER_FUNCTIONS as s, INSTANT_OPEN_TIMELOCK_CORE_FUNCTIONS as c, INSTANT_OPEN_TIMELOCK_SELECTORS as l, SymmError as u, createHttpTimelockApprovalProvider as d, getSelectorTimelockQueryOptions as f, getSolverInfoQueryOptions as p, getTimelockPolicyQueryOptions as m, getVirtualAccountQueryOptions as h, isDefiniteTimelockApprovalRejection as g, isUnsubmittedTimelockWalletRejection as _, resolveTimelockFamilyAccount as v } from "@symmio/trading-core";
5
+ import { isAddressEqual as y, zeroAddress as b } from "viem";
6
+ import { useEffect as x, useRef as S } from "react";
7
+ import { useConnection as C } from "wagmi";
8
+ import { useQueryClient as w } from "@tanstack/react-query";
9
+ //#region src/account-layer/use-automatic-timelock.ts
10
+ function T(T, E = !0, D) {
11
+ let O = w(), k = C(), A = S(!0);
12
+ x(() => (A.current = !0, () => {
13
+ A.current = !1;
14
+ }), []);
15
+ let j = S(/* @__PURE__ */ new WeakMap()), M = S(/* @__PURE__ */ new WeakMap()), N = S(/* @__PURE__ */ new WeakMap()), P = typeof E == "object" ? E : void 0, F = P ? JSON.stringify([
16
+ P.capability.unlocker.toLowerCase(),
17
+ P.capability.minTimelockDelaySeconds,
18
+ P.capability.validitySeconds,
19
+ P.capability.requestDomain.name,
20
+ P.capability.requestDomain.version,
21
+ String(P.capability.requestDomain.chainId),
22
+ P.capability.requestDomain.verifyingContract.toLowerCase(),
23
+ P.deadline?.toString()
24
+ ]) : String(E), I = P?.provider, L = `${k.chainId ?? ""}:${k.address?.toLowerCase() ?? ""}:${D?.toLowerCase() ?? ""}`, R = S({
25
+ config: T,
26
+ fingerprint: F,
27
+ providerIdentity: I,
28
+ walletScope: L,
29
+ revision: 0
30
+ });
31
+ (R.current.config !== T || R.current.fingerprint !== F || R.current.providerIdentity !== I || R.current.walletScope !== L) && (R.current = {
32
+ config: T,
33
+ fingerprint: F,
34
+ providerIdentity: I,
35
+ walletScope: L,
36
+ revision: R.current.revision + 1
37
+ });
38
+ let z = S(/* @__PURE__ */ new WeakMap());
39
+ function B(e, t) {
40
+ if (!A.current) throw new u("validation", "TIMELOCK_RECONCILIATION_REQUIRED", "The operation's context was unmounted. Reconcile the previous attempt before continuing.");
41
+ let n = z.current.get(e), r = `${R.current.revision}:${t.chainId}:${t.account.toLowerCase()}`;
42
+ if (n !== void 0 && n !== r) throw new u("validation", "TIMELOCK_RECONCILIATION_REQUIRED", "The timelock configuration changed during this operation. Reconcile the previous attempt before continuing.");
43
+ z.current.set(e, r);
44
+ }
45
+ async function V(e, t) {
46
+ B(e, t);
47
+ let n = T.getChainConfig(t.chainId);
48
+ if (!i(O, t.chainId, n.addresses.accountLayerAddress)) return;
49
+ let a = await O.fetchQuery({
50
+ ...h(T, {
51
+ chainId: t.chainId,
52
+ account: t.account
53
+ }),
54
+ retry: !1
55
+ });
56
+ B(e, t);
57
+ let o = v(t.account, a);
58
+ if (O.getQueryData(r(t.chainId, n.addresses.accountLayerAddress, o))) throw new u("validation", "TIMELOCK_RECONCILIATION_REQUIRED", "A previous timelock operation is pending or requires reconciliation.");
59
+ }
60
+ function H(i, a) {
61
+ if (E === !1 && !z.current.has(i)) return Promise.resolve(void 0);
62
+ if (B(i, a), a.explicit) return Promise.resolve(a.explicit);
63
+ if (E === !1) return Promise.resolve(void 0);
64
+ let g = `${a.chainId}:${a.account.toLowerCase()}:${a.functionName}:${a.slot ?? "single"}`, _ = j.current.get(i);
65
+ _ || (_ = /* @__PURE__ */ new Map(), j.current.set(i, _));
66
+ let x = _.get(g);
67
+ if (x) return x;
68
+ let S = (async () => {
69
+ await V(i, a);
70
+ let g = [...c, ...s].indexOf(a.functionName);
71
+ if (g < 0) return;
72
+ let _ = T.getChainConfig(a.chainId), x = T.getSolver({ chainId: a.chainId });
73
+ if (_.timelockSupported === !1 || x.capabilities?.timelockApproval === !1) return;
74
+ let S = p(T, {
75
+ chainId: a.chainId,
76
+ solverId: x.id
77
+ }), C = n(T, a.chainId, x.id);
78
+ async function w() {
79
+ let e = await O.fetchQuery({
80
+ ...h(T, {
81
+ chainId: a.chainId,
82
+ account: a.account
83
+ }),
84
+ retry: !1,
85
+ staleTime: 0
86
+ }), t = v(a.account, e), n = await O.fetchQuery({
87
+ ...f(T, {
88
+ chainId: a.chainId,
89
+ account: t,
90
+ selector: l[g]
91
+ }),
92
+ retry: !1,
93
+ staleTime: 0
94
+ });
95
+ return B(i, a), y(n.unlocker, b);
96
+ }
97
+ if (!P && x.id !== "enigma") {
98
+ if (x.capabilities?.timelockApproval !== !0 || await w()) return;
99
+ throw new u("config", "TIMELOCK_PROVIDER_REQUIRED", "Supply an explicit timelock authorization for this solver.");
100
+ }
101
+ let E = P?.capability ?? O.getQueryData(C);
102
+ if (!E && !P && (E = O.getQueryData(S.queryKey)?.timelockApproval, t(O, C, E)), !E) try {
103
+ E = (await O.fetchQuery({
104
+ ...S,
105
+ retry: !1,
106
+ staleTime: 0
107
+ })).timelockApproval, t(O, C, E);
108
+ } catch (e) {
109
+ try {
110
+ if (await w()) return;
111
+ } catch {}
112
+ throw e;
113
+ }
114
+ if (B(i, a), !E) {
115
+ if (await w()) return;
116
+ throw new u("config", "TIMELOCK_PROVIDER_REQUIRED", "The selector is timelocked, but the solver did not provide timelock metadata.");
117
+ }
118
+ let D = m(T, {
119
+ account: a.account,
120
+ chainId: a.chainId,
121
+ solverId: x.id,
122
+ capability: E,
123
+ selectors: [l[g]]
124
+ }), k = await O.fetchQuery({
125
+ ...D,
126
+ retry: !1,
127
+ staleTime: 0
128
+ });
129
+ if (B(i, a), k.selectors[0]?.status === "missing") return;
130
+ if (!k.ready) throw new u("validation", "TIMELOCK_POLICY_NOT_READY", "The account's timelock policy does not match the solver.");
131
+ let A = await T.getClient({ chainId: a.chainId }).getBlock();
132
+ B(i, a);
133
+ let j = P?.provider ?? d({ baseUrl: x.url }), M = N.current.get(i);
134
+ M || (M = {
135
+ token: {},
136
+ issued: 0
137
+ }, N.current.set(i, M));
138
+ let F = M, I = r(a.chainId, _.addresses.accountLayerAddress, k.rootAccount);
139
+ return {
140
+ capability: E,
141
+ provider: { requestApproval: async (t, n) => {
142
+ B(i, a), o(O, I, F.token), F.key = I;
143
+ try {
144
+ let e = await j.requestApproval(t, n);
145
+ return F.issued += 1, e;
146
+ } catch (t) {
147
+ throw P?.provider || e(O, T, a.chainId, x.id, t), t;
148
+ }
149
+ } },
150
+ deadline: P?.deadline ?? A.timestamp + 300n,
151
+ onApproval: async (e) => {
152
+ await P?.onApproval?.(e), B(i, a);
153
+ }
154
+ };
155
+ })();
156
+ return _.set(g, S), S;
157
+ }
158
+ function U(e, t) {
159
+ B(e, t);
160
+ let n = `${t.chainId}:${t.account.toLowerCase()}:${t.functionNames.join(",")}`, r = M.current.get(e);
161
+ r || (r = /* @__PURE__ */ new Map(), M.current.set(e, r));
162
+ let i = r.get(n);
163
+ if (i) return i;
164
+ let a = Promise.all(t.functionNames.map((n, r) => H(e, {
165
+ ...t,
166
+ functionName: n,
167
+ slot: r
168
+ }))).then((e) => e.some(Boolean) ? { calls: e } : void 0);
169
+ return r.set(n, a), a;
170
+ }
171
+ function W(e, t) {
172
+ let n = N.current.get(e);
173
+ n?.key && a(O, n.key, n.token, t.receipt?.status === "success");
174
+ }
175
+ function G(e, t) {
176
+ let n = N.current.get(e);
177
+ n?.key && a(O, n.key, n.token, n.issued === 0 && g(t) || _(t));
178
+ }
179
+ return Object.assign(H, {
180
+ batch: U,
181
+ finish: W,
182
+ fail: G,
183
+ guard: V
184
+ });
185
+ }
186
+ //#endregion
187
+ export { T as useAutomaticTimelock };
188
+
189
+ //# sourceMappingURL=use-automatic-timelock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-automatic-timelock.js","names":[],"sources":["../../src/account-layer/use-automatic-timelock.ts"],"sourcesContent":["\"use client\";\n\nimport {\n createHttpTimelockApprovalProvider,\n getSelectorTimelockQueryOptions,\n getSolverInfoQueryOptions,\n getTimelockPolicyQueryOptions,\n getVirtualAccountQueryOptions,\n INSTANT_OPEN_TIMELOCK_ACCOUNT_LAYER_FUNCTIONS,\n INSTANT_OPEN_TIMELOCK_CORE_FUNCTIONS,\n INSTANT_OPEN_TIMELOCK_SELECTORS,\n isDefiniteTimelockApprovalRejection,\n isUnsubmittedTimelockWalletRejection,\n resolveTimelockFamilyAccount,\n SymmError,\n type Config,\n type GetSolverInfoData,\n type TimelockApprovalCapability,\n type TimelockAuthorization,\n type TimelockBatchAuthorization,\n} from \"@symmio/trading-core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { useEffect, useRef } from \"react\";\nimport { isAddressEqual, zeroAddress, type Address } from \"viem\";\nimport { useConnection } from \"wagmi\";\nimport {\n refreshTimelockInfoAfterUnavailable,\n rememberTimelockCapability,\n timelockCapabilityKey,\n} from \"../solvers/timelock-capability-cache\";\nimport type { AutomaticTimelockWriteParameters } from \"../transactions/write-types\";\nimport {\n automaticAttemptKey,\n deploymentHasAutomaticAttempt,\n finishAutomaticAttempt,\n reserveAutomaticAttempt,\n} from \"./automatic-timelock-attempt\";\n\n/** Resolve an automatic authorization once per mutation variables object. */\nexport function useAutomaticTimelock(\n config: Config,\n options: AutomaticTimelockWriteParameters[\"automaticTimelock\"] = true,\n boundAccount?: Address,\n) {\n const client = useQueryClient();\n const connection = useConnection();\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const attempts = useRef(new WeakMap<object, Map<string, Promise<TimelockAuthorization | undefined>>>());\n const batches = useRef(new WeakMap<object, Map<string, Promise<TimelockBatchAuthorization | undefined>>>());\n const active = useRef(\n new WeakMap<object, { token: object; key?: ReturnType<typeof automaticAttemptKey>; issued: number }>(),\n );\n const supplied = typeof options === \"object\" ? options : undefined;\n const fingerprint = supplied\n ? JSON.stringify([\n supplied.capability.unlocker.toLowerCase(),\n supplied.capability.minTimelockDelaySeconds,\n supplied.capability.validitySeconds,\n supplied.capability.requestDomain.name,\n supplied.capability.requestDomain.version,\n String(supplied.capability.requestDomain.chainId),\n supplied.capability.requestDomain.verifyingContract.toLowerCase(),\n supplied.deadline?.toString(),\n ])\n : String(options);\n const providerIdentity = supplied?.provider;\n const walletScope = `${connection.chainId ?? \"\"}:${connection.address?.toLowerCase() ?? \"\"}:${boundAccount?.toLowerCase() ?? \"\"}`;\n const scope = useRef({ config, fingerprint, providerIdentity, walletScope, revision: 0 });\n if (\n scope.current.config !== config ||\n scope.current.fingerprint !== fingerprint ||\n scope.current.providerIdentity !== providerIdentity ||\n scope.current.walletScope !== walletScope\n ) {\n scope.current = { config, fingerprint, providerIdentity, walletScope, revision: scope.current.revision + 1 };\n }\n const operationScopes = useRef(new WeakMap<object, string>());\n\n function checkOperationScope(variables: object, parameters: { account: Address; chainId: number }) {\n if (!mounted.current)\n throw new SymmError(\n \"validation\",\n \"TIMELOCK_RECONCILIATION_REQUIRED\",\n \"The operation's context was unmounted. Reconcile the previous attempt before continuing.\",\n );\n const previous = operationScopes.current.get(variables);\n const current = `${scope.current.revision}:${parameters.chainId}:${parameters.account.toLowerCase()}`;\n if (previous !== undefined && previous !== current) {\n throw new SymmError(\n \"validation\",\n \"TIMELOCK_RECONCILIATION_REQUIRED\",\n \"The timelock configuration changed during this operation. Reconcile the previous attempt before continuing.\",\n );\n }\n operationScopes.current.set(variables, current);\n }\n\n async function guard(variables: object, parameters: { account: Address; chainId: number }) {\n checkOperationScope(variables, parameters);\n const chain = config.getChainConfig(parameters.chainId);\n if (!deploymentHasAutomaticAttempt(client, parameters.chainId, chain.addresses.accountLayerAddress)) return;\n const virtual = await client.fetchQuery({\n ...getVirtualAccountQueryOptions(config, { chainId: parameters.chainId, account: parameters.account }),\n retry: false,\n });\n checkOperationScope(variables, parameters);\n const root = resolveTimelockFamilyAccount(parameters.account, virtual);\n const existing = client.getQueryData(\n automaticAttemptKey(parameters.chainId, chain.addresses.accountLayerAddress, root),\n );\n if (existing)\n throw new SymmError(\n \"validation\",\n \"TIMELOCK_RECONCILIATION_REQUIRED\",\n \"A previous timelock operation is pending or requires reconciliation.\",\n );\n }\n\n function resolve(\n variables: object,\n parameters: {\n account: Address;\n chainId: number;\n functionName: string;\n slot?: number;\n explicit?: TimelockAuthorization;\n },\n ) {\n if (options === false && !operationScopes.current.has(variables)) return Promise.resolve(undefined);\n checkOperationScope(variables, parameters);\n if (parameters.explicit) return Promise.resolve(parameters.explicit);\n if (options === false) return Promise.resolve(undefined);\n const key = `${parameters.chainId}:${parameters.account.toLowerCase()}:${parameters.functionName}:${parameters.slot ?? \"single\"}`;\n let perOperation = attempts.current.get(variables);\n if (!perOperation) {\n perOperation = new Map();\n attempts.current.set(variables, perOperation);\n }\n const prior = perOperation.get(key);\n if (prior) return prior;\n const task = (async () => {\n await guard(variables, parameters);\n const names: readonly string[] = [\n ...INSTANT_OPEN_TIMELOCK_CORE_FUNCTIONS,\n ...INSTANT_OPEN_TIMELOCK_ACCOUNT_LAYER_FUNCTIONS,\n ];\n const index = names.indexOf(parameters.functionName);\n if (index < 0) return undefined;\n const chain = config.getChainConfig(parameters.chainId);\n const solver = config.getSolver({ chainId: parameters.chainId });\n if (chain.timelockSupported === false || solver.capabilities?.timelockApproval === false) return undefined;\n const infoOptions = getSolverInfoQueryOptions(config, { chainId: parameters.chainId, solverId: solver.id });\n const capabilityKey = timelockCapabilityKey(config, parameters.chainId, solver.id);\n async function selectorIsUnlocked() {\n const virtual = await client.fetchQuery({\n ...getVirtualAccountQueryOptions(config, { chainId: parameters.chainId, account: parameters.account }),\n retry: false,\n staleTime: 0,\n });\n const root = resolveTimelockFamilyAccount(parameters.account, virtual);\n const selector = await client.fetchQuery({\n ...getSelectorTimelockQueryOptions(config, {\n chainId: parameters.chainId,\n account: root,\n selector: INSTANT_OPEN_TIMELOCK_SELECTORS[index]!,\n }),\n retry: false,\n staleTime: 0,\n });\n checkOperationScope(variables, parameters);\n return isAddressEqual(selector.unlocker, zeroAddress);\n }\n if (!supplied && solver.id !== \"enigma\") {\n if (solver.capabilities?.timelockApproval !== true || (await selectorIsUnlocked())) return undefined;\n throw new SymmError(\n \"config\",\n \"TIMELOCK_PROVIDER_REQUIRED\",\n \"Supply an explicit timelock authorization for this solver.\",\n );\n }\n let capability = supplied?.capability ?? client.getQueryData<TimelockApprovalCapability>(capabilityKey);\n if (!capability && !supplied) {\n capability = client.getQueryData<GetSolverInfoData>(infoOptions.queryKey)?.timelockApproval;\n rememberTimelockCapability(client, capabilityKey, capability);\n }\n if (!capability) {\n try {\n capability = (await client.fetchQuery({ ...infoOptions, retry: false, staleTime: 0 })).timelockApproval;\n rememberTimelockCapability(client, capabilityKey, capability);\n } catch (error) {\n // A confirmed unlocked selector does not depend on the approval service.\n // If either chain read fails, retain the original discovery failure.\n try {\n if (await selectorIsUnlocked()) return undefined;\n } catch {\n // Preserve the original failure and do not assume the selector is unlocked.\n }\n throw error;\n }\n }\n checkOperationScope(variables, parameters);\n if (!capability) {\n if (await selectorIsUnlocked()) return undefined;\n throw new SymmError(\n \"config\",\n \"TIMELOCK_PROVIDER_REQUIRED\",\n \"The selector is timelocked, but the solver did not provide timelock metadata.\",\n );\n }\n const policyOptions = getTimelockPolicyQueryOptions(config, {\n account: parameters.account,\n chainId: parameters.chainId,\n solverId: solver.id,\n capability,\n selectors: [INSTANT_OPEN_TIMELOCK_SELECTORS[index]!],\n });\n const policy = await client.fetchQuery({ ...policyOptions, retry: false, staleTime: 0 });\n checkOperationScope(variables, parameters);\n if (policy.selectors[0]?.status === \"missing\") return undefined;\n if (!policy.ready)\n throw new SymmError(\n \"validation\",\n \"TIMELOCK_POLICY_NOT_READY\",\n \"The account's timelock policy does not match the solver.\",\n );\n const block = await config.getClient({ chainId: parameters.chainId }).getBlock();\n checkOperationScope(variables, parameters);\n const provider = supplied?.provider ?? createHttpTimelockApprovalProvider({ baseUrl: solver.url });\n let attempt = active.current.get(variables);\n if (!attempt) {\n attempt = { token: {}, issued: 0 };\n active.current.set(variables, attempt);\n }\n const currentAttempt = attempt;\n const key = automaticAttemptKey(parameters.chainId, chain.addresses.accountLayerAddress, policy.rootAccount);\n return {\n capability,\n provider: {\n requestApproval: async (request, requestOptions) => {\n checkOperationScope(variables, parameters);\n reserveAutomaticAttempt(client, key, currentAttempt.token);\n currentAttempt.key = key;\n try {\n const response = await provider.requestApproval(request, requestOptions);\n currentAttempt.issued += 1;\n return response;\n } catch (error) {\n if (!supplied?.provider)\n void refreshTimelockInfoAfterUnavailable(client, config, parameters.chainId, solver.id, error);\n throw error;\n }\n },\n },\n deadline: supplied?.deadline ?? block.timestamp + 300n,\n onApproval: async (approval) => {\n await supplied?.onApproval?.(approval);\n checkOperationScope(variables, parameters);\n },\n } satisfies TimelockAuthorization;\n })();\n perOperation.set(key, task);\n return task;\n }\n function batch(\n variables: object,\n parameters: { account: Address; chainId: number; functionNames: readonly string[] },\n ) {\n checkOperationScope(variables, parameters);\n const key = `${parameters.chainId}:${parameters.account.toLowerCase()}:${parameters.functionNames.join(\",\")}`;\n let perOperation = batches.current.get(variables);\n if (!perOperation) {\n perOperation = new Map();\n batches.current.set(variables, perOperation);\n }\n const prior = perOperation.get(key);\n if (prior) return prior;\n const task = Promise.all(\n parameters.functionNames.map((functionName, slot) => resolve(variables, { ...parameters, functionName, slot })),\n ).then((calls) => (calls.some(Boolean) ? { calls } : undefined));\n perOperation.set(key, task);\n return task;\n }\n function finish(variables: object, result: { receipt?: { status: string } }) {\n const attempt = active.current.get(variables);\n if (attempt?.key) finishAutomaticAttempt(client, attempt.key, attempt.token, result.receipt?.status === \"success\");\n }\n function fail(variables: object, error: unknown) {\n const attempt = active.current.get(variables);\n if (!attempt?.key) return;\n finishAutomaticAttempt(\n client,\n attempt.key,\n attempt.token,\n (attempt.issued === 0 && isDefiniteTimelockApprovalRejection(error)) ||\n isUnsubmittedTimelockWalletRejection(error),\n );\n }\n return Object.assign(resolve, { batch, finish, fail, guard });\n}\n"],"mappings":";;;;;;;;;AAuCA,SAAgB,EACd,GACA,IAAiE,IACjE,GACA;CACA,IAAM,IAAS,EAAe,GACxB,IAAa,EAAc,GAC3B,IAAU,EAAO,EAAI;CAC3B,SACE,EAAQ,UAAU,UACL;EACX,EAAQ,UAAU;CACpB,IACC,CAAC,CAAC;CACL,IAAM,IAAW,kBAAO,IAAI,QAAyE,CAAC,GAChG,IAAU,kBAAO,IAAI,QAA8E,CAAC,GACpG,IAAS,kBACb,IAAI,QAAiG,CACvG,GACM,IAAW,OAAO,KAAY,WAAW,IAAU,KAAA,GACnD,IAAc,IAChB,KAAK,UAAU;EACb,EAAS,WAAW,SAAS,YAAY;EACzC,EAAS,WAAW;EACpB,EAAS,WAAW;EACpB,EAAS,WAAW,cAAc;EAClC,EAAS,WAAW,cAAc;EAClC,OAAO,EAAS,WAAW,cA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H,oBAAe,IAAI,IAAI,GACvB,EAAQ,QAAQ,IAAI,GAAW,CAAY;EAE7C,IAAM,IAAQ,EAAa,IAAI,CAAG;EAClC,IAAI,GAAO,OAAO;EAClB,IAAM,IAAO,QAAQ,IACnB,EAAW,cAAc,KAAK,GAAc,MAAS,EAAQ,GAAW;GAAE,GAAG;GAAY;GAAc;EAAK,CAAC,CAAC,CAChH,EAAE,MAAM,MAAW,EAAM,KAAK,OAAO,IAAI,EAAE,SAAM,IAAI,KAAA,CAAU;EAE/D,OADA,EAAa,IAAI,GAAK,CAAI,GACnB;CACT;CACA,SAAS,EAAO,GAAmB,GAA0C;EAC3E,IAAM,IAAU,EAAO,QAAQ,IAAI,CAAS;EAC5C,AAAI,GAAS,OAAK,EAAuB,GAAQ,EAAQ,KAAK,EAAQ,OAAO,EAAO,SAAS,WAAW,SAAS;CACnH;CACA,SAAS,EAAK,GAAmB,GAAgB;EAC/C,IAAM,IAAU,EAAO,QAAQ,IAAI,CAAS;EACvC,GAAS,OACd,EACE,GACA,EAAQ,KACR,EAAQ,OACP,EAAQ,WAAW,KAAK,EAAoC,CAAK,KAChE,EAAqC,CAAK,CAC9C;CACF;CACA,OAAO,OAAO,OAAO,GAAS;EAAE;EAAO;EAAQ;EAAM;CAAM,CAAC;AAC9D"}
@@ -13,10 +13,15 @@ export type CreateSubAccountsResult = WriteResult;
13
13
  /** Return type of {@link useCreateSubAccounts}. */
14
14
  export type UseCreateSubAccountsReturnType = UseMutationResult<CreateSubAccountsResult, SymmioRequestError, CreateSubAccountsParameters>;
15
15
  /**
16
- * Submit a `createSubAccounts` transaction. The connected wallet becomes the
17
- * `owner` of every created subaccount. On success, the connected user's
18
- * `getUserSubAccounts`, `getUserSubAccountsAddresses`, and
19
- * `getSubAccountsCountOfUser` queries are invalidated so mounted lists refetch.
16
+ * Submit a `createSubAccounts` transaction through the configured SDK wallet.
17
+ * On success, all owner variants of `getUserSubAccounts`,
18
+ * `getUserSubAccountsAddresses`, and `getSubAccountsCountOfUser` queries are
19
+ * invalidated. A host embedded wallet or session signer need not match wagmi's
20
+ * connected address.
21
+ *
22
+ * To make creation recoverable, pass `gasless.idempotencyKey` in the
23
+ * variables — one key per user action, saved before calling — and call the
24
+ * mutation again with the same key after an unknown outcome.
20
25
  *
21
26
  * @remarks
22
27
  * The created subaccount addresses are not returned directly — read them from the
@@ -1 +1 @@
1
- {"version":3,"file":"use-create-sub-accounts.d.ts","sourceRoot":"","sources":["../../src/account-layer/use-create-sub-accounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,eAAe,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAElD,mDAAmD;AACnD,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAC5D,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,GAAE,8BAAmC,GAAG,8BAA8B,CA8BpH"}
1
+ {"version":3,"file":"use-create-sub-accounts.d.ts","sourceRoot":"","sources":["../../src/account-layer/use-create-sub-accounts.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,eAAe,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAElD,mDAAmD;AACnD,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAC5D,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,GAAE,8BAAmC,GAAG,8BAA8B,CA8BpH"}
@@ -5,35 +5,33 @@ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
5
  import { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
6
6
  import { predicateMatch as i } from "../utils/predicate-match.js";
7
7
  import { createSubAccountsMutationOptions as a, getSubAccountsCountOfUserQueryKey as o, getUserSubAccountsAddressesQueryKey as s, getUserSubAccountsQueryKey as c } from "@symmio/trading-core";
8
- import { useConnection as l } from "wagmi";
9
- import { useMutation as u, useQueryClient as d } from "@tanstack/react-query";
8
+ import { useMutation as l, useQueryClient as u } from "@tanstack/react-query";
10
9
  //#region src/account-layer/use-create-sub-accounts.ts
11
- function f(f = {}) {
12
- let p = t(f), m = e(), { address: h } = l(), g = d(), _ = a(p);
13
- return u({
14
- mutationKey: _.mutationKey,
10
+ function d(d = {}) {
11
+ let f = t(d), p = e(), m = u(), h = a(f);
12
+ return l({
13
+ mutationKey: h.mutationKey,
15
14
  mutationFn: async (e) => {
16
15
  try {
17
- let t = e.chainId ?? m;
18
- return r(p, await _.mutationFn({
16
+ let t = e.chainId ?? p;
17
+ return r(f, await h.mutationFn({
19
18
  ...e,
20
19
  chainId: t
21
20
  }), {
22
21
  chainId: t,
23
- waitForReceipt: f.waitForReceipt,
24
- confirmations: f.confirmations
22
+ waitForReceipt: d.waitForReceipt,
23
+ confirmations: d.confirmations
25
24
  });
26
25
  } catch (e) {
27
26
  throw n(e);
28
27
  }
29
28
  },
30
29
  onSuccess: () => {
31
- let e = h ? { user: h } : void 0;
32
- g.invalidateQueries({ predicate: i(c, e) }), g.invalidateQueries({ predicate: i(s, e) }), g.invalidateQueries({ predicate: i(o, e) });
30
+ m.invalidateQueries({ predicate: i(c) }), m.invalidateQueries({ predicate: i(s) }), m.invalidateQueries({ predicate: i(o) });
33
31
  }
34
32
  });
35
33
  }
36
34
  //#endregion
37
- export { f as useCreateSubAccounts };
35
+ export { d as useCreateSubAccounts };
38
36
 
39
37
  //# sourceMappingURL=use-create-sub-accounts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-create-sub-accounts.js","names":[],"sources":["../../src/account-layer/use-create-sub-accounts.ts"],"sourcesContent":["\"use client\";\n\nimport {\n createSubAccountsMutationOptions,\n getSubAccountsCountOfUserQueryKey,\n getUserSubAccountsAddressesQueryKey,\n getUserSubAccountsQueryKey,\n type CreateSubAccountsParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useConnection } from \"wagmi\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useCreateSubAccounts}.\n */\nexport type UseCreateSubAccountsParameters = WriteParameters;\n\n/**\n * Result returned by the {@link useCreateSubAccounts} mutation.\n */\nexport type CreateSubAccountsResult = WriteResult;\n\n/** Return type of {@link useCreateSubAccounts}. */\nexport type UseCreateSubAccountsReturnType = UseMutationResult<\n CreateSubAccountsResult,\n SymmioRequestError,\n CreateSubAccountsParameters\n>;\n\n/**\n * Submit a `createSubAccounts` transaction. The connected wallet becomes the\n * `owner` of every created subaccount. On success, the connected user's\n * `getUserSubAccounts`, `getUserSubAccountsAddresses`, and\n * `getSubAccountsCountOfUser` queries are invalidated so mounted lists refetch.\n *\n * @remarks\n * The created subaccount addresses are not returned directly — read them from the\n * refetched list (or the `SubAccountCreated` receipt events). This hook resolves\n * with the tx hash (and receipt when `waitForReceipt` is enabled).\n *\n * @example\n * ```tsx\n * const { mutate, status, error } = useCreateSubAccounts();\n * mutate({\n * affiliate,\n * accountsData: [{ name: \"Main\", metadata: \"0x\", symmioCore, isolationType, singleVAMode }],\n * });\n * ```\n */\nexport function useCreateSubAccounts(parameters: UseCreateSubAccountsParameters = {}): UseCreateSubAccountsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const { address } = useConnection();\n const queryClient = useQueryClient();\n\n const base = createSubAccountsMutationOptions(config);\n\n return useMutation<CreateSubAccountsResult, SymmioRequestError, CreateSubAccountsParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n const partial = address ? { user: address } : undefined;\n void queryClient.invalidateQueries({ predicate: predicateMatch(getUserSubAccountsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getUserSubAccountsAddressesQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getSubAccountsCountOfUserQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;;AAuDA,SAAgB,EAAqB,IAA6C,CAAC,GAAmC;CACpH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,EAAE,eAAY,EAAc,GAC5B,IAAc,EAAe,GAE7B,IAAO,EAAiC,CAAM;CAEpD,OAAO,EAAsF;EAC3F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GACf,IAAM,IAAU,IAAU,EAAE,MAAM,EAAQ,IAAI,KAAA;GAG9C,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA4B,CAAO,EAAE,CAAC,GACrG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAqC,CAAO,EAAE,CAAC,GAC9G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAmC,CAAO,EAAE,CAAC;EAC9G;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-create-sub-accounts.js","names":[],"sources":["../../src/account-layer/use-create-sub-accounts.ts"],"sourcesContent":["\"use client\";\n\nimport {\n createSubAccountsMutationOptions,\n getSubAccountsCountOfUserQueryKey,\n getUserSubAccountsAddressesQueryKey,\n getUserSubAccountsQueryKey,\n type CreateSubAccountsParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useCreateSubAccounts}.\n */\nexport type UseCreateSubAccountsParameters = WriteParameters;\n\n/**\n * Result returned by the {@link useCreateSubAccounts} mutation.\n */\nexport type CreateSubAccountsResult = WriteResult;\n\n/** Return type of {@link useCreateSubAccounts}. */\nexport type UseCreateSubAccountsReturnType = UseMutationResult<\n CreateSubAccountsResult,\n SymmioRequestError,\n CreateSubAccountsParameters\n>;\n\n/**\n * Submit a `createSubAccounts` transaction through the configured SDK wallet.\n * On success, all owner variants of `getUserSubAccounts`,\n * `getUserSubAccountsAddresses`, and `getSubAccountsCountOfUser` queries are\n * invalidated. A host embedded wallet or session signer need not match wagmi's\n * connected address.\n *\n * To make creation recoverable, pass `gasless.idempotencyKey` in the\n * variables — one key per user action, saved before calling — and call the\n * mutation again with the same key after an unknown outcome.\n *\n * @remarks\n * The created subaccount addresses are not returned directly — read them from the\n * refetched list (or the `SubAccountCreated` receipt events). This hook resolves\n * with the tx hash (and receipt when `waitForReceipt` is enabled).\n *\n * @example\n * ```tsx\n * const { mutate, status, error } = useCreateSubAccounts();\n * mutate({\n * affiliate,\n * accountsData: [{ name: \"Main\", metadata: \"0x\", symmioCore, isolationType, singleVAMode }],\n * });\n * ```\n */\nexport function useCreateSubAccounts(parameters: UseCreateSubAccountsParameters = {}): UseCreateSubAccountsReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = createSubAccountsMutationOptions(config);\n\n return useMutation<CreateSubAccountsResult, SymmioRequestError, CreateSubAccountsParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n // The host resolver may use an embedded owner or a session key unrelated to wagmi.\n // Invalidate every owner variant; active lists refetch without an extra owner RPC.\n void queryClient.invalidateQueries({ predicate: predicateMatch(getUserSubAccountsQueryKey) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getUserSubAccountsAddressesQueryKey) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getSubAccountsCountOfUserQueryKey) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA2DA,SAAgB,EAAqB,IAA6C,CAAC,GAAmC;CACpH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAiC,CAAM;CAEpD,OAAO,EAAsF;EAC3F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GAKf,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,CAA0B,EAAE,CAAC,GAC5F,EAAiB,kBAAkB,EAAE,WAAW,EAAe,CAAmC,EAAE,CAAC,GACrG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,CAAiC,EAAE,CAAC;EACrG;CACF,CAAC;AACH"}
@@ -1,11 +1,11 @@
1
1
  import { DeallocateAndInitiateWithdrawParameters, SingleUpnlSig } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
3
  import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
- import { WriteParameters, WriteResult } from '../transactions/index.js';
4
+ import { AutomaticTimelockWriteParameters, WriteResult } from '../transactions/index.js';
5
5
  /**
6
6
  * Parameters for {@link useDeallocateAndInitiateWithdraw}.
7
7
  */
8
- export type UseDeallocateAndInitiateWithdrawParameters = WriteParameters;
8
+ export type UseDeallocateAndInitiateWithdrawParameters = AutomaticTimelockWriteParameters;
9
9
  /**
10
10
  * Variables for the {@link useDeallocateAndInitiateWithdraw} mutation: the core
11
11
  * action's inputs except `upnlSig` is **optional**. When omitted, the hook fetches
@@ -29,7 +29,7 @@ export type UseDeallocateAndInitiateWithdrawReturnType = UseMutationResult<Deall
29
29
  * it to prove the subaccount stays solvent) immediately before submitting, unless
30
30
  * you pass one as `upnlSig`. The connected wallet must own the subaccount. On
31
31
  * success, the subaccount's balance reads and its pending-requests /
32
- * withdrawable-time reads are invalidated.
32
+ * withdrawable-time / withdraw-cooldown reads are invalidated.
33
33
  *
34
34
  * @remarks
35
35
  * The `deallocate` leg is subject to the on-chain deallocate debounce — submitting
@@ -1 +1 @@
1
- {"version":3,"file":"use-deallocate-and-initiate-withdraw.d.ts","sourceRoot":"","sources":["../../src/account-layer/use-deallocate-and-initiate-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,uCAAuC,EAC5C,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,0CAA0C,GAAG,eAAe,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,sCAAsC,GAAG,IAAI,CAAC,uCAAuC,EAAE,SAAS,CAAC,GAAG;IAC9G,iFAAiF;IACjF,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,mCAAmC,GAAG,WAAW,CAAC;AAE9D,+DAA+D;AAC/D,MAAM,MAAM,0CAA0C,GAAG,iBAAiB,CACxE,mCAAmC,EACnC,kBAAkB,EAClB,sCAAsC,CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,GAAE,0CAA+C,GAC1D,0CAA0C,CA0C5C"}
1
+ {"version":3,"file":"use-deallocate-and-initiate-withdraw.d.ts","sourceRoot":"","sources":["../../src/account-layer/use-deallocate-and-initiate-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAUL,KAAK,uCAAuC,EAC5C,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,gCAAgC,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAI9G;;GAEG;AACH,MAAM,MAAM,0CAA0C,GAAG,gCAAgC,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,MAAM,sCAAsC,GAAG,IAAI,CAAC,uCAAuC,EAAE,SAAS,CAAC,GAAG;IAC9G,iFAAiF;IACjF,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC;AAEF,gFAAgF;AAChF,MAAM,MAAM,mCAAmC,GAAG,WAAW,CAAC;AAE9D,+DAA+D;AAC/D,MAAM,MAAM,0CAA0C,GAAG,iBAAiB,CACxE,mCAAmC,EACnC,kBAAkB,EAClB,sCAAsC,CACvC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,GAAE,0CAA+C,GAC1D,0CAA0C,CAsE5C"}
@@ -3,42 +3,53 @@ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
3
  import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
4
  import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
5
  import { resolveWriteResult as r } from "../transactions/resolve-write-result.js";
6
- import { predicateMatch as i } from "../utils/predicate-match.js";
7
- import { deallocateAndInitiateWithdrawMutationOptions as a, getAccountBalanceInfoQueryKey as o, getAccountBalanceOfQueryKey as s, getDeallocateUpnlSig as c, getPendingWithdrawRequestsQueryKey as l, getWithdrawableTimeQueryKey as u } from "@symmio/trading-core";
8
- import { useMutation as d, useQueryClient as f } from "@tanstack/react-query";
6
+ import { normalizeProtectedWriteError as i } from "../errors/normalize-protected-write-error.js";
7
+ import { predicateMatch as a } from "../utils/predicate-match.js";
8
+ import { useAutomaticTimelock as o } from "./use-automatic-timelock.js";
9
+ import { assertTimelockBatchUnused as s, deallocateAndInitiateWithdrawMutationOptions as c, getAccountBalanceInfoQueryKey as l, getAccountBalanceOfQueryKey as u, getDeallocateUpnlSig as d, getPendingWithdrawRequestsBatchQueryKey as f, getPendingWithdrawRequestsQueryKey as p, getWithdrawCooldownOfQueryKey as m, getWithdrawableTimeQueryKey as h } from "@symmio/trading-core";
10
+ import { useMutation as g, useQueryClient as _ } from "@tanstack/react-query";
9
11
  //#region src/account-layer/use-deallocate-and-initiate-withdraw.ts
10
- function p(p = {}) {
11
- let m = t(p), h = e(), g = f(), _ = a(m);
12
- return d({
13
- mutationKey: _.mutationKey,
12
+ function v(v = {}) {
13
+ let y = t(v), b = e(), x = _(), S = o(y, v.automaticTimelock), C = c(y);
14
+ return g({
15
+ mutationKey: C.mutationKey,
14
16
  mutationFn: async (e) => {
17
+ let t = e.timelock;
15
18
  try {
16
- let t = e.chainId ?? h, n = e.upnlSig ?? await c(m, {
19
+ let n = e.chainId ?? b;
20
+ t ??= await S.batch(e, {
21
+ account: e.account,
22
+ chainId: n,
23
+ functionNames: ["deallocate", "initiateWithdraw"]
24
+ }), t && s(t);
25
+ let i = e.upnlSig ?? await d(y, {
17
26
  virtualAccount: e.account,
18
- chainId: t
19
- });
20
- return r(m, await _.mutationFn({
27
+ chainId: n
28
+ }), a = await r(y, await C.mutationFn({
21
29
  ...e,
22
- upnlSig: n,
23
- chainId: t
30
+ upnlSig: i,
31
+ chainId: n,
32
+ ...t ? { timelock: t } : {}
24
33
  }), {
25
- chainId: t,
26
- waitForReceipt: p.waitForReceipt,
27
- confirmations: p.confirmations
34
+ chainId: n,
35
+ waitForReceipt: v.waitForReceipt,
36
+ confirmations: v.confirmations
28
37
  });
29
- } catch (e) {
30
- throw n(e);
38
+ return S.finish(e, a), a;
39
+ } catch (r) {
40
+ throw S.fail(e, r), t ? i(r, t) : n(r);
31
41
  }
32
42
  },
33
43
  onSuccess: (e, t) => {
44
+ e.receipt && x.invalidateQueries({ predicate: a(f, { configKey: y.getChainConfigKey(t.chainId ?? b) }) });
34
45
  let n = { account: t.account };
35
- g.invalidateQueries({ predicate: i(o, n) }), g.invalidateQueries({ predicate: i(s, n) });
46
+ x.invalidateQueries({ predicate: a(l, n) }), x.invalidateQueries({ predicate: a(u, n) });
36
47
  let r = { user: t.account };
37
- g.invalidateQueries({ predicate: i(l, r) }), g.invalidateQueries({ predicate: i(u, r) });
48
+ x.invalidateQueries({ predicate: a(p, r) }), x.invalidateQueries({ predicate: a(h, r) }), x.invalidateQueries({ predicate: a(m, r) });
38
49
  }
39
50
  });
40
51
  }
41
52
  //#endregion
42
- export { p as useDeallocateAndInitiateWithdraw };
53
+ export { v as useDeallocateAndInitiateWithdraw };
43
54
 
44
55
  //# sourceMappingURL=use-deallocate-and-initiate-withdraw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-deallocate-and-initiate-withdraw.js","names":[],"sources":["../../src/account-layer/use-deallocate-and-initiate-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n deallocateAndInitiateWithdrawMutationOptions,\n getAccountBalanceInfoQueryKey,\n getAccountBalanceOfQueryKey,\n getDeallocateUpnlSig,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n type DeallocateAndInitiateWithdrawParameters,\n type SingleUpnlSig,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useDeallocateAndInitiateWithdraw}.\n */\nexport type UseDeallocateAndInitiateWithdrawParameters = WriteParameters;\n\n/**\n * Variables for the {@link useDeallocateAndInitiateWithdraw} mutation: the core\n * action's inputs except `upnlSig` is **optional**. When omitted, the hook fetches\n * a fresh Muon uPnL signature itself (for the `deallocate` leg) before submitting;\n * pass one only to reuse a signature you already fetched.\n */\nexport type DeallocateAndInitiateWithdrawVariables = Omit<DeallocateAndInitiateWithdrawParameters, \"upnlSig\"> & {\n /** A pre-fetched Muon uPnL signature. Omit to let the hook fetch a fresh one. */\n upnlSig?: SingleUpnlSig;\n};\n\n/** Result returned by the {@link useDeallocateAndInitiateWithdraw} mutation. */\nexport type DeallocateAndInitiateWithdrawResult = WriteResult;\n\n/** Return type of {@link useDeallocateAndInitiateWithdraw}. */\nexport type UseDeallocateAndInitiateWithdrawReturnType = UseMutationResult<\n DeallocateAndInitiateWithdrawResult,\n SymmioRequestError,\n DeallocateAndInitiateWithdrawVariables\n>;\n\n/**\n * Batch a subaccount's **deallocate** and **initiate-withdraw** into a single\n * atomic transaction — the cross-margin / Base withdraw path. The SDK routes both\n * core calls through one AccountLayer `_call`, so they succeed or revert together.\n *\n * The hook **fetches a fresh Muon uPnL signature** (the `deallocate` leg requires\n * it to prove the subaccount stays solvent) immediately before submitting, unless\n * you pass one as `upnlSig`. The connected wallet must own the subaccount. On\n * success, the subaccount's balance reads and its pending-requests /\n * withdrawable-time reads are invalidated.\n *\n * @remarks\n * The `deallocate` leg is subject to the on-chain deallocate debounce — submitting\n * too soon after a prior deallocate reverts the whole batch. That (and an\n * insolvent result, or a stale signature) is surfaced as a normalized\n * {@link SymmioRequestError}; enabling `simulateBeforeWrite` catches it as a\n * dry-run before anything is signed.\n *\n * @example\n * ```tsx\n * import { createClassicWithdrawPart } from \"@symmio/trading-core\";\n * const { mutate } = useDeallocateAndInitiateWithdraw();\n * mutate({\n * account: \"0xsub…\",\n * amount: 1_000000000000000000n,\n * parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId: 42161n })],\n * });\n * ```\n */\nexport function useDeallocateAndInitiateWithdraw(\n parameters: UseDeallocateAndInitiateWithdrawParameters = {},\n): UseDeallocateAndInitiateWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = deallocateAndInitiateWithdrawMutationOptions(config);\n\n return useMutation<DeallocateAndInitiateWithdrawResult, SymmioRequestError, DeallocateAndInitiateWithdrawVariables>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const upnlSig =\n variables.upnlSig ??\n (await getDeallocateUpnlSig(config, {\n virtualAccount: variables.account,\n chainId: resolvedChainId,\n }));\n const hash = await base.mutationFn({ ...variables, upnlSig, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: (_result, variables) => {\n const balancePartial = { account: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceInfoQueryKey, balancePartial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceOfQueryKey, balancePartial) });\n\n const withdrawPartial = { user: variables.account };\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, withdrawPartial),\n });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getWithdrawableTimeQueryKey, withdrawPartial),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA2EA,SAAgB,EACd,IAAyD,CAAC,GACd;CAC5C,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAA6C,CAAM;CAEhE,OAAO,EAA6G;EAClH,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW,GACvC,IACJ,EAAU,WACT,MAAM,EAAqB,GAAQ;KAClC,gBAAgB,EAAU;KAC1B,SAAS;IACX,CAAC;IAEH,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW;KAAS,SAAS;IAAgB,CAAC,GAC9C;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,YAAY,GAAS,MAAc;GACjC,IAAM,IAAiB,EAAE,SAAS,EAAU,QAAQ;GAEpD,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAc,EAAE,CAAC,GAC/G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAc,EAAE,CAAC;GAE7G,IAAM,IAAkB,EAAE,MAAM,EAAU,QAAQ;GAIlD,AAHA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC,CAAe,EAC/E,CAAC,GACD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA6B,CAAe,EACxE,CAAC;EACH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-deallocate-and-initiate-withdraw.js","names":[],"sources":["../../src/account-layer/use-deallocate-and-initiate-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n assertTimelockBatchUnused,\n deallocateAndInitiateWithdrawMutationOptions,\n getAccountBalanceInfoQueryKey,\n getAccountBalanceOfQueryKey,\n getDeallocateUpnlSig,\n getPendingWithdrawRequestsBatchQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawCooldownOfQueryKey,\n getWithdrawableTimeQueryKey,\n type DeallocateAndInitiateWithdrawParameters,\n type SingleUpnlSig,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { normalizeProtectedWriteError } from \"../errors/normalize-protected-write-error\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type AutomaticTimelockWriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\nimport { useAutomaticTimelock } from \"./use-automatic-timelock\";\n\n/**\n * Parameters for {@link useDeallocateAndInitiateWithdraw}.\n */\nexport type UseDeallocateAndInitiateWithdrawParameters = AutomaticTimelockWriteParameters;\n\n/**\n * Variables for the {@link useDeallocateAndInitiateWithdraw} mutation: the core\n * action's inputs except `upnlSig` is **optional**. When omitted, the hook fetches\n * a fresh Muon uPnL signature itself (for the `deallocate` leg) before submitting;\n * pass one only to reuse a signature you already fetched.\n */\nexport type DeallocateAndInitiateWithdrawVariables = Omit<DeallocateAndInitiateWithdrawParameters, \"upnlSig\"> & {\n /** A pre-fetched Muon uPnL signature. Omit to let the hook fetch a fresh one. */\n upnlSig?: SingleUpnlSig;\n};\n\n/** Result returned by the {@link useDeallocateAndInitiateWithdraw} mutation. */\nexport type DeallocateAndInitiateWithdrawResult = WriteResult;\n\n/** Return type of {@link useDeallocateAndInitiateWithdraw}. */\nexport type UseDeallocateAndInitiateWithdrawReturnType = UseMutationResult<\n DeallocateAndInitiateWithdrawResult,\n SymmioRequestError,\n DeallocateAndInitiateWithdrawVariables\n>;\n\n/**\n * Batch a subaccount's **deallocate** and **initiate-withdraw** into a single\n * atomic transaction — the cross-margin / Base withdraw path. The SDK routes both\n * core calls through one AccountLayer `_call`, so they succeed or revert together.\n *\n * The hook **fetches a fresh Muon uPnL signature** (the `deallocate` leg requires\n * it to prove the subaccount stays solvent) immediately before submitting, unless\n * you pass one as `upnlSig`. The connected wallet must own the subaccount. On\n * success, the subaccount's balance reads and its pending-requests /\n * withdrawable-time / withdraw-cooldown reads are invalidated.\n *\n * @remarks\n * The `deallocate` leg is subject to the on-chain deallocate debounce — submitting\n * too soon after a prior deallocate reverts the whole batch. That (and an\n * insolvent result, or a stale signature) is surfaced as a normalized\n * {@link SymmioRequestError}; enabling `simulateBeforeWrite` catches it as a\n * dry-run before anything is signed.\n *\n * @example\n * ```tsx\n * import { createClassicWithdrawPart } from \"@symmio/trading-core\";\n * const { mutate } = useDeallocateAndInitiateWithdraw();\n * mutate({\n * account: \"0xsub…\",\n * amount: 1_000000000000000000n,\n * parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId: 42161n })],\n * });\n * ```\n */\nexport function useDeallocateAndInitiateWithdraw(\n parameters: UseDeallocateAndInitiateWithdrawParameters = {},\n): UseDeallocateAndInitiateWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const automaticTimelock = useAutomaticTimelock(config, parameters.automaticTimelock);\n\n const base = deallocateAndInitiateWithdrawMutationOptions(config);\n\n return useMutation<DeallocateAndInitiateWithdrawResult, SymmioRequestError, DeallocateAndInitiateWithdrawVariables>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n let authorization = variables.timelock;\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n authorization ??= await automaticTimelock.batch(variables, {\n account: variables.account,\n chainId: resolvedChainId,\n functionNames: [\"deallocate\", \"initiateWithdraw\"],\n });\n if (authorization) assertTimelockBatchUnused(authorization);\n const upnlSig =\n variables.upnlSig ??\n (await getDeallocateUpnlSig(config, {\n virtualAccount: variables.account,\n chainId: resolvedChainId,\n }));\n const hash = await base.mutationFn({\n ...variables,\n upnlSig,\n chainId: resolvedChainId,\n ...(authorization ? { timelock: authorization } : {}),\n });\n const result = resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n const settled = await result;\n automaticTimelock.finish(variables, settled);\n return settled;\n } catch (err) {\n automaticTimelock.fail(variables, err);\n throw authorization ? normalizeProtectedWriteError(err, authorization) : normalizeSymmError(err);\n }\n },\n onSuccess: (result, variables) => {\n /** Broadcast-only callers own confirmation and the later batch refresh. */\n if (result.receipt) {\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getPendingWithdrawRequestsBatchQueryKey, {\n configKey: config.getChainConfigKey(variables.chainId ?? chainId),\n }),\n });\n }\n const balancePartial = { account: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceInfoQueryKey, balancePartial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAccountBalanceOfQueryKey, balancePartial) });\n\n const withdrawPartial = { user: variables.account };\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, withdrawPartial),\n });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getWithdrawableTimeQueryKey, withdrawPartial),\n });\n void queryClient.invalidateQueries({\n predicate: predicateMatch(getWithdrawCooldownOfQueryKey, withdrawPartial),\n });\n },\n });\n}\n"],"mappings":";;;;;;;;;;;AAgFA,SAAgB,EACd,IAAyD,CAAC,GACd;CAC5C,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAoB,EAAqB,GAAQ,EAAW,iBAAiB,GAE7E,IAAO,EAA6C,CAAM;CAEhE,OAAO,EAA6G;EAClH,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI,IAAgB,EAAU;GAC9B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAM7C,AALA,MAAkB,MAAM,EAAkB,MAAM,GAAW;KACzD,SAAS,EAAU;KACnB,SAAS;KACT,eAAe,CAAC,cAAc,kBAAkB;IAClD,CAAC,GACG,KAAe,EAA0B,CAAa;IAC1D,IAAM,IACJ,EAAU,WACT,MAAM,EAAqB,GAAQ;KAClC,gBAAgB,EAAU;KAC1B,SAAS;IACX,CAAC,GAYG,IAAU,MALD,EAAmB,GAAQ,MANvB,EAAK,WAAW;KACjC,GAAG;KACH;KACA,SAAS;KACT,GAAI,IAAgB,EAAE,UAAU,EAAc,IAAI,CAAC;IACrD,CAAC,GAC+C;KAC9C,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CACsB;IAEtB,OADA,EAAkB,OAAO,GAAW,CAAO,GACpC;GACT,SAAS,GAAK;IAEZ,MADA,EAAkB,KAAK,GAAW,CAAG,GAC/B,IAAgB,EAA6B,GAAK,CAAa,IAAI,EAAmB,CAAG;GACjG;EACF;EACA,YAAY,GAAQ,MAAc;GAEhC,AAAI,EAAO,WACT,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAyC,EACjE,WAAW,EAAO,kBAAkB,EAAU,WAAW,CAAO,EAClE,CAAC,EACH,CAAC;GAEH,IAAM,IAAiB,EAAE,SAAS,EAAU,QAAQ;GAEpD,AADA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA+B,CAAc,EAAE,CAAC,GAC/G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAc,EAAE,CAAC;GAE7G,IAAM,IAAkB,EAAE,MAAM,EAAU,QAAQ;GAOlD,AANA,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAoC,CAAe,EAC/E,CAAC,GACD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA6B,CAAe,EACxE,CAAC,GACD,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAA+B,CAAe,EAC1E,CAAC;EACH;CACF,CAAC;AACH"}
@@ -1,11 +1,11 @@
1
1
  import { DeallocateParameters, SingleUpnlSig } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
3
  import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
- import { WriteParameters, WriteResult } from '../transactions/index.js';
4
+ import { AutomaticTimelockWriteParameters, WriteResult } from '../transactions/index.js';
5
5
  /**
6
6
  * Parameters for {@link useDeallocate}.
7
7
  */
8
- export type UseDeallocateParameters = WriteParameters;
8
+ export type UseDeallocateParameters = AutomaticTimelockWriteParameters;
9
9
  /**
10
10
  * Variables for the {@link useDeallocate} mutation: the core action's inputs
11
11
  * except `upnlSig` is **optional**. When omitted, the hook fetches a fresh Muon
@@ -26,11 +26,12 @@ export type UseDeallocateReturnType = UseMutationResult<DeallocateResult, Symmio
26
26
  * fresh Muon uPnL signature** (the contract requires it to prove the subaccount
27
27
  * stays solvent) immediately before submitting, unless you pass one as `upnlSig`.
28
28
  * The connected wallet must own the subaccount. On success, the subaccount's
29
- * balance reads are invalidated.
29
+ * balance, withdraw-cooldown and withdrawable-time reads are invalidated.
30
30
  *
31
31
  * @remarks
32
- * Subject to the on-chain deallocate debounce — submitting too soon after a prior
33
- * deallocate reverts. That (and an insolvent result, or a stale signature) is
32
+ * Subject to the on-chain deallocate debounce — submitting before
33
+ * `withdrawCooldownOf + debounce` reverts (read both with
34
+ * {@link useWithdrawCooldownOf} and {@link useDeallocateDebounceTime}). That (and an insolvent result, or a stale signature) is
34
35
  * surfaced as a normalized {@link SymmioRequestError}; enabling `simulateBeforeWrite`
35
36
  * catches it as a dry-run before anything is signed.
36
37
  *
@@ -1 +1 @@
1
- {"version":3,"file":"use-deallocate.d.ts","sourceRoot":"","sources":["../../src/account-layer/use-deallocate.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,oBAAoB,EACzB,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,eAAe,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,G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