viem 2.53.1 → 2.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (441) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/_cjs/actions/index.js +3 -2
  3. package/_cjs/actions/index.js.map +1 -1
  4. package/_cjs/actions/token/approve.js +62 -0
  5. package/_cjs/actions/token/approve.js.map +1 -0
  6. package/_cjs/actions/token/approveSync.js +25 -0
  7. package/_cjs/actions/token/approveSync.js.map +1 -0
  8. package/_cjs/actions/token/getAllowance.js +32 -0
  9. package/_cjs/actions/token/getAllowance.js.map +1 -0
  10. package/_cjs/actions/token/getBalance.js +41 -0
  11. package/_cjs/actions/token/getBalance.js.map +1 -0
  12. package/_cjs/actions/token/getMetadata.js +40 -0
  13. package/_cjs/actions/token/getMetadata.js.map +1 -0
  14. package/_cjs/actions/token/getTotalSupply.js +32 -0
  15. package/_cjs/actions/token/getTotalSupply.js.map +1 -0
  16. package/_cjs/actions/token/index.js +20 -0
  17. package/_cjs/actions/token/index.js.map +1 -0
  18. package/_cjs/actions/token/internal.js +125 -0
  19. package/_cjs/actions/token/internal.js.map +1 -0
  20. package/_cjs/actions/token/transfer.js +70 -0
  21. package/_cjs/actions/token/transfer.js.map +1 -0
  22. package/_cjs/actions/token/transferSync.js +25 -0
  23. package/_cjs/actions/token/transferSync.js.map +1 -0
  24. package/_cjs/chains/definitions/battlechain.js +31 -0
  25. package/_cjs/chains/definitions/battlechain.js.map +1 -0
  26. package/_cjs/chains/definitions/marooTestnet.js +30 -0
  27. package/_cjs/chains/definitions/marooTestnet.js.map +1 -0
  28. package/_cjs/chains/index.js +18 -14
  29. package/_cjs/chains/index.js.map +1 -1
  30. package/_cjs/clients/createClient.js +39 -1
  31. package/_cjs/clients/createClient.js.map +1 -1
  32. package/_cjs/clients/createPublicClient.js.map +1 -1
  33. package/_cjs/clients/createWalletClient.js.map +1 -1
  34. package/_cjs/clients/decorators/public.js +11 -0
  35. package/_cjs/clients/decorators/public.js.map +1 -1
  36. package/_cjs/clients/decorators/wallet.js +8 -0
  37. package/_cjs/clients/decorators/wallet.js.map +1 -1
  38. package/_cjs/clients/transports/http.js +2 -1
  39. package/_cjs/clients/transports/http.js.map +1 -1
  40. package/_cjs/errors/encoding.js +9 -1
  41. package/_cjs/errors/encoding.js.map +1 -1
  42. package/_cjs/errors/request.js +24 -1
  43. package/_cjs/errors/request.js.map +1 -1
  44. package/_cjs/errors/transaction.js +9 -1
  45. package/_cjs/errors/transaction.js.map +1 -1
  46. package/_cjs/errors/version.js +1 -1
  47. package/_cjs/index.js +9 -6
  48. package/_cjs/index.js.map +1 -1
  49. package/_cjs/tempo/Client.js.map +1 -1
  50. package/_cjs/tempo/Decorator.js +234 -215
  51. package/_cjs/tempo/Decorator.js.map +1 -1
  52. package/_cjs/tempo/actions/token.js +210 -112
  53. package/_cjs/tempo/actions/token.js.map +1 -1
  54. package/_cjs/tempo/internal/utils.js +108 -0
  55. package/_cjs/tempo/internal/utils.js.map +1 -1
  56. package/_cjs/tokens/defineToken.js +21 -0
  57. package/_cjs/tokens/defineToken.js.map +1 -0
  58. package/_cjs/tokens/definitions/alphausd.js +14 -0
  59. package/_cjs/tokens/definitions/alphausd.js.map +1 -0
  60. package/_cjs/tokens/definitions/betausd.js +14 -0
  61. package/_cjs/tokens/definitions/betausd.js.map +1 -0
  62. package/_cjs/tokens/definitions/brla.js +14 -0
  63. package/_cjs/tokens/definitions/brla.js.map +1 -0
  64. package/_cjs/tokens/definitions/cbbtc.js +14 -0
  65. package/_cjs/tokens/definitions/cbbtc.js.map +1 -0
  66. package/_cjs/tokens/definitions/chfau.js +14 -0
  67. package/_cjs/tokens/definitions/chfau.js.map +1 -0
  68. package/_cjs/tokens/definitions/cusd.js +14 -0
  69. package/_cjs/tokens/definitions/cusd.js.map +1 -0
  70. package/_cjs/tokens/definitions/dlusd.js +14 -0
  71. package/_cjs/tokens/definitions/dlusd.js.map +1 -0
  72. package/_cjs/tokens/definitions/eurau.js +14 -0
  73. package/_cjs/tokens/definitions/eurau.js.map +1 -0
  74. package/_cjs/tokens/definitions/eurce.js +15 -0
  75. package/_cjs/tokens/definitions/eurce.js.map +1 -0
  76. package/_cjs/tokens/definitions/frxusd.js +14 -0
  77. package/_cjs/tokens/definitions/frxusd.js.map +1 -0
  78. package/_cjs/tokens/definitions/gbpa.js +14 -0
  79. package/_cjs/tokens/definitions/gbpa.js.map +1 -0
  80. package/_cjs/tokens/definitions/gusd.js +14 -0
  81. package/_cjs/tokens/definitions/gusd.js.map +1 -0
  82. package/_cjs/tokens/definitions/iusd.js +14 -0
  83. package/_cjs/tokens/definitions/iusd.js.map +1 -0
  84. package/_cjs/tokens/definitions/pathusd.js +15 -0
  85. package/_cjs/tokens/definitions/pathusd.js.map +1 -0
  86. package/_cjs/tokens/definitions/reusd.js +14 -0
  87. package/_cjs/tokens/definitions/reusd.js.map +1 -0
  88. package/_cjs/tokens/definitions/rusd.js +14 -0
  89. package/_cjs/tokens/definitions/rusd.js.map +1 -0
  90. package/_cjs/tokens/definitions/sbc.js +14 -0
  91. package/_cjs/tokens/definitions/sbc.js.map +1 -0
  92. package/_cjs/tokens/definitions/siusd.js +14 -0
  93. package/_cjs/tokens/definitions/siusd.js.map +1 -0
  94. package/_cjs/tokens/definitions/stcusd.js +14 -0
  95. package/_cjs/tokens/definitions/stcusd.js.map +1 -0
  96. package/_cjs/tokens/definitions/susde.js +14 -0
  97. package/_cjs/tokens/definitions/susde.js.map +1 -0
  98. package/_cjs/tokens/definitions/syrupusdc.js +14 -0
  99. package/_cjs/tokens/definitions/syrupusdc.js.map +1 -0
  100. package/_cjs/tokens/definitions/thetausd.js +14 -0
  101. package/_cjs/tokens/definitions/thetausd.js.map +1 -0
  102. package/_cjs/tokens/definitions/usd1.js +14 -0
  103. package/_cjs/tokens/definitions/usd1.js.map +1 -0
  104. package/_cjs/tokens/definitions/usdb.js +14 -0
  105. package/_cjs/tokens/definitions/usdb.js.map +1 -0
  106. package/_cjs/tokens/definitions/usdc.js +41 -0
  107. package/_cjs/tokens/definitions/usdc.js.map +1 -0
  108. package/_cjs/tokens/definitions/usdce.js +15 -0
  109. package/_cjs/tokens/definitions/usdce.js.map +1 -0
  110. package/_cjs/tokens/definitions/usde.js +14 -0
  111. package/_cjs/tokens/definitions/usde.js.map +1 -0
  112. package/_cjs/tokens/definitions/usdt0.js +14 -0
  113. package/_cjs/tokens/definitions/usdt0.js.map +1 -0
  114. package/_cjs/tokens/definitions/wsrusd.js +14 -0
  115. package/_cjs/tokens/definitions/wsrusd.js.map +1 -0
  116. package/_cjs/tokens/index.js +64 -0
  117. package/_cjs/tokens/index.js.map +1 -0
  118. package/_cjs/utils/encoding/fromRlp.js +7 -4
  119. package/_cjs/utils/encoding/fromRlp.js.map +1 -1
  120. package/_cjs/utils/rpc/http.js +58 -3
  121. package/_cjs/utils/rpc/http.js.map +1 -1
  122. package/_cjs/utils/transaction/parseTransaction.js +4 -1
  123. package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
  124. package/_esm/actions/index.js +1 -0
  125. package/_esm/actions/index.js.map +1 -1
  126. package/_esm/actions/token/approve.js +123 -0
  127. package/_esm/actions/token/approve.js.map +1 -0
  128. package/_esm/actions/token/approveSync.js +50 -0
  129. package/_esm/actions/token/approveSync.js.map +1 -0
  130. package/_esm/actions/token/getAllowance.js +62 -0
  131. package/_esm/actions/token/getAllowance.js.map +1 -0
  132. package/_esm/actions/token/getBalance.js +70 -0
  133. package/_esm/actions/token/getBalance.js.map +1 -0
  134. package/_esm/actions/token/getMetadata.js +60 -0
  135. package/_esm/actions/token/getMetadata.js.map +1 -0
  136. package/_esm/actions/token/getTotalSupply.js +60 -0
  137. package/_esm/actions/token/getTotalSupply.js.map +1 -0
  138. package/_esm/actions/token/index.js +10 -0
  139. package/_esm/actions/token/index.js.map +1 -0
  140. package/_esm/actions/token/internal.js +188 -0
  141. package/_esm/actions/token/internal.js.map +1 -0
  142. package/_esm/actions/token/transfer.js +147 -0
  143. package/_esm/actions/token/transfer.js.map +1 -0
  144. package/_esm/actions/token/transferSync.js +54 -0
  145. package/_esm/actions/token/transferSync.js.map +1 -0
  146. package/_esm/chains/definitions/battlechain.js +28 -0
  147. package/_esm/chains/definitions/battlechain.js.map +1 -0
  148. package/_esm/chains/definitions/marooTestnet.js +27 -0
  149. package/_esm/chains/definitions/marooTestnet.js.map +1 -0
  150. package/_esm/chains/index.js +2 -0
  151. package/_esm/chains/index.js.map +1 -1
  152. package/_esm/clients/createClient.js +53 -1
  153. package/_esm/clients/createClient.js.map +1 -1
  154. package/_esm/clients/createPublicClient.js.map +1 -1
  155. package/_esm/clients/createWalletClient.js.map +1 -1
  156. package/_esm/clients/decorators/public.js +17 -0
  157. package/_esm/clients/decorators/public.js.map +1 -1
  158. package/_esm/clients/decorators/wallet.js +8 -0
  159. package/_esm/clients/decorators/wallet.js.map +1 -1
  160. package/_esm/clients/transports/http.js +2 -1
  161. package/_esm/clients/transports/http.js.map +1 -1
  162. package/_esm/errors/encoding.js +7 -0
  163. package/_esm/errors/encoding.js.map +1 -1
  164. package/_esm/errors/request.js +22 -0
  165. package/_esm/errors/request.js.map +1 -1
  166. package/_esm/errors/transaction.js +7 -0
  167. package/_esm/errors/transaction.js.map +1 -1
  168. package/_esm/errors/version.js +1 -1
  169. package/_esm/index.js +3 -3
  170. package/_esm/index.js.map +1 -1
  171. package/_esm/tempo/Client.js.map +1 -1
  172. package/_esm/tempo/Decorator.js +234 -218
  173. package/_esm/tempo/Decorator.js.map +1 -1
  174. package/_esm/tempo/actions/token.js +335 -186
  175. package/_esm/tempo/actions/token.js.map +1 -1
  176. package/_esm/tempo/actions/wallet.js +1 -1
  177. package/_esm/tempo/internal/utils.js +154 -0
  178. package/_esm/tempo/internal/utils.js.map +1 -1
  179. package/_esm/tokens/defineToken.js +57 -0
  180. package/_esm/tokens/defineToken.js.map +1 -0
  181. package/_esm/tokens/definitions/alphausd.js +12 -0
  182. package/_esm/tokens/definitions/alphausd.js.map +1 -0
  183. package/_esm/tokens/definitions/betausd.js +12 -0
  184. package/_esm/tokens/definitions/betausd.js.map +1 -0
  185. package/_esm/tokens/definitions/brla.js +12 -0
  186. package/_esm/tokens/definitions/brla.js.map +1 -0
  187. package/_esm/tokens/definitions/cbbtc.js +12 -0
  188. package/_esm/tokens/definitions/cbbtc.js.map +1 -0
  189. package/_esm/tokens/definitions/chfau.js +12 -0
  190. package/_esm/tokens/definitions/chfau.js.map +1 -0
  191. package/_esm/tokens/definitions/cusd.js +12 -0
  192. package/_esm/tokens/definitions/cusd.js.map +1 -0
  193. package/_esm/tokens/definitions/dlusd.js +12 -0
  194. package/_esm/tokens/definitions/dlusd.js.map +1 -0
  195. package/_esm/tokens/definitions/eurau.js +12 -0
  196. package/_esm/tokens/definitions/eurau.js.map +1 -0
  197. package/_esm/tokens/definitions/eurce.js +13 -0
  198. package/_esm/tokens/definitions/eurce.js.map +1 -0
  199. package/_esm/tokens/definitions/frxusd.js +12 -0
  200. package/_esm/tokens/definitions/frxusd.js.map +1 -0
  201. package/_esm/tokens/definitions/gbpa.js +12 -0
  202. package/_esm/tokens/definitions/gbpa.js.map +1 -0
  203. package/_esm/tokens/definitions/gusd.js +12 -0
  204. package/_esm/tokens/definitions/gusd.js.map +1 -0
  205. package/_esm/tokens/definitions/iusd.js +12 -0
  206. package/_esm/tokens/definitions/iusd.js.map +1 -0
  207. package/_esm/tokens/definitions/pathusd.js +13 -0
  208. package/_esm/tokens/definitions/pathusd.js.map +1 -0
  209. package/_esm/tokens/definitions/reusd.js +12 -0
  210. package/_esm/tokens/definitions/reusd.js.map +1 -0
  211. package/_esm/tokens/definitions/rusd.js +12 -0
  212. package/_esm/tokens/definitions/rusd.js.map +1 -0
  213. package/_esm/tokens/definitions/sbc.js +12 -0
  214. package/_esm/tokens/definitions/sbc.js.map +1 -0
  215. package/_esm/tokens/definitions/siusd.js +12 -0
  216. package/_esm/tokens/definitions/siusd.js.map +1 -0
  217. package/_esm/tokens/definitions/stcusd.js +12 -0
  218. package/_esm/tokens/definitions/stcusd.js.map +1 -0
  219. package/_esm/tokens/definitions/susde.js +12 -0
  220. package/_esm/tokens/definitions/susde.js.map +1 -0
  221. package/_esm/tokens/definitions/syrupusdc.js +12 -0
  222. package/_esm/tokens/definitions/syrupusdc.js.map +1 -0
  223. package/_esm/tokens/definitions/thetausd.js +12 -0
  224. package/_esm/tokens/definitions/thetausd.js.map +1 -0
  225. package/_esm/tokens/definitions/usd1.js +12 -0
  226. package/_esm/tokens/definitions/usd1.js.map +1 -0
  227. package/_esm/tokens/definitions/usdb.js +12 -0
  228. package/_esm/tokens/definitions/usdb.js.map +1 -0
  229. package/_esm/tokens/definitions/usdc.js +67 -0
  230. package/_esm/tokens/definitions/usdc.js.map +1 -0
  231. package/_esm/tokens/definitions/usdce.js +13 -0
  232. package/_esm/tokens/definitions/usdce.js.map +1 -0
  233. package/_esm/tokens/definitions/usde.js +12 -0
  234. package/_esm/tokens/definitions/usde.js.map +1 -0
  235. package/_esm/tokens/definitions/usdt0.js +12 -0
  236. package/_esm/tokens/definitions/usdt0.js.map +1 -0
  237. package/_esm/tokens/definitions/wsrusd.js +12 -0
  238. package/_esm/tokens/definitions/wsrusd.js.map +1 -0
  239. package/_esm/tokens/index.js +32 -0
  240. package/_esm/tokens/index.js.map +1 -0
  241. package/_esm/utils/encoding/fromRlp.js +8 -5
  242. package/_esm/utils/encoding/fromRlp.js.map +1 -1
  243. package/_esm/utils/rpc/http.js +59 -4
  244. package/_esm/utils/rpc/http.js.map +1 -1
  245. package/_esm/utils/transaction/parseTransaction.js +5 -2
  246. package/_esm/utils/transaction/parseTransaction.js.map +1 -1
  247. package/_types/actions/index.d.ts +1 -0
  248. package/_types/actions/index.d.ts.map +1 -1
  249. package/_types/actions/token/approve.d.ts +253 -0
  250. package/_types/actions/token/approve.d.ts.map +1 -0
  251. package/_types/actions/token/approveSync.d.ts +57 -0
  252. package/_types/actions/token/approveSync.d.ts.map +1 -0
  253. package/_types/actions/token/getAllowance.d.ts +77 -0
  254. package/_types/actions/token/getAllowance.d.ts.map +1 -0
  255. package/_types/actions/token/getBalance.d.ts +69 -0
  256. package/_types/actions/token/getBalance.d.ts.map +1 -0
  257. package/_types/actions/token/getMetadata.d.ts +43 -0
  258. package/_types/actions/token/getMetadata.d.ts.map +1 -0
  259. package/_types/actions/token/getTotalSupply.d.ts +63 -0
  260. package/_types/actions/token/getTotalSupply.d.ts.map +1 -0
  261. package/_types/actions/token/index.d.ts +9 -0
  262. package/_types/actions/token/index.d.ts.map +1 -0
  263. package/_types/actions/token/internal.d.ts +168 -0
  264. package/_types/actions/token/internal.d.ts.map +1 -0
  265. package/_types/actions/token/transfer.d.ts +288 -0
  266. package/_types/actions/token/transfer.d.ts.map +1 -0
  267. package/_types/actions/token/transferSync.d.ts +61 -0
  268. package/_types/actions/token/transferSync.d.ts.map +1 -0
  269. package/_types/chains/definitions/battlechain.d.ts +447 -0
  270. package/_types/chains/definitions/battlechain.d.ts.map +1 -0
  271. package/_types/chains/definitions/marooTestnet.d.ts +49 -0
  272. package/_types/chains/definitions/marooTestnet.d.ts.map +1 -0
  273. package/_types/chains/index.d.ts +2 -0
  274. package/_types/chains/index.d.ts.map +1 -1
  275. package/_types/clients/createClient.d.ts +24 -6
  276. package/_types/clients/createClient.d.ts.map +1 -1
  277. package/_types/clients/createPublicClient.d.ts +4 -3
  278. package/_types/clients/createPublicClient.d.ts.map +1 -1
  279. package/_types/clients/createWalletClient.d.ts +4 -3
  280. package/_types/clients/createWalletClient.d.ts.map +1 -1
  281. package/_types/clients/decorators/public.d.ts +128 -3
  282. package/_types/clients/decorators/public.d.ts.map +1 -1
  283. package/_types/clients/decorators/wallet.d.ts +208 -3
  284. package/_types/clients/decorators/wallet.d.ts.map +1 -1
  285. package/_types/clients/transports/http.d.ts +2 -0
  286. package/_types/clients/transports/http.d.ts.map +1 -1
  287. package/_types/errors/encoding.d.ts +8 -0
  288. package/_types/errors/encoding.d.ts.map +1 -1
  289. package/_types/errors/request.d.ts +11 -0
  290. package/_types/errors/request.d.ts.map +1 -1
  291. package/_types/errors/transaction.d.ts +8 -0
  292. package/_types/errors/transaction.d.ts.map +1 -1
  293. package/_types/errors/version.d.ts +1 -1
  294. package/_types/index.d.ts +4 -3
  295. package/_types/index.d.ts.map +1 -1
  296. package/_types/tempo/Client.d.ts +1 -1
  297. package/_types/tempo/Client.d.ts.map +1 -1
  298. package/_types/tempo/Decorator.d.ts +88 -5
  299. package/_types/tempo/Decorator.d.ts.map +1 -1
  300. package/_types/tempo/actions/token.d.ts +223 -151
  301. package/_types/tempo/actions/token.d.ts.map +1 -1
  302. package/_types/tempo/actions/wallet.d.ts +3 -3
  303. package/_types/tempo/internal/types.d.ts +17 -0
  304. package/_types/tempo/internal/types.d.ts.map +1 -1
  305. package/_types/tempo/internal/utils.d.ts +73 -0
  306. package/_types/tempo/internal/utils.d.ts.map +1 -1
  307. package/_types/tokens/defineToken.d.ts +112 -0
  308. package/_types/tokens/defineToken.d.ts.map +1 -0
  309. package/_types/tokens/definitions/alphausd.d.ts +11 -0
  310. package/_types/tokens/definitions/alphausd.d.ts.map +1 -0
  311. package/_types/tokens/definitions/betausd.d.ts +11 -0
  312. package/_types/tokens/definitions/betausd.d.ts.map +1 -0
  313. package/_types/tokens/definitions/brla.d.ts +11 -0
  314. package/_types/tokens/definitions/brla.d.ts.map +1 -0
  315. package/_types/tokens/definitions/cbbtc.d.ts +11 -0
  316. package/_types/tokens/definitions/cbbtc.d.ts.map +1 -0
  317. package/_types/tokens/definitions/chfau.d.ts +11 -0
  318. package/_types/tokens/definitions/chfau.d.ts.map +1 -0
  319. package/_types/tokens/definitions/cusd.d.ts +11 -0
  320. package/_types/tokens/definitions/cusd.d.ts.map +1 -0
  321. package/_types/tokens/definitions/dlusd.d.ts +11 -0
  322. package/_types/tokens/definitions/dlusd.d.ts.map +1 -0
  323. package/_types/tokens/definitions/eurau.d.ts +11 -0
  324. package/_types/tokens/definitions/eurau.d.ts.map +1 -0
  325. package/_types/tokens/definitions/eurce.d.ts +12 -0
  326. package/_types/tokens/definitions/eurce.d.ts.map +1 -0
  327. package/_types/tokens/definitions/frxusd.d.ts +11 -0
  328. package/_types/tokens/definitions/frxusd.d.ts.map +1 -0
  329. package/_types/tokens/definitions/gbpa.d.ts +11 -0
  330. package/_types/tokens/definitions/gbpa.d.ts.map +1 -0
  331. package/_types/tokens/definitions/gusd.d.ts +11 -0
  332. package/_types/tokens/definitions/gusd.d.ts.map +1 -0
  333. package/_types/tokens/definitions/iusd.d.ts +11 -0
  334. package/_types/tokens/definitions/iusd.d.ts.map +1 -0
  335. package/_types/tokens/definitions/pathusd.d.ts +12 -0
  336. package/_types/tokens/definitions/pathusd.d.ts.map +1 -0
  337. package/_types/tokens/definitions/reusd.d.ts +11 -0
  338. package/_types/tokens/definitions/reusd.d.ts.map +1 -0
  339. package/_types/tokens/definitions/rusd.d.ts +11 -0
  340. package/_types/tokens/definitions/rusd.d.ts.map +1 -0
  341. package/_types/tokens/definitions/sbc.d.ts +11 -0
  342. package/_types/tokens/definitions/sbc.d.ts.map +1 -0
  343. package/_types/tokens/definitions/siusd.d.ts +11 -0
  344. package/_types/tokens/definitions/siusd.d.ts.map +1 -0
  345. package/_types/tokens/definitions/stcusd.d.ts +11 -0
  346. package/_types/tokens/definitions/stcusd.d.ts.map +1 -0
  347. package/_types/tokens/definitions/susde.d.ts +11 -0
  348. package/_types/tokens/definitions/susde.d.ts.map +1 -0
  349. package/_types/tokens/definitions/syrupusdc.d.ts +11 -0
  350. package/_types/tokens/definitions/syrupusdc.d.ts.map +1 -0
  351. package/_types/tokens/definitions/thetausd.d.ts +11 -0
  352. package/_types/tokens/definitions/thetausd.d.ts.map +1 -0
  353. package/_types/tokens/definitions/usd1.d.ts +11 -0
  354. package/_types/tokens/definitions/usd1.d.ts.map +1 -0
  355. package/_types/tokens/definitions/usdb.d.ts +11 -0
  356. package/_types/tokens/definitions/usdb.d.ts.map +1 -0
  357. package/_types/tokens/definitions/usdc.d.ts +67 -0
  358. package/_types/tokens/definitions/usdc.d.ts.map +1 -0
  359. package/_types/tokens/definitions/usdce.d.ts +12 -0
  360. package/_types/tokens/definitions/usdce.d.ts.map +1 -0
  361. package/_types/tokens/definitions/usde.d.ts +11 -0
  362. package/_types/tokens/definitions/usde.d.ts.map +1 -0
  363. package/_types/tokens/definitions/usdt0.d.ts +11 -0
  364. package/_types/tokens/definitions/usdt0.d.ts.map +1 -0
  365. package/_types/tokens/definitions/wsrusd.d.ts +11 -0
  366. package/_types/tokens/definitions/wsrusd.d.ts.map +1 -0
  367. package/_types/tokens/index.d.ts +31 -0
  368. package/_types/tokens/index.d.ts.map +1 -0
  369. package/_types/utils/encoding/fromRlp.d.ts +2 -2
  370. package/_types/utils/encoding/fromRlp.d.ts.map +1 -1
  371. package/_types/utils/rpc/http.d.ts +6 -2
  372. package/_types/utils/rpc/http.d.ts.map +1 -1
  373. package/_types/utils/transaction/parseTransaction.d.ts +2 -2
  374. package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
  375. package/actions/index.ts +1 -0
  376. package/actions/token/approve.ts +202 -0
  377. package/actions/token/approveSync.ts +95 -0
  378. package/actions/token/getAllowance.ts +105 -0
  379. package/actions/token/getBalance.ts +115 -0
  380. package/actions/token/getMetadata.ts +98 -0
  381. package/actions/token/getTotalSupply.ts +97 -0
  382. package/actions/token/index.ts +9 -0
  383. package/actions/token/internal.ts +367 -0
  384. package/actions/token/transfer.ts +230 -0
  385. package/actions/token/transferSync.ts +99 -0
  386. package/chains/definitions/battlechain.ts +28 -0
  387. package/chains/definitions/marooTestnet.ts +27 -0
  388. package/chains/index.ts +2 -0
  389. package/clients/createClient.ts +90 -8
  390. package/clients/createPublicClient.ts +22 -4
  391. package/clients/createWalletClient.ts +22 -4
  392. package/clients/decorators/public.ts +166 -4
  393. package/clients/decorators/wallet.ts +242 -3
  394. package/clients/transports/http.ts +4 -0
  395. package/errors/encoding.ts +11 -0
  396. package/errors/request.ts +17 -0
  397. package/errors/transaction.ts +11 -0
  398. package/errors/version.ts +1 -1
  399. package/index.ts +7 -0
  400. package/package.json +6 -1
  401. package/tempo/Client.ts +4 -2
  402. package/tempo/Decorator.ts +398 -337
  403. package/tempo/actions/token.ts +519 -296
  404. package/tempo/actions/wallet.ts +3 -3
  405. package/tempo/internal/types.ts +19 -0
  406. package/tempo/internal/utils.ts +204 -0
  407. package/tokens/defineToken.ts +142 -0
  408. package/tokens/definitions/alphausd.ts +13 -0
  409. package/tokens/definitions/betausd.ts +13 -0
  410. package/tokens/definitions/brla.ts +13 -0
  411. package/tokens/definitions/cbbtc.ts +13 -0
  412. package/tokens/definitions/chfau.ts +13 -0
  413. package/tokens/definitions/cusd.ts +13 -0
  414. package/tokens/definitions/dlusd.ts +13 -0
  415. package/tokens/definitions/eurau.ts +13 -0
  416. package/tokens/definitions/eurce.ts +14 -0
  417. package/tokens/definitions/frxusd.ts +13 -0
  418. package/tokens/definitions/gbpa.ts +13 -0
  419. package/tokens/definitions/gusd.ts +13 -0
  420. package/tokens/definitions/iusd.ts +13 -0
  421. package/tokens/definitions/pathusd.ts +14 -0
  422. package/tokens/definitions/reusd.ts +13 -0
  423. package/tokens/definitions/rusd.ts +13 -0
  424. package/tokens/definitions/sbc.ts +13 -0
  425. package/tokens/definitions/siusd.ts +13 -0
  426. package/tokens/definitions/stcusd.ts +13 -0
  427. package/tokens/definitions/susde.ts +13 -0
  428. package/tokens/definitions/syrupusdc.ts +13 -0
  429. package/tokens/definitions/thetausd.ts +13 -0
  430. package/tokens/definitions/usd1.ts +13 -0
  431. package/tokens/definitions/usdb.ts +13 -0
  432. package/tokens/definitions/usdc.ts +67 -0
  433. package/tokens/definitions/usdce.ts +14 -0
  434. package/tokens/definitions/usde.ts +13 -0
  435. package/tokens/definitions/usdt0.ts +13 -0
  436. package/tokens/definitions/wsrusd.ts +13 -0
  437. package/tokens/index.ts +31 -0
  438. package/tokens/package.json +6 -0
  439. package/utils/encoding/fromRlp.ts +22 -3
  440. package/utils/rpc/http.ts +70 -2
  441. package/utils/transaction/parseTransaction.ts +7 -2
