@symmio/trading-react 4.3.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 (186) 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.d.ts +1 -0
  125. package/dist/instant-layer/use-instant-open-inputs.d.ts.map +1 -1
  126. package/dist/instant-layer/use-instant-open-inputs.js +81 -80
  127. package/dist/instant-layer/use-instant-open-inputs.js.map +1 -1
  128. package/dist/instant-layer/use-prepare-instant-open-params.d.ts +6 -0
  129. package/dist/instant-layer/use-prepare-instant-open-params.d.ts.map +1 -1
  130. package/dist/instant-layer/use-prepare-instant-open-params.js +1 -0
  131. package/dist/instant-layer/use-prepare-instant-open-params.js.map +1 -1
  132. package/dist/instant-layer/use-session-key-selectors.d.ts +5 -2
  133. package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -1
  134. package/dist/instant-layer/use-session-key-selectors.js +9 -5
  135. package/dist/instant-layer/use-session-key-selectors.js.map +1 -1
  136. package/dist/instant-layer/use-simulate-grant-delegations.d.ts +25 -0
  137. package/dist/instant-layer/use-simulate-grant-delegations.d.ts.map +1 -0
  138. package/dist/instant-layer/use-simulate-grant-delegations.js +29 -0
  139. package/dist/instant-layer/use-simulate-grant-delegations.js.map +1 -0
  140. package/dist/price-service/use-enigma-prices.d.ts +4 -0
  141. package/dist/price-service/use-enigma-prices.d.ts.map +1 -1
  142. package/dist/price-service/use-enigma-prices.js +60 -24
  143. package/dist/price-service/use-enigma-prices.js.map +1 -1
  144. package/dist/provider/symmio-provider.d.ts +31 -4
  145. package/dist/provider/symmio-provider.d.ts.map +1 -1
  146. package/dist/provider/symmio-provider.js +12 -11
  147. package/dist/provider/symmio-provider.js.map +1 -1
  148. package/dist/solvers/timelock-capability-cache.d.ts +9 -0
  149. package/dist/solvers/timelock-capability-cache.d.ts.map +1 -0
  150. package/dist/solvers/timelock-capability-cache.js +79 -0
  151. package/dist/solvers/timelock-capability-cache.js.map +1 -0
  152. package/dist/solvers/use-solver-info.d.ts +5 -2
  153. package/dist/solvers/use-solver-info.d.ts.map +1 -1
  154. package/dist/solvers/use-solver-info.js +35 -11
  155. package/dist/solvers/use-solver-info.js.map +1 -1
  156. package/dist/transactions/write-types.d.ts +13 -1
  157. package/dist/transactions/write-types.d.ts.map +1 -1
  158. package/dist/withdraw/index.d.ts +3 -0
  159. package/dist/withdraw/index.d.ts.map +1 -1
  160. package/dist/withdraw/use-deallocate-debounce-time.d.ts +29 -0
  161. package/dist/withdraw/use-deallocate-debounce-time.d.ts.map +1 -0
  162. package/dist/withdraw/use-deallocate-debounce-time.js +27 -0
  163. package/dist/withdraw/use-deallocate-debounce-time.js.map +1 -0
  164. package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
  165. package/dist/withdraw/use-finalize-withdraw-request.js +13 -12
  166. package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
  167. package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
  168. package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
  169. package/dist/withdraw/use-initiate-withdraw.js +29 -17
  170. package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
  171. package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts +19 -0
  172. package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts.map +1 -0
  173. package/dist/withdraw/use-pending-withdraw-requests-batch.js +27 -0
  174. package/dist/withdraw/use-pending-withdraw-requests-batch.js.map +1 -0
  175. package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
  176. package/dist/withdraw/use-request-cancel-withdraw.js +14 -13
  177. package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
  178. package/dist/withdraw/use-withdraw-cooldown-of.d.ts +33 -0
  179. package/dist/withdraw/use-withdraw-cooldown-of.d.ts.map +1 -0
  180. package/dist/withdraw/use-withdraw-cooldown-of.js +27 -0
  181. package/dist/withdraw/use-withdraw-cooldown-of.js.map +1 -0
  182. package/dist/withdraw/use-withdraw.d.ts +3 -3
  183. package/dist/withdraw/use-withdraw.d.ts.map +1 -1
  184. package/dist/withdraw/use-withdraw.js +57 -31
  185. package/dist/withdraw/use-withdraw.js.map +1 -1
  186. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-deallocate-debounce-time.js","names":[],"sources":["../../src/withdraw/use-deallocate-debounce-time.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getDeallocateDebounceTimeQueryOptions,\n type ConfigParameter,\n type GetDeallocateDebounceTimeOptions,\n type GetDeallocateDebounceTimeReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } 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\";\n\n/**\n * Parameters for {@link useDeallocateDebounceTime}: the core query options\n * (optional chain id, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseDeallocateDebounceTimeParameters = GetDeallocateDebounceTimeOptions & ConfigParameter;\n\n/** Return type of {@link useDeallocateDebounceTime}. */\nexport type UseDeallocateDebounceTimeReturnType = UseQueryResult<\n GetDeallocateDebounceTimeReturnType,\n SymmioRequestError\n>;\n\n/**\n * Read the protocol's deallocate debounce, in seconds: the minimum gap the\n * SYMMIO core enforces between two deallocations of the same account. A\n * deallocation reverts until `withdrawCooldownOf(account) + debounce` has\n * passed (see {@link useWithdrawCooldownOf}); `0n` means no gap.\n *\n * It is a deployment-wide setting, the same for every account, so it rarely\n * changes. `chainId` defaults to the connected chain.\n *\n * @param parameters - Optional chain id, query overrides and config.\n * @returns The TanStack query result; `data` is the debounce in seconds.\n *\n * @example\n * ```tsx\n * const { data: debounceSeconds } = useDeallocateDebounceTime();\n * ```\n */\nexport function useDeallocateDebounceTime(\n parameters: UseDeallocateDebounceTimeParameters = {},\n): UseDeallocateDebounceTimeReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getDeallocateDebounceTimeQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseDeallocateDebounceTimeReturnType;\n}\n"],"mappings":";;;;;;;AA2CA,SAAgB,EACd,IAAkD,CAAC,GACd;CACrC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAsC,GAAQ;EAC5D,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-finalize-withdraw-request.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-finalize-withdraw-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,iCAAiC,EACvC,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,oCAAoC,GAAG,eAAe,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,MAAM,6BAA6B,GAAG,WAAW,CAAC;AAExD,yDAAyD;AACzD,MAAM,MAAM,oCAAoC,GAAG,iBAAiB,CAClE,6BAA6B,EAC7B,kBAAkB,EAClB,iCAAiC,CAClC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,oCAAyC,GACpD,oCAAoC,CA6BtC"}
