viem 2.57.4 → 2.57.6

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 (372) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/_cjs/actions/public/waitForTransactionReceipt.js +5 -2
  3. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  4. package/_cjs/actions/wallet/waitForCallsStatus.js +25 -2
  5. package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -1
  6. package/_cjs/chains/definitions/arcTestnet.js +11 -8
  7. package/_cjs/chains/definitions/arcTestnet.js.map +1 -1
  8. package/_cjs/chains/definitions/qmsTestnet.js +30 -0
  9. package/_cjs/chains/definitions/qmsTestnet.js.map +1 -0
  10. package/_cjs/chains/definitions/tempo.js +1 -1
  11. package/_cjs/chains/definitions/tempoModerato.js +2 -2
  12. package/_cjs/chains/index.js +7 -5
  13. package/_cjs/chains/index.js.map +1 -1
  14. package/_cjs/clients/transports/ipc.js +19 -10
  15. package/_cjs/clients/transports/ipc.js.map +1 -1
  16. package/_cjs/clients/transports/webSocket.js +19 -10
  17. package/_cjs/clients/transports/webSocket.js.map +1 -1
  18. package/_cjs/errors/version.js +1 -1
  19. package/_cjs/tempo/Abis.js +297 -1
  20. package/_cjs/tempo/Abis.js.map +1 -1
  21. package/_cjs/tempo/Account.js +40 -40
  22. package/_cjs/tempo/Account.js.map +1 -1
  23. package/_cjs/tempo/Addresses.js +2 -1
  24. package/_cjs/tempo/Addresses.js.map +1 -1
  25. package/_cjs/tempo/Decorator.js +9 -8
  26. package/_cjs/tempo/Decorator.js.map +1 -1
  27. package/_cjs/tempo/ExecutionError.js +95 -4
  28. package/_cjs/tempo/ExecutionError.js.map +1 -1
  29. package/_cjs/tempo/Formatters.js +8 -7
  30. package/_cjs/tempo/Formatters.js.map +1 -1
  31. package/_cjs/tempo/KeyAuthorizationManager.js +25 -16
  32. package/_cjs/tempo/KeyAuthorizationManager.js.map +1 -1
  33. package/_cjs/tempo/Relay.js +9 -4
  34. package/_cjs/tempo/Relay.js.map +1 -1
  35. package/_cjs/tempo/Transaction.js +9 -9
  36. package/_cjs/tempo/Transaction.js.map +1 -1
  37. package/_cjs/tempo/Transport.js +21 -11
  38. package/_cjs/tempo/Transport.js.map +1 -1
  39. package/_cjs/tempo/{multisig → accounts}/Config.js +8 -8
  40. package/_cjs/tempo/{multisig → accounts}/Config.js.map +1 -1
  41. package/_cjs/tempo/{multisig → accounts}/Operation.js +10 -10
  42. package/_cjs/tempo/{multisig → accounts}/Operation.js.map +1 -1
  43. package/_cjs/tempo/{multisig → accounts}/Signature.js +2 -2
  44. package/_cjs/tempo/accounts/Signature.js.map +1 -0
  45. package/_cjs/tempo/actions/accessKey.js +442 -47
  46. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  47. package/_cjs/tempo/actions/{multisig.js → accounts.js} +16 -20
  48. package/_cjs/tempo/actions/accounts.js.map +1 -0
  49. package/_cjs/tempo/actions/amm.js +90 -4
  50. package/_cjs/tempo/actions/amm.js.map +1 -1
  51. package/_cjs/tempo/actions/channel.js +183 -7
  52. package/_cjs/tempo/actions/channel.js.map +1 -1
  53. package/_cjs/tempo/actions/dex.js +507 -14
  54. package/_cjs/tempo/actions/dex.js.map +1 -1
  55. package/_cjs/tempo/actions/earn/deployment.js +4 -3
  56. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  57. package/_cjs/tempo/actions/earn.js +22 -21
  58. package/_cjs/tempo/actions/earn.js.map +1 -1
  59. package/_cjs/tempo/actions/fee.js +85 -5
  60. package/_cjs/tempo/actions/fee.js.map +1 -1
  61. package/_cjs/tempo/actions/index.js +2 -2
  62. package/_cjs/tempo/actions/index.js.map +1 -1
  63. package/_cjs/tempo/actions/nonce.js +54 -1
  64. package/_cjs/tempo/actions/nonce.js.map +1 -1
  65. package/_cjs/tempo/actions/policy.js +35 -6
  66. package/_cjs/tempo/actions/policy.js.map +1 -1
  67. package/_cjs/tempo/actions/propAmm.js +18 -8
  68. package/_cjs/tempo/actions/propAmm.js.map +1 -1
  69. package/_cjs/tempo/actions/receivePolicy.js +7 -6
  70. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  71. package/_cjs/tempo/actions/reward.js +7 -6
  72. package/_cjs/tempo/actions/reward.js.map +1 -1
  73. package/_cjs/tempo/actions/token.js +433 -22
  74. package/_cjs/tempo/actions/token.js.map +1 -1
  75. package/_cjs/tempo/actions/validator.js +12 -11
  76. package/_cjs/tempo/actions/validator.js.map +1 -1
  77. package/_cjs/tempo/actions/virtualAddress.js +3 -2
  78. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  79. package/_cjs/tempo/actions/zone.js +12 -11
  80. package/_cjs/tempo/actions/zone.js.map +1 -1
  81. package/_cjs/tempo/chainConfig.js +37 -37
  82. package/_cjs/tempo/chainConfig.js.map +1 -1
  83. package/_cjs/tempo/errors.js +57 -1
  84. package/_cjs/tempo/errors.js.map +1 -1
  85. package/_cjs/tempo/index.js +3 -3
  86. package/_cjs/tempo/index.js.map +1 -1
  87. package/_cjs/tempo/internal/errors.js +46 -0
  88. package/_cjs/tempo/internal/errors.js.map +1 -0
  89. package/_cjs/tempo/internal/relay/{multisig.js → accounts.js} +90 -93
  90. package/_cjs/tempo/internal/relay/accounts.js.map +1 -0
  91. package/_cjs/tempo/internal/relay/keyAuthorization.js +296 -0
  92. package/_cjs/tempo/internal/relay/keyAuthorization.js.map +1 -0
  93. package/_cjs/tempo/internal/relay/plugin.js +17 -7
  94. package/_cjs/tempo/internal/relay/plugin.js.map +1 -1
  95. package/_cjs/tempo/internal/resolveError.js +128 -0
  96. package/_cjs/tempo/internal/resolveError.js.map +1 -0
  97. package/_cjs/tempo/internal/utils.js +1 -0
  98. package/_cjs/tempo/internal/utils.js.map +1 -1
  99. package/_cjs/utils/hash/normalizeSignature.js +1 -1
  100. package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
  101. package/_cjs/utils/rpc/http.js +66 -31
  102. package/_cjs/utils/rpc/http.js.map +1 -1
  103. package/_cjs/utils/rpc/socket.js +1 -1
  104. package/_cjs/utils/rpc/socket.js.map +1 -1
  105. package/_esm/actions/public/waitForTransactionReceipt.js +5 -2
  106. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  107. package/_esm/actions/wallet/waitForCallsStatus.js +39 -2
  108. package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -1
  109. package/_esm/chains/definitions/arcTestnet.js +11 -8
  110. package/_esm/chains/definitions/arcTestnet.js.map +1 -1
  111. package/_esm/chains/definitions/qmsTestnet.js +27 -0
  112. package/_esm/chains/definitions/qmsTestnet.js.map +1 -0
  113. package/_esm/chains/definitions/tempo.js +1 -1
  114. package/_esm/chains/definitions/tempoModerato.js +2 -2
  115. package/_esm/chains/index.js +1 -0
  116. package/_esm/chains/index.js.map +1 -1
  117. package/_esm/clients/transports/ipc.js +21 -10
  118. package/_esm/clients/transports/ipc.js.map +1 -1
  119. package/_esm/clients/transports/webSocket.js +21 -10
  120. package/_esm/clients/transports/webSocket.js.map +1 -1
  121. package/_esm/errors/version.js +1 -1
  122. package/_esm/tempo/Abis.js +297 -0
  123. package/_esm/tempo/Abis.js.map +1 -1
  124. package/_esm/tempo/Account.js +42 -42
  125. package/_esm/tempo/Account.js.map +1 -1
  126. package/_esm/tempo/Addresses.js +1 -0
  127. package/_esm/tempo/Addresses.js.map +1 -1
  128. package/_esm/tempo/Client.js +3 -3
  129. package/_esm/tempo/Decorator.js +9 -8
  130. package/_esm/tempo/Decorator.js.map +1 -1
  131. package/_esm/tempo/ExecutionError.js +96 -3
  132. package/_esm/tempo/ExecutionError.js.map +1 -1
  133. package/_esm/tempo/Formatters.js +11 -10
  134. package/_esm/tempo/Formatters.js.map +1 -1
  135. package/_esm/tempo/KeyAuthorizationManager.js +58 -16
  136. package/_esm/tempo/KeyAuthorizationManager.js.map +1 -1
  137. package/_esm/tempo/Relay.js +49 -8
  138. package/_esm/tempo/Relay.js.map +1 -1
  139. package/_esm/tempo/Transaction.js +11 -11
  140. package/_esm/tempo/Transaction.js.map +1 -1
  141. package/_esm/tempo/Transport.js +22 -12
  142. package/_esm/tempo/Transport.js.map +1 -1
  143. package/_esm/tempo/{multisig → accounts}/Config.js +14 -14
  144. package/_esm/tempo/{multisig → accounts}/Config.js.map +1 -1
  145. package/_esm/tempo/{multisig → accounts}/Operation.js +17 -17
  146. package/_esm/tempo/{multisig → accounts}/Operation.js.map +1 -1
  147. package/_esm/tempo/accounts/Signature.js +9 -0
  148. package/_esm/tempo/accounts/Signature.js.map +1 -0
  149. package/_esm/tempo/actions/accessKey.js +499 -48
  150. package/_esm/tempo/actions/accessKey.js.map +1 -1
  151. package/_esm/tempo/actions/{multisig.js → accounts.js} +34 -38
  152. package/_esm/tempo/actions/accounts.js.map +1 -0
  153. package/_esm/tempo/actions/amm.js +95 -4
  154. package/_esm/tempo/actions/amm.js.map +1 -1
  155. package/_esm/tempo/actions/channel.js +191 -7
  156. package/_esm/tempo/actions/channel.js.map +1 -1
  157. package/_esm/tempo/actions/dex.js +537 -14
  158. package/_esm/tempo/actions/dex.js.map +1 -1
  159. package/_esm/tempo/actions/earn/deployment.js +4 -3
  160. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  161. package/_esm/tempo/actions/earn.js +22 -21
  162. package/_esm/tempo/actions/earn.js.map +1 -1
  163. package/_esm/tempo/actions/fee.js +90 -6
  164. package/_esm/tempo/actions/fee.js.map +1 -1
  165. package/_esm/tempo/actions/index.js +1 -1
  166. package/_esm/tempo/actions/index.js.map +1 -1
  167. package/_esm/tempo/actions/nonce.js +57 -1
  168. package/_esm/tempo/actions/nonce.js.map +1 -1
  169. package/_esm/tempo/actions/policy.js +36 -6
  170. package/_esm/tempo/actions/policy.js.map +1 -1
  171. package/_esm/tempo/actions/propAmm.js +18 -8
  172. package/_esm/tempo/actions/propAmm.js.map +1 -1
  173. package/_esm/tempo/actions/receivePolicy.js +7 -6
  174. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  175. package/_esm/tempo/actions/reward.js +7 -6
  176. package/_esm/tempo/actions/reward.js.map +1 -1
  177. package/_esm/tempo/actions/token.js +461 -22
  178. package/_esm/tempo/actions/token.js.map +1 -1
  179. package/_esm/tempo/actions/validator.js +12 -11
  180. package/_esm/tempo/actions/validator.js.map +1 -1
  181. package/_esm/tempo/actions/virtualAddress.js +3 -2
  182. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  183. package/_esm/tempo/actions/zone.js +12 -11
  184. package/_esm/tempo/actions/zone.js.map +1 -1
  185. package/_esm/tempo/chainConfig.js +38 -38
  186. package/_esm/tempo/chainConfig.js.map +1 -1
  187. package/_esm/tempo/errors.js +63 -0
  188. package/_esm/tempo/errors.js.map +1 -1
  189. package/_esm/tempo/index.js +2 -1
  190. package/_esm/tempo/index.js.map +1 -1
  191. package/_esm/tempo/internal/errors.js +51 -0
  192. package/_esm/tempo/internal/errors.js.map +1 -0
  193. package/_esm/tempo/internal/relay/{multisig.js → accounts.js} +93 -98
  194. package/_esm/tempo/internal/relay/accounts.js.map +1 -0
  195. package/_esm/tempo/internal/relay/feePayer.js +1 -1
  196. package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
  197. package/_esm/tempo/internal/relay/keyAuthorization.js +334 -0
  198. package/_esm/tempo/internal/relay/keyAuthorization.js.map +1 -0
  199. package/_esm/tempo/internal/relay/plugin.js +15 -6
  200. package/_esm/tempo/internal/relay/plugin.js.map +1 -1
  201. package/_esm/tempo/internal/resolveError.js +130 -0
  202. package/_esm/tempo/internal/resolveError.js.map +1 -0
  203. package/_esm/tempo/internal/utils.js +2 -0
  204. package/_esm/tempo/internal/utils.js.map +1 -1
  205. package/_esm/utils/hash/normalizeSignature.js +3 -2
  206. package/_esm/utils/hash/normalizeSignature.js.map +1 -1
  207. package/_esm/utils/rpc/http.js +74 -31
  208. package/_esm/utils/rpc/http.js.map +1 -1
  209. package/_esm/utils/rpc/socket.js +3 -1
  210. package/_esm/utils/rpc/socket.js.map +1 -1
  211. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  212. package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
  213. package/_types/chains/definitions/arcTestnet.d.ts +5 -5
  214. package/_types/chains/definitions/arcTestnet.d.ts.map +1 -1
  215. package/_types/chains/definitions/qmsTestnet.d.ts +50 -0
  216. package/_types/chains/definitions/qmsTestnet.d.ts.map +1 -0
  217. package/_types/chains/definitions/tempo.d.ts +2 -2
  218. package/_types/chains/definitions/tempoModerato.d.ts +4 -4
  219. package/_types/chains/index.d.ts +1 -0
  220. package/_types/chains/index.d.ts.map +1 -1
  221. package/_types/clients/transports/ipc.d.ts.map +1 -1
  222. package/_types/clients/transports/webSocket.d.ts.map +1 -1
  223. package/_types/errors/version.d.ts +1 -1
  224. package/_types/tempo/Abis.d.ts +807 -0
  225. package/_types/tempo/Abis.d.ts.map +1 -1
  226. package/_types/tempo/Account.d.ts +28 -28
  227. package/_types/tempo/Account.d.ts.map +1 -1
  228. package/_types/tempo/Addresses.d.ts +1 -0
  229. package/_types/tempo/Addresses.d.ts.map +1 -1
  230. package/_types/tempo/Client.d.ts +3 -3
  231. package/_types/tempo/Decorator.d.ts +64 -38
  232. package/_types/tempo/Decorator.d.ts.map +1 -1
  233. package/_types/tempo/ExecutionError.d.ts +3 -1
  234. package/_types/tempo/ExecutionError.d.ts.map +1 -1
  235. package/_types/tempo/Formatters.d.ts.map +1 -1
  236. package/_types/tempo/KeyAuthorizationManager.d.ts +45 -2
  237. package/_types/tempo/KeyAuthorizationManager.d.ts.map +1 -1
  238. package/_types/tempo/Relay.d.ts +62 -12
  239. package/_types/tempo/Relay.d.ts.map +1 -1
  240. package/_types/tempo/Transaction.d.ts +14 -11
  241. package/_types/tempo/Transaction.d.ts.map +1 -1
  242. package/_types/tempo/Transport.d.ts +20 -7
  243. package/_types/tempo/Transport.d.ts.map +1 -1
  244. package/_types/tempo/{multisig → accounts}/Config.d.ts +7 -7
  245. package/_types/tempo/accounts/Config.d.ts.map +1 -0
  246. package/_types/tempo/{multisig → accounts}/Operation.d.ts +7 -7
  247. package/_types/tempo/accounts/Operation.d.ts.map +1 -0
  248. package/_types/tempo/{multisig → accounts}/Signature.d.ts +1 -1
  249. package/_types/tempo/accounts/Signature.d.ts.map +1 -0
  250. package/_types/tempo/actions/accessKey.d.ts +214 -25
  251. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  252. package/_types/tempo/actions/{multisig.d.ts → accounts.d.ts} +31 -29
  253. package/_types/tempo/actions/accounts.d.ts.map +1 -0
  254. package/_types/tempo/actions/amm.d.ts +39 -0
  255. package/_types/tempo/actions/amm.d.ts.map +1 -1
  256. package/_types/tempo/actions/channel.d.ts +77 -7
  257. package/_types/tempo/actions/channel.d.ts.map +1 -1
  258. package/_types/tempo/actions/dex.d.ts +222 -16
  259. package/_types/tempo/actions/dex.d.ts.map +1 -1
  260. package/_types/tempo/actions/earn/deployment.d.ts +7 -6
  261. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  262. package/_types/tempo/actions/earn.d.ts +15 -14
  263. package/_types/tempo/actions/earn.d.ts.map +1 -1
  264. package/_types/tempo/actions/fee.d.ts +32 -6
  265. package/_types/tempo/actions/fee.d.ts.map +1 -1
  266. package/_types/tempo/actions/index.d.ts +1 -1
  267. package/_types/tempo/actions/index.d.ts.map +1 -1
  268. package/_types/tempo/actions/nonce.d.ts +35 -0
  269. package/_types/tempo/actions/nonce.d.ts.map +1 -1
  270. package/_types/tempo/actions/policy.d.ts +29 -8
  271. package/_types/tempo/actions/policy.d.ts.map +1 -1
  272. package/_types/tempo/actions/propAmm.d.ts +9 -1
  273. package/_types/tempo/actions/propAmm.d.ts.map +1 -1
  274. package/_types/tempo/actions/receivePolicy.d.ts +10 -6
  275. package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
  276. package/_types/tempo/actions/reward.d.ts +7 -3
  277. package/_types/tempo/actions/reward.d.ts.map +1 -1
  278. package/_types/tempo/actions/token.d.ts +200 -32
  279. package/_types/tempo/actions/token.d.ts.map +1 -1
  280. package/_types/tempo/actions/validator.d.ts +17 -5
  281. package/_types/tempo/actions/validator.d.ts.map +1 -1
  282. package/_types/tempo/actions/virtualAddress.d.ts +4 -3
  283. package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
  284. package/_types/tempo/actions/zone.d.ts +10 -9
  285. package/_types/tempo/actions/zone.d.ts.map +1 -1
  286. package/_types/tempo/errors.d.ts +63 -1
  287. package/_types/tempo/errors.d.ts.map +1 -1
  288. package/_types/tempo/index.d.ts +3 -2
  289. package/_types/tempo/index.d.ts.map +1 -1
  290. package/_types/tempo/internal/errors.d.ts +59 -0
  291. package/_types/tempo/internal/errors.d.ts.map +1 -0
  292. package/_types/tempo/internal/relay/accounts.d.ts +15 -0
  293. package/_types/tempo/internal/relay/accounts.d.ts.map +1 -0
  294. package/_types/tempo/internal/relay/keyAuthorization.d.ts +25 -0
  295. package/_types/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
  296. package/_types/tempo/internal/relay/plugin.d.ts +6 -3
  297. package/_types/tempo/internal/relay/plugin.d.ts.map +1 -1
  298. package/_types/tempo/internal/resolveError.d.ts +8 -0
  299. package/_types/tempo/internal/resolveError.d.ts.map +1 -0
  300. package/_types/tempo/internal/utils.d.ts.map +1 -1
  301. package/_types/utils/hash/normalizeSignature.d.ts.map +1 -1
  302. package/_types/utils/rpc/http.d.ts.map +1 -1
  303. package/_types/utils/rpc/socket.d.ts.map +1 -1
  304. package/actions/public/waitForTransactionReceipt.ts +8 -2
  305. package/actions/wallet/waitForCallsStatus.ts +41 -2
  306. package/chains/definitions/arcTestnet.ts +11 -8
  307. package/chains/definitions/qmsTestnet.ts +27 -0
  308. package/chains/definitions/tempo.ts +1 -1
  309. package/chains/definitions/tempoModerato.ts +2 -2
  310. package/chains/index.ts +1 -0
  311. package/clients/transports/ipc.ts +38 -29
  312. package/clients/transports/webSocket.ts +42 -33
  313. package/errors/version.ts +1 -1
  314. package/package.json +2 -2
  315. package/tempo/Abis.ts +298 -0
  316. package/tempo/Account.ts +95 -84
  317. package/tempo/Addresses.ts +1 -0
  318. package/tempo/Client.ts +3 -3
  319. package/tempo/Decorator.ts +91 -60
  320. package/tempo/ExecutionError.ts +102 -4
  321. package/tempo/Formatters.ts +14 -13
  322. package/tempo/KeyAuthorizationManager.ts +71 -19
  323. package/tempo/Relay.ts +70 -14
  324. package/tempo/Transaction.ts +31 -23
  325. package/tempo/Transport.ts +49 -21
  326. package/tempo/{multisig → accounts}/Config.ts +21 -21
  327. package/tempo/{multisig → accounts}/Operation.ts +26 -26
  328. package/tempo/{multisig → accounts}/Signature.ts +5 -3
  329. package/tempo/actions/accessKey.ts +675 -104
  330. package/tempo/actions/{multisig.ts → accounts.ts} +54 -59
  331. package/tempo/actions/amm.ts +126 -4
  332. package/tempo/actions/channel.ts +248 -14
  333. package/tempo/actions/dex.ts +599 -33
  334. package/tempo/actions/earn/deployment.ts +11 -9
  335. package/tempo/actions/earn.ts +40 -35
  336. package/tempo/actions/fee.ts +111 -9
  337. package/tempo/actions/index.ts +1 -1
  338. package/tempo/actions/nonce.ts +86 -1
  339. package/tempo/actions/policy.ts +66 -14
  340. package/tempo/actions/propAmm.ts +36 -9
  341. package/tempo/actions/receivePolicy.ts +26 -15
  342. package/tempo/actions/reward.ts +17 -9
  343. package/tempo/actions/token.ts +519 -54
  344. package/tempo/actions/validator.ts +40 -16
  345. package/tempo/actions/virtualAddress.ts +7 -5
  346. package/tempo/actions/zone.ts +25 -20
  347. package/tempo/chainConfig.ts +52 -52
  348. package/tempo/errors.ts +114 -1
  349. package/tempo/index.ts +5 -4
  350. package/tempo/internal/errors.ts +110 -0
  351. package/tempo/internal/relay/{multisig.ts → accounts.ts} +118 -118
  352. package/tempo/internal/relay/feePayer.ts +1 -1
  353. package/tempo/internal/relay/keyAuthorization.ts +415 -0
  354. package/tempo/internal/relay/plugin.ts +20 -7
  355. package/tempo/internal/resolveError.ts +169 -0
  356. package/tempo/internal/utils.ts +2 -0
  357. package/utils/hash/normalizeSignature.ts +3 -2
  358. package/utils/rpc/http.ts +76 -30
  359. package/utils/rpc/socket.ts +3 -1
  360. package/_cjs/tempo/actions/multisig.js.map +0 -1
  361. package/_cjs/tempo/internal/relay/multisig.js.map +0 -1
  362. package/_cjs/tempo/multisig/Signature.js.map +0 -1
  363. package/_esm/tempo/actions/multisig.js.map +0 -1
  364. package/_esm/tempo/internal/relay/multisig.js.map +0 -1
  365. package/_esm/tempo/multisig/Signature.js +0 -9
  366. package/_esm/tempo/multisig/Signature.js.map +0 -1
  367. package/_types/tempo/actions/multisig.d.ts.map +0 -1
  368. package/_types/tempo/internal/relay/multisig.d.ts +0 -4
  369. package/_types/tempo/internal/relay/multisig.d.ts.map +0 -1
  370. package/_types/tempo/multisig/Config.d.ts.map +0 -1
  371. package/_types/tempo/multisig/Operation.d.ts.map +0 -1
  372. package/_types/tempo/multisig/Signature.d.ts.map +0 -1
