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
@@ -4,13 +4,13 @@ import { bindActionDecorators, type Client } from '../clients/createClient.js'
4
4
  import type { Transport } from '../clients/transports/createTransport.js'
5
5
  import type { Chain } from '../types/chain.js'
6
6
  import * as accessKeyActions from './actions/accessKey.js'
7
+ import * as accountsActions from './actions/accounts.js'
7
8
  import * as ammActions from './actions/amm.js'
8
9
  import * as channelActions from './actions/channel.js'
9
10
  import * as dexActions from './actions/dex.js'
10
11
  import * as earnActions from './actions/earn.js'
11
12
  import * as faucetActions from './actions/faucet.js'
12
13
  import * as feeActions from './actions/fee.js'
13
- import * as multisigActions from './actions/multisig.js'
14
14
  import * as nonceActions from './actions/nonce.js'
15
15
  import * as policyActions from './actions/policy.js'
16
16
  import * as propAmmActions from './actions/propAmm.js'
@@ -308,13 +308,41 @@ type DecoratorBase<
308
308
  parameters: accessKeyActions.revokeSync.Parameters<chain, account>,
309
309
  ) => Promise<accessKeyActions.revokeSync.ReturnValue>
310
310
  /**
311
- * Signs a key authorization or adds one coordinated multisig approval.
311
+ * Saves a signed key authorization to a relay with key authorization storage.
312
+ *
313
+ * The relay attaches the authorization to the access key's next transaction
314
+ * until the key is active onchain. Requires a relay running the
315
+ * `Relay.keyAuthorization` plugin.
316
+ *
317
+ * @example
318
+ * ```ts
319
+ * import { createClient, http } from 'viem'
320
+ * import { tempo } from 'viem/chains'
321
+ * import { tempoActions, withRelay } from 'viem/tempo'
322
+ *
323
+ * const client = createClient({
324
+ * chain: tempo,
325
+ * transport: withRelay(http(), http('https://relay.example.com'), {
326
+ * keyAuthorization: true,
327
+ * }),
328
+ * }).extend(tempoActions())
329
+ *
330
+ * await client.accessKey.saveAuthorization({ keyAuthorization })
331
+ * ```
332
+ *
333
+ * @param parameters - Parameters.
334
+ */
335
+ saveAuthorization: (
336
+ parameters: accessKeyActions.saveAuthorization.Parameters,
337
+ ) => Promise<accessKeyActions.saveAuthorization.ReturnValue>
338
+ /**
339
+ * Signs a key authorization or adds one coordinated owner approval.
312
340
  *
313
341
  * @example
314
342
  * ```ts
315
343
  * const pending = await client.accessKey.signAuthorization({
316
344
  * accessKey,
317
- * account: multisig,
345
+ * account: configurable,
318
346
  * owner: owner_1,
319
347
  * })
320
348
  * const success = await client.accessKey.signAuthorization({
@@ -324,7 +352,7 @@ type DecoratorBase<
324
352
  * ```
325
353
  *
326
354
  * @param parameters - Authorization fields, or a stored operation hash.
327
- * @returns A signed key authorization with multisig operation metadata when coordinated.
355
+ * @returns A signed key authorization with account operation metadata when coordinated.
328
356
  */
329
357
  signAuthorization: {
330
358
  (
@@ -474,6 +502,48 @@ type DecoratorBase<
474
502
  parameters: accessKeyActions.watchWitnessBurned.Parameters,
475
503
  ) => ReturnType<typeof accessKeyActions.watchWitnessBurned>
476
504
  }
