@symmio/trading-core 4.3.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (693) hide show
  1. package/dist/candles/adapters/tradingview/map-resolution.d.ts.map +1 -1
  2. package/dist/candles/adapters/tradingview/map-resolution.js +2 -0
  3. package/dist/candles/adapters/tradingview/map-resolution.js.map +1 -1
  4. package/dist/candles/adapters/tradingview/to-tradingview-datafeed.d.ts.map +1 -1
  5. package/dist/candles/adapters/tradingview/to-tradingview-datafeed.js +6 -4
  6. package/dist/candles/adapters/tradingview/to-tradingview-datafeed.js.map +1 -1
  7. package/dist/candles/history-query.d.ts +67 -0
  8. package/dist/candles/history-query.d.ts.map +1 -0
  9. package/dist/candles/history-query.js +80 -0
  10. package/dist/candles/history-query.js.map +1 -0
  11. package/dist/candles/index.d.ts +3 -0
  12. package/dist/candles/index.d.ts.map +1 -1
  13. package/dist/candles/merge-candle-pages.d.ts +5 -0
  14. package/dist/candles/merge-candle-pages.d.ts.map +1 -0
  15. package/dist/candles/merge-candle-pages.js +13 -0
  16. package/dist/candles/merge-candle-pages.js.map +1 -0
  17. package/dist/candles/query.d.ts +5 -1
  18. package/dist/candles/query.d.ts.map +1 -1
  19. package/dist/candles/query.js +3 -2
  20. package/dist/candles/query.js.map +1 -1
  21. package/dist/candles/refresh-candle-history.d.ts +31 -0
  22. package/dist/candles/refresh-candle-history.d.ts.map +1 -0
  23. package/dist/candles/refresh-candle-history.js +91 -0
  24. package/dist/candles/refresh-candle-history.js.map +1 -0
  25. package/dist/candles/resolution.d.ts +3 -3
  26. package/dist/candles/resolution.d.ts.map +1 -1
  27. package/dist/candles/resolution.js +1 -0
  28. package/dist/candles/resolution.js.map +1 -1
  29. package/dist/candles/sources/binance/create-binance-candle-source.d.ts.map +1 -1
  30. package/dist/candles/sources/binance/create-binance-candle-source.js +3 -1
  31. package/dist/candles/sources/binance/create-binance-candle-source.js.map +1 -1
  32. package/dist/candles/sources/lowcap/create-lowcap-candle-source.d.ts +35 -0
  33. package/dist/candles/sources/lowcap/create-lowcap-candle-source.d.ts.map +1 -0
  34. package/dist/candles/sources/lowcap/create-lowcap-candle-source.js +104 -0
  35. package/dist/candles/sources/lowcap/create-lowcap-candle-source.js.map +1 -0
  36. package/dist/candles/sources/lowcap/create-lowcap-symbol-loader.d.ts +4 -0
  37. package/dist/candles/sources/lowcap/create-lowcap-symbol-loader.d.ts.map +1 -0
  38. package/dist/candles/sources/lowcap/create-lowcap-symbol-loader.js +40 -0
  39. package/dist/candles/sources/lowcap/create-lowcap-symbol-loader.js.map +1 -0
  40. package/dist/candles/sources/lowcap/get-lowcap-candles.d.ts +12 -0
  41. package/dist/candles/sources/lowcap/get-lowcap-candles.d.ts.map +1 -0
  42. package/dist/candles/sources/lowcap/get-lowcap-candles.js +48 -0
  43. package/dist/candles/sources/lowcap/get-lowcap-candles.js.map +1 -0
  44. package/dist/candles/sources/lowcap/index.d.ts +2 -0
  45. package/dist/candles/sources/lowcap/index.d.ts.map +1 -0
  46. package/dist/candles/sources/lowcap/lowcap-candle-time.d.ts +9 -0
  47. package/dist/candles/sources/lowcap/lowcap-candle-time.d.ts.map +1 -0
  48. package/dist/candles/sources/lowcap/lowcap-candle-time.js +24 -0
  49. package/dist/candles/sources/lowcap/lowcap-candle-time.js.map +1 -0
  50. package/dist/candles/sources/lowcap/map-resolution.d.ts +16 -0
  51. package/dist/candles/sources/lowcap/map-resolution.d.ts.map +1 -0
  52. package/dist/candles/sources/lowcap/map-resolution.js +26 -0
  53. package/dist/candles/sources/lowcap/map-resolution.js.map +1 -0
  54. package/dist/candles/sources/lowcap/resolve-lowcap-symbol.d.ts +12 -0
  55. package/dist/candles/sources/lowcap/resolve-lowcap-symbol.d.ts.map +1 -0
  56. package/dist/candles/sources/lowcap/resolve-lowcap-symbol.js +8 -0
  57. package/dist/candles/sources/lowcap/resolve-lowcap-symbol.js.map +1 -0
  58. package/dist/candles/sources/lowcap/watch-lowcap-candles.d.ts +19 -0
  59. package/dist/candles/sources/lowcap/watch-lowcap-candles.d.ts.map +1 -0
  60. package/dist/candles/sources/lowcap/watch-lowcap-candles.js +104 -0
  61. package/dist/candles/sources/lowcap/watch-lowcap-candles.js.map +1 -0
  62. package/dist/candles/types.d.ts +32 -16
  63. package/dist/candles/types.d.ts.map +1 -1
  64. package/dist/core/chains/registry.d.ts.map +1 -1
  65. package/dist/core/chains/registry.js +4 -5
  66. package/dist/core/chains/registry.js.map +1 -1
  67. package/dist/core/chains/types.d.ts +36 -1
  68. package/dist/core/chains/types.d.ts.map +1 -1
  69. package/dist/core/chains/types.js.map +1 -1
  70. package/dist/core/config/merge-chain-config.js +6 -3
  71. package/dist/core/config/merge-chain-config.js.map +1 -1
  72. package/dist/gasless/batch/calls.d.ts +21 -7
  73. package/dist/gasless/batch/calls.d.ts.map +1 -1
  74. package/dist/gasless/batch/calls.js +17 -16
  75. package/dist/gasless/batch/calls.js.map +1 -1
  76. package/dist/gasless/batch/resolve-gasless-batch.d.ts +10 -1
  77. package/dist/gasless/batch/resolve-gasless-batch.d.ts.map +1 -1
  78. package/dist/gasless/batch/resolve-gasless-batch.js +17 -15
  79. package/dist/gasless/batch/resolve-gasless-batch.js.map +1 -1
  80. package/dist/gasless/classify-gasless-failure.d.ts +3 -1
  81. package/dist/gasless/classify-gasless-failure.d.ts.map +1 -1
  82. package/dist/gasless/classify-gasless-failure.js +10 -10
  83. package/dist/gasless/classify-gasless-failure.js.map +1 -1
  84. package/dist/gasless/confirm-gasless-request/confirm-gasless-request.js +5 -5
  85. package/dist/gasless/constants.d.ts +21 -0
  86. package/dist/gasless/constants.d.ts.map +1 -1
  87. package/dist/gasless/constants.js +2 -2
  88. package/dist/gasless/constants.js.map +1 -1
  89. package/dist/gasless/delegation-preflight.js +10 -10
  90. package/dist/gasless/deployment-key.d.ts +39 -0
  91. package/dist/gasless/deployment-key.d.ts.map +1 -0
  92. package/dist/gasless/deployment-key.js +22 -0
  93. package/dist/gasless/deployment-key.js.map +1 -0
  94. package/dist/gasless/dispatch/attempt-start.d.ts +31 -0
  95. package/dist/gasless/dispatch/attempt-start.d.ts.map +1 -0
  96. package/dist/gasless/dispatch/attempt-start.js +14 -0
  97. package/dist/gasless/dispatch/attempt-start.js.map +1 -0
  98. package/dist/gasless/dispatch/maybe-relay-as-gasless.d.ts +4 -43
  99. package/dist/gasless/dispatch/maybe-relay-as-gasless.d.ts.map +1 -1
  100. package/dist/gasless/dispatch/maybe-relay-as-gasless.js +24 -182
  101. package/dist/gasless/dispatch/maybe-relay-as-gasless.js.map +1 -1
  102. package/dist/gasless/dispatch/resolve-gasless-write.d.ts +40 -0
  103. package/dist/gasless/dispatch/resolve-gasless-write.d.ts.map +1 -0
  104. package/dist/gasless/dispatch/resolve-gasless-write.js +48 -0
  105. package/dist/gasless/dispatch/resolve-gasless-write.js.map +1 -0
  106. package/dist/gasless/dispatch/submit-gasless-write.d.ts +11 -0
  107. package/dist/gasless/dispatch/submit-gasless-write.d.ts.map +1 -0
  108. package/dist/gasless/dispatch/submit-gasless-write.js +180 -0
  109. package/dist/gasless/dispatch/submit-gasless-write.js.map +1 -0
  110. package/dist/gasless/dispatch/types.d.ts +42 -0
  111. package/dist/gasless/dispatch/types.d.ts.map +1 -0
  112. package/dist/gasless/effective-instant-selectors.d.ts +11 -0
  113. package/dist/gasless/effective-instant-selectors.d.ts.map +1 -0
  114. package/dist/gasless/effective-instant-selectors.js +25 -0
  115. package/dist/gasless/effective-instant-selectors.js.map +1 -0
  116. package/dist/gasless/fallback.d.ts +43 -0
  117. package/dist/gasless/fallback.d.ts.map +1 -1
  118. package/dist/gasless/fallback.js +27 -17
  119. package/dist/gasless/fallback.js.map +1 -1
  120. package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.d.ts +13 -5
  121. package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.d.ts.map +1 -1
  122. package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.js +88 -81
  123. package/dist/gasless/gasless-wallet-execute/gasless-wallet-execute.js.map +1 -1
  124. package/dist/gasless/get-gasless-batch-funding/batch-fee-approvals.d.ts +20 -0
  125. package/dist/gasless/get-gasless-batch-funding/batch-fee-approvals.d.ts.map +1 -0
  126. package/dist/gasless/get-gasless-batch-funding/batch-fee-approvals.js +29 -0
  127. package/dist/gasless/get-gasless-batch-funding/batch-fee-approvals.js.map +1 -0
  128. package/dist/gasless/get-gasless-batch-funding/get-gasless-batch-funding.d.ts +43 -0
  129. package/dist/gasless/get-gasless-batch-funding/get-gasless-batch-funding.d.ts.map +1 -0
  130. package/dist/gasless/get-gasless-batch-funding/get-gasless-batch-funding.js +96 -0
  131. package/dist/gasless/get-gasless-batch-funding/get-gasless-batch-funding.js.map +1 -0
  132. package/dist/gasless/get-gasless-batch-funding/index.d.ts +4 -0
  133. package/dist/gasless/get-gasless-batch-funding/index.d.ts.map +1 -0
  134. package/dist/gasless/get-gasless-batch-funding/query.d.ts +31 -0
  135. package/dist/gasless/get-gasless-batch-funding/query.d.ts.map +1 -0
  136. package/dist/gasless/get-gasless-batch-funding/query.js +22 -0
  137. package/dist/gasless/get-gasless-batch-funding/query.js.map +1 -0
  138. package/dist/gasless/get-gasless-batch-funding/types.d.ts +80 -0
  139. package/dist/gasless/get-gasless-batch-funding/types.d.ts.map +1 -0
  140. package/dist/gasless/get-gasless-margin-funding/get-gasless-margin-funding.d.ts +33 -0
  141. package/dist/gasless/get-gasless-margin-funding/get-gasless-margin-funding.d.ts.map +1 -0
  142. package/dist/gasless/get-gasless-margin-funding/get-gasless-margin-funding.js +31 -0
  143. package/dist/gasless/get-gasless-margin-funding/get-gasless-margin-funding.js.map +1 -0
  144. package/dist/gasless/get-gasless-margin-funding/index.d.ts +4 -0
  145. package/dist/gasless/get-gasless-margin-funding/index.d.ts.map +1 -0
  146. package/dist/gasless/get-gasless-margin-funding/query.d.ts +31 -0
  147. package/dist/gasless/get-gasless-margin-funding/query.d.ts.map +1 -0
  148. package/dist/gasless/get-gasless-margin-funding/query.js +22 -0
  149. package/dist/gasless/get-gasless-margin-funding/query.js.map +1 -0
  150. package/dist/gasless/get-gasless-margin-funding/types.d.ts +27 -0
  151. package/dist/gasless/get-gasless-margin-funding/types.d.ts.map +1 -0
  152. package/dist/gasless/get-session-key-selectors.d.ts +18 -4
  153. package/dist/gasless/get-session-key-selectors.d.ts.map +1 -1
  154. package/dist/gasless/get-session-key-selectors.js +20 -12
  155. package/dist/gasless/get-session-key-selectors.js.map +1 -1
  156. package/dist/gasless/http.d.ts +7 -7
  157. package/dist/gasless/http.d.ts.map +1 -1
  158. package/dist/gasless/http.js +70 -72
  159. package/dist/gasless/http.js.map +1 -1
  160. package/dist/gasless/idempotency-key.d.ts +33 -0
  161. package/dist/gasless/idempotency-key.d.ts.map +1 -0
  162. package/dist/gasless/idempotency-key.js +15 -0
  163. package/dist/gasless/idempotency-key.js.map +1 -0
  164. package/dist/gasless/index.d.ts +4 -0
  165. package/dist/gasless/index.d.ts.map +1 -1
  166. package/dist/gasless/nonce-lock.d.ts +55 -17
  167. package/dist/gasless/nonce-lock.d.ts.map +1 -1
  168. package/dist/gasless/nonce-lock.js +53 -26
  169. package/dist/gasless/nonce-lock.js.map +1 -1
  170. package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.d.ts +30 -0
  171. package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.d.ts.map +1 -0
  172. package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.js +67 -0
  173. package/dist/gasless/relay-gasless-batch/preflight-batch-delegations.js.map +1 -0
  174. package/dist/gasless/relay-gasless-batch/relay-gasless-batch.d.ts +30 -9
  175. package/dist/gasless/relay-gasless-batch/relay-gasless-batch.d.ts.map +1 -1
  176. package/dist/gasless/relay-gasless-batch/relay-gasless-batch.js +99 -102
  177. package/dist/gasless/relay-gasless-batch/relay-gasless-batch.js.map +1 -1
  178. package/dist/gasless/relay-gasless-batch/resolve-batch-signers.d.ts +18 -0
  179. package/dist/gasless/relay-gasless-batch/resolve-batch-signers.d.ts.map +1 -0
  180. package/dist/gasless/relay-gasless-batch/resolve-batch-signers.js +17 -0
  181. package/dist/gasless/relay-gasless-batch/resolve-batch-signers.js.map +1 -0
  182. package/dist/gasless/relay-gasless-batch/sign-gasless-batch.d.ts +8 -5
  183. package/dist/gasless/relay-gasless-batch/sign-gasless-batch.d.ts.map +1 -1
  184. package/dist/gasless/relay-gasless-batch/sign-gasless-batch.js +22 -16
  185. package/dist/gasless/relay-gasless-batch/sign-gasless-batch.js.map +1 -1
  186. package/dist/gasless/relay-grant-delegation/relay-grant-delegation.d.ts +13 -7
  187. package/dist/gasless/relay-grant-delegation/relay-grant-delegation.d.ts.map +1 -1
  188. package/dist/gasless/relay-grant-delegation/relay-grant-delegation.js +46 -36
  189. package/dist/gasless/relay-grant-delegation/relay-grant-delegation.js.map +1 -1
  190. package/dist/gasless/relay-instant-operations/relay-instant-operations.d.ts +14 -15
  191. package/dist/gasless/relay-instant-operations/relay-instant-operations.d.ts.map +1 -1
  192. package/dist/gasless/relay-instant-operations/relay-instant-operations.js +12 -11
  193. package/dist/gasless/relay-instant-operations/relay-instant-operations.js.map +1 -1
  194. package/dist/gasless/relayable-writes.d.ts.map +1 -1
  195. package/dist/gasless/relayable-writes.js +28 -0
  196. package/dist/gasless/relayable-writes.js.map +1 -1
  197. package/dist/gasless/request-headers.d.ts +7 -0
  198. package/dist/gasless/request-headers.d.ts.map +1 -0
  199. package/dist/gasless/request-headers.js +34 -0
  200. package/dist/gasless/request-headers.js.map +1 -0
  201. package/dist/gasless/resolve-wallet-identities.js +4 -4
  202. package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.d.ts +11 -4
  203. package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.d.ts.map +1 -1
  204. package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.js +2 -2
  205. package/dist/gasless/resubmit-gasless-request/resubmit-gasless-request.js.map +1 -1
  206. package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.d.ts +10 -14
  207. package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.d.ts.map +1 -1
  208. package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.js +3 -2
  209. package/dist/gasless/settle-gasless-deposit-existing-account/settle-gasless-deposit-existing-account.js.map +1 -1
  210. package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.d.ts +15 -15
  211. package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.d.ts.map +1 -1
  212. package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.js +13 -12
  213. package/dist/gasless/settle-gasless-deposit-new-account/settle-gasless-deposit-new-account.js.map +1 -1
  214. package/dist/gasless/unconfirmed-submit.d.ts +12 -8
  215. package/dist/gasless/unconfirmed-submit.d.ts.map +1 -1
  216. package/dist/gasless/unconfirmed-submit.js +1 -1
  217. package/dist/gasless/unconfirmed-submit.js.map +1 -1
  218. package/dist/index.d.ts +27 -10
  219. package/dist/index.d.ts.map +1 -1
  220. package/dist/index.js +680 -615
  221. package/dist/pools/listing-config/to-listing-config.d.ts +10 -3
  222. package/dist/pools/listing-config/to-listing-config.d.ts.map +1 -1
  223. package/dist/pools/listing-config/to-listing-config.js +5 -1
  224. package/dist/pools/listing-config/to-listing-config.js.map +1 -1
  225. package/dist/pools/types/generated/listing-backend.d.ts +266 -1
  226. package/dist/pools/types/generated/listing-backend.d.ts.map +1 -1
  227. package/dist/pools/types/generated/listing-backend.js.map +1 -1
  228. package/dist/pools/types.d.ts +7 -0
  229. package/dist/pools/types.d.ts.map +1 -1
  230. package/dist/pools/types.js.map +1 -1
  231. package/dist/price-service/enigma/ohlcv/fetch-enigma-ohlcv.d.ts +39 -0
  232. package/dist/price-service/enigma/ohlcv/fetch-enigma-ohlcv.d.ts.map +1 -0
  233. package/dist/price-service/enigma/ohlcv/fetch-enigma-ohlcv.js +43 -0
  234. package/dist/price-service/enigma/ohlcv/fetch-enigma-ohlcv.js.map +1 -0
  235. package/dist/price-service/enigma/ohlcv/generated/enigma-price-service-ohlcv.d.ts +67 -0
  236. package/dist/price-service/enigma/ohlcv/generated/enigma-price-service-ohlcv.d.ts.map +1 -0
  237. package/dist/price-service/enigma/ohlcv/generated/enigma-price-service-ohlcv.js +15 -0
  238. package/dist/price-service/enigma/ohlcv/generated/enigma-price-service-ohlcv.js.map +1 -0
  239. package/dist/price-service/enigma/ohlcv/parse-enigma-ohlcv.d.ts +21 -0
  240. package/dist/price-service/enigma/ohlcv/parse-enigma-ohlcv.d.ts.map +1 -0
  241. package/dist/price-service/enigma/ohlcv/parse-enigma-ohlcv.js +36 -0
  242. package/dist/price-service/enigma/ohlcv/parse-enigma-ohlcv.js.map +1 -0
  243. package/dist/price-service/enigma/symbols-info/get-enigma-price-service-symbols-info.d.ts +2 -0
  244. package/dist/price-service/enigma/symbols-info/get-enigma-price-service-symbols-info.d.ts.map +1 -1
  245. package/dist/price-service/enigma/symbols-info/get-enigma-price-service-symbols-info.js +12 -8
  246. package/dist/price-service/enigma/symbols-info/get-enigma-price-service-symbols-info.js.map +1 -1
  247. package/dist/shared/errors/symm-error.js +3 -3
  248. package/dist/shared/types/properties.d.ts +45 -8
  249. package/dist/shared/types/properties.d.ts.map +1 -1
  250. package/dist/solvers/capabilities.d.ts.map +1 -1
  251. package/dist/solvers/capabilities.js +4 -2
  252. package/dist/solvers/capabilities.js.map +1 -1
  253. package/dist/solvers/estimated-price/get-estimated-price.js +6 -6
  254. package/dist/solvers/force-close/force-close-auto.d.ts.map +1 -1
  255. package/dist/solvers/force-close/force-close-auto.js +70 -69
  256. package/dist/solvers/force-close/force-close-auto.js.map +1 -1
  257. package/dist/solvers/get-error-message/get-error-message.js +4 -4
  258. package/dist/solvers/get-party-a-upnl/get-party-a-upnl.js +4 -4
  259. package/dist/solvers/get-solver-balance-info/get-solver-balance-info.js +4 -4
  260. package/dist/solvers/get-solver-info/get-solver-info.d.ts +5 -2
  261. package/dist/solvers/get-solver-info/get-solver-info.d.ts.map +1 -1
  262. package/dist/solvers/get-solver-info/get-solver-info.js +14 -12
  263. package/dist/solvers/get-solver-info/get-solver-info.js.map +1 -1
  264. package/dist/solvers/get-solver-info/parse-timelock-info.d.ts +5 -0
  265. package/dist/solvers/get-solver-info/parse-timelock-info.d.ts.map +1 -0
  266. package/dist/solvers/get-solver-info/parse-timelock-info.js +27 -0
  267. package/dist/solvers/get-solver-info/parse-timelock-info.js.map +1 -0
  268. package/dist/solvers/get-solver-open-interest/get-solver-open-interest.js +4 -4
  269. package/dist/solvers/get-solver-price-range/get-solver-price-range.js +4 -4
  270. package/dist/solvers/get-solver-readiness/get-solver-readiness.js +4 -4
  271. package/dist/solvers/instant-open/get-instant-opens/adapters/enigma-instant-opens.js +17 -17
  272. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts +8 -7
  273. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.d.ts.map +1 -1
  274. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js +43 -39
  275. package/dist/solvers/instant-open/instant-open/adapters/enigma-instant-open.js.map +1 -1
  276. package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.d.ts +16 -0
  277. package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.d.ts.map +1 -0
  278. package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.js +92 -0
  279. package/dist/solvers/instant-open/instant-open/adapters/enigma-margin-timelock.js.map +1 -0
  280. package/dist/solvers/instant-open/instant-open/adapters/rasa-instant-open.js +1 -1
  281. package/dist/solvers/instant-open/instant-open/index.d.ts +2 -0
  282. package/dist/solvers/instant-open/instant-open/index.d.ts.map +1 -1
  283. package/dist/solvers/instant-open/instant-open/instant-open.d.ts +22 -6
  284. package/dist/solvers/instant-open/instant-open/instant-open.d.ts.map +1 -1
  285. package/dist/solvers/instant-open/instant-open/instant-open.js +35 -27
  286. package/dist/solvers/instant-open/instant-open/instant-open.js.map +1 -1
  287. package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.d.ts +12 -0
  288. package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.d.ts.map +1 -0
  289. package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.js +49 -0
  290. package/dist/solvers/instant-open/instant-open/prepared/submit-prepared-instant-open.js.map +1 -0
  291. package/dist/solvers/instant-open/instant-open/prepared/types.d.ts +20 -0
  292. package/dist/solvers/instant-open/instant-open/prepared/types.d.ts.map +1 -0
  293. package/dist/solvers/instant-open/instant-open/types.d.ts +5 -4
  294. package/dist/solvers/instant-open/instant-open/types.d.ts.map +1 -1
  295. package/dist/solvers/instant-open/shared/hedger-api.d.ts.map +1 -1
  296. package/dist/solvers/instant-open/shared/hedger-api.js +38 -26
  297. package/dist/solvers/instant-open/shared/hedger-api.js.map +1 -1
  298. package/dist/solvers/markets/adapters/enigma-markets.js +34 -34
  299. package/dist/solvers/notional-cap/get-notional-cap-page.js +4 -4
  300. package/dist/solvers/revenue/get-solver-revenue.js +10 -10
  301. package/dist/solvers/revenue-records/get-revenue-records.js +11 -11
  302. package/dist/solvers/symbols/get-symbols.js +13 -13
  303. package/dist/solvers/trade-volume/get-trade-volume.js +10 -10
  304. package/dist/symmio-contracts/abi/v0.8.6/instant-layer.d.ts +46 -0
  305. package/dist/symmio-contracts/abi/v0.8.6/instant-layer.d.ts.map +1 -1
  306. package/dist/symmio-contracts/abi/v0.8.6/instant-layer.js +53 -0
  307. package/dist/symmio-contracts/abi/v0.8.6/instant-layer.js.map +1 -1
  308. package/dist/symmio-contracts/account-layer/actions/add-margin.d.ts +3 -0
  309. package/dist/symmio-contracts/account-layer/actions/add-margin.d.ts.map +1 -1
  310. package/dist/symmio-contracts/account-layer/actions/add-margin.js +41 -27
  311. package/dist/symmio-contracts/account-layer/actions/add-margin.js.map +1 -1
  312. package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.d.ts +23 -9
  313. package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.d.ts.map +1 -1
  314. package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.js +15 -36
  315. package/dist/symmio-contracts/account-layer/actions/create-sub-accounts.js.map +1 -1
  316. package/dist/symmio-contracts/account-layer/actions/delete-sub-account.d.ts +3 -0
  317. package/dist/symmio-contracts/account-layer/actions/delete-sub-account.d.ts.map +1 -1
  318. package/dist/symmio-contracts/account-layer/actions/delete-sub-account.js +40 -26
  319. package/dist/symmio-contracts/account-layer/actions/delete-sub-account.js.map +1 -1
  320. package/dist/symmio-contracts/account-layer/actions/edit-account-name.d.ts +1 -1
  321. package/dist/symmio-contracts/account-layer/actions/edit-account-name.d.ts.map +1 -1
  322. package/dist/symmio-contracts/account-layer/actions/edit-account-name.js +18 -37
  323. package/dist/symmio-contracts/account-layer/actions/edit-account-name.js.map +1 -1
  324. package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.d.ts +46 -0
  325. package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.d.ts.map +1 -0
  326. package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.js +20 -0
  327. package/dist/symmio-contracts/account-layer/actions/get-active-virtual-account-by-key.js.map +1 -0
  328. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.d.ts +31 -0
  329. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
  330. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.js +15 -0
  331. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-count-of-sub-account.js.map +1 -0
  332. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.d.ts +54 -0
  333. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.d.ts.map +1 -0
  334. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.js +26 -0
  335. package/dist/symmio-contracts/account-layer/actions/get-virtual-accounts-of-sub-account.js.map +1 -0
  336. package/dist/symmio-contracts/account-layer/actions/remove-margin.d.ts +3 -0
  337. package/dist/symmio-contracts/account-layer/actions/remove-margin.d.ts.map +1 -1
  338. package/dist/symmio-contracts/account-layer/actions/remove-margin.js +50 -32
  339. package/dist/symmio-contracts/account-layer/actions/remove-margin.js.map +1 -1
  340. package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.d.ts +12 -0
  341. package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.d.ts.map +1 -0
  342. package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.js +10 -0
  343. package/dist/symmio-contracts/account-layer/cancel-timelock-op/cancel-timelock-op.js.map +1 -0
  344. package/dist/symmio-contracts/account-layer/cancel-timelock-op/index.d.ts +3 -0
  345. package/dist/symmio-contracts/account-layer/cancel-timelock-op/index.d.ts.map +1 -0
  346. package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.d.ts +9 -0
  347. package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.d.ts.map +1 -0
  348. package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.js +13 -0
  349. package/dist/symmio-contracts/account-layer/cancel-timelock-op/query.js.map +1 -0
  350. package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.d.ts +12 -0
  351. package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.d.ts.map +1 -0
  352. package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.js +10 -0
  353. package/dist/symmio-contracts/account-layer/clear-timelocks/clear-timelocks.js.map +1 -0
  354. package/dist/symmio-contracts/account-layer/clear-timelocks/index.d.ts +3 -0
  355. package/dist/symmio-contracts/account-layer/clear-timelocks/index.d.ts.map +1 -0
  356. package/dist/symmio-contracts/account-layer/clear-timelocks/query.d.ts +9 -0
  357. package/dist/symmio-contracts/account-layer/clear-timelocks/query.d.ts.map +1 -0
  358. package/dist/symmio-contracts/account-layer/clear-timelocks/query.js +13 -0
  359. package/dist/symmio-contracts/account-layer/clear-timelocks/query.js.map +1 -0
  360. package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.d.ts +12 -0
  361. package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.d.ts.map +1 -0
  362. package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.js +9 -0
  363. package/dist/symmio-contracts/account-layer/execute-timelock-op/execute-timelock-op.js.map +1 -0
  364. package/dist/symmio-contracts/account-layer/execute-timelock-op/index.d.ts +3 -0
  365. package/dist/symmio-contracts/account-layer/execute-timelock-op/index.d.ts.map +1 -0
  366. package/dist/symmio-contracts/account-layer/execute-timelock-op/query.d.ts +9 -0
  367. package/dist/symmio-contracts/account-layer/execute-timelock-op/query.d.ts.map +1 -0
  368. package/dist/symmio-contracts/account-layer/execute-timelock-op/query.js +13 -0
  369. package/dist/symmio-contracts/account-layer/execute-timelock-op/query.js.map +1 -0
  370. package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.d.ts +12 -0
  371. package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.d.ts.map +1 -0
  372. package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.js +16 -0
  373. package/dist/symmio-contracts/account-layer/get-min-timelock-delay/get-min-timelock-delay.js.map +1 -0
  374. package/dist/symmio-contracts/account-layer/get-min-timelock-delay/index.d.ts +2 -0
  375. package/dist/symmio-contracts/account-layer/get-min-timelock-delay/index.d.ts.map +1 -0
  376. package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.d.ts +12 -0
  377. package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.d.ts.map +1 -0
  378. package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.js +22 -0
  379. package/dist/symmio-contracts/account-layer/get-selector-timelock/get-selector-timelock.js.map +1 -0
  380. package/dist/symmio-contracts/account-layer/get-selector-timelock/index.d.ts +3 -0
  381. package/dist/symmio-contracts/account-layer/get-selector-timelock/index.d.ts.map +1 -0
  382. package/dist/symmio-contracts/account-layer/get-selector-timelock/query.d.ts +22 -0
  383. package/dist/symmio-contracts/account-layer/get-selector-timelock/query.d.ts.map +1 -0
  384. package/dist/symmio-contracts/account-layer/get-selector-timelock/query.js +21 -0
  385. package/dist/symmio-contracts/account-layer/get-selector-timelock/query.js.map +1 -0
  386. package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.d.ts +12 -0
  387. package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.d.ts.map +1 -0
  388. package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.js +22 -0
  389. package/dist/symmio-contracts/account-layer/get-timelock-schedule/get-timelock-schedule.js.map +1 -0
  390. package/dist/symmio-contracts/account-layer/get-timelock-schedule/index.d.ts +2 -0
  391. package/dist/symmio-contracts/account-layer/get-timelock-schedule/index.d.ts.map +1 -0
  392. package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.d.ts +13 -0
  393. package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.d.ts.map +1 -0
  394. package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.js +17 -0
  395. package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/get-timelock-schedule-grace-period.js.map +1 -0
  396. package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/index.d.ts +2 -0
  397. package/dist/symmio-contracts/account-layer/get-timelock-schedule-grace-period/index.d.ts.map +1 -0
  398. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.d.ts +12 -0
  399. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.d.ts.map +1 -0
  400. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.js +67 -0
  401. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/get-timelock-schedule-state.js.map +1 -0
  402. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/index.d.ts +3 -0
  403. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/index.d.ts.map +1 -0
  404. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.d.ts +21 -0
  405. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.d.ts.map +1 -0
  406. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.js +21 -0
  407. package/dist/symmio-contracts/account-layer/get-timelock-schedule-state/query.js.map +1 -0
  408. package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.d.ts +15 -0
  409. package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.d.ts.map +1 -0
  410. package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.js +17 -0
  411. package/dist/symmio-contracts/account-layer/hash-timelock-approval/hash-timelock-approval.js.map +1 -0
  412. package/dist/symmio-contracts/account-layer/hash-timelock-approval/index.d.ts +2 -0
  413. package/dist/symmio-contracts/account-layer/hash-timelock-approval/index.d.ts.map +1 -0
  414. package/dist/symmio-contracts/account-layer/hook-metadata.d.ts +47 -0
  415. package/dist/symmio-contracts/account-layer/hook-metadata.d.ts.map +1 -0
  416. package/dist/symmio-contracts/account-layer/hook-metadata.js +30 -0
  417. package/dist/symmio-contracts/account-layer/hook-metadata.js.map +1 -0
  418. package/dist/symmio-contracts/account-layer/index.d.ts +21 -0
  419. package/dist/symmio-contracts/account-layer/index.d.ts.map +1 -1
  420. package/dist/symmio-contracts/account-layer/is-timelock-approval-used/index.d.ts +2 -0
  421. package/dist/symmio-contracts/account-layer/is-timelock-approval-used/index.d.ts.map +1 -0
  422. package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.d.ts +14 -0
  423. package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.d.ts.map +1 -0
  424. package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.js +17 -0
  425. package/dist/symmio-contracts/account-layer/is-timelock-approval-used/is-timelock-approval-used.js.map +1 -0
  426. package/dist/symmio-contracts/account-layer/query/generate-account-manager-address.js +6 -6
  427. package/dist/symmio-contracts/account-layer/query/get-account-balance-info.js +6 -6
  428. package/dist/symmio-contracts/account-layer/query/get-account-balance-of.js +6 -6
  429. package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.d.ts +43 -0
  430. package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.d.ts.map +1 -0
  431. package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.js +31 -0
  432. package/dist/symmio-contracts/account-layer/query/get-active-virtual-account-by-key.js.map +1 -0
  433. package/dist/symmio-contracts/account-layer/query/get-affiliate-state.js +6 -6
  434. package/dist/symmio-contracts/account-layer/query/get-sub-account-virtual-nonce.js +6 -6
  435. package/dist/symmio-contracts/account-layer/query/get-sub-accounts-count-of-user.js +6 -6
  436. package/dist/symmio-contracts/account-layer/query/get-user-sub-accounts-addresses.js +6 -6
  437. package/dist/symmio-contracts/account-layer/query/get-user-sub-accounts.js +6 -6
  438. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-addresses-of-sub-account.js +6 -6
  439. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.d.ts +39 -0
  440. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.d.ts.map +1 -0
  441. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.js +29 -0
  442. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-count-of-sub-account.js.map +1 -0
  443. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.d.ts +39 -0
  444. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.d.ts.map +1 -0
  445. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.js +31 -0
  446. package/dist/symmio-contracts/account-layer/query/get-virtual-accounts-of-sub-account.js.map +1 -0
  447. package/dist/symmio-contracts/account-layer/query/predict-next-virtual-account.js +6 -6
  448. package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/index.d.ts +2 -0
  449. package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/index.d.ts.map +1 -0
  450. package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.d.ts +19 -0
  451. package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.d.ts.map +1 -0
  452. package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.js +10 -0
  453. package/dist/symmio-contracts/account-layer/resolve-timelock-root-account/resolve-timelock-root-account.js.map +1 -0
  454. package/dist/symmio-contracts/account-layer/schedule-timelock-op/index.d.ts +3 -0
  455. package/dist/symmio-contracts/account-layer/schedule-timelock-op/index.d.ts.map +1 -0
  456. package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.d.ts +9 -0
  457. package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.d.ts.map +1 -0
  458. package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.js +13 -0
  459. package/dist/symmio-contracts/account-layer/schedule-timelock-op/query.js.map +1 -0
  460. package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.d.ts +12 -0
  461. package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.d.ts.map +1 -0
  462. package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.js +10 -0
  463. package/dist/symmio-contracts/account-layer/schedule-timelock-op/schedule-timelock-op.js.map +1 -0
  464. package/dist/symmio-contracts/account-layer/setup-timelocks/index.d.ts +3 -0
  465. package/dist/symmio-contracts/account-layer/setup-timelocks/index.d.ts.map +1 -0
  466. package/dist/symmio-contracts/account-layer/setup-timelocks/query.d.ts +9 -0
  467. package/dist/symmio-contracts/account-layer/setup-timelocks/query.d.ts.map +1 -0
  468. package/dist/symmio-contracts/account-layer/setup-timelocks/query.js +13 -0
  469. package/dist/symmio-contracts/account-layer/setup-timelocks/query.js.map +1 -0
  470. package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.d.ts +13 -0
  471. package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.d.ts.map +1 -0
  472. package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.js +18 -0
  473. package/dist/symmio-contracts/account-layer/setup-timelocks/setup-timelocks.js.map +1 -0
  474. package/dist/symmio-contracts/account-layer/timelock-selector.d.ts +4 -0
  475. package/dist/symmio-contracts/account-layer/timelock-selector.d.ts.map +1 -0
  476. package/dist/symmio-contracts/account-layer/timelock-selector.js +9 -0
  477. package/dist/symmio-contracts/account-layer/timelock-selector.js.map +1 -0
  478. package/dist/symmio-contracts/account-layer/timelock-test.d.ts +7 -0
  479. package/dist/symmio-contracts/account-layer/timelock-test.d.ts.map +1 -0
  480. package/dist/symmio-contracts/account-layer/timelock-types.d.ts +66 -0
  481. package/dist/symmio-contracts/account-layer/timelock-types.d.ts.map +1 -0
  482. package/dist/symmio-contracts/account-layer/types.d.ts +32 -2
  483. package/dist/symmio-contracts/account-layer/types.d.ts.map +1 -1
  484. package/dist/symmio-contracts/account-layer/types.js.map +1 -1
  485. package/dist/symmio-contracts/account-layer/write-timelock.d.ts +10 -0
  486. package/dist/symmio-contracts/account-layer/write-timelock.d.ts.map +1 -0
  487. package/dist/symmio-contracts/account-layer/write-timelock.js +51 -0
  488. package/dist/symmio-contracts/account-layer/write-timelock.js.map +1 -0
  489. package/dist/symmio-contracts/instant-layer/actions/grant-delegation.d.ts +4 -1
  490. package/dist/symmio-contracts/instant-layer/actions/grant-delegation.d.ts.map +1 -1
  491. package/dist/symmio-contracts/instant-layer/actions/grant-delegation.js +42 -38
  492. package/dist/symmio-contracts/instant-layer/actions/grant-delegation.js.map +1 -1
  493. package/dist/symmio-contracts/instant-layer/actions/grant-delegations.d.ts +75 -0
  494. package/dist/symmio-contracts/instant-layer/actions/grant-delegations.d.ts.map +1 -0
  495. package/dist/symmio-contracts/instant-layer/actions/grant-delegations.js +46 -0
  496. package/dist/symmio-contracts/instant-layer/actions/grant-delegations.js.map +1 -0
  497. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.d.ts +32 -0
  498. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.d.ts.map +1 -0
  499. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.js +18 -0
  500. package/dist/symmio-contracts/instant-layer/actions/simulate-grant-delegations.js.map +1 -0
  501. package/dist/symmio-contracts/instant-layer/grant-delegations-input.d.ts +33 -0
  502. package/dist/symmio-contracts/instant-layer/grant-delegations-input.d.ts.map +1 -0
  503. package/dist/symmio-contracts/instant-layer/grant-delegations-input.js +18 -0
  504. package/dist/symmio-contracts/instant-layer/grant-delegations-input.js.map +1 -0
  505. package/dist/symmio-contracts/instant-layer/index.d.ts +4 -0
  506. package/dist/symmio-contracts/instant-layer/index.d.ts.map +1 -1
  507. package/dist/symmio-contracts/instant-layer/query/grant-delegations.d.ts +22 -0
  508. package/dist/symmio-contracts/instant-layer/query/grant-delegations.d.ts.map +1 -0
  509. package/dist/symmio-contracts/instant-layer/query/grant-delegations.js +12 -0
  510. package/dist/symmio-contracts/instant-layer/query/grant-delegations.js.map +1 -0
  511. package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.d.ts +19 -0
  512. package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.d.ts.map +1 -0
  513. package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.js +12 -0
  514. package/dist/symmio-contracts/instant-layer/query/simulate-grant-delegations.js.map +1 -0
  515. package/dist/symmio-contracts/symmio/actions/allocate.d.ts +3 -0
  516. package/dist/symmio-contracts/symmio/actions/allocate.d.ts.map +1 -1
  517. package/dist/symmio-contracts/symmio/actions/allocate.js +22 -16
  518. package/dist/symmio-contracts/symmio/actions/allocate.js.map +1 -1
  519. package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.d.ts +74 -0
  520. package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.d.ts.map +1 -0
  521. package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.js +36 -0
  522. package/dist/symmio-contracts/symmio/actions/approve-operational-fee-allowance.js.map +1 -0
  523. package/dist/symmio-contracts/symmio/actions/approve-operational-fee.d.ts +3 -0
  524. package/dist/symmio-contracts/symmio/actions/approve-operational-fee.d.ts.map +1 -1
  525. package/dist/symmio-contracts/symmio/actions/approve-operational-fee.js +32 -29
  526. package/dist/symmio-contracts/symmio/actions/approve-operational-fee.js.map +1 -1
  527. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.d.ts +3 -0
  528. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.d.ts.map +1 -1
  529. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.js +37 -28
  530. package/dist/symmio-contracts/symmio/actions/deallocate-and-initiate-withdraw.js.map +1 -1
  531. package/dist/symmio-contracts/symmio/actions/deallocate.d.ts +3 -0
  532. package/dist/symmio-contracts/symmio/actions/deallocate.d.ts.map +1 -1
  533. package/dist/symmio-contracts/symmio/actions/deallocate.js +30 -20
  534. package/dist/symmio-contracts/symmio/actions/deallocate.js.map +1 -1
  535. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.d.ts +5 -0
  536. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.d.ts.map +1 -1
  537. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.js +31 -18
  538. package/dist/symmio-contracts/symmio/actions/initiate-withdraw.js.map +1 -1
  539. package/dist/symmio-contracts/symmio/actions/withdraw-auto.d.ts +4 -0
  540. package/dist/symmio-contracts/symmio/actions/withdraw-auto.d.ts.map +1 -1
  541. package/dist/symmio-contracts/symmio/actions/withdraw-auto.js +30 -25
  542. package/dist/symmio-contracts/symmio/actions/withdraw-auto.js.map +1 -1
  543. package/dist/symmio-contracts/symmio/actions/withdraw.d.ts +4 -0
  544. package/dist/symmio-contracts/symmio/actions/withdraw.d.ts.map +1 -1
  545. package/dist/symmio-contracts/symmio/actions/withdraw.js +12 -8
  546. package/dist/symmio-contracts/symmio/actions/withdraw.js.map +1 -1
  547. package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.d.ts +48 -0
  548. package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.d.ts.map +1 -0
  549. package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.js +33 -0
  550. package/dist/symmio-contracts/symmio/execute-account-calls/execute-account-calls.js.map +1 -0
  551. package/dist/symmio-contracts/symmio/execute-account-calls/index.d.ts +3 -0
  552. package/dist/symmio-contracts/symmio/execute-account-calls/index.d.ts.map +1 -0
  553. package/dist/symmio-contracts/symmio/execute-account-calls/query.d.ts +23 -0
  554. package/dist/symmio-contracts/symmio/execute-account-calls/query.d.ts.map +1 -0
  555. package/dist/symmio-contracts/symmio/execute-account-calls/query.js +12 -0
  556. package/dist/symmio-contracts/symmio/execute-account-calls/query.js.map +1 -0
  557. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.d.ts +22 -0
  558. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.d.ts.map +1 -0
  559. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.js +14 -0
  560. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/get-deallocate-debounce-time.js.map +1 -0
  561. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/index.d.ts +3 -0
  562. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/index.d.ts.map +1 -0
  563. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.d.ts +34 -0
  564. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.d.ts.map +1 -0
  565. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.js +21 -0
  566. package/dist/symmio-contracts/symmio/get-deallocate-debounce-time/query.js.map +1 -0
  567. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.d.ts +34 -0
  568. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.d.ts.map +1 -0
  569. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.js +35 -0
  570. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/get-pending-withdraw-requests-batch.js.map +1 -0
  571. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/index.d.ts +3 -0
  572. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/index.d.ts.map +1 -0
  573. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.d.ts +15 -0
  574. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.d.ts.map +1 -0
  575. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.js +20 -0
  576. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/limit-concurrency.js.map +1 -0
  577. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.d.ts +22 -0
  578. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.d.ts.map +1 -0
  579. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.js +30 -0
  580. package/dist/symmio-contracts/symmio/get-pending-withdraw-requests-batch/query.js.map +1 -0
  581. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.d.ts +30 -0
  582. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.d.ts.map +1 -0
  583. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.js +15 -0
  584. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/get-withdraw-cooldown-of.js.map +1 -0
  585. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/index.d.ts +3 -0
  586. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/index.d.ts.map +1 -0
  587. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.d.ts +38 -0
  588. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.d.ts.map +1 -0
  589. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.js +24 -0
  590. package/dist/symmio-contracts/symmio/get-withdraw-cooldown-of/query.js.map +1 -0
  591. package/dist/symmio-contracts/symmio/index.d.ts +6 -0
  592. package/dist/symmio-contracts/symmio/index.d.ts.map +1 -1
  593. package/dist/symmio-contracts/symmio/internal/call-as-sub-account.d.ts.map +1 -1
  594. package/dist/symmio-contracts/symmio/internal/call-as-sub-account.js +35 -34
  595. package/dist/symmio-contracts/symmio/internal/call-as-sub-account.js.map +1 -1
  596. package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.d.ts +18 -0
  597. package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.d.ts.map +1 -0
  598. package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.js +14 -0
  599. package/dist/symmio-contracts/symmio/internal/resolve-default-operational-fee-charger.js.map +1 -0
  600. package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.d.ts +18 -0
  601. package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.d.ts.map +1 -0
  602. package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.js +12 -0
  603. package/dist/symmio-contracts/symmio/query/approve-operational-fee-allowance.js.map +1 -0
  604. package/dist/symmio-subgraph/executeSubgraphRequest.js +3 -3
  605. package/dist/timelock/approval.d.ts +142 -0
  606. package/dist/timelock/approval.d.ts.map +1 -0
  607. package/dist/timelock/approval.js +176 -0
  608. package/dist/timelock/approval.js.map +1 -0
  609. package/dist/timelock/attempt-outcome.d.ts +37 -0
  610. package/dist/timelock/attempt-outcome.d.ts.map +1 -0
  611. package/dist/timelock/attempt-outcome.js +70 -0
  612. package/dist/timelock/attempt-outcome.js.map +1 -0
  613. package/dist/timelock/confirm-write.d.ts +5 -0
  614. package/dist/timelock/confirm-write.d.ts.map +1 -0
  615. package/dist/timelock/confirm-write.js +18 -0
  616. package/dist/timelock/confirm-write.js.map +1 -0
  617. package/dist/timelock/early-withdraw/early-withdraw.d.ts +60 -0
  618. package/dist/timelock/early-withdraw/early-withdraw.d.ts.map +1 -0
  619. package/dist/timelock/early-withdraw/early-withdraw.js +94 -0
  620. package/dist/timelock/early-withdraw/early-withdraw.js.map +1 -0
  621. package/dist/timelock/early-withdraw/index.d.ts +2 -0
  622. package/dist/timelock/early-withdraw/index.d.ts.map +1 -0
  623. package/dist/timelock/errors.d.ts +23 -0
  624. package/dist/timelock/errors.d.ts.map +1 -0
  625. package/dist/timelock/errors.js +29 -0
  626. package/dist/timelock/errors.js.map +1 -0
  627. package/dist/timelock/execute-protected-batch.d.ts +31 -0
  628. package/dist/timelock/execute-protected-batch.d.ts.map +1 -0
  629. package/dist/timelock/execute-protected-batch.js +148 -0
  630. package/dist/timelock/execute-protected-batch.js.map +1 -0
  631. package/dist/timelock/execute-protected-call.d.ts +68 -0
  632. package/dist/timelock/execute-protected-call.d.ts.map +1 -0
  633. package/dist/timelock/execute-protected-call.js +146 -0
  634. package/dist/timelock/execute-protected-call.js.map +1 -0
  635. package/dist/timelock/execute-protected-function.d.ts +51 -0
  636. package/dist/timelock/execute-protected-function.d.ts.map +1 -0
  637. package/dist/timelock/execute-protected-function.js +37 -0
  638. package/dist/timelock/execute-protected-function.js.map +1 -0
  639. package/dist/timelock/get-timelock-policy/get-timelock-policy.d.ts +38 -0
  640. package/dist/timelock/get-timelock-policy/get-timelock-policy.d.ts.map +1 -0
  641. package/dist/timelock/get-timelock-policy/get-timelock-policy.js +49 -0
  642. package/dist/timelock/get-timelock-policy/get-timelock-policy.js.map +1 -0
  643. package/dist/timelock/get-timelock-policy/index.d.ts +3 -0
  644. package/dist/timelock/get-timelock-policy/index.d.ts.map +1 -0
  645. package/dist/timelock/get-timelock-policy/query.d.ts +13 -0
  646. package/dist/timelock/get-timelock-policy/query.d.ts.map +1 -0
  647. package/dist/timelock/get-timelock-policy/query.js +21 -0
  648. package/dist/timelock/get-timelock-policy/query.js.map +1 -0
  649. package/dist/timelock/index.d.ts +14 -0
  650. package/dist/timelock/index.d.ts.map +1 -0
  651. package/dist/timelock/normalize-timelock-revert.d.ts +3 -0
  652. package/dist/timelock/normalize-timelock-revert.d.ts.map +1 -0
  653. package/dist/timelock/normalize-timelock-revert.js +11 -0
  654. package/dist/timelock/normalize-timelock-revert.js.map +1 -0
  655. package/dist/timelock/policy-change.d.ts +72 -0
  656. package/dist/timelock/policy-change.d.ts.map +1 -0
  657. package/dist/timelock/policy-change.js +63 -0
  658. package/dist/timelock/policy-change.js.map +1 -0
  659. package/dist/timelock/policy.d.ts +19 -0
  660. package/dist/timelock/policy.d.ts.map +1 -0
  661. package/dist/timelock/policy.js +59 -0
  662. package/dist/timelock/policy.js.map +1 -0
  663. package/dist/timelock/protected-call-preflight.d.ts +10 -0
  664. package/dist/timelock/protected-call-preflight.d.ts.map +1 -0
  665. package/dist/timelock/protected-call-preflight.js +17 -0
  666. package/dist/timelock/protected-call-preflight.js.map +1 -0
  667. package/dist/timelock/root-account.d.ts +14 -0
  668. package/dist/timelock/root-account.d.ts.map +1 -0
  669. package/dist/timelock/root-account.js +9 -0
  670. package/dist/timelock/root-account.js.map +1 -0
  671. package/dist/timelock/scheduled-call-match.d.ts +4 -0
  672. package/dist/timelock/scheduled-call-match.d.ts.map +1 -0
  673. package/dist/timelock/scheduled-call-match.js +43 -0
  674. package/dist/timelock/scheduled-call-match.js.map +1 -0
  675. package/dist/timelock/setup-timelock-policy/index.d.ts +2 -0
  676. package/dist/timelock/setup-timelock-policy/index.d.ts.map +1 -0
  677. package/dist/timelock/setup-timelock-policy/setup-timelock-policy.d.ts +46 -0
  678. package/dist/timelock/setup-timelock-policy/setup-timelock-policy.d.ts.map +1 -0
  679. package/dist/timelock/setup-timelock-policy/setup-timelock-policy.js +58 -0
  680. package/dist/timelock/setup-timelock-policy/setup-timelock-policy.js.map +1 -0
  681. package/dist/timelock/support.d.ts +4 -0
  682. package/dist/timelock/support.d.ts.map +1 -0
  683. package/dist/timelock/support.js +9 -0
  684. package/dist/timelock/support.js.map +1 -0
  685. package/dist/transactions/execute-contract-write.d.ts +9 -0
  686. package/dist/transactions/execute-contract-write.d.ts.map +1 -0
  687. package/dist/transactions/execute-contract-write.js +35 -0
  688. package/dist/transactions/execute-contract-write.js.map +1 -0
  689. package/dist/transactions/execute-write.d.ts +32 -0
  690. package/dist/transactions/execute-write.d.ts.map +1 -0
  691. package/dist/transactions/execute-write.js +23 -0
  692. package/dist/transactions/execute-write.js.map +1 -0
  693. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"merge-chain-config.js","names":[],"sources":["../../../src/core/config/merge-chain-config.ts"],"sourcesContent":["import { SymmError } from \"../../shared/errors/symm-error\";\nimport type { DeepPartial } from \"../../shared/types/properties\";\nimport {\n getChainConfig,\n listSupportedChains,\n type GaslessExecutionConfig,\n type SolverCapabilitiesConfig,\n type SolverId,\n type SymmioChainConfig,\n type SymmioGaslessConfig,\n type SymmioGaslessStatusStreamConfig,\n type SymmioInventoryConfig,\n type SymmioListingConfig,\n type SymmioNotificationsConfig,\n type SymmioPriceServiceConfig,\n type SymmioSolverConfig,\n type SymmioTpSlConfig,\n} from \"../chains\";\n\n/**\n * Build the per-chain config registry a {@link Config} holds: every built-in\n * supported chain, deep-merged with the caller's overrides.\n *\n * @param overrides - Optional per-chain partial overrides keyed by chain id.\n * @returns A registry mapping chain id to its fully-resolved config.\n *\n * @internal\n */\nexport function buildChainConfigs(\n overrides?: Partial<Record<number, DeepPartial<SymmioChainConfig>>>,\n): Record<number, SymmioChainConfig> {\n const registry: Record<number, SymmioChainConfig> = {};\n\n for (const chainId of listSupportedChains()) {\n const base = getChainConfig(chainId);\n const override = overrides?.[chainId];\n registry[chainId] = override ? mergeChainConfig(base, override) : base;\n }\n\n return registry;\n}\n\n/**\n * Deep-merge a single chain's overrides onto its built-in defaults. Only the\n * known nested groups (`addresses`, `subgraphs`, `solvers`, `priceService`,\n * `notifications`, `muon`, `listing`, `inventory`, `gasless`) are merged; unknown keys are ignored.\n *\n * @internal\n */\nfunction mergeChainConfig(base: SymmioChainConfig, override: DeepPartial<SymmioChainConfig>): SymmioChainConfig {\n return {\n ...base,\n ...(override.chainId !== undefined ? { chainId: override.chainId } : {}),\n contractsVersion: override.contractsVersion ?? base.contractsVersion,\n addresses: { ...base.addresses, ...override.addresses },\n subgraphs: { ...base.subgraphs, ...override.subgraphs },\n solvers: mergeSolvers(base.chainId, base.solvers, override.solvers),\n defaultSolverId: override.defaultSolverId ?? base.defaultSolverId,\n priceService: mergePriceService(base.chainId, base.priceService, override.priceService),\n muon: {\n /** `urls` is replaced wholesale when overridden, otherwise inherited from base. */\n urls: override.muon?.urls ?? base.muon.urls,\n },\n ...mergeListing(base.listing, override.listing),\n ...mergeInventory(base.inventory, override.inventory),\n ...mergeGasless(base.chainId, base.gasless, override.gasless),\n };\n}\n\n/**\n * Merge a GaslessQ service override onto its base.\n *\n * Returns a partial so the key stays **absent** when neither side configures\n * the service (same invariant as {@link mergeListing}). With a base, fields\n * merge one by one and the nested `execution` and `statusStream` blocks\n * deep-merge. With no base, the override must be a complete block — `url` and\n * `gaslessLayerAddress` are both required, since there is nothing to inherit\n * them from and a half-built block would only fail later, at request time, with\n * a confusing error.\n *\n * @throws {SymmError} `GASLESS_OVERRIDE_INCOMPLETE` when a base-less override\n * omits `url` or `gaslessLayerAddress`, or when a `statusStream` sets\n * `origin` with no `enabled` to inherit.\n */\nfunction mergeGasless(\n chainId: number,\n base: SymmioGaslessConfig | undefined,\n override: DeepPartial<SymmioGaslessConfig> | undefined,\n): Pick<SymmioChainConfig, \"gasless\"> | Record<string, never> {\n if (!base && !override) return {};\n if (!override) return { gasless: base };\n\n const url = override.url ?? base?.url;\n const gaslessLayerAddress = override.gaslessLayerAddress ?? base?.gaslessLayerAddress;\n if (url === undefined || gaslessLayerAddress === undefined) {\n throw new SymmError(\n \"config\",\n \"GASLESS_OVERRIDE_INCOMPLETE\",\n `createConfig: the gasless override for chain ${chainId} must declare ${url === undefined ? \"`url`\" : \"`gaslessLayerAddress`\"} — there is no built-in gasless config to inherit it from.`,\n );\n }\n\n const execution =\n override.execution || base?.execution\n ? { ...(base?.execution ?? {}), ...((override.execution ?? {}) as GaslessExecutionConfig) }\n : undefined;\n\n const protocolInstance = override.protocolInstance ?? base?.protocolInstance;\n const apiKey = override.apiKey ?? base?.apiKey;\n const statusStream = mergeGaslessStatusStream(chainId, base?.statusStream, override.statusStream);\n\n return {\n gasless: {\n url,\n gaslessLayerAddress,\n ...(protocolInstance !== undefined ? { protocolInstance } : {}),\n ...(apiKey !== undefined ? { apiKey } : {}),\n ...(statusStream ? { statusStream } : {}),\n ...(execution ? { execution } : {}),\n },\n };\n}\n\n/**\n * Merge a gasless `statusStream` override onto its base, field by field, so an\n * override that restates only `origin` keeps the base's `enabled` (and an\n * explicit `undefined` never erases a base value).\n *\n * The block stays absent when neither side declares a field. `enabled` has no\n * default: an `origin` with nothing to inherit `enabled` from is a half-built\n * block, and silently reading it as \"disabled\" would hide the mistake.\n *\n * @throws {SymmError} `GASLESS_OVERRIDE_INCOMPLETE` when the merged block has\n * an `origin` but no `enabled`.\n */\nfunction mergeGaslessStatusStream(\n chainId: number,\n base?: SymmioGaslessStatusStreamConfig,\n override?: DeepPartial<SymmioGaslessStatusStreamConfig>,\n): SymmioGaslessStatusStreamConfig | undefined {\n const enabled = override?.enabled ?? base?.enabled;\n const origin = override?.origin ?? base?.origin;\n if (enabled === undefined) {\n if (origin === undefined) return undefined;\n throw new SymmError(\n \"config\",\n \"GASLESS_OVERRIDE_INCOMPLETE\",\n `createConfig: the gasless statusStream override for chain ${chainId} sets \\`origin\\` but not \\`enabled\\` — there is no statusStream block to inherit it from.`,\n );\n }\n return { enabled, ...(origin !== undefined ? { origin } : {}) };\n}\n\n/**\n * Merge an inventory-service override onto its base. Mirrors\n * {@link mergeListing}: returns a partial so the key stays **absent** when\n * neither side configures the service.\n */\nfunction mergeInventory(\n base: SymmioInventoryConfig | undefined,\n override: DeepPartial<SymmioInventoryConfig> | undefined,\n): Pick<SymmioChainConfig, \"inventory\"> | Record<string, never> {\n const url = override?.url ?? base?.url;\n return url === undefined ? {} : { inventory: { url } };\n}\n\n/**\n * Merge a listing-service override onto its base.\n *\n * Returns a partial so the key stays **absent** when neither side configures the\n * service — an explicit `listing: undefined` would still be an own property and\n * would read as \"configured but empty\" to anything doing a key check.\n */\nfunction mergeListing(\n base: SymmioListingConfig | undefined,\n override: DeepPartial<SymmioListingConfig> | undefined,\n): Pick<SymmioChainConfig, \"listing\"> | Record<string, never> {\n const url = override?.url ?? base?.url;\n return url === undefined ? {} : { listing: { url } };\n}\n\n/**\n * Merge a price-service override onto its base.\n *\n * A plain spread is wrong once more than one provider exists: an override that\n * switches `type` without restating both URLs would inherit the *previous*\n * provider's endpoints, pointing one provider's client at another's host. That\n * type-checks cleanly and fails at runtime as a confusing 404, so a `type` swap\n * is required to supply the whole block.\n *\n * A same-type (or type-less) override still merges field-by-field, so the common\n * `{ url, wsUrl }` staging override keeps working.\n *\n * @throws {SymmError} `PRICE_SERVICE_OVERRIDE_INCOMPLETE` when the override\n * changes `type` but omits `url` or `wsUrl`.\n */\nfunction mergePriceService(\n chainId: number,\n base: SymmioPriceServiceConfig,\n override: DeepPartial<SymmioPriceServiceConfig> | undefined,\n): SymmioPriceServiceConfig {\n if (!override) return base;\n\n const merged = { ...base, ...override } as SymmioPriceServiceConfig;\n const swapsProvider = override.type !== undefined && override.type !== base.type;\n if (swapsProvider && (override.url === undefined || override.wsUrl === undefined)) {\n throw new SymmError(\n \"config\",\n \"PRICE_SERVICE_OVERRIDE_INCOMPLETE\",\n `createConfig: the priceService override for chain ${chainId} changes type from \"${base.type}\" to \"${override.type}\" but omits ${override.url === undefined ? \"`url`\" : \"`wsUrl`\"}. Supply both URLs when switching provider — inheriting the previous provider's endpoints would point the \"${override.type}\" client at \"${base.type}\" hosts.`,\n );\n }\n return merged;\n}\n\n/**\n * Merge a notifications override onto its base.\n *\n * Same trap as {@link mergePriceService}: once the config is a per-protocol\n * union, an override that switches `protocol` without restating the endpoint\n * would inherit the *previous* protocol's fields — a `rasa → enigma` swap\n * without a `channel` (or either swap without a `url`) type-checks as a\n * `DeepPartial` and fails at runtime. So a `protocol` swap must supply the\n * whole block; a same-protocol override still merges field-by-field.\n *\n * A swap takes the override block **alone** — nothing is inherited, including\n * the optional `searchUrl` (the previous protocol's REST search service does\n * not index the new protocol's stream).\n *\n * @throws {SymmError} `NOTIFICATIONS_OVERRIDE_INCOMPLETE` when the override\n * changes `protocol` but omits `url`, or targets `enigma` without a\n * `channel`.\n */\nfunction mergeNotifications(\n chainId: number,\n base: SymmioNotificationsConfig,\n override: DeepPartial<SymmioNotificationsConfig> | undefined,\n): SymmioNotificationsConfig {\n if (!override) return base;\n\n const swapsProtocol = override.protocol !== undefined && override.protocol !== base.protocol;\n if (swapsProtocol) {\n const missing =\n override.url === undefined\n ? \"`url`\"\n : override.protocol === \"enigma\" && (override as { channel?: string }).channel === undefined\n ? \"`channel`\"\n : null;\n if (missing) {\n throw new SymmError(\n \"config\",\n \"NOTIFICATIONS_OVERRIDE_INCOMPLETE\",\n `createConfig: the notifications override for chain ${chainId} changes protocol from \"${base.protocol}\" to \"${override.protocol}\" but omits ${missing}. Supply the whole block when switching protocol — inheriting the previous protocol's fields would point the \"${override.protocol}\" subscriber at \"${base.protocol}\" endpoints.`,\n );\n }\n return { ...override } as SymmioNotificationsConfig;\n }\n\n const merged = { ...base, ...override } as SymmioNotificationsConfig;\n if (merged.protocol === \"rasa\") {\n // A cast override could still sneak a `channel` key onto the rasa variant.\n delete (merged as { channel?: string }).channel;\n }\n return merged;\n}\n\n/**\n * Merge a per-chain solver map by id: each overridden solver is deep-merged onto\n * its base (or added when the id is new). Solvers the override does not mention\n * are inherited unchanged.\n */\nfunction mergeSolvers(\n chainId: number,\n base: Partial<Record<SolverId, SymmioSolverConfig>>,\n override: DeepPartial<Record<SolverId, SymmioSolverConfig>> | undefined,\n): Partial<Record<SolverId, SymmioSolverConfig>> {\n if (!override) return base;\n const merged: Partial<Record<SolverId, SymmioSolverConfig>> = { ...base };\n for (const [id, solverOverride] of Object.entries(override) as [SolverId, DeepPartial<SymmioSolverConfig>][]) {\n if (!solverOverride) continue;\n merged[id] = mergeSolver(chainId, base[id], solverOverride);\n }\n return merged;\n}\n\n/**\n * Merge one solver's fields. The optional nested `tpsl` and `priceService` blocks\n * are deep-merged so a partial override (e.g. only the `url`) keeps the base's\n * other fields. When neither base nor override declares a block, it stays absent\n * — for `priceService` that absence is meaningful: it is what makes the solver\n * fall back to the chain-level price service.\n */\nfunction mergeSolver(\n chainId: number,\n base: SymmioSolverConfig | undefined,\n override: DeepPartial<SymmioSolverConfig>,\n): SymmioSolverConfig {\n const merged = { ...(base ?? {}), ...(override as Partial<SymmioSolverConfig>) } as SymmioSolverConfig;\n\n const overrideTpsl = override.tpsl;\n if (overrideTpsl) {\n merged.tpsl = {\n ...(base?.tpsl ?? ({} as SymmioTpSlConfig)),\n ...(overrideTpsl as Partial<SymmioTpSlConfig>),\n } as SymmioTpSlConfig;\n } else if (base?.tpsl) {\n merged.tpsl = base.tpsl;\n } else {\n delete merged.tpsl;\n }\n\n const overridePriceService = override.priceService;\n if (overridePriceService) {\n // With no base block there is nothing to inherit, so the override must be\n // complete — route it through the same type-swap guard by treating it as a\n // swap away from the base (or chain) provider.\n merged.priceService = base?.priceService\n ? mergePriceService(chainId, base.priceService, overridePriceService)\n : assertCompletePriceService(chainId, overridePriceService);\n } else if (base?.priceService) {\n merged.priceService = base.priceService;\n } else {\n delete merged.priceService;\n }\n\n const overrideNotifications = override.notifications;\n if (overrideNotifications) {\n // With a base solver, deep-merge (same protocol-swap guard as the chain path\n // used to apply). With no base, the override must be a complete block.\n merged.notifications = base?.notifications\n ? mergeNotifications(chainId, base.notifications, overrideNotifications)\n : assertCompleteNotifications(chainId, overrideNotifications);\n } else if (base?.notifications) {\n merged.notifications = base.notifications;\n } else {\n throw new SymmError(\n \"config\",\n \"SOLVER_NOTIFICATIONS_REQUIRED\",\n `createConfig: a new solver on chain ${chainId} added via symmioConfig must declare a \\`notifications\\` block — it is required per solver and there is no base to inherit it from.`,\n );\n }\n\n const overrideCapabilities = override.capabilities;\n if (overrideCapabilities) {\n merged.capabilities = {\n ...(base?.capabilities ?? {}),\n ...(overrideCapabilities as SolverCapabilitiesConfig),\n };\n } else if (base?.capabilities) {\n merged.capabilities = base.capabilities;\n } else {\n delete merged.capabilities;\n }\n\n return merged;\n}\n\n/**\n * Validate a solver-nested price service that has no base to inherit from: every\n * field must be present, since there is nothing to fall back to.\n *\n * @throws {SymmError} `PRICE_SERVICE_OVERRIDE_INCOMPLETE`\n */\nfunction assertCompletePriceService(\n chainId: number,\n override: DeepPartial<SymmioPriceServiceConfig>,\n): SymmioPriceServiceConfig {\n if (override.type === undefined || override.url === undefined || override.wsUrl === undefined) {\n throw new SymmError(\n \"config\",\n \"PRICE_SERVICE_OVERRIDE_INCOMPLETE\",\n `createConfig: a solver-nested priceService on chain ${chainId} must declare \\`type\\`, \\`url\\` and \\`wsUrl\\` — there is no per-solver base to inherit the missing fields from. Omit the block entirely to fall back to the chain's price service.`,\n );\n }\n return override as SymmioPriceServiceConfig;\n}\n\n/**\n * Validate a solver-nested notifications block that has no base to inherit from\n * (a brand-new solver added via `symmioConfig`): `url` and `protocol` are always\n * required, and `enigma` additionally requires a `channel`.\n *\n * @throws {SymmError} `NOTIFICATIONS_OVERRIDE_INCOMPLETE`\n */\nfunction assertCompleteNotifications(\n chainId: number,\n override: DeepPartial<SymmioNotificationsConfig>,\n): SymmioNotificationsConfig {\n const missing =\n override.url === undefined\n ? \"`url`\"\n : override.protocol === undefined\n ? \"`protocol`\"\n : override.protocol === \"enigma\" && (override as { channel?: string }).channel === undefined\n ? \"`channel`\"\n : null;\n if (missing) {\n throw new SymmError(\n \"config\",\n \"NOTIFICATIONS_OVERRIDE_INCOMPLETE\",\n `createConfig: a solver-nested notifications block on chain ${chainId} must declare ${missing} — there is no per-solver base to inherit the missing fields from.`,\n );\n }\n return override as SymmioNotificationsConfig;\n}\n"],"mappings":";;;;AA4BA,SAAgB,EACd,GACmC;CACnC,IAAM,IAA8C,CAAC;CAErD,KAAK,IAAM,KAAW,EAAoB,GAAG;EAC3C,IAAM,IAAO,EAAe,CAAO,GAC7B,IAAW,IAAY;EAC7B,EAAS,KAAW,IAAW,EAAiB,GAAM,CAAQ,IAAI;CACpE;CAEA,OAAO;AACT;AASA,SAAS,EAAiB,GAAyB,GAA6D;CAC9G,OAAO;EACL,GAAG;EACH,GAAI,EAAS,YAAY,KAAA,IAA4C,CAAC,IAAjC,EAAE,SAAS,EAAS,QAAQ;EACjE,kBAAkB,EAAS,oBAAoB,EAAK;EACpD,WAAW;GAAE,GAAG,EAAK;GAAW,GAAG,EAAS;EAAU;EACtD,WAAW;GAAE,GAAG,EAAK;GAAW,GAAG,EAAS;EAAU;EACtD,SAAS,EAAa,EAAK,SAAS,EAAK,SAAS,EAAS,OAAO;EAClE,iBAAiB,EAAS,mBAAmB,EAAK;EAClD,cAAc,EAAkB,EAAK,SAAS,EAAK,cAAc,EAAS,YAAY;EACtF,MAAM,EAEJ,MAAM,EAAS,MAAM,QAAQ,EAAK,KAAK,KACzC;EACA,GAAG,EAAa,EAAK,SAAS,EAAS,OAAO;EAC9C,GAAG,EAAe,EAAK,WAAW,EAAS,SAAS;EACpD,GAAG,EAAa,EAAK,SAAS,EAAK,SAAS,EAAS,OAAO;CAC9D;AACF;AAiBA,SAAS,EACP,GACA,GACA,GAC4D;CAC5D,IAAI,CAAC,KAAQ,CAAC,GAAU,OAAO,CAAC;CAChC,IAAI,CAAC,GAAU,OAAO,EAAE,SAAS,EAAK;CAEtC,IAAM,I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mEAChG;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"merge-chain-config.js","names":[],"sources":["../../../src/core/config/merge-chain-config.ts"],"sourcesContent":["import { SymmError } from \"../../shared/errors/symm-error\";\nimport type { DeepPartial } from \"../../shared/types/properties\";\nimport {\n getChainConfig,\n listSupportedChains,\n type GaslessExecutionConfig,\n type SolverCapabilitiesConfig,\n type SolverId,\n type SymmioChainConfig,\n type SymmioGaslessConfig,\n type SymmioGaslessStatusStreamConfig,\n type SymmioInventoryConfig,\n type SymmioListingConfig,\n type SymmioNotificationsConfig,\n type SymmioPriceServiceConfig,\n type SymmioSolverConfig,\n type SymmioTpSlConfig,\n} from \"../chains\";\n\n/**\n * Build the per-chain config registry a {@link Config} holds: every built-in\n * supported chain, deep-merged with the caller's overrides.\n *\n * @param overrides - Optional per-chain partial overrides keyed by chain id.\n * @returns A registry mapping chain id to its fully-resolved config.\n *\n * @internal\n */\nexport function buildChainConfigs(\n overrides?: Partial<Record<number, DeepPartial<SymmioChainConfig>>>,\n): Record<number, SymmioChainConfig> {\n const registry: Record<number, SymmioChainConfig> = {};\n\n for (const chainId of listSupportedChains()) {\n const base = getChainConfig(chainId);\n const override = overrides?.[chainId];\n registry[chainId] = override ? mergeChainConfig(base, override) : base;\n }\n\n return registry;\n}\n\n/**\n * Deep-merge a single chain's overrides onto its built-in defaults. Only the\n * known nested groups (`addresses`, `subgraphs`, `solvers`, `priceService`,\n * `notifications`, `muon`, `listing`, `inventory`, `gasless`) are merged; unknown keys are ignored.\n *\n * @internal\n */\nfunction mergeChainConfig(base: SymmioChainConfig, override: DeepPartial<SymmioChainConfig>): SymmioChainConfig {\n const accountLayerChanged =\n override.addresses?.accountLayerAddress !== undefined &&\n override.addresses.accountLayerAddress.toLowerCase() !== base.addresses.accountLayerAddress.toLowerCase();\n const { timelockSupported: baseTimelockSupported, ...baseWithoutTimelockSupport } = base;\n const timelockSupported = override.timelockSupported ?? (accountLayerChanged ? undefined : baseTimelockSupported);\n return {\n ...baseWithoutTimelockSupport,\n ...(override.chainId !== undefined ? { chainId: override.chainId } : {}),\n contractsVersion: override.contractsVersion ?? base.contractsVersion,\n ...(timelockSupported !== undefined ? { timelockSupported } : {}),\n addresses: { ...base.addresses, ...override.addresses },\n subgraphs: { ...base.subgraphs, ...override.subgraphs },\n solvers: mergeSolvers(base.chainId, base.solvers, override.solvers),\n defaultSolverId: override.defaultSolverId ?? base.defaultSolverId,\n priceService: mergePriceService(base.chainId, base.priceService, override.priceService),\n muon: {\n /** `urls` is replaced wholesale when overridden, otherwise inherited from base. */\n urls: override.muon?.urls ?? base.muon.urls,\n },\n ...mergeListing(base.listing, override.listing),\n ...mergeInventory(base.inventory, override.inventory),\n ...mergeGasless(base.chainId, base.gasless, override.gasless),\n };\n}\n\n/**\n * Merge a GaslessQ service override onto its base.\n *\n * Returns a partial so the key stays **absent** when neither side configures\n * the service (same invariant as {@link mergeListing}). With a base, fields\n * merge one by one and the nested `execution` and `statusStream` blocks\n * deep-merge. With no base, the override must be a complete block — `url` and\n * `gaslessLayerAddress` are both required, since there is nothing to inherit\n * them from and a half-built block would only fail later, at request time, with\n * a confusing error.\n *\n * @throws {SymmError} `GASLESS_OVERRIDE_INCOMPLETE` when a base-less override\n * omits `url` or `gaslessLayerAddress`, or when a `statusStream` sets\n * `origin` with no `enabled` to inherit.\n */\nfunction mergeGasless(\n chainId: number,\n base: SymmioGaslessConfig | undefined,\n override: DeepPartial<SymmioGaslessConfig> | undefined,\n): Pick<SymmioChainConfig, \"gasless\"> | Record<string, never> {\n if (!base && !override) return {};\n if (!override) return { gasless: base };\n\n const url = override.url ?? base?.url;\n const gaslessLayerAddress = override.gaslessLayerAddress ?? base?.gaslessLayerAddress;\n if (url === undefined || gaslessLayerAddress === undefined) {\n throw new SymmError(\n \"config\",\n \"GASLESS_OVERRIDE_INCOMPLETE\",\n `createConfig: the gasless override for chain ${chainId} must declare ${url === undefined ? \"`url`\" : \"`gaslessLayerAddress`\"} — there is no built-in gasless config to inherit it from.`,\n );\n }\n\n const execution =\n override.execution || base?.execution\n ? { ...(base?.execution ?? {}), ...((override.execution ?? {}) as GaslessExecutionConfig) }\n : undefined;\n\n const protocolInstance = override.protocolInstance ?? base?.protocolInstance;\n const apiKey = override.apiKey ?? base?.apiKey;\n const getRequestHeaders = override.getRequestHeaders ?? base?.getRequestHeaders;\n const statusStream = mergeGaslessStatusStream(chainId, base?.statusStream, override.statusStream);\n\n return {\n gasless: {\n url,\n gaslessLayerAddress,\n ...(protocolInstance !== undefined ? { protocolInstance } : {}),\n ...(apiKey !== undefined ? { apiKey } : {}),\n ...(getRequestHeaders !== undefined ? { getRequestHeaders } : {}),\n ...(statusStream ? { statusStream } : {}),\n ...(execution ? { execution } : {}),\n },\n };\n}\n\n/**\n * Merge a gasless `statusStream` override onto its base, field by field, so an\n * override that restates only `origin` keeps the base's `enabled` (and an\n * explicit `undefined` never erases a base value).\n *\n * The block stays absent when neither side declares a field. `enabled` has no\n * default: an `origin` with nothing to inherit `enabled` from is a half-built\n * block, and silently reading it as \"disabled\" would hide the mistake.\n *\n * @throws {SymmError} `GASLESS_OVERRIDE_INCOMPLETE` when the merged block has\n * an `origin` but no `enabled`.\n */\nfunction mergeGaslessStatusStream(\n chainId: number,\n base?: SymmioGaslessStatusStreamConfig,\n override?: DeepPartial<SymmioGaslessStatusStreamConfig>,\n): SymmioGaslessStatusStreamConfig | undefined {\n const enabled = override?.enabled ?? base?.enabled;\n const origin = override?.origin ?? base?.origin;\n if (enabled === undefined) {\n if (origin === undefined) return undefined;\n throw new SymmError(\n \"config\",\n \"GASLESS_OVERRIDE_INCOMPLETE\",\n `createConfig: the gasless statusStream override for chain ${chainId} sets \\`origin\\` but not \\`enabled\\` — there is no statusStream block to inherit it from.`,\n );\n }\n return { enabled, ...(origin !== undefined ? { origin } : {}) };\n}\n\n/**\n * Merge an inventory-service override onto its base. Mirrors\n * {@link mergeListing}: returns a partial so the key stays **absent** when\n * neither side configures the service.\n */\nfunction mergeInventory(\n base: SymmioInventoryConfig | undefined,\n override: DeepPartial<SymmioInventoryConfig> | undefined,\n): Pick<SymmioChainConfig, \"inventory\"> | Record<string, never> {\n const url = override?.url ?? base?.url;\n return url === undefined ? {} : { inventory: { url } };\n}\n\n/**\n * Merge a listing-service override onto its base.\n *\n * Returns a partial so the key stays **absent** when neither side configures the\n * service — an explicit `listing: undefined` would still be an own property and\n * would read as \"configured but empty\" to anything doing a key check.\n */\nfunction mergeListing(\n base: SymmioListingConfig | undefined,\n override: DeepPartial<SymmioListingConfig> | undefined,\n): Pick<SymmioChainConfig, \"listing\"> | Record<string, never> {\n const url = override?.url ?? base?.url;\n return url === undefined ? {} : { listing: { url } };\n}\n\n/**\n * Merge a price-service override onto its base.\n *\n * A plain spread is wrong once more than one provider exists: an override that\n * switches `type` without restating both URLs would inherit the *previous*\n * provider's endpoints, pointing one provider's client at another's host. That\n * type-checks cleanly and fails at runtime as a confusing 404, so a `type` swap\n * is required to supply the whole block.\n *\n * A same-type (or type-less) override still merges field-by-field, so the common\n * `{ url, wsUrl }` staging override keeps working.\n *\n * @throws {SymmError} `PRICE_SERVICE_OVERRIDE_INCOMPLETE` when the override\n * changes `type` but omits `url` or `wsUrl`.\n */\nfunction mergePriceService(\n chainId: number,\n base: SymmioPriceServiceConfig,\n override: DeepPartial<SymmioPriceServiceConfig> | undefined,\n): SymmioPriceServiceConfig {\n if (!override) return base;\n\n const merged = { ...base, ...override } as SymmioPriceServiceConfig;\n const swapsProvider = override.type !== undefined && override.type !== base.type;\n if (swapsProvider && (override.url === undefined || override.wsUrl === undefined)) {\n throw new SymmError(\n \"config\",\n \"PRICE_SERVICE_OVERRIDE_INCOMPLETE\",\n `createConfig: the priceService override for chain ${chainId} changes type from \"${base.type}\" to \"${override.type}\" but omits ${override.url === undefined ? \"`url`\" : \"`wsUrl`\"}. Supply both URLs when switching provider — inheriting the previous provider's endpoints would point the \"${override.type}\" client at \"${base.type}\" hosts.`,\n );\n }\n return merged;\n}\n\n/**\n * Merge a notifications override onto its base.\n *\n * Same trap as {@link mergePriceService}: once the config is a per-protocol\n * union, an override that switches `protocol` without restating the endpoint\n * would inherit the *previous* protocol's fields — a `rasa → enigma` swap\n * without a `channel` (or either swap without a `url`) type-checks as a\n * `DeepPartial` and fails at runtime. So a `protocol` swap must supply the\n * whole block; a same-protocol override still merges field-by-field.\n *\n * A swap takes the override block **alone** — nothing is inherited, including\n * the optional `searchUrl` (the previous protocol's REST search service does\n * not index the new protocol's stream).\n *\n * @throws {SymmError} `NOTIFICATIONS_OVERRIDE_INCOMPLETE` when the override\n * changes `protocol` but omits `url`, or targets `enigma` without a\n * `channel`.\n */\nfunction mergeNotifications(\n chainId: number,\n base: SymmioNotificationsConfig,\n override: DeepPartial<SymmioNotificationsConfig> | undefined,\n): SymmioNotificationsConfig {\n if (!override) return base;\n\n const swapsProtocol = override.protocol !== undefined && override.protocol !== base.protocol;\n if (swapsProtocol) {\n const missing =\n override.url === undefined\n ? \"`url`\"\n : override.protocol === \"enigma\" && (override as { channel?: string }).channel === undefined\n ? \"`channel`\"\n : null;\n if (missing) {\n throw new SymmError(\n \"config\",\n \"NOTIFICATIONS_OVERRIDE_INCOMPLETE\",\n `createConfig: the notifications override for chain ${chainId} changes protocol from \"${base.protocol}\" to \"${override.protocol}\" but omits ${missing}. Supply the whole block when switching protocol — inheriting the previous protocol's fields would point the \"${override.protocol}\" subscriber at \"${base.protocol}\" endpoints.`,\n );\n }\n return { ...override } as SymmioNotificationsConfig;\n }\n\n const merged = { ...base, ...override } as SymmioNotificationsConfig;\n if (merged.protocol === \"rasa\") {\n // A cast override could still sneak a `channel` key onto the rasa variant.\n delete (merged as { channel?: string }).channel;\n }\n return merged;\n}\n\n/**\n * Merge a per-chain solver map by id: each overridden solver is deep-merged onto\n * its base (or added when the id is new). Solvers the override does not mention\n * are inherited unchanged.\n */\nfunction mergeSolvers(\n chainId: number,\n base: Partial<Record<SolverId, SymmioSolverConfig>>,\n override: DeepPartial<Record<SolverId, SymmioSolverConfig>> | undefined,\n): Partial<Record<SolverId, SymmioSolverConfig>> {\n if (!override) return base;\n const merged: Partial<Record<SolverId, SymmioSolverConfig>> = { ...base };\n for (const [id, solverOverride] of Object.entries(override) as [SolverId, DeepPartial<SymmioSolverConfig>][]) {\n if (!solverOverride) continue;\n merged[id] = mergeSolver(chainId, base[id], solverOverride);\n }\n return merged;\n}\n\n/**\n * Merge one solver's fields. The optional nested `tpsl` and `priceService` blocks\n * are deep-merged so a partial override (e.g. only the `url`) keeps the base's\n * other fields. When neither base nor override declares a block, it stays absent\n * — for `priceService` that absence is meaningful: it is what makes the solver\n * fall back to the chain-level price service.\n */\nfunction mergeSolver(\n chainId: number,\n base: SymmioSolverConfig | undefined,\n override: DeepPartial<SymmioSolverConfig>,\n): SymmioSolverConfig {\n const merged = { ...(base ?? {}), ...(override as Partial<SymmioSolverConfig>) } as SymmioSolverConfig;\n\n const overrideTpsl = override.tpsl;\n if (overrideTpsl) {\n merged.tpsl = {\n ...(base?.tpsl ?? ({} as SymmioTpSlConfig)),\n ...(overrideTpsl as Partial<SymmioTpSlConfig>),\n } as SymmioTpSlConfig;\n } else if (base?.tpsl) {\n merged.tpsl = base.tpsl;\n } else {\n delete merged.tpsl;\n }\n\n const overridePriceService = override.priceService;\n if (overridePriceService) {\n // With no base block there is nothing to inherit, so the override must be\n // complete — route it through the same type-swap guard by treating it as a\n // swap away from the base (or chain) provider.\n merged.priceService = base?.priceService\n ? mergePriceService(chainId, base.priceService, overridePriceService)\n : assertCompletePriceService(chainId, overridePriceService);\n } else if (base?.priceService) {\n merged.priceService = base.priceService;\n } else {\n delete merged.priceService;\n }\n\n const overrideNotifications = override.notifications;\n if (overrideNotifications) {\n // With a base solver, deep-merge (same protocol-swap guard as the chain path\n // used to apply). With no base, the override must be a complete block.\n merged.notifications = base?.notifications\n ? mergeNotifications(chainId, base.notifications, overrideNotifications)\n : assertCompleteNotifications(chainId, overrideNotifications);\n } else if (base?.notifications) {\n merged.notifications = base.notifications;\n } else {\n throw new SymmError(\n \"config\",\n \"SOLVER_NOTIFICATIONS_REQUIRED\",\n `createConfig: a new solver on chain ${chainId} added via symmioConfig must declare a \\`notifications\\` block — it is required per solver and there is no base to inherit it from.`,\n );\n }\n\n const overrideCapabilities = override.capabilities;\n if (overrideCapabilities) {\n merged.capabilities = {\n ...(base?.capabilities ?? {}),\n ...(overrideCapabilities as SolverCapabilitiesConfig),\n };\n } else if (base?.capabilities) {\n merged.capabilities = base.capabilities;\n } else {\n delete merged.capabilities;\n }\n\n return merged;\n}\n\n/**\n * Validate a solver-nested price service that has no base to inherit from: every\n * field must be present, since there is nothing to fall back to.\n *\n * @throws {SymmError} `PRICE_SERVICE_OVERRIDE_INCOMPLETE`\n */\nfunction assertCompletePriceService(\n chainId: number,\n override: DeepPartial<SymmioPriceServiceConfig>,\n): SymmioPriceServiceConfig {\n if (override.type === undefined || override.url === undefined || override.wsUrl === undefined) {\n throw new SymmError(\n \"config\",\n \"PRICE_SERVICE_OVERRIDE_INCOMPLETE\",\n `createConfig: a solver-nested priceService on chain ${chainId} must declare \\`type\\`, \\`url\\` and \\`wsUrl\\` — there is no per-solver base to inherit the missing fields from. Omit the block entirely to fall back to the chain's price service.`,\n );\n }\n return override as SymmioPriceServiceConfig;\n}\n\n/**\n * Validate a solver-nested notifications block that has no base to inherit from\n * (a brand-new solver added via `symmioConfig`): `url` and `protocol` are always\n * required, and `enigma` additionally requires a `channel`.\n *\n * @throws {SymmError} `NOTIFICATIONS_OVERRIDE_INCOMPLETE`\n */\nfunction assertCompleteNotifications(\n chainId: number,\n override: DeepPartial<SymmioNotificationsConfig>,\n): SymmioNotificationsConfig {\n const missing =\n override.url === undefined\n ? \"`url`\"\n : override.protocol === undefined\n ? \"`protocol`\"\n : override.protocol === \"enigma\" && (override as { channel?: string }).channel === undefined\n ? \"`channel`\"\n : null;\n if (missing) {\n throw new SymmError(\n \"config\",\n \"NOTIFICATIONS_OVERRIDE_INCOMPLETE\",\n `createConfig: a solver-nested notifications block on chain ${chainId} must declare ${missing} — there is no per-solver base to inherit the missing fields from.`,\n );\n }\n return override as SymmioNotificationsConfig;\n}\n"],"mappings":";;;;AA4BA,SAAgB,EACd,GACmC;CACnC,IAAM,IAA8C,CAAC;CAErD,KAAK,IAAM,KAAW,EAAoB,GAAG;EAC3C,IAAM,IAAO,EAAe,CAAO,GAC7B,IAAW,IAAY;EAC7B,EAAS,KAAW,IAAW,EAAiB,GAAM,CAAQ,IAAI;CACpE;CAEA,OAAO;AACT;AASA,SAAS,EAAiB,GAAyB,GAA6D;CAC9G,IAAM,IACJ,EAAS,WAAW,wBAAwB,KAAA,KAC5C,EAAS,UAAU,oBAAoB,YAAY,MAAM,EAAK,UAAU,oBAAoB,YAAY,GACpG,EAAE,mBAAmB,GAAuB,GAAG,MAA+B,GAC9E,IAAoB,EAAS,sBAAsB,IAAsB,KAAA,IAAY;CAC3F,OAAO;EACL,GAAG;EACH,GAAI,EAAS,YAAY,KAAA,IAA4C,CAAC,IAAjC,EAAE,SAAS,EAAS,QAAQ;EACjE,kBAAkB,EAAS,oBAAoB,EAAK;EACpD,GAAI,MAAsB,KAAA,IAAoC,CAAC,IAAzB,EAAE,qBAAkB;EAC1D,WAAW;GAAE,GAAG,EAAK;GAAW,GAAG,EAAS;EAAU;EACtD,WAAW;GAAE,GAAG,EAAK;GAAW,GAAG,EAAS;EAAU;EACtD,SAAS,EAAa,EAAK,SAAS,EAAK,SAAS,EAAS,OAAO;EAClE,iBAAiB,EAAS,mBAAmB,EAAK;EAClD,cAAc,EAAkB,EAAK,SAAS,EAAK,cAAc,EAAS,YAAY;EACtF,MAAM,EAEJ,MAAM,EAAS,MAAM,QAAQ,EAAK,KAAK,KACzC;EACA,GAAG,EAAa,EAAK,SAAS,EAAS,OAAO;EAC9C,GAAG,EAAe,EAAK,WAAW,EAAS,SAAS;EACpD,GAAG,EAAa,EAAK,SAAS,EAAK,SAAS,EAAS,OAAO;CAC9D;AACF;AAiBA,SAAS,EACP,GACA,GACA,GAC4D;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,GAC2B;CAC3B,IAAM,IACJ,EAAS,QAAQ,KAAA,IACb,UACA,EAAS,aAAa,KAAA,IACpB,eACA,EAAS,aAAa,YAAa,EAAkC,YAAY,KAAA,IAC/E,cACA;CACV,IAAI,GACF,MAAM,IAAI,EACR,UACA,qCACA,8DAA8D,EAAQ,gBAAgB,EAAQ,mEAChG;CAEF,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { Abi, Hex } from 'viem';
