@symmio/trading-react 4.4.0 → 4.6.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 (203) 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/candles/index.d.ts +2 -0
  77. package/dist/candles/index.d.ts.map +1 -1
  78. package/dist/candles/index.js +6 -4
  79. package/dist/candles/use-candle-history.d.ts +30 -0
  80. package/dist/candles/use-candle-history.d.ts.map +1 -0
  81. package/dist/candles/use-candle-history.js +66 -0
  82. package/dist/candles/use-candle-history.js.map +1 -0
  83. package/dist/candles/use-candle-stream.d.ts +5 -4
  84. package/dist/candles/use-candle-stream.d.ts.map +1 -1
  85. package/dist/candles/use-candle-stream.js +17 -10
  86. package/dist/candles/use-candle-stream.js.map +1 -1
  87. package/dist/candles/use-candles.js +2 -2
  88. package/dist/candles/use-candles.js.map +1 -1
  89. package/dist/candles/use-lowcap-candle-source.d.ts +19 -0
  90. package/dist/candles/use-lowcap-candle-source.d.ts.map +1 -0
  91. package/dist/candles/use-lowcap-candle-source.js +25 -0
  92. package/dist/candles/use-lowcap-candle-source.js.map +1 -0
  93. package/dist/errors/normalize-protected-write-error.d.ts +5 -0
  94. package/dist/errors/normalize-protected-write-error.d.ts.map +1 -0
  95. package/dist/errors/normalize-protected-write-error.js +43 -0
  96. package/dist/errors/normalize-protected-write-error.js.map +1 -0
  97. package/dist/errors/normalize-symm-error.d.ts.map +1 -1
  98. package/dist/errors/normalize-symm-error.js +56 -43
  99. package/dist/errors/normalize-symm-error.js.map +1 -1
  100. package/dist/errors/symmio-request-error.d.ts +5 -0
  101. package/dist/errors/symmio-request-error.d.ts.map +1 -1
  102. package/dist/errors/symmio-request-error.js +2 -1
  103. package/dist/errors/symmio-request-error.js.map +1 -1
  104. package/dist/gasless/index.d.ts +3 -0
  105. package/dist/gasless/index.d.ts.map +1 -1
  106. package/dist/gasless/index.js +22 -19
  107. package/dist/gasless/invalidate-relay-reads.d.ts +3 -1
  108. package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -1
  109. package/dist/gasless/invalidate-relay-reads.js +115 -60
  110. package/dist/gasless/invalidate-relay-reads.js.map +1 -1
  111. package/dist/gasless/use-approve-operational-fee-allowance.d.ts +37 -0
  112. package/dist/gasless/use-approve-operational-fee-allowance.d.ts.map +1 -0
  113. package/dist/gasless/use-approve-operational-fee-allowance.js +48 -0
  114. package/dist/gasless/use-approve-operational-fee-allowance.js.map +1 -0
  115. package/dist/gasless/use-approve-operational-fee.d.ts +2 -2
  116. package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -1
  117. package/dist/gasless/use-approve-operational-fee.js +28 -17
  118. package/dist/gasless/use-approve-operational-fee.js.map +1 -1
  119. package/dist/gasless/use-gasless-batch-funding.d.ts +22 -0
  120. package/dist/gasless/use-gasless-batch-funding.d.ts.map +1 -0
  121. package/dist/gasless/use-gasless-batch-funding.js +27 -0
  122. package/dist/gasless/use-gasless-batch-funding.js.map +1 -0
  123. package/dist/gasless/use-gasless-margin-funding.d.ts +26 -0
  124. package/dist/gasless/use-gasless-margin-funding.d.ts.map +1 -0
  125. package/dist/gasless/use-gasless-margin-funding.js +27 -0
  126. package/dist/gasless/use-gasless-margin-funding.js.map +1 -0
  127. package/dist/gasless/use-relay-gasless-batch.d.ts +5 -4
  128. package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -1
  129. package/dist/gasless/use-relay-gasless-batch.js.map +1 -1
  130. package/dist/index.d.ts +14 -8
  131. package/dist/index.d.ts.map +1 -1
  132. package/dist/index.js +275 -256
  133. package/dist/instant-layer/index.d.ts +2 -0
  134. package/dist/instant-layer/index.d.ts.map +1 -1
  135. package/dist/instant-layer/index.js +25 -23
  136. package/dist/instant-layer/invalidate-delegation-grant.d.ts +17 -0
  137. package/dist/instant-layer/invalidate-delegation-grant.d.ts.map +1 -0
  138. package/dist/instant-layer/invalidate-delegation-grant.js +26 -0
  139. package/dist/instant-layer/invalidate-delegation-grant.js.map +1 -0
  140. package/dist/instant-layer/use-grant-delegation.d.ts +3 -1
  141. package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
  142. package/dist/instant-layer/use-grant-delegation.js +19 -28
  143. package/dist/instant-layer/use-grant-delegation.js.map +1 -1
  144. package/dist/instant-layer/use-grant-delegations.d.ts +44 -0
  145. package/dist/instant-layer/use-grant-delegations.d.ts.map +1 -0
  146. package/dist/instant-layer/use-grant-delegations.js +36 -0
  147. package/dist/instant-layer/use-grant-delegations.js.map +1 -0
  148. package/dist/instant-layer/use-instant-close-fees.js +8 -8
  149. package/dist/instant-layer/use-instant-open-inputs.js +8 -8
  150. package/dist/instant-layer/use-session-key-selectors.d.ts +5 -2
  151. package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -1
  152. package/dist/instant-layer/use-session-key-selectors.js +9 -5
  153. package/dist/instant-layer/use-session-key-selectors.js.map +1 -1
  154. package/dist/instant-layer/use-simulate-grant-delegations.d.ts +25 -0
  155. package/dist/instant-layer/use-simulate-grant-delegations.d.ts.map +1 -0
  156. package/dist/instant-layer/use-simulate-grant-delegations.js +29 -0
  157. package/dist/instant-layer/use-simulate-grant-delegations.js.map +1 -0
  158. package/dist/pools/use-listing-config.d.ts +3 -1
  159. package/dist/pools/use-listing-config.d.ts.map +1 -1
  160. package/dist/pools/use-listing-config.js.map +1 -1
  161. package/dist/provider/symmio-provider.d.ts +31 -4
  162. package/dist/provider/symmio-provider.d.ts.map +1 -1
  163. package/dist/provider/symmio-provider.js +12 -11
  164. package/dist/provider/symmio-provider.js.map +1 -1
  165. package/dist/solvers/timelock-capability-cache.d.ts +9 -0
  166. package/dist/solvers/timelock-capability-cache.d.ts.map +1 -0
  167. package/dist/solvers/timelock-capability-cache.js +79 -0
  168. package/dist/solvers/timelock-capability-cache.js.map +1 -0
  169. package/dist/solvers/use-solver-info.d.ts +5 -2
  170. package/dist/solvers/use-solver-info.d.ts.map +1 -1
  171. package/dist/solvers/use-solver-info.js +35 -11
  172. package/dist/solvers/use-solver-info.js.map +1 -1
  173. package/dist/transactions/write-types.d.ts +13 -1
  174. package/dist/transactions/write-types.d.ts.map +1 -1
  175. package/dist/withdraw/index.d.ts +3 -0
  176. package/dist/withdraw/index.d.ts.map +1 -1
  177. package/dist/withdraw/use-deallocate-debounce-time.d.ts +29 -0
  178. package/dist/withdraw/use-deallocate-debounce-time.d.ts.map +1 -0
  179. package/dist/withdraw/use-deallocate-debounce-time.js +27 -0
  180. package/dist/withdraw/use-deallocate-debounce-time.js.map +1 -0
  181. package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
  182. package/dist/withdraw/use-finalize-withdraw-request.js +13 -12
  183. package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
  184. package/dist/withdraw/use-initiate-withdraw.d.ts +2 -2
  185. package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
  186. package/dist/withdraw/use-initiate-withdraw.js +29 -17
  187. package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
  188. package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts +19 -0
  189. package/dist/withdraw/use-pending-withdraw-requests-batch.d.ts.map +1 -0
  190. package/dist/withdraw/use-pending-withdraw-requests-batch.js +27 -0
  191. package/dist/withdraw/use-pending-withdraw-requests-batch.js.map +1 -0
  192. package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
  193. package/dist/withdraw/use-request-cancel-withdraw.js +14 -13
  194. package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
  195. package/dist/withdraw/use-withdraw-cooldown-of.d.ts +33 -0
  196. package/dist/withdraw/use-withdraw-cooldown-of.d.ts.map +1 -0
  197. package/dist/withdraw/use-withdraw-cooldown-of.js +27 -0
  198. package/dist/withdraw/use-withdraw-cooldown-of.js.map +1 -0
  199. package/dist/withdraw/use-withdraw.d.ts +3 -3
  200. package/dist/withdraw/use-withdraw.d.ts.map +1 -1
  201. package/dist/withdraw/use-withdraw.js +57 -31
  202. package/dist/withdraw/use-withdraw.js.map +1 -1
  203. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"use-listing-config.d.ts","sourceRoot":"","sources":["../../src/pools/use-listing-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,iGAAiG;AACjG,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,GAAG,eAAe,CAAC;AAEnF,2FAA2F;AAC3F,MAAM,MAAM,0BAA0B,GAAG,cAAc,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,0BAA+B,GAAG,0BAA0B,CAkBxG"}