1
+ {"version":3,"file":"use-finalize-withdraw-request.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-finalize-withdraw-request.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,iCAAiC,EACvC,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,oCAAoC,GAAG,eAAe,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,MAAM,6BAA6B,GAAG,WAAW,CAAC;AAExD,yDAAyD;AACzD,MAAM,MAAM,oCAAoC,GAAG,iBAAiB,CAClE,6BAA6B,EAC7B,kBAAkB,EAClB,iCAAiC,CAClC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,oCAAyC,GACpD,oCAAoC,CAqCtC"}
@@ -4,35 +4,36 @@ 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
6
  import { predicateMatch as i } from "../utils/predicate-match.js";
7
- import { finalizeWithdrawRequestMutationOptions as a, getPendingWithdrawRequestsQueryKey as o, getWithdrawRequestsQueryKey as s, getWithdrawableTimeQueryKey as c } from "@symmio/trading-core";
8
- import { useMutation as l, useQueryClient as u } from "@tanstack/react-query";
7
+ import { finalizeWithdrawRequestMutationOptions as a, getPendingWithdrawRequestsBatchQueryKey as o, getPendingWithdrawRequestsQueryKey as s, getWithdrawRequestsQueryKey as c, getWithdrawableTimeQueryKey as l } from "@symmio/trading-core";
8
+ import { useMutation as u, useQueryClient as d } from "@tanstack/react-query";
9
9
  //#region src/withdraw/use-finalize-withdraw-request.ts