1
+ import { Abi, Address, Hex } from 'viem';
2
2
  import { GaslessWalletCall } from '../gasless-wallet-execute/calls.js';
3
3
  /**
4
4
  * A relayable write named by its function, which the SDK encodes with viem's
@@ -23,11 +23,20 @@ export interface GaslessBatchContractCall {
23
23
  functionName: string;
24
24
  /** Arguments for `functionName`, in order. Omit for a no-argument function. */
25
25
  args?: readonly unknown[];
26
+ /**
27
+ * Who signs this call. Defaults to the batch's `from` (or the connected
28
+ * wallet). Give it to mix signers in one batch, for example a session key
29
+ * signing a call that an owner-signed grant earlier in the same batch
30
+ * authorizes.
31
+ */
32
+ from?: Address;
26
33
  }
27
34
  /** A relayable write given as raw calldata; its selector decides the target contract. */
28
35
  export interface GaslessBatchRawCall {
29
36
  /** Calldata of a relayable write. */
30
37
  data: Hex;
38
+ /** Who signs this call. Defaults to the batch's `from` (or the connected wallet). */
39
+ from?: Address;
31
40
  }
32
41
  /**
33
42
  * A GaslessWallet `execute` entry: several calls the owner's deterministic
@@ -46,6 +55,11 @@ export interface GaslessBatchWalletExecute {
46
55
  * balance and nonce stream.
47
56
  */
