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
@@ -1,4 +1,4 @@
1
- import { KeyAuthorization, MultisigConfig, MultisigOperation, SignatureEnvelope, } from 'ox/tempo';
1
+ import { AccountConfig, AccountOperation, KeyAuthorization, SignatureEnvelope, } from 'ox/tempo';
2
2
  import { parseAccount } from '../../accounts/utils/parseAccount.js';
3
3
  import { readContract } from '../../actions/public/readContract.js';
4
4
  import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
@@ -6,15 +6,19 @@ import { sendTransaction } from '../../actions/wallet/sendTransaction.js';
6
6
  import { sendTransactionSync } from '../../actions/wallet/sendTransactionSync.js';
7
7
  import { writeContract } from '../../actions/wallet/writeContract.js';
8
8
  import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
9
+ import { MethodNotFoundRpcError, MethodNotSupportedRpcError, } from '../../errors/rpc.js';
10
+ import { formatAbiItem } from '../../utils/abi/formatAbiItem.js';
9
11
  import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
10
12
  import { isAddressEqual } from '../../utils/address/isAddressEqual.js';
11
13
  import * as Abis from '../Abis.js';
12
- import { fromMultisig, getKeyAuthorizationSignPayload, resolveAccessKey, signKeyAuthorization, } from '../Account.js';
14
+ import { fromConfig, getKeyAuthorizationSignPayload, resolveAccessKey, signKeyAuthorization, } from '../Account.js';
13
15
  import * as Addresses from '../Addresses.js';
16
+ import { parseApproval } from '../accounts/Signature.js';
17
+ import { TempoExecutionError } from '../errors.js';
14
18
  import * as Hardfork from '../Hardfork.js';
19
+ import { formatAmount, formatTime, getFeeToken, isTip20, withExecutionError, } from '../internal/errors.js';
15
20
  import { defineCall } from '../internal/utils.js';
16
- import { parseApproval } from '../multisig/Signature.js';
17
- import { getConfig } from './multisig.js';
21
+ import { getConfig } from './accounts.js';
18
22
  /** @internal */
