@symmio/trading-react 3.0.0 → 3.1.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 (267) hide show
  1. package/dist/account-layer/use-account-balance-of.d.ts +5 -4
  2. package/dist/account-layer/use-account-balance-of.d.ts.map +1 -1
  3. package/dist/account-layer/use-account-balance-of.js.map +1 -1
  4. package/dist/account-layer/use-add-margin.d.ts.map +1 -1
  5. package/dist/account-layer/use-add-margin.js +1 -3
  6. package/dist/account-layer/use-add-margin.js.map +1 -1
  7. package/dist/account-layer/use-allocate.d.ts.map +1 -1
  8. package/dist/account-layer/use-allocate.js +1 -3
  9. package/dist/account-layer/use-allocate.js.map +1 -1
  10. package/dist/account-layer/use-cancel-registration.d.ts.map +1 -1
  11. package/dist/account-layer/use-cancel-registration.js +1 -2
  12. package/dist/account-layer/use-cancel-registration.js.map +1 -1
  13. package/dist/account-layer/use-create-sub-accounts.d.ts.map +1 -1
  14. package/dist/account-layer/use-create-sub-accounts.js +1 -3
  15. package/dist/account-layer/use-create-sub-accounts.js.map +1 -1
  16. package/dist/account-layer/use-deallocate-and-initiate-withdraw.d.ts.map +1 -1
  17. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js +1 -6
  18. package/dist/account-layer/use-deallocate-and-initiate-withdraw.js.map +1 -1
  19. package/dist/account-layer/use-deallocate.d.ts.map +1 -1
  20. package/dist/account-layer/use-deallocate.js +1 -3
  21. package/dist/account-layer/use-deallocate.js.map +1 -1
  22. package/dist/account-layer/use-delete-sub-account.d.ts.map +1 -1
  23. package/dist/account-layer/use-delete-sub-account.js +1 -2
  24. package/dist/account-layer/use-delete-sub-account.js.map +1 -1
  25. package/dist/account-layer/use-deposit-and-allocate.d.ts.map +1 -1
  26. package/dist/account-layer/use-deposit-and-allocate.js +1 -3
  27. package/dist/account-layer/use-deposit-and-allocate.js.map +1 -1
  28. package/dist/account-layer/use-deposit.d.ts.map +1 -1
  29. package/dist/account-layer/use-deposit.js +1 -3
  30. package/dist/account-layer/use-deposit.js.map +1 -1
  31. package/dist/account-layer/use-edit-account-name.d.ts.map +1 -1
  32. package/dist/account-layer/use-edit-account-name.js +1 -3
  33. package/dist/account-layer/use-edit-account-name.js.map +1 -1
  34. package/dist/account-layer/use-remove-margin.d.ts.map +1 -1
  35. package/dist/account-layer/use-remove-margin.js +1 -3
  36. package/dist/account-layer/use-remove-margin.js.map +1 -1
  37. package/dist/account-layer/use-request-to-register-affiliate.d.ts.map +1 -1
  38. package/dist/account-layer/use-request-to-register-affiliate.js +1 -2
  39. package/dist/account-layer/use-request-to-register-affiliate.js.map +1 -1
  40. package/dist/collateral/use-approve-collateral.d.ts.map +1 -1
  41. package/dist/collateral/use-approve-collateral.js +1 -2
  42. package/dist/collateral/use-approve-collateral.js.map +1 -1
  43. package/dist/errors/normalize-symm-error.d.ts.map +1 -1
  44. package/dist/errors/normalize-symm-error.js +1 -0
  45. package/dist/errors/normalize-symm-error.js.map +1 -1
  46. package/dist/errors/symmio-request-error.d.ts +19 -0
  47. package/dist/errors/symmio-request-error.d.ts.map +1 -1
  48. package/dist/errors/symmio-request-error.js +2 -1
  49. package/dist/errors/symmio-request-error.js.map +1 -1
  50. package/dist/gasless/gasless-relay-types.d.ts +115 -0
  51. package/dist/gasless/gasless-relay-types.d.ts.map +1 -0
  52. package/dist/gasless/gasless-relay-types.js +9 -0
  53. package/dist/gasless/gasless-relay-types.js.map +1 -0
  54. package/dist/gasless/index.d.ts +21 -0
  55. package/dist/gasless/index.d.ts.map +1 -0
  56. package/dist/gasless/index.js +21 -0
  57. package/dist/gasless/invalidate-relay-reads.d.ts +96 -0
  58. package/dist/gasless/invalidate-relay-reads.d.ts.map +1 -0
  59. package/dist/gasless/invalidate-relay-reads.js +107 -0
  60. package/dist/gasless/invalidate-relay-reads.js.map +1 -0
  61. package/dist/gasless/use-approve-operational-fee.d.ts +38 -0
  62. package/dist/gasless/use-approve-operational-fee.d.ts.map +1 -0
  63. package/dist/gasless/use-approve-operational-fee.js +37 -0
  64. package/dist/gasless/use-approve-operational-fee.js.map +1 -0
  65. package/dist/gasless/use-debounced-batch.d.ts +22 -0
  66. package/dist/gasless/use-debounced-batch.d.ts.map +1 -0
  67. package/dist/gasless/use-debounced-batch.js +27 -0
  68. package/dist/gasless/use-debounced-batch.js.map +1 -0
  69. package/dist/gasless/use-gasless-batch-fee-quote.d.ts +48 -0
  70. package/dist/gasless/use-gasless-batch-fee-quote.d.ts.map +1 -0
  71. package/dist/gasless/use-gasless-batch-fee-quote.js +33 -0
  72. package/dist/gasless/use-gasless-batch-fee-quote.js.map +1 -0
  73. package/dist/gasless/use-gasless-deposit-policy.d.ts +28 -0
  74. package/dist/gasless/use-gasless-deposit-policy.d.ts.map +1 -0
  75. package/dist/gasless/use-gasless-deposit-policy.js +27 -0
  76. package/dist/gasless/use-gasless-deposit-policy.js.map +1 -0
  77. package/dist/gasless/use-gasless-fee-quote.d.ts +25 -0
  78. package/dist/gasless/use-gasless-fee-quote.d.ts.map +1 -0
  79. package/dist/gasless/use-gasless-fee-quote.js +27 -0
  80. package/dist/gasless/use-gasless-fee-quote.js.map +1 -0
  81. package/dist/gasless/use-gasless-relay-confirmation.d.ts +72 -0
  82. package/dist/gasless/use-gasless-relay-confirmation.d.ts.map +1 -0
  83. package/dist/gasless/use-gasless-relay-confirmation.js +148 -0
  84. package/dist/gasless/use-gasless-relay-confirmation.js.map +1 -0
  85. package/dist/gasless/use-gasless-request-stream.d.ts +34 -0
  86. package/dist/gasless/use-gasless-request-stream.d.ts.map +1 -0
  87. package/dist/gasless/use-gasless-request-stream.js +86 -0
  88. package/dist/gasless/use-gasless-request-stream.js.map +1 -0
  89. package/dist/gasless/use-gasless-request-transactions.d.ts +42 -0
  90. package/dist/gasless/use-gasless-request-transactions.d.ts.map +1 -0
  91. package/dist/gasless/use-gasless-request-transactions.js +28 -0
  92. package/dist/gasless/use-gasless-request-transactions.js.map +1 -0
  93. package/dist/gasless/use-gasless-request.d.ts +56 -0
  94. package/dist/gasless/use-gasless-request.d.ts.map +1 -0
  95. package/dist/gasless/use-gasless-request.js +51 -0
  96. package/dist/gasless/use-gasless-request.js.map +1 -0
  97. package/dist/gasless/use-gasless-wallet-address.d.ts +24 -0
  98. package/dist/gasless/use-gasless-wallet-address.d.ts.map +1 -0
  99. package/dist/gasless/use-gasless-wallet-address.js +27 -0
  100. package/dist/gasless/use-gasless-wallet-address.js.map +1 -0
  101. package/dist/gasless/use-gasless-wallet-creation-fee.d.ts +29 -0
  102. package/dist/gasless/use-gasless-wallet-creation-fee.d.ts.map +1 -0
  103. package/dist/gasless/use-gasless-wallet-creation-fee.js +27 -0
  104. package/dist/gasless/use-gasless-wallet-creation-fee.js.map +1 -0
  105. package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts +44 -0
  106. package/dist/gasless/use-gasless-wallet-execute-selectors.d.ts.map +1 -0
  107. package/dist/gasless/use-gasless-wallet-execute-selectors.js +19 -0
  108. package/dist/gasless/use-gasless-wallet-execute-selectors.js.map +1 -0
  109. package/dist/gasless/use-gasless-wallet-execute.d.ts +51 -0
  110. package/dist/gasless/use-gasless-wallet-execute.d.ts.map +1 -0
  111. package/dist/gasless/use-gasless-wallet-execute.js +44 -0
  112. package/dist/gasless/use-gasless-wallet-execute.js.map +1 -0
  113. package/dist/gasless/use-gasless-wallet-nonce.d.ts +27 -0
  114. package/dist/gasless/use-gasless-wallet-nonce.d.ts.map +1 -0
  115. package/dist/gasless/use-gasless-wallet-nonce.js +27 -0
  116. package/dist/gasless/use-gasless-wallet-nonce.js.map +1 -0
  117. package/dist/gasless/use-operational-fee-allowance.d.ts +23 -0
  118. package/dist/gasless/use-operational-fee-allowance.d.ts.map +1 -0
  119. package/dist/gasless/use-operational-fee-allowance.js +27 -0
  120. package/dist/gasless/use-operational-fee-allowance.js.map +1 -0
  121. package/dist/gasless/use-relay-gasless-batch.d.ts +48 -0
  122. package/dist/gasless/use-relay-gasless-batch.d.ts.map +1 -0
  123. package/dist/gasless/use-relay-gasless-batch.js +44 -0
  124. package/dist/gasless/use-relay-gasless-batch.js.map +1 -0
  125. package/dist/gasless/use-relay-instant-operations.d.ts +43 -0
  126. package/dist/gasless/use-relay-instant-operations.d.ts.map +1 -0
  127. package/dist/gasless/use-relay-instant-operations.js +44 -0
  128. package/dist/gasless/use-relay-instant-operations.js.map +1 -0
  129. package/dist/gasless/use-resubmit-gasless-request.d.ts +39 -0
  130. package/dist/gasless/use-resubmit-gasless-request.d.ts.map +1 -0
  131. package/dist/gasless/use-resubmit-gasless-request.js +56 -0
  132. package/dist/gasless/use-resubmit-gasless-request.js.map +1 -0
  133. package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts +41 -0
  134. package/dist/gasless/use-settle-gasless-deposit-existing-account.d.ts.map +1 -0
  135. package/dist/gasless/use-settle-gasless-deposit-existing-account.js +47 -0
  136. package/dist/gasless/use-settle-gasless-deposit-existing-account.js.map +1 -0
  137. package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts +48 -0
  138. package/dist/gasless/use-settle-gasless-deposit-new-account.d.ts.map +1 -0
  139. package/dist/gasless/use-settle-gasless-deposit-new-account.js +48 -0
  140. package/dist/gasless/use-settle-gasless-deposit-new-account.js.map +1 -0
  141. package/dist/gasless/use-supports-gasless-service.d.ts +22 -0
  142. package/dist/gasless/use-supports-gasless-service.d.ts.map +1 -0
  143. package/dist/gasless/use-supports-gasless-service.js +13 -0
  144. package/dist/gasless/use-supports-gasless-service.js.map +1 -0
  145. package/dist/index.d.ts +29 -11
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +251 -221
  148. package/dist/instant-layer/index.d.ts +7 -0
  149. package/dist/instant-layer/index.d.ts.map +1 -1
  150. package/dist/instant-layer/index.js +26 -19
  151. package/dist/instant-layer/use-active-delegations.d.ts +31 -0
  152. package/dist/instant-layer/use-active-delegations.d.ts.map +1 -0
  153. package/dist/instant-layer/use-active-delegations.js +23 -0
  154. package/dist/instant-layer/use-active-delegations.js.map +1 -0
  155. package/dist/instant-layer/use-are-delegations-active.d.ts +100 -0
  156. package/dist/instant-layer/use-are-delegations-active.d.ts.map +1 -0
  157. package/dist/instant-layer/use-are-delegations-active.js +60 -0
  158. package/dist/instant-layer/use-are-delegations-active.js.map +1 -0
  159. package/dist/instant-layer/use-finalize-revoke-delegation.d.ts +32 -0
  160. package/dist/instant-layer/use-finalize-revoke-delegation.d.ts.map +1 -0
  161. package/dist/instant-layer/use-finalize-revoke-delegation.js +45 -0
  162. package/dist/instant-layer/use-finalize-revoke-delegation.js.map +1 -0
  163. package/dist/instant-layer/use-grant-delegation.d.ts +12 -2
  164. package/dist/instant-layer/use-grant-delegation.d.ts.map +1 -1
  165. package/dist/instant-layer/use-grant-delegation.js +27 -20
  166. package/dist/instant-layer/use-grant-delegation.js.map +1 -1
  167. package/dist/instant-layer/use-initiate-revoke-delegation.d.ts +32 -0
  168. package/dist/instant-layer/use-initiate-revoke-delegation.d.ts.map +1 -0
  169. package/dist/instant-layer/use-initiate-revoke-delegation.js +45 -0
  170. package/dist/instant-layer/use-initiate-revoke-delegation.js.map +1 -0
  171. package/dist/instant-layer/use-pending-revocation.d.ts +119 -0
  172. package/dist/instant-layer/use-pending-revocation.d.ts.map +1 -0
  173. package/dist/instant-layer/use-pending-revocation.js +73 -0
  174. package/dist/instant-layer/use-pending-revocation.js.map +1 -0
  175. package/dist/instant-layer/use-revocation-cooldown.d.ts +24 -0
  176. package/dist/instant-layer/use-revocation-cooldown.d.ts.map +1 -0
  177. package/dist/instant-layer/use-revocation-cooldown.js +23 -0
  178. package/dist/instant-layer/use-revocation-cooldown.js.map +1 -0
  179. package/dist/instant-layer/use-session-key-selectors.d.ts +53 -0
  180. package/dist/instant-layer/use-session-key-selectors.d.ts.map +1 -0
  181. package/dist/instant-layer/use-session-key-selectors.js +25 -0
  182. package/dist/instant-layer/use-session-key-selectors.js.map +1 -0
  183. package/dist/margin/use-available-instant-open-margin.js +8 -8
  184. package/dist/markets/index.d.ts +1 -0
  185. package/dist/markets/index.d.ts.map +1 -1
  186. package/dist/markets/index.js +3 -2
  187. package/dist/markets/use-funding-fees-of-party-b.d.ts +47 -0
  188. package/dist/markets/use-funding-fees-of-party-b.d.ts.map +1 -0
  189. package/dist/markets/use-funding-fees-of-party-b.js +27 -0
  190. package/dist/markets/use-funding-fees-of-party-b.js.map +1 -0
  191. package/dist/provider/create-session-key-wallet-client-resolver.d.ts +68 -0
  192. package/dist/provider/create-session-key-wallet-client-resolver.d.ts.map +1 -0
  193. package/dist/provider/create-session-key-wallet-client-resolver.js +51 -0
  194. package/dist/provider/create-session-key-wallet-client-resolver.js.map +1 -0
  195. package/dist/provider/index.d.ts +1 -0
  196. package/dist/provider/index.d.ts.map +1 -1
  197. package/dist/provider/index.js +5 -4
  198. package/dist/provider/symmio-provider.d.ts +7 -2
  199. package/dist/provider/symmio-provider.d.ts.map +1 -1
  200. package/dist/provider/symmio-provider.js +10 -7
  201. package/dist/provider/symmio-provider.js.map +1 -1
  202. package/dist/quotes/index.d.ts +2 -0
  203. package/dist/quotes/index.d.ts.map +1 -1
  204. package/dist/quotes/use-account-upnl.js +9 -9
  205. package/dist/quotes/use-close-quote-group.js +13 -13
  206. package/dist/quotes/use-force-cancel-close-request.d.ts.map +1 -1
  207. package/dist/quotes/use-force-cancel-close-request.js +1 -4
  208. package/dist/quotes/use-force-cancel-close-request.js.map +1 -1
  209. package/dist/quotes/use-force-cancel-quote.d.ts.map +1 -1
  210. package/dist/quotes/use-force-cancel-quote.js +1 -4
  211. package/dist/quotes/use-force-cancel-quote.js.map +1 -1
  212. package/dist/quotes/use-force-close.d.ts +2 -1
  213. package/dist/quotes/use-force-close.d.ts.map +1 -1
  214. package/dist/quotes/use-force-close.js +14 -12
  215. package/dist/quotes/use-force-close.js.map +1 -1
  216. package/dist/quotes/use-limit-orders.js +9 -9
  217. package/dist/quotes/use-managed-quotes.d.ts.map +1 -1
  218. package/dist/quotes/use-managed-quotes.js +103 -103
  219. package/dist/quotes/use-managed-quotes.js.map +1 -1
  220. package/dist/quotes/use-party-a-open-positions.js +5 -5
  221. package/dist/quotes/use-quote-group-funding-history.d.ts +10 -7
  222. package/dist/quotes/use-quote-group-funding-history.d.ts.map +1 -1
  223. package/dist/quotes/use-quote-group-funding-history.js.map +1 -1
  224. package/dist/quotes/use-quote-group-funding.d.ts +4 -2
  225. package/dist/quotes/use-quote-group-funding.d.ts.map +1 -1
  226. package/dist/quotes/use-quote-group-funding.js.map +1 -1
  227. package/dist/quotes/use-quote-pending-funding.d.ts +62 -0
  228. package/dist/quotes/use-quote-pending-funding.d.ts.map +1 -0
  229. package/dist/quotes/use-quote-pending-funding.js +31 -0
  230. package/dist/quotes/use-quote-pending-funding.js.map +1 -0
  231. package/dist/quotes/use-quotes-funding.d.ts +4 -2
  232. package/dist/quotes/use-quotes-funding.d.ts.map +1 -1
  233. package/dist/quotes/use-quotes-funding.js.map +1 -1
  234. package/dist/quotes/use-quotes-pending-funding.d.ts +92 -0
  235. package/dist/quotes/use-quotes-pending-funding.d.ts.map +1 -0
  236. package/dist/quotes/use-quotes-pending-funding.js +94 -0
  237. package/dist/quotes/use-quotes-pending-funding.js.map +1 -0
  238. package/dist/quotes/use-request-to-cancel-close-request.d.ts.map +1 -1
  239. package/dist/quotes/use-request-to-cancel-close-request.js +1 -4
  240. package/dist/quotes/use-request-to-cancel-close-request.js.map +1 -1
  241. package/dist/quotes/use-request-to-cancel-quote.d.ts.map +1 -1
  242. package/dist/quotes/use-request-to-cancel-quote.js +1 -4
  243. package/dist/quotes/use-request-to-cancel-quote.js.map +1 -1
  244. package/dist/transactions/index.js +3 -3
  245. package/dist/transactions/resolve-write-result.d.ts +53 -2
  246. package/dist/transactions/resolve-write-result.d.ts.map +1 -1
  247. package/dist/transactions/resolve-write-result.js +52 -9
  248. package/dist/transactions/resolve-write-result.js.map +1 -1
  249. package/dist/transactions/write-types.d.ts +19 -1
  250. package/dist/transactions/write-types.d.ts.map +1 -1
  251. package/dist/utils/predicate-match.d.ts +7 -4
  252. package/dist/utils/predicate-match.d.ts.map +1 -1
  253. package/dist/utils/predicate-match.js +5 -5
  254. package/dist/utils/predicate-match.js.map +1 -1
  255. package/dist/withdraw/use-finalize-withdraw-request.d.ts.map +1 -1
  256. package/dist/withdraw/use-finalize-withdraw-request.js +1 -3
  257. package/dist/withdraw/use-finalize-withdraw-request.js.map +1 -1
  258. package/dist/withdraw/use-initiate-withdraw.d.ts.map +1 -1
  259. package/dist/withdraw/use-initiate-withdraw.js +1 -5
  260. package/dist/withdraw/use-initiate-withdraw.js.map +1 -1
  261. package/dist/withdraw/use-request-cancel-withdraw.d.ts.map +1 -1
  262. package/dist/withdraw/use-request-cancel-withdraw.js +1 -3
  263. package/dist/withdraw/use-request-cancel-withdraw.js.map +1 -1
  264. package/dist/withdraw/use-withdraw.d.ts.map +1 -1
  265. package/dist/withdraw/use-withdraw.js +2 -1
  266. package/dist/withdraw/use-withdraw.js.map +1 -1
  267. package/package.json +6 -2