48
57
  walletId?: bigint;
58
+ /**
59
+ * Who signs this wallet operation. Defaults to the batch's `from`, then the
60
+ * configured wallet. The wallet contract still executes the inner calls.
61
+ */
62
+ from?: Address;
49
63
  }
50
64
  /**
51
65
  * One entry of a gasless batch: a relayable write — an ABI-level call
@@ -93,17 +107,17 @@ export declare function gaslessCallDataSelector(callData: Hex): Hex;
93
107
  * The selectors a gasless batch runs — the delegation set a session key must
94
108
  * hold to relay it on the batch's account: each relayable write's selector, and
95
109
  * for every GaslessWallet entry the wallet-execution sentinel plus each inner
96
- * call's selector. Lowercased and de-duplicated in first-seen order, because
97
- * `grantDelegation` rejects a duplicate-bearing array.
110
+ * call's selector. Lowercased and de-duplicated in first-seen order.
98
111
  *
99
112
  * Selectors come from the **encoded** calldata, so an overloaded ABI resolves to
100
113
  * the function that will actually run.
101
114
  *
102
- * A batch that contains `grantDelegation` must be owner-signed whatever this
103
- * returns: the InstantLayer rejects a delegate-signed grant, so no delegation
104
- * makes it relayable by a session key.
115
+ * For a mixed-signer batch, pass only the calls the delegate signs. This helper
116
+ * collects selectors without resolving `from`. A `grantDelegation` or
117
+ * `grantDelegations` entry must itself be owner-signed: no delegation makes a
118
+ * grant relayable by a session key.
105
119
  *
106
- * @param calls - The batch, in any order.
120
+ * @param calls - The calls signed by the delegate, in any order.
107
121
  * @returns The selector set, as `bytes4` hex.
108
122
  * @throws Viem's encoding error when an ABI-level call does not encode.
109
123
  *
@@ -1 +1 @@
1
- {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../../../src/gasless/batch/calls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,GAAG,EAAoB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAE7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAIzE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,wBAAwB;IACvC,4GAA4G;IAC5G,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,OAAO,EAAE,CAAC;IAC/B,8FAA8F;IAC9F,YAAY,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CAC3B;AAED,yFAAyF;AACzF,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,IAAI,EAAE,GAAG,CAAC;CACX;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,2GAA2G;IAC3G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,CAAC;IACV,qFAAqF;IACrF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,2GAA2G;IAC3G,WAAW,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,gBAAgB,GAAG,wBAAwB,GAAG,mBAAmB,GAAG,yBAAyB,CAAC;AAE1G;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,IAAI,yBAAyB,CAErG;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,wBAAwB,GAAG,mBAAmB,GAAG,GAAG,CAI9F;AAcD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,CAE1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,GAAG,SAAS,GAAG,EAAE,CAmB3F"}
@@ -1,36 +1,37 @@
1
1
  import { SymmError as e } from "../../shared/errors/symm-error.js";
2
2
  import { GASLESS_RELAYABLE_FUNCTIONS as t } from "../relayable-writes.js";
3
- import { getGaslessWalletExecuteSelectors as n } from "../gasless-wallet-execute/selectors.js";
4
- import { encodeFunctionData as r, size as i, slice as a } from "viem";
3
+ import { getEffectiveInstantSelectors as n } from "../effective-instant-selectors.js";
4
+ import { getGaslessWalletExecuteSelectors as r } from "../gasless-wallet-execute/selectors.js";
5
+ import { encodeFunctionData as i, size as a, slice as o } from "viem";
5
6
  //#region src/gasless/batch/calls.ts
6
- function o(e) {
7
+ function s(e) {
7
8
  return "walletCalls" in e;
8
9
  }
9
- function s(e) {
10
- return "data" in e ? e.data : r({
11
- abi: e.abi ?? [c(e.functionName)],
10
+ function c(e) {
11
+ return "data" in e ? e.data : i({
12
+ abi: e.abi ?? [l(e.functionName)],
12
13
  functionName: e.functionName,
13
14
  args: e.args
14
15
  });
15
16
  }
16
- function c(n) {
17
+ function l(n) {
17
18
  let r = t.get(n);
18
19
  if (!r) throw new e("validation", "GASLESS_NOT_RELAYABLE", `Gasless: no relayable write is named "${n}". A batch carries the writes in GASLESS_RELAYABLE_SELECTORS; run any other call from the GaslessWallet as a \`walletCalls\` entry.`);
19
20
  return r;
20
21
  }
21
- function l(e) {
22
- return (i(e) < 4 ? "0x00000000" : a(e, 0, 4)).toLowerCase();
23
- }
24
22
  function u(e) {
25
- let t = /* @__PURE__ */ new Set(), r = [], i = (e) => {
23
+ return (a(e) < 4 ? "0x00000000" : o(e, 0, 4)).toLowerCase();
24
+ }
25
+ function d(e) {
26
+ let t = /* @__PURE__ */ new Set(), i = [], a = (e) => {
26
27
  let n = e.toLowerCase();
27
- t.has(n) || (t.add(n), r.push(n));
28
+ t.has(n) || (t.add(n), i.push(n));
28
29
  };
29
- for (let t of e) if (o(t)) for (let e of n(t.walletCalls)) i(e);
30
- else i(l(s(t)));
31
- return r;
30
+ for (let t of e) if (s(t)) for (let e of r(t.walletCalls)) a(e);
31
+ else for (let e of n(c(t))) a(e);
32
+ return i;
32
33
  }