10
- function d(d = {}) {
11
- let f = t(d), p = e(), m = u(), h = a(f);
12
- return l({
13
- mutationKey: h.mutationKey,
10
+ function f(f = {}) {
11
+ let p = t(f), m = e(), h = d(), g = a(p);
12
+ return u({
13
+ mutationKey: g.mutationKey,
14
14
  mutationFn: async (e) => {
15
15
  try {
16
- let t = e.chainId ?? p;
17
- return r(f, await h.mutationFn({
16
+ let t = e.chainId ?? m;
17
+ return r(p, await g.mutationFn({
18
18
  ...e,
19
19
  chainId: t
20
20
  }), {
21
21
  chainId: t,
22
- waitForReceipt: d.waitForReceipt,
23
- confirmations: d.confirmations
22
+ waitForReceipt: f.waitForReceipt,
23
+ confirmations: f.confirmations
24
24
  });
25
25
  } catch (e) {
26
26
  throw n(e);
27
27
  }
28
28
  },
29
29
  onSuccess: (e, t) => {
30
+ e.receipt && h.invalidateQueries({ predicate: i(o, { configKey: p.getChainConfigKey(t.chainId ?? m) }) });
30
31
  let n = { user: t.user };
31
- m.invalidateQueries({ predicate: i(o, n) }), m.invalidateQueries({ predicate: i(s, n) }), m.invalidateQueries({ predicate: i(c, n) });
32
+ h.invalidateQueries({ predicate: i(s, n) }), h.invalidateQueries({ predicate: i(c, n) }), h.invalidateQueries({ predicate: i(l, n) });
32
33
  }
33
34
  });
34
35
  }
35
36
  //#endregion
36
- export { d as useFinalizeWithdrawRequest };
37
+ export { f as useFinalizeWithdrawRequest };
37
38
 
38
39
  //# sourceMappingURL=use-finalize-withdraw-request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-finalize-withdraw-request.js","names":[],"sources":["../../src/withdraw/use-finalize-withdraw-request.ts"],"sourcesContent":["\"use client\";\n\nimport {\n finalizeWithdrawRequestMutationOptions,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n type FinalizeWithdrawRequestParameters,\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 useFinalizeWithdrawRequest}.\n */\nexport type UseFinalizeWithdrawRequestParameters = WriteParameters;\n\n/** Result returned by the {@link useFinalizeWithdrawRequest} mutation. */\nexport type FinalizeWithdrawRequestResult = WriteResult;\n\n/** Return type of {@link useFinalizeWithdrawRequest}. */\nexport type UseFinalizeWithdrawRequestReturnType = UseMutationResult<\n FinalizeWithdrawRequestResult,\n SymmioRequestError,\n FinalizeWithdrawRequestParameters\n>;\n\n/**\n * Finalize a matured withdraw request, paying out collateral to its receivers.\n * The underlying core call is permissionless, so any connected wallet may submit\n * it. On success, the subaccount's pending-requests, single-request, and\n * withdrawable-time queries are invalidated.\n *\n * @example\n * ```tsx\n * const { mutate } = useFinalizeWithdrawRequest();\n * mutate({ user: \"0xsub…\", requestId: 1n });\n * ```\n */\nexport function useFinalizeWithdrawRequest(\n parameters: UseFinalizeWithdrawRequestParameters = {},\n): UseFinalizeWithdrawRequestReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = finalizeWithdrawRequestMutationOptions(config);\n\n return useMutation<FinalizeWithdrawRequestResult, SymmioRequestError, FinalizeWithdrawRequestParameters>({\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: (_result, variables) => {\n const partial = { user: variables.user };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawableTimeQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA4CA,SAAgB,EACd,IAAmD,CAAC,GACd;CACtC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAuC,CAAM;CAE1D,OAAO,EAAkG;EACvG,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,YAAY,GAAS,MAAc;GACjC,IAAM,IAAU,EAAE,MAAM,EAAU,KAAK;GAGvC,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAoC,CAAO,EAAE,CAAC,GAC7G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC,GACtG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC;EACxG;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-finalize-withdraw-request.js","names":[],"sources":["../../src/withdraw/use-finalize-withdraw-request.ts"],"sourcesContent":["\"use client\";\n\nimport {\n finalizeWithdrawRequestMutationOptions,\n getPendingWithdrawRequestsBatchQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n type FinalizeWithdrawRequestParameters,\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 useFinalizeWithdrawRequest}.\n */\nexport type UseFinalizeWithdrawRequestParameters = WriteParameters;\n\n/** Result returned by the {@link useFinalizeWithdrawRequest} mutation. */\nexport type FinalizeWithdrawRequestResult = WriteResult;\n\n/** Return type of {@link useFinalizeWithdrawRequest}. */\nexport type UseFinalizeWithdrawRequestReturnType = UseMutationResult<\n FinalizeWithdrawRequestResult,\n SymmioRequestError,\n FinalizeWithdrawRequestParameters\n>;\n\n/**\n * Finalize a matured withdraw request, paying out collateral to its receivers.\n * The underlying core call is permissionless, so any connected wallet may submit\n * it. On success, the subaccount's pending-requests, single-request, and\n * withdrawable-time queries are invalidated.\n *\n * @example\n * ```tsx\n * const { mutate } = useFinalizeWithdrawRequest();\n * mutate({ user: \"0xsub…\", requestId: 1n });\n * ```\n */\nexport function useFinalizeWithdrawRequest(\n parameters: UseFinalizeWithdrawRequestParameters = {},\n): UseFinalizeWithdrawRequestReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = finalizeWithdrawRequestMutationOptions(config);\n\n return useMutation<FinalizeWithdrawRequestResult, SymmioRequestError, FinalizeWithdrawRequestParameters>({\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: (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 partial = { user: variables.user };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawableTimeQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA6CA,SAAgB,EACd,IAAmD,CAAC,GACd;CACtC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAuC,CAAM;CAE1D,OAAO,EAAkG;EACvG,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,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,IAAU,EAAE,MAAM,EAAU,KAAK;GAGvC,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAoC,CAAO,EAAE,CAAC,GAC7G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC,GACtG,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC;EACxG;CACF,CAAC;AACH"}
@@ -1,11 +1,11 @@
1
1
  import { InitiateWithdrawParameters } 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 useInitiateWithdraw}.
7
7
  */
8
- export type UseInitiateWithdrawParameters = WriteParameters;
8
+ export type UseInitiateWithdrawParameters = AutomaticTimelockWriteParameters;
9
9
  /** Result returned by the {@link useInitiateWithdraw} mutation. */
10
10
  export type InitiateWithdrawResult = WriteResult;
11
11
  /** Return type of {@link useInitiateWithdraw}. */
@@ -1 +1 @@
1
- {"version":3,"file":"use-initiate-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-initiate-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,0BAA0B,EAChC,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,6BAA6B,GAAG,eAAe,CAAC;AAE5D,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAEjD,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,iBAAiB,CAC3D,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,CAC3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,6BAAkC,GAAG,6BAA6B,CA6BjH"}
1
+ {"version":3,"file":"use-initiate-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-initiate-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,gCAAgC,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9G;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,gCAAgC,CAAC;AAE7E,mEAAmE;AACnE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAEjD,kDAAkD;AAClD,MAAM,MAAM,6BAA6B,GAAG,iBAAiB,CAC3D,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,CAC3B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAE,6BAAkC,GAAG,6BAA6B,CAqDjH"}
@@ -3,36 +3,48 @@ 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 { getLastWithdrawRequestIdQueryKey as a, getPendingWithdrawRequestsQueryKey as o, getWithdrawableTimeQueryKey as s, initiateWithdrawMutationOptions as c } from "@symmio/trading-core";
8
- import { useMutation as l, useQueryClient as u } 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 "../account-layer/use-automatic-timelock.js";
9
+ import { getLastWithdrawRequestIdQueryKey as s, getPendingWithdrawRequestsBatchQueryKey as c, getPendingWithdrawRequestsQueryKey as l, getWithdrawableTimeQueryKey as u, initiateWithdrawMutationOptions as d } from "@symmio/trading-core";
10
+ import { useMutation as f, useQueryClient as p } from "@tanstack/react-query";
9
11
  //#region src/withdraw/use-initiate-withdraw.ts
10
- function d(d = {}) {
11
- let f = t(d), p = e(), m = u(), h = c(f);
12
- return l({
13
- mutationKey: h.mutationKey,
12
+ function m(m = {}) {
13
+ let h = t(m), g = e(), _ = p(), v = o(h, m.automaticTimelock), y = d(h);
14
+ return f({
15
+ mutationKey: y.mutationKey,
14
16
  mutationFn: async (e) => {
17
+ let t = e.timelock;
15
18
  try {
16
- let t = e.chainId ?? p;
17
- return r(f, await h.mutationFn({
19
+ let n = e.chainId ?? g;
20
+ t = await v(e, {
21
+ account: e.account,
22
+ chainId: n,
23
+ functionName: "initiateWithdraw",
24
+ explicit: t
25
+ });
26
+ let i = await r(h, await y.mutationFn({
18
27
  ...e,
19
- chainId: t
28
+ chainId: n,
29
+ ...t ? { timelock: t } : {}
20
30
  }), {
21
- chainId: t,
22
- waitForReceipt: d.waitForReceipt,
23
- confirmations: d.confirmations
31
+ chainId: n,
32
+ waitForReceipt: m.waitForReceipt,
33
+ confirmations: m.confirmations
24
34
  });
25
- } catch (e) {
26
- throw n(e);
35
+ return v.finish(e, i), i;
36
+ } catch (r) {
37
+ throw v.fail(e, r), t ? i(r, t) : n(r);
27
38
  }
28
39
  },
29
40
  onSuccess: (e, t) => {
41
+ e.receipt && _.invalidateQueries({ predicate: a(c, { configKey: h.getChainConfigKey(t.chainId ?? g) }) });
30
42
  let n = { user: t.account };
31
- m.invalidateQueries({ predicate: i(o, n) }), m.invalidateQueries({ predicate: i(a, n) }), m.invalidateQueries({ predicate: i(s, n) });
43
+ _.invalidateQueries({ predicate: a(l, n) }), _.invalidateQueries({ predicate: a(s, n) }), _.invalidateQueries({ predicate: a(u, n) });
32
44
  }
33
45
  });
34
46
  }
35
47
  //#endregion
36
- export { d as useInitiateWithdraw };
48
+ export { m as useInitiateWithdraw };
37
49
 
38
50
  //# sourceMappingURL=use-initiate-withdraw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-initiate-withdraw.js","names":[],"sources":["../../src/withdraw/use-initiate-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getLastWithdrawRequestIdQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n initiateWithdrawMutationOptions,\n type InitiateWithdrawParameters,\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 useInitiateWithdraw}.\n */\nexport type UseInitiateWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useInitiateWithdraw} mutation. */\nexport type InitiateWithdrawResult = WriteResult;\n\n/** Return type of {@link useInitiateWithdraw}. */\nexport type UseInitiateWithdrawReturnType = UseMutationResult<\n InitiateWithdrawResult,\n SymmioRequestError,\n InitiateWithdrawParameters\n>;\n\n/**\n * Open a withdraw request for a subaccount (the SDK routes it through the\n * AccountLayer `_call` proxy). The full input surface is exposed via the mutation\n * variables — `parts`, `speedUp`, `providerData`. On success, the subaccount's\n * pending-requests, last-request-id, and withdrawable-time queries are\n * invalidated.\n *\n * @example\n * ```tsx\n * import { createClassicWithdrawPart } from \"@symmio/trading-core\";\n * const { mutate } = useInitiateWithdraw();\n * mutate({ account: \"0xsub…\", parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId: 42161n })] });\n * ```\n */\nexport function useInitiateWithdraw(parameters: UseInitiateWithdrawParameters = {}): UseInitiateWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = initiateWithdrawMutationOptions(config);\n\n return useMutation<InitiateWithdrawResult, SymmioRequestError, InitiateWithdrawParameters>({\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: (_result, variables) => {\n const partial = { user: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getLastWithdrawRequestIdQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawableTimeQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAgB,EAAoB,IAA4C,CAAC,GAAkC;CACjH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAgC,CAAM;CAEnD,OAAO,EAAoF;EACzF,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,YAAY,GAAS,MAAc;GACjC,IAAM,IAAU,EAAE,MAAM,EAAU,QAAQ;GAG1C,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAoC,CAAO,EAAE,CAAC,GAC7G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAkC,CAAO,EAAE,CAAC,GAC3G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC;EACxG;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-initiate-withdraw.js","names":[],"sources":["../../src/withdraw/use-initiate-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getLastWithdrawRequestIdQueryKey,\n getPendingWithdrawRequestsBatchQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawableTimeQueryKey,\n initiateWithdrawMutationOptions,\n type InitiateWithdrawParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useAutomaticTimelock } from \"../account-layer/use-automatic-timelock\";\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\";\n\n/**\n * Parameters for {@link useInitiateWithdraw}.\n */\nexport type UseInitiateWithdrawParameters = AutomaticTimelockWriteParameters;\n\n/** Result returned by the {@link useInitiateWithdraw} mutation. */\nexport type InitiateWithdrawResult = WriteResult;\n\n/** Return type of {@link useInitiateWithdraw}. */\nexport type UseInitiateWithdrawReturnType = UseMutationResult<\n InitiateWithdrawResult,\n SymmioRequestError,\n InitiateWithdrawParameters\n>;\n\n/**\n * Open a withdraw request for a subaccount (the SDK routes it through the\n * AccountLayer `_call` proxy). The full input surface is exposed via the mutation\n * variables — `parts`, `speedUp`, `providerData`. On success, the subaccount's\n * pending-requests, last-request-id, and withdrawable-time queries are\n * invalidated.\n *\n * @example\n * ```tsx\n * import { createClassicWithdrawPart } from \"@symmio/trading-core\";\n * const { mutate } = useInitiateWithdraw();\n * mutate({ account: \"0xsub…\", parts: [createClassicWithdrawPart({ id: 0n, amount, receiver, chainId: 42161n })] });\n * ```\n */\nexport function useInitiateWithdraw(parameters: UseInitiateWithdrawParameters = {}): UseInitiateWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n const automaticTimelock = useAutomaticTimelock(config, parameters.automaticTimelock);\n\n const base = initiateWithdrawMutationOptions(config);\n\n return useMutation<InitiateWithdrawResult, SymmioRequestError, InitiateWithdrawParameters>({\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(variables, {\n account: variables.account,\n chainId: resolvedChainId,\n functionName: \"initiateWithdraw\",\n explicit: authorization,\n });\n const hash = await base.mutationFn({\n ...variables,\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 partial = { user: variables.account };\n void queryClient.invalidateQueries({ predicate: predicateMatch(getPendingWithdrawRequestsQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getLastWithdrawRequestIdQueryKey, partial) });\n void queryClient.invalidateQueries({ predicate: predicateMatch(getWithdrawableTimeQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;;;AAiDA,SAAgB,EAAoB,IAA4C,CAAC,GAAkC;CACjH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAC7B,IAAoB,EAAqB,GAAQ,EAAW,iBAAiB,GAE7E,IAAO,EAAgC,CAAM;CAEnD,OAAO,EAAoF;EACzF,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI,IAAgB,EAAU;GAC9B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAC7C,IAAgB,MAAM,EAAkB,GAAW;KACjD,SAAS,EAAU;KACnB,SAAS;KACT,cAAc;KACd,UAAU;IACZ,CAAC;IAWD,IAAM,IAAU,MALD,EAAmB,GAAQ,MALvB,EAAK,WAAW;KACjC,GAAG;KACH,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,IAAU,EAAE,MAAM,EAAU,QAAQ;GAG1C,AAFA,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAoC,CAAO,EAAE,CAAC,GAC7G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAkC,CAAO,EAAE,CAAC,GAC3G,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAA6B,CAAO,EAAE,CAAC;EACxG;CACF,CAAC;AACH"}
@@ -0,0 +1,19 @@
1
+ import { ConfigParameter, GetPendingWithdrawRequestsBatchOptions, GetPendingWithdrawRequestsBatchReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /** Inputs for complete multi-subaccount pending-withdrawal reads. */
5
+ export type UsePendingWithdrawRequestsBatchParameters = GetPendingWithdrawRequestsBatchOptions & ConfigParameter;
6
+ /** Query state and complete per-user pending requests. */
7
+ export type UsePendingWithdrawRequestsBatchReturnType = UseQueryResult<GetPendingWithdrawRequestsBatchReturnType, SymmioRequestError>;
8
+ /**
9
+ * Read every pending-withdrawal page for each distinct user. Empty users disable
10
+ * automatic reads; errors are normalized and never become partial empty balances.
11
+ * @param parameters - Users, optional page size, chain/config and query overrides.
12
+ * @returns The complete query result. Presentation and polling policy stay with the consumer.
13
+ * @example
14
+ * ```tsx
15
+ * const pending = usePendingWithdrawRequestsBatch({ users: subAccounts, chainId });
16
+ * ```
17
+ */
18
+ export declare function usePendingWithdrawRequestsBatch(parameters?: UsePendingWithdrawRequestsBatchParameters): UsePendingWithdrawRequestsBatchReturnType;
19
+ //# sourceMappingURL=use-pending-withdraw-requests-batch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pending-withdraw-requests-batch.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-pending-withdraw-requests-batch.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,sCAAsC,EAC3C,KAAK,yCAAyC,EAC/C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,qEAAqE;AACrE,MAAM,MAAM,yCAAyC,GAAG,sCAAsC,GAAG,eAAe,CAAC;AACjH,0DAA0D;AAC1D,MAAM,MAAM,yCAAyC,GAAG,cAAc,CACpE,yCAAyC,EACzC,kBAAkB,CACnB,CAAC;AACF;;;;;;;;;GASG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,GAAE,yCAA8C,GACzD,yCAAyC,CAiB3C"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { getPendingWithdrawRequestsBatchQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/withdraw/use-pending-withdraw-requests-batch.ts
8
+ function a(a = {}) {
9
+ let o = t(a), s = e(), c = r(o, {
10
+ ...a,
11
+ chainId: a.chainId ?? s
12
+ });
13
+ return i({
14
+ ...c,
15
+ queryFn: async () => {
16
+ try {
17
+ return await c.queryFn();
18
+ } catch (e) {
19
+ throw n(e);
20
+ }
21
+ }
22
+ });
23
+ }
24
+ //#endregion
25
+ export { a as usePendingWithdrawRequestsBatch };
26
+
27
+ //# sourceMappingURL=use-pending-withdraw-requests-batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pending-withdraw-requests-batch.js","names":[],"sources":["../../src/withdraw/use-pending-withdraw-requests-batch.ts"],"sourcesContent":["\"use client\";\nimport {\n getPendingWithdrawRequestsBatchQueryOptions,\n type ConfigParameter,\n type GetPendingWithdrawRequestsBatchOptions,\n type GetPendingWithdrawRequestsBatchReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } 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\";\n/** Inputs for complete multi-subaccount pending-withdrawal reads. */\nexport type UsePendingWithdrawRequestsBatchParameters = GetPendingWithdrawRequestsBatchOptions & ConfigParameter;\n/** Query state and complete per-user pending requests. */\nexport type UsePendingWithdrawRequestsBatchReturnType = UseQueryResult<\n GetPendingWithdrawRequestsBatchReturnType,\n SymmioRequestError\n>;\n/**\n * Read every pending-withdrawal page for each distinct user. Empty users disable\n * automatic reads; errors are normalized and never become partial empty balances.\n * @param parameters - Users, optional page size, chain/config and query overrides.\n * @returns The complete query result. Presentation and polling policy stay with the consumer.\n * @example\n * ```tsx\n * const pending = usePendingWithdrawRequestsBatch({ users: subAccounts, chainId });\n * ```\n */\nexport function usePendingWithdrawRequestsBatch(\n parameters: UsePendingWithdrawRequestsBatchParameters = {},\n): UsePendingWithdrawRequestsBatchReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getPendingWithdrawRequestsBatchQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (error) {\n throw normalizeSymmError(error);\n }\n },\n }) as UsePendingWithdrawRequestsBatchReturnType;\n}\n"],"mappings":";;;;;;;AA6BA,SAAgB,EACd,IAAwD,CAAC,GACd;CAC3C,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA4C,GAAQ;EAClE,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CACD,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAO;IACd,MAAM,EAAmB,CAAK;GAChC;EACF;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-request-cancel-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,+BAA+B,EACrC,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,kCAAkC,GAAG,eAAe,CAAC;AAEjE,wEAAwE;AACxE,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC;AAEtD,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,iBAAiB,CAChE,2BAA2B,EAC3B,kBAAkB,EAClB,+BAA+B,CAChC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,kCAAuC,GAClD,kCAAkC,CAoCpC"}
1
+ {"version":3,"file":"use-request-cancel-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,+BAA+B,EACrC,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,kCAAkC,GAAG,eAAe,CAAC;AAEjE,wEAAwE;AACxE,MAAM,MAAM,2BAA2B,GAAG,WAAW,CAAC;AAEtD,uDAAuD;AACvD,MAAM,MAAM,kCAAkC,GAAG,iBAAiB,CAChE,2BAA2B,EAC3B,kBAAkB,EAClB,+BAA+B,CAChC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,GAAE,kCAAuC,GAClD,kCAAkC,CA4CpC"}
@@ -4,37 +4,38 @@ 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
6
  import { predicateMatch as i } from "../utils/predicate-match.js";
7
- import { getAccountBalanceInfoQueryKey as a, getAccountBalanceOfQueryKey as o, getPendingWithdrawRequestsQueryKey as s, getWithdrawRequestsQueryKey as c, requestCancelWithdrawMutationOptions as l } from "@symmio/trading-core";
8
- import { useMutation as u, useQueryClient as d } from "@tanstack/react-query";
7
+ import { getAccountBalanceInfoQueryKey as a, getAccountBalanceOfQueryKey as o, getPendingWithdrawRequestsBatchQueryKey as s, getPendingWithdrawRequestsQueryKey as c, getWithdrawRequestsQueryKey as l, requestCancelWithdrawMutationOptions as u } from "@symmio/trading-core";
8
+ import { useMutation as d, useQueryClient as f } from "@tanstack/react-query";
9
9
  //#region src/withdraw/use-request-cancel-withdraw.ts
10
- function f(f = {}) {
11
- let p = t(f), m = e(), h = d(), g = l(p);
12
- return u({
13
- mutationKey: g.mutationKey,
10
+ function p(p = {}) {
11
+ let m = t(p), h = e(), g = f(), _ = u(m);
12
+ return d({
13
+ mutationKey: _.mutationKey,
14
14
  mutationFn: async (e) => {
15
15
  try {
16
- let t = e.chainId ?? m;
17
- return r(p, await g.mutationFn({
16
+ let t = e.chainId ?? h;
17
+ return r(m, await _.mutationFn({
18
18
  ...e,
19
19
  chainId: t
20
20
  }), {
21
21
  chainId: t,
22
- waitForReceipt: f.waitForReceipt,
23
- confirmations: f.confirmations
22
+ waitForReceipt: p.waitForReceipt,
23
+ confirmations: p.confirmations
24
24
  });
25
25
  } catch (e) {
26
26
  throw n(e);
27
27
  }
28
28
  },
29
29
  onSuccess: (e, t) => {
30
+ e.receipt && g.invalidateQueries({ predicate: i(s, { configKey: m.getChainConfigKey(t.chainId ?? h) }) });
30
31
  let n = { account: t.account };
31
- h.invalidateQueries({ predicate: i(a, n) }), h.invalidateQueries({ predicate: i(o, n) });
32
+ g.invalidateQueries({ predicate: i(a, n) }), g.invalidateQueries({ predicate: i(o, n) });
32
33
  let r = { user: t.account };
33
- h.invalidateQueries({ predicate: i(s, r) }), h.invalidateQueries({ predicate: i(c, r) });
34
+ g.invalidateQueries({ predicate: i(c, r) }), g.invalidateQueries({ predicate: i(l, r) });
34
35
  }
35
36
  });
36
37
  }
37
38
  //#endregion
38
- export { f as useRequestCancelWithdraw };
39
+ export { p as useRequestCancelWithdraw };
39
40
 
40
41
  //# sourceMappingURL=use-request-cancel-withdraw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-request-cancel-withdraw.js","names":[],"sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getAccountBalanceInfoQueryKey,\n getAccountBalanceOfQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawRequestsQueryKey,\n requestCancelWithdrawMutationOptions,\n type RequestCancelWithdrawParameters,\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 useRequestCancelWithdraw}.\n */\nexport type UseRequestCancelWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useRequestCancelWithdraw} mutation. */\nexport type RequestCancelWithdrawResult = WriteResult;\n\n/** Return type of {@link useRequestCancelWithdraw}. */\nexport type UseRequestCancelWithdrawReturnType = UseMutationResult<\n RequestCancelWithdrawResult,\n SymmioRequestError,\n RequestCancelWithdrawParameters\n>;\n\n/**\n * Request cancellation of a pending withdraw request (routed through the\n * AccountLayer `_call` proxy). On success (after the receipt), the subaccount's\n * balance reads (`balanceInfo`, `balanceOf`) and its pending-requests / requests\n * queries are invalidated — cancel returns the reserved funds to the available\n * balance.\n *\n * @example\n * ```tsx\n * const { mutate } = useRequestCancelWithdraw();\n * mutate({ account: \"0xsub…\", requestId: 1n });\n * ```\n */\nexport function useRequestCancelWithdraw(\n parameters: UseRequestCancelWithdrawParameters = {},\n): UseRequestCancelWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = requestCancelWithdrawMutationOptions(config);\n\n return useMutation<RequestCancelWithdrawResult, SymmioRequestError, RequestCancelWithdrawParameters>({\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: (_result, variables) => {\n // Cancel returns the reserved funds to the subaccount's available balance and\n // removes the request — refetch balances + the withdraw lists (after the receipt).\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({ predicate: predicateMatch(getWithdrawRequestsQueryKey, withdrawPartial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA8CA,SAAgB,EACd,IAAiD,CAAC,GACd;CACpC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAqC,CAAM;CAExD,OAAO,EAA8F;EACnG,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,YAAY,GAAS,MAAc;GAGjC,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,EAAE,WAAW,EAAe,GAA6B,CAAe,EAAE,CAAC;EAChH;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-request-cancel-withdraw.js","names":[],"sources":["../../src/withdraw/use-request-cancel-withdraw.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getAccountBalanceInfoQueryKey,\n getAccountBalanceOfQueryKey,\n getPendingWithdrawRequestsBatchQueryKey,\n getPendingWithdrawRequestsQueryKey,\n getWithdrawRequestsQueryKey,\n requestCancelWithdrawMutationOptions,\n type RequestCancelWithdrawParameters,\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 useRequestCancelWithdraw}.\n */\nexport type UseRequestCancelWithdrawParameters = WriteParameters;\n\n/** Result returned by the {@link useRequestCancelWithdraw} mutation. */\nexport type RequestCancelWithdrawResult = WriteResult;\n\n/** Return type of {@link useRequestCancelWithdraw}. */\nexport type UseRequestCancelWithdrawReturnType = UseMutationResult<\n RequestCancelWithdrawResult,\n SymmioRequestError,\n RequestCancelWithdrawParameters\n>;\n\n/**\n * Request cancellation of a pending withdraw request (routed through the\n * AccountLayer `_call` proxy). On success (after the receipt), the subaccount's\n * balance reads (`balanceInfo`, `balanceOf`) and its pending-requests / requests\n * queries are invalidated — cancel returns the reserved funds to the available\n * balance.\n *\n * @example\n * ```tsx\n * const { mutate } = useRequestCancelWithdraw();\n * mutate({ account: \"0xsub…\", requestId: 1n });\n * ```\n */\nexport function useRequestCancelWithdraw(\n parameters: UseRequestCancelWithdrawParameters = {},\n): UseRequestCancelWithdrawReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = requestCancelWithdrawMutationOptions(config);\n\n return useMutation<RequestCancelWithdrawResult, SymmioRequestError, RequestCancelWithdrawParameters>({\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: (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 // Cancel returns the reserved funds to the subaccount's available balance and\n // removes the request — refetch balances + the withdraw lists (after the receipt).\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({ predicate: predicateMatch(getWithdrawRequestsQueryKey, withdrawPartial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA+CA,SAAgB,EACd,IAAiD,CAAC,GACd;CACpC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAAqC,CAAM;CAExD,OAAO,EAA8F;EACnG,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,YAAY,GAAQ,MAAc;GAEhC,AAAI,EAAO,WACT,EAAiB,kBAAkB,EACjC,WAAW,EAAe,GAAyC,EACjE,WAAW,EAAO,kBAAkB,EAAU,WAAW,CAAO,EAClE,CAAC,EACH,CAAC;GAIH,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,EAAE,WAAW,EAAe,GAA6B,CAAe,EAAE,CAAC;EAChH;CACF,CAAC;AACH"}
@@ -0,0 +1,33 @@
1
+ import { ConfigParameter, GetWithdrawCooldownOfOptions, GetWithdrawCooldownOfReturnType } from '@symmio/trading-core';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Parameters for {@link useWithdrawCooldownOf}: the core query options (`user`,
6
+ * optional chain id, TanStack `query` overrides) plus an optional `config`.
7
+ */
8
+ export type UseWithdrawCooldownOfParameters = GetWithdrawCooldownOfOptions & ConfigParameter;
9
+ /** Return type of {@link useWithdrawCooldownOf}. */
10
+ export type UseWithdrawCooldownOfReturnType = UseQueryResult<GetWithdrawCooldownOfReturnType, SymmioRequestError>;
11
+ /**
12
+ * Read a subaccount's raw `withdrawCooldownOf` value: the core's stored
13
+ * `deallocateTimestamp`, in Unix seconds.
14
+ *
15
+ * Deallocation and internal credits to withdrawable balance stamp it; ordinary
16
+ * external deposits do not. It is **a timestamp, not a duration**, and not the
17
+ * time a withdrawal unlocks — use {@link useWithdrawableTime} to know when a
18
+ * withdrawal initiated now could be finalized. `chainId` defaults to the
19
+ * connected chain.
20
+ *
21
+ * Deallocation hooks (`useDeallocate`, `useDeallocateAndInitiateWithdraw`,
22
+ * `useWithdraw`) refresh this read once they succeed.
23
+ *
24
+ * @param parameters - The subaccount (`user`), optional chain id, query overrides and config.
25
+ * @returns The TanStack query result; `data` is the stored timestamp in seconds (`0n` when never stamped).
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * const { data: lastCredit } = useWithdrawCooldownOf({ user: subAccount });
30
+ * ```
31
+ */
32
+ export declare function useWithdrawCooldownOf(parameters: UseWithdrawCooldownOfParameters): UseWithdrawCooldownOfReturnType;
33
+ //# sourceMappingURL=use-withdraw-cooldown-of.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-withdraw-cooldown-of.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-withdraw-cooldown-of.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,+BAA+B,EACrC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE;;;GAGG;AACH,MAAM,MAAM,+BAA+B,GAAG,4BAA4B,GAAG,eAAe,CAAC;AAE7F,oDAAoD;AACpD,MAAM,MAAM,+BAA+B,GAAG,cAAc,CAAC,+BAA+B,EAAE,kBAAkB,CAAC,CAAC;AAElH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,+BAA+B,GAAG,+BAA+B,CAkBlH"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { useSymmioChainId as e } from "../provider/use-symmio-chain-id.js";
3
+ import { useSymmioConfig as t } from "../provider/use-symmio-config.js";
4
+ import { normalizeSymmError as n } from "../errors/normalize-symm-error.js";
5
+ import { getWithdrawCooldownOfQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/withdraw/use-withdraw-cooldown-of.ts
8
+ function a(a) {
9
+ let o = t(a), s = e(), c = r(o, {
10
+ ...a,
11
+ chainId: a.chainId ?? s
12
+ });
13
+ return i({
14
+ ...c,
15
+ queryFn: async () => {
16
+ try {
17
+ return await c.queryFn();
18
+ } catch (e) {
19
+ throw n(e);
20
+ }
21
+ }
22
+ });
23
+ }
24
+ //#endregion
25
+ export { a as useWithdrawCooldownOf };
26
+
27
+ //# sourceMappingURL=use-withdraw-cooldown-of.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-withdraw-cooldown-of.js","names":[],"sources":["../../src/withdraw/use-withdraw-cooldown-of.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getWithdrawCooldownOfQueryOptions,\n type ConfigParameter,\n type GetWithdrawCooldownOfOptions,\n type GetWithdrawCooldownOfReturnType,\n} from \"@symmio/trading-core\";\nimport { useQuery, type UseQueryResult } 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\";\n\n/**\n * Parameters for {@link useWithdrawCooldownOf}: the core query options (`user`,\n * optional chain id, TanStack `query` overrides) plus an optional `config`.\n */\nexport type UseWithdrawCooldownOfParameters = GetWithdrawCooldownOfOptions & ConfigParameter;\n\n/** Return type of {@link useWithdrawCooldownOf}. */\nexport type UseWithdrawCooldownOfReturnType = UseQueryResult<GetWithdrawCooldownOfReturnType, SymmioRequestError>;\n\n/**\n * Read a subaccount's raw `withdrawCooldownOf` value: the core's stored\n * `deallocateTimestamp`, in Unix seconds.\n *\n * Deallocation and internal credits to withdrawable balance stamp it; ordinary\n * external deposits do not. It is **a timestamp, not a duration**, and not the\n * time a withdrawal unlocks — use {@link useWithdrawableTime} to know when a\n * withdrawal initiated now could be finalized. `chainId` defaults to the\n * connected chain.\n *\n * Deallocation hooks (`useDeallocate`, `useDeallocateAndInitiateWithdraw`,\n * `useWithdraw`) refresh this read once they succeed.\n *\n * @param parameters - The subaccount (`user`), optional chain id, query overrides and config.\n * @returns The TanStack query result; `data` is the stored timestamp in seconds (`0n` when never stamped).\n *\n * @example\n * ```tsx\n * const { data: lastCredit } = useWithdrawCooldownOf({ user: subAccount });\n * ```\n */\nexport function useWithdrawCooldownOf(parameters: UseWithdrawCooldownOfParameters): UseWithdrawCooldownOfReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getWithdrawCooldownOfQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n });\n\n return useQuery({\n ...options,\n queryFn: async () => {\n try {\n return await options.queryFn();\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseWithdrawCooldownOfReturnType;\n}\n"],"mappings":";;;;;;;AA4CA,SAAgB,EAAsB,GAA8E;CAClH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAAkC,GAAQ;EACxD,GAAG;EACH,SAAS,EAAW,WAAW;CACjC,CAAC;CAED,OAAO,EAAS;EACd,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,OAAO,MAAM,EAAQ,QAAQ;GAC/B,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;AACH"}
@@ -2,14 +2,14 @@ import { WithdrawAutoParameters } from '@symmio/trading-core';
2
2
  import { UseMutationResult } from '@tanstack/react-query';
3
3
  import { Address } from 'viem';
4
4
  import { SymmioRequestError } from '../errors/symmio-request-error.js';
5
- import { WriteParameters, WriteResult } from '../transactions/index.js';
5
+ import { AutomaticTimelockWriteParameters, WriteResult } from '../transactions/index.js';
6
6
  /**
7
7
  * Parameters for {@link useWithdraw}. `account` (the subaccount) and `chainId` are
8
8
  * read at hook time so the hook can resolve the subaccount's isolation type via
9
9
  * {@link useSubAccount}; the per-withdraw inputs (`amount`, `receiver`, …) are the
10
10
  * mutation variables.
11
11
  */
12
- export type UseWithdrawParameters = WriteParameters & {
12
+ export type UseWithdrawParameters = AutomaticTimelockWriteParameters & {
13
13
  /** The subaccount to withdraw from. The connected wallet must be its on-chain owner. */
14
14
  account?: Address;
15
15
  /** Target chain id. Defaults to the connected chain. */
@@ -46,7 +46,7 @@ export type UseWithdrawReturnType = UseMutationResult<WithdrawResult, SymmioRequ
46
46
  * scale anything.
47
47
  *
48
48
  * On success, the subaccount's balance reads (`balanceInfo`, `balanceOf`) and its
49
- * pending-requests / withdrawable-time reads are invalidated.
49
+ * pending-requests / withdrawable-time / withdraw-cooldown reads are invalidated.
50
50
  *
51
51
  * @remarks
52
52
  * On the `CUSTOM` path the SDK fetches a fresh Muon uPnL signature for the
@@ -1 +1 @@
1
- {"version":3,"file":"use-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,eAAe,GAAG;IACpD,wFAAwF;IACxF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,CAAC,CAAC;AAEzG,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AAEzC,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AAEhH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,WAAW,CAAC,UAAU,GAAE,qBAA0B,GAAG,qBAAqB,CAqDzF"}
1
+ {"version":3,"file":"use-withdraw.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-withdraw.ts"],"names":[],"mappings":"AAEA,OAAO,EAWL,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAKpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,gCAAgC,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9G;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,gCAAgC,GAAG;IACrE,wFAAwF;IACxF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,eAAe,GAAG,SAAS,CAAC,CAAC;AAEzG,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;AAEzC,0CAA0C;AAC1C,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,cAAc,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AAEhH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,WAAW,CAAC,UAAU,GAAE,qBAA0B,GAAG,qBAAqB,CA4GzF"}
@@ -3,48 +3,74 @@ 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 { useSubAccount as a } from "../account-layer/use-sub-account.js";
8
- import { SymmError as o, getAccountBalanceInfoQueryKey as s, getAccountBalanceOfQueryKey as c, getPendingWithdrawRequestsQueryKey as l, getWithdrawableTimeQueryKey as u, withdrawAutoMutationOptions as d } from "@symmio/trading-core";
9
- import { useMutation as f, useQueryClient as p } 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 "../account-layer/use-automatic-timelock.js";
9
+ import { useSubAccount as s } from "../account-layer/use-sub-account.js";
10
+ import { SubAccountIsolationType as c, SymmError as l, getAccountBalanceInfoQueryKey as u, getAccountBalanceOfQueryKey as d, getPendingWithdrawRequestsBatchQueryKey as f, getPendingWithdrawRequestsQueryKey as p, getSubAccountQueryOptions as m, getWithdrawCooldownOfQueryKey as h, getWithdrawableTimeQueryKey as g, withdrawAutoMutationOptions as _ } from "@symmio/trading-core";
11
+ import { useMutation as v, useQueryClient as y } from "@tanstack/react-query";
10
12
  //#region src/withdraw/use-withdraw.ts
11
- function m(m = {}) {
12
- let h = t(m), g = e(), _ = p(), v = m.chainId ?? g, { data: y } = a({
13
- account: m.account,
14
- chainId: m.chainId,
15
- config: m.config
16
- }), b = y?.isolationType, x = d(h);
17
- return f({
18
- mutationKey: x.mutationKey,
13
+ function b(b = {}) {
14
+ let x = t(b), S = e(), C = y(), w = o(x, b.automaticTimelock, b.account), T = b.chainId ?? S, { data: E } = s({
15
+ account: b.account,
16
+ chainId: b.chainId,
17
+ config: b.config
18
+ }), D = E?.isolationType, O = _(x);
19
+ return v({
20
+ mutationKey: O.mutationKey,
19
21
  mutationFn: async (e) => {
22
+ let t = e.timelock;
20
23
  try {
21
- let t = m.account;
22
- if (!t) throw new o("validation", "MISSING_ACCOUNT", "useWithdraw: `account` must be set on the hook.");
23
- return r(h, await x.mutationFn({
24
+ let n = b.account;
25
+ if (!n) throw new l("validation", "MISSING_ACCOUNT", "useWithdraw: `account` must be set on the hook.");
26
+ !t && b.automaticTimelock !== !1 && await w.guard(e, {
27
+ account: n,
28
+ chainId: T
29
+ });
30
+ let i = D, a = x.getSolver({ chainId: T }), o = b.automaticTimelock !== !1 && x.getChainConfig(T).timelockSupported !== !1 && a.capabilities?.timelockApproval !== !1 && (typeof b.automaticTimelock == "object" || a.id === "enigma" || a.capabilities?.timelockApproval === !0);
31
+ !t && o && (i ??= (await C.fetchQuery({
32
+ ...m(x, {
33
+ account: n,
34
+ chainId: T
35
+ }),
36
+ retry: !1
37
+ })).isolationType, t = i === c.CUSTOM ? await w.batch(e, {
38
+ account: n,
39
+ chainId: T,
40
+ functionNames: ["deallocate", "initiateWithdraw"]
41
+ }) : await w(e, {
42
+ account: n,
43
+ chainId: T,
44
+ functionName: "initiateWithdraw"
45
+ }));
46
+ let s = await r(x, await O.mutationFn({
24
47
  ...e,
25
- account: t,
26
- chainId: v,
27
- isolationType: b
48
+ account: n,
49
+ chainId: T,
50
+ isolationType: i,
51
+ ...t ? { timelock: t } : {}
28
52
  }), {
29
- chainId: v,
30
- waitForReceipt: m.waitForReceipt,
31
- confirmations: m.confirmations
53
+ chainId: T,
54
+ waitForReceipt: b.waitForReceipt,
55
+ confirmations: b.confirmations
32
56
  });
33
- } catch (e) {
34
- throw n(e);
57
+ return w.finish(e, s), s;
58
+ } catch (r) {
59
+ throw w.fail(e, r), t ? i(r, t) : n(r);
35
60
  }
36
61
  },
37
- onSuccess: () => {
38
- let e = m.account;
39
- if (!e) return;
40
- let t = { account: e };
41
- _.invalidateQueries({ predicate: i(s, t) }), _.invalidateQueries({ predicate: i(c, t) });
42
- let n = { user: e };
43
- _.invalidateQueries({ predicate: i(l, n) }), _.invalidateQueries({ predicate: i(u, n) });
62
+ onSuccess: (e) => {
63
+ e.receipt && C.invalidateQueries({ predicate: a(f, { configKey: x.getChainConfigKey(T) }) });
64
+ let t = b.account;
65
+ if (!t) return;
66
+ let n = { account: t };
67
+ C.invalidateQueries({ predicate: a(u, n) }), C.invalidateQueries({ predicate: a(d, n) });
68
+ let r = { user: t };
69
+ C.invalidateQueries({ predicate: a(p, r) }), C.invalidateQueries({ predicate: a(g, r) }), C.invalidateQueries({ predicate: a(h, r) });
44
70
  }
45
71
  });
46
72
  }
47
73
  //#endregion
48
- export { m as useWithdraw };
74
+ export { b as useWithdraw };
49
75
 
50
76
  //# sourceMappingURL=use-withdraw.js.map