@@ -1 +1 @@
1
- {"version":3,"file":"use-request-to-register-affiliate.js","names":[],"sources":["../../src/account-layer/use-request-to-register-affiliate.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getAffiliateStateQueryKey,\n requestToRegisterAffiliateMutationOptions,\n type RequestToRegisterAffiliateParameters,\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 useRequestToRegisterAffiliate}.\n */\nexport type UseRequestToRegisterAffiliateParameters = WriteParameters;\n\n/**\n * Result returned by the {@link useRequestToRegisterAffiliate} mutation.\n */\nexport type RequestToRegisterAffiliateResult = WriteResult;\n\n/** Return type of {@link useRequestToRegisterAffiliate}. */\nexport type UseRequestToRegisterAffiliateReturnType = UseMutationResult<\n RequestToRegisterAffiliateResult,\n SymmioRequestError,\n RequestToRegisterAffiliateParameters\n>;\n\n/**\n * Submit a `requestToRegisterAffiliate` transaction — the permissionless\n * on-chain request that creates a `PENDING` affiliate awaiting approval. On\n * success, every `getAffiliateState` query is invalidated so any mounted status\n * poll refetches.\n *\n * The registration is faithful to the contract tuple: `stakeholders` shares plus\n * `symmioShare` must sum to `1e18`. Derive the resulting affiliate address with\n * `useGeneratedAccountManagerAddress` (a write cannot return it).\n *\n * @example\n * ```tsx\n * const { mutate, status, error } = useRequestToRegisterAffiliate();\n * mutate({\n * registration: {\n * name: \"Acme\",\n * brandColor: \"#ff5c39\",\n * admin,\n * stakeholders: [{ receiver: admin, share: 900000000000000000n }],\n * symmioShare: 100000000000000000n,\n * metadata: \"0x\",\n * legacyMultiAccounts: [],\n * symmioCores: [core],\n * },\n * });\n * ```\n */\nexport function useRequestToRegisterAffiliate(\n parameters: UseRequestToRegisterAffiliateParameters = {},\n): UseRequestToRegisterAffiliateReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = requestToRegisterAffiliateMutationOptions(config);\n\n return useMutation<RequestToRegisterAffiliateResult, SymmioRequestError, RequestToRegisterAffiliateParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({\n registration: variables.registration,\n simulateBeforeWrite: variables.simulateBeforeWrite,\n chainId: resolvedChainId,\n });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAffiliateStateQueryKey) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA2DA,SAAgB,EACd,IAAsD,CAAC,GACd;CACzC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAA0C,CAAM;CAE7D,OAAO,EAAwG;EAC7G,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAM7C,OAAO,EAAmB,GAAQ,MALf,EAAK,WAAW;KACjC,cAAc,EAAU;KACxB,qBAAqB,EAAU;KAC/B,SAAS;IACX,CAAC,GACuC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GACf,EAAiB,kBAAkB,EAAE,WAAW,EAAe,CAAyB,EAAE,CAAC;EAC7F;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-request-to-register-affiliate.js","names":[],"sources":["../../src/account-layer/use-request-to-register-affiliate.ts"],"sourcesContent":["\"use client\";\n\nimport {\n getAffiliateStateQueryKey,\n requestToRegisterAffiliateMutationOptions,\n type RequestToRegisterAffiliateParameters,\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 useRequestToRegisterAffiliate}.\n */\nexport type UseRequestToRegisterAffiliateParameters = WriteParameters;\n\n/**\n * Result returned by the {@link useRequestToRegisterAffiliate} mutation.\n */\nexport type RequestToRegisterAffiliateResult = WriteResult;\n\n/** Return type of {@link useRequestToRegisterAffiliate}. */\nexport type UseRequestToRegisterAffiliateReturnType = UseMutationResult<\n RequestToRegisterAffiliateResult,\n SymmioRequestError,\n RequestToRegisterAffiliateParameters\n>;\n\n/**\n * Submit a `requestToRegisterAffiliate` transaction — the permissionless\n * on-chain request that creates a `PENDING` affiliate awaiting approval. On\n * success, every `getAffiliateState` query is invalidated so any mounted status\n * poll refetches.\n *\n * The registration is faithful to the contract tuple: `stakeholders` shares plus\n * `symmioShare` must sum to `1e18`. Derive the resulting affiliate address with\n * `useGeneratedAccountManagerAddress` (a write cannot return it).\n *\n * @example\n * ```tsx\n * const { mutate, status, error } = useRequestToRegisterAffiliate();\n * mutate({\n * registration: {\n * name: \"Acme\",\n * brandColor: \"#ff5c39\",\n * admin,\n * stakeholders: [{ receiver: admin, share: 900000000000000000n }],\n * symmioShare: 100000000000000000n,\n * metadata: \"0x\",\n * legacyMultiAccounts: [],\n * symmioCores: [core],\n * },\n * });\n * ```\n */\nexport function useRequestToRegisterAffiliate(\n parameters: UseRequestToRegisterAffiliateParameters = {},\n): UseRequestToRegisterAffiliateReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const queryClient = useQueryClient();\n\n const base = requestToRegisterAffiliateMutationOptions(config);\n\n return useMutation<RequestToRegisterAffiliateResult, SymmioRequestError, RequestToRegisterAffiliateParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ predicate: predicateMatch(getAffiliateStateQueryKey) });\n },\n });\n}\n"],"mappings":";;;;;;;;;AA2DA,SAAgB,EACd,IAAsD,CAAC,GACd;CACzC,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,IAAc,EAAe,GAE7B,IAAO,EAA0C,CAAM;CAE7D,OAAO,EAAwG;EAC7G,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GACf,EAAiB,kBAAkB,EAAE,WAAW,EAAe,CAAyB,EAAE,CAAC;EAC7F;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-approve-collateral.d.ts","sourceRoot":"","sources":["../../src/collateral/use-approve-collateral.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,eAAe,CAAC;AAE7D,oEAAoE;AACpE,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAElD,mDAAmD;AACnD,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAC5D,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,CAC5B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,GAAE,8BAAmC,GAAG,8BAA8B,CAgCpH"}
1
+ {"version":3,"file":"use-approve-collateral.d.ts","sourceRoot":"","sources":["../../src/collateral/use-approve-collateral.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA+B,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7F;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,eAAe,CAAC;AAE7D,oEAAoE;AACpE,MAAM,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAElD,mDAAmD;AACnD,MAAM,MAAM,8BAA8B,GAAG,iBAAiB,CAC5D,uBAAuB,EACvB,kBAAkB,EAClB,2BAA2B,CAC5B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,GAAE,8BAAmC,GAAG,8BAA8B,CA4BpH"}
@@ -16,8 +16,7 @@ function u(u = {}) {
16
16
  try {
17
17
  let t = e.chainId ?? f;
18
18
  return r(d, await h.mutationFn({
19
- amount: e.amount,
20
- simulateBeforeWrite: e.simulateBeforeWrite,
19
+ ...e,
21
20
  chainId: t
22
21
  }), {
23
22
  chainId: t,
@@ -1 +1 @@
1
- {"version":3,"file":"use-approve-collateral.js","names":[],"sources":["../../src/collateral/use-approve-collateral.ts"],"sourcesContent":["\"use client\";\n\nimport {\n approveCollateralMutationOptions,\n getCollateralAllowanceQueryKey,\n type ApproveCollateralParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useConnection } from \"wagmi\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useApproveCollateral}.\n */\nexport type UseApproveCollateralParameters = WriteParameters;\n\n/** Result returned by the {@link useApproveCollateral} mutation. */\nexport type ApproveCollateralResult = WriteResult;\n\n/** Return type of {@link useApproveCollateral}. */\nexport type UseApproveCollateralReturnType = UseMutationResult<\n ApproveCollateralResult,\n SymmioRequestError,\n ApproveCollateralParameters\n>;\n\n/**\n * Submit an ERC20 `approve` of the collateral token to the SYMMIO core — the\n * prerequisite for `useDeposit` / `useDepositAndAllocate`. On success, the\n * connected wallet's collateral allowance query is invalidated so a gating\n * \"needs approval\" check refetches.\n *\n * @example\n * ```tsx\n * import { maxUint256 } from \"viem\";\n * const { mutate, status, error } = useApproveCollateral();\n * mutate({ amount: maxUint256 });\n * ```\n */\nexport function useApproveCollateral(parameters: UseApproveCollateralParameters = {}): UseApproveCollateralReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const { address } = useConnection();\n const queryClient = useQueryClient();\n\n const base = approveCollateralMutationOptions(config);\n\n return useMutation<ApproveCollateralResult, SymmioRequestError, ApproveCollateralParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({\n amount: variables.amount,\n simulateBeforeWrite: variables.simulateBeforeWrite,\n chainId: resolvedChainId,\n });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n const partial = address ? { owner: address } : undefined;\n void queryClient.invalidateQueries({ predicate: predicateMatch(getCollateralAllowanceQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;;AA4CA,SAAgB,EAAqB,IAA6C,CAAC,GAAmC;CACpH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,EAAE,eAAY,EAAc,GAC5B,IAAc,EAAe,GAE7B,IAAO,EAAiC,CAAM;CAEpD,OAAO,EAAsF;EAC3F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAM7C,OAAO,EAAmB,GAAQ,MALf,EAAK,WAAW;KACjC,QAAQ,EAAU;KAClB,qBAAqB,EAAU;KAC/B,SAAS;IACX,CAAC,GACuC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GACf,IAAM,IAAU,IAAU,EAAE,OAAO,EAAQ,IAAI,KAAA;GAC/C,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC;EAC3G;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"use-approve-collateral.js","names":[],"sources":["../../src/collateral/use-approve-collateral.ts"],"sourcesContent":["\"use client\";\n\nimport {\n approveCollateralMutationOptions,\n getCollateralAllowanceQueryKey,\n type ApproveCollateralParameters,\n} from \"@symmio/trading-core\";\nimport { useMutation, useQueryClient, type UseMutationResult } from \"@tanstack/react-query\";\nimport { useConnection } from \"wagmi\";\nimport { normalizeSymmError } from \"../errors/normalize-symm-error\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\nimport { useSymmioChainId } from \"../provider/use-symmio-chain-id\";\nimport { useSymmioConfig } from \"../provider/use-symmio-config\";\nimport { resolveWriteResult, type WriteParameters, type WriteResult } from \"../transactions\";\nimport { predicateMatch } from \"../utils\";\n\n/**\n * Parameters for {@link useApproveCollateral}.\n */\nexport type UseApproveCollateralParameters = WriteParameters;\n\n/** Result returned by the {@link useApproveCollateral} mutation. */\nexport type ApproveCollateralResult = WriteResult;\n\n/** Return type of {@link useApproveCollateral}. */\nexport type UseApproveCollateralReturnType = UseMutationResult<\n ApproveCollateralResult,\n SymmioRequestError,\n ApproveCollateralParameters\n>;\n\n/**\n * Submit an ERC20 `approve` of the collateral token to the SYMMIO core — the\n * prerequisite for `useDeposit` / `useDepositAndAllocate`. On success, the\n * connected wallet's collateral allowance query is invalidated so a gating\n * \"needs approval\" check refetches.\n *\n * @example\n * ```tsx\n * import { maxUint256 } from \"viem\";\n * const { mutate, status, error } = useApproveCollateral();\n * mutate({ amount: maxUint256 });\n * ```\n */\nexport function useApproveCollateral(parameters: UseApproveCollateralParameters = {}): UseApproveCollateralReturnType {\n const config = useSymmioConfig(parameters);\n const chainId = useSymmioChainId();\n const { address } = useConnection();\n const queryClient = useQueryClient();\n\n const base = approveCollateralMutationOptions(config);\n\n return useMutation<ApproveCollateralResult, SymmioRequestError, ApproveCollateralParameters>({\n mutationKey: base.mutationKey,\n mutationFn: async (variables) => {\n try {\n const resolvedChainId = variables.chainId ?? chainId;\n const hash = await base.mutationFn({ ...variables, chainId: resolvedChainId });\n return resolveWriteResult(config, hash, {\n chainId: resolvedChainId,\n waitForReceipt: parameters.waitForReceipt,\n confirmations: parameters.confirmations,\n });\n } catch (err) {\n throw normalizeSymmError(err);\n }\n },\n onSuccess: () => {\n const partial = address ? { owner: address } : undefined;\n void queryClient.invalidateQueries({ predicate: predicateMatch(getCollateralAllowanceQueryKey, partial) });\n },\n });\n}\n"],"mappings":";;;;;;;;;;AA4CA,SAAgB,EAAqB,IAA6C,CAAC,GAAmC;CACpH,IAAM,IAAS,EAAgB,CAAU,GACnC,IAAU,EAAiB,GAC3B,EAAE,eAAY,EAAc,GAC5B,IAAc,EAAe,GAE7B,IAAO,EAAiC,CAAM;CAEpD,OAAO,EAAsF;EAC3F,aAAa,EAAK;EAClB,YAAY,OAAO,MAAc;GAC/B,IAAI;IACF,IAAM,IAAkB,EAAU,WAAW;IAE7C,OAAO,EAAmB,GAAQ,MADf,EAAK,WAAW;KAAE,GAAG;KAAW,SAAS;IAAgB,CAAC,GACrC;KACtC,SAAS;KACT,gBAAgB,EAAW;KAC3B,eAAe,EAAW;IAC5B,CAAC;GACH,SAAS,GAAK;IACZ,MAAM,EAAmB,CAAG;GAC9B;EACF;EACA,iBAAiB;GACf,IAAM,IAAU,IAAU,EAAE,OAAO,EAAQ,IAAI,KAAA;GAC/C,EAAiB,kBAAkB,EAAE,WAAW,EAAe,GAAgC,CAAO,EAAE,CAAC;EAC3G;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-symm-error.d.ts","sourceRoot":"","sources":["../../src/errors/normalize-symm-error.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CAsFnE"}
1
+ {"version":3,"file":"normalize-symm-error.d.ts","sourceRoot":"","sources":["../../src/errors/normalize-symm-error.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CAuFnE"}
@@ -10,6 +10,7 @@ function d(r) {
10
10
  code: r.code,
11
11
  status: r.status,
12
12
  responseData: r.responseData,
13
+ retryAfterMs: r.retryAfterMs,
13
14
  cause: r
14
15
  });
15
16
  if (r instanceof n) return new e({
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-symm-error.js","names":[],"sources":["../../src/errors/normalize-symm-error.ts"],"sourcesContent":["import { SymmApiError, SymmError } from \"@symmio/trading-core\";\nimport {\n BaseError,\n ContractFunctionRevertedError,\n EstimateGasExecutionError,\n HttpRequestError,\n InsufficientFundsError,\n TimeoutError,\n TransactionExecutionError,\n UserRejectedRequestError,\n} from \"viem\";\nimport { SymmioRequestError } from \"./symmio-request-error\";\n\n/**\n * Classify any thrown value into a {@link SymmioRequestError}. Hooks call this\n * inside their `queryFn` / `mutationFn` so consumers always see the same\n * discriminated shape, regardless of which viem error type fired underneath.\n *\n * The order of `walk` matters: a wallet-popup dismissal nests inside a\n * `TransactionExecutionError`, so the rejection check has to consider every\n * level of the cause chain, not just the topmost throw.\n *\n * @param err - The thrown value (typed `unknown` because Promises can reject with anything).\n */\nexport function normalizeSymmError(err: unknown): SymmioRequestError {\n if (err instanceof SymmioRequestError) return err;\n\n if (err instanceof SymmApiError) {\n return new SymmioRequestError({\n kind: \"api\",\n message: err.message,\n code: err.code,\n status: err.status,\n responseData: err.responseData,\n cause: err,\n });\n }\n\n if (err instanceof SymmError) {\n return new SymmioRequestError({\n kind: \"sdk\",\n message: err.message,\n code: err.code,\n cause: err,\n });\n }\n\n const viemErr = findViemError(err);\n\n if (viemErr) {\n const userRejected = findInCauseChain(viemErr, UserRejectedRequestError);\n if (userRejected) {\n return new SymmioRequestError({\n kind: \"user-rejected\",\n message: userRejected.shortMessage || \"Wallet request was rejected.\",\n cause: err,\n });\n }\n\n const revert = findInCauseChain(viemErr, ContractFunctionRevertedError);\n if (revert) {\n const reason = revert.reason ?? revert.data?.errorName;\n return new SymmioRequestError({\n kind: \"contract-revert\",\n message: revert.shortMessage || `Contract reverted${reason ? `: ${reason}` : \".\"}`,\n reason,\n cause: err,\n });\n }\n\n const insufficient = findInCauseChain(viemErr, InsufficientFundsError);\n if (insufficient) {\n return new SymmioRequestError({\n kind: \"insufficient-funds\",\n message: insufficient.shortMessage || \"Insufficient funds for gas.\",\n cause: err,\n });\n }\n\n const transport =\n findInCauseChain(viemErr, HttpRequestError) ||\n findInCauseChain(viemErr, TimeoutError) ||\n findInCauseChain(viemErr, EstimateGasExecutionError) ||\n findInCauseChain(viemErr, TransactionExecutionError);\n if (transport) {\n return new SymmioRequestError({\n kind: \"rpc\",\n message: transport.shortMessage || transport.message,\n shortMessage: transport.shortMessage,\n cause: err,\n });\n }\n\n return new SymmioRequestError({\n kind: \"rpc\",\n message: viemErr.shortMessage || viemErr.message,\n shortMessage: viemErr.shortMessage,\n cause: err,\n });\n }\n\n if (err instanceof Error) {\n return new SymmioRequestError({ kind: \"unknown\", message: err.message, cause: err });\n }\n\n return new SymmioRequestError({\n kind: \"unknown\",\n message: typeof err === \"string\" ? err : \"An unknown error occurred.\",\n cause: err,\n });\n}\n\n/**\n * Walk an error and its `cause` chain looking for a viem `BaseError`. Returns\n * the first one found, or `undefined`.\n *\n * @internal\n */\nfunction findViemError(err: unknown): BaseError | undefined {\n let current: unknown = err;\n let depth = 0;\n while (current && depth < 16) {\n if (current instanceof BaseError) return current;\n if (current instanceof Error && current.cause) {\n current = current.cause;\n depth += 1;\n continue;\n }\n return undefined;\n }\n return undefined;\n}\n\n/**\n * Walk a viem `BaseError`'s `walk()` chain looking for a specific subclass.\n *\n * @internal\n */\nfunction findInCauseChain<T extends BaseError>(err: BaseError, ctor: new (...args: never[]) => T): T | undefined {\n const found = err.walk((candidate) => candidate instanceof ctor);\n return found instanceof ctor ? (found as T) : undefined;\n}\n"],"mappings":";;;;AAwBA,SAAgB,EAAmB,GAAkC;CACnE,IAAI,aAAe,GAAoB,OAAO;CAE9C,IAAI,aAAe,GACjB,OAAO,IAAI,EAAmB;EAC5B,MAAM;EACN,SAAS,EAAI;EACb,MAAM,EAAI;EACV,QAAQ,EAAI;EACZ,cAAc,EAAI;EAClB,OAAO;CACT,CAAC;CAGH,IAAI,aAAe,GACjB,OAAO,IAAI,EAAmB;EAC5B,MAAM;EACN,SAAS,EAAI;EACb,MAAM,EAAI;EACV,OAAO;CACT,CAAC;CAGH,IAAM,IAAU,EAAc,CAAG;CAEjC,IAAI,GAAS;EACX,IAAM,IAAe,EAAiB,GAAS,CAAwB;EACvE,IAAI,GACF,OAAO,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAa,gBAAgB;GACtC,OAAO;EACT,CAAC;EAGH,IAAM,IAAS,EAAiB,GAAS,CAA6B;EACtE,IAAI,GAAQ;GACV,IAAM,IAAS,EAAO,UAAU,EAAO,MAAM;GAC7C,OAAO,IAAI,EAAmB;IAC5B,MAAM;IACN,SAAS,EAAO,gBAAgB,oBAAoB,IAAS,KAAK,MAAW;IAC7E;IACA,OAAO;GACT,CAAC;EACH;EAEA,IAAM,IAAe,EAAiB,GAAS,CAAsB;EACrE,IAAI,GACF,OAAO,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAa,gBAAgB;GACtC,OAAO;EACT,CAAC;EAGH,IAAM,IACJ,EAAiB,GAAS,CAAgB,KAC1C,EAAiB,GAAS,CAAY,KACtC,EAAiB,GAAS,CAAyB,KACnD,EAAiB,GAAS,CAAyB;EAUrD,OATI,IACK,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAU,gBAAgB,EAAU;GAC7C,cAAc,EAAU;GACxB,OAAO;EACT,CAAC,IAGI,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAQ,gBAAgB,EAAQ;GACzC,cAAc,EAAQ;GACtB,OAAO;EACT,CAAC;CACH;CAMA,OAJI,aAAe,QACV,IAAI,EAAmB;EAAE,MAAM;EAAW,SAAS,EAAI;EAAS,OAAO;CAAI,CAAC,IAG9E,IAAI,EAAmB;EAC5B,MAAM;EACN,SAAS,OAAO,KAAQ,WAAW,IAAM;EACzC,OAAO;CACT,CAAC;AACH;AAQA,SAAS,EAAc,GAAqC;CAC1D,IAAI,IAAmB,GACnB,IAAQ;CACZ,OAAO,KAAW,IAAQ,KAAI;EAC5B,IAAI,aAAmB,GAAW,OAAO;EACzC,IAAI,aAAmB,SAAS,EAAQ,OAAO;GAE7C,AADA,IAAU,EAAQ,OAClB,KAAS;GACT;EACF;EACA;CACF;AAEF;AAOA,SAAS,EAAsC,GAAgB,GAAkD;CAC/G,IAAM,IAAQ,EAAI,MAAM,MAAc,aAAqB,CAAI;CAC/D,OAAO,aAAiB,IAAQ,IAAc,KAAA;AAChD"}
1
+ {"version":3,"file":"normalize-symm-error.js","names":[],"sources":["../../src/errors/normalize-symm-error.ts"],"sourcesContent":["import { SymmApiError, SymmError } from \"@symmio/trading-core\";\nimport {\n BaseError,\n ContractFunctionRevertedError,\n EstimateGasExecutionError,\n HttpRequestError,\n InsufficientFundsError,\n TimeoutError,\n TransactionExecutionError,\n UserRejectedRequestError,\n} from \"viem\";\nimport { SymmioRequestError } from \"./symmio-request-error\";\n\n/**\n * Classify any thrown value into a {@link SymmioRequestError}. Hooks call this\n * inside their `queryFn` / `mutationFn` so consumers always see the same\n * discriminated shape, regardless of which viem error type fired underneath.\n *\n * The order of `walk` matters: a wallet-popup dismissal nests inside a\n * `TransactionExecutionError`, so the rejection check has to consider every\n * level of the cause chain, not just the topmost throw.\n *\n * @param err - The thrown value (typed `unknown` because Promises can reject with anything).\n */\nexport function normalizeSymmError(err: unknown): SymmioRequestError {\n if (err instanceof SymmioRequestError) return err;\n\n if (err instanceof SymmApiError) {\n return new SymmioRequestError({\n kind: \"api\",\n message: err.message,\n code: err.code,\n status: err.status,\n responseData: err.responseData,\n retryAfterMs: err.retryAfterMs,\n cause: err,\n });\n }\n\n if (err instanceof SymmError) {\n return new SymmioRequestError({\n kind: \"sdk\",\n message: err.message,\n code: err.code,\n cause: err,\n });\n }\n\n const viemErr = findViemError(err);\n\n if (viemErr) {\n const userRejected = findInCauseChain(viemErr, UserRejectedRequestError);\n if (userRejected) {\n return new SymmioRequestError({\n kind: \"user-rejected\",\n message: userRejected.shortMessage || \"Wallet request was rejected.\",\n cause: err,\n });\n }\n\n const revert = findInCauseChain(viemErr, ContractFunctionRevertedError);\n if (revert) {\n const reason = revert.reason ?? revert.data?.errorName;\n return new SymmioRequestError({\n kind: \"contract-revert\",\n message: revert.shortMessage || `Contract reverted${reason ? `: ${reason}` : \".\"}`,\n reason,\n cause: err,\n });\n }\n\n const insufficient = findInCauseChain(viemErr, InsufficientFundsError);\n if (insufficient) {\n return new SymmioRequestError({\n kind: \"insufficient-funds\",\n message: insufficient.shortMessage || \"Insufficient funds for gas.\",\n cause: err,\n });\n }\n\n const transport =\n findInCauseChain(viemErr, HttpRequestError) ||\n findInCauseChain(viemErr, TimeoutError) ||\n findInCauseChain(viemErr, EstimateGasExecutionError) ||\n findInCauseChain(viemErr, TransactionExecutionError);\n if (transport) {\n return new SymmioRequestError({\n kind: \"rpc\",\n message: transport.shortMessage || transport.message,\n shortMessage: transport.shortMessage,\n cause: err,\n });\n }\n\n return new SymmioRequestError({\n kind: \"rpc\",\n message: viemErr.shortMessage || viemErr.message,\n shortMessage: viemErr.shortMessage,\n cause: err,\n });\n }\n\n if (err instanceof Error) {\n return new SymmioRequestError({ kind: \"unknown\", message: err.message, cause: err });\n }\n\n return new SymmioRequestError({\n kind: \"unknown\",\n message: typeof err === \"string\" ? err : \"An unknown error occurred.\",\n cause: err,\n });\n}\n\n/**\n * Walk an error and its `cause` chain looking for a viem `BaseError`. Returns\n * the first one found, or `undefined`.\n *\n * @internal\n */\nfunction findViemError(err: unknown): BaseError | undefined {\n let current: unknown = err;\n let depth = 0;\n while (current && depth < 16) {\n if (current instanceof BaseError) return current;\n if (current instanceof Error && current.cause) {\n current = current.cause;\n depth += 1;\n continue;\n }\n return undefined;\n }\n return undefined;\n}\n\n/**\n * Walk a viem `BaseError`'s `walk()` chain looking for a specific subclass.\n *\n * @internal\n */\nfunction findInCauseChain<T extends BaseError>(err: BaseError, ctor: new (...args: never[]) => T): T | undefined {\n const found = err.walk((candidate) => candidate instanceof ctor);\n return found instanceof ctor ? (found as T) : undefined;\n}\n"],"mappings":";;;;AAwBA,SAAgB,EAAmB,GAAkC;CACnE,IAAI,aAAe,GAAoB,OAAO;CAE9C,IAAI,aAAe,GACjB,OAAO,IAAI,EAAmB;EAC5B,MAAM;EACN,SAAS,EAAI;EACb,MAAM,EAAI;EACV,QAAQ,EAAI;EACZ,cAAc,EAAI;EAClB,cAAc,EAAI;EAClB,OAAO;CACT,CAAC;CAGH,IAAI,aAAe,GACjB,OAAO,IAAI,EAAmB;EAC5B,MAAM;EACN,SAAS,EAAI;EACb,MAAM,EAAI;EACV,OAAO;CACT,CAAC;CAGH,IAAM,IAAU,EAAc,CAAG;CAEjC,IAAI,GAAS;EACX,IAAM,IAAe,EAAiB,GAAS,CAAwB;EACvE,IAAI,GACF,OAAO,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAa,gBAAgB;GACtC,OAAO;EACT,CAAC;EAGH,IAAM,IAAS,EAAiB,GAAS,CAA6B;EACtE,IAAI,GAAQ;GACV,IAAM,IAAS,EAAO,UAAU,EAAO,MAAM;GAC7C,OAAO,IAAI,EAAmB;IAC5B,MAAM;IACN,SAAS,EAAO,gBAAgB,oBAAoB,IAAS,KAAK,MAAW;IAC7E;IACA,OAAO;GACT,CAAC;EACH;EAEA,IAAM,IAAe,EAAiB,GAAS,CAAsB;EACrE,IAAI,GACF,OAAO,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAa,gBAAgB;GACtC,OAAO;EACT,CAAC;EAGH,IAAM,IACJ,EAAiB,GAAS,CAAgB,KAC1C,EAAiB,GAAS,CAAY,KACtC,EAAiB,GAAS,CAAyB,KACnD,EAAiB,GAAS,CAAyB;EAUrD,OATI,IACK,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAU,gBAAgB,EAAU;GAC7C,cAAc,EAAU;GACxB,OAAO;EACT,CAAC,IAGI,IAAI,EAAmB;GAC5B,MAAM;GACN,SAAS,EAAQ,gBAAgB,EAAQ;GACzC,cAAc,EAAQ;GACtB,OAAO;EACT,CAAC;CACH;CAMA,OAJI,aAAe,QACV,IAAI,EAAmB;EAAE,MAAM;EAAW,SAAS,EAAI;EAAS,OAAO;CAAI,CAAC,IAG9E,IAAI,EAAmB;EAC5B,MAAM;EACN,SAAS,OAAO,KAAQ,WAAW,IAAM;EACzC,OAAO;CACT,CAAC;AACH;AAQA,SAAS,EAAc,GAAqC;CAC1D,IAAI,IAAmB,GACnB,IAAQ;CACZ,OAAO,KAAW,IAAQ,KAAI;EAC5B,IAAI,aAAmB,GAAW,OAAO;EACzC,IAAI,aAAmB,SAAS,EAAQ,OAAO;GAE7C,AADA,IAAU,EAAQ,OAClB,KAAS;GACT;EACF;EACA;CACF;AAEF;AAOA,SAAS,EAAsC,GAAgB,GAAkD;CAC/G,IAAM,IAAQ,EAAI,MAAM,MAAc,aAAqB,CAAI;CAC/D,OAAO,aAAiB,IAAQ,IAAc,KAAA;AAChD"}
@@ -16,6 +16,11 @@ export interface SymmioRequestErrorOptions {
16
16
  * server's structured error fields without unwrapping `cause`.
17
17
  */
18
18
  responseData?: unknown;
19
+ /**
20
+ * Retry delay the server asked for, in ms, from `SymmApiError.retryAfterMs`.
21
+ * Only meaningful when `kind === "api"`. Defaults to `null`.
22
+ */
23
+ retryAfterMs?: number | null;
19
24
  /** Solidity revert reason. Only meaningful when `kind === "contract-revert"`. */
20
25
  reason?: string;
21
26
  /** viem's human-readable short message. Only meaningful when `kind === "rpc"`. */
@@ -45,6 +50,20 @@ export declare class SymmioRequestError extends Error {
45
50
  readonly status?: number;
46
51
  /** Raw response body returned by the server when `kind === "api"`. */
47
52
  readonly responseData?: unknown;
53
+ /**
54
+ * How long the server asked the client to wait before retrying, in ms,
55
+ * parsed from its `Retry-After` header. `normalizeSymmError` sets it only for
56
+ * `kind === "api"`, and even then it is `null` when the response carried no
57
+ * usable header. A cross-origin browser sees the header only when the server
58
+ * exposes it, so treat `null` as "unknown" and still back off, e.g. at least
59
+ * one second plus jitter.
60
+ *
61
+ * @example
62
+ * if (error?.kind === "api" && error.status === 429) {
63
+ * retryIn(error.retryAfterMs ?? 1_000 + Math.random() * 500);
64
+ * }
65
+ */
66
+ readonly retryAfterMs: number | null;
48
67
  /** Solidity revert reason when `kind === "contract-revert"`. */
49
68
  readonly reason?: string;
50
69
  /** viem's short message when `kind === "rpc"`. */
@@ -1 +1 @@
1
- {"version":3,"file":"symmio-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/symmio-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAkB,IAAI,wBAAwB;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEnB,OAAO,EAAE,yBAAyB;CAS/C"}
1
+ {"version":3,"file":"symmio-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/symmio-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,yBAAyB,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAkB,IAAI,wBAAwB;IAC9C,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,qDAAqD;IACrD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAChC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;gBAEnB,OAAO,EAAE,yBAAyB;CAU/C"}
@@ -5,10 +5,11 @@ var e = class extends Error {
5
5
  code;
6
6
  status;
7
7
  responseData;
8
+ retryAfterMs;
8
9
  reason;
9
10
  shortMessage;
10
11
  constructor(e) {
11
- super(e.message, { cause: e.cause }), this.kind = e.kind, this.code = e.code, this.status = e.status, this.responseData = e.responseData, this.reason = e.reason, this.shortMessage = e.shortMessage;
12
+ super(e.message, { cause: e.cause }), this.kind = e.kind, this.code = e.code, this.status = e.status, this.responseData = e.responseData, this.retryAfterMs = e.retryAfterMs ?? null, this.reason = e.reason, this.shortMessage = e.shortMessage;
12
13
  }
13
14
  };
14
15
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"symmio-request-error.js","names":[],"sources":["../../src/errors/symmio-request-error.ts"],"sourcesContent":["import type { SymmioNormalizedErrorKind } from \"./types\";\n\n/**\n * Options accepted by the {@link SymmioRequestError} constructor. Carries\n * the discriminator-specific fields the UI cares about.\n */\nexport interface SymmioRequestErrorOptions {\n kind: SymmioNormalizedErrorKind;\n message: string;\n /** SDK error code (e.g., \"FETCH_MARKETS_FAILED\", \"UNSUPPORTED_CHAIN\"). */\n code?: string;\n /** HTTP status code. Only meaningful when `kind === \"api\"`. */\n status?: number;\n /**\n * Raw response body returned by the server. Only meaningful when `kind === \"api\"`.\n * Forwarded verbatim from `SymmApiError.responseData` so the UI can render the\n * server's structured error fields without unwrapping `cause`.\n */\n responseData?: unknown;\n /** Solidity revert reason. Only meaningful when `kind === \"contract-revert\"`. */\n reason?: string;\n /** viem's human-readable short message. Only meaningful when `kind === \"rpc\"`. */\n shortMessage?: string;\n /** The original underlying error, kept for debugging. */\n cause?: unknown;\n}\n\n/**\n * The single error class every SYMMIO React hook throws when a read or write\n * fails. Carries a discriminator (`kind`) the UI can switch on without\n * inspecting viem's internal error hierarchy.\n *\n * @example\n * const { error } = useUserSubAccounts({ user });\n * if (error?.kind === \"user-rejected\") return null; // silent\n * if (error?.kind === \"contract-revert\") return <ShowReason reason={error.reason} />;\n * if (error?.kind === \"api\") return <ApiError status={error.status} code={error.code} />;\n * if (error) return <GenericError message={error.message} />;\n */\nexport class SymmioRequestError extends Error {\n override readonly name = \"SymmioRequestError\";\n /** Classification used by the UI to branch on this failure. */\n readonly kind: SymmioNormalizedErrorKind;\n /** SDK error code (e.g., \"FETCH_MARKETS_FAILED\"). */\n readonly code?: string;\n /** HTTP status code when `kind === \"api\"`. */\n readonly status?: number;\n /** Raw response body returned by the server when `kind === \"api\"`. */\n readonly responseData?: unknown;\n /** Solidity revert reason when `kind === \"contract-revert\"`. */\n readonly reason?: string;\n /** viem's short message when `kind === \"rpc\"`. */\n readonly shortMessage?: string;\n\n constructor(options: SymmioRequestErrorOptions) {\n super(options.message, { cause: options.cause });\n this.kind = options.kind;\n this.code = options.code;\n this.status = options.status;\n this.responseData = options.responseData;\n this.reason = options.reason;\n this.shortMessage = options.shortMessage;\n }\n}\n"],"mappings":";AAuCA,IAAa,IAAb,cAAwC,MAAM;CAC5C,OAAyB;CAEzB;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAY,GAAoC;EAO9C,AANA,MAAM,EAAQ,SAAS,EAAE,OAAO,EAAQ,MAAM,CAAC,GAC/C,KAAK,OAAO,EAAQ,MACpB,KAAK,OAAO,EAAQ,MACpB,KAAK,SAAS,EAAQ,QACtB,KAAK,eAAe,EAAQ,cAC5B,KAAK,SAAS,EAAQ,QACtB,KAAK,eAAe,EAAQ;CAC9B;AACF"}
1
+ {"version":3,"file":"symmio-request-error.js","names":[],"sources":["../../src/errors/symmio-request-error.ts"],"sourcesContent":["import type { SymmioNormalizedErrorKind } from \"./types\";\n\n/**\n * Options accepted by the {@link SymmioRequestError} constructor. Carries\n * the discriminator-specific fields the UI cares about.\n */\nexport interface SymmioRequestErrorOptions {\n kind: SymmioNormalizedErrorKind;\n message: string;\n /** SDK error code (e.g., \"FETCH_MARKETS_FAILED\", \"UNSUPPORTED_CHAIN\"). */\n code?: string;\n /** HTTP status code. Only meaningful when `kind === \"api\"`. */\n status?: number;\n /**\n * Raw response body returned by the server. Only meaningful when `kind === \"api\"`.\n * Forwarded verbatim from `SymmApiError.responseData` so the UI can render the\n * server's structured error fields without unwrapping `cause`.\n */\n responseData?: unknown;\n /**\n * Retry delay the server asked for, in ms, from `SymmApiError.retryAfterMs`.\n * Only meaningful when `kind === \"api\"`. Defaults to `null`.\n */\n retryAfterMs?: number | null;\n /** Solidity revert reason. Only meaningful when `kind === \"contract-revert\"`. */\n reason?: string;\n /** viem's human-readable short message. Only meaningful when `kind === \"rpc\"`. */\n shortMessage?: string;\n /** The original underlying error, kept for debugging. */\n cause?: unknown;\n}\n\n/**\n * The single error class every SYMMIO React hook throws when a read or write\n * fails. Carries a discriminator (`kind`) the UI can switch on without\n * inspecting viem's internal error hierarchy.\n *\n * @example\n * const { error } = useUserSubAccounts({ user });\n * if (error?.kind === \"user-rejected\") return null; // silent\n * if (error?.kind === \"contract-revert\") return <ShowReason reason={error.reason} />;\n * if (error?.kind === \"api\") return <ApiError status={error.status} code={error.code} />;\n * if (error) return <GenericError message={error.message} />;\n */\nexport class SymmioRequestError extends Error {\n override readonly name = \"SymmioRequestError\";\n /** Classification used by the UI to branch on this failure. */\n readonly kind: SymmioNormalizedErrorKind;\n /** SDK error code (e.g., \"FETCH_MARKETS_FAILED\"). */\n readonly code?: string;\n /** HTTP status code when `kind === \"api\"`. */\n readonly status?: number;\n /** Raw response body returned by the server when `kind === \"api\"`. */\n readonly responseData?: unknown;\n /**\n * How long the server asked the client to wait before retrying, in ms,\n * parsed from its `Retry-After` header. `normalizeSymmError` sets it only for\n * `kind === \"api\"`, and even then it is `null` when the response carried no\n * usable header. A cross-origin browser sees the header only when the server\n * exposes it, so treat `null` as \"unknown\" and still back off, e.g. at least\n * one second plus jitter.\n *\n * @example\n * if (error?.kind === \"api\" && error.status === 429) {\n * retryIn(error.retryAfterMs ?? 1_000 + Math.random() * 500);\n * }\n */\n readonly retryAfterMs: number | null;\n /** Solidity revert reason when `kind === \"contract-revert\"`. */\n readonly reason?: string;\n /** viem's short message when `kind === \"rpc\"`. */\n readonly shortMessage?: string;\n\n constructor(options: SymmioRequestErrorOptions) {\n super(options.message, { cause: options.cause });\n this.kind = options.kind;\n this.code = options.code;\n this.status = options.status;\n this.responseData = options.responseData;\n this.retryAfterMs = options.retryAfterMs ?? null;\n this.reason = options.reason;\n this.shortMessage = options.shortMessage;\n }\n}\n"],"mappings":";AA4CA,IAAa,IAAb,cAAwC,MAAM;CAC5C,OAAyB;CAEzB;CAEA;CAEA;CAEA;CAcA;CAEA;CAEA;CAEA,YAAY,GAAoC;EAQ9C,AAPA,MAAM,EAAQ,SAAS,EAAE,OAAO,EAAQ,MAAM,CAAC,GAC/C,KAAK,OAAO,EAAQ,MACpB,KAAK,OAAO,EAAQ,MACpB,KAAK,SAAS,EAAQ,QACtB,KAAK,eAAe,EAAQ,cAC5B,KAAK,eAAe,EAAQ,gBAAgB,MAC5C,KAAK,SAAS,EAAQ,QACtB,KAAK,eAAe,EAAQ;CAC9B;AACF"}
@@ -0,0 +1,115 @@
1
+ import { ConfigParameter, GaslessAcceptedRequest, GaslessConfirmation, GaslessConfirmedRequest, GaslessRequest, GaslessRequestStatus } from '@symmio/trading-core';
2
+ import { Hash } from 'viem';
3
+ import { SymmioRequestError } from '../errors/symmio-request-error.js';
4
+ /**
5
+ * Confirmation options shared by every explicit relay hook — the gasless
6
+ * analogue of `WriteParameters`.
7
+ *
8
+ * A relayed submit returns a `202` in milliseconds while the transaction lands
9
+ * seconds later, so a mutation that resolves on acceptance resolves before its
10
+ * own effect exists. These options decide how far the hook follows the request
11
+ * before calling it done.
12
+ */
13
+ export interface GaslessRelayParameters extends ConfigParameter {
14
+ /**
15
+ * How far to confirm before resolving. Default `"receipt"`.
16
+ *
17
+ * `"receipt"` waits for the receipt on *this config's* client, which is what
18
+ * makes the invalidation that follows truthful — refetching against a node
19
+ * that has not seen the block re-reads pre-state. `"terminal"` trusts the
20
+ * relayer's view; `"none"` restores fire-and-forget, and hands you the
21
+ * lifecycle and the invalidation.
22
+ */
23
+ confirmation?: GaslessConfirmation;
24
+ /** Confirmations for the receipt wait. Default `1`. Only for `confirmation: "receipt"`. */
25
+ receiptConfirmations?: number;
26
+ /** Budget for the terminal wait. Defaults to the SDK's `GASLESS_WAIT_TIMEOUT_MS`. */
27
+ timeoutMs?: number;
28
+ /** Budget for the receipt wait. Defaults to the SDK's `GASLESS_RECEIPT_TIMEOUT_MS`. */
29
+ receiptTimeoutMs?: number;
30
+ /**
31
+ * Abort the wait when the hook unmounts. Default `true`.
32
+ *
33
+ * TanStack mutations do not cancel on unmount, so this is a deliberate
34
+ * deviation — right for a modal that closes, wrong when you want the wait to
35
+ * finish so the cache refreshes for the rest of the app. Either way the
36
+ * invalidation still runs if a `succeeded` terminal was observed before the
37
+ * abort.
38
+ */
39
+ abortOnUnmount?: boolean;
40
+ /** Observer for every polled record — the imperative form of {@link GaslessRelayProgress}. */
41
+ onProgress?: (request: GaslessRequest) => void;
42
+ /**
43
+ * Observer invoked the moment the service accepts the request — before any
44
+ * confirmation, and before the `confirmation: "none"` early return.
45
+ *
46
+ * This is the persistence hook. There is no list-by-wallet endpoint, so a
47
+ * request id that never left memory is unrecoverable: a reload, a crash or a
48
+ * closed tab loses the only handle on a workflow that keeps running and will
49
+ * spend the user's collateral. Persist `{ service, protocolInstance,
50
+ * requestId, owner, walletIds, idempotencyKey }` here, not in `onSuccess`,
51
+ * which does not run until the relay has landed — or never, if the wait
52
+ * times out.
53
+ *
54
+ * Its own failures are swallowed: a broken observer must not fail a relay
55
+ * that the service has already accepted.
56
+ */
57
+ onAccepted?: (accepted: GaslessAcceptedRequest) => void;
58
+ }
59
+ /**
60
+ * What a confirmed relay hook resolves with.
61
+ *
62
+ * `accepted` stays nested rather than merged: `GaslessSubmitReceipt.status` is
63
+ * the *acceptance* status (normally `queued`) while `GaslessRequest.status` is
64
+ * the *terminal* one, and flattening them would put a field named `status`
65
+ * holding "queued" on a result that means success.
66
+ */
67
+ export interface GaslessRelayResult<accepted> {
68
+ /** The `202` acceptance. Its `status` is never success. */
69
+ accepted: accepted;
70
+ /** The confirmation. Absent only when `confirmation: "none"`. */
71
+ confirmed?: GaslessConfirmedRequest;
72
+ }
73
+ /**
74
+ * Where a relay is, merged onto the mutation result as `relay`.
75
+ *
76
+ * A confirmed mutation stays pending for as long as the relayer takes, so
77
+ * `isPending` alone cannot tell a user whether anything is happening. This
78
+ * exposes the lifecycle without making every consumer mount a second hook.
79
+ */
80
+ export interface GaslessRelayProgress {
81
+ /**
82
+ * Coarse phase, suitable for driving a label or a spinner.
83
+ *
84
+ * `"unconfirmed"` is the one that needs a deliberate UI: the wait ran out of
85
+ * budget, so the relay's outcome is **unknown**, not failed. The request is
86
+ * still running server-side — show the request id and keep watching it (the
87
+ * mutation itself still rejects, because it cannot report a result it does not
88
+ * have). Never re-run the intent through the wallet from this phase.
89
+ */
90
+ phase: "idle" | "submitting" | "queued" | "submitted" | "awaiting-receipt" | "confirmed" | "unconfirmed" | "error";
91
+ /** Present from acceptance onward — persist it; a lost id is unrecoverable. */
92
+ requestId?: string;
93
+ /**
94
+ * The idempotency key the request was submitted with, from acceptance onward.
95
+ * Persist it with the id: resending the byte-identical request under this key
96
+ * is what makes a lost response recoverable.
97
+ */
98
+ idempotencyKey?: string;
99
+ /** The relayer's last reported status. */
100
+ status?: GaslessRequestStatus;
101
+ /** Present once the relayer broadcasts. */
102
+ txHash?: Hash;
103
+ /**
104
+ * Whether the status is currently unreadable — a `429`, a `503`, a dropped
105
+ * connection. The workflow is unaffected; only our view of it is stale, so
106
+ * render "status unavailable" rather than anything that reads as a failure.
107
+ * Clears as soon as a read succeeds.
108
+ */
109
+ degraded: boolean;
110
+ /** The last transient read failure, while `degraded` — for diagnostics, never for a retry decision. */
111
+ issue?: SymmioRequestError;
112
+ }
113
+ /** The initial, nothing-in-flight progress value. */
114
+ export declare const IDLE_RELAY_PROGRESS: GaslessRelayProgress;
115
+ //# sourceMappingURL=gasless-relay-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasless-relay-types.d.ts","sourceRoot":"","sources":["../../src/gasless/gasless-relay-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,WAAW,sBAAuB,SAAQ,eAAe;IAC7D;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,2FAA2F;IAC3F,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/C;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACzD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB,CAAC,QAAQ;IAC1C,2DAA2D;IAC3D,QAAQ,EAAE,QAAQ,CAAC;IACnB,iEAAiE;IACjE,SAAS,CAAC,EAAE,uBAAuB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,GAAG,kBAAkB,GAAG,WAAW,GAAG,aAAa,GAAG,OAAO,CAAC;IACnH,+EAA+E;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,uGAAuG;IACvG,KAAK,CAAC,EAAE,kBAAkB,CAAC;CAC5B;AAED,qDAAqD;AACrD,eAAO,MAAM,mBAAmB,EAAE,oBAAyD,CAAC"}
@@ -0,0 +1,9 @@
1
+ //#region src/gasless/gasless-relay-types.ts
2
+ var e = {
3
+ phase: "idle",
4
+ degraded: !1
5
+ };
6
+ //#endregion
7
+ export { e as IDLE_RELAY_PROGRESS };
8
+
9
+ //# sourceMappingURL=gasless-relay-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gasless-relay-types.js","names":[],"sources":["../../src/gasless/gasless-relay-types.ts"],"sourcesContent":["import type {\n ConfigParameter,\n GaslessAcceptedRequest,\n GaslessConfirmation,\n GaslessConfirmedRequest,\n GaslessRequest,\n GaslessRequestStatus,\n} from \"@symmio/trading-core\";\nimport type { Hash } from \"viem\";\nimport type { SymmioRequestError } from \"../errors/symmio-request-error\";\n\n/**\n * Confirmation options shared by every explicit relay hook — the gasless\n * analogue of `WriteParameters`.\n *\n * A relayed submit returns a `202` in milliseconds while the transaction lands\n * seconds later, so a mutation that resolves on acceptance resolves before its\n * own effect exists. These options decide how far the hook follows the request\n * before calling it done.\n */\nexport interface GaslessRelayParameters extends ConfigParameter {\n /**\n * How far to confirm before resolving. Default `\"receipt\"`.\n *\n * `\"receipt\"` waits for the receipt on *this config's* client, which is what\n * makes the invalidation that follows truthful — refetching against a node\n * that has not seen the block re-reads pre-state. `\"terminal\"` trusts the\n * relayer's view; `\"none\"` restores fire-and-forget, and hands you the\n * lifecycle and the invalidation.\n */\n confirmation?: GaslessConfirmation;\n /** Confirmations for the receipt wait. Default `1`. Only for `confirmation: \"receipt\"`. */\n receiptConfirmations?: number;\n /** Budget for the terminal wait. Defaults to the SDK's `GASLESS_WAIT_TIMEOUT_MS`. */\n timeoutMs?: number;\n /** Budget for the receipt wait. Defaults to the SDK's `GASLESS_RECEIPT_TIMEOUT_MS`. */\n receiptTimeoutMs?: number;\n /**\n * Abort the wait when the hook unmounts. Default `true`.\n *\n * TanStack mutations do not cancel on unmount, so this is a deliberate\n * deviation — right for a modal that closes, wrong when you want the wait to\n * finish so the cache refreshes for the rest of the app. Either way the\n * invalidation still runs if a `succeeded` terminal was observed before the\n * abort.\n */\n abortOnUnmount?: boolean;\n /** Observer for every polled record — the imperative form of {@link GaslessRelayProgress}. */\n onProgress?: (request: GaslessRequest) => void;\n /**\n * Observer invoked the moment the service accepts the request — before any\n * confirmation, and before the `confirmation: \"none\"` early return.\n *\n * This is the persistence hook. There is no list-by-wallet endpoint, so a\n * request id that never left memory is unrecoverable: a reload, a crash or a\n * closed tab loses the only handle on a workflow that keeps running and will\n * spend the user's collateral. Persist `{ service, protocolInstance,\n * requestId, owner, walletIds, idempotencyKey }` here, not in `onSuccess`,\n * which does not run until the relay has landed — or never, if the wait\n * times out.\n *\n * Its own failures are swallowed: a broken observer must not fail a relay\n * that the service has already accepted.\n */\n onAccepted?: (accepted: GaslessAcceptedRequest) => void;\n}\n\n/**\n * What a confirmed relay hook resolves with.\n *\n * `accepted` stays nested rather than merged: `GaslessSubmitReceipt.status` is\n * the *acceptance* status (normally `queued`) while `GaslessRequest.status` is\n * the *terminal* one, and flattening them would put a field named `status`\n * holding \"queued\" on a result that means success.\n */\nexport interface GaslessRelayResult<accepted> {\n /** The `202` acceptance. Its `status` is never success. */\n accepted: accepted;\n /** The confirmation. Absent only when `confirmation: \"none\"`. */\n confirmed?: GaslessConfirmedRequest;\n}\n\n/**\n * Where a relay is, merged onto the mutation result as `relay`.\n *\n * A confirmed mutation stays pending for as long as the relayer takes, so\n * `isPending` alone cannot tell a user whether anything is happening. This\n * exposes the lifecycle without making every consumer mount a second hook.\n */\nexport interface GaslessRelayProgress {\n /**\n * Coarse phase, suitable for driving a label or a spinner.\n *\n * `\"unconfirmed\"` is the one that needs a deliberate UI: the wait ran out of\n * budget, so the relay's outcome is **unknown**, not failed. The request is\n * still running server-side — show the request id and keep watching it (the\n * mutation itself still rejects, because it cannot report a result it does not\n * have). Never re-run the intent through the wallet from this phase.\n */\n phase: \"idle\" | \"submitting\" | \"queued\" | \"submitted\" | \"awaiting-receipt\" | \"confirmed\" | \"unconfirmed\" | \"error\";\n /** Present from acceptance onward — persist it; a lost id is unrecoverable. */\n requestId?: string;\n /**\n * The idempotency key the request was submitted with, from acceptance onward.\n * Persist it with the id: resending the byte-identical request under this key\n * is what makes a lost response recoverable.\n */\n idempotencyKey?: string;\n /** The relayer's last reported status. */\n status?: GaslessRequestStatus;\n /** Present once the relayer broadcasts. */\n txHash?: Hash;\n /**\n * Whether the status is currently unreadable — a `429`, a `503`, a dropped\n * connection. The workflow is unaffected; only our view of it is stale, so\n * render \"status unavailable\" rather than anything that reads as a failure.\n * Clears as soon as a read succeeds.\n */\n degraded: boolean;\n /** The last transient read failure, while `degraded` — for diagnostics, never for a retry decision. */\n issue?: SymmioRequestError;\n}\n\n/** The initial, nothing-in-flight progress value. */\nexport const IDLE_RELAY_PROGRESS: GaslessRelayProgress = { phase: \"idle\", degraded: false };\n"],"mappings":";AA4HA,IAAa,IAA4C;CAAE,OAAO;CAAQ,UAAU;AAAM"}
@@ -0,0 +1,21 @@
1
+ export * from './gasless-relay-types.js';
2
+ export * from './use-approve-operational-fee.js';
3
+ export * from './use-gasless-batch-fee-quote.js';
4
+ export * from './use-gasless-deposit-policy.js';
5
+ export * from './use-gasless-fee-quote.js';
6
+ export * from './use-gasless-request.js';
7
+ export * from './use-gasless-request-stream.js';
8
+ export * from './use-gasless-request-transactions.js';
9
+ export * from './use-gasless-wallet-address.js';
10
+ export * from './use-gasless-wallet-creation-fee.js';
11
+ export * from './use-gasless-wallet-execute.js';
12
+ export * from './use-gasless-wallet-execute-selectors.js';
13
+ export * from './use-gasless-wallet-nonce.js';
14
+ export * from './use-operational-fee-allowance.js';
15
+ export * from './use-relay-gasless-batch.js';
16
+ export * from './use-relay-instant-operations.js';
17
+ export * from './use-resubmit-gasless-request.js';
18
+ export * from './use-settle-gasless-deposit-existing-account.js';
19
+ export * from './use-settle-gasless-deposit-new-account.js';
20
+ export * from './use-supports-gasless-service.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/gasless/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,cAAc,gCAAgC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { IDLE_RELAY_PROGRESS as e } from "./gasless-relay-types.js";
2
+ import { useApproveOperationalFee as t } from "./use-approve-operational-fee.js";
3
+ import { useGaslessBatchFeeQuote as n } from "./use-gasless-batch-fee-quote.js";
4
+ import { useGaslessDepositPolicy as r } from "./use-gasless-deposit-policy.js";
5
+ import { useGaslessFeeQuote as i } from "./use-gasless-fee-quote.js";
6
+ import { useGaslessRequestStream as a } from "./use-gasless-request-stream.js";
7
+ import { useGaslessRequest as o } from "./use-gasless-request.js";
8
+ import { useGaslessRequestTransactions as s } from "./use-gasless-request-transactions.js";
9
+ import { useGaslessWalletAddress as c } from "./use-gasless-wallet-address.js";
10
+ import { useGaslessWalletCreationFee as l } from "./use-gasless-wallet-creation-fee.js";
11
+ import { useGaslessWalletExecute as u } from "./use-gasless-wallet-execute.js";
12
+ import { useGaslessWalletExecuteSelectors as d } from "./use-gasless-wallet-execute-selectors.js";
13
+ import { useGaslessWalletNonce as f } from "./use-gasless-wallet-nonce.js";
14
+ import { useOperationalFeeAllowance as p } from "./use-operational-fee-allowance.js";
15
+ import { useRelayGaslessBatch as m } from "./use-relay-gasless-batch.js";
16
+ import { useRelayInstantOperations as h } from "./use-relay-instant-operations.js";
17
+ import { useResubmitGaslessRequest as g } from "./use-resubmit-gasless-request.js";
18
+ import { useSettleGaslessDepositExistingAccount as _ } from "./use-settle-gasless-deposit-existing-account.js";
19
+ import { useSettleGaslessDepositNewAccount as v } from "./use-settle-gasless-deposit-new-account.js";
20
+ import { useSupportsGaslessService as y } from "./use-supports-gasless-service.js";
21
+ export { e as IDLE_RELAY_PROGRESS, t as useApproveOperationalFee, n as useGaslessBatchFeeQuote, r as useGaslessDepositPolicy, i as useGaslessFeeQuote, o as useGaslessRequest, a as useGaslessRequestStream, s as useGaslessRequestTransactions, c as useGaslessWalletAddress, l as useGaslessWalletCreationFee, u as useGaslessWalletExecute, d as useGaslessWalletExecuteSelectors, f as useGaslessWalletNonce, p as useOperationalFeeAllowance, m as useRelayGaslessBatch, h as useRelayInstantOperations, g as useResubmitGaslessRequest, _ as useSettleGaslessDepositExistingAccount, v as useSettleGaslessDepositNewAccount, y as useSupportsGaslessService };
@@ -0,0 +1,96 @@
1
+ import { GaslessBatchCall } from '@symmio/trading-core';
2
+ import { QueryClient } from '@tanstack/react-query';
3
+ import { Address } from 'viem';
4
+ /** Chain-config fingerprint every invalidation is scoped by. */
5
+ interface Scope {
6
+ configKey?: string;
7
+ }
8
+ /**
9
+ * The GaslessWallet a relayed action touched, as far as its variables say.
10
+ * Every omitted field matches all of its values — a superset is correct, a
11
+ * silent no-op is not.
12
+ */
13
+ interface GaslessWalletScope {
14
+ /** The wallet's owner. */
15
+ owner?: Address;
16
+ /**
17
+ * The wallet's id. `useGaslessWalletExecute` forwards its variables whole, so
18
+ * its `walletId` narrows the invalidation on its own; the settlement hooks
19
+ * take theirs from the acceptance receipt, which is the id the service
20
+ * actually settled. Omitted, every id of the owner matches.
21
+ */
22
+ walletId?: bigint;
23
+ }
24
+ /**
25
+ * Invalidate the reads a relayed InstantLayer batch changed.
26
+ *
27
+ * Only transport-level facts: `operationType` is a free-form label the fee
28
+ * policy ignores, so the SDK cannot know which domain reads a batch touched and
29
+ * must not guess. Callers who know the operation pass their own `onSuccess` to
30
+ * `mutate`, which now runs after confirmation.
31
+ *
32
+ * @internal
33
+ */
34
+ export declare function invalidateRelayInstantOperationsReads(queryClient: QueryClient, scope: Scope, signerAccounts: readonly Address[]): void;
35
+ /**
36
+ * Invalidate the reads a relayed gasless-wallet `execute` changed.
37
+ *
38
+ * The wallet-operation nonce is keyed by `(owner, walletId, signerAccount)`,
39
+ * and the operation consumed it under its signer account — which defaults to
40
+ * the owner. The wallet's own collateral balance moves, and its address is
41
+ * derived rather than passed, so the collateral read is invalidated chain-wide.
42
+ * The operation may also have deployed the wallet, which zeroes its creation fee.
43
+ *
44
+ * @param wallet - The action's variables, forwarded whole: `owner`, `signerAccount` and `walletId`
45
+ * scope the invalidation, and each omitted one matches every value.
46
+ *
47
+ * @internal
48
+ */
49
+ export declare function invalidateGaslessWalletExecuteReads(queryClient: QueryClient, scope: Scope, wallet: GaslessWalletScope & {
50
+ signerAccount?: Address;
51
+ }): void;
52
+ /**
53
+ * Invalidate the reads a relayed gasless batch changed.
54
+ *
55
+ * Unlike an opaque `relayInstantOperations` batch, every call of a gasless
56
+ * batch is a known relayable write (the SDK refuses anything else), so its
57
+ * selectors say exactly which domains moved. Each domain's reads are
58
+ * invalidated chain-wide — the calls' own arguments name the rows, but a
59
+ * superset is correct and a silent no-op is not.
60
+ *
61
+ * Always: the account's InstantLayer nonce, fee allowances and balances. Per
62
+ * GaslessWallet entry: that wallet's nonce, collateral and deployment reads.
63
+ *
64
+ * @param batch - The batch's variables: its `account` and `calls`.
65
+ *
66
+ * @internal
67
+ */
68
+ export declare function invalidateGaslessBatchReads(queryClient: QueryClient, scope: Scope, batch: {
69
+ account: Address;
70
+ calls: readonly GaslessBatchCall[];
71
+ }): void;
72
+ /**
73
+ * Invalidate the reads a deposit settlement changed.
74
+ *
75
+ * The deposit address is swept to zero, so its collateral balance is
76
+ * invalidated precisely when the acceptance receipt carries it. The settlement
77
+ * deploys the wallet on its first use, which zeroes the wallet's creation fee
78
+ * and lowers its deposit policy's `settlementMinimum`, so both are invalidated
79
+ * for the owner's wallet.
80
+ *
81
+ * `depositAddress` arrives as the vendor's raw string, so a value that is not a
82
+ * well-formed address widens to a chain-wide collateral invalidation rather
83
+ * than scoping to nothing — a superset is correct, a silent no-op is not.
84
+ *
85
+ * @param options.owner - The settled wallet's owner.
86
+ * @param options.newAccount - `true` for a new-account settlement, which also
87
+ * refreshes the owner's sub-account lists; omit for a top-up into an existing account.
88
+ *
89
+ * @internal
90
+ */
91
+ export declare function invalidateDepositSettlementReads(queryClient: QueryClient, scope: Scope, options: GaslessWalletScope & {
92
+ depositAddress?: string;
93
+ newAccount?: boolean;
94
+ }): void;
95
+ export {};
96
+ //# sourceMappingURL=invalidate-relay-reads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invalidate-relay-reads.d.ts","sourceRoot":"","sources":["../../src/gasless/invalidate-relay-reads.ts"],"names":[],"mappings":"AAAA,OAAO,EA2BL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAA6D,KAAK,OAAO,EAAY,MAAM,MAAM,CAAC;AAIzG,gEAAgE;AAChE,UAAU,KAAK;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,UAAU,kBAAkB;IAC1B,0BAA0B;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA4CD;;;;;;;;;GASG;AACH,wBAAgB,qCAAqC,CACnD,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,SAAS,OAAO,EAAE,GACjC,IAAI,CAWN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,kBAAkB,GAAG;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GACvD,IAAI,CAYN;AAyCD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAAE,GAC9D,IAAI,CA0DN;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gCAAgC,CAC9C,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,kBAAkB,GAAG;IAAE,cAAc,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9E,IAAI,CAcN"}
@@ -0,0 +1,107 @@
1
+ import { predicateMatch as e } from "../utils/predicate-match.js";
2
+ import { invalidateAccountBalances as t } from "../utils/invalidate-account-balances.js";
3
+ import { accountLayerAbi as n, getCollateralAllowanceQueryKey as r, getCollateralBalanceQueryKey as i, getDelegationExpiryQueryKey as a, getGaslessBatchSelectors as o, getGaslessDepositPolicyQueryKey as s, getGaslessWalletCreationFeeQueryKey as c, getGaslessWalletNonceQueryKey as l, getInstantLayerNonceQueryKey as u, getIsDelegationActiveQueryKey as d, getLastWithdrawRequestIdQueryKey as f, getOperationalFeeAllowanceQueryKey as p, getPartyAOpenPositionsQueryKey as m, getPartyAPendingQuotesQueryKey as h, getPendingQuotesQueryKey as g, getPendingWithdrawRequestsQueryKey as _, getQuotePendingFundingQueryKey as v, getQuoteQueryKey as y, getSubAccountQueryKey as b, getSubAccountsCountOfUserQueryKey as x, getUserSubAccountsAddressesQueryKey as S, getUserSubAccountsQueryKey as C, getWithdrawRequestsQueryKey as w, getWithdrawableTimeQueryKey as T, instantLayerAbi as E, symmioAbi as D } from "@symmio/trading-core";
4
+ import { isAddress as O, toFunctionSelector as k } from "viem";
5
+ //#region src/gasless/invalidate-relay-reads.ts
6
+ function A(n, r, i) {
7
+ t(n, r), n.invalidateQueries({ predicate: e(p, {
8
+ ...r,
9
+ payer: i
10
+ }) });
11
+ }
12
+ function j(t, n, r) {
13
+ let i = {
14
+ ...n,
15
+ owner: r.owner,
16
+ walletId: r.walletId
17
+ };
18
+ t.invalidateQueries({ predicate: e(s, i) }), t.invalidateQueries({ predicate: e(c, i) });
19
+ }
20
+ function M(n, r, i) {
21
+ let a = [...new Set(i)];
22
+ for (let t of a) n.invalidateQueries({ predicate: e(u, {
23
+ ...r,
24
+ account: t
25
+ }) }), n.invalidateQueries({ predicate: e(p, {
26
+ ...r,
27
+ payer: t
28
+ }) });
29
+ t(n, r);
30
+ }
31
+ function N(t, n, r) {
32
+ t.invalidateQueries({ predicate: e(l, {
33
+ ...n,
34
+ owner: r.owner,
35
+ walletId: r.walletId,
36
+ account: r.signerAccount ?? r.owner
37
+ }) }), t.invalidateQueries({ predicate: e(i, n) }), j(t, n, r), A(t, n);
38
+ }
39
+ function P(e, t) {
40
+ let n = e.find((e) => e.type === "function" && e.name === t);
41
+ if (!n) throw Error(`invalidate-relay-reads: the shipped ABI has no function "${t}".`);
42
+ return k(n);
43
+ }
44
+ var F = new Set([
45
+ P(D, "initiateWithdraw"),
46
+ P(D, "requestCancelWithdraw"),
47
+ P(D, "finalizeWithdrawRequest")
48
+ ]), I = new Set([
49
+ P(D, "requestToCancelQuote"),
50
+ P(D, "requestToCancelCloseRequest"),
51
+ P(D, "forceCancelQuote"),
52
+ P(D, "forceCancelCloseRequest"),
53
+ P(D, "forceClosePosition")
54
+ ]), L = new Set([
55
+ P(n, "createSubAccounts"),
56
+ P(n, "deleteSubAccount"),
57
+ P(n, "editAccountName")
58
+ ]), R = new Set([P(n, "depositForAccount"), P(n, "depositAndAllocateForAccount")]), z = P(E, "grantDelegation");
59
+ function B(t, n, s) {
60
+ let c = new Set(o(s.calls)), l = (e) => [...e].some((e) => c.has(e));
61
+ t.invalidateQueries({ predicate: e(u, {
62
+ ...n,
63
+ account: s.account
64
+ }) }), A(t, n);
65
+ for (let e of s.calls) "walletCalls" in e && N(t, n, {
66
+ walletId: e.walletId ?? 0n,
67
+ signerAccount: s.account
68
+ });
69
+ if (l(F)) for (let r of [
70
+ _,
71
+ f,
72
+ T,
73
+ w
74
+ ]) t.invalidateQueries({ predicate: e(r, n) });
75
+ if (l(I)) for (let r of [
76
+ h,
77
+ g,
78
+ y,
79
+ m,
80
+ v
81
+ ]) t.invalidateQueries({ predicate: e(r, n) });
82
+ if (l(L)) for (let r of [
83
+ C,
84
+ S,
85
+ x,
86
+ b
87
+ ]) t.invalidateQueries({ predicate: e(r, n) });
88
+ l(R) && (t.invalidateQueries({ predicate: e(i, n) }), t.invalidateQueries({ predicate: e(r, n) })), c.has(z) && (t.invalidateQueries({ predicate: e(d, n) }), t.invalidateQueries({ predicate: e(a, n) }));
89
+ }
90
+ function V(n, r, a) {
91
+ let o = a.depositAddress && O(a.depositAddress) ? a.depositAddress : void 0;
92
+ if (n.invalidateQueries({ predicate: e(i, {
93
+ ...r,
94
+ owner: o
95
+ }) }), a.newAccount && a.owner) {
96
+ let t = {
97
+ ...r,
98
+ user: a.owner
99
+ };
100
+ n.invalidateQueries({ predicate: e(C, t) }), n.invalidateQueries({ predicate: e(S, t) }), n.invalidateQueries({ predicate: e(x, t) });
101
+ }
102
+ j(n, r, a), t(n, r);
103
+ }
104
+ //#endregion
105
+ export { V as invalidateDepositSettlementReads, B as invalidateGaslessBatchReads, N as invalidateGaslessWalletExecuteReads, M as invalidateRelayInstantOperationsReads };
106
+
107
+ //# sourceMappingURL=invalidate-relay-reads.js.map