33
34
  //#endregion
34
- export { s as gaslessBatchCallData, l as gaslessCallDataSelector, u as getGaslessBatchSelectors, o as isGaslessBatchWalletExecute };
35
+ export { c as gaslessBatchCallData, u as gaslessCallDataSelector, d as getGaslessBatchSelectors, s as isGaslessBatchWalletExecute };
35
36
 
36
37
  //# sourceMappingURL=calls.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"calls.js","names":[],"sources":["../../../src/gasless/batch/calls.ts"],"sourcesContent":["import { encodeFunctionData, size, slice, type Abi, type AbiFunction, type Hex } from \"viem\";\nimport { SymmError } from \"../../shared/errors/symm-error\";\nimport type { GaslessWalletCall } from \"../gasless-wallet-execute/calls\";\nimport { getGaslessWalletExecuteSelectors } from \"../gasless-wallet-execute/selectors\";\nimport { GASLESS_RELAYABLE_FUNCTIONS } from \"../relayable-writes\";\n\n/**\n * A relayable write named by its function, which the SDK encodes with viem's\n * `encodeFunctionData` — that throws on an arity or type mismatch, before any\n * signature prompt or network call.\n *\n * The target contract is **not** given: the SDK resolves it from the encoded\n * selector (the core diamond, the AccountLayer or the InstantLayer). The `abi`\n * is optional too — every relayable write is a known SYMMIO function, so\n * `{ functionName: \"allocate\", args: [amount] }` is enough. Pass an `abi` (the\n * SDK's own `symmioAbi`, `accountLayerAbi` or `instantLayerAbi`) when you\n * already hold it; the selector must still be a relayable write.\n *\n * `args` is deliberately `readonly unknown[]`, as for `GaslessWalletContractCall`.\n * When you want compile-time-checked arguments, encode with viem yourself and\n * pass the result as a {@link GaslessBatchRawCall}.\n */\nexport interface GaslessBatchContractCall {\n /** ABI containing `functionName`. Omit it to use the SDK's own ABI for the relayable write of that name. */\n abi?: Abi | readonly unknown[];\n /** The relayable write to run — `\"allocate\"`, `\"initiateWithdraw\"`, `\"grantDelegation\"`, … */\n functionName: string;\n /** Arguments for `functionName`, in order. Omit for a no-argument function. */\n args?: readonly unknown[];\n}\n\n/** A relayable write given as raw calldata; its selector decides the target contract. */\nexport interface GaslessBatchRawCall {\n /** Calldata of a relayable write. */\n data: Hex;\n}\n\n/**\n * A GaslessWallet `execute` entry: several calls the owner's deterministic\n * wallet makes, authorized by **one** gateway-domain signature.\n *\n * The calls run **as the wallet contract**, not as the SYMMIO account — use it to\n * move the wallet's own tokens (an ERC-20 `approve` followed by a bridge call,\n * say), exactly as with `gaslessWalletExecute`.\n */\nexport interface GaslessBatchWalletExecute {\n /** The calls the wallet makes, in order. Each is raw `data` or an `{ abi, functionName, args }` triple. */\n walletCalls: readonly GaslessWalletCall[];\n /**\n * Which of the owner's GaslessWallets makes them. Defaults to `0n`, the\n * original wallet. Each id is an independent wallet with its own address,\n * balance and nonce stream.\n */\n walletId?: bigint;\n}\n\n/**\n * One entry of a gasless batch: a relayable write — an ABI-level call\n * ({@link GaslessBatchContractCall}) or raw calldata ({@link GaslessBatchRawCall}) —\n * or a GaslessWallet `execute` ({@link GaslessBatchWalletExecute}). The forms mix\n * freely in one batch.\n *\n * @example\n * ```ts\n * import type { GaslessBatchCall } from \"@symmio/trading-core\";\n * import { erc20Abi } from \"viem\";\n *\n * const calls: GaslessBatchCall[] = [\n * { functionName: \"allocate\", args: [amount] },\n * { walletId: 1n, walletCalls: [{ target: usdc, abi: erc20Abi, functionName: \"transfer\", args: [to, value] }] },\n * ];\n * ```\n */\nexport type GaslessBatchCall = GaslessBatchContractCall | GaslessBatchRawCall | GaslessBatchWalletExecute;\n\n/**\n * Whether a batch entry is a GaslessWallet `execute`.\n *\n * @internal\n */\nexport function isGaslessBatchWalletExecute(call: GaslessBatchCall): call is GaslessBatchWalletExecute {\n return \"walletCalls\" in call;\n}\n\n/**\n * The calldata a relayable-write entry runs with — raw `data`, or the named\n * call encoded against its own `abi` or, when it has none, the SDK's ABI for\n * the relayable write of that name.\n *\n * @throws {SymmError} `GASLESS_NOT_RELAYABLE` when a call without an `abi` names no relayable write.\n * @throws Viem's encoding error when the arguments do not encode.\n *\n * @internal\n */\nexport function gaslessBatchCallData(call: GaslessBatchContractCall | GaslessBatchRawCall): Hex {\n if (\"data\" in call) return call.data;\n const abi = call.abi ?? [relayableFunction(call.functionName)];\n return encodeFunctionData({ abi: abi as Abi, functionName: call.functionName, args: call.args });\n}\n\nfunction relayableFunction(functionName: string): AbiFunction {\n const item = GASLESS_RELAYABLE_FUNCTIONS.get(functionName);\n if (!item) {\n throw new SymmError(\n \"validation\",\n \"GASLESS_NOT_RELAYABLE\",\n `Gasless: no relayable write is named \"${functionName}\". A batch carries the writes in GASLESS_RELAYABLE_SELECTORS; run any other call from the GaslessWallet as a \\`walletCalls\\` entry.`,\n );\n }\n return item;\n}\n\n/**\n * The 4-byte selector of a calldata blob, lowercased. Calldata shorter than a\n * selector yields `0x00000000`, which no relayable write uses.\n *\n * @internal\n */\nexport function gaslessCallDataSelector(callData: Hex): Hex {\n return (size(callData) < 4 ? \"0x00000000\" : slice(callData, 0, 4)).toLowerCase() as Hex;\n}\n\n/**\n * The selectors a gasless batch runs — the delegation set a session key must\n * hold to relay it on the batch's account: each relayable write's selector, and\n * for every GaslessWallet entry the wallet-execution sentinel plus each inner\n * call's selector. Lowercased and de-duplicated in first-seen order, because\n * `grantDelegation` rejects a duplicate-bearing array.\n *\n * Selectors come from the **encoded** calldata, so an overloaded ABI resolves to\n * the function that will actually run.\n *\n * A batch that contains `grantDelegation` must be owner-signed whatever this\n * returns: the InstantLayer rejects a delegate-signed grant, so no delegation\n * makes it relayable by a session key.\n *\n * @param calls - The batch, in any order.\n * @returns The selector set, as `bytes4` hex.\n * @throws Viem's encoding error when an ABI-level call does not encode.\n *\n * @example\n * ```ts\n * await grantDelegation(config, {\n * account: { addr: subAccount, isPartyB: false },\n * delegatedSigner: sessionKey,\n * selectors: getGaslessBatchSelectors(calls),\n * expiryTimestamp,\n * });\n * ```\n */\nexport function getGaslessBatchSelectors(calls: readonly GaslessBatchCall[]): readonly Hex[] {\n const seen = new Set<Hex>();\n const unique: Hex[] = [];\n const add = (selector: Hex) => {\n const normalized = selector.toLowerCase() as Hex;\n if (seen.has(normalized)) return;\n seen.add(normalized);\n unique.push(normalized);\n };\n\n for (const call of calls) {\n if (isGaslessBatchWalletExecute(call)) {\n for (const selector of getGaslessWalletExecuteSelectors(call.walletCalls)) add(selector);\n } else {\n add(gaslessCallDataSelector(gaslessBatchCallData(call)));\n }\n }\n\n return unique;\n}\n"],"mappings":";;;;;AAgFA,SAAgB,EAA4B,GAA2D;CACrG,OAAO,iBAAiB;AAC1B;AAYA,SAAgB,EAAqB,GAA2D;CAG9F,OAFI,UAAU,IAAa,EAAK,OAEzB,EAAmB;EAAO,KADrB,EAAK,OAAO,CAAC,EAAkB,EAAK,YAAY,CAAC;EAChB,cAAc,EAAK;EAAc,MAAM,EAAK;CAAK,CAAC;AACjG;AAEA,SAAS,EAAkB,GAAmC;CAC5D,IAAM,IAAO,EAA4B,IAAI,CAAY;CACzD,IAAI,CAAC,GACH,MAAM,IAAI,EACR,cACA,yBACA,yCAAyC,EAAa,oIACxD;CAEF,OAAO;AACT;AAQA,SAAgB,EAAwB,GAAoB;CAC1D,QAAQ,EAAK,CAAQ,IAAI,IAAI,eAAe,EAAM,GAAU,GAAG,CAAC,GAAG,YAAY;AACjF;AA8BA,SAAgB,EAAyB,GAAoD;CAC3F,IAAM,oBAAO,IAAI,IAAS,GACpB,IAAgB,CAAC,GACjB,KAAO,MAAkB;EAC7B,IAAM,IAAa,EAAS,YAAY;EACpC,EAAK,IAAI,CAAU,MACvB,EAAK,IAAI,CAAU,GACnB,EAAO,KAAK,CAAU;CACxB;CAEA,KAAK,IAAM,KAAQ,GACjB,IAAI,EAA4B,CAAI,GAClC,KAAK,IAAM,KAAY,EAAiC,EAAK,WAAW,GAAG,EAAI,CAAQ;MAEvF,EAAI,EAAwB,EAAqB,CAAI,CAAC,CAAC;CAI3D,OAAO;AACT"}