1
+ {"version":3,"file":"use-listing-config.d.ts","sourceRoot":"","sources":["../../src/pools/use-listing-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,iGAAiG;AACjG,MAAM,MAAM,0BAA0B,GAAG,uBAAuB,GAAG,eAAe,CAAC;AAEnF,2FAA2F;AAC3F,MAAM,MAAM,0BAA0B,GAAG,cAAc,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAE3F;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,GAAE,0BAA+B,GAAG,0BAA0B,CAkBxG"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-listing-config.js","names":[],"sources":["../../src/pools/use-listing-config.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getListingConfigQueryOptions,\n type ConfigParameter,\n type GetListingConfigOptions,\n type ListingConfig,\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/** Parameters for {@link useListingConfig}: the core query options plus an optional `config`. */\nexport type UseListingConfigParameters = GetListingConfigOptions & ConfigParameter;\n\n/** Return type of {@link useListingConfig}: the listing service's public client config. */\nexport type UseListingConfigReturnType = UseQueryResult<ListingConfig, SymmioRequestError>;\n\n/**\n * Missing rate limits remain null; legacy initial-deposit fields retain their actual minimum.\n * Read the listing service's **public** client configuration — the data a\n * create-pool UI must show a user before they list a token: the recommended and\n * minimum initial deposits, the listing fee, the supported deposit chains, the\n * per-day rate limits, and the protocol reward share.\n *\n * This is the public twin of {@link useAuthenticateListing}-gated reads: no\n * token, resolved from the config, so it can be mounted unconditionally. The\n * three `*Usdc` figures are `bigint` at `LISTING_VALUE_DECIMALS` (18) — descale\n * with `formatUnits` before rendering as USD. `supportedDepositChains` is the\n * source of truth for a deposit-chain picker; do not hardcode the list.\n * Enigma-only; errors are normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data, isPending } = useListingConfig();\n * const chains = data?.supportedDepositChains ?? [];\n * ```\n */\nexport function useListingConfig(parameters: UseListingConfigParameters = {}): UseListingConfigReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getListingConfigQueryOptions(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 UseListingConfigReturnType;\n}\n"],"mappings":";;;;;;;AAwCA,SAAgB,EAAiB,IAAyC,CAAC,GAA+B;CACxG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA6B,GAAQ;EACnD,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
+ {"version":3,"file":"use-listing-config.js","names":[],"sources":["../../src/pools/use-listing-config.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getListingConfigQueryOptions,\n type ConfigParameter,\n type GetListingConfigOptions,\n type ListingConfig,\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/** Parameters for {@link useListingConfig}: the core query options plus an optional `config`. */\nexport type UseListingConfigParameters = GetListingConfigOptions & ConfigParameter;\n\n/** Return type of {@link useListingConfig}: the listing service's public client config. */\nexport type UseListingConfigReturnType = UseQueryResult<ListingConfig, SymmioRequestError>;\n\n/**\n * Missing rate limits remain null; legacy initial-deposit fields retain their actual minimum.\n * Read the listing service's **public** client configuration — the data a\n * create-pool UI must show a user before they list a token: the recommended and\n * minimum initial deposits, the listing fee, the supported deposit chains, the\n * per-day rate limits, and the protocol reward share.\n *\n * This is the public twin of {@link useAuthenticateListing}-gated reads: no\n * token, resolved from the config, so it can be mounted unconditionally. The\n * three `*Usdc` figures are `bigint` at `LISTING_VALUE_DECIMALS` (18) — descale\n * with `formatUnits` before rendering as USD. `supportedDepositChains` is the\n * source of truth for a deposit-chain picker; do not hardcode the list. Each\n * chain's optional `usdToken` preserves its address and native decimals; do not\n * apply LISTING_VALUE_DECIMALS to that metadata. Older backends may omit it.\n * Enigma-only; errors are normalized to {@link SymmioRequestError}.\n *\n * @example\n * ```tsx\n * const { data, isPending } = useListingConfig();\n * const chains = data?.supportedDepositChains ?? [];\n * ```\n */\nexport function useListingConfig(parameters: UseListingConfigParameters = {}): UseListingConfigReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getListingConfigQueryOptions(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 UseListingConfigReturnType;\n}\n"],"mappings":";;;;;;;AA0CA,SAAgB,EAAiB,IAAyC,CAAC,GAA+B;CACxG,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA6B,GAAQ;EACnD,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,4 +1,4 @@
1
- import { CreateConfigParameters, GetWalletClientFn } from '@symmio/trading-core';
1
+ import { CreateConfigParameters, GetClientFn, GetWalletClientFn } from '@symmio/trading-core';
2
2
  import { ReactNode } from 'react';
3
3
  /**
4
4
  * Props for {@link SymmioProvider}.
@@ -28,6 +28,32 @@ export interface SymmioProviderProps {
28
28
  * chain. Defaults to the SDK's first supported chain.
29
29
  */
30
30
  defaultChainId?: number;
31
+ /**
32
+ * Custom read-client resolver. Receives `{ chainId? }` from the SDK and
33
+ * returns the viem `PublicClient` that every on-chain SDK read — and every
34
+ * write's dry-run and receipt wait — runs on. Use it when the app reads
35
+ * through its own client (a dedicated RPC URL, request batching, an
36
+ * instrumented transport) rather than wagmi's transport for that chain.
37
+ *
38
+ * Return a client bound to the requested `chainId`, or throw for a chain the
39
+ * app does not serve — never a client for another chain, which would read
40
+ * the wrong contracts without any error.
41
+ *
42
+ * When omitted, the provider reads through wagmi's public client for the
43
+ * requested chain. Memoize the resolver: a new function identity rebuilds
44
+ * the SDK config, which resets every per-config cache (nonce locks, relay
45
+ * request registry, stream connections).
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * const getClient = useCallback(() => appPublicClient, []);
50
+ *
51
+ * <SymmioProvider symmioConfig={symmioConfig} getClient={getClient}>
52
+ * {children}
53
+ * </SymmioProvider>;
54
+ * ```
55
+ */
56
+ getClient?: GetClientFn;
31
57
  /**
32
58
  * Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK
33
59
  * and returns the wallet client to sign with. Use this to plug in
@@ -45,8 +71,9 @@ export interface SymmioProviderProps {
45
71
  }
46
72
  /**
47
73
  * Provides the SYMMIO {@link Config} to descendant hooks. The config's viem
48
- * clients are resolved from the host's wagmi config, so this is the only place
49
- * the SDK touches wagmi.
74
+ * clients are resolved from the host's wagmi config unless the host passes its
75
+ * own `getClient` / `getWalletClient` resolver, so this is the only place the
76
+ * SDK touches wagmi.
50
77
  *
51
78
  * **Mount order matters**: this reads wagmi context and (transitively) the
52
79
  * host's `@tanstack/react-query` `QueryClient`. Both must be mounted **outside**
@@ -65,5 +92,5 @@ export interface SymmioProviderProps {
65
92
  * The SDK never mounts wagmi or a `QueryClient` for the host — those (which
66
93
  * connectors, which RPC URLs, which shared `QueryClient`) belong to the host.
67
94
  */
68
- export declare function SymmioProvider({ children, symmioConfig, defaultChainId, getWalletClient: getWalletClientProp, }: SymmioProviderProps): import("react").JSX.Element;
95
+ export declare function SymmioProvider({ children, symmioConfig, defaultChainId, getClient: getClientProp, getWalletClient: getWalletClientProp, }: SymmioProviderProps): import("react").JSX.Element;
69
96
  //# sourceMappingURL=symmio-provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"symmio-provider.d.ts","sourceRoot":"","sources":["../../src/provider/symmio-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,eAAe,EAAE,mBAAmB,GACrC,EAAE,mBAAmB,+BAsErB"}
1
+ {"version":3,"file":"symmio-provider.d.ts","sourceRoot":"","sources":["../../src/provider/symmio-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,iBAAiB,EAEvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,mDAAmD;IACnD,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;;;;;;;;OAYG;IACH,YAAY,EAAE,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACrD;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,SAAS,EAAE,aAAa,EACxB,eAAe,EAAE,mBAAmB,GACrC,EAAE,mBAAmB,+BAwErB"}
@@ -6,19 +6,19 @@ import { useMemo as o } from "react";
6
6
  import { useChainId as s, useConfig as c } from "wagmi";
7
7
  import { jsx as l } from "react/jsx-runtime";
8
8
  //#region src/provider/symmio-provider.tsx
9
- function u({ children: u, symmioConfig: d, defaultChainId: f, getWalletClient: p }) {
10
- let m = c(), h = s(), g = r().some((e) => e === h) ? h : f, _ = o(() => n({
9
+ function u({ children: u, symmioConfig: d, defaultChainId: f, getClient: p, getWalletClient: m }) {
10
+ let h = c(), g = s(), _ = r().some((e) => e === g) ? g : f, v = o(() => n({
11
11
  symmioConfig: d,
12
- defaultChainId: g,
13
- getClient: ({ chainId: e } = {}) => {
14
- let n = i(m, { chainId: e });
12
+ defaultChainId: _,
13
+ getClient: p ?? (({ chainId: e } = {}) => {
14
+ let n = i(h, { chainId: e });
15
15
  if (!n) throw new t("config", "NO_PUBLIC_CLIENT", `No public client available for chain ${e ?? "(default)"}.`);
16
16
  return n;
17
- },
18
- getWalletClient: p ?? (async ({ chainId: e, from: n }) => {
17
+ }),
18
+ getWalletClient: m ?? (async ({ chainId: e, from: n }) => {
19
19
  let r;
20
20
  try {
21
- r = await a(m, { chainId: e });
21
+ r = await a(h, { chainId: e });
22
22
  } catch (e) {
23
23
  throw new t("config", "NO_WALLET_CONNECTED", "No connected wallet. Connect a wallet before sending transactions.", { cause: e instanceof Error ? e : void 0 });
24
24
  }
@@ -27,12 +27,13 @@ function u({ children: u, symmioConfig: d, defaultChainId: f, getWalletClient: p
27
27
  })
28
28
  }), [
29
29
  d,
30
- g,
30
+ _,
31
31
  p,
32
- m
32
+ m,
33
+ h
33
34
  ]);
34
35
  return /* @__PURE__ */ l(e.Provider, {
35
- value: _,
36
+ value: v,
36
37
  children: u
37
38
  });
38
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"symmio-provider.js","names":[],"sources":["../../src/provider/symmio-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createConfig,\n listSupportedChains,\n SymmError,\n type Config,\n type CreateConfigParameters,\n type GetWalletClientFn,\n type SymmioWalletClient,\n} from \"@symmio/trading-core\";\nimport { useMemo, type ReactNode } from \"react\";\nimport type { PublicClient } from \"viem\";\nimport { useChainId, useConfig } from \"wagmi\";\nimport { getPublicClient, getWalletClient } from \"wagmi/actions\";\nimport { SymmioConfigContext } from \"./symmio-config-context\";\n\n/**\n * Props for {@link SymmioProvider}.\n */\nexport interface SymmioProviderProps {\n /** React subtree that may use SYMMIO SDK hooks. */\n children: ReactNode;\n /**\n * Per-chain SYMMIO configuration, keyed by chain id — deep-merged onto the\n * SDK's built-in defaults (addresses, subgraphs, solver, …).\n *\n * **Required.** Every supported chain must set a non-zero\n * `addresses.affiliatesAddress` — your frontend's on-chain affiliate (your\n * identity in SYMMIO on that chain), attached to every quote so the protocol\n * attributes the trade to you and routes your fee share. Affiliate addresses\n * are per chain (a registration on one chain is not valid on another). The\n * provider throws `AFFILIATE_ADDRESS_REQUIRED` (via `createConfig`) for any\n * supported chain missing it, so trades can never silently fall back to the\n * built-in default affiliate and lose attribution.\n */\n symmioConfig: CreateConfigParameters[\"symmioConfig\"];\n /**\n * Fallback chain used when a hook or action omits `chainId` **and** the\n * connected wallet is not on a supported SYMMIO chain (or is disconnected).\n * When the wallet *is* on a supported chain, that chain becomes the default\n * instead — so a no-arg `config.getChainConfig()` always follows the active\n * chain. Defaults to the SDK's first supported chain.\n */\n defaultChainId?: number;\n /**\n * Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK\n * and returns the wallet client to sign with. Use this to plug in\n * session-key, multi-signer, or any non-wagmi flow — the resolver decides.\n * {@link createSessionKeyWalletClientResolver} builds the session-key one.\n *\n * When omitted, the provider signs with wagmi's connected wallet. That default\n * can only honor a `from` that *is* the connected account: any other `from`\n * (a session key, another signer) throws `SESSION_SIGNER_UNAVAILABLE` rather\n * than silently prompting the connected wallet instead — the owner is also\n * authorized on-chain, so such a write would otherwise succeed with the wrong\n * signer and no way to notice.\n */\n getWalletClient?: GetWalletClientFn;\n}\n\n/**\n * Provides the SYMMIO {@link Config} to descendant hooks. The config's viem\n * clients are resolved from the host's wagmi config, so this is the only place\n * the SDK touches wagmi.\n *\n * **Mount order matters**: this reads wagmi context and (transitively) the\n * host's `@tanstack/react-query` `QueryClient`. Both must be mounted **outside**\n * `SymmioProvider`:\n *\n * ```tsx\n * <WagmiProvider config={wagmiConfig}>\n * <QueryClientProvider client={queryClient}>\n * <SymmioProvider symmioConfig={{ [SymmioSupportedChainId.ARBITRUM]: { addresses: { affiliatesAddress: \"0x…\" } } }}>\n * <App />\n * </SymmioProvider>\n * </QueryClientProvider>\n * </WagmiProvider>\n * ```\n *\n * The SDK never mounts wagmi or a `QueryClient` for the host — those (which\n * connectors, which RPC URLs, which shared `QueryClient`) belong to the host.\n */\nexport function SymmioProvider({\n children,\n symmioConfig,\n defaultChainId,\n getWalletClient: getWalletClientProp,\n}: SymmioProviderProps) {\n const wagmiConfig = useConfig();\n const connectedChainId = useChainId();\n\n // Track the connected wallet's chain as the config default whenever it is a\n // supported SYMMIO chain, so a no-arg `config.getChainConfig()` — and any hook\n // that omits `chainId` — resolves to the ACTIVE chain rather than a hardcoded\n // first chain. Single fix for the whole class of \"reads the wrong chain's\n // addresses after switching\". Falls back to the explicit `defaultChainId` prop\n // (then the SDK's first supported chain) when the wallet is on an unsupported\n // chain or disconnected.\n const effectiveDefaultChainId = listSupportedChains().some((id) => id === connectedChainId)\n ? connectedChainId\n : defaultChainId;\n\n const config = useMemo<Config>(\n () =>\n createConfig({\n symmioConfig,\n defaultChainId: effectiveDefaultChainId,\n getClient: ({ chainId } = {}): PublicClient => {\n const client = getPublicClient(wagmiConfig, { chainId });\n\n if (!client)\n throw new SymmError(\n \"config\",\n \"NO_PUBLIC_CLIENT\",\n `No public client available for chain ${chainId ?? \"(default)\"}.`,\n );\n return client;\n },\n getWalletClient:\n getWalletClientProp ??\n (async ({ chainId, from }) => {\n let walletClient: SymmioWalletClient;\n\n try {\n walletClient = await getWalletClient(wagmiConfig, { chainId });\n } catch (err) {\n throw new SymmError(\n \"config\",\n \"NO_WALLET_CONNECTED\",\n \"No connected wallet. Connect a wallet before sending transactions.\",\n { cause: err instanceof Error ? err : undefined },\n );\n }\n\n /**\n * `from` is never forwarded to wagmi as `account` — a session key is\n * not a wagmi-connected account, so wagmi would reject it or\n * mis-resolve it. Instead the resolved signer is checked against the\n * request. Dropping a `from` it cannot honor would be silent: the\n * account owner is authorized on-chain for the same calls, so the\n * write succeeds after an unexpected wallet prompt and nothing looks\n * broken.\n */\n if (from && from.toLowerCase() !== walletClient.account.address.toLowerCase())\n throw new SymmError(\n \"config\",\n \"SESSION_SIGNER_UNAVAILABLE\",\n `This action asked to sign as ${from}, but the default wallet-client resolver can only sign with the wagmi-connected wallet (${walletClient.account.address}). Pass SymmioProvider a \\`getWalletClient\\` built by \\`createSessionKeyWalletClientResolver\\` to route session-key signers.`,\n );\n\n return walletClient;\n }),\n }),\n [symmioConfig, effectiveDefaultChainId, getWalletClientProp, wagmiConfig],\n );\n\n return <SymmioConfigContext.Provider value={config}>{children}</SymmioConfigContext.Provider>;\n}\n"],"mappings":";;;;;;;;AAmFA,SAAgB,EAAe,EAC7B,aACA,iBACA,mBACA,iBAAiB,KACK;CACtB,IAAM,IAAc,EAAU,GACxB,IAAmB,EAAW,GAS9B,IAA0B,EAAoB,EAAE,MAAM,MAAO,MAAO,CAAgB,IACtF,IACA,GAEE,IAAS,QAEX,EAAa;EACX;EACA,gBAAgB;EAChB,YAAY,EAAE,eAAY,CAAC,MAAoB;GAC7C,IAAM,IAAS,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAEvD,IAAI,CAAC,GACH,MAAM,IAAI,EACR,UACA,oBACA,wCAAwC,KAAW,YAAY,EACjE;GACF,OAAO;EACT;EACA,iBACE,MACC,OAAO,EAAE,YAAS,cAAW;GAC5B,IAAI;GAEJ,IAAI;IACF,IAAe,MAAM,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAC/D,SAAS,GAAK;IACZ,MAAM,IAAI,EACR,UACA,uBACA,sEACA,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;GACF;GAWA,IAAI,KAAQ,EAAK,YAAY,MAAM,EAAa,QAAQ,QAAQ,YAAY,GAC1E,MAAM,IAAI,EACR,UACA,8BACA,gCAAgC,EAAK,0FAA0F,EAAa,QAAQ,QAAQ,6HAC9J;GAEF,OAAO;EACT;CACJ,CAAC,GACH;EAAC;EAAc;EAAyB;EAAqB;CAAW,CAC1E;CAEA,OAAO,kBAAC,EAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F"}
1
+ {"version":3,"file":"symmio-provider.js","names":[],"sources":["../../src/provider/symmio-provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createConfig,\n listSupportedChains,\n SymmError,\n type Config,\n type CreateConfigParameters,\n type GetClientFn,\n type GetWalletClientFn,\n type SymmioWalletClient,\n} from \"@symmio/trading-core\";\nimport { useMemo, type ReactNode } from \"react\";\nimport type { PublicClient } from \"viem\";\nimport { useChainId, useConfig } from \"wagmi\";\nimport { getPublicClient, getWalletClient } from \"wagmi/actions\";\nimport { SymmioConfigContext } from \"./symmio-config-context\";\n\n/**\n * Props for {@link SymmioProvider}.\n */\nexport interface SymmioProviderProps {\n /** React subtree that may use SYMMIO SDK hooks. */\n children: ReactNode;\n /**\n * Per-chain SYMMIO configuration, keyed by chain id — deep-merged onto the\n * SDK's built-in defaults (addresses, subgraphs, solver, …).\n *\n * **Required.** Every supported chain must set a non-zero\n * `addresses.affiliatesAddress` — your frontend's on-chain affiliate (your\n * identity in SYMMIO on that chain), attached to every quote so the protocol\n * attributes the trade to you and routes your fee share. Affiliate addresses\n * are per chain (a registration on one chain is not valid on another). The\n * provider throws `AFFILIATE_ADDRESS_REQUIRED` (via `createConfig`) for any\n * supported chain missing it, so trades can never silently fall back to the\n * built-in default affiliate and lose attribution.\n */\n symmioConfig: CreateConfigParameters[\"symmioConfig\"];\n /**\n * Fallback chain used when a hook or action omits `chainId` **and** the\n * connected wallet is not on a supported SYMMIO chain (or is disconnected).\n * When the wallet *is* on a supported chain, that chain becomes the default\n * instead — so a no-arg `config.getChainConfig()` always follows the active\n * chain. Defaults to the SDK's first supported chain.\n */\n defaultChainId?: number;\n /**\n * Custom read-client resolver. Receives `{ chainId? }` from the SDK and\n * returns the viem `PublicClient` that every on-chain SDK read — and every\n * write's dry-run and receipt wait — runs on. Use it when the app reads\n * through its own client (a dedicated RPC URL, request batching, an\n * instrumented transport) rather than wagmi's transport for that chain.\n *\n * Return a client bound to the requested `chainId`, or throw for a chain the\n * app does not serve — never a client for another chain, which would read\n * the wrong contracts without any error.\n *\n * When omitted, the provider reads through wagmi's public client for the\n * requested chain. Memoize the resolver: a new function identity rebuilds\n * the SDK config, which resets every per-config cache (nonce locks, relay\n * request registry, stream connections).\n *\n * @example\n * ```tsx\n * const getClient = useCallback(() => appPublicClient, []);\n *\n * <SymmioProvider symmioConfig={symmioConfig} getClient={getClient}>\n * {children}\n * </SymmioProvider>;\n * ```\n */\n getClient?: GetClientFn;\n /**\n * Custom wallet-client resolver. Receives `{ chainId, from? }` from the SDK\n * and returns the wallet client to sign with. Use this to plug in\n * session-key, multi-signer, or any non-wagmi flow — the resolver decides.\n * {@link createSessionKeyWalletClientResolver} builds the session-key one.\n *\n * When omitted, the provider signs with wagmi's connected wallet. That default\n * can only honor a `from` that *is* the connected account: any other `from`\n * (a session key, another signer) throws `SESSION_SIGNER_UNAVAILABLE` rather\n * than silently prompting the connected wallet instead — the owner is also\n * authorized on-chain, so such a write would otherwise succeed with the wrong\n * signer and no way to notice.\n */\n getWalletClient?: GetWalletClientFn;\n}\n\n/**\n * Provides the SYMMIO {@link Config} to descendant hooks. The config's viem\n * clients are resolved from the host's wagmi config unless the host passes its\n * own `getClient` / `getWalletClient` resolver, so this is the only place the\n * SDK touches wagmi.\n *\n * **Mount order matters**: this reads wagmi context and (transitively) the\n * host's `@tanstack/react-query` `QueryClient`. Both must be mounted **outside**\n * `SymmioProvider`:\n *\n * ```tsx\n * <WagmiProvider config={wagmiConfig}>\n * <QueryClientProvider client={queryClient}>\n * <SymmioProvider symmioConfig={{ [SymmioSupportedChainId.ARBITRUM]: { addresses: { affiliatesAddress: \"0x…\" } } }}>\n * <App />\n * </SymmioProvider>\n * </QueryClientProvider>\n * </WagmiProvider>\n * ```\n *\n * The SDK never mounts wagmi or a `QueryClient` for the host — those (which\n * connectors, which RPC URLs, which shared `QueryClient`) belong to the host.\n */\nexport function SymmioProvider({\n children,\n symmioConfig,\n defaultChainId,\n getClient: getClientProp,\n getWalletClient: getWalletClientProp,\n}: SymmioProviderProps) {\n const wagmiConfig = useConfig();\n const connectedChainId = useChainId();\n\n // Track the connected wallet's chain as the config default whenever it is a\n // supported SYMMIO chain, so a no-arg `config.getChainConfig()` — and any hook\n // that omits `chainId` — resolves to the ACTIVE chain rather than a hardcoded\n // first chain. Single fix for the whole class of \"reads the wrong chain's\n // addresses after switching\". Falls back to the explicit `defaultChainId` prop\n // (then the SDK's first supported chain) when the wallet is on an unsupported\n // chain or disconnected.\n const effectiveDefaultChainId = listSupportedChains().some((id) => id === connectedChainId)\n ? connectedChainId\n : defaultChainId;\n\n const config = useMemo<Config>(\n () =>\n createConfig({\n symmioConfig,\n defaultChainId: effectiveDefaultChainId,\n getClient:\n getClientProp ??\n (({ chainId } = {}): PublicClient => {\n const client = getPublicClient(wagmiConfig, { chainId });\n\n if (!client)\n throw new SymmError(\n \"config\",\n \"NO_PUBLIC_CLIENT\",\n `No public client available for chain ${chainId ?? \"(default)\"}.`,\n );\n return client;\n }),\n getWalletClient:\n getWalletClientProp ??\n (async ({ chainId, from }) => {\n let walletClient: SymmioWalletClient;\n\n try {\n walletClient = await getWalletClient(wagmiConfig, { chainId });\n } catch (err) {\n throw new SymmError(\n \"config\",\n \"NO_WALLET_CONNECTED\",\n \"No connected wallet. Connect a wallet before sending transactions.\",\n { cause: err instanceof Error ? err : undefined },\n );\n }\n\n /**\n * `from` is never forwarded to wagmi as `account` — a session key is\n * not a wagmi-connected account, so wagmi would reject it or\n * mis-resolve it. Instead the resolved signer is checked against the\n * request. Dropping a `from` it cannot honor would be silent: the\n * account owner is authorized on-chain for the same calls, so the\n * write succeeds after an unexpected wallet prompt and nothing looks\n * broken.\n */\n if (from && from.toLowerCase() !== walletClient.account.address.toLowerCase())\n throw new SymmError(\n \"config\",\n \"SESSION_SIGNER_UNAVAILABLE\",\n `This action asked to sign as ${from}, but the default wallet-client resolver can only sign with the wagmi-connected wallet (${walletClient.account.address}). Pass SymmioProvider a \\`getWalletClient\\` built by \\`createSessionKeyWalletClientResolver\\` to route session-key signers.`,\n );\n\n return walletClient;\n }),\n }),\n [symmioConfig, effectiveDefaultChainId, getClientProp, getWalletClientProp, wagmiConfig],\n );\n\n return <SymmioConfigContext.Provider value={config}>{children}</SymmioConfigContext.Provider>;\n}\n"],"mappings":";;;;;;;;AA+GA,SAAgB,EAAe,EAC7B,aACA,iBACA,mBACA,WAAW,GACX,iBAAiB,KACK;CACtB,IAAM,IAAc,EAAU,GACxB,IAAmB,EAAW,GAS9B,IAA0B,EAAoB,EAAE,MAAM,MAAO,MAAO,CAAgB,IACtF,IACA,GAEE,IAAS,QAEX,EAAa;EACX;EACA,gBAAgB;EAChB,WACE,OACE,EAAE,eAAY,CAAC,MAAoB;GACnC,IAAM,IAAS,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAEvD,IAAI,CAAC,GACH,MAAM,IAAI,EACR,UACA,oBACA,wCAAwC,KAAW,YAAY,EACjE;GACF,OAAO;EACT;EACF,iBACE,MACC,OAAO,EAAE,YAAS,cAAW;GAC5B,IAAI;GAEJ,IAAI;IACF,IAAe,MAAM,EAAgB,GAAa,EAAE,WAAQ,CAAC;GAC/D,SAAS,GAAK;IACZ,MAAM,IAAI,EACR,UACA,uBACA,sEACA,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;GACF;GAWA,IAAI,KAAQ,EAAK,YAAY,MAAM,EAAa,QAAQ,QAAQ,YAAY,GAC1E,MAAM,IAAI,EACR,UACA,8BACA,gCAAgC,EAAK,0FAA0F,EAAa,QAAQ,QAAQ,6HAC9J;GAEF,OAAO;EACT;CACJ,CAAC,GACH;EAAC;EAAc;EAAyB;EAAe;EAAqB;CAAW,CACzF;CAEA,OAAO,kBAAC,EAAoB,UAArB;EAA8B,OAAO;EAAS;CAAuC,CAAA;AAC9F"}
@@ -0,0 +1,9 @@
1
+ import { Config, SolverId, TimelockApprovalCapability } from '@symmio/trading-core';
2
+ import { QueryClient } from '@tanstack/react-query';
3
+ /** Keep positive discovery scoped to one solver deployment and QueryClient. */
4
+ export declare function timelockCapabilityKey(config: Config, chainId: number, solverId?: SolverId): readonly ["symmio", "known-timelock-capability", number, string, "enigma" | "rasa", string];
5
+ export declare function rememberTimelockCapability(client: QueryClient, key: ReturnType<typeof timelockCapabilityKey>, capability: TimelockApprovalCapability | undefined): void;
6
+ /** Recheck availability after a transport outage without retrying the approval request. */
7
+ export declare function refreshTimelockInfoAfterUnavailable(client: QueryClient, config: Config, chainId: number, solverId: SolverId, error: unknown): Promise<void>;
8
+ export declare function useKnownTimelockCapability(config: Config, chainId: number, solverId?: SolverId): TimelockApprovalCapability | undefined;
9
+ //# sourceMappingURL=timelock-capability-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timelock-capability-cache.d.ts","sourceRoot":"","sources":["../../src/solvers/timelock-capability-cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzE,+EAA+E;AAC/E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,+FAWzF;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC7C,UAAU,EAAE,0BAA0B,GAAG,SAAS,QAKnD;AAED,2FAA2F;AAC3F,wBAAsB,mCAAmC,CACvD,MAAM,EAAE,WAAW,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,iBAqCf;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,0CA2B9F"}
@@ -0,0 +1,79 @@
1
+ "use client";
2
+ import { normalizeSymmError as e } from "../errors/normalize-symm-error.js";
3
+ import { TimelockApprovalHttpError as t, getSolverInfoQueryOptions as n } from "@symmio/trading-core";
4
+ import { useCallback as r, useMemo as i, useSyncExternalStore as a } from "react";
5
+ import { useQueryClient as o } from "@tanstack/react-query";
6
+ //#region src/solvers/timelock-capability-cache.ts
7
+ function s(e, t, n) {
8
+ let r = e.getChainConfig(t), i = e.getSolver({
9
+ chainId: t,
10
+ solverId: n
11
+ });
12
+ return [
13
+ "symmio",
14
+ "known-timelock-capability",
15
+ t,
16
+ r.addresses.accountLayerAddress.toLowerCase(),
17
+ i.id,
18
+ i.url
19
+ ];
20
+ }
21
+ function c(e, t, n) {
22
+ n && (e.setQueryDefaults(t, {
23
+ gcTime: Infinity,
24
+ staleTime: Infinity
25
+ }), e.setQueryData(t, n));
26
+ }
27
+ async function l(r, i, a, o, l) {
28
+ if (!(!(l instanceof t) || l.status !== 0 && l.status < 500)) try {
29
+ if (i.getSolver({
30
+ chainId: a,
31
+ solverId: o
32
+ }).id !== "enigma") return;
33
+ let t = s(i, a, o), l = n(i, {
34
+ chainId: a,
35
+ solverId: o
36
+ }), u = i.getSolver({ chainId: a }).id === o ? [l, n(i, { chainId: a })] : [l], d, f = async () => {
37
+ try {
38
+ if (!d) {
39
+ let e = l.queryFn();
40
+ d = e, e.then(() => {
41
+ d === e && (d = void 0);
42
+ }, () => {
43
+ d === e && (d = void 0);
44
+ });
45
+ }
46
+ let e = await d;
47
+ return c(r, t, e.timelockApproval), e;
48
+ } catch (t) {
49
+ throw e(t);
50
+ }
51
+ };
52
+ await Promise.allSettled(u.map((e) => r.fetchQuery({
53
+ ...e,
54
+ retry: !1,
55
+ staleTime: 0,
56
+ queryFn: f
57
+ })));
58
+ } catch {}
59
+ }
60
+ function u(e, t, n) {
61
+ let c = o(), l = i(() => {
62
+ try {
63
+ return s(e, t, n);
64
+ } catch {
65
+ return;
66
+ }
67
+ }, [
68
+ e,
69
+ t,
70
+ n
71
+ ]);
72
+ return a(r((e) => c.getQueryCache().subscribe((t) => {
73
+ l && t.query.queryKey.length === l.length && l.every((e, n) => t.query.queryKey[n] === e) && e();
74
+ }), [c, l]), r(() => l ? c.getQueryData(l) : void 0, [c, l]), () => void 0);
75
+ }
76
+ //#endregion
77
+ export { l as refreshTimelockInfoAfterUnavailable, c as rememberTimelockCapability, s as timelockCapabilityKey, u as useKnownTimelockCapability };
78
+
79
+ //# sourceMappingURL=timelock-capability-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timelock-capability-cache.js","names":[],"sources":["../../src/solvers/timelock-capability-cache.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverInfoQueryOptions,\n TimelockApprovalHttpError,\n type Config,\n type SolverId,\n type TimelockApprovalCapability,\n} from \"@symmio/trading-core\";\nimport { useQueryClient, type QueryClient } from \"@tanstack/react-query\";\nimport { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\n\n/** Keep positive discovery scoped to one solver deployment and QueryClient. */\nexport function timelockCapabilityKey(config: Config, chainId: number, solverId?: SolverId) {\n const chain = config.getChainConfig(chainId);\n const solver = config.getSolver({ chainId, solverId });\n return [\n \"symmio\",\n \"known-timelock-capability\",\n chainId,\n chain.addresses.accountLayerAddress.toLowerCase(),\n solver.id,\n solver.url,\n ] as const;\n}\n\nexport function rememberTimelockCapability(\n client: QueryClient,\n key: ReturnType<typeof timelockCapabilityKey>,\n capability: TimelockApprovalCapability | undefined,\n) {\n if (!capability) return;\n client.setQueryDefaults(key, { gcTime: Infinity, staleTime: Infinity });\n client.setQueryData(key, capability);\n}\n\n/** Recheck availability after a transport outage without retrying the approval request. */\nexport async function refreshTimelockInfoAfterUnavailable(\n client: QueryClient,\n config: Config,\n chainId: number,\n solverId: SolverId,\n error: unknown,\n) {\n if (!(error instanceof TimelockApprovalHttpError) || (error.status !== 0 && error.status < 500)) return;\n try {\n if (config.getSolver({ chainId, solverId }).id !== \"enigma\") return;\n const key = timelockCapabilityKey(config, chainId, solverId);\n const options = getSolverInfoQueryOptions(config, { chainId, solverId });\n const isDefault = config.getSolver({ chainId }).id === solverId;\n const queries = isDefault ? [options, getSolverInfoQueryOptions(config, { chainId })] : [options];\n let shared: ReturnType<typeof options.queryFn> | undefined;\n const queryFn = async () => {\n try {\n if (!shared) {\n const pending = options.queryFn();\n shared = pending;\n void pending.then(\n () => {\n if (shared === pending) shared = undefined;\n },\n () => {\n if (shared === pending) shared = undefined;\n },\n );\n }\n const info = await shared;\n rememberTimelockCapability(client, key, info.timelockApproval);\n return info;\n } catch (failure) {\n throw normalizeSymmError(failure);\n }\n };\n await Promise.allSettled(\n queries.map((query) => client.fetchQuery({ ...query, retry: false, staleTime: 0, queryFn })),\n );\n } catch {\n // Preserve the original approval error and previously confirmed capability.\n }\n}\n\nexport function useKnownTimelockCapability(config: Config, chainId: number, solverId?: SolverId) {\n const client = useQueryClient();\n const key = useMemo(() => {\n try {\n return timelockCapabilityKey(config, chainId, solverId);\n } catch {\n // Disabled and invalid queries must retain the normal query error behavior.\n return undefined;\n }\n }, [config, chainId, solverId]);\n const subscribe = useCallback(\n (callback: () => void) =>\n client.getQueryCache().subscribe((event) => {\n if (\n key &&\n event.query.queryKey.length === key.length &&\n key.every((part, index) => event.query.queryKey[index] === part)\n )\n callback();\n }),\n [client, key],\n );\n const snapshot = useCallback(\n () => (key ? client.getQueryData<TimelockApprovalCapability>(key) : undefined),\n [client, key],\n );\n return useSyncExternalStore(subscribe, snapshot, () => undefined);\n}\n"],"mappings":";;;;;;AAcA,SAAgB,EAAsB,GAAgB,GAAiB,GAAqB;CAC1F,IAAM,IAAQ,EAAO,eAAe,CAAO,GACrC,IAAS,EAAO,UAAU;EAAE;EAAS;CAAS,CAAC;CACrD,OAAO;EACL;EACA;EACA;EACA,EAAM,UAAU,oBAAoB,YAAY;EAChD,EAAO;EACP,EAAO;CACT;AACF;AAEA,SAAgB,EACd,GACA,GACA,GACA;CACK,MACL,EAAO,iBAAiB,GAAK;EAAE,QAAQ;EAAU,WAAW;CAAS,CAAC,GACtE,EAAO,aAAa,GAAK,CAAU;AACrC;AAGA,eAAsB,EACpB,GACA,GACA,GACA,GACA,GACA;CACI,QAAE,aAAiB,MAA+B,EAAM,WAAW,KAAK,EAAM,SAAS,MAC3F,IAAI;EACF,IAAI,EAAO,UAAU;GAAE;GAAS;EAAS,CAAC,EAAE,OAAO,UAAU;EAC7D,IAAM,IAAM,EAAsB,GAAQ,GAAS,CAAQ,GACrD,IAAU,EAA0B,GAAQ;GAAE;GAAS;EAAS,CAAC,GAEjE,IADY,EAAO,UAAU,EAAE,WAAQ,CAAC,EAAE,OAAO,IAC3B,CAAC,GAAS,EAA0B,GAAQ,EAAE,WAAQ,CAAC,CAAC,IAAI,CAAC,CAAO,GAC5F,GACE,IAAU,YAAY;GAC1B,IAAI;IACF,IAAI,CAAC,GAAQ;KACX,IAAM,IAAU,EAAQ,QAAQ;KAEhC,AADA,IAAS,GACT,EAAa,WACL;MACJ,AAAI,MAAW,MAAS,IAAS,KAAA;KACnC,SACM;MACJ,AAAI,MAAW,MAAS,IAAS,KAAA;KACnC,CACF;IACF;IACA,IAAM,IAAO,MAAM;IAEnB,OADA,EAA2B,GAAQ,GAAK,EAAK,gBAAgB,GACtD;GACT,SAAS,GAAS;IAChB,MAAM,EAAmB,CAAO;GAClC;EACF;EACA,MAAM,QAAQ,WACZ,EAAQ,KAAK,MAAU,EAAO,WAAW;GAAE,GAAG;GAAO,OAAO;GAAO,WAAW;GAAG;EAAQ,CAAC,CAAC,CAC7F;CACF,QAAQ,CAER;AACF;AAEA,SAAgB,EAA2B,GAAgB,GAAiB,GAAqB;CAC/F,IAAM,IAAS,EAAe,GACxB,IAAM,QAAc;EACxB,IAAI;GACF,OAAO,EAAsB,GAAQ,GAAS,CAAQ;EACxD,QAAQ;GAEN;EACF;CACF,GAAG;EAAC;EAAQ;EAAS;CAAQ,CAAC;CAiB9B,OAAO,EAhBW,GACf,MACC,EAAO,cAAc,EAAE,WAAW,MAAU;EAC1C,AACE,KACA,EAAM,MAAM,SAAS,WAAW,EAAI,UACpC,EAAI,OAAO,GAAM,MAAU,EAAM,MAAM,SAAS,OAAW,CAAI,KAE/D,EAAS;CACb,CAAC,GACH,CAAC,GAAQ,CAAG,CAMc,GAJX,QACR,IAAM,EAAO,aAAyC,CAAG,IAAI,KAAA,GACpE,CAAC,GAAQ,CAAG,CAEyB,SAAgB,KAAA,CAAS;AAClE"}
@@ -1,10 +1,13 @@
1
- import { ConfigParameter, GetSolverInfoData, GetSolverInfoOptions } from '@symmio/trading-core';
1
+ import { ConfigParameter, GetSolverInfoData, GetSolverInfoOptions, TimelockApprovalCapability } from '@symmio/trading-core';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
3
  import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
4
  /** Parameters for {@link useSolverInfo}. */
5
5
  export type UseSolverInfoParameters = GetSolverInfoOptions & ConfigParameter;
6
6
  /** Return type of {@link useSolverInfo}. */
7
- export type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError>;
7
+ export type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError> & {
8
+ /** Last validated positive timelock capability observed for this deployment in this QueryClient. */
9
+ knownTimelockApproval?: TimelockApprovalCapability;
10
+ };
8
11
  /**
9
12
  * Read the solver's static fee configuration via the Enigma-only `/info`
10
13
  * endpoint. Fails with `UNSUPPORTED_BY_SOLVER` when the resolved solver is not
@@ -1 +1 @@
1
- {"version":3,"file":"use-solver-info.d.ts","sourceRoot":"","sources":["../../src/solvers/use-solver-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAY,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIzE,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAE7E,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAAC;AAE5F;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,GAAE,uBAA4B,GAAG,uBAAuB,CAkB/F"}
1
+ {"version":3,"file":"use-solver-info.d.ts","sourceRoot":"","sources":["../../src/solvers/use-solver-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AASzE,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAE7E,4CAA4C;AAC5C,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GAAG;IAC5F,oGAAoG;IACpG,qBAAqB,CAAC,EAAE,0BAA0B,CAAC;CACpD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,GAAE,uBAA4B,GAAG,uBAAuB,CAsC/F"}
@@ -2,26 +2,50 @@
2
2
  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
- import { getSolverInfoQueryOptions as r } from "@symmio/trading-core";
6
- import { useQuery as i } from "@tanstack/react-query";
5
+ import { rememberTimelockCapability as r, timelockCapabilityKey as i, useKnownTimelockCapability as a } from "./timelock-capability-cache.js";
6
+ import { getSolverInfoQueryOptions as o } from "@symmio/trading-core";
7
+ import { useEffect as s, useMemo as c } from "react";
8
+ import { useQuery as l, useQueryClient as u } from "@tanstack/react-query";
7
9
  //#region src/solvers/use-solver-info.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,
10
+ function d(d = {}) {
11
+ let f = t(d), p = e(), m = d.chainId ?? p, h = u(), g = c(() => {
12
+ try {
13
+ return i(f, m, d.solverId);
14
+ } catch {
15
+ return;
16
+ }
17
+ }, [
18
+ f,
19
+ m,
20
+ d.solverId
21
+ ]), _ = a(f, m, d.solverId), v = o(f, {
22
+ ...d,
23
+ chainId: m
24
+ }), y = l({
25
+ ...v,
15
26
  queryFn: async () => {
16
27
  try {
17
- return await c.queryFn();
28
+ let e = await v.queryFn();
29
+ return g && r(h, g, e.timelockApproval), e;
18
30
  } catch (e) {
19
31
  throw n(e);
20
32
  }
21
33
  }
22
34
  });
35
+ return s(() => {
36
+ g && !y.isPlaceholderData && y.data?.timelockApproval && !_ && r(h, g, y.data.timelockApproval);
37
+ }, [
38
+ h,
39
+ g,
40
+ _,
41
+ y.isPlaceholderData,
42
+ y.data?.timelockApproval
43
+ ]), {
44
+ ...y,
45
+ knownTimelockApproval: _ ?? (y.isPlaceholderData ? void 0 : y.data?.timelockApproval)
46
+ };
23
47
  }
24
48
  //#endregion
25
- export { a as useSolverInfo };
49
+ export { d as useSolverInfo };
26
50
 
27
51
  //# sourceMappingURL=use-solver-info.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-solver-info.js","names":[],"sources":["../../src/solvers/use-solver-info.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverInfoQueryOptions,\n type ConfigParameter,\n type GetSolverInfoData,\n type GetSolverInfoOptions,\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/** Parameters for {@link useSolverInfo}. */\nexport type UseSolverInfoParameters = GetSolverInfoOptions & ConfigParameter;\n\n/** Return type of {@link useSolverInfo}. */\nexport type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError>;\n\n/**\n * Read the solver's static fee configuration via the Enigma-only `/info`\n * endpoint. Fails with `UNSUPPORTED_BY_SOLVER` when the resolved solver is not\n * an `enigma` solver.\n */\nexport function useSolverInfo(parameters: UseSolverInfoParameters = {}): UseSolverInfoReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const options = getSolverInfoQueryOptions(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 UseSolverInfoReturnType;\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,EAAc,IAAsC,CAAC,GAA4B;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAU,EAA0B,GAAQ;EAChD,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
+ {"version":3,"file":"use-solver-info.js","names":[],"sources":["../../src/solvers/use-solver-info.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getSolverInfoQueryOptions,\n type ConfigParameter,\n type GetSolverInfoData,\n type GetSolverInfoOptions,\n type TimelockApprovalCapability,\n} from \"@symmio/trading-core\";\nimport { useQuery, useQueryClient, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useEffect, useMemo } from \"react\";\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 {\n rememberTimelockCapability,\n timelockCapabilityKey,\n useKnownTimelockCapability,\n} from \"./timelock-capability-cache\";\n\n/** Parameters for {@link useSolverInfo}. */\nexport type UseSolverInfoParameters = GetSolverInfoOptions & ConfigParameter;\n\n/** Return type of {@link useSolverInfo}. */\nexport type UseSolverInfoReturnType = UseQueryResult<GetSolverInfoData, SymmioRequestError> & {\n /** Last validated positive timelock capability observed for this deployment in this QueryClient. */\n knownTimelockApproval?: TimelockApprovalCapability;\n};\n\n/**\n * Read the solver's static fee configuration via the Enigma-only `/info`\n * endpoint. Fails with `UNSUPPORTED_BY_SOLVER` when the resolved solver is not\n * an `enigma` solver.\n */\nexport function useSolverInfo(parameters: UseSolverInfoParameters = {}): UseSolverInfoReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const resolvedChainId = parameters.chainId ?? chainId;\n const queryClient = useQueryClient();\n const key = useMemo(() => {\n try {\n return timelockCapabilityKey(config, resolvedChainId, parameters.solverId);\n } catch {\n return undefined;\n }\n }, [config, resolvedChainId, parameters.solverId]);\n const known = useKnownTimelockCapability(config, resolvedChainId, parameters.solverId);\n const options = getSolverInfoQueryOptions(config, {\n ...parameters,\n chainId: resolvedChainId,\n });\n\n const result = useQuery({\n ...options,\n queryFn: async () => {\n try {\n const data = await options.queryFn();\n if (key) rememberTimelockCapability(queryClient, key, data.timelockApproval);\n return data;\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n }) as UseQueryResult<GetSolverInfoData, SymmioRequestError>;\n useEffect(() => {\n if (key && !result.isPlaceholderData && result.data?.timelockApproval && !known)\n rememberTimelockCapability(queryClient, key, result.data.timelockApproval);\n }, [queryClient, key, known, result.isPlaceholderData, result.data?.timelockApproval]);\n return {\n ...result,\n knownTimelockApproval: known ?? (result.isPlaceholderData ? undefined : result.data?.timelockApproval),\n };\n}\n"],"mappings":";;;;;;;;;AAmCA,SAAgB,EAAc,IAAsC,CAAC,GAA4B;CAC/F,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAkB,EAAW,WAAW,GACxC,IAAc,EAAe,GAC7B,IAAM,QAAc;EACxB,IAAI;GACF,OAAO,EAAsB,GAAQ,GAAiB,EAAW,QAAQ;EAC3E,QAAQ;GACN;EACF;CACF,GAAG;EAAC;EAAQ;EAAiB,EAAW;CAAQ,CAAC,GAC3C,IAAQ,EAA2B,GAAQ,GAAiB,EAAW,QAAQ,GAC/E,IAAU,EAA0B,GAAQ;EAChD,GAAG;EACH,SAAS;CACX,CAAC,GAEK,IAAS,EAAS;EACtB,GAAG;EACH,SAAS,YAAY;GACnB,IAAI;IACF,IAAM,IAAO,MAAM,EAAQ,QAAQ;IAEnC,OADI,KAAK,EAA2B,GAAa,GAAK,EAAK,gBAAgB,GACpE;GACT,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;CACF,CAAC;CAKD,OAJA,QAAgB;EACd,AAAI,KAAO,CAAC,EAAO,qBAAqB,EAAO,MAAM,oBAAoB,CAAC,KACxE,EAA2B,GAAa,GAAK,EAAO,KAAK,gBAAgB;CAC7E,GAAG;EAAC;EAAa;EAAK;EAAO,EAAO;EAAmB,EAAO,MAAM;CAAgB,CAAC,GAC9E;EACL,GAAG;EACH,uBAAuB,MAAU,EAAO,oBAAoB,KAAA,IAAY,EAAO,MAAM;CACvF;AACF"}
@@ -1,4 +1,4 @@
1
- import { ConfigParameter } from '@symmio/trading-core';
1
+ import { ConfigParameter, TimelockApprovalCapability, TimelockApprovalProvider, ValidatedTimelockApproval } from '@symmio/trading-core';
2
2
  import { Hash, TransactionReceipt } from 'viem';
3
3
  /**
4
4
  * Parameters shared by every write hook — those that submit a transaction and
@@ -15,6 +15,18 @@ export interface WriteParameters extends ConfigParameter {
15
15
  /** Confirmations to wait for when `waitForReceipt` is true. Defaults to `1`. */
16
16
  confirmations?: number;
17
17
  }
18
+ /** Write-hook options for operations that can automatically request a timelock approval. */
19
+ export interface AutomaticTimelockWriteParameters extends WriteParameters {
20
+ /** Set false for app-owned routing, or provide metadata and transport for a custom provider. Defaults to true. Keep the provider object stable while an operation is active. */
21
+ automaticTimelock?: boolean | {
22
+ capability: TimelockApprovalCapability;
23
+ provider: TimelockApprovalProvider;
24
+ /** Unix-seconds request deadline; defaults to chain time plus five minutes. */
25
+ deadline?: bigint;
26
+ /** Persist issued approvals before submission when recovery must survive reload. */
27
+ onApproval?: (approval: ValidatedTimelockApproval) => void | Promise<void>;
28
+ };
29
+ }
18
30
  /**
19
31
  * Result shared by every write hook: the submitted transaction hash, plus the
20
32
  * mined receipt when `waitForReceipt` is enabled.
@@ -1 +1 @@
1
- {"version":3,"file":"write-types.d.ts","sourceRoot":"","sources":["../../src/transactions/write-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,mEAAmE;IACnE,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE;QACR,uDAAuD;QACvD,SAAS,EAAE,MAAM,CAAC;QAClB,sEAAsE;QACtE,aAAa,EAAE,IAAI,CAAC;KACrB,CAAC;CACH"}
1
+ {"version":3,"file":"write-types.d.ts","sourceRoot":"","sources":["../../src/transactions/write-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,4FAA4F;AAC5F,MAAM,WAAW,gCAAiC,SAAQ,eAAe;IACvE,gLAAgL;IAChL,iBAAiB,CAAC,EACd,OAAO,GACP;QACE,UAAU,EAAE,0BAA0B,CAAC;QACvC,QAAQ,EAAE,wBAAwB,CAAC;QACnC,+EAA+E;QAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,oFAAoF;QACpF,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,yBAAyB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5E,CAAC;CACP;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH,IAAI,EAAE,IAAI,CAAC;IACX,mEAAmE;IACnE,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;;;;;OAMG;IACH,OAAO,CAAC,EAAE;QACR,uDAAuD;QACvD,SAAS,EAAE,MAAM,CAAC;QAClB,sEAAsE;QACtE,aAAa,EAAE,IAAI,CAAC;KACrB,CAAC;CACH"}
@@ -1,12 +1,15 @@
1
+ export * from './use-deallocate-debounce-time.js';
1
2
  export * from './use-finalize-withdraw-request.js';
2
3
  export * from './use-initiate-withdraw.js';
3
4
  export * from './use-last-withdraw-request-id.js';
4
5
  export * from './use-pending-withdraw-requests.js';
6
+ export * from './use-pending-withdraw-requests-batch.js';
5
7
  export * from './use-request-cancel-withdraw.js';
6
8
  export * from './use-simulate-finalize-withdraw-request.js';
7
9
  export * from './use-simulate-initiate-withdraw.js';
8
10
  export * from './use-simulate-request-cancel-withdraw.js';
9
11
  export * from './use-withdraw.js';
12
+ export * from './use-withdraw-cooldown-of.js';
10
13
  export * from './use-withdraw-requests.js';
11
14
  export * from './use-withdrawable-time.js';
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withdraw/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/withdraw/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0CAA0C,CAAC;AACzD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { ConfigParameter, GetDeallocateDebounceTimeOptions, GetDeallocateDebounceTimeReturnType } 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 useDeallocateDebounceTime}: the core query options
6
+ * (optional chain id, TanStack `query` overrides) plus an optional `config`.
7
+ */
8
+ export type UseDeallocateDebounceTimeParameters = GetDeallocateDebounceTimeOptions & ConfigParameter;
9
+ /** Return type of {@link useDeallocateDebounceTime}. */
10
+ export type UseDeallocateDebounceTimeReturnType = UseQueryResult<GetDeallocateDebounceTimeReturnType, SymmioRequestError>;
11
+ /**
12
+ * Read the protocol's deallocate debounce, in seconds: the minimum gap the
13
+ * SYMMIO core enforces between two deallocations of the same account. A
14
+ * deallocation reverts until `withdrawCooldownOf(account) + debounce` has
15
+ * passed (see {@link useWithdrawCooldownOf}); `0n` means no gap.
16
+ *
17
+ * It is a deployment-wide setting, the same for every account, so it rarely
18
+ * changes. `chainId` defaults to the connected chain.
19
+ *
20
+ * @param parameters - Optional chain id, query overrides and config.
21
+ * @returns The TanStack query result; `data` is the debounce in seconds.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * const { data: debounceSeconds } = useDeallocateDebounceTime();
26
+ * ```
27
+ */
28
+ export declare function useDeallocateDebounceTime(parameters?: UseDeallocateDebounceTimeParameters): UseDeallocateDebounceTimeReturnType;
29
+ //# sourceMappingURL=use-deallocate-debounce-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-deallocate-debounce-time.d.ts","sourceRoot":"","sources":["../../src/withdraw/use-deallocate-debounce-time.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,gCAAgC,EACrC,KAAK,mCAAmC,EACzC,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,mCAAmC,GAAG,gCAAgC,GAAG,eAAe,CAAC;AAErG,wDAAwD;AACxD,MAAM,MAAM,mCAAmC,GAAG,cAAc,CAC9D,mCAAmC,EACnC,kBAAkB,CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,GAAE,mCAAwC,GACnD,mCAAmC,CAkBrC"}
@@ -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 { getDeallocateDebounceTimeQueryOptions as r } from "@symmio/trading-core";
6
+ import { useQuery as i } from "@tanstack/react-query";
7
+ //#region src/withdraw/use-deallocate-debounce-time.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 useDeallocateDebounceTime };
26
+
27
+ //# sourceMappingURL=use-deallocate-debounce-time.js.map
@@ -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}. */