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
@@ -419,7 +419,7 @@ async function handleRawTransaction(options: handleRawTransaction.Options) {
419
419
  })
420
420
 
421
421
  const transaction = Transaction.deserialize(serialized)
422
- // Prefer sender recovered from raw envelope; multisig finalize path supplies fallback sender.
422
+ // Prefer sender recovered from raw envelope; configurable account finalize path supplies fallback sender.
423
423
  const sender = transaction.from ?? options.sender
424
424
 
425
425
  // Sponsorship only applies after sender has signed original transaction.
@@ -0,0 +1,415 @@
1
+ import type { Address } from 'abitype'
2
+ import * as RpcResponse from 'ox/RpcResponse'
3
+ import {
4
+ AccountConfig,
5
+ AccountOperation,
6
+ KeyAuthorization,
7
+ SignatureEnvelope,
8
+ } from 'ox/tempo'
9
+ import { getBlockNumber } from '../../../actions/public/getBlockNumber.js'
10
+ import type { Client } from '../../../clients/createClient.js'
11
+ import { BaseError } from '../../../errors/base.js'
12
+ import { isAddressEqual } from '../../../utils/address/isAddressEqual.js'
13
+ import * as Actions from '../../actions/index.js'
14
+ import type * as Relay from '../../Relay.js'
15
+ import * as Store from '../../Store.js'
16
+ import { selectApprovals, validateConfig } from './accounts.js'
17
+ import * as Plugin from './plugin.js'
18
+
19
+ /** Creates middleware that stores pending key authorizations and attaches them to fills. @internal */
20
+ export function create(
21
+ options: Relay.keyAuthorization.Options = {},
22
+ ): Relay.keyAuthorization.ReturnType {
23
+ const { store = Store.memory() } = options
24
+ if (!store.compareAndSet)
25
+ throw new RpcResponse.InvalidParamsError({
26
+ message:
27
+ 'Key authorization storage requires a store with atomic `compareAndSet`.',
28
+ })
29
+ return Plugin.keyAuthorization({
30
+ async handleRequest(context, next) {
31
+ const { request } = context
32
+
33
+ if (request.method === 'relay_saveKeyAuthorization') {
34
+ const keyAuthorization = parse(request.params?.[0])
35
+ const chainId = Number(keyAuthorization.chainId)
36
+ if (
37
+ context.options.chainId !== undefined &&
38
+ context.options.chainId !== chainId
39
+ )
40
+ throw new RpcResponse.InvalidParamsError({
41
+ message: 'Conflicting chain ids.',
42
+ })
43
+ const client = context.getClient(chainId)
44
+ const account = await check(client, keyAuthorization)
45
+ if (!account) return null
46
+ // Drop an unusable pending authorization so it cannot block this one.
47
+ await read(client, store, {
48
+ account,
49
+ accessKey: keyAuthorization.address,
50
+ chainId,
51
+ })
52
+ if (!(await write(store, { account, keyAuthorization })))
53
+ throw new RpcResponse.InvalidParamsError({
54
+ message:
55
+ 'A pending key authorization for this access key expires later.',
56
+ })
57
+ return null
58
+ }
59
+
60
+ if (request.method === 'account_approveKeyAuthorization') {
61
+ await next()
62
+ const operation = AccountOperation.fromRpc(
63
+ context.result as AccountOperation.Rpc,
64
+ ) as AccountOperation.KeyAuthorizationOperation
65
+ if (operation.status !== 'success') return
66
+ const keyAuthorization = KeyAuthorization.deserialize(
67
+ operation.keyAuthorization,
68
+ ) as KeyAuthorization.Signed
69
+ // Re-check completed operations: quorum may land after expiry, and a
70
+ // stored success may predate a config rotation. The approval itself
71
+ // succeeded, so an authorization that fails these checks, or loses to a
72
+ // newer pending one, is skipped rather than reported. Operational
73
+ // failures propagate so callers know storage did not complete.
74
+ const chainId = Number(keyAuthorization.chainId)
75
+ const client = context.getClient(chainId)
76
+ const account = await check(client, keyAuthorization).catch((error) => {
77
+ if (error instanceof RpcResponse.InvalidParamsError) return undefined
78
+ throw error
79
+ })
80
+ if (!account) return
81
+ await read(client, store, {
82
+ account,
83
+ accessKey: keyAuthorization.address,
84
+ chainId,
85
+ })
86
+ await write(store, { account, keyAuthorization })
87
+ return
88
+ }
89
+
90
+ if (request.method !== 'eth_fillTransaction') return next()
91
+
92
+ const parameters = request.params?.[0] as Record<string, unknown>
93
+ const { from: account, keyId: accessKey } = parameters
94
+ if (
95
+ parameters.keyAuthorization ||
96
+ typeof account !== 'string' ||
97
+ typeof accessKey !== 'string'
98
+ )
99
+ return next()
100
+
101
+ const pending = await read(context.client, store, {
102
+ account: account as Address,
103
+ accessKey: accessKey as Address,
104
+ chainId: context.options.chainId!,
105
+ })
106
+ if (!pending) return next()
107
+ const metadata = await Actions.accessKey.getMetadata(context.client, {
108
+ account: account as Address,
109
+ accessKey: accessKey as Address,
110
+ })
111
+ // The key already landed onchain, so the authorization is spent.
112
+ if (isActive(metadata, accessKey as Address)) {
113
+ await remove(store, pending)
114
+ return next()
115
+ }
116
+ const keyAuthorization = KeyAuthorization.toRpc(pending.keyAuthorization)
117
+
118
+ // Attach before forwarding so gas estimation and later plugins see the authorization.
119
+ context.request = {
120
+ ...request,
121
+ params: [{ ...parameters, keyAuthorization }],
122
+ }
123
+ return next()
124
+ },
125
+ })
126
+ }
127
+
128
+ /** Parses a signed key authorization from RPC parameters. */
129
+ function parse(value: unknown) {
130
+ const keyAuthorization = (() => {
131
+ try {
132
+ if (typeof value === 'string')
133
+ return KeyAuthorization.deserialize(value as `0x${string}`)
134
+ return KeyAuthorization.fromRpc(value as KeyAuthorization.Rpc)
135
+ } catch {
136
+ return undefined
137
+ }
138
+ })()
139
+ if (!keyAuthorization?.signature)
140
+ throw new RpcResponse.InvalidParamsError({
141
+ message: 'Expected a signed key authorization.',
142
+ })
143
+ return keyAuthorization as KeyAuthorization.Signed
144
+ }
145
+
146
+ /**
147
+ * Validates an authorization and returns the account it authorizes, or `undefined`
148
+ * when the access key is already active onchain.
149
+ */
150
+ async function check(
151
+ client: Client,
152
+ keyAuthorization: KeyAuthorization.Signed,
153
+ ): Promise<Address | undefined> {
154
+ if (isExpired(keyAuthorization))
155
+ throw new RpcResponse.InvalidParamsError({
156
+ message: 'Key authorization has expired.',
157
+ })
158
+ const account = await verify(client, keyAuthorization)
159
+ if (await isBurned(client, { account, keyAuthorization }))
160
+ throw new RpcResponse.InvalidParamsError({
161
+ message: 'Key authorization witness has been burned.',
162
+ })
163
+ // Authorizations for keys that are already active would only be removed on the next fill.
164
+ const metadata = await Actions.accessKey.getMetadata(client, {
165
+ account,
166
+ accessKey: keyAuthorization.address,
167
+ })
168
+ if (isActive(metadata, keyAuthorization.address)) return undefined
169
+ return account
170
+ }
171
+
172
+ /** Verifies the authorization signature and returns the account it authorizes. */
173
+ async function verify(
174
+ client: Client,
175
+ keyAuthorization: KeyAuthorization.Signed,
176
+ ): Promise<Address> {
177
+ const { signature, ...unsigned } = keyAuthorization
178
+ const payload = KeyAuthorization.getSignPayload(unsigned)
179
+
180
+ if (signature.type === 'configurable') {
181
+ if (
182
+ !keyAuthorization.account ||
183
+ !isAddressEqual(keyAuthorization.account, signature.account)
184
+ )
185
+ throw new RpcResponse.InvalidParamsError({
186
+ message:
187
+ 'Configurable account key authorization account does not match its signature.',
188
+ })
189
+ const config = AccountConfig.from(signature.config)
190
+ await validateConfig({
191
+ account: signature.account,
192
+ blockNumber: await getBlockNumber(client, { cacheTime: 0 }),
193
+ client: client as never,
194
+ config,
195
+ })
196
+ const approvals = await selectApprovals({
197
+ account: signature.account,
198
+ approvals: signature.signatures.map((signature) =>
199
+ SignatureEnvelope.serialize(signature),
200
+ ),
201
+ config,
202
+ hash: AccountConfig.getSignPayload({
203
+ account: signature.account,
204
+ config,
205
+ payload,
206
+ }),
207
+ })
208
+ if (approvals.weight < approvals.threshold)
209
+ throw new RpcResponse.InvalidParamsError({
210
+ message:
211
+ 'Configurable account key authorization has not reached quorum.',
212
+ })
213
+ return signature.account
214
+ }
215
+
216
+ const signer = (() => {
217
+ try {
218
+ const signer = SignatureEnvelope.extractAddress({ payload, signature })
219
+ if (SignatureEnvelope.verify(signature, { address: signer, payload }))
220
+ return signer
221
+ } catch {}
222
+ throw new RpcResponse.InvalidParamsError({
223
+ message: 'Invalid key authorization signature.',
224
+ })
225
+ })()
226
+
227
+ // Admin-signed authorizations can only be submitted by the admin key itself,
228
+ // so only authorizations signed by the account can be attached for the new key.
229
+ if (
230
+ keyAuthorization.account &&
231
+ !isAddressEqual(keyAuthorization.account, signer)
232
+ )
233
+ throw new RpcResponse.InvalidParamsError({
234
+ message: 'Key authorization must be signed by its account.',
235
+ })
236
+ return signer
237
+ }
238
+
239
+ /**
240
+ * Reads the pending authorization for an access key. Entries that are malformed,
241
+ * expired, or whose witness has been burned are removed.
242
+ */
243
+ async function read(
244
+ client: Client,
245
+ store: Store.Atomic,
246
+ options: { account: Address; accessKey: Address; chainId: number },
247
+ ) {
248
+ const { account } = options
249
+ const key = getKey(options)
250
+ const value = await store.getItem(key)
251
+ if (!value) return undefined
252
+ const keyAuthorization = (() => {
253
+ try {
254
+ return KeyAuthorization.deserialize(
255
+ value as `0x${string}`,
256
+ ) as KeyAuthorization.Signed
257
+ } catch {
258
+ return undefined
259
+ }
260
+ })()
261
+ if (
262
+ keyAuthorization &&
263
+ !isExpired(keyAuthorization) &&
264
+ (await isVerified(client, keyAuthorization)) &&
265
+ !(await isBurned(client, { account, keyAuthorization }))
266
+ )
267
+ return { key, keyAuthorization, value }
268
+ await remove(store, { key, value })
269
+ return undefined
270
+ }
271
+
272
+ /**
273
+ * Removes a stored authorization only while it still holds the value that was read,
274
+ * so a concurrently saved replacement survives. The empty value expires immediately.
275
+ * @internal
276
+ */
277
+ export async function remove(
278
+ store: Store.Atomic,
279
+ options: { key: string; value: string },
280
+ ) {
281
+ const { key, value } = options
282
+ await store.compareAndSet(key, value, '', { expiresAt: Date.now() })
283
+ }
284
+
285
+ /**
286
+ * Returns whether the authorization still verifies, such as after a configurable
287
+ * account rotates its config. Operational failures propagate.
288
+ */
289
+ async function isVerified(
290
+ client: Client,
291
+ keyAuthorization: KeyAuthorization.Signed,
292
+ ) {
293
+ try {
294
+ await verify(client, keyAuthorization)
295
+ return true
296
+ } catch (error) {
297
+ if (error instanceof RpcResponse.InvalidParamsError) return false
298
+ throw error
299
+ }
300
+ }
301
+
302
+ /** Returns whether the authorization's witness has been burned onchain. */
303
+ async function isBurned(
304
+ client: Client,
305
+ options: { account: Address; keyAuthorization: KeyAuthorization.Signed },
306
+ ) {
307
+ const { account, keyAuthorization } = options
308
+ if (!keyAuthorization.witness) return false
309
+ return Actions.accessKey.isWitnessBurned(client, {
310
+ account,
311
+ witness: keyAuthorization.witness,
312
+ })
313
+ }
314
+
315
+ /**
316
+ * Stores an authorization unless a pending authorization for the same key expires
317
+ * later, so a replayed older authorization cannot replace a newer one.
318
+ * @internal
319
+ */
320
+ export async function write(
321
+ store: Store.Atomic,
322
+ options: {
323
+ account: Address
324
+ keyAuthorization: KeyAuthorization.Signed
325
+ },
326
+ ): Promise<boolean> {
327
+ const { account, keyAuthorization } = options
328
+ const key = getKey({
329
+ account,
330
+ accessKey: keyAuthorization.address,
331
+ chainId: Number(keyAuthorization.chainId),
332
+ })
333
+ const value = KeyAuthorization.serialize(keyAuthorization)
334
+ const expiresAt = Math.min(
335
+ Date.now() + maxTtl,
336
+ getExpiry(keyAuthorization) * 1_000,
337
+ )
338
+ for (let attempt = 0; attempt < maxWriteAttempts; attempt++) {
339
+ const current = (await store.getItem(key)) ?? null
340
+ const existing = (() => {
341
+ if (!current) return undefined
342
+ try {
343
+ return KeyAuthorization.deserialize(current as `0x${string}`)
344
+ } catch {
345
+ return undefined
346
+ }
347
+ })()
348
+ if (existing && current!.toLowerCase() === value.toLowerCase()) return true
349
+ if (existing && getExpiry(existing) >= getExpiry(keyAuthorization))
350
+ return false
351
+ // A lost compare-and-set means another writer replaced the value, so compare again.
352
+ if (await store.compareAndSet(key, current, value, { expiresAt }))
353
+ return true
354
+ }
355
+ throw new StoreConflictError()
356
+ }
357
+
358
+ /** Maximum compare-and-set attempts before a write is abandoned. */
359
+ const maxWriteAttempts = 32
360
+
361
+ /** Maximum time a pending key authorization is kept. */
362
+ const maxTtl = 30 * 24 * 60 * 60 * 1_000
363
+
364
+ /** Returns the authorization expiry in seconds, treating no expiry as unbounded. */
365
+ function getExpiry(keyAuthorization: KeyAuthorization.KeyAuthorization) {
366
+ const { expiry } = keyAuthorization
367
+ return expiry === undefined || expiry === null
368
+ ? Number.POSITIVE_INFINITY
369
+ : Number(expiry)
370
+ }
371
+
372
+ /** Returns whether the access key is active onchain. */
373
+ function isActive(
374
+ metadata: Actions.accessKey.getMetadata.ReturnValue,
375
+ accessKey: Address,
376
+ ) {
377
+ return (
378
+ isAddressEqual(metadata.address, accessKey) &&
379
+ !metadata.isRevoked &&
380
+ metadata.expiry > BigInt(Math.floor(Date.now() / 1000))
381
+ )
382
+ }
383
+
384
+ function isExpired(keyAuthorization: KeyAuthorization.KeyAuthorization) {
385
+ const { expiry } = keyAuthorization
386
+ return (
387
+ expiry !== undefined &&
388
+ expiry !== null &&
389
+ BigInt(expiry) <= BigInt(Math.floor(Date.now() / 1000))
390
+ )
391
+ }
392
+
393
+ function getKey(options: {
394
+ account: Address
395
+ accessKey: Address
396
+ chainId: number
397
+ }) {
398
+ const { account, accessKey, chainId } = options
399
+ return [
400
+ 'keyAuthorization',
401
+ chainId,
402
+ account.toLowerCase(),
403
+ accessKey.toLowerCase(),
404
+ ].join(':')
405
+ }
406
+
407
+ /** Thrown when a pending key authorization cannot be written after repeated conflicts. */
408
+ class StoreConflictError extends BaseError {
409
+ constructor() {
410
+ super(
411
+ 'Pending key authorization could not be written after repeated conflicts.',
412
+ { name: 'Relay.KeyAuthorization.StoreConflictError' },
413
+ )
414
+ }
415
+ }
@@ -1,13 +1,26 @@
1
1
  import type * as Relay from '../../Relay.js'