505
+ accounts: {
506
+ /**
507
+ * Gets the current cached config for a configurable account.
508
+ *
509
+ * @param parameters - Parameters.
510
+ * @returns The config, or `null` when it is unknown.
511
+ */
512
+ getConfig: (
513
+ parameters: accountsActions.getConfig.Parameters,
514
+ ) => Promise<accountsActions.getConfig.ReturnValue>
515
+ /** Gets the current configuration commitment for a configurable account. */
516
+ getConfigCommitment: (
517
+ parameters: accountsActions.getConfigCommitment.Parameters,
518
+ ) => Promise<accountsActions.getConfigCommitment.ReturnValue>
519
+ /**
520
+ * Gets a coordinated account operation by its hash.
521
+ *
522
+ * @param parameters - Parameters.
523
+ * @returns The operation, or `null` when it is unknown.
524
+ */
525
+ getOperation: (
526
+ parameters: accountsActions.getOperation.Parameters,
527
+ ) => Promise<accountsActions.getOperation.ReturnValue>
528
+ /**
529
+ * Replaces the current configuration for a configurable account.
530
+ *
531
+ * @param parameters - New configuration and transaction parameters.
532
+ * @returns The transaction hash.
533
+ */
534
+ updateConfig: (
535
+ parameters: accountsActions.updateConfig.Parameters<chain, account>,
536
+ ) => Promise<accountsActions.updateConfig.ReturnValue>
537
+ /**
538
+ * Replaces a configurable account configuration and waits for confirmation.
539
+ *
540
+ * @param parameters - New configuration and transaction parameters.
541
+ * @returns The update event and transaction receipt.
542
+ */
543
+ updateConfigSync: (
544
+ parameters: accountsActions.updateConfigSync.Parameters<chain, account>,
545
+ ) => Promise<accountsActions.updateConfigSync.ReturnValue>
546
+ }
477
547
  amm: {
478
548
  /**
479
549
  * Gets the reserves for a liquidity pool.
@@ -2392,48 +2462,6 @@ type DecoratorBase<
2392
2462
  parameters: faucetActions.fundSync.Parameters,
2393
2463
  ) => Promise<faucetActions.fundSync.ReturnValue>
2394
2464
  }
2395
- multisig: {
2396
- /**
2397
- * Gets the current cached config for a multisig account.
2398
- *
2399
- * @param parameters - Parameters.
2400
- * @returns The config, or `null` when it is unknown.
2401
- */
2402
- getConfig: (
2403
- parameters: multisigActions.getConfig.Parameters,
2404
- ) => Promise<multisigActions.getConfig.ReturnValue>
2405
- /** Gets the current configuration commitment for a multisig account. */
2406
- getConfigCommitment: (
2407
- parameters: multisigActions.getConfigCommitment.Parameters,
2408
- ) => Promise<multisigActions.getConfigCommitment.ReturnValue>
2409
- /**
2410
- * Gets a coordinated multisig operation by its hash.
2411
- *
2412
- * @param parameters - Parameters.
2413
- * @returns The operation, or `null` when it is unknown.
2414
- */
2415
- getOperation: (
2416
- parameters: multisigActions.getOperation.Parameters,
2417
- ) => Promise<multisigActions.getOperation.ReturnValue>
2418
- /**
2419
- * Replaces the current configuration for a native multisig account.
2420
- *
2421
- * @param parameters - New configuration and transaction parameters.
2422
- * @returns The transaction hash.
2423
- */
2424
- updateConfig: (
2425
- parameters: multisigActions.updateConfig.Parameters<chain, account>,
2426
- ) => Promise<multisigActions.updateConfig.ReturnValue>
2427
- /**
2428
- * Replaces a native multisig configuration and waits for confirmation.
2429
- *
2430
- * @param parameters - New configuration and transaction parameters.
2431
- * @returns The update event and transaction receipt.
2432
- */
2433
- updateConfigSync: (
2434
- parameters: multisigActions.updateConfigSync.Parameters<chain, account>,
2435
- ) => Promise<multisigActions.updateConfigSync.ReturnValue>
2436
- }
2437
2465
  nonce: {
2438
2466
  /**
2439
2467
  * Gets the nonce for an account and nonce key.
@@ -6049,9 +6077,11 @@ type DecorateNamespace<namespace, actions> = {
6049
6077
  ? namespace[key] & BoundActionHelpers<actions[key]>
6050
6078
  : namespace[key]
6051
6079
  } & {
6052
- [key in Exclude<keyof actions, keyof namespace> as actions[key] extends (
6053
- ...parameters: any
6054
- ) => any
6080
+ // Error classes and resolvers are not actions; skipping them by name avoids evaluating their types.
6081
+ [key in Exclude<
6082
+ keyof actions,
6083
+ keyof namespace | `${string}Error` | 'errorResolvers'
6084
+ > as actions[key] extends (...parameters: any) => any
6055
6085
  ? key
6056
6086
  : never]: BoundAction<actions[key]>
6057
6087
  }
@@ -6064,6 +6094,10 @@ export type Decorator<
6064
6094
  DecoratorBase<chain, account>['accessKey'],
6065
6095
  typeof accessKeyActions
6066
6096
  >
6097
+ accounts: DecorateNamespace<
6098
+ DecoratorBase<chain, account>['accounts'],
6099
+ typeof accountsActions
6100
+ >
6067
6101
  amm: DecorateNamespace<
6068
6102
  DecoratorBase<chain, account>['amm'],
6069
6103
  typeof ammActions
@@ -6084,10 +6118,6 @@ export type Decorator<
6084
6118
  DecoratorBase<chain, account>['faucet'],
6085
6119
  typeof faucetActions
6086
6120
  >
6087
- multisig: DecorateNamespace<
6088
- DecoratorBase<chain, account>['multisig'],
6089
- typeof multisigActions
6090
- >
6091
6121
  nonce: DecorateNamespace<
6092
6122
  DecoratorBase<chain, account>['nonce'],
6093
6123
  typeof nonceActions
@@ -6166,6 +6196,7 @@ export function decorator() {
6166
6196
  'prepareAuthorization',
6167
6197
  'revoke',
6168
6198
  'revokeSync',
6199
+ 'saveAuthorization',
6169
6200
  'signAuthorization',
6170
6201
  'updateLimit',
6171
6202
  'updateLimitSync',
@@ -6174,6 +6205,13 @@ export function decorator() {
6174
6205
  'watchWitness',
6175
6206
  'watchWitnessBurned',
6176
6207
  ]),
6208
+ accounts: bindActions(client, accountsActions, [
6209
+ 'getConfig',
6210
+ 'getConfigCommitment',
6211
+ 'getOperation',
6212
+ 'updateConfig',
6213
+ 'updateConfigSync',
6214
+ ]),
6177
6215
  amm: bindActions(client, ammActions, [
6178
6216
  'getPool',
6179
6217
  'getLiquidityBalance',
@@ -6262,13 +6300,6 @@ export function decorator() {
6262
6300
  'withdrawExactSync',
6263
6301
  ]),
6264
6302
  faucet: bindActions(client, faucetActions, ['fund', 'fundSync']),
6265
- multisig: bindActions(client, multisigActions, [
6266
- 'getConfig',
6267
- 'getConfigCommitment',
6268
- 'getOperation',
6269
- 'updateConfig',
6270
- 'updateConfigSync',
6271
- ]),
6272
6303
  nonce: bindActions(client, nonceActions, [
6273
6304
  'getNonce',
6274
6305
  'watchNonceIncremented',
@@ -8,7 +8,7 @@ import { formatAbiItem } from '../utils/abi/formatAbiItem.js'
8
8
  import { toFunctionSelector } from '../utils/hash/toFunctionSelector.js'
9
9
  import * as Abis from './Abis.js'
10
10
 
11
- type AllAbis = typeof Abis.core
11
+ type AllAbis = typeof Abis.coreErrors
12
12
  type AbiErrorName = Extract<AllAbis[number], { type: 'error' }>['name']
13
13
 
14
14
  type DecodedError<error = DecodeErrorResultReturnType<AllAbis>> =
@@ -114,7 +114,7 @@ export const messages: Record<`${AbiErrorName}(${string})`, string> = {
114
114
  'InvalidMasterAddress()': 'Invalid master address.',
115
115
  'InvalidMigrationIndex()': 'Invalid migration index.',
116
116
  'InvalidMode()': 'Invalid mode.',
117
- 'InvalidMultisigOwner()': 'Invalid multisig owner.',
117
+ 'InvalidMultisigOwner()': 'Invalid owner.',
118
118
  'InvalidNonceKey()': 'Invalid nonce key.',
119
119
  'InvalidOwner()': 'Invalid owner.',
120
120
  'InvalidOwnerOrder()': 'Invalid owner order.',
@@ -230,6 +230,88 @@ export const messages: Record<`${AbiErrorName}(${string})`, string> = {
230
230
  'ZeroPublicKey()': 'Public key cannot be zero.',
231
231
  }
232
232
 
233
+ /** Steps to resolve an error, keyed by error signature in `Abis.core`. */
234
+ export const hints: Partial<Record<keyof typeof messages, readonly string[]>> =
235
+ {
236
+ 'CallNotAllowed()': [
237
+ "The access key's scopes do not allow this target, selector, or recipient.",
238
+ 'Authorize an access key whose scopes include this call.',
239
+ ],
240
+ 'ContractPaused()': [
241
+ 'The token is paused. An account with the unpause role can unpause it.',
242
+ ],
243
+ 'ExpiringNonceReplay()': ['Resend the transaction with a new nonce.'],
244
+ 'ExpiryInPast()': ['Set the expiry to a future time.'],
245
+ 'InsufficientAllowance()': [
246
+ 'Approve the spender for at least this amount.',
247
+ ],
248
+ 'InsufficientBalance(uint256,uint256,address)': [
249
+ 'Fund the account or lower the amount.',
250
+ ],
251
+ 'InsufficientFeeTokenBalance()': [
252
+ 'Fund the account with the fee token, or pay fees with another token.',
253
+ ],
254
+ 'KeyAlreadyExists()': ['Use a new access key, or revoke the existing one.'],
255
+ 'KeyAlreadyRevoked()': [
256
+ 'Revoked access keys cannot be used or re-authorized. Authorize a new access key.',
257
+ ],
258
+ 'KeyExpired()': ['Authorize a new access key.'],
259
+ 'KeyNotFound()': [
260
+ 'Authorize the access key first, or authorize it in the same transaction with a key authorization.',
261
+ ],
262
+ 'PolicyForbids()': [
263
+ 'The token transfer policy forbids this sender or recipient.',
264
+ ],
265
+ 'SpendingLimitExceeded()': [
266
+ 'Raise the spending limit, or wait for a periodic limit to reset.',
267
+ ],
268
+ 'UnauthorizedCaller()': ['Sign with the root key or an admin access key.'],
269
+ 'AmountExceedsDeposit()': [
270
+ 'Top up the channel, or use a voucher for a smaller amount.',
271
+ ],
272
+ 'AmountNotIncreasing()': [
273
+ 'Use a voucher with a higher cumulative amount than the amount already settled.',
274
+ ],
275
+ 'BelowMinimumOrderSize(uint128)': ['Place a larger order.'],
276
+ 'ChannelNotFound()': [
277
+ 'Check the channel details, or open the channel first.',
278
+ ],
279
+ 'CloseNotReady()': [
280
+ 'Request a close, then wait for the grace period to end before withdrawing.',
281
+ ],
282
+ 'InsufficientBalance()': [
283
+ 'Deposit more of the token, or lower the amount.',
284
+ ],
285
+ 'InsufficientLiquidity()': ['Use a smaller amount.'],
286
+ 'InsufficientOutput()': [
287
+ 'Lower the minimum output amount, or sell a smaller amount.',
288
+ ],
289
+ 'InsufficientReserves()': ['Use a smaller amount.'],
290
+ 'InvalidExpiringNonceExpiry()': [
291
+ 'Set the transaction expiry to a time in the near future.',
292
+ ],
293
+ 'InvalidFlipTick()': [
294
+ 'Choose a flip tick on the correct side of the order tick.',
295
+ ],
296
+ 'MaxInputExceeded()': [
297
+ 'Raise the maximum input amount, or buy a smaller amount.',
298
+ ],
299
+ 'OrderDoesNotExist()': [
300
+ 'Check the order ID. Filled and cancelled orders no longer exist.',
301
+ ],
302
+ 'OrderNotStale()': [
303
+ 'Only orders whose maker lost authorization can be cancelled as stale.',
304
+ ],
305
+ 'PairDoesNotExist()': ['Create the trading pair first.'],
306
+ 'PolicyNotFound()': ['Check the policy ID, or create the policy first.'],
307
+ 'SignatureTypeMismatch(uint8,uint8)': [
308
+ 'Sign with the same key type the access key was authorized with.',
309
+ ],
310
+ 'SupplyCapExceeded()': ['Mint a smaller amount, or raise the supply cap.'],
311
+ 'TickOutOfBounds(int16)': ['Use a tick within the allowed range.'],
312
+ 'Unauthorized()': ['The account lacks the permission this call requires.'],
313
+ }
314
+
233
315
  /** Interpolate `{0}`, `{1}`, … placeholders with args. */
234
316
  function interpolate(template: string, args?: readonly unknown[]): string {
235
317
  if (!args) return template
@@ -370,7 +452,7 @@ function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
370
452
  const data = extractRevertData(error)
371
453
  if (data) {
372
454
  try {
373
- const decoded = decodeErrorResult({ abi: Abis.core, data })
455
+ const decoded = decodeErrorResult({ abi: Abis.coreErrors, data })
374
456
  const template =
375
457
  messages[formatAbiItem(decoded.abiItem) as keyof typeof messages]
376
458
  return {
@@ -382,7 +464,7 @@ function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
382
464
  } as never
383
465
  } catch {
384
466
  if (data.length === 10) {
385
- const abiItem = Abis.core.find(
467
+ const abiItem = Abis.coreErrors.find(
386
468
  (item) =>
387
469
  item.type === 'error' &&
388
470
  toFunctionSelector(formatAbiItem(item)) === data.toLowerCase(),
@@ -399,6 +481,22 @@ function parse(error: Exclude<from.Parameters, Hex>): ExecutionError {
399
481
  }
400
482
  }
401
483
 
484
+ // Nodes print zero-argument errors as `Name(Name)`, whose revert data is the selector alone.
485
+ const debugMatch = /\b(\w+)\(\1\)/.exec(raw)
486
+ const abiItem = debugMatch
487
+ ? Abis.coreErrors.find(
488
+ (item) => item.name === debugMatch[1] && item.inputs.length === 0,
489
+ )
490
+ : undefined
491
+ if (abiItem)
492
+ return {
493
+ abiItem,
494
+ args: undefined,
495
+ data: toFunctionSelector(formatAbiItem(abiItem)),
496
+ errorName: abiItem.name,
497
+ message: messages[formatAbiItem(abiItem) as keyof typeof messages]!,
498
+ } as DecodedError
499
+
402
500
  // Human-readable names cannot distinguish overloads with different templates.
403
501
  const nameMatch = /:\s*(\w+)\(([^)]*)\)/.exec(raw)
404
502
  if (nameMatch) {
@@ -3,7 +3,7 @@
3
3
  import type { Address } from 'abitype'
4
4
  import * as Hex from 'ox/Hex'
5
5
  import {
6
- MultisigOperation,
6
+ AccountOperation,
7
7
  Transaction as ox_Transaction,
8
8
  TransactionRequest as ox_TransactionRequest,
9
9
  } from 'ox/tempo'
@@ -12,7 +12,7 @@ import { parseAccount } from '../accounts/utils/parseAccount.js'
12
12
  import { formatTransaction as viem_formatTransaction } from '../utils/formatters/transaction.js'
13
13
  import { formatTransactionReceipt as viem_formatTransactionReceipt } from '../utils/formatters/transactionReceipt.js'
14
14
  import { formatTransactionRequest as viem_formatTransactionRequest } from '../utils/formatters/transactionRequest.js'
15
- import type { Account, MultisigAccount } from './Account.js'
15
+ import type { Account, ConfigurableAccount } from './Account.js'
16
16
  import {
17
17
  isTempo,
18
18
  type Transaction,
@@ -33,7 +33,7 @@ export function formatTransaction(
33
33
  transaction.blockTimestamp == null
34
34
  ? undefined
35
35
  : BigInt(transaction.blockTimestamp)
36
- const multisig = transaction.multisig
36
+ const operation = transaction.operation
37
37
  const {
38
38
  feePayerSignature,
39
39
  gasPrice: _,
@@ -53,8 +53,8 @@ export function formatTransaction(
53
53
  yParity: feePayerSignature.yParity,
54
54
  }
55
55
  : undefined,
56
- multisig: formatMultisig(multisig),
57
56
  nonce: Number(nonce),
57
+ operation: formatOperation(operation),
58
58
  typeHex:
59
59
  ox_Transaction.toRpcType[
60
60
  tx.type as keyof typeof ox_Transaction.toRpcType
@@ -69,7 +69,7 @@ export function formatTransactionReceipt(
69
69
  const transactionReceipt = viem_formatTransactionReceipt(receipt as never)
70
70
  return {
71
71
  ...transactionReceipt,
72
- multisig: formatMultisig(receipt.multisig),
72
+ operation: formatOperation(receipt.operation),
73
73
  ...(receipt.status === 'pending'
74
74
  ? { status: 'pending', type: 'tempo' }
75
75
  : {}),
@@ -77,11 +77,11 @@ export function formatTransactionReceipt(
77
77
  }
78
78
 
79
79
  /** Formats a transaction operation attached to an RPC result. */
80
- function formatMultisig(value: MultisigOperation.TransactionRpc | undefined) {
80
+ function formatOperation(value: AccountOperation.TransactionRpc | undefined) {
81
81
  if (!value) return undefined
82
- const operation = MultisigOperation.fromRpc(value)
82
+ const operation = AccountOperation.fromRpc(value)
83
83
  if (operation.type !== 'transaction')
84
- throw new Error('Expected a multisig transaction operation.')
84
+ throw new Error('Expected an account transaction operation.')
85
85
  return operation
86
86
  }
87
87
 
@@ -98,21 +98,21 @@ export function formatTransactionRequest(
98
98
  keyData?: Hex.Hex | undefined
99
99
  keyId?: Address | undefined
100
100
  keyType?: 'p256' | 'secp256k1' | 'webAuthn' | undefined
101
- owner?: viem_Account | MultisigAccount | Address | undefined
101
+ owner?: viem_Account | ConfigurableAccount | Address | undefined
102
102
  signatures?: unknown
103
103
  }
104
104
  const account = request.account
105
105
  ? parseAccount<Account | viem_Account | Address>(request.account)
106
106
  : undefined
107
107
  const owner = request.owner
108
- ? parseAccount<Account | MultisigAccount | viem_Account | Address>(
108
+ ? parseAccount<Account | ConfigurableAccount | viem_Account | Address>(
109
109
  request.owner,
110
110
  )
111
111
  : undefined
112
112
 
113
113
  if (owner?.type === 'json-rpc')
114
114
  throw new Error(
115
- 'A local owner account is required to approve a multisig transaction.',
115
+ 'A local owner account is required to approve a configurable account transaction.',
116
116
  )
117
117
 
118
118
  // If the request is not a Tempo transaction, route to Viem formatter.
@@ -147,7 +147,7 @@ export function formatTransactionRequest(
147
147
  if (request.feePayer === true && !request.feePayerSignature)
148
148
  delete request.feeToken
149
149
 
150
- // Client-only TIP-1061 fields drive local signing and envelope assembly.
150
+ // Client-only TIP-1107 fields drive local signing and envelope assembly.
151
151
  const { owner: _owner, signatures: _signatures, ...rpcRequest } = request
152
152
 
153
153
  const rpc = ox_TransactionRequest.toRpc({
@@ -191,7 +191,8 @@ export function formatTransactionRequest(
191
191
  ...(keyData ? { keyData } : {}),
192
192
  ...(keyId ? { keyId } : {}),
193
193
  ...(keyType ? { keyType } : {}),
194
- // Keep the key visible to `extract`; the undefined value never reaches JSON-RPC.
194
+ // Keep client-only keys visible to `extract`; undefined values never reach JSON-RPC.
195
+ ...(request.accountSimulation ? { accountSimulation: undefined } : {}),
195
196
  ...(request.owner ? { owner: undefined } : {}),
196
197
  ...(typeof request.feePayer !== 'undefined'
197
198
  ? {
@@ -1,49 +1,101 @@
1
1
  import type { Address } from 'abitype'
2
- import type { KeyAuthorization } from 'ox/tempo'
2
+ import { KeyAuthorization } from 'ox/tempo'
3
3
  import type { MaybePromise } from '../types/utils.js'
4
+ import * as Store from './Store.js'
4
5
 
6
+ /** Identifies a pending key authorization by account, access key, and chain. */
5
7
  export type Key = {
8
+ /** Account the access key acts for. */
6
9
  address: Address
10
+ /** Access key address. */
7
11
  accessKey: Address
12
+ /** Chain the authorization is for. */
8
13
  chainId: number
9
14
  }
10
15
 
16
+ /** Pending key authorizations that the client attaches to an access key's next transaction. */
11
17
  export type KeyAuthorizationManager = {
18
+ /** Reads the pending authorization for a key. */
12
19
  get(key: Key): MaybePromise<KeyAuthorization.Signed | undefined>
20
+ /** Removes the pending authorization for a key. */
13
21
  remove(key: Key): MaybePromise<void>
22
+ /** Stores a pending authorization for a key. */
14
23
  set(key: Key, keyAuthorization: KeyAuthorization.Signed): MaybePromise<void>
15
24
  }
16
25
 
26
+ /**
27
+ * Creates a key authorization manager backed by a store.
28
+ *
29
+ * Entries use the same keys as the `Relay.keyAuthorization` plugin, so both can
30
+ * share one store.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { Account, KeyAuthorizationManager, Store } from 'viem/tempo'
35
+ *
36
+ * const accessKey = Account.fromP256(privateKey, {
37
+ * access: root,
38
+ * keyAuthorizationManager: KeyAuthorizationManager.from({
39
+ * store: Store.session(),
40
+ * }),
41
+ * })
42
+ * ```
43
+ *
44
+ * @param options - Manager options.
45
+ * @returns A key authorization manager.
46
+ */
17
47
  export function from(options: from.Options): KeyAuthorizationManager {
18
- return options.source
48
+ const { store } = options
49
+ return {
50
+ async get(key) {
51
+ const value = await store.getItem(getStoreKey(key))
52
+ if (!value) return undefined
53
+ try {
54
+ return KeyAuthorization.deserialize(
55
+ value as `0x${string}`,
56
+ ) as KeyAuthorization.Signed
57
+ } catch {
58
+ return undefined
59
+ }
60
+ },
61
+ async remove(key) {
62
+ await store.removeItem(getStoreKey(key))
63
+ },
64
+ async set(key, keyAuthorization) {
65
+ await store.setItem(
66
+ getStoreKey(key),
67
+ KeyAuthorization.serialize(keyAuthorization),
68
+ )
69
+ },
70
+ }
19
71
  }
20
72
 
21
73
  export declare namespace from {
22
74
  type Options = {
23
- source: KeyAuthorizationManager
75
+ /** Store for pending key authorizations. */
76
+ store: Store.Store
24
77
  }
25
78
  }
26
79
 
80
+ /**
81
+ * Creates a key authorization manager backed by a process-local memory store.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { KeyAuthorizationManager } from 'viem/tempo'
86
+ *
87
+ * const keyAuthorizationManager = KeyAuthorizationManager.memory()
88
+ * ```
89
+ *
90
+ * @returns A key authorization manager.
91
+ */
27
92
  export function memory(): KeyAuthorizationManager {
28
- const keyAuthorizations = new Map<string, KeyAuthorization.Signed>()
29
-
30
- return from({
31
- source: {
32
- get(key) {
33
- return keyAuthorizations.get(serializeKey(key))
34
- },
35
- remove(key) {
36
- keyAuthorizations.delete(serializeKey(key))
37
- },
38
- set(key, keyAuthorization) {
39
- keyAuthorizations.set(serializeKey(key), keyAuthorization)
40
- },
41
- },
42
- })
93
+ return from({ store: Store.memory() })
43
94
  }
44
95
 
45
- function serializeKey(key: Key) {
96
+ function getStoreKey(key: Key) {
46
97
  return [
98
+ 'keyAuthorization',
47
99
  key.chainId,
48
100
  key.address.toLowerCase(),
49
101
  key.accessKey.toLowerCase(),