19
23
  const signatureTypes = {
20
24
  0: 'secp256k1',
@@ -69,7 +73,7 @@ export async function authorize(client, parameters) {
69
73
  throw new Error('account is required.');
70
74
  if (!chainId)
71
75
  throw new Error('chainId is required.');
72
- const keyAuthorization = await signAuthorization(client, {
76
+ const keyAuthorization = await signLocal(client, {
73
77
  account: account_,
74
78
  accessKey,
75
79
  chainId,
@@ -79,7 +83,13 @@ export async function authorize(client, parameters) {
79
83
  scopes,
80
84
  witness,
81
85
  });
82
- return (await action(client, {
86
+ return (await withExecutionError(action, {
87
+ hints: {
88
+ KeyAlreadyExists: [
89
+ 'This access key is already authorized. Update its spending limits instead.',
90
+ ],
91
+ },
92
+ })(client, {
83
93
  ...rest,
84
94
  keyAuthorization,
85
95
  }));
@@ -183,7 +193,7 @@ export async function burnWitness(client, parameters) {
183
193
  async function inner(action, client, parameters) {
184
194
  const { witness, ...rest } = parameters;
185
195
  const call = burnWitness.call({ witness });
186
- return (await action(client, {
196
+ return (await withExecutionError(action)(client, {
187
197
  ...rest,
188
198
  ...call,
189
199
  }));
@@ -309,7 +319,7 @@ export async function getMetadata(client, parameters) {
309
319
  if (!account_)
310
320
  throw new Error('account is required.');
311
321
  const account = parseAccount(account_);
312
- const result = await readContract(client, {
322
+ const result = await withExecutionError(readContract)(client, {
313
323
  ...rest,
314
324
  account: null,
315
325
  ...getMetadata.call({ account: account.address, accessKey }),
@@ -376,13 +386,13 @@ export async function getRemainingLimit(client, parameters) {
376
386
  // TODO: remove pre-t3 branch once mainnet is on t3.
377
387
  const hardfork = client.chain?.hardfork;
378
388
  if (hardfork && Hardfork.lt(hardfork, 't3')) {
379
- const remaining = await readContract(client, {
389
+ const remaining = await withExecutionError(readContract)(client, {
380
390
  ...rest,
381
391
  ...getRemainingLimit.call({ account: account.address, accessKey, token }),
382
392
  });
383
393
  return { remaining, periodEnd: undefined };
384
394
  }
385
- const [remaining, periodEnd] = await readContract(client, {
395
+ const [remaining, periodEnd] = await withExecutionError(readContract)(client, {
386
396
  ...rest,
387
397
  ...getRemainingLimit.callWithPeriod({
388
398
  account: account.address,
@@ -460,7 +470,7 @@ export async function isAdmin(client, parameters) {
460
470
  if (!account_)
461
471
  throw new Error('account is required.');
462
472
  const account = parseAccount(account_);
463
- return readContract(client, {
473
+ return withExecutionError(readContract)(client, {
464
474
  ...rest,
465
475
  account: null,
466
476
  ...isAdmin.call({ account: account.address, accessKey }),
@@ -513,7 +523,7 @@ export async function isWitnessBurned(client, parameters) {
513
523
  if (!account_)
514
524
  throw new Error('account is required.');
515
525
  const account = parseAccount(account_);
516
- return readContract(client, {
526
+ return withExecutionError(readContract)(client, {
517
527
  ...rest,
518
528
  account: null,
519
529
  ...isWitnessBurned.call({ account: account.address, witness }),
@@ -570,7 +580,7 @@ export async function revoke(client, parameters) {
570
580
  async function inner(action, client, parameters) {
571
581
  const { accessKey, ...rest } = parameters;
572
582
  const call = revoke.call({ accessKey });
573
- return (await action(client, {
583
+ return (await withExecutionError(action)(client, {
574
584
  ...rest,
575
585
  ...call,
576
586
  }));
@@ -694,14 +704,14 @@ export async function prepareAuthorization(client, parameters) {
694
704
  if (!chainId)
695
705
  throw new Error('chainId is required.');
696
706
  const parsed = parseAccount(account_);
697
- const multisigState = await (async () => {
698
- if ('multisig' in parameters)
699
- return parameters.multisig;
700
- if (parsed.source !== 'multisig')
707
+ const configurableState = await (async () => {
708
+ if ('configurable' in parameters)
709
+ return parameters.configurable;
710
+ if (parsed.source !== 'configurable')
701
711
  return undefined;
702
712
  const account = parsed;
703
713
  if (!account.config)
704
- throw new Error('A multisig config is required to prepare a key authorization.');
714
+ throw new Error('An account config is required to prepare a key authorization.');
705
715
  return { config: account.config };
706
716
  })();
707
717
  const authorizationSignPayload = getKeyAuthorizationSignPayload(parsed, {
@@ -709,10 +719,10 @@ export async function prepareAuthorization(client, parameters) {
709
719
  chainId: BigInt(chainId),
710
720
  key: parameters.accessKey,
711
721
  });
712
- const signPayload = parsed.source === 'multisig' && multisigState
713
- ? MultisigConfig.getSignPayload({
722
+ const signPayload = parsed.source === 'configurable' && configurableState
723
+ ? AccountConfig.getSignPayload({
714
724
  account: parsed.address,
715
- config: multisigState.config,
725
+ config: configurableState.config,
716
726
  payload: authorizationSignPayload,
717
727
  })
718
728
  : authorizationSignPayload;
@@ -720,10 +730,46 @@ export async function prepareAuthorization(client, parameters) {
720
730
  ...parameters,
721
731
  account: parsed,
722
732
  chainId,
723
- multisig: multisigState,
733
+ configurable: configurableState,
724
734
  signPayload,
725
735
  };
726
736
  }
737
+ /**
738
+ * Saves a signed key authorization to a relay with key authorization storage.
739
+ *
740
+ * The relay attaches the authorization to the access key's next transaction until
741
+ * the key is active onchain. Use this for authorizations signed outside
742
+ * {@link signAuthorization}, such as on another device. Requires a relay running the
743
+ * `Relay.keyAuthorization` plugin.
744
+ *
745
+ * @example
746
+ * ```ts
747
+ * import { createClient, http } from 'viem'
748
+ * import { tempo } from 'viem/chains'
749
+ * import { Actions, withRelay } from 'viem/tempo'
750
+ *
751
+ * const client = createClient({
752
+ * chain: tempo,
753
+ * transport: withRelay(http(), http('https://relay.example.com'), {
754
+ * keyAuthorization: true,
755
+ * }),
756
+ * })
757
+ *
758
+ * await Actions.accessKey.saveAuthorization(client, {
759
+ * keyAuthorization,
760
+ * })
761
+ * ```
762
+ *
763
+ * @param client - Client.
764
+ * @param parameters - Parameters.
765
+ */
766
+ export async function saveAuthorization(client, parameters) {
767
+ const { keyAuthorization } = parameters;
768
+ await client.request({
769
+ method: 'relay_saveKeyAuthorization',
770
+ params: [KeyAuthorization.toRpc(keyAuthorization)],
771
+ });
772
+ }
727
773
  export async function signAuthorization(client, parameters) {
728
774
  const coordinated = ('hash' in parameters && parameters.hash) ||
729
775
  ('owner' in parameters && parameters.owner);
@@ -731,11 +777,11 @@ export async function signAuthorization(client, parameters) {
731
777
  const parameters_ = parameters;
732
778
  const owner_ = parameters_.owner;
733
779
  if (!owner_ || typeof owner_ === 'string')
734
- throw new Error('A local owner account is required to approve a multisig key authorization.');
780
+ throw new Error('A local owner account is required to approve a configurable account key authorization.');
735
781
  const owner = parseAccount(owner_);
736
782
  const sign = owner.sign;
737
783
  if (!sign)
738
- throw new Error('A local owner account is required to approve a multisig key authorization.');
784
+ throw new Error('A local owner account is required to approve a configurable account key authorization.');
739
785
  const request = await (async () => {
740
786
  if ('hash' in parameters_ && parameters_.hash) {
741
787
  const signature = SignatureEnvelope.serialize(SignatureEnvelope.from(await sign({ hash: parameters_.hash })));
@@ -749,16 +795,16 @@ export async function signAuthorization(client, parameters) {
749
795
  const config = await getConfig(client, { address });
750
796
  if (config)
751
797
  return config;
752
- throw new Error(`No current multisig config is cached for account ${address}. Provide the current config.`);
798
+ throw new Error(`No current account config is cached for account ${address}. Provide the current config.`);
753
799
  })();
754
800
  const account = (() => {
755
801
  if (config.version !== 0n)
756
- return fromMultisig({ address, ...config });
802
+ return fromConfig({ address, ...config });
757
803
  const { version: _, ...initialConfig } = config;
758
- return fromMultisig({ address: 'infer', ...initialConfig });
804
+ return fromConfig({ address: 'infer', ...initialConfig });
759
805
  })();
760
806
  if (!isAddressEqual(account.address, address))
761
- throw new Error('Initial multisig config does not match the account.');
807
+ throw new Error('Initial account config does not match the account.');
762
808
  const prepared = await prepareAuthorization(client, {
763
809
  ...authorization,
764
810
  account,
@@ -782,44 +828,62 @@ export async function signAuthorization(client, parameters) {
782
828
  return { keyAuthorization: KeyAuthorization.toRpc(keyAuthorization) };
783
829
  })();
784
830
  const operation = await client.request({
785
- method: 'multisig_approveKeyAuthorization',
831
+ method: 'account_approveKeyAuthorization',
786
832
  params: [request],
787
833
  });
788
- const multisig = MultisigOperation.fromRpc(operation);
834
+ const operation_ = AccountOperation.fromRpc(operation);
789
835
  const keyAuthorization = KeyAuthorization.deserialize(await (async () => {
790
- if (multisig.status === 'success')
791
- return multisig.keyAuthorization;
792
- const approvals = await MultisigOperation.selectApprovals({
793
- account: multisig.account,
794
- approvals: multisig.approvals,
795
- config: multisig.config,
796
- hash: multisig.hash,
836
+ if (operation_.status === 'success')
837
+ return operation_.keyAuthorization;
838
+ const approvals = await AccountOperation.selectApprovals({
839
+ account: operation_.account,
840
+ approvals: operation_.approvals,
841
+ config: operation_.config,
842
+ hash: operation_.hash,
797
843
  });
798
- return MultisigOperation.serializeKeyAuthorization(multisig.keyAuthorization, {
799
- account: multisig.account,
844
+ return AccountOperation.serializeKeyAuthorization(operation_.keyAuthorization, {
845
+ account: operation_.account,
800
846
  approvals: approvals.selectedApprovals.length > 0
801
847
  ? approvals.selectedApprovals
802
848
  : approvals.approvals.slice(0, 1),
803
- config: multisig.config,
849
+ config: operation_.config,
804
850
  });
805
851
  })());
806
852
  if (!keyAuthorization.signature)
807
- throw new Error('Expected a signed multisig key authorization.');
853
+ throw new Error('Expected a signed configurable account key authorization.');
808
854
  return {
809
855
  ...keyAuthorization,
810
- hash: multisig.hash,
811
- multisig,
812
- status: multisig.status,
856
+ hash: operation_.hash,
857
+ operation: operation_,
858
+ status: operation_.status,
813
859
  };
814
860
  }
861
+ const keyAuthorization = await signLocal(client, parameters);
862
+ const signer = parameters.account ?? client.account;
863
+ // Relays with key authorization storage attach it to the access key's next
864
+ // transaction. Admin-signed authorizations can only be submitted by the admin key.
865
+ if (client.transport.keyAuthorization &&
866
+ signer &&
867
+ parseAccount(signer).source !== 'accessKey')
868
+ await saveAuthorization(client, { keyAuthorization }).catch((error) => {
869
+ // Remote relays without key authorization storage do not expose this method.
870
+ if (error instanceof MethodNotFoundRpcError ||
871
+ error instanceof MethodNotSupportedRpcError)
872
+ return;
873
+ throw error;
874
+ });
875
+ return keyAuthorization;
876
+ }
877
+ /** Signs a key authorization locally without saving it to a relay. */
878
+ async function signLocal(client, parameters) {
815
879
  const prepared = ('signPayload' in parameters
816
880
  ? parameters
817
881
  : await prepareAuthorization(client, parameters));
818
- const { accessKey, account: account_, chainId, multisig: multisigState, signPayload: _, ...rest } = prepared;
882
+ const { accessKey, account: account_, chainId, configurable: configurableState, signPayload: _, ...rest } = prepared;
819
883
  return signKeyAuthorization(account_, {
820
884
  chainId: BigInt(chainId),
821
885
  key: accessKey,
822
- multisig: multisigState,
886
+ configurable: configurableState,
823
887
  ...rest,
824
888
  });
825
889
  }
@@ -858,7 +922,7 @@ export async function updateLimit(client, parameters) {
858
922
  async function inner(action, client, parameters) {
859
923
  const { accessKey, token, limit, ...rest } = parameters;
860
924
  const call = updateLimit.call({ accessKey, token, limit });
861
- return (await action(client, {
925
+ return (await withExecutionError(action)(client, {
862
926
  ...rest,
863
927
  ...call,
864
928
  }));
@@ -1125,7 +1189,7 @@ export function watchWitnessBurned(client, parameters) {
1125
1189
  */
1126
1190
  export async function verifyHash(client, parameters) {
1127
1191
  const { account, admin, hash, signature, ...rest } = parameters;
1128
- return readContract(client, {
1192
+ return withExecutionError(readContract)(client, {
1129
1193
  ...rest,
1130
1194
  ...verifyHash.call({ account, admin, hash, signature }),
1131
1195
  });
@@ -1155,4 +1219,391 @@ function resolveAccessKeyAddress(accessKey) {
1155
1219
  return accessKey;
1156
1220
  return accessKey.accessKeyAddress;
1157
1221
  }
1222
+ /** Thrown when an access key fails an `AccountKeychain` check. */
1223
+ export class AccessKeyError extends TempoExecutionError {
1224
+ constructor(parameters, options = {}) {
1225
+ const { account, accessKey } = parameters;
1226
+ super(parameters, {
1227
+ shortMessage: `Access key "${accessKey}" failed: ${parameters.error.message}`,
1228
+ ...options,
1229
+ details: { account, 'access key': accessKey, ...options.details },
1230
+ docsPath: '/tempo/guides/access-keys/manage',
1231
+ name: options.name ?? 'AccessKeyError',
1232
+ });
1233
+ /** Root account that owns the access key. */
1234
+ Object.defineProperty(this, "account", {
1235
+ enumerable: true,
1236
+ configurable: true,
1237
+ writable: true,
1238
+ value: void 0
1239
+ });
1240
+ /** Access key address. */
1241
+ Object.defineProperty(this, "accessKey", {
1242
+ enumerable: true,
1243
+ configurable: true,
1244
+ writable: true,
1245
+ value: void 0
1246
+ });
1247
+ this.account = account;
1248
+ this.accessKey = accessKey;
1249
+ }
1250
+ }
1251
+ /** Thrown when a transfer, approval, or fee payment exceeds an access key's spending limit. */
1252
+ export class AccessKeySpendingLimitExceededError extends AccessKeyError {
1253
+ constructor(parameters) {
1254
+ const { amount, decimals, fee, periodEnd, remaining, token } = parameters;
1255
+ super(parameters, {
1256
+ details: {
1257
+ token,
1258
+ amount: formatAmount(amount, decimals),
1259
+ remaining: formatAmount(remaining, decimals),
1260
+ 'exceeded by': amount !== undefined && remaining !== undefined
1261
+ ? formatAmount(amount - remaining, decimals)
1262
+ : undefined,
1263
+ 'resets at': formatTime(periodEnd),
1264
+ },
1265
+ name: 'AccessKeySpendingLimitExceededError',
1266
+ shortMessage: `Access key "${parameters.accessKey}" exceeded its spending limit${token ? ` for token "${token}"` : ''}${fee ? ' while paying fees' : ''}.`,
1267
+ });
1268
+ /** Amount the call tried to spend, when known. */
1269
+ Object.defineProperty(this, "amount", {
1270
+ enumerable: true,
1271
+ configurable: true,
1272
+ writable: true,
1273
+ value: void 0
1274
+ });
1275
+ /** Token decimals, when known. */
1276
+ Object.defineProperty(this, "decimals", {
1277
+ enumerable: true,
1278
+ configurable: true,
1279
+ writable: true,
1280
+ value: void 0
1281
+ });
1282
+ /** Whether the fee payment, rather than the call, exceeded the limit. */
1283
+ Object.defineProperty(this, "fee", {
1284
+ enumerable: true,
1285
+ configurable: true,
1286
+ writable: true,
1287
+ value: void 0
1288
+ });
1289
+ /** End of the current period (Unix seconds) for periodic limits, when known. */
1290
+ Object.defineProperty(this, "periodEnd", {
1291
+ enumerable: true,
1292
+ configurable: true,
1293
+ writable: true,
1294
+ value: void 0
1295
+ });
1296
+ /** Remaining limit for `token`, when known. */
1297
+ Object.defineProperty(this, "remaining", {
1298
+ enumerable: true,
1299
+ configurable: true,
1300
+ writable: true,
1301
+ value: void 0
1302
+ });
1303
+ /** Token the limit applies to, when known. */
1304
+ Object.defineProperty(this, "token", {
1305
+ enumerable: true,
1306
+ configurable: true,
1307
+ writable: true,
1308
+ value: void 0
1309
+ });
1310
+ this.amount = amount;
1311
+ this.decimals = decimals;
1312
+ this.fee = fee;
1313
+ this.periodEnd = periodEnd;
1314
+ this.remaining = remaining;
1315
+ this.token = token;
1316
+ }
1317
+ }
1318
+ /** Thrown when a transaction is signed with an expired access key. */
1319
+ export class AccessKeyExpiredError extends AccessKeyError {
1320
+ constructor(parameters) {
1321
+ super(parameters, {
1322
+ details: { 'expired at': formatTime(parameters.expiry) },
1323
+ name: 'AccessKeyExpiredError',
1324
+ shortMessage: `Access key "${parameters.accessKey}" has expired.`,
1325
+ });
1326
+ /** Expiry (Unix seconds), when known. */
1327
+ Object.defineProperty(this, "expiry", {
1328
+ enumerable: true,
1329
+ configurable: true,
1330
+ writable: true,
1331
+ value: void 0
1332
+ });
1333
+ this.expiry = parameters.expiry;
1334
+ }
1335
+ }
1336
+ /** Thrown when an access key's scopes do not allow a call. */
1337
+ export class AccessKeyCallNotAllowedError extends AccessKeyError {
1338
+ constructor(parameters) {
1339
+ const { selector, target } = parameters;
1340
+ super(parameters, {
1341
+ details: { target, selector },
1342
+ name: 'AccessKeyCallNotAllowedError',
1343
+ shortMessage: `Access key "${parameters.accessKey}" is not allowed to make this call.`,
1344
+ });
1345
+ /** Function selector of the rejected call, when known. */
1346
+ Object.defineProperty(this, "selector", {
1347
+ enumerable: true,
1348
+ configurable: true,
1349
+ writable: true,
1350
+ value: void 0
1351
+ });
1352
+ /** Target of the rejected call, when known. */
1353
+ Object.defineProperty(this, "target", {
1354
+ enumerable: true,
1355
+ configurable: true,
1356
+ writable: true,
1357
+ value: void 0
1358
+ });
1359
+ this.selector = selector;
1360
+ this.target = target;
1361
+ }
1362
+ }
1363
+ /** Thrown when authorizing an access key that is already authorized. */
1364
+ export class AccessKeyAlreadyExistsError extends AccessKeyError {
1365
+ constructor(parameters) {
1366
+ const { expiry, limited } = parameters;
1367
+ super(parameters, {
1368
+ details: {
1369
+ expires: formatTime(expiry),
1370
+ 'spending limits': limited === undefined ? undefined : limited ? 'enforced' : 'none',
1371
+ },
1372
+ name: 'AccessKeyAlreadyExistsError',
1373
+ shortMessage: `Access key "${parameters.accessKey}" is already authorized on account "${parameters.account}".`,
1374
+ });
1375
+ /** Expiry (Unix seconds) of the existing key, when known. */
1376
+ Object.defineProperty(this, "expiry", {
1377
+ enumerable: true,
1378
+ configurable: true,
1379
+ writable: true,
1380
+ value: void 0
1381
+ });
1382
+ /** Whether the existing key enforces spending limits, when known. */
1383
+ Object.defineProperty(this, "limited", {
1384
+ enumerable: true,
1385
+ configurable: true,
1386
+ writable: true,
1387
+ value: void 0
1388
+ });
1389
+ this.expiry = expiry;
1390
+ this.limited = limited;
1391
+ }
1392
+ }
1393
+ /** Thrown when an access key signs with a different key type than it was authorized with. */
1394
+ export class AccessKeySignatureTypeMismatchError extends AccessKeyError {
1395
+ constructor(parameters) {
1396
+ const [expected, actual] = (parameters.error.args ?? []).map((type) => signatureTypes[Number(type)]);
1397
+ super(parameters, {
1398
+ details: { expected, actual },
1399
+ name: 'AccessKeySignatureTypeMismatchError',
1400
+ shortMessage: `Access key "${parameters.accessKey}" signed with a ${actual ?? 'different'} key, but was authorized as a ${expected ?? 'different'} key.`,
1401
+ });
1402
+ /** Key type the access key was authorized with. */
1403
+ Object.defineProperty(this, "expected", {
1404
+ enumerable: true,
1405
+ configurable: true,
1406
+ writable: true,
1407
+ value: void 0
1408
+ });
1409
+ /** Key type of the signature. */
1410
+ Object.defineProperty(this, "actual", {
1411
+ enumerable: true,
1412
+ configurable: true,
1413
+ writable: true,
1414
+ value: void 0
1415
+ });
1416
+ this.expected = expected;
1417
+ this.actual = actual;
1418
+ }
1419
+ }
1420
+ /** Thrown when authorizing an access key with an expiry that has passed or is too soon. */
1421
+ export class AccessKeyExpiryInPastError extends AccessKeyError {
1422
+ constructor(parameters) {
1423
+ const { expiry, minimum } = parameters;
1424
+ super(parameters, {
1425
+ details: { expiry: formatTime(expiry), minimum: formatTime(minimum) },
1426
+ name: 'AccessKeyExpiryInPastError',
1427
+ shortMessage: `Access key "${parameters.accessKey}" expiry must be later${minimum ? ` than ${formatTime(minimum)}` : ''}.`,
1428
+ });
1429
+ /** Requested expiry (Unix seconds), when known. */
1430
+ Object.defineProperty(this, "expiry", {
1431
+ enumerable: true,
1432
+ configurable: true,
1433
+ writable: true,
1434
+ value: void 0
1435
+ });
1436
+ /** Earliest allowed expiry (Unix seconds), when known. */
1437
+ Object.defineProperty(this, "minimum", {
1438
+ enumerable: true,
1439
+ configurable: true,
1440
+ writable: true,
1441
+ value: void 0
1442
+ });
1443
+ this.expiry = expiry;
1444
+ this.minimum = minimum;
1445
+ }
1446
+ }
1447
+ const keychain = {
1448
+ address: Addresses.accountKeychain,
1449
+ abi: Abis.accountKeychain,
1450
+ };
1451
+ /** Signer and key for errors raised while validating the signing access key. */
1452
+ function getSigner(context) {
1453
+ const { call, parameters, signer } = context;
1454
+ if (!signer?.accessKey)
1455
+ return undefined;
1456
+ // Key management calls and authorizations of another key fail about that key, not the signer.
1457
+ if (call && isAddressEqual(call.address, Addresses.accountKeychain))
1458
+ return undefined;
1459
+ const authorized = parameters.keyAuthorization?.address;
1460
+ if (authorized && !isAddressEqual(authorized, signer.accessKey))
1461
+ return undefined;
1462
+ return {
1463
+ ...context.base,
1464
+ account: signer.address,
1465
+ accessKey: signer.accessKey,
1466
+ };
1467
+ }
1468
+ /** Fee payer and key for fee payment errors. External fee payers cannot be resolved. */
1469
+ function getFeePayer(context) {
1470
+ const { feePayer } = context.parameters;
1471
+ if (typeof feePayer !== 'object')
1472
+ return undefined;
1473
+ const account = parseAccount(feePayer);
1474
+ if (account.source !== 'accessKey' || !('accessKeyAddress' in account))
1475
+ return undefined;
1476
+ return {
1477
+ ...context.base,
1478
+ account: account.address,
1479
+ accessKey: account.accessKeyAddress,
1480
+ };
1481
+ }
1482
+ /** Account and key for errors raised while authorizing a key. */
1483
+ function getAuthorization(context) {
1484
+ const { call, parameters, signer } = context;
1485
+ const accessKey = parameters.keyAuthorization?.address ??
1486
+ call?.arg('keyId');
1487
+ if (!signer || !accessKey)
1488
+ return undefined;
1489
+ return { ...context.base, account: signer.address, accessKey };
1490
+ }
1491
+ /** @internal */
1492
+ export const errorResolvers = {
1493
+ // Fallback for `AccountKeychain` errors without a specific resolver below.
1494
+ ...Object.fromEntries(Abis.accountKeychain.flatMap((item) => item.type === 'error'
1495
+ ? [
1496
+ [
1497
+ formatAbiItem(item),
1498
+ (context) => {
1499
+ const parameters = getSigner(context);
1500
+ return parameters && new AccessKeyError(parameters);
1501
+ },
1502
+ ],
1503
+ ]
1504
+ : [])),
1505
+ 'CallNotAllowed()': (context) => {
1506
+ const parameters = getSigner(context);
1507
+ if (!parameters)
1508
+ return undefined;
1509
+ return new AccessKeyCallNotAllowedError({
1510
+ ...parameters,
1511
+ selector: context.parameters.data?.slice(0, 10),
1512
+ target: context.call?.address ?? context.parameters.to,
1513
+ });
1514
+ },
1515
+ 'ExpiryInPast()': (context) => {
1516
+ const parameters = getAuthorization(context);
1517
+ if (!parameters)
1518
+ return undefined;
1519
+ const [, expiry, minimum] = /expiry (\d+) <= min allowed (\d+)/.exec(context.details) ?? [];
1520
+ const requested = context.parameters.keyAuthorization?.expiry ??
1521
+ context.call?.arg('expiry') ??
1522
+ context.call?.arg('config')?.expiry;
1523
+ return new AccessKeyExpiryInPastError({
1524
+ ...parameters,
1525
+ expiry: expiry
1526
+ ? BigInt(expiry)
1527
+ : requested === undefined || requested === null
1528
+ ? undefined
1529
+ : BigInt(requested),
1530
+ minimum: minimum ? BigInt(minimum) : undefined,
1531
+ });
1532
+ },
1533
+ 'KeyAlreadyExists()': async (context) => {
1534
+ const parameters = getAuthorization(context);
1535
+ if (!parameters)
1536
+ return undefined;
1537
+ const [key] = await context.read([
1538
+ {
1539
+ ...keychain,
1540
+ functionName: 'getKey',
1541
+ args: [parameters.account, parameters.accessKey],
1542
+ },
1543
+ ]);
1544
+ return new AccessKeyAlreadyExistsError({
1545
+ ...parameters,
1546
+ expiry: key?.result?.expiry,
1547
+ limited: key?.result?.enforceLimits,
1548
+ });
1549
+ },
1550
+ 'KeyExpired()': async (context) => {
1551
+ const parameters = getSigner(context);
1552
+ if (!parameters)
1553
+ return undefined;
1554
+ const [key] = await context.read([
1555
+ {
1556
+ ...keychain,
1557
+ functionName: 'getKey',
1558
+ args: [parameters.account, parameters.accessKey],
1559
+ },
1560
+ ]);
1561
+ return new AccessKeyExpiredError({
1562
+ ...parameters,
1563
+ expiry: key?.result?.expiry,
1564
+ });
1565
+ },
1566
+ 'SignatureTypeMismatch(uint8,uint8)': (context) => {
1567
+ const parameters = getSigner(context) ?? getAuthorization(context);
1568
+ return parameters && new AccessKeySignatureTypeMismatchError(parameters);
1569
+ },
1570
+ 'SpendingLimitExceeded()': async (context) => {
1571
+ // Without revert data, the fee payment exceeded the limit.
1572
+ const fee = context.validation;
1573
+ const parameters = fee && context.parameters.feePayer
1574
+ ? getFeePayer(context)
1575
+ : getSigner(context);
1576
+ if (!parameters)
1577
+ return undefined;
1578
+ const token = fee
1579
+ ? getFeeToken(context)
1580
+ : isTip20(context.call?.address)
1581
+ ? context.call.address
1582
+ : undefined;
1583
+ if (!token)
1584
+ return new AccessKeySpendingLimitExceededError({
1585
+ ...parameters,
1586
+ fee,
1587
+ hints: fee
1588
+ ? [...parameters.hints, 'Pay fees with another token.']
1589
+ : parameters.hints,
1590
+ });
1591
+ const args = [parameters.account, parameters.accessKey, token];
1592
+ const [withPeriod, legacy, decimals] = await context.read([
1593
+ // `getRemainingLimitWithPeriod` is T3+; `getRemainingLimit` covers earlier hardforks.
1594
+ { ...keychain, functionName: 'getRemainingLimitWithPeriod', args },
1595
+ { ...keychain, functionName: 'getRemainingLimit', args },
1596
+ { address: token, abi: Abis.tip20, functionName: 'decimals' },
1597
+ ]);
1598
+ return new AccessKeySpendingLimitExceededError({
1599
+ ...parameters,
1600
+ amount: fee ? undefined : context.call?.arg('amount'),
1601
+ decimals: decimals?.result,
1602
+ fee,
1603
+ periodEnd: withPeriod?.result?.[1] || undefined,
1604
+ remaining: withPeriod?.result?.[0] ?? legacy?.result,
1605
+ token,
1606
+ });
1607
+ },
1608
+ };
1158
1609
  //# sourceMappingURL=accessKey.js.map