1
+ {"version":3,"file":"calls.js","names":[],"sources":["../../../src/gasless/batch/calls.ts"],"sourcesContent":["import { encodeFunctionData, size, slice, type Abi, type AbiFunction, type Address, type Hex } from \"viem\";\nimport { SymmError } from \"../../shared/errors/symm-error\";\nimport { getEffectiveInstantSelectors } from \"../effective-instant-selectors\";\nimport type { GaslessWalletCall } from \"../gasless-wallet-execute/calls\";\nimport { getGaslessWalletExecuteSelectors } from \"../gasless-wallet-execute/selectors\";\nimport { GASLESS_RELAYABLE_FUNCTIONS } from \"../relayable-writes\";\n\n/**\n * A relayable write named by its function, which the SDK encodes with viem's\n * `encodeFunctionData` — that throws on an arity or type mismatch, before any\n * signature prompt or network call.\n *\n * The target contract is **not** given: the SDK resolves it from the encoded\n * selector (the core diamond, the AccountLayer or the InstantLayer). The `abi`\n * is optional too — every relayable write is a known SYMMIO function, so\n * `{ functionName: \"allocate\", args: [amount] }` is enough. Pass an `abi` (the\n * SDK's own `symmioAbi`, `accountLayerAbi` or `instantLayerAbi`) when you\n * already hold it; the selector must still be a relayable write.\n *\n * `args` is deliberately `readonly unknown[]`, as for `GaslessWalletContractCall`.\n * When you want compile-time-checked arguments, encode with viem yourself and\n * pass the result as a {@link GaslessBatchRawCall}.\n */\nexport interface GaslessBatchContractCall {\n /** ABI containing `functionName`. Omit it to use the SDK's own ABI for the relayable write of that name. */\n abi?: Abi | readonly unknown[];\n /** The relayable write to run — `\"allocate\"`, `\"initiateWithdraw\"`, `\"grantDelegation\"`, … */\n functionName: string;\n /** Arguments for `functionName`, in order. Omit for a no-argument function. */\n args?: readonly unknown[];\n /**\n * Who signs this call. Defaults to the batch's `from` (or the connected\n * wallet). Give it to mix signers in one batch, for example a session key\n * signing a call that an owner-signed grant earlier in the same batch\n * authorizes.\n */\n from?: Address;\n}\n\n/** A relayable write given as raw calldata; its selector decides the target contract. */\nexport interface GaslessBatchRawCall {\n /** Calldata of a relayable write. */\n data: Hex;\n /** Who signs this call. Defaults to the batch's `from` (or the connected wallet). */\n from?: Address;\n}\n\n/**\n * A GaslessWallet `execute` entry: several calls the owner's deterministic\n * wallet makes, authorized by **one** gateway-domain signature.\n *\n * The calls run **as the wallet contract**, not as the SYMMIO account — use it to\n * move the wallet's own tokens (an ERC-20 `approve` followed by a bridge call,\n * say), exactly as with `gaslessWalletExecute`.\n */\nexport interface GaslessBatchWalletExecute {\n /** The calls the wallet makes, in order. Each is raw `data` or an `{ abi, functionName, args }` triple. */\n walletCalls: readonly GaslessWalletCall[];\n /**\n * Which of the owner's GaslessWallets makes them. Defaults to `0n`, the\n * original wallet. Each id is an independent wallet with its own address,\n * balance and nonce stream.\n */\n walletId?: bigint;\n /**\n * Who signs this wallet operation. Defaults to the batch's `from`, then the\n * configured wallet. The wallet contract still executes the inner calls.\n */\n from?: Address;\n}\n\n/**\n * One entry of a gasless batch: a relayable write — an ABI-level call\n * ({@link GaslessBatchContractCall}) or raw calldata ({@link GaslessBatchRawCall}) —\n * or a GaslessWallet `execute` ({@link GaslessBatchWalletExecute}). The forms mix\n * freely in one batch.\n *\n * @example\n * ```ts\n * import type { GaslessBatchCall } from \"@symmio/trading-core\";\n * import { erc20Abi } from \"viem\";\n *\n * const calls: GaslessBatchCall[] = [\n * { functionName: \"allocate\", args: [amount] },\n * { walletId: 1n, walletCalls: [{ target: usdc, abi: erc20Abi, functionName: \"transfer\", args: [to, value] }] },\n * ];\n * ```\n */\nexport type GaslessBatchCall = GaslessBatchContractCall | GaslessBatchRawCall | GaslessBatchWalletExecute;\n\n/**\n * Whether a batch entry is a GaslessWallet `execute`.\n *\n * @internal\n */\nexport function isGaslessBatchWalletExecute(call: GaslessBatchCall): call is GaslessBatchWalletExecute {\n return \"walletCalls\" in call;\n}\n\n/**\n * The calldata a relayable-write entry runs with — raw `data`, or the named\n * call encoded against its own `abi` or, when it has none, the SDK's ABI for\n * the relayable write of that name.\n *\n * @throws {SymmError} `GASLESS_NOT_RELAYABLE` when a call without an `abi` names no relayable write.\n * @throws Viem's encoding error when the arguments do not encode.\n *\n * @internal\n */\nexport function gaslessBatchCallData(call: GaslessBatchContractCall | GaslessBatchRawCall): Hex {\n if (\"data\" in call) return call.data;\n const abi = call.abi ?? [relayableFunction(call.functionName)];\n return encodeFunctionData({ abi: abi as Abi, functionName: call.functionName, args: call.args });\n}\n\nfunction relayableFunction(functionName: string): AbiFunction {\n const item = GASLESS_RELAYABLE_FUNCTIONS.get(functionName);\n if (!item) {\n throw new SymmError(\n \"validation\",\n \"GASLESS_NOT_RELAYABLE\",\n `Gasless: no relayable write is named \"${functionName}\". A batch carries the writes in GASLESS_RELAYABLE_SELECTORS; run any other call from the GaslessWallet as a \\`walletCalls\\` entry.`,\n );\n }\n return item;\n}\n\n/**\n * The 4-byte selector of a calldata blob, lowercased. Calldata shorter than a\n * selector yields `0x00000000`, which no relayable write uses.\n *\n * @internal\n */\nexport function gaslessCallDataSelector(callData: Hex): Hex {\n return (size(callData) < 4 ? \"0x00000000\" : slice(callData, 0, 4)).toLowerCase() as Hex;\n}\n\n/**\n * The selectors a gasless batch runs — the delegation set a session key must\n * hold to relay it on the batch's account: each relayable write's selector, and\n * for every GaslessWallet entry the wallet-execution sentinel plus each inner\n * call's selector. Lowercased and de-duplicated in first-seen order.\n *\n * Selectors come from the **encoded** calldata, so an overloaded ABI resolves to\n * the function that will actually run.\n *\n * For a mixed-signer batch, pass only the calls the delegate signs. This helper\n * collects selectors without resolving `from`. A `grantDelegation` or\n * `grantDelegations` entry must itself be owner-signed: no delegation makes a\n * grant relayable by a session key.\n *\n * @param calls - The calls signed by the delegate, in any order.\n * @returns The selector set, as `bytes4` hex.\n * @throws Viem's encoding error when an ABI-level call does not encode.\n *\n * @example\n * ```ts\n * await grantDelegation(config, {\n * account: { addr: subAccount, isPartyB: false },\n * delegatedSigner: sessionKey,\n * selectors: getGaslessBatchSelectors(calls),\n * expiryTimestamp,\n * });\n * ```\n */\nexport function getGaslessBatchSelectors(calls: readonly GaslessBatchCall[]): readonly Hex[] {\n const seen = new Set<Hex>();\n const unique: Hex[] = [];\n const add = (selector: Hex) => {\n const normalized = selector.toLowerCase() as Hex;\n if (seen.has(normalized)) return;\n seen.add(normalized);\n unique.push(normalized);\n };\n\n for (const call of calls) {\n if (isGaslessBatchWalletExecute(call)) {\n for (const selector of getGaslessWalletExecuteSelectors(call.walletCalls)) add(selector);\n } else {\n for (const selector of getEffectiveInstantSelectors(gaslessBatchCallData(call))) add(selector);\n }\n }\n\n return unique;\n}\n"],"mappings":";;;;;;AA+FA,SAAgB,EAA4B,GAA2D;CACrG,OAAO,iBAAiB;AAC1B;AAYA,SAAgB,EAAqB,GAA2D;CAG9F,OAFI,UAAU,IAAa,EAAK,OAEzB,EAAmB;EAAO,KADrB,EAAK,OAAO,CAAC,EAAkB,EAAK,YAAY,CAAC;EAChB,cAAc,EAAK;EAAc,MAAM,EAAK;CAAK,CAAC;AACjG;AAEA,SAAS,EAAkB,GAAmC;CAC5D,IAAM,IAAO,EAA4B,IAAI,CAAY;CACzD,IAAI,CAAC,GACH,MAAM,IAAI,EACR,cACA,yBACA,yCAAyC,EAAa,oIACxD;CAEF,OAAO;AACT;AAQA,SAAgB,EAAwB,GAAoB;CAC1D,QAAQ,EAAK,CAAQ,IAAI,IAAI,eAAe,EAAM,GAAU,GAAG,CAAC,GAAG,YAAY;AACjF;AA8BA,SAAgB,EAAyB,GAAoD;CAC3F,IAAM,oBAAO,IAAI,IAAS,GACpB,IAAgB,CAAC,GACjB,KAAO,MAAkB;EAC7B,IAAM,IAAa,EAAS,YAAY;EACpC,EAAK,IAAI,CAAU,MACvB,EAAK,IAAI,CAAU,GACnB,EAAO,KAAK,CAAU;CACxB;CAEA,KAAK,IAAM,KAAQ,GACjB,IAAI,EAA4B,CAAI,GAClC,KAAK,IAAM,KAAY,EAAiC,EAAK,WAAW,GAAG,EAAI,CAAQ;MAEvF,KAAK,IAAM,KAAY,EAA6B,EAAqB,CAAI,CAAC,GAAG,EAAI,CAAQ;CAIjG,OAAO;AACT"}
@@ -15,6 +15,8 @@ export interface ResolvedGaslessInstantEntry {
15
15
  selector: Hex;
16
16
  /** The write's stable workflow label (`"allocate"`, `"initiateWithdraw"`, …). */
17
17
  operationType: string;
18
+ /** The signer the call asked for with `from`; the batch's own signer when absent. */
19
+ from?: Address;
18
20
  }