@@ -1,18 +1,23 @@
1
1
  import * as Hex from 'ox/Hex';
2
2
  import { TokenId, TokenRole } from 'ox/tempo';
3
3
  import { parseAccount } from '../../accounts/utils/parseAccount.js';
4
+ import { estimateContractGas } from '../../actions/public/estimateContractGas.js';
4
5
  import { multicall } from '../../actions/public/multicall.js';
5
6
  import { readContract } from '../../actions/public/readContract.js';
7
+ import { simulateContract, } from '../../actions/public/simulateContract.js';
6
8
  import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
9
+ import * as internal_Token from '../../actions/token/internal.js';
7
10
  import { sendTransaction } from '../../actions/wallet/sendTransaction.js';
8
11
  import { sendTransactionSync, } from '../../actions/wallet/sendTransactionSync.js';
9
12
  import { writeContract } from '../../actions/wallet/writeContract.js';
10
13
  import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
14
+ import { AccountNotFoundError } from '../../errors/account.js';
11
15
  import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js';
12
16
  import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
17
+ import { formatUnits } from '../../utils/unit/formatUnits.js';
13
18
  import * as Abis from '../Abis.js';
14
19
  import * as Addresses from '../Addresses.js';
15
- import { defineCall } from '../internal/utils.js';
20
+ import { defineCall, findDeclaredToken, pickWriteParameters, resolveToken, resolveTokenWithDecimals, } from '../internal/utils.js';
16
21
  /**
17
22
  * Approves a spender to transfer TIP20 tokens on behalf of the caller.
18
23
  *
@@ -40,62 +45,77 @@ import { defineCall } from '../internal/utils.js';
40
45
  * @returns The transaction hash.
41
46
  */