@@ -24,8 +24,16 @@ import type { ExtractAbiItem, GetEventArgs } from '../../types/contract.js'
24
24
  import type { Log as viem_Log } from '../../types/log.js'
25
25
  import type { Compute, UnionOmit } from '../../types/utils.js'
26
26
  import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
27
+ import { isAddressEqual } from '../../utils/address/isAddressEqual.js'
27
28
  import * as Abis from '../Abis.js'
28
29
  import * as Addresses from '../Addresses.js'
30
+ import type * as Errors from '../errors.js'
31
+ import { TempoExecutionError } from '../errors.js'
32
+ import {
33
+ type Context,
34
+ type Resolvers,
35
+ withExecutionError,
36
+ } from '../internal/errors.js'
29
37
  import type {
30
38
  GetAccountParameter,
31
39
  ReadParameters,
@@ -97,7 +105,7 @@ export namespace buy {
97
105
  export type ReturnValue = WriteContractReturnType
98
106
 
99
107
  // TODO: exhaustive error type
100
- export type ErrorType = BaseErrorType
108
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
101
109
 
102
110
  /** @internal */
103
111
  export async function inner<
@@ -111,7 +119,7 @@ export namespace buy {
111
119
  ): Promise<ReturnType<action>> {
112
120
  const { tokenIn, tokenOut, amountOut, maxAmountIn, ...rest } = parameters
113
121
  const call = buy.call({ tokenIn, tokenOut, amountOut, maxAmountIn })
114
- return (await action(client, {
122
+ return (await withExecutionError(action)(client, {
115
123
  ...rest,
116
124
  ...call,
117
125
  } as never)) as never
@@ -219,7 +227,7 @@ export namespace buySync {
219
227
  }>
220
228
 
221
229
  // TODO: exhaustive error type
222
- export type ErrorType = BaseErrorType
230
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
223
231
  }
224
232
 
225
233
  /**
@@ -271,7 +279,7 @@ export namespace cancel {
271
279
  export type ReturnValue = WriteContractReturnType
272
280
 
273
281
  // TODO: exhaustive error type
274
- export type ErrorType = BaseErrorType
282
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
275
283
 
276
284
  /** @internal */
277
285
  export async function inner<
@@ -285,7 +293,7 @@ export namespace cancel {
285
293
  ): Promise<ReturnType<action>> {
286
294
  const { orderId, ...rest } = parameters
287
295
  const call = cancel.call({ orderId })
288
- return (await action(client, {
296
+ return (await withExecutionError(action)(client, {
289
297
  ...rest,
290
298
  ...call,
291
299
  } as never)) as never
@@ -416,7 +424,7 @@ export namespace cancelSync {
416
424
  >
417
425
 
418
426
  // TODO: exhaustive error type
419
- export type ErrorType = BaseErrorType
427
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
420
428
  }
421
429
 
422
430
  /**
@@ -471,7 +479,7 @@ export namespace cancelStale {
471
479
  export type ReturnValue = WriteContractReturnType
472
480
 
473
481
  // TODO: exhaustive error type
474
- export type ErrorType = BaseErrorType
482
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
475
483
 
476
484
  /** @internal */
477
485
  export async function inner<
@@ -485,7 +493,7 @@ export namespace cancelStale {
485
493
  ): Promise<ReturnType<action>> {
486
494
  const { orderId, ...rest } = parameters
487
495
  const call = cancelStale.call({ orderId })
488
- return (await action(client, {
496
+ return (await withExecutionError(action)(client, {
489
497
  ...rest,
490
498
  ...call,
491
499
  } as never)) as never
@@ -619,7 +627,7 @@ export namespace cancelStaleSync {
619
627
  >
620
628
 
621
629
  // TODO: exhaustive error type
622
- export type ErrorType = BaseErrorType
630
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
623
631
  }
624
632
 
625
633
  /**
@@ -671,7 +679,7 @@ export namespace createPair {
671
679
  export type ReturnValue = WriteContractReturnType
672
680
 
673
681
  // TODO: exhaustive error type
674
- export type ErrorType = BaseErrorType
682
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
675
683
 
676
684
  /** @internal */
677
685
  export async function inner<
@@ -685,7 +693,7 @@ export namespace createPair {
685
693
  ): Promise<ReturnType<action>> {
686
694
  const { base, ...rest } = parameters
687
695
  const call = createPair.call({ base })
688
- return (await action(client, {
696
+ return (await withExecutionError(action)(client, {
689
697
  ...rest,
690
698
  ...call,
691
699
  } as never)) as never
@@ -816,7 +824,7 @@ export namespace createPairSync {
816
824
  >
817
825
 
818
826
  // TODO: exhaustive error type
819
- export type ErrorType = BaseErrorType
827
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
820
828
  }
821
829
 
822
830
  /**
@@ -853,7 +861,7 @@ export async function getBalance<
853
861
  const { account: acc = client.account, token, ...rest } = parameters
854
862
  const address = acc ? parseAccount(acc).address : undefined
855
863
  if (!address) throw new Error('account is required.')
856
- return readContract(client, {
864
+ return withExecutionError(readContract)(client, {
857
865
  ...rest,
858
866
  ...getBalance.call({ account: address, token }),
859
867
  })
@@ -892,6 +900,8 @@ export namespace getBalance {
892
900
  functionName: 'balanceOf',
893
901
  })
894
902
  }
903
+
904
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
895
905
  }
896
906
 
897
907
  /**
@@ -924,7 +934,7 @@ export async function getBuyQuote<chain extends Chain | undefined>(
924
934
  parameters: getBuyQuote.Parameters,
925
935
  ): Promise<getBuyQuote.ReturnValue> {
926
936
  const { tokenIn, tokenOut, amountOut, ...rest } = parameters
927
- return readContract(client, {
937
+ return withExecutionError(readContract)(client, {
928
938
  ...rest,
929
939
  ...getBuyQuote.call({ tokenIn, tokenOut, amountOut }),
930
940
  })
@@ -963,6 +973,8 @@ export namespace getBuyQuote {
963
973
  functionName: 'quoteSwapExactAmountOut',
964
974
  })
965
975
  }
976
+
977
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
966
978
  }
967
979
 
968
980
  /**
@@ -993,7 +1005,7 @@ export async function getOrder<chain extends Chain | undefined>(
993
1005
  parameters: getOrder.Parameters,
994
1006
  ): Promise<getOrder.ReturnValue> {
995
1007
  const { orderId, ...rest } = parameters
996
- return readContract(client, {
1008
+ return withExecutionError(readContract)(client, {
997
1009
  ...rest,
998
1010
  ...getOrder.call({ orderId }),
999
1011
  })
@@ -1028,6 +1040,8 @@ export namespace getOrder {
1028
1040
  functionName: 'getOrder',
1029
1041
  })
1030
1042
  }
1043
+
1044
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1031
1045
  }
1032
1046
 
1033
1047
  /**
@@ -1059,7 +1073,7 @@ export async function getOrderbook<chain extends Chain | undefined>(
1059
1073
  parameters: getOrderbook.Parameters,
1060
1074
  ): Promise<getOrderbook.ReturnValue> {
1061
1075
  const { base, quote, ...rest } = parameters
1062
- return readContract(client, {
1076
+ return withExecutionError(readContract)(client, {
1063
1077
  ...rest,
1064
1078
  ...getOrderbook.call({ base, quote }),
1065
1079
  })
@@ -1097,6 +1111,8 @@ export namespace getOrderbook {
1097
1111
  functionName: 'books',
1098
1112
  })
1099
1113
  }
1114
+
1115
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1100
1116
  }
1101
1117
 
1102
1118
  /**
@@ -1129,10 +1145,13 @@ export async function getTickLevel<chain extends Chain | undefined>(
1129
1145
  parameters: getTickLevel.Parameters,
1130
1146
  ): Promise<getTickLevel.ReturnValue> {
1131
1147
  const { base, tick, isBid, ...rest } = parameters
1132
- const [head, tail, totalLiquidity] = await readContract(client, {
1133
- ...rest,
1134
- ...getTickLevel.call({ base, tick, isBid }),
1135
- })
1148
+ const [head, tail, totalLiquidity] = await withExecutionError(readContract)(
1149
+ client,
1150
+ {
1151
+ ...rest,
1152
+ ...getTickLevel.call({ base, tick, isBid }),
1153
+ },
1154
+ )
1136
1155
  return { head, tail, totalLiquidity }
1137
1156
  }
1138
1157
 
@@ -1172,6 +1191,8 @@ export namespace getTickLevel {
1172
1191
  functionName: 'getTickLevel',
1173
1192
  })
1174
1193
  }
1194
+
1195
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1175
1196
  }
1176
1197
 
1177
1198
  /**
@@ -1204,7 +1225,7 @@ export async function getSellQuote<chain extends Chain | undefined>(
1204
1225
  parameters: getSellQuote.Parameters,
1205
1226
  ): Promise<getSellQuote.ReturnValue> {
1206
1227
  const { tokenIn, tokenOut, amountIn, ...rest } = parameters
1207
- return readContract(client, {
1228
+ return withExecutionError(readContract)(client, {
1208
1229
  ...rest,
1209
1230
  ...getSellQuote.call({ tokenIn, tokenOut, amountIn }),
1210
1231
  })
@@ -1243,6 +1264,8 @@ export namespace getSellQuote {
1243
1264
  functionName: 'quoteSwapExactAmountIn',
1244
1265
  })
1245
1266
  }
1267
+
1268
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1246
1269
  }
1247
1270
 
1248
1271
  /**
@@ -1303,7 +1326,7 @@ export namespace place {
1303
1326
  export type ReturnValue = WriteContractReturnType
1304
1327
 
1305
1328
  // TODO: exhaustive error type
1306
- export type ErrorType = BaseErrorType
1329
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1307
1330
 
1308
1331
  /** @internal */
1309
1332
  export async function inner<
@@ -1317,7 +1340,7 @@ export namespace place {
1317
1340
  ): Promise<ReturnType<action>> {
1318
1341
  const { amount, token, type, tick, ...rest } = parameters
1319
1342
  const call = place.call({ amount, token, type, tick })
1320
- return (await action(client, {
1343
+ return (await withExecutionError(action)(client, {
1321
1344
  ...rest,
1322
1345
  ...call,
1323
1346
  } as never)) as never
@@ -1447,7 +1470,7 @@ export namespace placeFlip {
1447
1470
  export type ReturnValue = WriteContractReturnType
1448
1471
 
1449
1472
  // TODO: exhaustive error type
1450
- export type ErrorType = BaseErrorType
1473
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1451
1474
 
1452
1475
  /** @internal */
1453
1476
  export async function inner<
@@ -1461,7 +1484,7 @@ export namespace placeFlip {
1461
1484
  ): Promise<ReturnType<action>> {
1462
1485
  const { amount, flipTick, tick, token, type, ...rest } = parameters
1463
1486
  const call = placeFlip.call({ amount, flipTick, tick, token, type })
1464
- return (await action(client, {
1487
+ return (await withExecutionError(action)(client, {
1465
1488
  ...rest,
1466
1489
  ...call,
1467
1490
  } as never)) as never
@@ -1602,7 +1625,7 @@ export namespace placeFlipSync {
1602
1625
  >
1603
1626
 
1604
1627
  // TODO: exhaustive error type
1605
- export type ErrorType = BaseErrorType
1628
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1606
1629
  }
1607
1630
 
1608
1631
  /**
@@ -1674,7 +1697,7 @@ export namespace placeSync {
1674
1697
  >
1675
1698
 
1676
1699
  // TODO: exhaustive error type
1677
- export type ErrorType = BaseErrorType
1700
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1678
1701
  }
1679
1702
 
1680
1703
  /**
@@ -1735,7 +1758,7 @@ export namespace sell {
1735
1758
  export type ReturnValue = WriteContractReturnType
1736
1759
 
1737
1760
  // TODO: exhaustive error type
1738
- export type ErrorType = BaseErrorType
1761
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1739
1762
 
1740
1763
  /** @internal */
1741
1764
  export async function inner<
@@ -1749,7 +1772,7 @@ export namespace sell {
1749
1772
  ): Promise<ReturnType<action>> {
1750
1773
  const { tokenIn, tokenOut, amountIn, minAmountOut, ...rest } = parameters
1751
1774
  const call = sell.call({ tokenIn, tokenOut, amountIn, minAmountOut })
1752
- return (await action(client, {
1775
+ return (await withExecutionError(action)(client, {
1753
1776
  ...rest,
1754
1777
  ...call,
1755
1778
  } as never)) as never
@@ -1857,7 +1880,7 @@ export namespace sellSync {
1857
1880
  }>
1858
1881
 
1859
1882
  // TODO: exhaustive error type
1860
- export type ErrorType = BaseErrorType
1883
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
1861
1884
  }
1862
1885
 
1863
1886
  /**
@@ -2236,7 +2259,7 @@ export namespace withdraw {
2236
2259
  export type ReturnValue = WriteContractReturnType
2237
2260
 
2238
2261
  // TODO: exhaustive error type
2239
- export type ErrorType = BaseErrorType
2262
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
2240
2263
 
2241
2264
  /** @internal */
2242
2265
  export async function inner<
@@ -2250,7 +2273,7 @@ export namespace withdraw {
2250
2273
  ): Promise<ReturnType<action>> {
2251
2274
  const { token, amount, ...rest } = parameters
2252
2275
  const call = withdraw.call({ token, amount })
2253
- return (await action(client, {
2276
+ return (await withExecutionError(action)(client, {
2254
2277
  ...rest,
2255
2278
  ...call,
2256
2279
  } as never)) as never
@@ -2354,9 +2377,552 @@ export namespace withdrawSync {
2354
2377
  }>
2355
2378
 
2356
2379
  // TODO: exhaustive error type
2357
- export type ErrorType = BaseErrorType
2380
+ export type ErrorType = Errors.ExecutionErrorType | BaseErrorType
2358
2381
  }
2359
2382
 
2360
2383
  function getPairKey(base: Address, quote: Address) {
2361
2384
  return Hash.keccak256(Hex.concat(base, quote))
2362
2385
  }
2386
+
2387
+ // Errors
2388
+
2389
+ /** Errors this module throws for decoded Tempo errors. Narrow with `error.name`. */
2390
+ export type ExecutionErrorType =
2391
+ | DexBelowMinimumOrderSizeErrorType
2392
+ | DexInsufficientBalanceErrorType
2393
+ | DexInsufficientLiquidityErrorType
2394
+ | DexInsufficientOutputErrorType
2395
+ | DexInvalidFlipTickErrorType
2396
+ | DexMaxInputExceededErrorType
2397
+ | DexOrderNotFoundErrorType
2398
+ | DexOrderNotStaleErrorType
2399
+ | DexPairNotFoundErrorType
2400
+ | DexTickOutOfBoundsErrorType
2401
+
2402
+ /** `DexInsufficientOutputError` with a literal `name`, for narrowing. */
2403
+ export type DexInsufficientOutputErrorType = DexInsufficientOutputError & {
2404
+ name: 'DexInsufficientOutputError'
2405
+ }
2406
+
2407
+ /** Thrown when a sell would return less than `minAmountOut`. */
2408
+ export class DexInsufficientOutputError extends TempoExecutionError<
2409
+ Errors.TempoExecutionError.Decoded<'InsufficientOutput'>
2410
+ > {
2411
+ /** Amount of `tokenIn` to sell. */
2412
+ amountIn: bigint | undefined
2413
+ /** Minimum amount of `tokenOut` to receive. */
2414
+ minAmountOut: bigint | undefined
2415
+ /** Current quote for `amountIn`, when available. */
2416
+ quote: bigint | undefined
2417
+ /** Token to sell. */
2418
+ tokenIn: Address | undefined
2419
+ /** Token to buy. */
2420
+ tokenOut: Address | undefined
2421
+
2422
+ constructor(parameters: DexInsufficientOutputError.Parameters) {
2423
+ const { amountIn, minAmountOut, quote, tokenIn, tokenOut } = parameters
2424
+ super(parameters, {
2425
+ details: {
2426
+ 'token in': tokenIn,
2427
+ 'token out': tokenOut,
2428
+ 'amount in': amountIn,
2429
+ 'min amount out': minAmountOut,
2430
+ quote,
2431
+ },
2432
+ name: 'DexInsufficientOutputError',
2433
+ })
2434
+ this.amountIn = amountIn
2435
+ this.minAmountOut = minAmountOut
2436
+ this.quote = quote
2437
+ this.tokenIn = tokenIn
2438
+ this.tokenOut = tokenOut
2439
+ }
2440
+ }
2441
+
2442
+ export declare namespace DexInsufficientOutputError {
2443
+ /** Constructor parameters. */
2444
+ type Parameters = Errors.TempoExecutionError.Parameters & {
2445
+ /** Amount of `tokenIn` to sell. */
2446
+ amountIn?: bigint | undefined
2447
+ /** Minimum amount of `tokenOut` to receive. */
2448
+ minAmountOut?: bigint | undefined
2449
+ /** Current quote for `amountIn`, when available. */
2450
+ quote?: bigint | undefined
2451
+ /** Token to sell. */
2452
+ tokenIn?: Address | undefined
2453
+ /** Token to buy. */
2454
+ tokenOut?: Address | undefined
2455
+ }
2456
+ }
2457
+
2458
+ /** `DexMaxInputExceededError` with a literal `name`, for narrowing. */
2459
+ export type DexMaxInputExceededErrorType = DexMaxInputExceededError & {
2460
+ name: 'DexMaxInputExceededError'
2461
+ }
2462
+
2463
+ /** Thrown when a buy would cost more than `maxAmountIn`. */
2464
+ export class DexMaxInputExceededError extends TempoExecutionError<
2465
+ Errors.TempoExecutionError.Decoded<'MaxInputExceeded'>
2466
+ > {
2467
+ /** Amount of `tokenOut` to buy. */
2468
+ amountOut: bigint | undefined
2469
+ /** Maximum amount of `tokenIn` to spend. */
2470
+ maxAmountIn: bigint | undefined
2471
+ /** Current cost of `amountOut`, when available. */
2472
+ quote: bigint | undefined
2473
+ /** Token to spend. */
2474
+ tokenIn: Address | undefined
2475
+ /** Token to buy. */
2476
+ tokenOut: Address | undefined
2477
+
2478
+ constructor(parameters: DexMaxInputExceededError.Parameters) {
2479
+ const { amountOut, maxAmountIn, quote, tokenIn, tokenOut } = parameters
2480
+ super(parameters, {
2481
+ details: {
2482
+ 'token in': tokenIn,
2483
+ 'token out': tokenOut,
2484
+ 'amount out': amountOut,
2485
+ 'max amount in': maxAmountIn,
2486
+ quote,
2487
+ },
2488
+ name: 'DexMaxInputExceededError',
2489
+ })
2490
+ this.amountOut = amountOut
2491
+ this.maxAmountIn = maxAmountIn
2492
+ this.quote = quote
2493
+ this.tokenIn = tokenIn
2494
+ this.tokenOut = tokenOut
2495
+ }
2496
+ }
2497
+
2498
+ export declare namespace DexMaxInputExceededError {
2499
+ /** Constructor parameters. */
2500
+ type Parameters = Errors.TempoExecutionError.Parameters & {
2501
+ /** Amount of `tokenOut` to buy. */
2502
+ amountOut?: bigint | undefined
2503
+ /** Maximum amount of `tokenIn` to spend. */
2504
+ maxAmountIn?: bigint | undefined
2505
+ /** Current cost of `amountOut`, when available. */
2506
+ quote?: bigint | undefined
2507
+ /** Token to spend. */
2508
+ tokenIn?: Address | undefined
2509
+ /** Token to buy. */
2510
+ tokenOut?: Address | undefined
2511
+ }
2512
+ }
2513
+
2514
+ /** `DexInsufficientLiquidityError` with a literal `name`, for narrowing. */
2515
+ export type DexInsufficientLiquidityErrorType =
2516
+ DexInsufficientLiquidityError & { name: 'DexInsufficientLiquidityError' }
2517
+
2518
+ /** Thrown when the order book cannot fill a swap. */
2519
+ export class DexInsufficientLiquidityError extends TempoExecutionError<
2520
+ Errors.TempoExecutionError.Decoded<'InsufficientLiquidity'>
2521
+ > {
2522
+ /** Amount of `tokenIn` to sell, for sells. */
2523
+ amountIn: bigint | undefined
2524
+ /** Amount of `tokenOut` to buy, for buys. */
2525
+ amountOut: bigint | undefined
2526
+ /** Token to spend. */
2527
+ tokenIn: Address | undefined
2528
+ /** Token to buy. */
2529
+ tokenOut: Address | undefined
2530
+
2531
+ constructor(
2532
+ parameters: Errors.TempoExecutionError.Parameters & {
2533
+ amountIn?: bigint | undefined
2534
+ amountOut?: bigint | undefined
2535
+ tokenIn?: Address | undefined
2536
+ tokenOut?: Address | undefined
2537
+ },
2538
+ ) {
2539
+ const { amountIn, amountOut, tokenIn, tokenOut } = parameters
2540
+ super(parameters, {
2541
+ details: {
2542
+ 'token in': tokenIn,
2543
+ 'token out': tokenOut,
2544
+ 'amount in': amountIn,
2545
+ 'amount out': amountOut,
2546
+ },
2547
+ name: 'DexInsufficientLiquidityError',
2548
+ })
2549
+ this.amountIn = amountIn
2550
+ this.amountOut = amountOut
2551
+ this.tokenIn = tokenIn
2552
+ this.tokenOut = tokenOut
2553
+ }
2554
+ }
2555
+
2556
+ /** `DexBelowMinimumOrderSizeError` with a literal `name`, for narrowing. */
2557
+ export type DexBelowMinimumOrderSizeErrorType =
2558
+ DexBelowMinimumOrderSizeError & { name: 'DexBelowMinimumOrderSizeError' }
2559
+
2560
+ /** Thrown when an order is smaller than the minimum order size. */
2561
+ export class DexBelowMinimumOrderSizeError extends TempoExecutionError<
2562
+ Errors.TempoExecutionError.Decoded<'BelowMinimumOrderSize'>
2563
+ > {
2564
+ /** Order amount. */
2565
+ amount: bigint
2566
+ /** Minimum order amount, when known. */
2567
+ minimum: bigint | undefined
2568
+
2569
+ constructor(
2570
+ parameters: Errors.TempoExecutionError.Parameters & {
2571
+ minimum?: bigint | undefined
2572
+ },
2573
+ ) {
2574
+ const [amount] = parameters.error.args as readonly [bigint]
2575
+ const { minimum } = parameters
2576
+ super(parameters, {
2577
+ details: { amount, minimum },
2578
+ name: 'DexBelowMinimumOrderSizeError',
2579
+ shortMessage: `Order amount ${amount} is below the minimum${minimum === undefined ? '' : ` of ${minimum}`}.`,
2580
+ })
2581
+ this.amount = amount
2582
+ this.minimum = minimum
2583
+ }
2584
+ }
2585
+
2586
+ /** `DexTickOutOfBoundsError` with a literal `name`, for narrowing. */
2587
+ export type DexTickOutOfBoundsErrorType = DexTickOutOfBoundsError & {
2588
+ name: 'DexTickOutOfBoundsError'
2589
+ }
2590
+
2591
+ /** Thrown when an order's tick or flip tick is outside the allowed range. */
2592
+ export class DexTickOutOfBoundsError extends TempoExecutionError<
2593
+ Errors.TempoExecutionError.Decoded<'TickOutOfBounds'>
2594
+ > {
2595
+ /** Highest allowed tick, when known. */
2596
+ maxTick: number | undefined
2597
+ /** Lowest allowed tick, when known. */
2598
+ minTick: number | undefined
2599
+ /** Tick that is out of range. */
2600
+ tick: number
2601
+
2602
+ constructor(
2603
+ parameters: Errors.TempoExecutionError.Parameters & {
2604
+ maxTick?: number | undefined
2605
+ minTick?: number | undefined
2606
+ },
2607
+ ) {
2608
+ const [tick] = parameters.error.args as readonly [number]
2609
+ const { maxTick, minTick } = parameters
2610
+ super(parameters, {
2611
+ details: {
2612
+ tick,
2613
+ range:
2614
+ minTick === undefined || maxTick === undefined
2615
+ ? undefined
2616
+ : `${minTick} to ${maxTick}`,
2617
+ },
2618
+ name: 'DexTickOutOfBoundsError',
2619
+ })
2620
+ this.maxTick = maxTick
2621
+ this.minTick = minTick
2622
+ this.tick = tick
2623
+ }
2624
+ }
2625
+
2626
+ /** `DexInvalidFlipTickError` with a literal `name`, for narrowing. */
2627
+ export type DexInvalidFlipTickErrorType = DexInvalidFlipTickError & {
2628
+ name: 'DexInvalidFlipTickError'
2629
+ }
2630
+
2631
+ /** Thrown when a flip order's flip tick is on the wrong side of its tick or off the tick spacing. */
2632
+ export class DexInvalidFlipTickError extends TempoExecutionError<
2633
+ Errors.TempoExecutionError.Decoded<'InvalidFlipTick'>
2634
+ > {
2635
+ /** Flip tick. */
2636
+ flipTick: number | undefined
2637
+ /** Order side. */
2638
+ side: 'buy' | 'sell' | undefined
2639
+ /** Order tick. */
2640
+ tick: number | undefined
2641
+ /** Tick spacing, when known. */
2642
+ tickSpacing: number | undefined
2643
+
2644
+ constructor(
2645
+ parameters: Errors.TempoExecutionError.Parameters & {
2646
+ flipTick?: number | undefined
2647
+ side?: 'buy' | 'sell' | undefined
2648
+ tick?: number | undefined
2649
+ tickSpacing?: number | undefined
2650
+ },
2651
+ ) {
2652
+ const { flipTick, side, tick, tickSpacing } = parameters
2653
+ super(parameters, {
2654
+ details: {
2655
+ side,
2656
+ tick,
2657
+ 'flip tick': flipTick,
2658
+ 'tick spacing': tickSpacing,
2659
+ },
2660
+ name: 'DexInvalidFlipTickError',
2661
+ shortMessage:
2662
+ side === 'buy'
2663
+ ? 'The flip tick of a buy order must be at or above its tick, and a multiple of the tick spacing.'
2664
+ : side === 'sell'
2665
+ ? 'The flip tick of a sell order must be at or below its tick, and a multiple of the tick spacing.'
2666
+ : undefined,
2667
+ })
2668
+ this.flipTick = flipTick
2669
+ this.side = side
2670
+ this.tick = tick
2671
+ this.tickSpacing = tickSpacing
2672
+ }
2673
+ }
2674
+
2675
+ /** `DexOrderNotFoundError` with a literal `name`, for narrowing. */
2676
+ export type DexOrderNotFoundErrorType = DexOrderNotFoundError & {
2677
+ name: 'DexOrderNotFoundError'
2678
+ }
2679
+
2680
+ /** Thrown when an order does not exist or is already filled. */
2681
+ export class DexOrderNotFoundError extends TempoExecutionError<
2682
+ Errors.TempoExecutionError.Decoded<'OrderDoesNotExist'>
2683
+ > {
2684
+ /** Order ID. */
2685
+ orderId: bigint
2686
+
2687
+ constructor(
2688
+ parameters: Errors.TempoExecutionError.Parameters & { orderId: bigint },
2689
+ ) {
2690
+ super(parameters, {
2691
+ details: { order: parameters.orderId },
2692
+ name: 'DexOrderNotFoundError',
2693
+ shortMessage: `Order ${parameters.orderId} does not exist or is already filled.`,
2694
+ })
2695
+ this.orderId = parameters.orderId
2696
+ }
2697
+ }
2698
+
2699
+ /** `DexOrderNotStaleError` with a literal `name`, for narrowing. */
2700
+ export type DexOrderNotStaleErrorType = DexOrderNotStaleError & {
2701
+ name: 'DexOrderNotStaleError'
2702
+ }
2703
+
2704
+ /** Thrown when cancelling a stale order whose maker is still authorized by the token's policy. */
2705
+ export class DexOrderNotStaleError extends TempoExecutionError<
2706
+ Errors.TempoExecutionError.Decoded<'OrderNotStale'>
2707
+ > {
2708
+ /** Order ID. */
2709
+ orderId: bigint
2710
+
2711
+ constructor(
2712
+ parameters: Errors.TempoExecutionError.Parameters & { orderId: bigint },
2713
+ ) {
2714
+ super(parameters, {
2715
+ details: { order: parameters.orderId },
2716
+ name: 'DexOrderNotStaleError',
2717
+ shortMessage: `Order ${parameters.orderId} is not stale: its maker is still authorized.`,
2718
+ })
2719
+ this.orderId = parameters.orderId
2720
+ }
2721
+ }
2722
+
2723
+ /** `DexPairNotFoundError` with a literal `name`, for narrowing. */
2724
+ export type DexPairNotFoundErrorType = DexPairNotFoundError & {
2725
+ name: 'DexPairNotFoundError'
2726
+ }
2727
+
2728
+ /** Thrown when no trading pair exists for a token. */
2729
+ export class DexPairNotFoundError extends TempoExecutionError<
2730
+ Errors.TempoExecutionError.Decoded<'PairDoesNotExist'>
2731
+ > {
2732
+ /** Tokens of the call. */
2733
+ tokens: readonly Address[]
2734
+
2735
+ constructor(
2736
+ parameters: Errors.TempoExecutionError.Parameters & {
2737
+ tokens: readonly Address[]
2738
+ },
2739
+ ) {
2740
+ super(parameters, {
2741
+ details: { tokens: parameters.tokens.join(', ') || undefined },
2742
+ name: 'DexPairNotFoundError',
2743
+ })
2744
+ this.tokens = parameters.tokens
2745
+ }
2746
+ }
2747
+
2748
+ /** `DexInsufficientBalanceError` with a literal `name`, for narrowing. */
2749
+ export type DexInsufficientBalanceErrorType = DexInsufficientBalanceError & {
2750
+ name: 'DexInsufficientBalanceError'
2751
+ }
2752
+
2753
+ /** Thrown when withdrawing more than the account's exchange balance. */
2754
+ export class DexInsufficientBalanceError extends TempoExecutionError<
2755
+ Errors.TempoExecutionError.Decoded<'InsufficientBalance'>
2756
+ > {
2757
+ /** Amount to withdraw. */
2758
+ amount: bigint | undefined
2759
+ /** Exchange balance, when known. */
2760
+ balance: bigint | undefined
2761
+ /** Token address. */
2762
+ token: Address
2763
+
2764
+ constructor(
2765
+ parameters: Errors.TempoExecutionError.Parameters & {
2766
+ amount?: bigint | undefined
2767
+ balance?: bigint | undefined
2768
+ token: Address
2769
+ },
2770
+ ) {
2771
+ const { amount, balance, token } = parameters
2772
+ super(parameters, {
2773
+ details: { token, amount, balance },
2774
+ name: 'DexInsufficientBalanceError',
2775
+ shortMessage: `Insufficient exchange balance of token "${token}".`,
2776
+ })
2777
+ this.amount = amount
2778
+ this.balance = balance
2779
+ this.token = token
2780
+ }
2781
+ }
2782
+
2783
+ const exchange = {
2784
+ address: Addresses.stablecoinDex,
2785
+ abi: Abis.stablecoinDex,
2786
+ } as const
2787
+
2788
+ /** The failed call, when it targets the exchange. */
2789
+ function getExchangeCall(context: Context) {
2790
+ const { call } = context
2791
+ return call && isAddressEqual(call.address, Addresses.stablecoinDex)
2792
+ ? call
2793
+ : undefined
2794
+ }
2795
+
2796
+ /** @internal */
2797
+ export const errorResolvers: Resolvers = {
2798
+ 'BelowMinimumOrderSize(uint128)': async (context) => {
2799
+ if (!getExchangeCall(context) || !context.base.error.args) return undefined
2800
+ const [minimum] = await context.read([
2801
+ { ...exchange, functionName: 'MIN_ORDER_AMOUNT' },
2802
+ ])
2803
+ return new DexBelowMinimumOrderSizeError({
2804
+ ...context.base,
2805
+ minimum: minimum?.result,
2806
+ })
2807
+ },
2808
+ 'InsufficientBalance()': async (context) => {
2809
+ const call = getExchangeCall(context)
2810
+ const token = call?.arg<Address>('token')
2811
+ if (call?.functionName !== 'withdraw' || !token || !context.signer)
2812
+ return undefined
2813
+ const [balance] = await context.read([
2814
+ {
2815
+ ...exchange,
2816
+ functionName: 'balanceOf',
2817
+ args: [context.signer.address, token],
2818
+ },
2819
+ ])
2820
+ return new DexInsufficientBalanceError({
2821
+ ...context.base,
2822
+ amount: call.arg<bigint>('amount'),
2823
+ balance: balance?.result,
2824
+ token,
2825
+ })
2826
+ },
2827
+ 'InsufficientLiquidity()': (context) => {
2828
+ const call = getExchangeCall(context)
2829
+ if (!call) return undefined
2830
+ return new DexInsufficientLiquidityError({
2831
+ ...context.base,
2832
+ amountIn: call.arg<bigint>('amountIn'),
2833
+ amountOut: call.arg<bigint>('amountOut'),
2834
+ tokenIn: call.arg<Address>('tokenIn'),
2835
+ tokenOut: call.arg<Address>('tokenOut'),
2836
+ })
2837
+ },
2838
+ 'InsufficientOutput()': async (context) => {
2839
+ const call = getExchangeCall(context)
2840
+ if (!call) return undefined
2841
+ const tokenIn = call.arg<Address>('tokenIn')!
2842
+ const tokenOut = call.arg<Address>('tokenOut')!
2843
+ const amountIn = call.arg<bigint>('amountIn')!
2844
+ const [quote] = await context.read([
2845
+ {
2846
+ ...exchange,
2847
+ functionName: 'quoteSwapExactAmountIn',
2848
+ args: [tokenIn, tokenOut, amountIn],
2849
+ },
2850
+ ])
2851
+ return new DexInsufficientOutputError({
2852
+ ...context.base,
2853
+ amountIn,
2854
+ minAmountOut: call.arg<bigint>('minAmountOut'),
2855
+ quote: quote?.result,
2856
+ tokenIn,
2857
+ tokenOut,
2858
+ })
2859
+ },
2860
+ 'InvalidFlipTick()': async (context) => {
2861
+ const call = getExchangeCall(context)
2862
+ if (!call) return undefined
2863
+ const [tickSpacing] = await context.read([
2864
+ { ...exchange, functionName: 'TICK_SPACING' },
2865
+ ])
2866
+ const isBid = call.arg<boolean>('isBid')
2867
+ return new DexInvalidFlipTickError({
2868
+ ...context.base,
2869
+ flipTick: call.arg<number>('flipTick'),
2870
+ side: isBid === undefined ? undefined : isBid ? 'buy' : 'sell',
2871
+ tick: call.arg<number>('tick'),
2872
+ tickSpacing: tickSpacing?.result,
2873
+ })
2874
+ },
2875
+ 'MaxInputExceeded()': async (context) => {
2876
+ const call = getExchangeCall(context)
2877
+ if (!call) return undefined
2878
+ const tokenIn = call.arg<Address>('tokenIn')!
2879
+ const tokenOut = call.arg<Address>('tokenOut')!
2880
+ const amountOut = call.arg<bigint>('amountOut')!
2881
+ const [quote] = await context.read([
2882
+ {
2883
+ ...exchange,
2884
+ functionName: 'quoteSwapExactAmountOut',
2885
+ args: [tokenIn, tokenOut, amountOut],
2886
+ },
2887
+ ])
2888
+ return new DexMaxInputExceededError({
2889
+ ...context.base,
2890
+ amountOut,
2891
+ maxAmountIn: call.arg<bigint>('maxAmountIn'),
2892
+ quote: quote?.result,
2893
+ tokenIn,
2894
+ tokenOut,
2895
+ })
2896
+ },
2897
+ 'OrderDoesNotExist()': (context) => {
2898
+ const orderId = getExchangeCall(context)?.arg<bigint>('orderId')
2899
+ if (orderId === undefined) return undefined
2900
+ return new DexOrderNotFoundError({ ...context.base, orderId })
2901
+ },
2902
+ 'OrderNotStale()': (context) => {
2903
+ const orderId = getExchangeCall(context)?.arg<bigint>('orderId')
2904
+ if (orderId === undefined) return undefined
2905
+ return new DexOrderNotStaleError({ ...context.base, orderId })
2906
+ },
2907
+ 'PairDoesNotExist()': (context) => {
2908
+ const call = getExchangeCall(context)
2909
+ if (!call) return undefined
2910
+ const tokens = ['token', 'tokenIn', 'tokenOut', 'base'].flatMap((name) => {
2911
+ const token = call.arg<Address>(name)
2912
+ return token ? [token] : []
2913
+ })
2914
+ return new DexPairNotFoundError({ ...context.base, tokens })
2915
+ },
2916
+ 'TickOutOfBounds(int16)': async (context) => {
2917
+ if (!getExchangeCall(context) || !context.base.error.args) return undefined
2918
+ const [minTick, maxTick] = await context.read([
2919
+ { ...exchange, functionName: 'MIN_TICK' },
2920
+ { ...exchange, functionName: 'MAX_TICK' },
2921
+ ])
2922
+ return new DexTickOutOfBoundsError({
2923
+ ...context.base,
2924
+ maxTick: maxTick?.result,
2925
+ minTick: minTick?.result,
2926
+ })
2927
+ },
2928
+ }