2
2
 
3
- const multisigPlugins = new WeakSet<Relay.Plugin>()
3
+ const accountsPlugins = new WeakSet<Relay.Plugin>()
4
+ const keyAuthorizationPlugins = new WeakSet<Relay.Plugin>()
4
5
 
5
- /** Registers the built-in multisig plugin for transport capability detection. */
6
- export function multisig(plugin: Relay.Plugin): Relay.multisig.ReturnType {
7
- multisigPlugins.add(plugin)
8
- return plugin as Relay.multisig.ReturnType
6
+ /** Registers the built-in accounts plugin for transport capability detection. */
7
+ export function accounts(plugin: Relay.Plugin): Relay.accounts.ReturnType {
8
+ accountsPlugins.add(plugin)
9
+ return plugin as Relay.accounts.ReturnType
9
10
  }
10
11
 
11
- export function isMultisig(plugin: Relay.Plugin): boolean {
12
- return multisigPlugins.has(plugin)
12
+ export function isAccounts(plugin: Relay.Plugin): boolean {
13
+ return accountsPlugins.has(plugin)
14
+ }
15
+
16
+ /** Registers the built-in key authorization plugin for transport capability detection. */
17
+ export function keyAuthorization(
18
+ plugin: Relay.Plugin,
19
+ ): Relay.keyAuthorization.ReturnType {
20
+ keyAuthorizationPlugins.add(plugin)
21
+ return plugin as Relay.keyAuthorization.ReturnType
22
+ }
23
+
24
+ export function isKeyAuthorization(plugin: Relay.Plugin): boolean {
25
+ return keyAuthorizationPlugins.has(plugin)
13
26
  }
@@ -0,0 +1,169 @@
1
+ import type { Abi, Address } from 'abitype'
2
+ import { parseAccount } from '../../accounts/utils/parseAccount.js'
3
+ import { call } from '../../actions/public/call.js'
4
+ import { multicall } from '../../actions/public/multicall.js'
5
+ import type { Client } from '../../clients/createClient.js'
6
+ import { BaseError } from '../../errors/base.js'
7
+ import { TransactionReceiptRevertedError } from '../../errors/transaction.js'
8
+ import type { ContractFunctionParameters } from '../../types/contract.js'
9
+ import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js'
10
+ import { formatAbiItem } from '../../utils/abi/formatAbiItem.js'
11
+ import { toFunctionSelector } from '../../utils/hash/toFunctionSelector.js'
12
+ import { errorResolvers as accessKeyResolvers } from '../actions/accessKey.js'
13
+ import { errorResolvers as ammResolvers } from '../actions/amm.js'
14
+ import { errorResolvers as channelResolvers } from '../actions/channel.js'
15
+ import { errorResolvers as dexResolvers } from '../actions/dex.js'
16
+ import { errorResolvers as feeResolvers } from '../actions/fee.js'
17
+ import { errorResolvers as nonceResolvers } from '../actions/nonce.js'
18
+ import { errorResolvers as policyResolvers } from '../actions/policy.js'
19
+ import { errorResolvers as tokenResolvers } from '../actions/token.js'
20
+ import * as ExecutionError from '../ExecutionError.js'
21
+ import { TempoExecutionError } from '../errors.js'
22
+ import type { Context, Hints, Resolvers } from './errors.js'
23
+
24
+ /** Node messages that carry no revert data, mapped to the error they describe. */
25
+ const messages = [
26
+ [/Access key expired: expiry \d+ <= min allowed \d+/, 'ExpiryInPast()'],
27
+ ] as const
28
+
29
+ export async function toExecutionError(
30
+ cause: unknown,
31
+ options: {
32
+ client: Client
33
+ hints?: Hints | undefined
34
+ parameters: Record<string, any>
35
+ },
36
+ ) {
37
+ if (!(cause instanceof BaseError)) return cause
38
+ const { client, parameters } = options
39
+ const source = (await replay(cause, client, parameters)) ?? cause
40
+ const details = source.details ?? ''
41
+ let error: ExecutionError.ExecutionError = ExecutionError.from(source)
42
+ if (error.errorName === 'unknown') {
43
+ const signature = messages.find(([pattern]) => pattern.test(details))?.[1]
44
+ if (!signature) return cause
45
+ error = ExecutionError.from(toFunctionSelector(signature))
46
+ }
47
+ if (error.errorName === 'unknown') return cause
48
+
49
+ const signature = formatAbiItem(
50
+ error.abiItem,
51
+ ) as keyof typeof ExecutionError.messages
52
+ // Solidity `Error(string)` and `Panic(uint256)` are not Tempo errors.
53
+ if (!(signature in ExecutionError.messages)) return cause
54
+ const hints = [
55
+ ...(options.hints?.[error.errorName] ?? []),
56
+ ...(ExecutionError.hints[signature] ?? []),
57
+ ]
58
+ const base = { cause, error, hints } as TempoExecutionError.Parameters
59
+
60
+ const account_ = parameters.account ?? client.account
61
+ const account = account_ ? parseAccount(account_) : undefined
62
+ const context: Context = {
63
+ base,
64
+ call: getCall(parameters),
65
+ client,
66
+ details,
67
+ parameters,
68
+ read: (contracts) =>
69
+ multicall(client, {
70
+ allowFailure: true,
71
+ contracts: contracts as readonly ContractFunctionParameters[],
72
+ deployless: true,
73
+ }).catch(() => []) as never,
74
+ signer: account && {
75
+ address: account.address,
76
+ accessKey:
77
+ account.source === 'accessKey' && 'accessKeyAddress' in account
78
+ ? (account.accessKeyAddress as Address)
79
+ : undefined,
80
+ },
81
+ validation: !hasRevertData(source),
82
+ }
83
+
84
+ for (const resolvers of [
85
+ accessKeyResolvers,
86
+ ammResolvers,
87
+ channelResolvers,
88
+ dexResolvers,
89
+ feeResolvers,
90
+ nonceResolvers,
91
+ policyResolvers,
92
+ tokenResolvers,
93
+ ] as readonly Resolvers[]) {
94
+ const result = await resolvers[signature]?.(context)
95
+ if (result) return result
96
+ }
97
+ return new TempoExecutionError(base)
98
+ }
99
+
100
+ /** Replays a call whose receipt reverted, to recover its revert data. */
101
+ async function replay(
102
+ cause: BaseError,
103
+ client: Client,
104
+ parameters: Record<string, any>,
105
+ ) {
106
+ const reverted = cause.walk(
107
+ (error) => error instanceof TransactionReceiptRevertedError,
108
+ ) as TransactionReceiptRevertedError | null
109
+ const to = parameters.to ?? parameters.address
110
+ const data =
111
+ parameters.data ??
112
+ (parameters.abi && parameters.functionName
113
+ ? encodeFunctionData({
114
+ abi: parameters.abi,
115
+ args: parameters.args,
116
+ functionName: parameters.functionName,
117
+ })
118
+ : undefined)
119
+ if (!reverted || !to || !data) return undefined
120
+ // ponytail: replays on the parent block, so earlier transactions in the same block are not applied.
121
+ return call(client, {
122
+ account: parameters.account ?? client.account,
123
+ blockNumber: reverted.receipt.blockNumber - 1n,
124
+ data,
125
+ to,
126
+ value: parameters.value,
127
+ }).then(
128
+ () => undefined,
129
+ (error) => (error instanceof BaseError ? error : undefined),
130
+ )
131
+ }
132
+
133
+ /** Whether an error carries revert data, which only execution reverts have. */
134
+ function hasRevertData(error: BaseError) {
135
+ return !!error.walk((error) => {
136
+ const { data, raw } = error as { data?: unknown; raw?: unknown }
137
+ const hex =
138
+ typeof data === 'object' && data !== null
139
+ ? (data as { data?: unknown }).data
140
+ : (data ?? raw)
141
+ return typeof hex === 'string' && hex.length >= 10
142
+ })
143
+ }
144
+
145
+ function getCall(parameters: Record<string, any>): Context['call'] {
146
+ const {
147
+ abi,
148
+ address,
149
+ args = [],
150
+ functionName,
151
+ } = parameters as {
152
+ abi?: Abi
153
+ address?: Address
154
+ args?: readonly unknown[]
155
+ functionName?: string
156
+ }
157
+ if (!address || !functionName) return undefined
158
+ const item = abi?.find(
159
+ (item) => item.type === 'function' && item.name === functionName,
160
+ )
161
+ const inputs = item?.type === 'function' ? item.inputs : []
162
+ return {
163
+ address,
164
+ args,
165
+ functionName,
166
+ arg: (name) =>
167
+ args[inputs.findIndex((input) => input.name === name)] as never,
168
+ }
169
+ }
@@ -279,6 +279,8 @@ export function defineCall<
279
279
  } {
280
280
  return {
281
281
  ...(call as any),
282
+ // Precompile errors bubble up across contracts (e.g. `AccountKeychain` errors from a TIP-20 `transfer`).
283
+ abi: [...call.abi, ...Abis.coreErrors],
282
284
  data: encodeFunctionData(call as never),
283
285
  to: call.address,
284
286
  } as const
@@ -46,8 +46,9 @@ export function normalizeSignature(
46
46
 
47
47
  // Ignore spaces
48
48
  if (char === ' ') {
49
- // If the previous character is a separator, and the current section isn't empty, we want to deactivate.
50
- if (signature[i - 1] !== ',' && current !== ',' && current !== ',(') {
49
+ // A space directly after a `(` or `,` separator is leading whitespace.
50
+ // Otherwise, it ends the type, so we want to deactivate.
51
+ if (!current.endsWith(',') && !current.endsWith('(')) {
51
52
  current = ''
52
53
  active = false
53
54
  }