42
47
  export async function approve(client, parameters) {
43
- const { token, ...rest } = parameters;
44
- return approve.inner(writeContract, client, parameters, { ...rest, token });
48
+ return approve.inner(writeContract, client, parameters);
45
49
  }
46
50
  (function (approve) {
47
51
  /** @internal */
48
- async function inner(action, client, parameters, args) {
49
- const call = approve.call(args);
52
+ async function inner(action, client, parameters) {
50
53
  return (await action(client, {
51
54
  ...parameters,
52
- ...call,
55
+ ...approve.call(client, parameters),
53
56
  }));
54
57
  }
55
58
  approve.inner = inner;
56
59
  /**
57
60
  * Defines a call to the `approve` function.
58
61
  *
59
- * Can be passed as a parameter to:
60
- * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
61
- * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
62
- * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
63
- *
64
- * @example
65
- * ```ts
66
- * import { createClient, http, walletActions } from 'viem'
67
- * import { tempo } from 'viem/chains'
68
- * import { Actions } from 'viem/tempo'
69
- *
70
- * const client = createClient({
71
- * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
72
- * transport: http(),
73
- * }).extend(walletActions)
74
- *
75
- * const { result } = await client.sendCalls({
76
- * calls: [
77
- * actions.token.approve.call({
78
- * spender: '0x20c0...beef',
79
- * amount: 100n,
80
- * token: '0x20c0...babe',
81
- * }),
82
- * ]
83
- * })
84
- * ```
62
+ * Can be passed as a parameter to `estimateContractGas`, `simulateContract`,
63
+ * `sendCalls`, `sendTransaction` (`calls`), or `multicall`. The token is
64
+ * selected by `token`, which is either a TIP20 token id or a contract
65
+ * `address`; `amount.decimals` is inferred from the client's declared
66
+ * `tokens` when omitted.
85
67
  *
86
- * @param args - Arguments.
68
+ * @param client - Client.
69
+ * @param parameters - Parameters.
87
70
  * @returns The call.
88
71
  */
89
- function call(args) {
90
- const { spender, amount, token } = args;
72
+ function call(client, parameters) {
73
+ const { amount, spender, token } = parameters;
74
+ const { address, decimals } = resolveToken(client, { token });
91
75
  return defineCall({
92
- address: TokenId.toAddress(token),
76
+ address,
93
77
  abi: Abis.tip20,
94
78
  functionName: 'approve',
95
- args: [spender, amount],
79
+ args: [spender, internal_Token.toBaseUnits(amount, decimals)],
96
80
  });
97
81
  }
98
82
  approve.call = call;
83
+ /**
84
+ * Estimates the gas required to approve a spender. `amount.decimals` is
85
+ * inferred from the client's declared `tokens` when omitted.
86
+ *
87
+ * @param client - Client.
88
+ * @param parameters - Parameters.
89
+ * @returns The gas estimate.
90
+ */
91
+ async function estimateGas(client, parameters) {
92
+ return estimateContractGas(client, {
93
+ ...pickWriteParameters(parameters),
94
+ ...approve.call(client, parameters),
95
+ });
96
+ }
97
+ approve.estimateGas = estimateGas;
98
+ /**
99
+ * Simulates an approval of a spender. `amount.decimals` is inferred from
100
+ * the client's declared `tokens` when omitted.
101
+ *
102
+ * @param client - Client.
103
+ * @param parameters - Parameters.
104
+ * @returns The simulation result and write request.
105
+ */
106
+ async function simulate(client, parameters) {
107
+ return simulateContract(client, {
108
+ ...pickWriteParameters(parameters),
109
+ ...approve.call(client, parameters),
110
+ });
111
+ }
112
+ approve.simulate = simulate;
113
+ /**
114
+ * Extracts the `Approval` event from logs.
115
+ *
116
+ * @param logs - The logs.
117
+ * @returns The `Approval` event.
118
+ */
99
119
  function extractEvent(logs) {
100
120
  const [log] = parseEventLogs({
101
121
  abi: Abis.tip20,
@@ -135,11 +155,19 @@ export async function approve(client, parameters) {
135
155
  * @returns The transaction receipt and event data.
136
156
  */
137
157
  export async function approveSync(client, parameters) {
138
- const { throwOnReceiptRevert = true, ...rest } = parameters;
139
- const receipt = await approve.inner(writeContractSync, client, { ...parameters, throwOnReceiptRevert }, rest);
158
+ const { amount, token, throwOnReceiptRevert = true } = parameters;
159
+ const { decimals } = resolveToken(client, { token });
160
+ const resolved = internal_Token.resolveAmountDecimals(amount, decimals);
161
+ const receipt = await approve.inner(writeContractSync, client, {
162
+ ...parameters,
163
+ throwOnReceiptRevert,
164
+ });
140
165
  const { args } = approve.extractEvent(receipt.logs);
141
166
  return {
142
167
  ...args,
168
+ ...(resolved === undefined
169
+ ? {}
170
+ : { decimals: resolved, formatted: formatUnits(args.amount, resolved) }),
143
171
  receipt,
144
172
  };
145
173
  }
@@ -177,7 +205,7 @@ export async function burnBlocked(client, parameters) {
177
205
  /** @internal */
178
206
  async function inner(action, client, parameters) {
179
207
  const { amount, from, token, ...rest } = parameters;
180
- const call = burnBlocked.call({ amount, from, token });
208
+ const call = burnBlocked.call(client, { amount, from, token });
181
209
  return (await action(client, {
182
210
  ...rest,
183
211
  ...call,
@@ -205,7 +233,7 @@ export async function burnBlocked(client, parameters) {
205
233
  *
206
234
  * const { result } = await client.sendCalls({
207
235
  * calls: [
208
- * actions.token.burnBlocked.call({
236
+ * actions.token.burnBlocked.call(client, {
209
237
  * from: '0x20c0...beef',
210
238
  * amount: 100n,
211
239
  * token: '0x20c0...babe',
@@ -214,16 +242,19 @@ export async function burnBlocked(client, parameters) {
214
242
  * })
215
243
  * ```
216
244
  *
245
+ * `amount.decimals` is inferred from the client's declared `tokens` when omitted.
246
+ *
217
247
  * @param args - Arguments.
218
248
  * @returns The call.
219
249
  */
220
- function call(args) {
250
+ function call(client, args) {
221
251
  const { from, amount, token } = args;
252
+ const { address, decimals } = resolveToken(client, { token });
222
253
  return defineCall({
223
- address: TokenId.toAddress(token),
254
+ address,
224
255
  abi: Abis.tip20,
225
256
  functionName: 'burnBlocked',
226
- args: [from, amount],
257
+ args: [from, internal_Token.toBaseUnits(amount, decimals)],
227
258
  });
228
259
  }
229
260
  burnBlocked.call = call;
@@ -317,7 +348,7 @@ export async function burn(client, parameters) {
317
348
  /** @internal */
318
349
  async function inner(action, client, parameters) {
319
350
  const { amount, memo, token, ...rest } = parameters;
320
- const call = burn.call({ amount, memo, token });
351
+ const call = burn.call(client, { amount, memo, token });
321
352
  return (await action(client, {
322
353
  ...rest,
323
354
  ...call,
@@ -345,7 +376,7 @@ export async function burn(client, parameters) {
345
376
  *
346
377
  * const { result } = await client.sendCalls({
347
378
  * calls: [
348
- * actions.token.burn.call({
379
+ * actions.token.burn.call(client, {
349
380
  * amount: 100n,
350
381
  * token: '0x20c0...babe',
351
382
  * }),
@@ -353,22 +384,26 @@ export async function burn(client, parameters) {
353
384
  * })
354
385
  * ```
355
386
  *
387
+ * `amount.decimals` is inferred from the client's declared `tokens` when omitted.
388
+ *
356
389
  * @param args - Arguments.
357
390
  * @returns The call.
358
391
  */
359
- function call(args) {
392
+ function call(client, args) {
360
393
  const { amount, memo, token } = args;
394
+ const { address, decimals } = resolveToken(client, { token });
395
+ const value = internal_Token.toBaseUnits(amount, decimals);
361
396
  const callArgs = memo
362
397
  ? {
363
398
  functionName: 'burnWithMemo',
364
- args: [amount, Hex.padLeft(memo, 32)],
399
+ args: [value, Hex.padLeft(memo, 32)],
365
400
  }
366
401
  : {
367
402
  functionName: 'burn',
368
- args: [amount],
403
+ args: [value],
369
404
  };
370
405
  return defineCall({
371
- address: TokenId.toAddress(token),
406
+ address,
372
407
  abi: Abis.tip20,
373
408
  ...callArgs,
374
409
  });
@@ -463,7 +498,7 @@ export async function changeTransferPolicy(client, parameters) {
463
498
  /** @internal */
464
499
  async function inner(action, client, parameters) {
465
500
  const { policyId, token, ...rest } = parameters;
466
- const call = changeTransferPolicy.call({ policyId, token });
501
+ const call = changeTransferPolicy.call(client, { policyId, token });
467
502
  return (await action(client, {
468
503
  ...rest,
469
504
  ...call,
@@ -491,7 +526,7 @@ export async function changeTransferPolicy(client, parameters) {
491
526
  *
492
527
  * const { result } = await client.sendCalls({
493
528
  * calls: [
494
- * actions.token.changeTransferPolicy.call({
529
+ * actions.token.changeTransferPolicy.call(client, {
495
530
  * token: '0x20c0...babe',
496
531
  * policyId: 1n,
497
532
  * }),
@@ -502,10 +537,10 @@ export async function changeTransferPolicy(client, parameters) {
502
537
  * @param args - Arguments.
503
538
  * @returns The call.
504
539
  */
505
- function call(args) {
540
+ function call(client, args) {
506
541
  const { token, policyId } = args;
507
542
  return defineCall({
508
- address: TokenId.toAddress(token),
543
+ address: resolveToken(client, { token }).address,
509
544
  abi: Abis.tip20,
510
545
  functionName: 'changeTransferPolicyId',
511
546
  args: [policyId],
@@ -606,7 +641,7 @@ export async function create(client, parameters) {
606
641
  const admin = admin_ ? parseAccount(admin_) : undefined;
607
642
  if (!admin)
608
643
  throw new Error('admin is required.');
609
- const call = create.call({ ...rest, admin: admin.address });
644
+ const call = create.call(client, { ...rest, admin: admin.address });
610
645
  return (await action(client, {
611
646
  ...parameters,
612
647
  account,
@@ -636,7 +671,7 @@ export async function create(client, parameters) {
636
671
  *
637
672
  * const { result } = await client.sendCalls({
638
673
  * calls: [
639
- * actions.token.create.call({
674
+ * actions.token.create.call(client, {
640
675
  * name: 'My Token',
641
676
  * symbol: 'MTK',
642
677
  * currency: 'USD',
@@ -650,7 +685,7 @@ export async function create(client, parameters) {
650
685
  * @param args - Arguments.
651
686
  * @returns The call.
652
687
  */
653
- function call(args) {
688
+ function call(client, args) {
654
689
  const { name, symbol, currency, logoURI, quoteToken = Addresses.pathUsd, admin, salt = Hex.random(32), } = args;
655
690
  return defineCall({
656
691
  address: Addresses.tip20Factory,
@@ -660,7 +695,7 @@ export async function create(client, parameters) {
660
695
  name,
661
696
  symbol,
662
697
  currency,
663
- TokenId.toAddress(quoteToken),
698
+ resolveToken(client, { token: quoteToken }).address,
664
699
  admin,
665
700
  salt,
666
701
  logoURI,
@@ -669,7 +704,7 @@ export async function create(client, parameters) {
669
704
  name,
670
705
  symbol,
671
706
  currency,
672
- TokenId.toAddress(quoteToken),
707
+ resolveToken(client, { token: quoteToken }).address,
673
708
  admin,
674
709
  salt,
675
710
  ],
@@ -755,38 +790,48 @@ export async function createSync(client, parameters) {
755
790
  * })
756
791
  *
757
792
  * const allowance = await Actions.token.getAllowance(client, {
793
+ * account: '0x...',
758
794
  * spender: '0x...',
795
+ * token: '0x...',
759
796
  * })
760
797
  * ```
761
798
  *
762
799
  * @param client - Client.
763
800
  * @param parameters - Parameters.
764
- * @returns The token allowance.
801
+ * @returns The token allowance, in base units and human-readable form.
765
802
  */
766
803
  export async function getAllowance(client, parameters) {
767
- const { account = client.account } = parameters;
768
- const address = account ? parseAccount(account).address : undefined;
769
- if (!address)
770
- throw new Error('account is required.');
771
- return readContract(client, {
772
- ...parameters,
773
- ...getAllowance.call({ ...parameters, account: address }),
774
- });
804
+ const { account, decimals, spender, token, ...rest } = parameters;
805
+ const [amount, { decimals: resolved }] = await Promise.all([
806
+ readContract(client, {
807
+ ...rest,
808
+ ...getAllowance.call(client, { account, spender, token }),
809
+ }),
810
+ resolveTokenWithDecimals(client, {
811
+ decimals,
812
+ token,
813
+ }),
814
+ ]);
815
+ return internal_Token.toAmount(amount, resolved);
775
816
  }
776
817
  (function (getAllowance) {
777
818
  /**
778
819
  * Defines a call to the `allowance` function.
779
820
  *
821
+ * Can be passed as a parameter to `multicall`, `simulateContract`, or any
822
+ * other action that accepts a contract call. The token is selected by `token`,
823
+ * which is either a TIP20 token id or a contract address.
824
+ *
825
+ * @param client - Client.
780
826
  * @param args - Arguments.
781
827
  * @returns The call.
782
828
  */
783
- function call(args) {
784
- const { account, spender, token } = args;
829
+ function call(client, args) {
785
830
  return defineCall({
786
- address: TokenId.toAddress(token),
831
+ address: resolveToken(client, args).address,
787
832
  abi: Abis.tip20,
788
833
  functionName: 'allowance',
789
- args: [account, spender],
834
+ args: [args.account, args.spender],
790
835
  });
791
836
  }
792
837
  getAllowance.call = call;
@@ -808,35 +853,51 @@ export async function getAllowance(client, parameters) {
808
853
  * })
809
854
  *
810
855
  * const balance = await Actions.token.getBalance(client, {
856
+ * account: '0x...',
811
857
  * token: '0x...',
812
858
  * })
813
859
  * ```
814
860
  *
815
861
  * @param client - Client.
816
862
  * @param parameters - Parameters.
817
- * @returns The token balance.
863
+ * @returns The token balance, in base units and human-readable form.
818
864
  */
819
865
  export async function getBalance(client, parameters) {
820
- const { account = client.account, ...rest } = parameters;
821
- const address = account ? parseAccount(account).address : undefined;
822
- if (!address)
823
- throw new Error('account is required.');
824
- return readContract(client, {
825
- ...rest,
826
- ...getBalance.call({ account: address, ...rest }),
827
- });
866
+ const { account: account_ = client.account, decimals, token, ...rest } = parameters;
867
+ if (!account_)
868
+ throw new AccountNotFoundError();
869
+ const account = parseAccount(account_).address;
870
+ const [amount, { decimals: resolved }] = await Promise.all([
871
+ readContract(client, {
872
+ ...rest,
873
+ ...getBalance.call(client, { account, token }),
874
+ }),
875
+ resolveTokenWithDecimals(client, {
876
+ decimals,
877
+ token,
878
+ }),
879
+ ]);
880
+ return internal_Token.toAmount(amount, resolved);
828
881
  }
829
882
  (function (getBalance) {
830
883
  /**
831
884
  * Defines a call to the `balanceOf` function.
832
885
  *
886
+ * Can be passed as a parameter to `multicall`, `simulateContract`, or any
887
+ * other action that accepts a contract call. The token is selected by `token`,
888
+ * which is either a TIP20 token id or a contract address.
889
+ *
890
+ * @param client - Client.
833
891
  * @param args - Arguments.
834
892
  * @returns The call.
835
893
  */
836
- function call(args) {
837
- const { account, token } = args;
894
+ function call(client, args) {
895
+ const account_ = args.account ?? client.account;
896
+ if (!account_)
897
+ throw new AccountNotFoundError();
898
+ const account = parseAccount(account_).address;
838
899
  return defineCall({
839
- address: TokenId.toAddress(token),
900
+ address: resolveToken(client, args).address,
840
901
  abi: Abis.tip20,
841
902
  functionName: 'balanceOf',
842
903
  args: [account],
@@ -871,9 +932,15 @@ export async function getBalance(client, parameters) {
871
932
  */
872
933
  export async function getMetadata(client, parameters) {
873
934
  const { token, ...rest } = parameters;
874
- const address = TokenId.toAddress(token);
935
+ const { address } = resolveToken(client, { token });
875
936
  const abi = Abis.tip20;
876
- if (TokenId.from(token) === TokenId.fromAddress(Addresses.pathUsd))
937
+ const declared = findDeclaredToken(client, token);
938
+ const overrides = {
939
+ ...(declared?.decimals != null ? { decimals: declared.decimals } : {}),
940
+ ...(declared?.name != null ? { name: declared.name } : {}),
941
+ ...(declared?.symbol != null ? { symbol: declared.symbol } : {}),
942
+ };
943
+ if (TokenId.fromAddress(address) === TokenId.fromAddress(Addresses.pathUsd))
877
944
  return multicall(client, {
878
945
  ...rest,
879
946
  contracts: [
@@ -917,6 +984,7 @@ export async function getMetadata(client, parameters) {
917
984
  decimals: unwrapMulticallResult(decimals),
918
985
  logoURI: unwrapMulticallResult(logoURI, ''),
919
986
  totalSupply: unwrapMulticallResult(totalSupply),
987
+ ...overrides,
920
988
  }));
921
989
  return multicall(client, {
922
990
  ...rest,
@@ -985,6 +1053,7 @@ export async function getMetadata(client, parameters) {
985
1053
  paused: unwrapMulticallResult(paused),
986
1054
  supplyCap: unwrapMulticallResult(supplyCap),
987
1055
  transferPolicyId: unwrapMulticallResult(transferPolicyId),
1056
+ ...overrides,
988
1057
  }));
989
1058
  }
990
1059
  function unwrapMulticallResult(response, ...fallback) {
@@ -995,6 +1064,65 @@ function unwrapMulticallResult(response, ...fallback) {
995
1064
  }
996
1065
  return response.result;
997
1066
  }
1067
+ /**
1068
+ * Gets the total supply of a TIP20 token.
1069
+ *
1070
+ * @example
1071
+ * ```ts
1072
+ * import { createClient, http } from 'viem'
1073
+ * import { tempo } from 'viem/chains'
1074
+ * import { Actions } from 'viem/tempo'
1075
+ *
1076
+ * const client = createClient({
1077
+ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
1078
+ * transport: http(),
1079
+ * })
1080
+ *
1081
+ * const totalSupply = await Actions.token.getTotalSupply(client, {
1082
+ * token: '0x...',
1083
+ * })
1084
+ * ```
1085
+ *
1086
+ * @param client - Client.
1087
+ * @param parameters - Parameters.
1088
+ * @returns The token total supply, in base units and human-readable form.
1089
+ */
1090
+ export async function getTotalSupply(client, parameters) {
1091
+ const { decimals, token, ...rest } = parameters;
1092
+ const [amount, { decimals: resolved }] = await Promise.all([
1093
+ readContract(client, {
1094
+ ...rest,
1095
+ ...getTotalSupply.call(client, { token }),
1096
+ }),
1097
+ resolveTokenWithDecimals(client, {
1098
+ decimals,
1099
+ token,
1100
+ }),
1101
+ ]);
1102
+ return internal_Token.toAmount(amount, resolved);
1103
+ }
1104
+ (function (getTotalSupply) {
1105
+ /**
1106
+ * Defines a call to the `totalSupply` function.
1107
+ *
1108
+ * Can be passed as a parameter to `multicall`, `simulateContract`, or any
1109
+ * other action that accepts a contract call. The token is selected by `token`,
1110
+ * which is either a TIP20 token id or a contract address.
1111
+ *
1112
+ * @param client - Client.
1113
+ * @param args - Arguments.
1114
+ * @returns The call.
1115
+ */
1116
+ function call(client, args) {
1117
+ return defineCall({
1118
+ address: resolveToken(client, args).address,
1119
+ abi: Abis.tip20,
1120
+ args: [],
1121
+ functionName: 'totalSupply',
1122
+ });
1123
+ }
1124
+ getTotalSupply.call = call;
1125
+ })(getTotalSupply || (getTotalSupply = {}));
998
1126
  /**
999
1127
  * Gets the admin role for a specific role in a TIP20 token.
1000
1128
  *
@@ -1022,7 +1150,7 @@ function unwrapMulticallResult(response, ...fallback) {
1022
1150
  export async function getRoleAdmin(client, parameters) {
1023
1151
  return readContract(client, {
1024
1152
  ...parameters,
1025
- ...getRoleAdmin.call(parameters),
1153
+ ...getRoleAdmin.call(client, parameters),
1026
1154
  });
1027
1155
  }
1028
1156
  (function (getRoleAdmin) {
@@ -1032,10 +1160,10 @@ export async function getRoleAdmin(client, parameters) {
1032
1160
  * @param args - Arguments.
1033
1161
  * @returns The call.
1034
1162
  */
1035
- function call(args) {
1163
+ function call(client, args) {
1036
1164
  const { role, token } = args;
1037
1165
  return defineCall({
1038
- address: TokenId.toAddress(token),
1166
+ address: resolveToken(client, { token }).address,
1039
1167
  abi: Abis.tip20,
1040
1168
  functionName: 'getRoleAdmin',
1041
1169
  args: [TokenRole.serialize(role)],
@@ -1075,7 +1203,7 @@ export async function hasRole(client, parameters) {
1075
1203
  throw new Error('account is required.');
1076
1204
  return readContract(client, {
1077
1205
  ...parameters,
1078
- ...hasRole.call({ ...parameters, account: address }),
1206
+ ...hasRole.call(client, { ...parameters, account: address }),
1079
1207
  });
1080
1208
  }
1081
1209
  (function (hasRole) {
@@ -1085,10 +1213,10 @@ export async function hasRole(client, parameters) {
1085
1213
  * @param args - Arguments.
1086
1214
  * @returns The call.
1087
1215
  */
1088
- function call(args) {
1216
+ function call(client, args) {
1089
1217
  const { account, role, token } = args;
1090
1218
  return defineCall({
1091
- address: TokenId.toAddress(token),
1219
+ address: resolveToken(client, { token }).address,
1092
1220
  abi: Abis.tip20,
1093
1221
  functionName: 'hasRole',
1094
1222
  args: [account, TokenRole.serialize(role)],
@@ -1132,7 +1260,7 @@ export async function grantRoles(client, parameters) {
1132
1260
  return (await action(client, {
1133
1261
  ...parameters,
1134
1262
  calls: parameters.roles.map((role) => {
1135
- const call = grantRoles.call({ ...parameters, role });
1263
+ const call = grantRoles.call(client, { ...parameters, role });
1136
1264
  return {
1137
1265
  ...call,
1138
1266
  data: encodeFunctionData(call),
@@ -1162,7 +1290,7 @@ export async function grantRoles(client, parameters) {
1162
1290
  *
1163
1291
  * const { result } = await client.sendCalls({
1164
1292
  * calls: [
1165
- * actions.token.grantRoles.call({
1293
+ * actions.token.grantRoles.call(client, {
1166
1294
  * token: '0x20c0...babe',
1167
1295
  * to: '0x20c0...beef',
1168
1296
  * role: 'issuer',
@@ -1174,11 +1302,11 @@ export async function grantRoles(client, parameters) {
1174
1302
  * @param args - Arguments.
1175
1303
  * @returns The call.
1176
1304
  */
1177
- function call(args) {
1305
+ function call(client, args) {
1178
1306
  const { token, to, role } = args;
1179
1307
  const roleHash = TokenRole.serialize(role);
1180
1308
  return defineCall({
1181
- address: TokenId.toAddress(token),
1309
+ address: resolveToken(client, { token }).address,
1182
1310
  abi: Abis.tip20,
1183
1311
  functionName: 'grantRole',
1184
1312
  args: [roleHash, to],
@@ -1276,9 +1404,10 @@ export async function mint(client, parameters) {
1276
1404
  (function (mint) {
1277
1405
  /** @internal */
1278
1406
  async function inner(action, client, parameters) {
1279
- const call = mint.call(parameters);
1407
+ const { amount, memo, to, token, ...rest } = parameters;
1408
+ const call = mint.call(client, { amount, memo, to, token });
1280
1409
  return (await action(client, {
1281
- ...parameters,
1410
+ ...rest,
1282
1411
  ...call,
1283
1412
  }));
1284
1413
  }
@@ -1304,7 +1433,7 @@ export async function mint(client, parameters) {
1304
1433
  *
1305
1434
  * const { result } = await client.sendCalls({
1306
1435
  * calls: [
1307
- * actions.token.mint.call({
1436
+ * actions.token.mint.call(client, {
1308
1437
  * to: '0x20c0...beef',
1309
1438
  * amount: 100n,
1310
1439
  * token: '0x20c0...babe',
@@ -1313,22 +1442,26 @@ export async function mint(client, parameters) {
1313
1442
  * })
1314
1443
  * ```
1315
1444
  *
1445
+ * `amount.decimals` is inferred from the client's declared `tokens` when omitted.
1446
+ *
1316
1447
  * @param args - Arguments.
1317
1448
  * @returns The call.
1318
1449
  */
1319
- function call(args) {
1450
+ function call(client, args) {
1320
1451
  const { to, amount, memo, token } = args;
1452
+ const { address, decimals } = resolveToken(client, { token });
1453
+ const value = internal_Token.toBaseUnits(amount, decimals);
1321
1454
  const callArgs = memo
1322
1455
  ? {
1323
1456
  functionName: 'mintWithMemo',
1324
- args: [to, amount, Hex.padLeft(memo, 32)],
1457
+ args: [to, value, Hex.padLeft(memo, 32)],
1325
1458
  }
1326
1459
  : {
1327
1460
  functionName: 'mint',
1328
- args: [to, amount],
1461
+ args: [to, value],
1329
1462
  };
1330
1463
  return defineCall({
1331
- address: TokenId.toAddress(token),
1464
+ address,
1332
1465
  abi: Abis.tip20,
1333
1466
  ...callArgs,
1334
1467
  });
@@ -1423,7 +1556,7 @@ export async function pause(client, parameters) {
1423
1556
  /** @internal */
1424
1557
  async function inner(action, client, parameters) {
1425
1558
  const { token, ...rest } = parameters;
1426
- const call = pause.call({ token });
1559
+ const call = pause.call(client, { token });
1427
1560
  return (await action(client, {
1428
1561
  ...rest,
1429
1562
  ...call,
@@ -1451,7 +1584,7 @@ export async function pause(client, parameters) {
1451
1584
  *
1452
1585
  * const { result } = await client.sendCalls({
1453
1586
  * calls: [
1454
- * actions.token.pause.call({
1587
+ * actions.token.pause.call(client, {
1455
1588
  * token: '0x20c0...babe',
1456
1589
  * }),
1457
1590
  * ]
@@ -1461,10 +1594,10 @@ export async function pause(client, parameters) {
1461
1594
  * @param args - Arguments.
1462
1595
  * @returns The call.
1463
1596
  */
1464
- function call(args) {
1597
+ function call(client, args) {
1465
1598
  const { token } = args;
1466
1599
  return defineCall({
1467
- address: TokenId.toAddress(token),
1600
+ address: resolveToken(client, { token }).address,
1468
1601
  abi: Abis.tip20,
1469
1602
  functionName: 'pause',
1470
1603
  args: [],
@@ -1561,7 +1694,7 @@ export async function renounceRoles(client, parameters) {
1561
1694
  return (await action(client, {
1562
1695
  ...parameters,
1563
1696
  calls: parameters.roles.map((role) => {
1564
- const call = renounceRoles.call({ ...parameters, role });
1697
+ const call = renounceRoles.call(client, { ...parameters, role });
1565
1698
  return {
1566
1699
  ...call,
1567
1700
  data: encodeFunctionData(call),
@@ -1591,7 +1724,7 @@ export async function renounceRoles(client, parameters) {
1591
1724
  *
1592
1725
  * const { result } = await client.sendCalls({
1593
1726
  * calls: [
1594
- * actions.token.renounceRoles.call({
1727
+ * actions.token.renounceRoles.call(client, {
1595
1728
  * token: '0x20c0...babe',
1596
1729
  * role: 'issuer',
1597
1730
  * }),
@@ -1602,11 +1735,11 @@ export async function renounceRoles(client, parameters) {
1602
1735
  * @param args - Arguments.
1603
1736
  * @returns The call.
1604
1737
  */
1605
- function call(args) {
1738
+ function call(client, args) {
1606
1739
  const { token, role } = args;
1607
1740
  const roleHash = TokenRole.serialize(role);
1608
1741
  return defineCall({
1609
- address: TokenId.toAddress(token),
1742
+ address: resolveToken(client, { token }).address,
1610
1743
  abi: Abis.tip20,
1611
1744
  functionName: 'renounceRole',
1612
1745
  args: [roleHash],
@@ -1707,7 +1840,7 @@ export async function revokeRoles(client, parameters) {
1707
1840
  return (await action(client, {
1708
1841
  ...rest,
1709
1842
  calls: parameters.roles.map((role) => {
1710
- const call = revokeRoles.call({ ...parameters, role });
1843
+ const call = revokeRoles.call(client, { ...parameters, role });
1711
1844
  return {
1712
1845
  ...call,
1713
1846
  data: encodeFunctionData(call),
@@ -1737,7 +1870,7 @@ export async function revokeRoles(client, parameters) {
1737
1870
  *
1738
1871
  * const { result } = await client.sendCalls({
1739
1872
  * calls: [
1740
- * actions.token.revokeRoles.call({
1873
+ * actions.token.revokeRoles.call(client, {
1741
1874
  * token: '0x20c0...babe',
1742
1875
  * from: '0x20c0...beef',
1743
1876
  * role: 'issuer',
@@ -1749,11 +1882,11 @@ export async function revokeRoles(client, parameters) {
1749
1882
  * @param args - Arguments.
1750
1883
  * @returns The call.
1751
1884
  */
1752
- function call(args) {
1885
+ function call(client, args) {
1753
1886
  const { token, from, role } = args;
1754
1887
  const roleHash = TokenRole.serialize(role);
1755
1888
  return defineCall({
1756
- address: TokenId.toAddress(token),
1889
+ address: resolveToken(client, { token }).address,
1757
1890
  abi: Abis.tip20,
1758
1891
  functionName: 'revokeRole',
1759
1892
  args: [roleHash, from],
@@ -1851,7 +1984,7 @@ export async function setSupplyCap(client, parameters) {
1851
1984
  /** @internal */
1852
1985
  async function inner(action, client, parameters) {
1853
1986
  const { supplyCap, token, ...rest } = parameters;
1854
- const call = setSupplyCap.call({ supplyCap, token });
1987
+ const call = setSupplyCap.call(client, { supplyCap, token });
1855
1988
  return (await action(client, {
1856
1989
  ...rest,
1857
1990
  ...call,
@@ -1879,7 +2012,7 @@ export async function setSupplyCap(client, parameters) {
1879
2012
  *
1880
2013
  * const { result } = await client.sendCalls({
1881
2014
  * calls: [
1882
- * actions.token.setSupplyCap.call({
2015
+ * actions.token.setSupplyCap.call(client, {
1883
2016
  * token: '0x20c0...babe',
1884
2017
  * supplyCap: 1000000n,
1885
2018
  * }),
@@ -1890,10 +2023,10 @@ export async function setSupplyCap(client, parameters) {
1890
2023
  * @param args - Arguments.
1891
2024
  * @returns The call.
1892
2025
  */
1893
- function call(args) {
2026
+ function call(client, args) {
1894
2027
  const { token, supplyCap } = args;
1895
2028
  return defineCall({
1896
- address: TokenId.toAddress(token),
2029
+ address: resolveToken(client, { token }).address,
1897
2030
  abi: Abis.tip20,
1898
2031
  functionName: 'setSupplyCap',
1899
2032
  args: [supplyCap],
@@ -1990,7 +2123,7 @@ export async function setRoleAdmin(client, parameters) {
1990
2123
  /** @internal */
1991
2124
  async function inner(action, client, parameters) {
1992
2125
  const { adminRole, role, token, ...rest } = parameters;
1993
- const call = setRoleAdmin.call({ adminRole, role, token });
2126
+ const call = setRoleAdmin.call(client, { adminRole, role, token });
1994
2127
  return (await action(client, {
1995
2128
  ...rest,
1996
2129
  ...call,
@@ -2018,7 +2151,7 @@ export async function setRoleAdmin(client, parameters) {
2018
2151
  *
2019
2152
  * const { result } = await client.sendCalls({
2020
2153
  * calls: [
2021
- * actions.token.setRoleAdmin.call({
2154
+ * actions.token.setRoleAdmin.call(client, {
2022
2155
  * token: '0x20c0...babe',
2023
2156
  * role: 'issuer',
2024
2157
  * adminRole: 'admin',
@@ -2030,12 +2163,12 @@ export async function setRoleAdmin(client, parameters) {
2030
2163
  * @param args - Arguments.
2031
2164
  * @returns The call.
2032
2165
  */
2033
- function call(args) {
2166
+ function call(client, args) {
2034
2167
  const { token, role, adminRole } = args;
2035
2168
  const roleHash = TokenRole.serialize(role);
2036
2169
  const adminRoleHash = TokenRole.serialize(adminRole);
2037
2170
  return defineCall({
2038
- address: TokenId.toAddress(token),
2171
+ address: resolveToken(client, { token }).address,
2039
2172
  abi: Abis.tip20,
2040
2173
  functionName: 'setRoleAdmin',
2041
2174
  args: [roleHash, adminRoleHash],
@@ -2131,82 +2264,93 @@ export async function transfer(client, parameters) {
2131
2264
  (function (transfer) {
2132
2265
  /** @internal */
2133
2266
  async function inner(action, client, parameters) {
2134
- const { amount, from, memo, token, to, ...rest } = parameters;
2135
- const call = transfer.call({ amount, from, memo, token, to });
2136
2267
  return (await action(client, {
2137
- ...rest,
2138
- ...call,
2268
+ ...parameters,
2269
+ ...transfer.call(client, parameters),
2139
2270
  }));
2140
2271
  }
2141
2272
  transfer.inner = inner;
2142
2273
  /**
2143
- * Defines a call to the `transfer`, `transferFrom`, `transferWithMemo`, or `transferFromWithMemo` function.
2144
- *
2145
- * Can be passed as a parameter to:
2146
- * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
2147
- * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
2148
- * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
2274
+ * Defines a call to the `transfer`, `transferFrom`, `transferWithMemo`, or
2275
+ * `transferFromWithMemo` function.
2149
2276
  *
2150
- * @example
2151
- * ```ts
2152
- * import { createClient, http, walletActions } from 'viem'
2153
- * import { tempo } from 'viem/chains'
2154
- * import { Actions } from 'viem/tempo'
2277
+ * Can be passed as a parameter to `estimateContractGas`, `simulateContract`,
2278
+ * `sendCalls`, `sendTransaction` (`calls`), or `multicall`. The token is
2279
+ * selected by `token`, which is either a TIP20 token id or a contract
2280
+ * `address`; `amount.decimals` is inferred from the client's declared
2281
+ * `tokens` when omitted.
2155
2282
  *
2156
- * const client = createClient({
2157
- * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
2158
- * transport: http(),
2159
- * }).extend(walletActions)
2160
- *
2161
- * const { result } = await client.sendCalls({
2162
- * calls: [
2163
- * actions.token.transfer.call({
2164
- * to: '0x20c0...beef',
2165
- * amount: 100n,
2166
- * token: '0x20c0...babe',
2167
- * }),
2168
- * ]
2169
- * })
2170
- * ```
2171
- *
2172
- * @param args - Arguments.
2283
+ * @param client - Client.
2284
+ * @param parameters - Parameters.
2173
2285
  * @returns The call.
2174
2286
  */
2175
- function call(args) {
2176
- const { amount, from, memo, token, to } = args;
2287
+ function call(client, parameters) {
2288
+ const { from, memo, to, token } = parameters;
2289
+ const { address, decimals } = resolveToken(client, { token });
2290
+ const value = internal_Token.toBaseUnits(parameters.amount, decimals);
2177
2291
  const callArgs = (() => {
2178
2292
  if (memo && from)
2179
2293
  return {
2180
2294
  functionName: 'transferFromWithMemo',
2181
- args: [from, to, amount, Hex.padLeft(memo, 32)],
2295
+ args: [from, to, value, Hex.padLeft(memo, 32)],
2182
2296
  };
2183
2297
  if (memo)
2184
2298
  return {
2185
2299
  functionName: 'transferWithMemo',
2186
- args: [to, amount, Hex.padLeft(memo, 32)],
2300
+ args: [to, value, Hex.padLeft(memo, 32)],
2187
2301
  };
2188
2302
  if (from)
2189
2303
  return {
2190
2304
  functionName: 'transferFrom',
2191
- args: [from, to, amount],
2305
+ args: [from, to, value],
2192
2306
  };
2193
2307
  return {
2194
2308
  functionName: 'transfer',
2195
- args: [to, amount],
2309
+ args: [to, value],
2196
2310
  };
2197
2311
  })();
2198
2312
  return defineCall({
2199
- address: TokenId.toAddress(token),
2313
+ address,
2200
2314
  abi: Abis.tip20,
2201
2315
  ...callArgs,
2202
2316
  });
2203
2317
  }
2204
2318
  transfer.call = call;
2205
2319
  /**
2206
- * Extracts the event from the logs.
2320
+ * Estimates the gas required to transfer TIP20 tokens. `amount.decimals` is
2321
+ * inferred from the client's declared `tokens` when omitted.
2322
+ *
2323
+ * @param client - Client.
2324
+ * @param parameters - Parameters.
2325
+ * @returns The gas estimate.
2326
+ */
2327
+ async function estimateGas(client, parameters) {
2328
+ return estimateContractGas(client, {
2329
+ ...pickWriteParameters(parameters),
2330
+ ...transfer.call(client, parameters),
2331
+ });
2332
+ }
2333
+ transfer.estimateGas = estimateGas;
2334
+ /**
2335
+ * Simulates a transfer of TIP20 tokens. `amount.decimals` is inferred from
2336
+ * the client's declared `tokens` when omitted.
2337
+ *
2338
+ * @param client - Client.
2339
+ * @param parameters - Parameters.
2340
+ * @returns The simulation result and write request.
2341
+ */
2342
+ async function simulate(client, parameters) {
2343
+ return simulateContract(client, {
2344
+ ...pickWriteParameters(parameters),
2345
+ ...transfer.call(client, parameters),
2346
+ });
2347
+ }
2348
+ transfer.simulate = simulate;
2349
+ /**
2350
+ * Extracts the `Transfer` event from logs.
2207
2351
  *
2208
2352
  * @param logs - Logs.
2209
- * @returns The event.
2353
+ * @returns The `Transfer` event.
2210
2354
  */
2211
2355
  function extractEvent(logs) {
2212
2356
  const [log] = parseEventLogs({
@@ -2247,14 +2391,19 @@ export async function transfer(client, parameters) {
2247
2391
  * @returns The transaction receipt and event data.
2248
2392
  */
2249
2393
  export async function transferSync(client, parameters) {
2250
- const { throwOnReceiptRevert = true, ...rest } = parameters;
2394
+ const { amount, token, throwOnReceiptRevert = true } = parameters;
2395
+ const { decimals } = resolveToken(client, { token });
2396
+ const resolved = internal_Token.resolveAmountDecimals(amount, decimals);
2251
2397
  const receipt = await transfer.inner(writeContractSync, client, {
2252
- ...rest,
2398
+ ...parameters,
2253
2399
  throwOnReceiptRevert,
2254
2400
  });
2255
2401
  const { args } = transfer.extractEvent(receipt.logs);
2256
2402
  return {
2257
2403
  ...args,
2404
+ ...(resolved === undefined
2405
+ ? {}
2406
+ : { decimals: resolved, formatted: formatUnits(args.amount, resolved) }),
2258
2407
  receipt,
2259
2408
  };
2260
2409
  }
@@ -2290,7 +2439,7 @@ export async function unpause(client, parameters) {
2290
2439
  /** @internal */
2291
2440
  async function inner(action, client, parameters) {
2292
2441
  const { token, ...rest } = parameters;
2293
- const call = unpause.call({ token });
2442
+ const call = unpause.call(client, { token });
2294
2443
  return (await action(client, {
2295
2444
  ...rest,
2296
2445
  ...call,
@@ -2318,7 +2467,7 @@ export async function unpause(client, parameters) {
2318
2467
  *
2319
2468
  * const { result } = await client.sendCalls({
2320
2469
  * calls: [
2321
- * actions.token.unpause.call({
2470
+ * actions.token.unpause.call(client, {
2322
2471
  * token: '0x20c0...babe',
2323
2472
  * }),
2324
2473
  * ]
@@ -2328,10 +2477,10 @@ export async function unpause(client, parameters) {
2328
2477
  * @param args - Arguments.
2329
2478
  * @returns The call.
2330
2479
  */
2331
- function call(args) {
2480
+ function call(client, args) {
2332
2481
  const { token } = args;
2333
2482
  return defineCall({
2334
- address: TokenId.toAddress(token),
2483
+ address: resolveToken(client, { token }).address,
2335
2484
  abi: Abis.tip20,
2336
2485
  functionName: 'unpause',
2337
2486
  args: [],
@@ -2426,7 +2575,7 @@ export async function prepareUpdateQuoteToken(client, parameters) {
2426
2575
  /** @internal */
2427
2576
  async function inner(action, client, parameters) {
2428
2577
  const { quoteToken, token, ...rest } = parameters;
2429
- const call = prepareUpdateQuoteToken.call({ quoteToken, token });
2578
+ const call = prepareUpdateQuoteToken.call(client, { quoteToken, token });
2430
2579
  return (await action(client, {
2431
2580
  ...rest,
2432
2581
  ...call,
@@ -2454,7 +2603,7 @@ export async function prepareUpdateQuoteToken(client, parameters) {
2454
2603
  *
2455
2604
  * const { result } = await client.sendCalls({
2456
2605
  * calls: [
2457
- * actions.token.prepareUpdateQuoteToken.call({
2606
+ * actions.token.prepareUpdateQuoteToken.call(client, {
2458
2607
  * token: '0x20c0...babe',
2459
2608
  * quoteToken: '0x20c0...cafe',
2460
2609
  * }),
@@ -2465,13 +2614,13 @@ export async function prepareUpdateQuoteToken(client, parameters) {
2465
2614
  * @param args - Arguments.
2466
2615
  * @returns The call.
2467
2616
  */
2468
- function call(args) {
2617
+ function call(client, args) {
2469
2618
  const { token, quoteToken } = args;
2470
2619
  return defineCall({
2471
- address: TokenId.toAddress(token),
2620
+ address: resolveToken(client, { token }).address,
2472
2621
  abi: Abis.tip20,
2473
2622
  functionName: 'setNextQuoteToken',
2474
- args: [TokenId.toAddress(quoteToken)],
2623
+ args: [resolveToken(client, { token: quoteToken }).address],
2475
2624
  });
2476
2625
  }
2477
2626
  prepareUpdateQuoteToken.call = call;
@@ -2559,7 +2708,7 @@ export async function updateQuoteToken(client, parameters) {
2559
2708
  /** @internal */
2560
2709
  async function inner(action, client, parameters) {
2561
2710
  const { token, ...rest } = parameters;
2562
- const call = updateQuoteToken.call({ token });
2711
+ const call = updateQuoteToken.call(client, { token });
2563
2712
  return (await action(client, {
2564
2713
  ...rest,
2565
2714
  ...call,
@@ -2587,7 +2736,7 @@ export async function updateQuoteToken(client, parameters) {
2587
2736
  *
2588
2737
  * const { result } = await client.sendCalls({
2589
2738
  * calls: [
2590
- * actions.token.updateQuoteToken.call({
2739
+ * actions.token.updateQuoteToken.call(client, {
2591
2740
  * token: '0x20c0...babe',
2592
2741
  * }),
2593
2742
  * ]
@@ -2597,10 +2746,10 @@ export async function updateQuoteToken(client, parameters) {
2597
2746
  * @param args - Arguments.
2598
2747
  * @returns The call.
2599
2748
  */
2600
- function call(args) {
2749
+ function call(client, args) {
2601
2750
  const { token } = args;
2602
2751
  return defineCall({
2603
- address: TokenId.toAddress(token),
2752
+ address: resolveToken(client, { token }).address,
2604
2753
  abi: Abis.tip20,
2605
2754
  functionName: 'completeQuoteTokenUpdate',
2606
2755
  args: [],
@@ -2687,7 +2836,7 @@ export function watchApprove(client, parameters) {
2687
2836
  const { onApproval, token, ...rest } = parameters;
2688
2837
  return watchContractEvent(client, {
2689
2838
  ...rest,
2690
- address: TokenId.toAddress(token),
2839
+ address: resolveToken(client, { token }).address,
2691
2840
  abi: Abis.tip20,
2692
2841
  eventName: 'Approval',
2693
2842
  onLogs: (logs) => {
@@ -2726,7 +2875,7 @@ export function watchBurn(client, parameters) {
2726
2875
  const { onBurn, token, ...rest } = parameters;
2727
2876
  return watchContractEvent(client, {
2728
2877
  ...rest,
2729
- address: TokenId.toAddress(token),
2878
+ address: resolveToken(client, { token }).address,
2730
2879
  abi: Abis.tip20,
2731
2880
  eventName: 'Burn',
2732
2881
  onLogs: (logs) => {
@@ -2804,7 +2953,7 @@ export function watchMint(client, parameters) {
2804
2953
  const { onMint, token, ...rest } = parameters;
2805
2954
  return watchContractEvent(client, {
2806
2955
  ...rest,
2807
- address: TokenId.toAddress(token),
2956
+ address: resolveToken(client, { token }).address,
2808
2957
  abi: Abis.tip20,
2809
2958
  eventName: 'Mint',
2810
2959
  onLogs: (logs) => {
@@ -2843,7 +2992,7 @@ export function watchAdminRole(client, parameters) {
2843
2992
  const { onRoleAdminUpdated, token, ...rest } = parameters;
2844
2993
  return watchContractEvent(client, {
2845
2994
  ...rest,
2846
- address: TokenId.toAddress(token),
2995
+ address: resolveToken(client, { token }).address,
2847
2996
  abi: Abis.tip20,
2848
2997
  eventName: 'RoleAdminUpdated',
2849
2998
  onLogs: (logs) => {
@@ -2882,7 +3031,7 @@ export function watchRole(client, parameters) {
2882
3031
  const { onRoleUpdated, token, ...rest } = parameters;
2883
3032
  return watchContractEvent(client, {
2884
3033
  ...rest,
2885
- address: TokenId.toAddress(token),
3034
+ address: resolveToken(client, { token }).address,
2886
3035
  abi: Abis.tip20,
2887
3036
  eventName: 'RoleMembershipUpdated',
2888
3037
  onLogs: (logs) => {
@@ -2924,7 +3073,7 @@ export function watchTransfer(client, parameters) {
2924
3073
  const { onTransfer, token, ...rest } = parameters;
2925
3074
  return watchContractEvent(client, {
2926
3075
  ...rest,
2927
- address: TokenId.toAddress(token),
3076
+ address: resolveToken(client, { token }).address,
2928
3077
  abi: Abis.tip20,
2929
3078
  eventName: 'Transfer',
2930
3079
  onLogs: (logs) => {
@@ -2964,7 +3113,7 @@ export function watchTransfer(client, parameters) {
2964
3113
  */
2965
3114
  export function watchUpdateQuoteToken(client, parameters) {
2966
3115
  const { onUpdateQuoteToken, token, ...rest } = parameters;
2967
- const address = TokenId.toAddress(token);
3116
+ const address = resolveToken(client, { token }).address;
2968
3117
  return watchContractEvent(client, {
2969
3118
  ...rest,
2970
3119
  address,