19
21
  /** A GaslessWallet `execute` entry, encoded. @internal */
20
22
  export interface ResolvedGaslessWalletEntry {
@@ -25,6 +27,8 @@ export interface ResolvedGaslessWalletEntry {
25
27
  callData: Hex;
26
28
  /** The inner calls, for the delegation pre-flight. */
27
29
  walletCalls: readonly GaslessWalletCall[];
30
+ /** The signer requested by this entry; falls back to the batch's signer. */
31
+ from?: Address;
28
32
  }
29
33
  /** One batch entry, resolved and encoded, in relay order. @internal */
30
34
  export type ResolvedGaslessBatchEntry = ResolvedGaslessInstantEntry | ResolvedGaslessWalletEntry;
@@ -76,8 +80,13 @@ export declare function readGaslessBatchWalletTargets(config: Config, parameters
76
80
  }): Promise<Map<bigint, Address>>;
77
81
  /** Everything a batch's operations are built from, besides its entries. @internal */
78
82
  export interface GaslessBatchBuildContext {
79
- /** The EIP-712 signer written into every operation. */
83
+ /** The EIP-712 signer written into every operation without its own entry in `entrySigners`. */
80
84
  signer: Address;
85
+ /**
86
+ * Per-entry signer, aligned with the entries — for a batch that mixes signers.
87
+ * An entry without one is signed by `signer`.
88
+ */
89
+ entrySigners?: readonly (Address | undefined)[];
81
90
  /** The batch's account — every operation's `signerAccount.addr`. */
82
91
  account: Address;
83
92
  /** The signature deadline shared by every operation (unix seconds). */
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-gasless-batch.d.ts","sourceRoot":"","sources":["../../../src/gasless/batch/resolve-gasless-batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAK5F,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAC;AAQjB,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,SAAS,CAAC;IAChB,uDAAuD;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,4BAA4B;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,wCAAwC;IACxC,QAAQ,EAAE,GAAG,CAAC;IACd,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,0DAA0D;AAC1D,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,QAAQ,CAAC;IACf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MAAM,GAAG,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,oEAAoE;IACpE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,gGAAgG;IAChG,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,4EAA4E;IAC5E,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,SAAS,yBAAyB,EAAE,EAC7C,OAAO,EAAE,wBAAwB,GAChC,sBAAsB,CAuCxB"}
1
+ {"version":3,"file":"resolve-gasless-batch.d.ts","sourceRoot":"","sources":["../../../src/gasless/batch/resolve-gasless-batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE/E,OAAO,EAAqB,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAK5F,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,SAAS,CAAC;AAQjB,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,SAAS,CAAC;IAChB,uDAAuD;IACvD,MAAM,EAAE,OAAO,CAAC;IAChB,4BAA4B;IAC5B,QAAQ,EAAE,GAAG,CAAC;IACd,wCAAwC;IACxC,QAAQ,EAAE,GAAG,CAAC;IACd,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,0DAA0D;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AE,MAAM,CAAC;IACrB,qEAAqE;IACrE,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,uHAAuH;IACvH,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,6EAA6E;IAC7E,IAAI,EAAE,MAAM,GAAG,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,sBAAsB;IACrC,+CAA+C;IAC/C,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,oEAAoE;IACpE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,gGAAgG;IAChG,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,4EAA4E;IAC5E,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,SAAS,yBAAyB,EAAE,EAC7C,OAAO,EAAE,wBAAwB,GAChC,sBAAsB,CAuCxB"}
@@ -1,8 +1,8 @@
1
1
  import { gaslessWalletAbi as e } from "../../symmio-contracts/abi/v0.8.6/gasless-wallet.js";
2
2
  import { SymmError as t } from "../../shared/errors/symm-error.js";
3
3
  import { buildSignedOperation as n } from "../../solvers/instant-open/shared/operations.js";
4
- import { assertGaslessWalletId as r } from "../wallet-id.js";
5
- import { GASLESS_RELAYABLE_WRITES as i } from "../relayable-writes.js";
4
+ import { GASLESS_RELAYABLE_WRITES as r } from "../relayable-writes.js";
5
+ import { assertGaslessWalletId as i } from "../wallet-id.js";
6
6
  import { toWalletCallTuple as a } from "../gasless-wallet-execute/calls.js";
7
7
  import { gaslessBatchCallData as o, gaslessCallDataSelector as s, isGaslessBatchWalletExecute as c } from "./calls.js";
8
8
  import { getGaslessWalletAddress as l } from "../get-gasless-wallet-address/get-gasless-wallet-address.js";
@@ -22,22 +22,24 @@ function h(n, l) {
22
22
  return l.map((l, u) => {
23
23
  if (c(l)) return {
24
24
  type: "wallet",
25
- walletId: r(l.walletId ?? 0n, `calls[${u}].walletId`),
25
+ walletId: i(l.walletId ?? 0n, `calls[${u}].walletId`),
26
26
  callData: d({
27
27
  abi: e,
28
28
  functionName: "execute",
29
29
  args: [l.walletCalls.map(a)]
30
30
  }),
31
- walletCalls: l.walletCalls
31
+ walletCalls: l.walletCalls,
32
+ ...l.from === void 0 ? {} : { from: l.from }
32
33
  };
33
- let f = o(l), p = s(f), h = i.get(p);
34
+ let f = o(l), p = s(f), h = r.get(p);
34
35
  if (!h) throw new t("validation", "GASLESS_NOT_RELAYABLE", `Gasless: calls[${u}] (selector ${p}) is not a relayable write. A batch carries the writes in GASLESS_RELAYABLE_SELECTORS; run any other call from the GaslessWallet as a \`walletCalls\` entry.`);
35
36
  return {
36
37
  type: "instant",
37
38
  target: m(n, h.target),
38
39
  callData: f,
39
40
  selector: p,
40
- operationType: h.operationType
41
+ operationType: h.operationType,
42
+ ...l.from === void 0 ? {} : { from: l.from }
41
43
  };
42
44
  });
43
45
  }
@@ -58,21 +60,21 @@ async function v(e, t) {
58
60
  }
59
61
  function y(e, t) {
60
62
  let r = [], i = [], a = null, o = /* @__PURE__ */ new Map();
61
- for (let s of e) {
62
- let e, c;
63
- if (s.type === "instant") e = s.target, c = (a ?? t.instantNonce) + 1n, a = c, i.push(0n);
63
+ for (let [s, c] of e.entries()) {
64
+ let e, l;
65
+ if (c.type === "instant") e = c.target, l = (a ?? t.instantNonce) + 1n, a = l, i.push(0n);
64
66
  else {
65
- let n = t.walletTargets.get(s.walletId);
66
- if (n === void 0) throw Error(`gasless batch: no wallet address was resolved for wallet id ${s.walletId}.`);
67
- e = n, c = (o.get(s.walletId) ?? t.walletNonces.get(s.walletId) ?? 0n) + 1n, o.set(s.walletId, c), i.push(s.walletId);
67
+ let n = t.walletTargets.get(c.walletId);
68
+ if (n === void 0) throw Error(`gasless batch: no wallet address was resolved for wallet id ${c.walletId}.`);
69
+ e = n, l = (o.get(c.walletId) ?? t.walletNonces.get(c.walletId) ?? 0n) + 1n, o.set(c.walletId, l), i.push(c.walletId);
68
70
  }
69
71
  r.push(n({
70
- signer: t.signer,
72
+ signer: t.entrySigners?.[s] ?? t.signer,
71
73
  target: e,
72
- callData: s.callData,
74
+ callData: c.callData,
73
75
  signerAccount: t.account,
74
76
  deadline: t.deadline,
75
- nonce: c,
77
+ nonce: l,
76
78
  salt: t.salt()
77
79
  }));
78
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resolve-gasless-batch.js","names":[],"sources":["../../../src/gasless/batch/resolve-gasless-batch.ts"],"sourcesContent":["import { encodeFunctionData, type Address, type Hex } from \"viem\";\nimport type { SymmioContractAddresses } from \"../../core/chains/types\";\nimport type { Config } from \"../../core/config\";\nimport { SymmError } from \"../../shared/errors/symm-error\";\nimport { buildSignedOperation } from \"../../solvers/instant-open/shared/operations\";\nimport type { SignedOperation } from \"../../solvers/instant-open/shared/types\";\nimport { gaslessWalletAbi } from \"../../symmio-contracts/abi/v0.8.6/gasless-wallet\";\nimport { toWalletCallTuple, type GaslessWalletCall } from \"../gasless-wallet-execute/calls\";\nimport { GASLESS_WALLET_EXECUTE_OPERATION_TYPE } from \"../gasless-wallet-execute/gasless-wallet-execute\";\nimport { getGaslessWalletAddress } from \"../get-gasless-wallet-address/get-gasless-wallet-address\";\nimport { GASLESS_RELAYABLE_WRITES, type GaslessRelayableTarget } from \"../relayable-writes\";\nimport { assertGaslessWalletId } from \"../wallet-id\";\nimport {\n gaslessBatchCallData,\n gaslessCallDataSelector,\n isGaslessBatchWalletExecute,\n type GaslessBatchCall,\n} from \"./calls\";\n\n/** The label a batch relays under when its entries' own labels do not fit the service's 128 characters. */\nconst GASLESS_BATCH_OPERATION_TYPE = \"gaslessBatch\";\n\n/** The service's limit on an `operationType` label. */\nconst GASLESS_OPERATION_TYPE_MAX_LENGTH = 128;\n\n/** A relayable write, resolved to the contract the InstantLayer calls. @internal */\nexport interface ResolvedGaslessInstantEntry {\n type: \"instant\";\n /** Contract the InstantLayer calls with `callData`. */\n target: Address;\n /** The write's calldata. */\n callData: Hex;\n /** The write's selector, lowercased. */\n selector: Hex;\n /** The write's stable workflow label (`\"allocate\"`, `\"initiateWithdraw\"`, …). */\n operationType: string;\n}\n\n/** A GaslessWallet `execute` entry, encoded. @internal */\nexport interface ResolvedGaslessWalletEntry {\n type: \"wallet\";\n /** The wallet id the entry executes from. */\n walletId: bigint;\n /** `GaslessWallet.execute(calls)` calldata. */\n callData: Hex;\n /** The inner calls, for the delegation pre-flight. */\n walletCalls: readonly GaslessWalletCall[];\n}\n\n/** One batch entry, resolved and encoded, in relay order. @internal */\nexport type ResolvedGaslessBatchEntry = ResolvedGaslessInstantEntry | ResolvedGaslessWalletEntry;\n\nfunction relayableTargetAddress(addresses: SymmioContractAddresses, target: GaslessRelayableTarget): Address {\n switch (target) {\n case \"symmio\":\n return addresses.symmioAddress;\n case \"accountLayer\":\n return addresses.accountLayerAddress;\n case \"instantLayer\":\n return addresses.instantLayerAddress;\n }\n}\n\n/**\n * Encode every batch entry and resolve each relayable write to its contract.\n *\n * Runs before any network call or signature prompt, so a malformed call, an\n * invalid wallet id or a write the relayer cannot carry fails up front.\n *\n * @param addresses - The chain's contract addresses.\n * @param calls - The batch, in relay order.\n * @returns The resolved entries, in the same order.\n * @throws {SymmError} `GASLESS_EMPTY_BATCH` for an empty batch.\n * @throws {SymmError} `GASLESS_NOT_RELAYABLE` for a call whose selector is not a relayable write.\n * @throws {SymmError} `GASLESS_WALLET_ID_INVALID` for a wallet id outside the `uint256` range.\n * @throws Viem's encoding error when an ABI-level call does not encode.\n *\n * @internal\n */\nexport function resolveGaslessBatchEntries(\n addresses: SymmioContractAddresses,\n calls: readonly GaslessBatchCall[],\n): ResolvedGaslessBatchEntry[] {\n if (calls.length === 0) {\n throw new SymmError(\"validation\", \"GASLESS_EMPTY_BATCH\", \"Gasless: a batch needs at least one call.\");\n }\n\n return calls.map((call, index): ResolvedGaslessBatchEntry => {\n if (isGaslessBatchWalletExecute(call)) {\n return {\n type: \"wallet\",\n walletId: assertGaslessWalletId(call.walletId ?? 0n, `calls[${index}].walletId`),\n callData: encodeFunctionData({\n abi: gaslessWalletAbi,\n functionName: \"execute\",\n args: [call.walletCalls.map(toWalletCallTuple)],\n }),\n walletCalls: call.walletCalls,\n };\n }\n\n const callData = gaslessBatchCallData(call);\n const selector = gaslessCallDataSelector(callData);\n const write = GASLESS_RELAYABLE_WRITES.get(selector);\n if (!write) {\n throw new SymmError(\n \"validation\",\n \"GASLESS_NOT_RELAYABLE\",\n `Gasless: calls[${index}] (selector ${selector}) is not a relayable write. A batch carries the writes in GASLESS_RELAYABLE_SELECTORS; run any other call from the GaslessWallet as a \\`walletCalls\\` entry.`,\n );\n }\n return {\n type: \"instant\",\n target: relayableTargetAddress(addresses, write.target),\n callData,\n selector,\n operationType: write.operationType,\n };\n });\n}\n\n/**\n * The label a batch relays under by default: its entries' labels joined with\n * `+` (`\"approveOperationalFee+allocate\"`), or `\"gaslessBatch\"` when that exceeds\n * the service's 128 characters.\n *\n * @internal\n */\nexport function defaultGaslessBatchOperationType(entries: readonly ResolvedGaslessBatchEntry[]): string {\n const label = entries\n .map((entry) => (entry.type === \"wallet\" ? GASLESS_WALLET_EXECUTE_OPERATION_TYPE : entry.operationType))\n .join(\"+\");\n return label.length <= GASLESS_OPERATION_TYPE_MAX_LENGTH ? label : GASLESS_BATCH_OPERATION_TYPE;\n}\n\n/**\n * The distinct wallet ids a batch's GaslessWallet entries execute from, in first-seen order.\n *\n * @internal\n */\nexport function distinctGaslessBatchWalletIds(entries: readonly ResolvedGaslessBatchEntry[]): bigint[] {\n return [...new Set(entries.flatMap((entry) => (entry.type === \"wallet\" ? [entry.walletId] : [])))];\n}\n\n/**\n * Read the address of each wallet a batch executes from — the signed `target`\n * of its GaslessWallet entries.\n *\n * @param config - The SDK config.\n * @param parameters - The chain, the wallets' owner, and the distinct wallet ids.\n * @returns Each id's wallet address.\n *\n * @internal\n */\nexport async function readGaslessBatchWalletTargets(\n config: Config,\n parameters: { chainId: number; owner: Address; walletIds: readonly bigint[] },\n): Promise<Map<bigint, Address>> {\n const { chainId, owner, walletIds } = parameters;\n const addresses = await Promise.all(\n walletIds.map((walletId) => getGaslessWalletAddress(config, { chainId, owner, walletId })),\n );\n return new Map(walletIds.map((walletId, index) => [walletId, addresses[index]!]));\n}\n\n/** Everything a batch's operations are built from, besides its entries. @internal */\nexport interface GaslessBatchBuildContext {\n /** The EIP-712 signer written into every operation. */\n signer: Address;\n /** The batch's account — every operation's `signerAccount.addr`. */\n account: Address;\n /** The signature deadline shared by every operation (unix seconds). */\n deadline: bigint;\n /** The InstantLayer nonce the account has consumed; the first relayable write signs `+ 1n`. */\n instantNonce: bigint;\n /** Each wallet id's address — the signed `target` of its entries. */\n walletTargets: ReadonlyMap<bigint, Address>;\n /** Each wallet id's consumed wallet-operation nonce; the first entry on it signs `+ 1n`. Omitted ids start at `0n`. */\n walletNonces: ReadonlyMap<bigint, bigint>;\n /** The replay salt of each operation, called once per operation in order. */\n salt: () => Hex;\n}\n\n/** A batch's operations, ready to sign. @internal */\nexport interface GaslessBatchOperations {\n /** One operation per entry, in relay order. */\n operations: SignedOperation[];\n /** One wallet id per operation — `0n` for every relayable write. */\n walletIds: bigint[];\n /** The highest InstantLayer nonce the batch signs, or `null` when it has no relayable write. */\n lastInstantNonce: bigint | null;\n /** The highest wallet-operation nonce the batch signs on each wallet id. */\n lastWalletNonces: Map<bigint, bigint>;\n}\n\n/**\n * Build a batch's operations with sequential nonces on each stream: the\n * relayable writes count up the account's InstantLayer stream, and each wallet\n * id's entries count up that wallet's own stream.\n *\n * Every operation is the full InstantLayer `SignedOperation` shape — a wallet\n * entry too, with no flex fields and `maxUses` 1, which is how the relay's ABI\n * and wire format carry it. Only its **signature** covers the five-field\n * gateway struct.\n *\n * @internal\n */\nexport function buildGaslessBatchOperations(\n entries: readonly ResolvedGaslessBatchEntry[],\n context: GaslessBatchBuildContext,\n): GaslessBatchOperations {\n const operations: SignedOperation[] = [];\n const walletIds: bigint[] = [];\n let lastInstantNonce: bigint | null = null;\n const lastWalletNonces = new Map<bigint, bigint>();\n\n for (const entry of entries) {\n let target: Address;\n let nonce: bigint;\n if (entry.type === \"instant\") {\n target = entry.target;\n nonce = (lastInstantNonce ?? context.instantNonce) + 1n;\n lastInstantNonce = nonce;\n walletIds.push(0n);\n } else {\n const walletTarget = context.walletTargets.get(entry.walletId);\n if (walletTarget === undefined) {\n throw new Error(`gasless batch: no wallet address was resolved for wallet id ${entry.walletId}.`);\n }\n target = walletTarget;\n nonce = (lastWalletNonces.get(entry.walletId) ?? context.walletNonces.get(entry.walletId) ?? 0n) + 1n;\n lastWalletNonces.set(entry.walletId, nonce);\n walletIds.push(entry.walletId);\n }\n\n operations.push(\n buildSignedOperation({\n signer: context.signer,\n target,\n callData: entry.callData,\n signerAccount: context.account,\n deadline: context.deadline,\n nonce,\n salt: context.salt(),\n }),\n );\n }\n\n return { operations, walletIds, lastInstantNonce, lastWalletNonces };\n}\n"],"mappings":";;;;;;;;;;;AAoBA,IAAM,IAA+B,gBAG/B,IAAoC;AA6B1C,SAAS,EAAuB,GAAoC,GAAyC;CAC3G,QAAQ,GAAR;EACE,KAAK,UACH,OAAO,EAAU;EACnB,KAAK,gBACH,OAAO,EAAU;EACnB,KAAK,gBACH,OAAO,EAAU;CACrB;AACF;AAkBA,SAAgB,EACd,GACA,GAC6B;CAC7B,IAAI,EAAM,WAAW,GACnB,MAAM,IAAI,EAAU,cAAc,uBAAuB,2CAA2C;CAGtG,OAAO,EAAM,KAAK,GAAM,MAAqC;EAC3D,IAAI,EAA4B,CAAI,GAClC,OAAO;GACL,MAAM;GACN,UAAU,EAAsB,EAAK,YAAY,IAAI,SAAS,EAAM,WAAW;GAC/E,UAAU,EAAmB;IAC3B,KAAK;IACL,cAAc;IACd,MAAM,CAAC,EAAK,YAAY,IAAI,CAAiB,CAAC;GAChD,CAAC;GACD,aAAa,EAAK;EACpB;EAGF,IAAM,IAA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U,MAAM,+DAA+D,EAAM,SAAS,EAAE;GAKlG,AAHA,IAAS,GACT,KAAS,EAAiB,IAAI,EAAM,QAAQ,KAAK,EAAQ,aAAa,IAAI,EAAM,QAAQ,KAAK,MAAM,IACnG,EAAiB,IAAI,EAAM,UAAU,CAAK,GAC1C,EAAU,KAAK,EAAM,QAAQ;EAC/B;EAEA,EAAW,KACT,EAAqB;GACnB,QAAQ,EAAQ;GAChB;GACA,UAAU,EAAM;GAChB,eAAe,EAAQ;GACvB,UAAU,EAAQ;GAClB;GACA,MAAM,EAAQ,KAAK;EACrB,CAAC,CACH;CACF;CAEA,OAAO;EAAE;EAAY;EAAW;EAAkB;CAAiB;AACrE"}
1
+ {"version":3,"file":"resolve-gasless-batch.js","names":[],"sources":["../../../src/gasless/batch/resolve-gasless-batch.ts"],"sourcesContent":["import { encodeFunctionData, type Address, type Hex } from \"viem\";\nimport type { SymmioContractAddresses } from \"../../core/chains/types\";\nimport type { Config } from \"../../core/config\";\nimport { SymmError } from \"../../shared/errors/symm-error\";\nimport { buildSignedOperation } from \"../../solvers/instant-open/shared/operations\";\nimport type { SignedOperation } from \"../../solvers/instant-open/shared/types\";\nimport { gaslessWalletAbi } from \"../../symmio-contracts/abi/v0.8.6/gasless-wallet\";\nimport { toWalletCallTuple, type GaslessWalletCall } from \"../gasless-wallet-execute/calls\";\nimport { GASLESS_WALLET_EXECUTE_OPERATION_TYPE } from \"../gasless-wallet-execute/gasless-wallet-execute\";\nimport { getGaslessWalletAddress } from \"../get-gasless-wallet-address/get-gasless-wallet-address\";\nimport { GASLESS_RELAYABLE_WRITES, type GaslessRelayableTarget } from \"../relayable-writes\";\nimport { assertGaslessWalletId } from \"../wallet-id\";\nimport {\n gaslessBatchCallData,\n gaslessCallDataSelector,\n isGaslessBatchWalletExecute,\n type GaslessBatchCall,\n} from \"./calls\";\n\n/** The label a batch relays under when its entries' own labels do not fit the service's 128 characters. */\nconst GASLESS_BATCH_OPERATION_TYPE = \"gaslessBatch\";\n\n/** The service's limit on an `operationType` label. */\nconst GASLESS_OPERATION_TYPE_MAX_LENGTH = 128;\n\n/** A relayable write, resolved to the contract the InstantLayer calls. @internal */\nexport interface ResolvedGaslessInstantEntry {\n type: \"instant\";\n /** Contract the InstantLayer calls with `callData`. */\n target: Address;\n /** The write's calldata. */\n callData: Hex;\n /** The write's selector, lowercased. */\n selector: Hex;\n /** The write's stable workflow label (`\"allocate\"`, `\"initiateWithdraw\"`, …). */\n operationType: string;\n /** The signer the call asked for with `from`; the batch's own signer when absent. */\n from?: Address;\n}\n\n/** A GaslessWallet `execute` entry, encoded. @internal */\nexport interface ResolvedGaslessWalletEntry {\n type: \"wallet\";\n /** The wallet id the entry executes from. */\n walletId: bigint;\n /** `GaslessWallet.execute(calls)` calldata. */\n callData: Hex;\n /** The inner calls, for the delegation pre-flight. */\n walletCalls: readonly GaslessWalletCall[];\n /** The signer requested by this entry; falls back to the batch's signer. */\n from?: Address;\n}\n\n/** One batch entry, resolved and encoded, in relay order. @internal */\nexport type ResolvedGaslessBatchEntry = ResolvedGaslessInstantEntry | ResolvedGaslessWalletEntry;\n\nfunction relayableTargetAddress(addresses: SymmioContractAddresses, target: GaslessRelayableTarget): Address {\n switch (target) {\n case \"symmio\":\n return addresses.symmioAddress;\n case \"accountLayer\":\n return addresses.accountLayerAddress;\n case \"instantLayer\":\n return addresses.instantLayerAddress;\n }\n}\n\n/**\n * Encode every batch entry and resolve each relayable write to its contract.\n *\n * Runs before any network call or signature prompt, so a malformed call, an\n * invalid wallet id or a write the relayer cannot carry fails up front.\n *\n * @param addresses - The chain's contract addresses.\n * @param calls - The batch, in relay order.\n * @returns The resolved entries, in the same order.\n * @throws {SymmError} `GASLESS_EMPTY_BATCH` for an empty batch.\n * @throws {SymmError} `GASLESS_NOT_RELAYABLE` for a call whose selector is not a relayable write.\n * @throws {SymmError} `GASLESS_WALLET_ID_INVALID` for a wallet id outside the `uint256` range.\n * @throws Viem's encoding error when an ABI-level call does not encode.\n *\n * @internal\n */\nexport function resolveGaslessBatchEntries(\n addresses: SymmioContractAddresses,\n calls: readonly GaslessBatchCall[],\n): ResolvedGaslessBatchEntry[] {\n if (calls.length === 0) {\n throw new SymmError(\"validation\", \"GASLESS_EMPTY_BATCH\", \"Gasless: a batch needs at least one call.\");\n }\n\n return calls.map((call, index): ResolvedGaslessBatchEntry => {\n if (isGaslessBatchWalletExecute(call)) {\n return {\n type: \"wallet\",\n walletId: assertGaslessWalletId(call.walletId ?? 0n, `calls[${index}].walletId`),\n callData: encodeFunctionData({\n abi: gaslessWalletAbi,\n functionName: \"execute\",\n args: [call.walletCalls.map(toWalletCallTuple)],\n }),\n walletCalls: call.walletCalls,\n ...(call.from !== undefined ? { from: call.from } : {}),\n };\n }\n\n const callData = gaslessBatchCallData(call);\n const selector = gaslessCallDataSelector(callData);\n const write = GASLESS_RELAYABLE_WRITES.get(selector);\n if (!write) {\n throw new SymmError(\n \"validation\",\n \"GASLESS_NOT_RELAYABLE\",\n `Gasless: calls[${index}] (selector ${selector}) is not a relayable write. A batch carries the writes in GASLESS_RELAYABLE_SELECTORS; run any other call from the GaslessWallet as a \\`walletCalls\\` entry.`,\n );\n }\n return {\n type: \"instant\",\n target: relayableTargetAddress(addresses, write.target),\n callData,\n selector,\n operationType: write.operationType,\n ...(call.from !== undefined ? { from: call.from } : {}),\n };\n });\n}\n\n/**\n * The label a batch relays under by default: its entries' labels joined with\n * `+` (`\"approveOperationalFee+allocate\"`), or `\"gaslessBatch\"` when that exceeds\n * the service's 128 characters.\n *\n * @internal\n */\nexport function defaultGaslessBatchOperationType(entries: readonly ResolvedGaslessBatchEntry[]): string {\n const label = entries\n .map((entry) => (entry.type === \"wallet\" ? GASLESS_WALLET_EXECUTE_OPERATION_TYPE : entry.operationType))\n .join(\"+\");\n return label.length <= GASLESS_OPERATION_TYPE_MAX_LENGTH ? label : GASLESS_BATCH_OPERATION_TYPE;\n}\n\n/**\n * The distinct wallet ids a batch's GaslessWallet entries execute from, in first-seen order.\n *\n * @internal\n */\nexport function distinctGaslessBatchWalletIds(entries: readonly ResolvedGaslessBatchEntry[]): bigint[] {\n return [...new Set(entries.flatMap((entry) => (entry.type === \"wallet\" ? [entry.walletId] : [])))];\n}\n\n/**\n * Read the address of each wallet a batch executes from — the signed `target`\n * of its GaslessWallet entries.\n *\n * @param config - The SDK config.\n * @param parameters - The chain, the wallets' owner, and the distinct wallet ids.\n * @returns Each id's wallet address.\n *\n * @internal\n */\nexport async function readGaslessBatchWalletTargets(\n config: Config,\n parameters: { chainId: number; owner: Address; walletIds: readonly bigint[] },\n): Promise<Map<bigint, Address>> {\n const { chainId, owner, walletIds } = parameters;\n const addresses = await Promise.all(\n walletIds.map((walletId) => getGaslessWalletAddress(config, { chainId, owner, walletId })),\n );\n return new Map(walletIds.map((walletId, index) => [walletId, addresses[index]!]));\n}\n\n/** Everything a batch's operations are built from, besides its entries. @internal */\nexport interface GaslessBatchBuildContext {\n /** The EIP-712 signer written into every operation without its own entry in `entrySigners`. */\n signer: Address;\n /**\n * Per-entry signer, aligned with the entries — for a batch that mixes signers.\n * An entry without one is signed by `signer`.\n */\n entrySigners?: readonly (Address | undefined)[];\n /** The batch's account — every operation's `signerAccount.addr`. */\n account: Address;\n /** The signature deadline shared by every operation (unix seconds). */\n deadline: bigint;\n /** The InstantLayer nonce the account has consumed; the first relayable write signs `+ 1n`. */\n instantNonce: bigint;\n /** Each wallet id's address — the signed `target` of its entries. */\n walletTargets: ReadonlyMap<bigint, Address>;\n /** Each wallet id's consumed wallet-operation nonce; the first entry on it signs `+ 1n`. Omitted ids start at `0n`. */\n walletNonces: ReadonlyMap<bigint, bigint>;\n /** The replay salt of each operation, called once per operation in order. */\n salt: () => Hex;\n}\n\n/** A batch's operations, ready to sign. @internal */\nexport interface GaslessBatchOperations {\n /** One operation per entry, in relay order. */\n operations: SignedOperation[];\n /** One wallet id per operation — `0n` for every relayable write. */\n walletIds: bigint[];\n /** The highest InstantLayer nonce the batch signs, or `null` when it has no relayable write. */\n lastInstantNonce: bigint | null;\n /** The highest wallet-operation nonce the batch signs on each wallet id. */\n lastWalletNonces: Map<bigint, bigint>;\n}\n\n/**\n * Build a batch's operations with sequential nonces on each stream: the\n * relayable writes count up the account's InstantLayer stream, and each wallet\n * id's entries count up that wallet's own stream.\n *\n * Every operation is the full InstantLayer `SignedOperation` shape — a wallet\n * entry too, with no flex fields and `maxUses` 1, which is how the relay's ABI\n * and wire format carry it. Only its **signature** covers the five-field\n * gateway struct.\n *\n * @internal\n */\nexport function buildGaslessBatchOperations(\n entries: readonly ResolvedGaslessBatchEntry[],\n context: GaslessBatchBuildContext,\n): GaslessBatchOperations {\n const operations: SignedOperation[] = [];\n const walletIds: bigint[] = [];\n let lastInstantNonce: bigint | null = null;\n const lastWalletNonces = new Map<bigint, bigint>();\n\n for (const [index, entry] of entries.entries()) {\n let target: Address;\n let nonce: bigint;\n if (entry.type === \"instant\") {\n target = entry.target;\n nonce = (lastInstantNonce ?? context.instantNonce) + 1n;\n lastInstantNonce = nonce;\n walletIds.push(0n);\n } else {\n const walletTarget = context.walletTargets.get(entry.walletId);\n if (walletTarget === undefined) {\n throw new Error(`gasless batch: no wallet address was resolved for wallet id ${entry.walletId}.`);\n }\n target = walletTarget;\n nonce = (lastWalletNonces.get(entry.walletId) ?? context.walletNonces.get(entry.walletId) ?? 0n) + 1n;\n lastWalletNonces.set(entry.walletId, nonce);\n walletIds.push(entry.walletId);\n }\n\n operations.push(\n buildSignedOperation({\n signer: context.entrySigners?.[index] ?? context.signer,\n target,\n callData: entry.callData,\n signerAccount: context.account,\n deadline: context.deadline,\n nonce,\n salt: context.salt(),\n }),\n );\n }\n\n return { operations, walletIds, lastInstantNonce, lastWalletNonces };\n}\n"],"mappings":";;;;;;;;;;;AAoBA,IAAM,IAA+B,gBAG/B,IAAoC;AAiC1C,SAAS,EAAuB,GAAoC,GAAyC;CAC3G,QAAQ,GAAR;EACE,KAAK,UACH,OAAO,EAAU;EACnB,KAAK,gBACH,OAAO,EAAU;EAC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c,GAChC,IAAY,MAAM,QAAQ,IAC9B,EAAU,KAAK,MAAa,EAAwB,GAAQ;EAAE;EAAS;EAAO;CAAS,CAAC,CAAC,CAC3F;CACA,OAAO,IAAI,IAAI,EAAU,KAAK,GAAU,MAAU,CAAC,GAAU,EAAU,EAAO,CAAC,CAAC;AAClF;AAiDA,SAAgB,EACd,GACA,GACwB;CACxB,IAAM,IAAgC,CAAC,GACjC,IAAsB,CAAC,GACzB,IAAkC,MAChC,oBAAmB,IAAI,IAAoB;CAEjD,KAAK,IAAM,CAAC,GAAO,MAAU,EAAQ,QAAQ,GAAG;EAC9C,IAAI,GACA;EACJ,IAAI,EAAM,SAAS,WAIjB,AAHA,IAAS,EAAM,QACf,KAAS,KAAoB,EAAQ,gBAAgB,IACrD,IAAmB,GACnB,EAAU,KAAK,EAAE;OACZ;GACL,IAAM,IAAe,EAAQ,cAAc,IAAI,EAAM,QAAQ;GAC7D,IAAI,MAAiB,KAAA,GACnB,MAAU,MAAM,+DAA+D,EAAM,SAAS,EAAE;GAKlG,AAHA,IAAS,GACT,KAAS,EAAiB,IAAI,EAAM,QAAQ,KAAK,EAAQ,aAAa,IAAI,EAAM,QAAQ,KAAK,MAAM,IACnG,EAAiB,IAAI,EAAM,UAAU,CAAK,GAC1C,EAAU,KAAK,EAAM,QAAQ;EAC/B;EAEA,EAAW,KACT,EAAqB;GACnB,QAAQ,EAAQ,eAAe,MAAU,EAAQ;GACjD;GACA,UAAU,EAAM;GAChB,eAAe,EAAQ;GACvB,UAAU,EAAQ;GAClB;GACA,MAAM,EAAQ,KAAK;EACrB,CAAC,CACH;CACF;CAEA,OAAO;EAAE;EAAY;EAAW;EAAkB;CAAiB;AACrE"}
@@ -23,7 +23,9 @@ import { Abi, DecodeErrorResultReturnType, Hex } from 'viem';
23
23
  * settlement minimum, or the funds are not visible yet.
24
24
  * - `"deposit-not-above-fees"` — the balance clears the minimum but not the
25
25
  * deposit and wallet-creation fees.
26
- * - `"idempotency-conflict"` — the key belongs to another workflow; mint a new one.
26
+ * - `"idempotency-conflict"` — a `409 IDEMPOTENCY_KEY_CONFLICT`, a safeguard:
27
+ * the current service never sends it. The action is unresolved; keep it
28
+ * pending and reconcile it, and never resend it under a new key.
27
29
  * - `"client-schema"` — a `422`: the payload's shape is wrong. A client bug.
28
30
  * - `"rate-limited"` / `"unauthorized"` / `"forbidden"` / `"unknown-instance"` /
29
31
  * `"gateway-unavailable"` — the gateway answered, before any service saw it.
@@ -1 +1 @@
1
- {"version":3,"file":"classify-gasless-failure.d.ts","sourceRoot":"","sources":["../../src/gasless/classify-gasless-failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,GAAG,EAAE,KAAK,2BAA2B,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAM/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,oBAAoB,GAC5B,eAAe,GACf,eAAe,GACf,YAAY,GACZ,WAAW,GACX,kBAAkB,GAClB,mBAAmB,GACnB,uBAAuB,GACvB,wBAAwB,GACxB,sBAAsB,GACtB,eAAe,GACf,cAAc,GACd,cAAc,GACd,WAAW,GACX,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,qBAAqB,GACrB,SAAS,CAAC;AAyEd;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAkBzE;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,UAAU,EAAE,GAAG,CAAC;IAChB,sEAAsE;IACtE,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,8BAA8B,GAAG,IAAI,CAY3G"}
1
+ {"version":3,"file":"classify-gasless-failure.d.ts","sourceRoot":"","sources":["../../src/gasless/classify-gasless-failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,GAAG,EAAE,KAAK,2BAA2B,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAM/F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,oBAAoB,GAC5B,eAAe,GACf,eAAe,GACf,YAAY,GACZ,WAAW,GACX,kBAAkB,GAClB,mBAAmB,GACnB,uBAAuB,GACvB,wBAAwB,GACxB,sBAAsB,GACtB,eAAe,GACf,cAAc,GACd,cAAc,GACd,WAAW,GACX,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,qBAAqB,GACrB,SAAS,CAAC;AAyEd;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CAkBzE;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC7C,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,UAAU,EAAE,GAAG,CAAC;IAChB,sEAAsE;IACtE,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,8BAA8B,GAAG,IAAI,CAY3G"}
@@ -1,7 +1,7 @@
1
1
  import { gaslessRevertText as e, parseGaslessErrorDetail as t } from "./errors.js";
2
- import { getGaslessUnconfirmedSubmit as n, isGaslessIdempotencyConflictError as r } from "./unconfirmed-submit.js";
3
- import { classifyGaslessHttpStatus as i } from "./http.js";
4
- import { isGaslessFreeQuotaExhaustedError as a } from "./get-gasless-fee-quote/fee-quote-errors.js";
2
+ import { isGaslessFreeQuotaExhaustedError as n } from "./get-gasless-fee-quote/fee-quote-errors.js";
3
+ import { getGaslessUnconfirmedSubmit as r, isGaslessIdempotencyConflictError as i } from "./unconfirmed-submit.js";
4
+ import { classifyGaslessHttpStatus as a } from "./http.js";
5
5
  import { decodeErrorResult as o } from "viem";
6
6
  //#region src/gasless/classify-gasless-failure.ts
7
7
  function s(e) {
@@ -17,7 +17,7 @@ function c(e) {
17
17
  }
18
18
  }
19
19
  function l(e) {
20
- switch (i(e)) {
20
+ switch (a(e)) {
21
21
  case "rate-limited": return "rate-limited";
22
22
  case "unauthorized": return "unauthorized";
23
23
  case "forbidden": return "forbidden";
@@ -29,12 +29,12 @@ function l(e) {
29
29
  default: return null;
30
30
  }
31
31
  }
32
- function u(i) {
33
- if (n(i) !== null) return "submit-unconfirmed";
34
- if (r(i)) return "idempotency-conflict";
35
- if (a(i)) return "free-quota";
36
- let o = t(i);
37
- return s(e(o)) || (o?.failedOperation ? "failed-operation" : c(o?.code ?? null) || l(i) || (o?.code === "SIMULATION_REVERTED" ? "simulation-reverted" : "unknown"));
32
+ function u(a) {
33
+ if (r(a) !== null) return "submit-unconfirmed";
34
+ if (i(a)) return "idempotency-conflict";
35
+ if (n(a)) return "free-quota";
36
+ let o = t(a);
37
+ return s(e(o)) || (o?.failedOperation ? "failed-operation" : c(o?.code ?? null) || l(a) || (o?.code === "SIMULATION_REVERTED" ? "simulation-reverted" : "unknown"));
38
38
  }
39
39
  function d(e, n) {
40
40
  let r = t(e)?.failedOperation;
@@ -1 +1 @@
1
- {"version":3,"file":"classify-gasless-failure.js","names":[],"sources":["../../src/gasless/classify-gasless-failure.ts"],"sourcesContent":["import { decodeErrorResult, type Abi, type DecodeErrorResultReturnType, type Hex } from \"viem\";\nimport { gaslessRevertText, parseGaslessErrorDetail } from \"./errors\";\nimport { isGaslessFreeQuotaExhaustedError } from \"./get-gasless-fee-quote/fee-quote-errors\";\nimport { classifyGaslessHttpStatus } from \"./http\";\nimport { getGaslessUnconfirmedSubmit, isGaslessIdempotencyConflictError } from \"./unconfirmed-submit\";\n\n/**\n * Why a gasless action failed, in terms of what a UI can do about it.\n *\n * Deliberately coarser than the vendor's codes and finer than the HTTP status:\n * `INSUFFICIENT_ALLOWANCE` and an `OperationalFee: Allowance exceeded` revert\n * are the same problem with two wire shapes, while a `404` for an unknown\n * instance and a `404` for an unknown request id are not the same problem at\n * all.\n *\n * - `\"payer-balance\"` — the billing account cannot cover the fee. Top up its\n * SYMMIO collateral; raising the allowance alone does nothing.\n * - `\"fee-allowance\"` — the payer's operational-fee allowance is too low.\n * Approve more with `approveOperationalFee`, then re-read.\n * - `\"free-quota\"` — the daily free-operations quota is spent and the\n * deployment refuses paid ones. Wait for the UTC reset or use the wallet.\n * - `\"fee-limit\"` — the fee policy refused the request for any other reason.\n * - `\"failed-operation\"` — one entry of the batch reverted; decode it with\n * {@link decodeGaslessOperationFailure} to name the real cause.\n * - `\"nonce-or-deadline\"` — the signature is stale. Refresh the nonce and\n * deadline and ask for a new one; never resend the old payload.\n * - `\"deposit-below-minimum\"` — the deposit address holds less than the\n * settlement minimum, or the funds are not visible yet.\n * - `\"deposit-not-above-fees\"` — the balance clears the minimum but not the\n * deposit and wallet-creation fees.\n * - `\"idempotency-conflict\"` — the key belongs to another workflow; mint a new one.\n * - `\"client-schema\"` — a `422`: the payload's shape is wrong. A client bug.\n * - `\"rate-limited\"` / `\"unauthorized\"` / `\"forbidden\"` / `\"unknown-instance\"` /\n * `\"gateway-unavailable\"` — the gateway answered, before any service saw it.\n * - `\"submit-unconfirmed\"` — the outcome is unknown and the request may be\n * executing. Replay it with `resubmitGaslessRequest`; never re-run the intent.\n * - `\"simulation-reverted\"` — the service simulated the batch and it reverted\n * for a reason none of the above explains. Rebuild and re-sign.\n * - `\"unknown\"` — nothing classified it.\n */\nexport type GaslessFailureReason =\n | \"payer-balance\"\n | \"fee-allowance\"\n | \"free-quota\"\n | \"fee-limit\"\n | \"failed-operation\"\n | \"nonce-or-deadline\"\n | \"deposit-below-minimum\"\n | \"deposit-not-above-fees\"\n | \"idempotency-conflict\"\n | \"client-schema\"\n | \"rate-limited\"\n | \"unauthorized\"\n | \"forbidden\"\n | \"unknown-instance\"\n | \"gateway-unavailable\"\n | \"submit-unconfirmed\"\n | \"simulation-reverted\"\n | \"unknown\";\n\n/**\n * Map a revert the service decoded onto a reason, when one of the contract's\n * own error names or require-strings is unambiguous about the cause.\n *\n * The error names come from the perps-core 0.8.6 GaslessLayer and InstantLayer\n * ABIs. The `\"OperationalFee: …\"` strings are not theirs — they are SymmioCore's\n * own `LibOperationalFee` require messages, raised when the GaslessLayer charges\n * the payer (the same ones `approveOperationalFee` documents), and they reach the\n * SDK through the service's simulation of the batch.\n */\nfunction reasonFromRevert(text: string): GaslessFailureReason | null {\n if (text.includes(\"DailyFreeOpsLimitExceeded\")) return \"free-quota\";\n if (text.includes(\"OperationalFee: Insufficient balance\")) return \"payer-balance\";\n if (text.includes(\"OperationalFee: Allowance\") || text.includes(\"OperationalFee: Insufficient allowance\")) {\n return \"fee-allowance\";\n }\n if (text.includes(\"FeeLimitExceeded\") || text.includes(\"OperationalFee:\")) return \"fee-limit\";\n if (text.includes(\"DepositAmountBelowMinimum\")) return \"deposit-below-minimum\";\n if (text.includes(\"DepositAmountNotAboveFees\") || text.includes(\"MinimumDepositNotAboveFee\")) {\n return \"deposit-not-above-fees\";\n }\n if (\n text.includes(\"InvalidNonce\") ||\n text.includes(\"DeadlineExpired\") ||\n text.includes(\"WalletOperationExpired\") ||\n text.includes(\"WalletOperationInvalidNonce\") ||\n text.includes(\"NativeGasTopUpNonceMismatch\")\n ) {\n return \"nonce-or-deadline\";\n }\n return null;\n}\n\n/** Map a vendor `detail.code` onto a reason, where the code alone decides. */\nfunction reasonFromVendorCode(code: string | null): GaslessFailureReason | null {\n switch (code) {\n case \"IDEMPOTENCY_KEY_CONFLICT\":\n return \"idempotency-conflict\";\n case \"INSUFFICIENT_ALLOWANCE\":\n return \"fee-allowance\";\n case \"FEE_POLICY_WOULD_REVERT\":\n return \"fee-limit\";\n case \"DEPOSIT_BELOW_MINIMUM\":\n return \"deposit-below-minimum\";\n default:\n return null;\n }\n}\n\n/** Map the gateway's own answer onto a reason. */\nfunction reasonFromHttpStatus(err: unknown): GaslessFailureReason | null {\n switch (classifyGaslessHttpStatus(err)) {\n case \"rate-limited\":\n return \"rate-limited\";\n case \"unauthorized\":\n return \"unauthorized\";\n case \"forbidden\":\n return \"forbidden\";\n case \"unknown-instance\":\n case \"selector-conflict\":\n return \"unknown-instance\";\n case \"client-schema\":\n return \"client-schema\";\n case \"gateway-not-ready\":\n case \"ambiguous\":\n return \"gateway-unavailable\";\n default:\n return null;\n }\n}\n\n/**\n * Classify any gasless failure into the one reason a UI should act on.\n *\n * The order is deliberate: what the request *did* (unconfirmed, conflicting)\n * outranks what the service *said*, which outranks what the gateway answered —\n * a `400 SIMULATION_REVERTED` whose revert names an allowance shortfall is an\n * allowance problem, not a \"bad request\".\n *\n * Works on the error a framework layer re-wrapped too, so a React hook's\n * `SymmioRequestError` classifies exactly like the `SymmApiError` under it.\n *\n * @param err - Anything caught from a gasless action, or a polled record error.\n * @returns The reason, or `\"unknown\"` when nothing identifies it.\n *\n * @example\n * ```ts\n * switch (classifyGaslessFailure(err)) {\n * case \"fee-allowance\":\n * return showApproveOperationalFee();\n * case \"submit-unconfirmed\":\n * return showReconcilePending(getGaslessUnconfirmedSubmit(err));\n * default:\n * return showDiagnostics(parseGaslessErrorDetail(err));\n * }\n * ```\n */\nexport function classifyGaslessFailure(err: unknown): GaslessFailureReason {\n if (getGaslessUnconfirmedSubmit(err) !== null) return \"submit-unconfirmed\";\n if (isGaslessIdempotencyConflictError(err)) return \"idempotency-conflict\";\n /** Thrown by the fee pre-flight, before any HTTP call and with no vendor detail. */\n if (isGaslessFreeQuotaExhaustedError(err)) return \"free-quota\";\n\n const detail = parseGaslessErrorDetail(err);\n const fromRevert = reasonFromRevert(gaslessRevertText(detail));\n if (fromRevert) return fromRevert;\n if (detail?.failedOperation) return \"failed-operation\";\n\n const fromCode = reasonFromVendorCode(detail?.code ?? null);\n if (fromCode) return fromCode;\n\n const fromStatus = reasonFromHttpStatus(err);\n if (fromStatus) return fromStatus;\n\n return detail?.code === \"SIMULATION_REVERTED\" ? \"simulation-reverted\" : \"unknown\";\n}\n\n/**\n * The failing batch entry of an `OperationFailed` revert, with its inner revert\n * decoded against the ABI you supplied.\n */\nexport interface GaslessDecodedOperationFailure {\n /** Zero-based position of the failing operation in the submitted batch. */\n index: number;\n /** The inner revert data, exactly as the service reported it. */\n revertData: Hex;\n /** The decoded error, or `null` when the ABI does not describe it. */\n decoded: DecodeErrorResultReturnType | null;\n}\n\n/**\n * Identify the batch entry that reverted, and decode its inner revert.\n *\n * A relayed batch is atomic, so the InstantLayer reports an inner failure as\n * `OperationFailed(operationIndex, revertData)` — which names a position, not a\n * cause. Decoding `revertData` against the ABI of the contract that operation\n * targeted turns it back into the error the user can act on\n * (`InvalidNameLength`, `InsufficientBalance`, …).\n *\n * @param err - Anything caught from a gasless submit.\n * @param abi - ABI of the contract the failing operation targeted.\n * @returns The index, the raw revert data and the decoded error, or `null` when\n * the failure was not an `OperationFailed`.\n *\n * @example\n * ```ts\n * const failure = decodeGaslessOperationFailure(err, accountLayerAbi);\n * if (failure) {\n * console.error(`operation ${failure.index} reverted:`, failure.decoded?.errorName ?? failure.revertData);\n * }\n * ```\n */\nexport function decodeGaslessOperationFailure(err: unknown, abi: Abi): GaslessDecodedOperationFailure | null {\n const failed = parseGaslessErrorDetail(err)?.failedOperation;\n if (!failed) return null;\n\n let decoded: DecodeErrorResultReturnType | null = null;\n try {\n decoded = decodeErrorResult({ abi, data: failed.revertData });\n } catch {\n /** An ABI that does not describe this error is a caller mistake, not a reason to lose the index. */\n decoded = null;\n }\n return { index: failed.index, revertData: failed.revertData, decoded };\n}\n"],"mappings":";;;;;;AAsEA,SAAS,EAAiB,GAA2C;CAoBnE,OAnBI,EAAK,SAAS,2BAA2B,IAAU,eACnD,EAAK,SAAS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AO;CAEpB,IAAI,IAA8C;CAClD,IAAI;EACF,IAAU,EAAkB;GAAE;GAAK,MAAM,EAAO;EAAW,CAAC;CAC9D,QAAQ;EAEN,IAAU;CACZ;CACA,OAAO;EAAE,OAAO,EAAO;EAAO,YAAY,EAAO;EAAY;CAAQ;AACvE"}
1
+ {"version":3,"file":"classify-gasless-failure.js","names":[],"sources":["../../src/gasless/classify-gasless-failure.ts"],"sourcesContent":["import { decodeErrorResult, type Abi, type DecodeErrorResultReturnType, type Hex } from \"viem\";\nimport { gaslessRevertText, parseGaslessErrorDetail } from \"./errors\";\nimport { isGaslessFreeQuotaExhaustedError } from \"./get-gasless-fee-quote/fee-quote-errors\";\nimport { classifyGaslessHttpStatus } from \"./http\";\nimport { getGaslessUnconfirmedSubmit, isGaslessIdempotencyConflictError } from \"./unconfirmed-submit\";\n\n/**\n * Why a gasless action failed, in terms of what a UI can do about it.\n *\n * Deliberately coarser than the vendor's codes and finer than the HTTP status:\n * `INSUFFICIENT_ALLOWANCE` and an `OperationalFee: Allowance exceeded` revert\n * are the same problem with two wire shapes, while a `404` for an unknown\n * instance and a `404` for an unknown request id are not the same problem at\n * all.\n *\n * - `\"payer-balance\"` — the billing account cannot cover the fee. Top up its\n * SYMMIO collateral; raising the allowance alone does nothing.\n * - `\"fee-allowance\"` — the payer's operational-fee allowance is too low.\n * Approve more with `approveOperationalFee`, then re-read.\n * - `\"free-quota\"` — the daily free-operations quota is spent and the\n * deployment refuses paid ones. Wait for the UTC reset or use the wallet.\n * - `\"fee-limit\"` — the fee policy refused the request for any other reason.\n * - `\"failed-operation\"` — one entry of the batch reverted; decode it with\n * {@link decodeGaslessOperationFailure} to name the real cause.\n * - `\"nonce-or-deadline\"` — the signature is stale. Refresh the nonce and\n * deadline and ask for a new one; never resend the old payload.\n * - `\"deposit-below-minimum\"` — the deposit address holds less than the\n * settlement minimum, or the funds are not visible yet.\n * - `\"deposit-not-above-fees\"` — the balance clears the minimum but not the\n * deposit and wallet-creation fees.\n * - `\"idempotency-conflict\"` — a `409 IDEMPOTENCY_KEY_CONFLICT`, a safeguard:\n * the current service never sends it. The action is unresolved; keep it\n * pending and reconcile it, and never resend it under a new key.\n * - `\"client-schema\"` — a `422`: the payload's shape is wrong. A client bug.\n * - `\"rate-limited\"` / `\"unauthorized\"` / `\"forbidden\"` / `\"unknown-instance\"` /\n * `\"gateway-unavailable\"` — the gateway answered, before any service saw it.\n * - `\"submit-unconfirmed\"` — the outcome is unknown and the request may be\n * executing. Replay it with `resubmitGaslessRequest`; never re-run the intent.\n * - `\"simulation-reverted\"` — the service simulated the batch and it reverted\n * for a reason none of the above explains. Rebuild and re-sign.\n * - `\"unknown\"` — nothing classified it.\n */\nexport type GaslessFailureReason =\n | \"payer-balance\"\n | \"fee-allowance\"\n | \"free-quota\"\n | \"fee-limit\"\n | \"failed-operation\"\n | \"nonce-or-deadline\"\n | \"deposit-below-minimum\"\n | \"deposit-not-above-fees\"\n | \"idempotency-conflict\"\n | \"client-schema\"\n | \"rate-limited\"\n | \"unauthorized\"\n | \"forbidden\"\n | \"unknown-instance\"\n | \"gateway-unavailable\"\n | \"submit-unconfirmed\"\n | \"simulation-reverted\"\n | \"unknown\";\n\n/**\n * Map a revert the service decoded onto a reason, when one of the contract's\n * own error names or require-strings is unambiguous about the cause.\n *\n * The error names come from the perps-core 0.8.6 GaslessLayer and InstantLayer\n * ABIs. The `\"OperationalFee: …\"` strings are not theirs — they are SymmioCore's\n * own `LibOperationalFee` require messages, raised when the GaslessLayer charges\n * the payer (the same ones `approveOperationalFee` documents), and they reach the\n * SDK through the service's simulation of the batch.\n */\nfunction reasonFromRevert(text: string): GaslessFailureReason | null {\n if (text.includes(\"DailyFreeOpsLimitExceeded\")) return \"free-quota\";\n if (text.includes(\"OperationalFee: Insufficient balance\")) return \"payer-balance\";\n if (text.includes(\"OperationalFee: Allowance\") || text.includes(\"OperationalFee: Insufficient allowance\")) {\n return \"fee-allowance\";\n }\n if (text.includes(\"FeeLimitExceeded\") || text.includes(\"OperationalFee:\")) return \"fee-limit\";\n if (text.includes(\"DepositAmountBelowMinimum\")) return \"deposit-below-minimum\";\n if (text.includes(\"DepositAmountNotAboveFees\") || text.includes(\"MinimumDepositNotAboveFee\")) {\n return \"deposit-not-above-fees\";\n }\n if (\n text.includes(\"InvalidNonce\") ||\n text.includes(\"DeadlineExpired\") ||\n text.includes(\"WalletOperationExpired\") ||\n text.includes(\"WalletOperationInvalidNonce\") ||\n text.includes(\"NativeGasTopUpNonceMismatch\")\n ) {\n return \"nonce-or-deadline\";\n }\n return null;\n}\n\n/** Map a vendor `detail.code` onto a reason, where the code alone decides. */\nfunction reasonFromVendorCode(code: string | null): GaslessFailureReason | null {\n switch (code) {\n case \"IDEMPOTENCY_KEY_CONFLICT\":\n return \"idempotency-conflict\";\n case \"INSUFFICIENT_ALLOWANCE\":\n return \"fee-allowance\";\n case \"FEE_POLICY_WOULD_REVERT\":\n return \"fee-limit\";\n case \"DEPOSIT_BELOW_MINIMUM\":\n return \"deposit-below-minimum\";\n default:\n return null;\n }\n}\n\n/** Map the gateway's own answer onto a reason. */\nfunction reasonFromHttpStatus(err: unknown): GaslessFailureReason | null {\n switch (classifyGaslessHttpStatus(err)) {\n case \"rate-limited\":\n return \"rate-limited\";\n case \"unauthorized\":\n return \"unauthorized\";\n case \"forbidden\":\n return \"forbidden\";\n case \"unknown-instance\":\n case \"selector-conflict\":\n return \"unknown-instance\";\n case \"client-schema\":\n return \"client-schema\";\n case \"gateway-not-ready\":\n case \"ambiguous\":\n return \"gateway-unavailable\";\n default:\n return null;\n }\n}\n\n/**\n * Classify any gasless failure into the one reason a UI should act on.\n *\n * The order is deliberate: what the request *did* (unconfirmed, conflicting)\n * outranks what the service *said*, which outranks what the gateway answered —\n * a `400 SIMULATION_REVERTED` whose revert names an allowance shortfall is an\n * allowance problem, not a \"bad request\".\n *\n * Works on the error a framework layer re-wrapped too, so a React hook's\n * `SymmioRequestError` classifies exactly like the `SymmApiError` under it.\n *\n * @param err - Anything caught from a gasless action, or a polled record error.\n * @returns The reason, or `\"unknown\"` when nothing identifies it.\n *\n * @example\n * ```ts\n * switch (classifyGaslessFailure(err)) {\n * case \"fee-allowance\":\n * return showApproveOperationalFee();\n * case \"submit-unconfirmed\":\n * return showReconcilePending(getGaslessUnconfirmedSubmit(err));\n * default:\n * return showDiagnostics(parseGaslessErrorDetail(err));\n * }\n * ```\n */\nexport function classifyGaslessFailure(err: unknown): GaslessFailureReason {\n if (getGaslessUnconfirmedSubmit(err) !== null) return \"submit-unconfirmed\";\n if (isGaslessIdempotencyConflictError(err)) return \"idempotency-conflict\";\n /** Thrown by the fee pre-flight, before any HTTP call and with no vendor detail. */\n if (isGaslessFreeQuotaExhaustedError(err)) return \"free-quota\";\n\n const detail = parseGaslessErrorDetail(err);\n const fromRevert = reasonFromRevert(gaslessRevertText(detail));\n if (fromRevert) return fromRevert;\n if (detail?.failedOperation) return \"failed-operation\";\n\n const fromCode = reasonFromVendorCode(detail?.code ?? null);\n if (fromCode) return fromCode;\n\n const fromStatus = reasonFromHttpStatus(err);\n if (fromStatus) return fromStatus;\n\n return detail?.code === \"SIMULATION_REVERTED\" ? \"simulation-reverted\" : \"unknown\";\n}\n\n/**\n * The failing batch entry of an `OperationFailed` revert, with its inner revert\n * decoded against the ABI you supplied.\n */\nexport interface GaslessDecodedOperationFailure {\n /** Zero-based position of the failing operation in the submitted batch. */\n index: number;\n /** The inner revert data, exactly as the service reported it. */\n revertData: Hex;\n /** The decoded error, or `null` when the ABI does not describe it. */\n decoded: DecodeErrorResultReturnType | null;\n}\n\n/**\n * Identify the batch entry that reverted, and decode its inner revert.\n *\n * A relayed batch is atomic, so the InstantLayer reports an inner failure as\n * `OperationFailed(operationIndex, revertData)` — which names a position, not a\n * cause. Decoding `revertData` against the ABI of the contract that operation\n * targeted turns it back into the error the user can act on\n * (`InvalidNameLength`, `InsufficientBalance`, …).\n *\n * @param err - Anything caught from a gasless submit.\n * @param abi - ABI of the contract the failing operation targeted.\n * @returns The index, the raw revert data and the decoded error, or `null` when\n * the failure was not an `OperationFailed`.\n *\n * @example\n * ```ts\n * const failure = decodeGaslessOperationFailure(err, accountLayerAbi);\n * if (failure) {\n * console.error(`operation ${failure.index} reverted:`, failure.decoded?.errorName ?? failure.revertData);\n * }\n * ```\n */\nexport function decodeGaslessOperationFailure(err: unknown, abi: Abi): GaslessDecodedOperationFailure | null {\n const failed = parseGaslessErrorDetail(err)?.failedOperation;\n if (!failed) return null;\n\n let decoded: DecodeErrorResultReturnType | null = null;\n try {\n decoded = decodeErrorResult({ abi, data: failed.revertData });\n } catch {\n /** An ABI that does not describe this error is a caller mistake, not a reason to lose the index. */\n decoded = null;\n }\n return { index: failed.index, revertData: failed.revertData, decoded };\n}\n"],"mappings":";;;;;;AAwEA,SAAS,EAAiB,GAA2C;CAoBnE,OAnBI,EAAK,SAAS,2BAA2B,IAAU,eACnD,EAAK,SAAS,sCAAsC,IAAU,kBAC9D,EAAK,SAAS,2BAA2B,KAAK,EAAK,SAAS,wCAAwC,IAC/F,kBAEL,EAAK,SAAS,kBAAkB,KAAK,EAAK,SAAS,iBAAiB,IAAU,cAC9E,EAAK,SAAS,2BAA2B,IAAU,0BACnD,EAAK,SAAS,2BAA2B,KAAK,EAAK,SAAS,2BAA2B,IAClF,2BAGP,EAAK,SAAS,cAAc,KAC5B,EAAK,SAAS,iBAAiB,KAC/B,EAAK,SAAS,wBAAwB,KACtC,EAAK,SAAS,6BAA6B,KAC3C,EAAK,SAAS,6BAA6B,IAEpC,sBAEF;AACT;AAGA,SAAS,EAAqB,GAAkD;CAC9E,QAAQ,GAAR;EACE,KAAK,4BACH,OAAO;EACT,KAAK,0BACH,OAAO;EACT,KAAK,2BACH,OAAO;EACT,KAAK,yBACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAGA,SAAS,EAAqB,GAA2C;CACvE,QAAQ,EAA0B,CAAG,GAArC;EACE,KAAK,gBACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,aACH,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