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.
- package/CHANGELOG.md +55 -0
- package/_cjs/actions/index.js +3 -2
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/token/approve.js +62 -0
- package/_cjs/actions/token/approve.js.map +1 -0
- package/_cjs/actions/token/approveSync.js +25 -0
- package/_cjs/actions/token/approveSync.js.map +1 -0
- package/_cjs/actions/token/getAllowance.js +32 -0
- package/_cjs/actions/token/getAllowance.js.map +1 -0
- package/_cjs/actions/token/getBalance.js +41 -0
- package/_cjs/actions/token/getBalance.js.map +1 -0
- package/_cjs/actions/token/getMetadata.js +40 -0
- package/_cjs/actions/token/getMetadata.js.map +1 -0
- package/_cjs/actions/token/getTotalSupply.js +32 -0
- package/_cjs/actions/token/getTotalSupply.js.map +1 -0
- package/_cjs/actions/token/index.js +20 -0
- package/_cjs/actions/token/index.js.map +1 -0
- package/_cjs/actions/token/internal.js +125 -0
- package/_cjs/actions/token/internal.js.map +1 -0
- package/_cjs/actions/token/transfer.js +70 -0
- package/_cjs/actions/token/transfer.js.map +1 -0
- package/_cjs/actions/token/transferSync.js +25 -0
- package/_cjs/actions/token/transferSync.js.map +1 -0
- package/_cjs/chains/definitions/battlechain.js +31 -0
- package/_cjs/chains/definitions/battlechain.js.map +1 -0
- package/_cjs/chains/definitions/marooTestnet.js +30 -0
- package/_cjs/chains/definitions/marooTestnet.js.map +1 -0
- package/_cjs/chains/index.js +18 -14
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/createClient.js +39 -1
- package/_cjs/clients/createClient.js.map +1 -1
- package/_cjs/clients/createPublicClient.js.map +1 -1
- package/_cjs/clients/createWalletClient.js.map +1 -1
- package/_cjs/clients/decorators/public.js +11 -0
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js +8 -0
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/clients/transports/http.js +2 -1
- package/_cjs/clients/transports/http.js.map +1 -1
- package/_cjs/errors/encoding.js +9 -1
- package/_cjs/errors/encoding.js.map +1 -1
- package/_cjs/errors/request.js +24 -1
- package/_cjs/errors/request.js.map +1 -1
- package/_cjs/errors/transaction.js +9 -1
- package/_cjs/errors/transaction.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +9 -6
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/Client.js.map +1 -1
- package/_cjs/tempo/Decorator.js +234 -215
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/actions/token.js +210 -112
- package/_cjs/tempo/actions/token.js.map +1 -1
- package/_cjs/tempo/internal/utils.js +108 -0
- package/_cjs/tempo/internal/utils.js.map +1 -1
- package/_cjs/tokens/defineToken.js +21 -0
- package/_cjs/tokens/defineToken.js.map +1 -0
- package/_cjs/tokens/definitions/alphausd.js +14 -0
- package/_cjs/tokens/definitions/alphausd.js.map +1 -0
- package/_cjs/tokens/definitions/betausd.js +14 -0
- package/_cjs/tokens/definitions/betausd.js.map +1 -0
- package/_cjs/tokens/definitions/brla.js +14 -0
- package/_cjs/tokens/definitions/brla.js.map +1 -0
- package/_cjs/tokens/definitions/cbbtc.js +14 -0
- package/_cjs/tokens/definitions/cbbtc.js.map +1 -0
- package/_cjs/tokens/definitions/chfau.js +14 -0
- package/_cjs/tokens/definitions/chfau.js.map +1 -0
- package/_cjs/tokens/definitions/cusd.js +14 -0
- package/_cjs/tokens/definitions/cusd.js.map +1 -0
- package/_cjs/tokens/definitions/dlusd.js +14 -0
- package/_cjs/tokens/definitions/dlusd.js.map +1 -0
- package/_cjs/tokens/definitions/eurau.js +14 -0
- package/_cjs/tokens/definitions/eurau.js.map +1 -0
- package/_cjs/tokens/definitions/eurce.js +15 -0
- package/_cjs/tokens/definitions/eurce.js.map +1 -0
- package/_cjs/tokens/definitions/frxusd.js +14 -0
- package/_cjs/tokens/definitions/frxusd.js.map +1 -0
- package/_cjs/tokens/definitions/gbpa.js +14 -0
- package/_cjs/tokens/definitions/gbpa.js.map +1 -0
- package/_cjs/tokens/definitions/gusd.js +14 -0
- package/_cjs/tokens/definitions/gusd.js.map +1 -0
- package/_cjs/tokens/definitions/iusd.js +14 -0
- package/_cjs/tokens/definitions/iusd.js.map +1 -0
- package/_cjs/tokens/definitions/pathusd.js +15 -0
- package/_cjs/tokens/definitions/pathusd.js.map +1 -0
- package/_cjs/tokens/definitions/reusd.js +14 -0
- package/_cjs/tokens/definitions/reusd.js.map +1 -0
- package/_cjs/tokens/definitions/rusd.js +14 -0
- package/_cjs/tokens/definitions/rusd.js.map +1 -0
- package/_cjs/tokens/definitions/sbc.js +14 -0
- package/_cjs/tokens/definitions/sbc.js.map +1 -0
- package/_cjs/tokens/definitions/siusd.js +14 -0
- package/_cjs/tokens/definitions/siusd.js.map +1 -0
- package/_cjs/tokens/definitions/stcusd.js +14 -0
- package/_cjs/tokens/definitions/stcusd.js.map +1 -0
- package/_cjs/tokens/definitions/susde.js +14 -0
- package/_cjs/tokens/definitions/susde.js.map +1 -0
- package/_cjs/tokens/definitions/syrupusdc.js +14 -0
- package/_cjs/tokens/definitions/syrupusdc.js.map +1 -0
- package/_cjs/tokens/definitions/thetausd.js +14 -0
- package/_cjs/tokens/definitions/thetausd.js.map +1 -0
- package/_cjs/tokens/definitions/usd1.js +14 -0
- package/_cjs/tokens/definitions/usd1.js.map +1 -0
- package/_cjs/tokens/definitions/usdb.js +14 -0
- package/_cjs/tokens/definitions/usdb.js.map +1 -0
- package/_cjs/tokens/definitions/usdc.js +41 -0
- package/_cjs/tokens/definitions/usdc.js.map +1 -0
- package/_cjs/tokens/definitions/usdce.js +15 -0
- package/_cjs/tokens/definitions/usdce.js.map +1 -0
- package/_cjs/tokens/definitions/usde.js +14 -0
- package/_cjs/tokens/definitions/usde.js.map +1 -0
- package/_cjs/tokens/definitions/usdt0.js +14 -0
- package/_cjs/tokens/definitions/usdt0.js.map +1 -0
- package/_cjs/tokens/definitions/wsrusd.js +14 -0
- package/_cjs/tokens/definitions/wsrusd.js.map +1 -0
- package/_cjs/tokens/index.js +64 -0
- package/_cjs/tokens/index.js.map +1 -0
- package/_cjs/utils/encoding/fromRlp.js +7 -4
- package/_cjs/utils/encoding/fromRlp.js.map +1 -1
- package/_cjs/utils/rpc/http.js +58 -3
- package/_cjs/utils/rpc/http.js.map +1 -1
- package/_cjs/utils/transaction/parseTransaction.js +4 -1
- package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/token/approve.js +123 -0
- package/_esm/actions/token/approve.js.map +1 -0
- package/_esm/actions/token/approveSync.js +50 -0
- package/_esm/actions/token/approveSync.js.map +1 -0
- package/_esm/actions/token/getAllowance.js +62 -0
- package/_esm/actions/token/getAllowance.js.map +1 -0
- package/_esm/actions/token/getBalance.js +70 -0
- package/_esm/actions/token/getBalance.js.map +1 -0
- package/_esm/actions/token/getMetadata.js +60 -0
- package/_esm/actions/token/getMetadata.js.map +1 -0
- package/_esm/actions/token/getTotalSupply.js +60 -0
- package/_esm/actions/token/getTotalSupply.js.map +1 -0
- package/_esm/actions/token/index.js +10 -0
- package/_esm/actions/token/index.js.map +1 -0
- package/_esm/actions/token/internal.js +188 -0
- package/_esm/actions/token/internal.js.map +1 -0
- package/_esm/actions/token/transfer.js +147 -0
- package/_esm/actions/token/transfer.js.map +1 -0
- package/_esm/actions/token/transferSync.js +54 -0
- package/_esm/actions/token/transferSync.js.map +1 -0
- package/_esm/chains/definitions/battlechain.js +28 -0
- package/_esm/chains/definitions/battlechain.js.map +1 -0
- package/_esm/chains/definitions/marooTestnet.js +27 -0
- package/_esm/chains/definitions/marooTestnet.js.map +1 -0
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/createClient.js +53 -1
- package/_esm/clients/createClient.js.map +1 -1
- package/_esm/clients/createPublicClient.js.map +1 -1
- package/_esm/clients/createWalletClient.js.map +1 -1
- package/_esm/clients/decorators/public.js +17 -0
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/clients/decorators/wallet.js +8 -0
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/clients/transports/http.js +2 -1
- package/_esm/clients/transports/http.js.map +1 -1
- package/_esm/errors/encoding.js +7 -0
- package/_esm/errors/encoding.js.map +1 -1
- package/_esm/errors/request.js +22 -0
- package/_esm/errors/request.js.map +1 -1
- package/_esm/errors/transaction.js +7 -0
- package/_esm/errors/transaction.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +3 -3
- package/_esm/index.js.map +1 -1
- package/_esm/tempo/Client.js.map +1 -1
- package/_esm/tempo/Decorator.js +234 -218
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/actions/token.js +335 -186
- package/_esm/tempo/actions/token.js.map +1 -1
- package/_esm/tempo/actions/wallet.js +1 -1
- package/_esm/tempo/internal/utils.js +154 -0
- package/_esm/tempo/internal/utils.js.map +1 -1
- package/_esm/tokens/defineToken.js +57 -0
- package/_esm/tokens/defineToken.js.map +1 -0
- package/_esm/tokens/definitions/alphausd.js +12 -0
- package/_esm/tokens/definitions/alphausd.js.map +1 -0
- package/_esm/tokens/definitions/betausd.js +12 -0
- package/_esm/tokens/definitions/betausd.js.map +1 -0
- package/_esm/tokens/definitions/brla.js +12 -0
- package/_esm/tokens/definitions/brla.js.map +1 -0
- package/_esm/tokens/definitions/cbbtc.js +12 -0
- package/_esm/tokens/definitions/cbbtc.js.map +1 -0
- package/_esm/tokens/definitions/chfau.js +12 -0
- package/_esm/tokens/definitions/chfau.js.map +1 -0
- package/_esm/tokens/definitions/cusd.js +12 -0
- package/_esm/tokens/definitions/cusd.js.map +1 -0
- package/_esm/tokens/definitions/dlusd.js +12 -0
- package/_esm/tokens/definitions/dlusd.js.map +1 -0
- package/_esm/tokens/definitions/eurau.js +12 -0
- package/_esm/tokens/definitions/eurau.js.map +1 -0
- package/_esm/tokens/definitions/eurce.js +13 -0
- package/_esm/tokens/definitions/eurce.js.map +1 -0
- package/_esm/tokens/definitions/frxusd.js +12 -0
- package/_esm/tokens/definitions/frxusd.js.map +1 -0
- package/_esm/tokens/definitions/gbpa.js +12 -0
- package/_esm/tokens/definitions/gbpa.js.map +1 -0
- package/_esm/tokens/definitions/gusd.js +12 -0
- package/_esm/tokens/definitions/gusd.js.map +1 -0
- package/_esm/tokens/definitions/iusd.js +12 -0
- package/_esm/tokens/definitions/iusd.js.map +1 -0
- package/_esm/tokens/definitions/pathusd.js +13 -0
- package/_esm/tokens/definitions/pathusd.js.map +1 -0
- package/_esm/tokens/definitions/reusd.js +12 -0
- package/_esm/tokens/definitions/reusd.js.map +1 -0
- package/_esm/tokens/definitions/rusd.js +12 -0
- package/_esm/tokens/definitions/rusd.js.map +1 -0
- package/_esm/tokens/definitions/sbc.js +12 -0
- package/_esm/tokens/definitions/sbc.js.map +1 -0
- package/_esm/tokens/definitions/siusd.js +12 -0
- package/_esm/tokens/definitions/siusd.js.map +1 -0
- package/_esm/tokens/definitions/stcusd.js +12 -0
- package/_esm/tokens/definitions/stcusd.js.map +1 -0
- package/_esm/tokens/definitions/susde.js +12 -0
- package/_esm/tokens/definitions/susde.js.map +1 -0
- package/_esm/tokens/definitions/syrupusdc.js +12 -0
- package/_esm/tokens/definitions/syrupusdc.js.map +1 -0
- package/_esm/tokens/definitions/thetausd.js +12 -0
- package/_esm/tokens/definitions/thetausd.js.map +1 -0
- package/_esm/tokens/definitions/usd1.js +12 -0
- package/_esm/tokens/definitions/usd1.js.map +1 -0
- package/_esm/tokens/definitions/usdb.js +12 -0
- package/_esm/tokens/definitions/usdb.js.map +1 -0
- package/_esm/tokens/definitions/usdc.js +67 -0
- package/_esm/tokens/definitions/usdc.js.map +1 -0
- package/_esm/tokens/definitions/usdce.js +13 -0
- package/_esm/tokens/definitions/usdce.js.map +1 -0
- package/_esm/tokens/definitions/usde.js +12 -0
- package/_esm/tokens/definitions/usde.js.map +1 -0
- package/_esm/tokens/definitions/usdt0.js +12 -0
- package/_esm/tokens/definitions/usdt0.js.map +1 -0
- package/_esm/tokens/definitions/wsrusd.js +12 -0
- package/_esm/tokens/definitions/wsrusd.js.map +1 -0
- package/_esm/tokens/index.js +32 -0
- package/_esm/tokens/index.js.map +1 -0
- package/_esm/utils/encoding/fromRlp.js +8 -5
- package/_esm/utils/encoding/fromRlp.js.map +1 -1
- package/_esm/utils/rpc/http.js +59 -4
- package/_esm/utils/rpc/http.js.map +1 -1
- package/_esm/utils/transaction/parseTransaction.js +5 -2
- package/_esm/utils/transaction/parseTransaction.js.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/token/approve.d.ts +253 -0
- package/_types/actions/token/approve.d.ts.map +1 -0
- package/_types/actions/token/approveSync.d.ts +57 -0
- package/_types/actions/token/approveSync.d.ts.map +1 -0
- package/_types/actions/token/getAllowance.d.ts +77 -0
- package/_types/actions/token/getAllowance.d.ts.map +1 -0
- package/_types/actions/token/getBalance.d.ts +69 -0
- package/_types/actions/token/getBalance.d.ts.map +1 -0
- package/_types/actions/token/getMetadata.d.ts +43 -0
- package/_types/actions/token/getMetadata.d.ts.map +1 -0
- package/_types/actions/token/getTotalSupply.d.ts +63 -0
- package/_types/actions/token/getTotalSupply.d.ts.map +1 -0
- package/_types/actions/token/index.d.ts +9 -0
- package/_types/actions/token/index.d.ts.map +1 -0
- package/_types/actions/token/internal.d.ts +168 -0
- package/_types/actions/token/internal.d.ts.map +1 -0
- package/_types/actions/token/transfer.d.ts +288 -0
- package/_types/actions/token/transfer.d.ts.map +1 -0
- package/_types/actions/token/transferSync.d.ts +61 -0
- package/_types/actions/token/transferSync.d.ts.map +1 -0
- package/_types/chains/definitions/battlechain.d.ts +447 -0
- package/_types/chains/definitions/battlechain.d.ts.map +1 -0
- package/_types/chains/definitions/marooTestnet.d.ts +49 -0
- package/_types/chains/definitions/marooTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/createClient.d.ts +24 -6
- package/_types/clients/createClient.d.ts.map +1 -1
- package/_types/clients/createPublicClient.d.ts +4 -3
- package/_types/clients/createPublicClient.d.ts.map +1 -1
- package/_types/clients/createWalletClient.d.ts +4 -3
- package/_types/clients/createWalletClient.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +128 -3
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/clients/decorators/wallet.d.ts +208 -3
- package/_types/clients/decorators/wallet.d.ts.map +1 -1
- package/_types/clients/transports/http.d.ts +2 -0
- package/_types/clients/transports/http.d.ts.map +1 -1
- package/_types/errors/encoding.d.ts +8 -0
- package/_types/errors/encoding.d.ts.map +1 -1
- package/_types/errors/request.d.ts +11 -0
- package/_types/errors/request.d.ts.map +1 -1
- package/_types/errors/transaction.d.ts +8 -0
- package/_types/errors/transaction.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +4 -3
- package/_types/index.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +1 -1
- package/_types/tempo/Client.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +88 -5
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/actions/token.d.ts +223 -151
- package/_types/tempo/actions/token.d.ts.map +1 -1
- package/_types/tempo/actions/wallet.d.ts +3 -3
- package/_types/tempo/internal/types.d.ts +17 -0
- package/_types/tempo/internal/types.d.ts.map +1 -1
- package/_types/tempo/internal/utils.d.ts +73 -0
- package/_types/tempo/internal/utils.d.ts.map +1 -1
- package/_types/tokens/defineToken.d.ts +112 -0
- package/_types/tokens/defineToken.d.ts.map +1 -0
- package/_types/tokens/definitions/alphausd.d.ts +11 -0
- package/_types/tokens/definitions/alphausd.d.ts.map +1 -0
- package/_types/tokens/definitions/betausd.d.ts +11 -0
- package/_types/tokens/definitions/betausd.d.ts.map +1 -0
- package/_types/tokens/definitions/brla.d.ts +11 -0
- package/_types/tokens/definitions/brla.d.ts.map +1 -0
- package/_types/tokens/definitions/cbbtc.d.ts +11 -0
- package/_types/tokens/definitions/cbbtc.d.ts.map +1 -0
- package/_types/tokens/definitions/chfau.d.ts +11 -0
- package/_types/tokens/definitions/chfau.d.ts.map +1 -0
- package/_types/tokens/definitions/cusd.d.ts +11 -0
- package/_types/tokens/definitions/cusd.d.ts.map +1 -0
- package/_types/tokens/definitions/dlusd.d.ts +11 -0
- package/_types/tokens/definitions/dlusd.d.ts.map +1 -0
- package/_types/tokens/definitions/eurau.d.ts +11 -0
- package/_types/tokens/definitions/eurau.d.ts.map +1 -0
- package/_types/tokens/definitions/eurce.d.ts +12 -0
- package/_types/tokens/definitions/eurce.d.ts.map +1 -0
- package/_types/tokens/definitions/frxusd.d.ts +11 -0
- package/_types/tokens/definitions/frxusd.d.ts.map +1 -0
- package/_types/tokens/definitions/gbpa.d.ts +11 -0
- package/_types/tokens/definitions/gbpa.d.ts.map +1 -0
- package/_types/tokens/definitions/gusd.d.ts +11 -0
- package/_types/tokens/definitions/gusd.d.ts.map +1 -0
- package/_types/tokens/definitions/iusd.d.ts +11 -0
- package/_types/tokens/definitions/iusd.d.ts.map +1 -0
- package/_types/tokens/definitions/pathusd.d.ts +12 -0
- package/_types/tokens/definitions/pathusd.d.ts.map +1 -0
- package/_types/tokens/definitions/reusd.d.ts +11 -0
- package/_types/tokens/definitions/reusd.d.ts.map +1 -0
- package/_types/tokens/definitions/rusd.d.ts +11 -0
- package/_types/tokens/definitions/rusd.d.ts.map +1 -0
- package/_types/tokens/definitions/sbc.d.ts +11 -0
- package/_types/tokens/definitions/sbc.d.ts.map +1 -0
- package/_types/tokens/definitions/siusd.d.ts +11 -0
- package/_types/tokens/definitions/siusd.d.ts.map +1 -0
- package/_types/tokens/definitions/stcusd.d.ts +11 -0
- package/_types/tokens/definitions/stcusd.d.ts.map +1 -0
- package/_types/tokens/definitions/susde.d.ts +11 -0
- package/_types/tokens/definitions/susde.d.ts.map +1 -0
- package/_types/tokens/definitions/syrupusdc.d.ts +11 -0
- package/_types/tokens/definitions/syrupusdc.d.ts.map +1 -0
- package/_types/tokens/definitions/thetausd.d.ts +11 -0
- package/_types/tokens/definitions/thetausd.d.ts.map +1 -0
- package/_types/tokens/definitions/usd1.d.ts +11 -0
- package/_types/tokens/definitions/usd1.d.ts.map +1 -0
- package/_types/tokens/definitions/usdb.d.ts +11 -0
- package/_types/tokens/definitions/usdb.d.ts.map +1 -0
- package/_types/tokens/definitions/usdc.d.ts +67 -0
- package/_types/tokens/definitions/usdc.d.ts.map +1 -0
- package/_types/tokens/definitions/usdce.d.ts +12 -0
- package/_types/tokens/definitions/usdce.d.ts.map +1 -0
- package/_types/tokens/definitions/usde.d.ts +11 -0
- package/_types/tokens/definitions/usde.d.ts.map +1 -0
- package/_types/tokens/definitions/usdt0.d.ts +11 -0
- package/_types/tokens/definitions/usdt0.d.ts.map +1 -0
- package/_types/tokens/definitions/wsrusd.d.ts +11 -0
- package/_types/tokens/definitions/wsrusd.d.ts.map +1 -0
- package/_types/tokens/index.d.ts +31 -0
- package/_types/tokens/index.d.ts.map +1 -0
- package/_types/utils/encoding/fromRlp.d.ts +2 -2
- package/_types/utils/encoding/fromRlp.d.ts.map +1 -1
- package/_types/utils/rpc/http.d.ts +6 -2
- package/_types/utils/rpc/http.d.ts.map +1 -1
- package/_types/utils/transaction/parseTransaction.d.ts +2 -2
- package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
- package/actions/index.ts +1 -0
- package/actions/token/approve.ts +202 -0
- package/actions/token/approveSync.ts +95 -0
- package/actions/token/getAllowance.ts +105 -0
- package/actions/token/getBalance.ts +115 -0
- package/actions/token/getMetadata.ts +98 -0
- package/actions/token/getTotalSupply.ts +97 -0
- package/actions/token/index.ts +9 -0
- package/actions/token/internal.ts +367 -0
- package/actions/token/transfer.ts +230 -0
- package/actions/token/transferSync.ts +99 -0
- package/chains/definitions/battlechain.ts +28 -0
- package/chains/definitions/marooTestnet.ts +27 -0
- package/chains/index.ts +2 -0
- package/clients/createClient.ts +90 -8
- package/clients/createPublicClient.ts +22 -4
- package/clients/createWalletClient.ts +22 -4
- package/clients/decorators/public.ts +166 -4
- package/clients/decorators/wallet.ts +242 -3
- package/clients/transports/http.ts +4 -0
- package/errors/encoding.ts +11 -0
- package/errors/request.ts +17 -0
- package/errors/transaction.ts +11 -0
- package/errors/version.ts +1 -1
- package/index.ts +7 -0
- package/package.json +6 -1
- package/tempo/Client.ts +4 -2
- package/tempo/Decorator.ts +398 -337
- package/tempo/actions/token.ts +519 -296
- package/tempo/actions/wallet.ts +3 -3
- package/tempo/internal/types.ts +19 -0
- package/tempo/internal/utils.ts +204 -0
- package/tokens/defineToken.ts +142 -0
- package/tokens/definitions/alphausd.ts +13 -0
- package/tokens/definitions/betausd.ts +13 -0
- package/tokens/definitions/brla.ts +13 -0
- package/tokens/definitions/cbbtc.ts +13 -0
- package/tokens/definitions/chfau.ts +13 -0
- package/tokens/definitions/cusd.ts +13 -0
- package/tokens/definitions/dlusd.ts +13 -0
- package/tokens/definitions/eurau.ts +13 -0
- package/tokens/definitions/eurce.ts +14 -0
- package/tokens/definitions/frxusd.ts +13 -0
- package/tokens/definitions/gbpa.ts +13 -0
- package/tokens/definitions/gusd.ts +13 -0
- package/tokens/definitions/iusd.ts +13 -0
- package/tokens/definitions/pathusd.ts +14 -0
- package/tokens/definitions/reusd.ts +13 -0
- package/tokens/definitions/rusd.ts +13 -0
- package/tokens/definitions/sbc.ts +13 -0
- package/tokens/definitions/siusd.ts +13 -0
- package/tokens/definitions/stcusd.ts +13 -0
- package/tokens/definitions/susde.ts +13 -0
- package/tokens/definitions/syrupusdc.ts +13 -0
- package/tokens/definitions/thetausd.ts +13 -0
- package/tokens/definitions/usd1.ts +13 -0
- package/tokens/definitions/usdb.ts +13 -0
- package/tokens/definitions/usdc.ts +67 -0
- package/tokens/definitions/usdce.ts +14 -0
- package/tokens/definitions/usde.ts +13 -0
- package/tokens/definitions/usdt0.ts +13 -0
- package/tokens/definitions/wsrusd.ts +13 -0
- package/tokens/index.ts +31 -0
- package/tokens/package.json +6 -0
- package/utils/encoding/fromRlp.ts +22 -3
- package/utils/rpc/http.ts +70 -2
- package/utils/transaction/parseTransaction.ts +7 -2
package/tempo/actions/token.ts
CHANGED
|
@@ -3,14 +3,20 @@ import * as Hex from 'ox/Hex'
|
|
|
3
3
|
import { TokenId, TokenRole } from 'ox/tempo'
|
|
4
4
|
import type { Account } from '../../accounts/types.js'
|
|
5
5
|
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
|
6
|
+
import { estimateContractGas } from '../../actions/public/estimateContractGas.js'
|
|
6
7
|
import { multicall } from '../../actions/public/multicall.js'
|
|
7
8
|
import type { ReadContractReturnType } from '../../actions/public/readContract.js'
|
|
8
9
|
import { readContract } from '../../actions/public/readContract.js'
|
|
10
|
+
import {
|
|
11
|
+
type SimulateContractReturnType,
|
|
12
|
+
simulateContract,
|
|
13
|
+
} from '../../actions/public/simulateContract.js'
|
|
9
14
|
import type {
|
|
10
15
|
WatchContractEventParameters,
|
|
11
16
|
WatchContractEventReturnType,
|
|
12
17
|
} from '../../actions/public/watchContractEvent.js'
|
|
13
18
|
import { watchContractEvent } from '../../actions/public/watchContractEvent.js'
|
|
19
|
+
import * as internal_Token from '../../actions/token/internal.js'
|
|
14
20
|
import { sendTransaction } from '../../actions/wallet/sendTransaction.js'
|
|
15
21
|
import {
|
|
16
22
|
type SendTransactionSyncParameters,
|
|
@@ -21,6 +27,7 @@ import { writeContract } from '../../actions/wallet/writeContract.js'
|
|
|
21
27
|
import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
|
|
22
28
|
import type { Client } from '../../clients/createClient.js'
|
|
23
29
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
30
|
+
import { AccountNotFoundError } from '../../errors/account.js'
|
|
24
31
|
import type { BaseErrorType } from '../../errors/base.js'
|
|
25
32
|
import type { Chain } from '../../types/chain.js'
|
|
26
33
|
import type { ExtractAbiItem, GetEventArgs } from '../../types/contract.js'
|
|
@@ -28,14 +35,23 @@ import type { Log, Log as viem_Log } from '../../types/log.js'
|
|
|
28
35
|
import type { Compute, OneOf, UnionOmit } from '../../types/utils.js'
|
|
29
36
|
import { encodeFunctionData } from '../../utils/abi/encodeFunctionData.js'
|
|
30
37
|
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js'
|
|
38
|
+
import { formatUnits } from '../../utils/unit/formatUnits.js'
|
|
31
39
|
import * as Abis from '../Abis.js'
|
|
32
40
|
import * as Addresses from '../Addresses.js'
|
|
33
41
|
import type {
|
|
34
42
|
GetAccountParameter,
|
|
35
43
|
ReadParameters,
|
|
44
|
+
TokenParameter,
|
|
45
|
+
TokenParameters,
|
|
36
46
|
WriteParameters,
|
|
37
47
|
} from '../internal/types.js'
|
|
38
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
defineCall,
|
|
50
|
+
findDeclaredToken,
|
|
51
|
+
pickWriteParameters,
|
|
52
|
+
resolveToken,
|
|
53
|
+
resolveTokenWithDecimals,
|
|
54
|
+
} from '../internal/utils.js'
|
|
39
55
|
import type { TransactionReceipt } from '../Transaction.js'
|
|
40
56
|
|
|
41
57
|
/**
|
|
@@ -71,27 +87,21 @@ export async function approve<
|
|
|
71
87
|
client: Client<Transport, chain, account>,
|
|
72
88
|
parameters: approve.Parameters<chain, account>,
|
|
73
89
|
): Promise<approve.ReturnValue> {
|
|
74
|
-
|
|
75
|
-
return approve.inner(writeContract, client, parameters, { ...rest, token })
|
|
90
|
+
return approve.inner(writeContract, client, parameters)
|
|
76
91
|
}
|
|
77
92
|
|
|
78
93
|
export namespace approve {
|
|
94
|
+
export type Args = {
|
|
95
|
+
/** Amount of tokens to approve, in base units or formatted decimal form. */
|
|
96
|
+
amount: internal_Token.AmountInput
|
|
97
|
+
/** Address of the spender. */
|
|
98
|
+
spender: Address
|
|
99
|
+
} & TokenParameter
|
|
79
100
|
export type Parameters<
|
|
80
101
|
chain extends Chain | undefined = Chain | undefined,
|
|
81
102
|
account extends Account | undefined = Account | undefined,
|
|
82
103
|
> = WriteParameters<chain, account> & Args
|
|
83
|
-
|
|
84
|
-
export type Args = {
|
|
85
|
-
/** Amount of tokens to approve. */
|
|
86
|
-
amount: bigint
|
|
87
|
-
/** Address of the spender. */
|
|
88
|
-
spender: Address
|
|
89
|
-
/** Address or ID of the TIP20 token. */
|
|
90
|
-
token: TokenId.TokenIdOrAddress
|
|
91
|
-
}
|
|
92
|
-
|
|
93
104
|
export type ReturnValue = WriteContractReturnType
|
|
94
|
-
|
|
95
105
|
// TODO: exhaustive error type
|
|
96
106
|
export type ErrorType = BaseErrorType
|
|
97
107
|
|
|
@@ -104,58 +114,88 @@ export namespace approve {
|
|
|
104
114
|
action: action,
|
|
105
115
|
client: Client<Transport, chain, account>,
|
|
106
116
|
parameters: approve.Parameters<chain, account>,
|
|
107
|
-
args: Args,
|
|
108
117
|
): Promise<ReturnType<action>> {
|
|
109
|
-
const call = approve.call(args)
|
|
110
118
|
return (await action(client, {
|
|
111
119
|
...parameters,
|
|
112
|
-
...call,
|
|
120
|
+
...approve.call(client, parameters as never),
|
|
113
121
|
} as never)) as never
|
|
114
122
|
}
|
|
115
123
|
|
|
116
124
|
/**
|
|
117
125
|
* Defines a call to the `approve` function.
|
|
118
126
|
*
|
|
119
|
-
* Can be passed as a parameter to
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @example
|
|
125
|
-
* ```ts
|
|
126
|
-
* import { createClient, http, walletActions } from 'viem'
|
|
127
|
-
* import { tempo } from 'viem/chains'
|
|
128
|
-
* import { Actions } from 'viem/tempo'
|
|
129
|
-
*
|
|
130
|
-
* const client = createClient({
|
|
131
|
-
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
132
|
-
* transport: http(),
|
|
133
|
-
* }).extend(walletActions)
|
|
134
|
-
*
|
|
135
|
-
* const { result } = await client.sendCalls({
|
|
136
|
-
* calls: [
|
|
137
|
-
* actions.token.approve.call({
|
|
138
|
-
* spender: '0x20c0...beef',
|
|
139
|
-
* amount: 100n,
|
|
140
|
-
* token: '0x20c0...babe',
|
|
141
|
-
* }),
|
|
142
|
-
* ]
|
|
143
|
-
* })
|
|
144
|
-
* ```
|
|
127
|
+
* Can be passed as a parameter to `estimateContractGas`, `simulateContract`,
|
|
128
|
+
* `sendCalls`, `sendTransaction` (`calls`), or `multicall`. The token is
|
|
129
|
+
* selected by `token`, which is either a TIP20 token id or a contract
|
|
130
|
+
* `address`; `amount.decimals` is inferred from the client's declared
|
|
131
|
+
* `tokens` when omitted.
|
|
145
132
|
*
|
|
146
|
-
* @param
|
|
133
|
+
* @param client - Client.
|
|
134
|
+
* @param parameters - Parameters.
|
|
147
135
|
* @returns The call.
|
|
148
136
|
*/
|
|
149
|
-
export function call
|
|
150
|
-
|
|
137
|
+
export function call<chain extends Chain | undefined>(
|
|
138
|
+
client: Client<Transport, chain>,
|
|
139
|
+
parameters: Args,
|
|
140
|
+
) {
|
|
141
|
+
const { amount, spender, token } = parameters
|
|
142
|
+
const { address, decimals } = resolveToken(client, { token })
|
|
151
143
|
return defineCall({
|
|
152
|
-
address
|
|
144
|
+
address,
|
|
153
145
|
abi: Abis.tip20,
|
|
154
146
|
functionName: 'approve',
|
|
155
|
-
args: [spender, amount],
|
|
147
|
+
args: [spender, internal_Token.toBaseUnits(amount, decimals)],
|
|
156
148
|
})
|
|
157
149
|
}
|
|
158
150
|
|
|
151
|
+
/**
|
|
152
|
+
* Estimates the gas required to approve a spender. `amount.decimals` is
|
|
153
|
+
* inferred from the client's declared `tokens` when omitted.
|
|
154
|
+
*
|
|
155
|
+
* @param client - Client.
|
|
156
|
+
* @param parameters - Parameters.
|
|
157
|
+
* @returns The gas estimate.
|
|
158
|
+
*/
|
|
159
|
+
export async function estimateGas<
|
|
160
|
+
chain extends Chain | undefined,
|
|
161
|
+
account extends Account | undefined,
|
|
162
|
+
>(
|
|
163
|
+
client: Client<Transport, chain, account>,
|
|
164
|
+
parameters: approve.Parameters<chain, account>,
|
|
165
|
+
): Promise<bigint> {
|
|
166
|
+
return estimateContractGas(client, {
|
|
167
|
+
...pickWriteParameters(parameters as never),
|
|
168
|
+
...approve.call(client, parameters as never),
|
|
169
|
+
} as never)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Simulates an approval of a spender. `amount.decimals` is inferred from
|
|
174
|
+
* the client's declared `tokens` when omitted.
|
|
175
|
+
*
|
|
176
|
+
* @param client - Client.
|
|
177
|
+
* @param parameters - Parameters.
|
|
178
|
+
* @returns The simulation result and write request.
|
|
179
|
+
*/
|
|
180
|
+
export async function simulate<
|
|
181
|
+
chain extends Chain | undefined,
|
|
182
|
+
account extends Account | undefined,
|
|
183
|
+
>(
|
|
184
|
+
client: Client<Transport, chain, account>,
|
|
185
|
+
parameters: approve.Parameters<chain, account>,
|
|
186
|
+
): Promise<SimulateContractReturnType<typeof Abis.tip20, 'approve'>> {
|
|
187
|
+
return simulateContract(client, {
|
|
188
|
+
...pickWriteParameters(parameters as never),
|
|
189
|
+
...approve.call(client, parameters as never),
|
|
190
|
+
} as never) as never
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Extracts the `Approval` event from logs.
|
|
195
|
+
*
|
|
196
|
+
* @param logs - The logs.
|
|
197
|
+
* @returns The `Approval` event.
|
|
198
|
+
*/
|
|
159
199
|
export function extractEvent(logs: Log[]) {
|
|
160
200
|
const [log] = parseEventLogs({
|
|
161
201
|
abi: Abis.tip20,
|
|
@@ -200,28 +240,29 @@ export async function approveSync<
|
|
|
200
240
|
client: Client<Transport, chain, account>,
|
|
201
241
|
parameters: approveSync.Parameters<chain, account>,
|
|
202
242
|
): Promise<approveSync.ReturnValue> {
|
|
203
|
-
const { throwOnReceiptRevert = true
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
)
|
|
243
|
+
const { amount, token, throwOnReceiptRevert = true } = parameters
|
|
244
|
+
const { decimals } = resolveToken(client, { token })
|
|
245
|
+
const resolved = internal_Token.resolveAmountDecimals(amount, decimals)
|
|
246
|
+
const receipt = await approve.inner(writeContractSync, client, {
|
|
247
|
+
...parameters,
|
|
248
|
+
throwOnReceiptRevert,
|
|
249
|
+
} as never)
|
|
210
250
|
const { args } = approve.extractEvent(receipt.logs)
|
|
211
251
|
return {
|
|
212
252
|
...args,
|
|
253
|
+
...(resolved === undefined
|
|
254
|
+
? {}
|
|
255
|
+
: { decimals: resolved, formatted: formatUnits(args.amount, resolved) }),
|
|
213
256
|
receipt,
|
|
214
257
|
} as never
|
|
215
258
|
}
|
|
216
259
|
|
|
217
260
|
export namespace approveSync {
|
|
261
|
+
export type Args = approve.Args
|
|
218
262
|
export type Parameters<
|
|
219
263
|
chain extends Chain | undefined = Chain | undefined,
|
|
220
264
|
account extends Account | undefined = Account | undefined,
|
|
221
265
|
> = approve.Parameters<chain, account>
|
|
222
|
-
|
|
223
|
-
export type Args = approve.Args
|
|
224
|
-
|
|
225
266
|
export type ReturnValue = Compute<
|
|
226
267
|
GetEventArgs<
|
|
227
268
|
typeof Abis.tip20,
|
|
@@ -231,11 +272,14 @@ export namespace approveSync {
|
|
|
231
272
|
Required: true
|
|
232
273
|
}
|
|
233
274
|
> & {
|
|
275
|
+
/** Token decimals used to derive `formatted`, if known. */
|
|
276
|
+
decimals?: number | undefined
|
|
277
|
+
/** Approved amount formatted with the token's `decimals`, if known. */
|
|
278
|
+
formatted?: string | undefined
|
|
234
279
|
/** Transaction receipt. */
|
|
235
280
|
receipt: TransactionReceipt
|
|
236
281
|
}
|
|
237
282
|
>
|
|
238
|
-
|
|
239
283
|
// TODO: exhaustive error type
|
|
240
284
|
export type ErrorType = BaseErrorType
|
|
241
285
|
}
|
|
@@ -278,20 +322,18 @@ export async function burnBlocked<
|
|
|
278
322
|
}
|
|
279
323
|
|
|
280
324
|
export namespace burnBlocked {
|
|
325
|
+
export type Args = {
|
|
326
|
+
/** Amount of tokens to burn, in base units or formatted decimal form. */
|
|
327
|
+
amount: internal_Token.AmountInput
|
|
328
|
+
/** Address to burn tokens from. */
|
|
329
|
+
from: Address
|
|
330
|
+
} & TokenParameter
|
|
331
|
+
|
|
281
332
|
export type Parameters<
|
|
282
333
|
chain extends Chain | undefined = Chain | undefined,
|
|
283
334
|
account extends Account | undefined = Account | undefined,
|
|
284
335
|
> = WriteParameters<chain, account> & Args
|
|
285
336
|
|
|
286
|
-
export type Args = {
|
|
287
|
-
/** Amount of tokens to burn. */
|
|
288
|
-
amount: bigint
|
|
289
|
-
/** Address to burn tokens from. */
|
|
290
|
-
from: Address
|
|
291
|
-
/** Address or ID of the TIP20 token. */
|
|
292
|
-
token: TokenId.TokenIdOrAddress
|
|
293
|
-
}
|
|
294
|
-
|
|
295
337
|
export type ReturnValue = WriteContractReturnType
|
|
296
338
|
|
|
297
339
|
// TODO: exhaustive error type
|
|
@@ -308,7 +350,7 @@ export namespace burnBlocked {
|
|
|
308
350
|
parameters: burnBlocked.Parameters<chain, account>,
|
|
309
351
|
): Promise<ReturnType<action>> {
|
|
310
352
|
const { amount, from, token, ...rest } = parameters
|
|
311
|
-
const call = burnBlocked.call({ amount, from, token })
|
|
353
|
+
const call = burnBlocked.call(client, { amount, from, token } as never)
|
|
312
354
|
return (await action(client, {
|
|
313
355
|
...rest,
|
|
314
356
|
...call,
|
|
@@ -336,7 +378,7 @@ export namespace burnBlocked {
|
|
|
336
378
|
*
|
|
337
379
|
* const { result } = await client.sendCalls({
|
|
338
380
|
* calls: [
|
|
339
|
-
* actions.token.burnBlocked.call({
|
|
381
|
+
* actions.token.burnBlocked.call(client, {
|
|
340
382
|
* from: '0x20c0...beef',
|
|
341
383
|
* amount: 100n,
|
|
342
384
|
* token: '0x20c0...babe',
|
|
@@ -345,16 +387,22 @@ export namespace burnBlocked {
|
|
|
345
387
|
* })
|
|
346
388
|
* ```
|
|
347
389
|
*
|
|
390
|
+
* `amount.decimals` is inferred from the client's declared `tokens` when omitted.
|
|
391
|
+
*
|
|
348
392
|
* @param args - Arguments.
|
|
349
393
|
* @returns The call.
|
|
350
394
|
*/
|
|
351
|
-
export function call
|
|
395
|
+
export function call<chain extends Chain | undefined>(
|
|
396
|
+
client: Client<Transport, chain>,
|
|
397
|
+
args: Args,
|
|
398
|
+
) {
|
|
352
399
|
const { from, amount, token } = args
|
|
400
|
+
const { address, decimals } = resolveToken(client, { token })
|
|
353
401
|
return defineCall({
|
|
354
|
-
address
|
|
402
|
+
address,
|
|
355
403
|
abi: Abis.tip20,
|
|
356
404
|
functionName: 'burnBlocked',
|
|
357
|
-
args: [from, amount],
|
|
405
|
+
args: [from, internal_Token.toBaseUnits(amount, decimals)],
|
|
358
406
|
})
|
|
359
407
|
}
|
|
360
408
|
|
|
@@ -484,20 +532,18 @@ export async function burn<
|
|
|
484
532
|
}
|
|
485
533
|
|
|
486
534
|
export namespace burn {
|
|
535
|
+
export type Args = {
|
|
536
|
+
/** Amount of tokens to burn, in base units or formatted decimal form. */
|
|
537
|
+
amount: internal_Token.AmountInput
|
|
538
|
+
/** Memo to include in the transfer. */
|
|
539
|
+
memo?: Hex.Hex | undefined
|
|
540
|
+
} & TokenParameter
|
|
541
|
+
|
|
487
542
|
export type Parameters<
|
|
488
543
|
chain extends Chain | undefined = Chain | undefined,
|
|
489
544
|
account extends Account | undefined = Account | undefined,
|
|
490
545
|
> = WriteParameters<chain, account> & Args
|
|
491
546
|
|
|
492
|
-
export type Args = {
|
|
493
|
-
/** Amount of tokens to burn. */
|
|
494
|
-
amount: bigint
|
|
495
|
-
/** Memo to include in the transfer. */
|
|
496
|
-
memo?: Hex.Hex | undefined
|
|
497
|
-
/** Address or ID of the TIP20 token. */
|
|
498
|
-
token: TokenId.TokenIdOrAddress
|
|
499
|
-
}
|
|
500
|
-
|
|
501
547
|
export type ReturnValue = WriteContractReturnType
|
|
502
548
|
|
|
503
549
|
// TODO: exhaustive error type
|
|
@@ -514,7 +560,7 @@ export namespace burn {
|
|
|
514
560
|
parameters: burn.Parameters<chain, account>,
|
|
515
561
|
): Promise<ReturnType<action>> {
|
|
516
562
|
const { amount, memo, token, ...rest } = parameters
|
|
517
|
-
const call = burn.call({ amount, memo, token })
|
|
563
|
+
const call = burn.call(client, { amount, memo, token } as never)
|
|
518
564
|
return (await action(client, {
|
|
519
565
|
...rest,
|
|
520
566
|
...call,
|
|
@@ -542,7 +588,7 @@ export namespace burn {
|
|
|
542
588
|
*
|
|
543
589
|
* const { result } = await client.sendCalls({
|
|
544
590
|
* calls: [
|
|
545
|
-
* actions.token.burn.call({
|
|
591
|
+
* actions.token.burn.call(client, {
|
|
546
592
|
* amount: 100n,
|
|
547
593
|
* token: '0x20c0...babe',
|
|
548
594
|
* }),
|
|
@@ -550,22 +596,29 @@ export namespace burn {
|
|
|
550
596
|
* })
|
|
551
597
|
* ```
|
|
552
598
|
*
|
|
599
|
+
* `amount.decimals` is inferred from the client's declared `tokens` when omitted.
|
|
600
|
+
*
|
|
553
601
|
* @param args - Arguments.
|
|
554
602
|
* @returns The call.
|
|
555
603
|
*/
|
|
556
|
-
export function call
|
|
604
|
+
export function call<chain extends Chain | undefined>(
|
|
605
|
+
client: Client<Transport, chain>,
|
|
606
|
+
args: Args,
|
|
607
|
+
) {
|
|
557
608
|
const { amount, memo, token } = args
|
|
609
|
+
const { address, decimals } = resolveToken(client, { token })
|
|
610
|
+
const value = internal_Token.toBaseUnits(amount, decimals)
|
|
558
611
|
const callArgs = memo
|
|
559
612
|
? ({
|
|
560
613
|
functionName: 'burnWithMemo',
|
|
561
|
-
args: [
|
|
614
|
+
args: [value, Hex.padLeft(memo, 32)],
|
|
562
615
|
} as const)
|
|
563
616
|
: ({
|
|
564
617
|
functionName: 'burn',
|
|
565
|
-
args: [
|
|
618
|
+
args: [value],
|
|
566
619
|
} as const)
|
|
567
620
|
return defineCall({
|
|
568
|
-
address
|
|
621
|
+
address,
|
|
569
622
|
abi: Abis.tip20,
|
|
570
623
|
...callArgs,
|
|
571
624
|
})
|
|
@@ -723,7 +776,7 @@ export namespace changeTransferPolicy {
|
|
|
723
776
|
parameters: changeTransferPolicy.Parameters<chain, account>,
|
|
724
777
|
): Promise<ReturnType<action>> {
|
|
725
778
|
const { policyId, token, ...rest } = parameters
|
|
726
|
-
const call = changeTransferPolicy.call({ policyId, token })
|
|
779
|
+
const call = changeTransferPolicy.call(client, { policyId, token })
|
|
727
780
|
return (await action(client, {
|
|
728
781
|
...rest,
|
|
729
782
|
...call,
|
|
@@ -751,7 +804,7 @@ export namespace changeTransferPolicy {
|
|
|
751
804
|
*
|
|
752
805
|
* const { result } = await client.sendCalls({
|
|
753
806
|
* calls: [
|
|
754
|
-
* actions.token.changeTransferPolicy.call({
|
|
807
|
+
* actions.token.changeTransferPolicy.call(client, {
|
|
755
808
|
* token: '0x20c0...babe',
|
|
756
809
|
* policyId: 1n,
|
|
757
810
|
* }),
|
|
@@ -762,10 +815,13 @@ export namespace changeTransferPolicy {
|
|
|
762
815
|
* @param args - Arguments.
|
|
763
816
|
* @returns The call.
|
|
764
817
|
*/
|
|
765
|
-
export function call
|
|
818
|
+
export function call<chain extends Chain | undefined>(
|
|
819
|
+
client: Client<Transport, chain>,
|
|
820
|
+
args: Args,
|
|
821
|
+
) {
|
|
766
822
|
const { token, policyId } = args
|
|
767
823
|
return defineCall({
|
|
768
|
-
address:
|
|
824
|
+
address: resolveToken(client, { token }).address,
|
|
769
825
|
abi: Abis.tip20,
|
|
770
826
|
functionName: 'changeTransferPolicyId',
|
|
771
827
|
args: [policyId],
|
|
@@ -948,7 +1004,7 @@ export namespace create {
|
|
|
948
1004
|
const admin = admin_ ? parseAccount(admin_) : undefined
|
|
949
1005
|
if (!admin) throw new Error('admin is required.')
|
|
950
1006
|
|
|
951
|
-
const call = create.call({ ...rest, admin: admin.address })
|
|
1007
|
+
const call = create.call(client, { ...rest, admin: admin.address })
|
|
952
1008
|
|
|
953
1009
|
return (await action(
|
|
954
1010
|
client as never,
|
|
@@ -982,7 +1038,7 @@ export namespace create {
|
|
|
982
1038
|
*
|
|
983
1039
|
* const { result } = await client.sendCalls({
|
|
984
1040
|
* calls: [
|
|
985
|
-
* actions.token.create.call({
|
|
1041
|
+
* actions.token.create.call(client, {
|
|
986
1042
|
* name: 'My Token',
|
|
987
1043
|
* symbol: 'MTK',
|
|
988
1044
|
* currency: 'USD',
|
|
@@ -996,7 +1052,10 @@ export namespace create {
|
|
|
996
1052
|
* @param args - Arguments.
|
|
997
1053
|
* @returns The call.
|
|
998
1054
|
*/
|
|
999
|
-
export function call
|
|
1055
|
+
export function call<chain extends Chain | undefined>(
|
|
1056
|
+
client: Client<Transport, chain>,
|
|
1057
|
+
args: Args,
|
|
1058
|
+
) {
|
|
1000
1059
|
const {
|
|
1001
1060
|
name,
|
|
1002
1061
|
symbol,
|
|
@@ -1015,7 +1074,7 @@ export namespace create {
|
|
|
1015
1074
|
name,
|
|
1016
1075
|
symbol,
|
|
1017
1076
|
currency,
|
|
1018
|
-
|
|
1077
|
+
resolveToken(client, { token: quoteToken }).address,
|
|
1019
1078
|
admin,
|
|
1020
1079
|
salt,
|
|
1021
1080
|
logoURI,
|
|
@@ -1024,7 +1083,7 @@ export namespace create {
|
|
|
1024
1083
|
name,
|
|
1025
1084
|
symbol,
|
|
1026
1085
|
currency,
|
|
1027
|
-
|
|
1086
|
+
resolveToken(client, { token: quoteToken }).address,
|
|
1028
1087
|
admin,
|
|
1029
1088
|
salt,
|
|
1030
1089
|
],
|
|
@@ -1143,63 +1202,64 @@ export namespace createSync {
|
|
|
1143
1202
|
* })
|
|
1144
1203
|
*
|
|
1145
1204
|
* const allowance = await Actions.token.getAllowance(client, {
|
|
1205
|
+
* account: '0x...',
|
|
1146
1206
|
* spender: '0x...',
|
|
1207
|
+
* token: '0x...',
|
|
1147
1208
|
* })
|
|
1148
1209
|
* ```
|
|
1149
1210
|
*
|
|
1150
1211
|
* @param client - Client.
|
|
1151
1212
|
* @param parameters - Parameters.
|
|
1152
|
-
* @returns The token allowance.
|
|
1213
|
+
* @returns The token allowance, in base units and human-readable form.
|
|
1153
1214
|
*/
|
|
1154
|
-
export async function getAllowance<
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
>(
|
|
1158
|
-
client: Client<Transport, chain, account>,
|
|
1159
|
-
parameters: getAllowance.Parameters<account>,
|
|
1215
|
+
export async function getAllowance<chain extends Chain | undefined>(
|
|
1216
|
+
client: Client<Transport, chain>,
|
|
1217
|
+
parameters: getAllowance.Parameters,
|
|
1160
1218
|
): Promise<getAllowance.ReturnValue> {
|
|
1161
|
-
const { account
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1219
|
+
const { account, decimals, spender, token, ...rest } = parameters
|
|
1220
|
+
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1221
|
+
readContract(client, {
|
|
1222
|
+
...rest,
|
|
1223
|
+
...getAllowance.call(client, { account, spender, token } as never),
|
|
1224
|
+
}),
|
|
1225
|
+
resolveTokenWithDecimals(client, {
|
|
1226
|
+
decimals,
|
|
1227
|
+
token,
|
|
1228
|
+
}),
|
|
1229
|
+
])
|
|
1230
|
+
return internal_Token.toAmount(amount, resolved)
|
|
1168
1231
|
}
|
|
1169
1232
|
|
|
1170
1233
|
export namespace getAllowance {
|
|
1171
|
-
export type Parameters<
|
|
1172
|
-
account extends Account | undefined = Account | undefined,
|
|
1173
|
-
> = ReadParameters & GetAccountParameter<account> & Omit<Args, 'account'> & {}
|
|
1174
|
-
|
|
1175
1234
|
export type Args = {
|
|
1176
|
-
/** Account
|
|
1235
|
+
/** Account that owns the tokens. */
|
|
1177
1236
|
account: Address
|
|
1178
|
-
/**
|
|
1237
|
+
/** Spender of the tokens. */
|
|
1179
1238
|
spender: Address
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
export type ReturnValue = ReadContractReturnType<
|
|
1185
|
-
typeof Abis.tip20,
|
|
1186
|
-
'allowance',
|
|
1187
|
-
never
|
|
1188
|
-
>
|
|
1239
|
+
} & TokenParameters
|
|
1240
|
+
export type Parameters = ReadParameters & Args
|
|
1241
|
+
export type ReturnValue = internal_Token.Amount
|
|
1189
1242
|
|
|
1190
1243
|
/**
|
|
1191
1244
|
* Defines a call to the `allowance` function.
|
|
1192
1245
|
*
|
|
1246
|
+
* Can be passed as a parameter to `multicall`, `simulateContract`, or any
|
|
1247
|
+
* other action that accepts a contract call. The token is selected by `token`,
|
|
1248
|
+
* which is either a TIP20 token id or a contract address.
|
|
1249
|
+
*
|
|
1250
|
+
* @param client - Client.
|
|
1193
1251
|
* @param args - Arguments.
|
|
1194
1252
|
* @returns The call.
|
|
1195
1253
|
*/
|
|
1196
|
-
export function call
|
|
1197
|
-
|
|
1254
|
+
export function call<chain extends Chain | undefined>(
|
|
1255
|
+
client: Client<Transport, chain>,
|
|
1256
|
+
args: Args,
|
|
1257
|
+
) {
|
|
1198
1258
|
return defineCall({
|
|
1199
|
-
address:
|
|
1259
|
+
address: resolveToken(client, args).address,
|
|
1200
1260
|
abi: Abis.tip20,
|
|
1201
1261
|
functionName: 'allowance',
|
|
1202
|
-
args: [account, spender],
|
|
1262
|
+
args: [args.account, args.spender],
|
|
1203
1263
|
})
|
|
1204
1264
|
}
|
|
1205
1265
|
}
|
|
@@ -1221,13 +1281,14 @@ export namespace getAllowance {
|
|
|
1221
1281
|
* })
|
|
1222
1282
|
*
|
|
1223
1283
|
* const balance = await Actions.token.getBalance(client, {
|
|
1284
|
+
* account: '0x...',
|
|
1224
1285
|
* token: '0x...',
|
|
1225
1286
|
* })
|
|
1226
1287
|
* ```
|
|
1227
1288
|
*
|
|
1228
1289
|
* @param client - Client.
|
|
1229
1290
|
* @param parameters - Parameters.
|
|
1230
|
-
* @returns The token balance.
|
|
1291
|
+
* @returns The token balance, in base units and human-readable form.
|
|
1231
1292
|
*/
|
|
1232
1293
|
export async function getBalance<
|
|
1233
1294
|
chain extends Chain | undefined,
|
|
@@ -1236,43 +1297,55 @@ export async function getBalance<
|
|
|
1236
1297
|
client: Client<Transport, chain, account>,
|
|
1237
1298
|
parameters: getBalance.Parameters<account>,
|
|
1238
1299
|
): Promise<getBalance.ReturnValue> {
|
|
1239
|
-
const {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
...rest
|
|
1244
|
-
|
|
1245
|
-
|
|
1300
|
+
const {
|
|
1301
|
+
account: account_ = client.account,
|
|
1302
|
+
decimals,
|
|
1303
|
+
token,
|
|
1304
|
+
...rest
|
|
1305
|
+
} = parameters
|
|
1306
|
+
if (!account_) throw new AccountNotFoundError()
|
|
1307
|
+
const account = parseAccount(account_).address
|
|
1308
|
+
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1309
|
+
readContract(client, {
|
|
1310
|
+
...rest,
|
|
1311
|
+
...getBalance.call(client, { account, token } as never),
|
|
1312
|
+
}),
|
|
1313
|
+
resolveTokenWithDecimals(client, {
|
|
1314
|
+
decimals,
|
|
1315
|
+
token,
|
|
1316
|
+
}),
|
|
1317
|
+
])
|
|
1318
|
+
return internal_Token.toAmount(amount, resolved)
|
|
1246
1319
|
}
|
|
1247
1320
|
|
|
1248
1321
|
export namespace getBalance {
|
|
1322
|
+
export type Args<account extends Account | undefined = Account | undefined> =
|
|
1323
|
+
GetAccountParameter<account, Account | Address> & TokenParameters
|
|
1249
1324
|
export type Parameters<
|
|
1250
1325
|
account extends Account | undefined = Account | undefined,
|
|
1251
|
-
> = ReadParameters
|
|
1252
|
-
|
|
1253
|
-
export type Args = {
|
|
1254
|
-
/** Account address. */
|
|
1255
|
-
account: Address
|
|
1256
|
-
/** Address or ID of the TIP20 token. */
|
|
1257
|
-
token: TokenId.TokenIdOrAddress
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
export type ReturnValue = ReadContractReturnType<
|
|
1261
|
-
typeof Abis.tip20,
|
|
1262
|
-
'balanceOf',
|
|
1263
|
-
never
|
|
1264
|
-
>
|
|
1326
|
+
> = Omit<ReadParameters, 'account'> & Args<account>
|
|
1327
|
+
export type ReturnValue = internal_Token.Amount
|
|
1265
1328
|
|
|
1266
1329
|
/**
|
|
1267
1330
|
* Defines a call to the `balanceOf` function.
|
|
1268
1331
|
*
|
|
1332
|
+
* Can be passed as a parameter to `multicall`, `simulateContract`, or any
|
|
1333
|
+
* other action that accepts a contract call. The token is selected by `token`,
|
|
1334
|
+
* which is either a TIP20 token id or a contract address.
|
|
1335
|
+
*
|
|
1336
|
+
* @param client - Client.
|
|
1269
1337
|
* @param args - Arguments.
|
|
1270
1338
|
* @returns The call.
|
|
1271
1339
|
*/
|
|
1272
|
-
export function call
|
|
1273
|
-
|
|
1340
|
+
export function call<
|
|
1341
|
+
chain extends Chain | undefined,
|
|
1342
|
+
account extends Account | undefined,
|
|
1343
|
+
>(client: Client<Transport, chain, account>, args: Args<account>) {
|
|
1344
|
+
const account_ = args.account ?? client.account
|
|
1345
|
+
if (!account_) throw new AccountNotFoundError()
|
|
1346
|
+
const account = parseAccount(account_).address
|
|
1274
1347
|
return defineCall({
|
|
1275
|
-
address:
|
|
1348
|
+
address: resolveToken(client, args).address,
|
|
1276
1349
|
abi: Abis.tip20,
|
|
1277
1350
|
functionName: 'balanceOf',
|
|
1278
1351
|
args: [account],
|
|
@@ -1310,10 +1383,17 @@ export async function getMetadata<chain extends Chain | undefined>(
|
|
|
1310
1383
|
parameters: getMetadata.Parameters,
|
|
1311
1384
|
): Promise<getMetadata.ReturnValue> {
|
|
1312
1385
|
const { token, ...rest } = parameters
|
|
1313
|
-
const address =
|
|
1386
|
+
const { address } = resolveToken(client, { token })
|
|
1314
1387
|
const abi = Abis.tip20
|
|
1315
1388
|
|
|
1316
|
-
|
|
1389
|
+
const declared = findDeclaredToken(client, token)
|
|
1390
|
+
const overrides = {
|
|
1391
|
+
...(declared?.decimals != null ? { decimals: declared.decimals } : {}),
|
|
1392
|
+
...(declared?.name != null ? { name: declared.name } : {}),
|
|
1393
|
+
...(declared?.symbol != null ? { symbol: declared.symbol } : {}),
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
if (TokenId.fromAddress(address) === TokenId.fromAddress(Addresses.pathUsd))
|
|
1317
1397
|
return multicall(client, {
|
|
1318
1398
|
...rest,
|
|
1319
1399
|
contracts: [
|
|
@@ -1357,6 +1437,7 @@ export async function getMetadata<chain extends Chain | undefined>(
|
|
|
1357
1437
|
decimals: unwrapMulticallResult(decimals),
|
|
1358
1438
|
logoURI: unwrapMulticallResult(logoURI, ''),
|
|
1359
1439
|
totalSupply: unwrapMulticallResult(totalSupply),
|
|
1440
|
+
...overrides,
|
|
1360
1441
|
}))
|
|
1361
1442
|
|
|
1362
1443
|
return multicall(client, {
|
|
@@ -1438,6 +1519,7 @@ export async function getMetadata<chain extends Chain | undefined>(
|
|
|
1438
1519
|
paused: unwrapMulticallResult(paused),
|
|
1439
1520
|
supplyCap: unwrapMulticallResult(supplyCap),
|
|
1440
1521
|
transferPolicyId: unwrapMulticallResult(transferPolicyId),
|
|
1522
|
+
...overrides,
|
|
1441
1523
|
}),
|
|
1442
1524
|
)
|
|
1443
1525
|
}
|
|
@@ -1467,10 +1549,7 @@ function unwrapMulticallResult<result>(
|
|
|
1467
1549
|
}
|
|
1468
1550
|
|
|
1469
1551
|
export declare namespace getMetadata {
|
|
1470
|
-
export type Parameters =
|
|
1471
|
-
/** Address or ID of the TIP20 token. */
|
|
1472
|
-
token: TokenId.TokenIdOrAddress
|
|
1473
|
-
}
|
|
1552
|
+
export type Parameters = Omit<ReadParameters, 'account'> & TokenParameter
|
|
1474
1553
|
|
|
1475
1554
|
export type ReturnValue = Compute<{
|
|
1476
1555
|
/**
|
|
@@ -1526,6 +1605,76 @@ export declare namespace getMetadata {
|
|
|
1526
1605
|
}>
|
|
1527
1606
|
}
|
|
1528
1607
|
|
|
1608
|
+
/**
|
|
1609
|
+
* Gets the total supply of a TIP20 token.
|
|
1610
|
+
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* ```ts
|
|
1613
|
+
* import { createClient, http } from 'viem'
|
|
1614
|
+
* import { tempo } from 'viem/chains'
|
|
1615
|
+
* import { Actions } from 'viem/tempo'
|
|
1616
|
+
*
|
|
1617
|
+
* const client = createClient({
|
|
1618
|
+
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
1619
|
+
* transport: http(),
|
|
1620
|
+
* })
|
|
1621
|
+
*
|
|
1622
|
+
* const totalSupply = await Actions.token.getTotalSupply(client, {
|
|
1623
|
+
* token: '0x...',
|
|
1624
|
+
* })
|
|
1625
|
+
* ```
|
|
1626
|
+
*
|
|
1627
|
+
* @param client - Client.
|
|
1628
|
+
* @param parameters - Parameters.
|
|
1629
|
+
* @returns The token total supply, in base units and human-readable form.
|
|
1630
|
+
*/
|
|
1631
|
+
export async function getTotalSupply<chain extends Chain | undefined>(
|
|
1632
|
+
client: Client<Transport, chain>,
|
|
1633
|
+
parameters: getTotalSupply.Parameters,
|
|
1634
|
+
): Promise<getTotalSupply.ReturnValue> {
|
|
1635
|
+
const { decimals, token, ...rest } = parameters
|
|
1636
|
+
const [amount, { decimals: resolved }] = await Promise.all([
|
|
1637
|
+
readContract(client, {
|
|
1638
|
+
...rest,
|
|
1639
|
+
...getTotalSupply.call(client, { token } as never),
|
|
1640
|
+
}),
|
|
1641
|
+
resolveTokenWithDecimals(client, {
|
|
1642
|
+
decimals,
|
|
1643
|
+
token,
|
|
1644
|
+
}),
|
|
1645
|
+
])
|
|
1646
|
+
return internal_Token.toAmount(amount, resolved)
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
export namespace getTotalSupply {
|
|
1650
|
+
export type Args = TokenParameters
|
|
1651
|
+
export type Parameters = Omit<ReadParameters, 'account'> & Args
|
|
1652
|
+
export type ReturnValue = internal_Token.Amount
|
|
1653
|
+
|
|
1654
|
+
/**
|
|
1655
|
+
* Defines a call to the `totalSupply` function.
|
|
1656
|
+
*
|
|
1657
|
+
* Can be passed as a parameter to `multicall`, `simulateContract`, or any
|
|
1658
|
+
* other action that accepts a contract call. The token is selected by `token`,
|
|
1659
|
+
* which is either a TIP20 token id or a contract address.
|
|
1660
|
+
*
|
|
1661
|
+
* @param client - Client.
|
|
1662
|
+
* @param args - Arguments.
|
|
1663
|
+
* @returns The call.
|
|
1664
|
+
*/
|
|
1665
|
+
export function call<chain extends Chain | undefined>(
|
|
1666
|
+
client: Client<Transport, chain>,
|
|
1667
|
+
args: Args,
|
|
1668
|
+
) {
|
|
1669
|
+
return defineCall({
|
|
1670
|
+
address: resolveToken(client, args).address,
|
|
1671
|
+
abi: Abis.tip20,
|
|
1672
|
+
args: [],
|
|
1673
|
+
functionName: 'totalSupply',
|
|
1674
|
+
})
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1529
1678
|
/**
|
|
1530
1679
|
* Gets the admin role for a specific role in a TIP20 token.
|
|
1531
1680
|
*
|
|
@@ -1556,7 +1705,7 @@ export async function getRoleAdmin<chain extends Chain | undefined>(
|
|
|
1556
1705
|
): Promise<getRoleAdmin.ReturnValue> {
|
|
1557
1706
|
return readContract(client, {
|
|
1558
1707
|
...parameters,
|
|
1559
|
-
...getRoleAdmin.call(parameters),
|
|
1708
|
+
...getRoleAdmin.call(client, parameters),
|
|
1560
1709
|
})
|
|
1561
1710
|
}
|
|
1562
1711
|
|
|
@@ -1582,10 +1731,13 @@ export namespace getRoleAdmin {
|
|
|
1582
1731
|
* @param args - Arguments.
|
|
1583
1732
|
* @returns The call.
|
|
1584
1733
|
*/
|
|
1585
|
-
export function call
|
|
1734
|
+
export function call<chain extends Chain | undefined>(
|
|
1735
|
+
client: Client<Transport, chain>,
|
|
1736
|
+
args: Args,
|
|
1737
|
+
) {
|
|
1586
1738
|
const { role, token } = args
|
|
1587
1739
|
return defineCall({
|
|
1588
|
-
address:
|
|
1740
|
+
address: resolveToken(client, { token }).address,
|
|
1589
1741
|
abi: Abis.tip20,
|
|
1590
1742
|
functionName: 'getRoleAdmin',
|
|
1591
1743
|
args: [TokenRole.serialize(role)],
|
|
@@ -1630,7 +1782,7 @@ export async function hasRole<
|
|
|
1630
1782
|
if (!address) throw new Error('account is required.')
|
|
1631
1783
|
return readContract(client, {
|
|
1632
1784
|
...parameters,
|
|
1633
|
-
...hasRole.call({ ...parameters, account: address }),
|
|
1785
|
+
...hasRole.call(client, { ...parameters, account: address }),
|
|
1634
1786
|
})
|
|
1635
1787
|
}
|
|
1636
1788
|
|
|
@@ -1660,10 +1812,13 @@ export namespace hasRole {
|
|
|
1660
1812
|
* @param args - Arguments.
|
|
1661
1813
|
* @returns The call.
|
|
1662
1814
|
*/
|
|
1663
|
-
export function call
|
|
1815
|
+
export function call<chain extends Chain | undefined>(
|
|
1816
|
+
client: Client<Transport, chain>,
|
|
1817
|
+
args: Args,
|
|
1818
|
+
) {
|
|
1664
1819
|
const { account, role, token } = args
|
|
1665
1820
|
return defineCall({
|
|
1666
|
-
address:
|
|
1821
|
+
address: resolveToken(client, { token }).address,
|
|
1667
1822
|
abi: Abis.tip20,
|
|
1668
1823
|
functionName: 'hasRole',
|
|
1669
1824
|
args: [account, TokenRole.serialize(role)],
|
|
@@ -1745,7 +1900,7 @@ export namespace grantRoles {
|
|
|
1745
1900
|
return (await action(client, {
|
|
1746
1901
|
...parameters,
|
|
1747
1902
|
calls: parameters.roles.map((role) => {
|
|
1748
|
-
const call = grantRoles.call({ ...parameters, role })
|
|
1903
|
+
const call = grantRoles.call(client, { ...parameters, role })
|
|
1749
1904
|
return {
|
|
1750
1905
|
...call,
|
|
1751
1906
|
data: encodeFunctionData(call),
|
|
@@ -1775,7 +1930,7 @@ export namespace grantRoles {
|
|
|
1775
1930
|
*
|
|
1776
1931
|
* const { result } = await client.sendCalls({
|
|
1777
1932
|
* calls: [
|
|
1778
|
-
* actions.token.grantRoles.call({
|
|
1933
|
+
* actions.token.grantRoles.call(client, {
|
|
1779
1934
|
* token: '0x20c0...babe',
|
|
1780
1935
|
* to: '0x20c0...beef',
|
|
1781
1936
|
* role: 'issuer',
|
|
@@ -1787,11 +1942,14 @@ export namespace grantRoles {
|
|
|
1787
1942
|
* @param args - Arguments.
|
|
1788
1943
|
* @returns The call.
|
|
1789
1944
|
*/
|
|
1790
|
-
export function call
|
|
1945
|
+
export function call<chain extends Chain | undefined>(
|
|
1946
|
+
client: Client<Transport, chain>,
|
|
1947
|
+
args: Args,
|
|
1948
|
+
) {
|
|
1791
1949
|
const { token, to, role } = args
|
|
1792
1950
|
const roleHash = TokenRole.serialize(role)
|
|
1793
1951
|
return defineCall({
|
|
1794
|
-
address:
|
|
1952
|
+
address: resolveToken(client, { token }).address,
|
|
1795
1953
|
abi: Abis.tip20,
|
|
1796
1954
|
functionName: 'grantRole',
|
|
1797
1955
|
args: [roleHash, to],
|
|
@@ -1922,21 +2080,19 @@ export async function mint<
|
|
|
1922
2080
|
}
|
|
1923
2081
|
|
|
1924
2082
|
export namespace mint {
|
|
1925
|
-
export type Parameters<
|
|
1926
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
1927
|
-
account extends Account | undefined = Account | undefined,
|
|
1928
|
-
> = WriteParameters<chain, account> & Args
|
|
1929
|
-
|
|
1930
2083
|
export type Args = {
|
|
1931
|
-
/** Amount of tokens to mint. */
|
|
1932
|
-
amount:
|
|
2084
|
+
/** Amount of tokens to mint, in base units or formatted decimal form. */
|
|
2085
|
+
amount: internal_Token.AmountInput
|
|
1933
2086
|
/** Memo to include in the mint. */
|
|
1934
2087
|
memo?: Hex.Hex | undefined
|
|
1935
2088
|
/** Address to mint tokens to. */
|
|
1936
2089
|
to: Address
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2090
|
+
} & TokenParameter
|
|
2091
|
+
|
|
2092
|
+
export type Parameters<
|
|
2093
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
2094
|
+
account extends Account | undefined = Account | undefined,
|
|
2095
|
+
> = WriteParameters<chain, account> & Args
|
|
1940
2096
|
|
|
1941
2097
|
export type ReturnValue = WriteContractReturnType
|
|
1942
2098
|
|
|
@@ -1951,11 +2107,12 @@ export namespace mint {
|
|
|
1951
2107
|
>(
|
|
1952
2108
|
action: action,
|
|
1953
2109
|
client: Client<Transport, chain, account>,
|
|
1954
|
-
parameters:
|
|
2110
|
+
parameters: mint.Parameters<chain, account>,
|
|
1955
2111
|
): Promise<ReturnType<action>> {
|
|
1956
|
-
const
|
|
2112
|
+
const { amount, memo, to, token, ...rest } = parameters
|
|
2113
|
+
const call = mint.call(client, { amount, memo, to, token } as never)
|
|
1957
2114
|
return (await action(client, {
|
|
1958
|
-
...
|
|
2115
|
+
...rest,
|
|
1959
2116
|
...call,
|
|
1960
2117
|
} as never)) as never
|
|
1961
2118
|
}
|
|
@@ -1981,7 +2138,7 @@ export namespace mint {
|
|
|
1981
2138
|
*
|
|
1982
2139
|
* const { result } = await client.sendCalls({
|
|
1983
2140
|
* calls: [
|
|
1984
|
-
* actions.token.mint.call({
|
|
2141
|
+
* actions.token.mint.call(client, {
|
|
1985
2142
|
* to: '0x20c0...beef',
|
|
1986
2143
|
* amount: 100n,
|
|
1987
2144
|
* token: '0x20c0...babe',
|
|
@@ -1990,22 +2147,29 @@ export namespace mint {
|
|
|
1990
2147
|
* })
|
|
1991
2148
|
* ```
|
|
1992
2149
|
*
|
|
2150
|
+
* `amount.decimals` is inferred from the client's declared `tokens` when omitted.
|
|
2151
|
+
*
|
|
1993
2152
|
* @param args - Arguments.
|
|
1994
2153
|
* @returns The call.
|
|
1995
2154
|
*/
|
|
1996
|
-
export function call
|
|
2155
|
+
export function call<chain extends Chain | undefined>(
|
|
2156
|
+
client: Client<Transport, chain>,
|
|
2157
|
+
args: Args,
|
|
2158
|
+
) {
|
|
1997
2159
|
const { to, amount, memo, token } = args
|
|
2160
|
+
const { address, decimals } = resolveToken(client, { token })
|
|
2161
|
+
const value = internal_Token.toBaseUnits(amount, decimals)
|
|
1998
2162
|
const callArgs = memo
|
|
1999
2163
|
? ({
|
|
2000
2164
|
functionName: 'mintWithMemo',
|
|
2001
|
-
args: [to,
|
|
2165
|
+
args: [to, value, Hex.padLeft(memo, 32)],
|
|
2002
2166
|
} as const)
|
|
2003
2167
|
: ({
|
|
2004
2168
|
functionName: 'mint',
|
|
2005
|
-
args: [to,
|
|
2169
|
+
args: [to, value],
|
|
2006
2170
|
} as const)
|
|
2007
2171
|
return defineCall({
|
|
2008
|
-
address
|
|
2172
|
+
address,
|
|
2009
2173
|
abi: Abis.tip20,
|
|
2010
2174
|
...callArgs,
|
|
2011
2175
|
})
|
|
@@ -2161,7 +2325,7 @@ export namespace pause {
|
|
|
2161
2325
|
parameters: pause.Parameters<chain, account>,
|
|
2162
2326
|
): Promise<ReturnType<action>> {
|
|
2163
2327
|
const { token, ...rest } = parameters
|
|
2164
|
-
const call = pause.call({ token })
|
|
2328
|
+
const call = pause.call(client, { token })
|
|
2165
2329
|
return (await action(client, {
|
|
2166
2330
|
...rest,
|
|
2167
2331
|
...call,
|
|
@@ -2189,7 +2353,7 @@ export namespace pause {
|
|
|
2189
2353
|
*
|
|
2190
2354
|
* const { result } = await client.sendCalls({
|
|
2191
2355
|
* calls: [
|
|
2192
|
-
* actions.token.pause.call({
|
|
2356
|
+
* actions.token.pause.call(client, {
|
|
2193
2357
|
* token: '0x20c0...babe',
|
|
2194
2358
|
* }),
|
|
2195
2359
|
* ]
|
|
@@ -2199,10 +2363,13 @@ export namespace pause {
|
|
|
2199
2363
|
* @param args - Arguments.
|
|
2200
2364
|
* @returns The call.
|
|
2201
2365
|
*/
|
|
2202
|
-
export function call
|
|
2366
|
+
export function call<chain extends Chain | undefined>(
|
|
2367
|
+
client: Client<Transport, chain>,
|
|
2368
|
+
args: Args,
|
|
2369
|
+
) {
|
|
2203
2370
|
const { token } = args
|
|
2204
2371
|
return defineCall({
|
|
2205
|
-
address:
|
|
2372
|
+
address: resolveToken(client, { token }).address,
|
|
2206
2373
|
abi: Abis.tip20,
|
|
2207
2374
|
functionName: 'pause',
|
|
2208
2375
|
args: [],
|
|
@@ -2361,7 +2528,7 @@ export namespace renounceRoles {
|
|
|
2361
2528
|
return (await action(client, {
|
|
2362
2529
|
...parameters,
|
|
2363
2530
|
calls: parameters.roles.map((role) => {
|
|
2364
|
-
const call = renounceRoles.call({ ...parameters, role })
|
|
2531
|
+
const call = renounceRoles.call(client, { ...parameters, role })
|
|
2365
2532
|
return {
|
|
2366
2533
|
...call,
|
|
2367
2534
|
data: encodeFunctionData(call),
|
|
@@ -2391,7 +2558,7 @@ export namespace renounceRoles {
|
|
|
2391
2558
|
*
|
|
2392
2559
|
* const { result } = await client.sendCalls({
|
|
2393
2560
|
* calls: [
|
|
2394
|
-
* actions.token.renounceRoles.call({
|
|
2561
|
+
* actions.token.renounceRoles.call(client, {
|
|
2395
2562
|
* token: '0x20c0...babe',
|
|
2396
2563
|
* role: 'issuer',
|
|
2397
2564
|
* }),
|
|
@@ -2402,11 +2569,14 @@ export namespace renounceRoles {
|
|
|
2402
2569
|
* @param args - Arguments.
|
|
2403
2570
|
* @returns The call.
|
|
2404
2571
|
*/
|
|
2405
|
-
export function call
|
|
2572
|
+
export function call<chain extends Chain | undefined>(
|
|
2573
|
+
client: Client<Transport, chain>,
|
|
2574
|
+
args: Args,
|
|
2575
|
+
) {
|
|
2406
2576
|
const { token, role } = args
|
|
2407
2577
|
const roleHash = TokenRole.serialize(role)
|
|
2408
2578
|
return defineCall({
|
|
2409
|
-
address:
|
|
2579
|
+
address: resolveToken(client, { token }).address,
|
|
2410
2580
|
abi: Abis.tip20,
|
|
2411
2581
|
functionName: 'renounceRole',
|
|
2412
2582
|
args: [roleHash],
|
|
@@ -2573,7 +2743,7 @@ export namespace revokeRoles {
|
|
|
2573
2743
|
return (await action(client, {
|
|
2574
2744
|
...rest,
|
|
2575
2745
|
calls: parameters.roles.map((role) => {
|
|
2576
|
-
const call = revokeRoles.call({ ...parameters, role })
|
|
2746
|
+
const call = revokeRoles.call(client, { ...parameters, role })
|
|
2577
2747
|
return {
|
|
2578
2748
|
...call,
|
|
2579
2749
|
data: encodeFunctionData(call),
|
|
@@ -2603,7 +2773,7 @@ export namespace revokeRoles {
|
|
|
2603
2773
|
*
|
|
2604
2774
|
* const { result } = await client.sendCalls({
|
|
2605
2775
|
* calls: [
|
|
2606
|
-
* actions.token.revokeRoles.call({
|
|
2776
|
+
* actions.token.revokeRoles.call(client, {
|
|
2607
2777
|
* token: '0x20c0...babe',
|
|
2608
2778
|
* from: '0x20c0...beef',
|
|
2609
2779
|
* role: 'issuer',
|
|
@@ -2615,11 +2785,14 @@ export namespace revokeRoles {
|
|
|
2615
2785
|
* @param args - Arguments.
|
|
2616
2786
|
* @returns The call.
|
|
2617
2787
|
*/
|
|
2618
|
-
export function call
|
|
2788
|
+
export function call<chain extends Chain | undefined>(
|
|
2789
|
+
client: Client<Transport, chain>,
|
|
2790
|
+
args: Args,
|
|
2791
|
+
) {
|
|
2619
2792
|
const { token, from, role } = args
|
|
2620
2793
|
const roleHash = TokenRole.serialize(role)
|
|
2621
2794
|
return defineCall({
|
|
2622
|
-
address:
|
|
2795
|
+
address: resolveToken(client, { token }).address,
|
|
2623
2796
|
abi: Abis.tip20,
|
|
2624
2797
|
functionName: 'revokeRole',
|
|
2625
2798
|
args: [roleHash, from],
|
|
@@ -2777,7 +2950,7 @@ export namespace setSupplyCap {
|
|
|
2777
2950
|
parameters: setSupplyCap.Parameters<chain, account>,
|
|
2778
2951
|
): Promise<ReturnType<action>> {
|
|
2779
2952
|
const { supplyCap, token, ...rest } = parameters
|
|
2780
|
-
const call = setSupplyCap.call({ supplyCap, token })
|
|
2953
|
+
const call = setSupplyCap.call(client, { supplyCap, token })
|
|
2781
2954
|
return (await action(client, {
|
|
2782
2955
|
...rest,
|
|
2783
2956
|
...call,
|
|
@@ -2805,7 +2978,7 @@ export namespace setSupplyCap {
|
|
|
2805
2978
|
*
|
|
2806
2979
|
* const { result } = await client.sendCalls({
|
|
2807
2980
|
* calls: [
|
|
2808
|
-
* actions.token.setSupplyCap.call({
|
|
2981
|
+
* actions.token.setSupplyCap.call(client, {
|
|
2809
2982
|
* token: '0x20c0...babe',
|
|
2810
2983
|
* supplyCap: 1000000n,
|
|
2811
2984
|
* }),
|
|
@@ -2816,10 +2989,13 @@ export namespace setSupplyCap {
|
|
|
2816
2989
|
* @param args - Arguments.
|
|
2817
2990
|
* @returns The call.
|
|
2818
2991
|
*/
|
|
2819
|
-
export function call
|
|
2992
|
+
export function call<chain extends Chain | undefined>(
|
|
2993
|
+
client: Client<Transport, chain>,
|
|
2994
|
+
args: Args,
|
|
2995
|
+
) {
|
|
2820
2996
|
const { token, supplyCap } = args
|
|
2821
2997
|
return defineCall({
|
|
2822
|
-
address:
|
|
2998
|
+
address: resolveToken(client, { token }).address,
|
|
2823
2999
|
abi: Abis.tip20,
|
|
2824
3000
|
functionName: 'setSupplyCap',
|
|
2825
3001
|
args: [supplyCap],
|
|
@@ -2976,7 +3152,7 @@ export namespace setRoleAdmin {
|
|
|
2976
3152
|
parameters: setRoleAdmin.Parameters<chain, account>,
|
|
2977
3153
|
): Promise<ReturnType<action>> {
|
|
2978
3154
|
const { adminRole, role, token, ...rest } = parameters
|
|
2979
|
-
const call = setRoleAdmin.call({ adminRole, role, token })
|
|
3155
|
+
const call = setRoleAdmin.call(client, { adminRole, role, token })
|
|
2980
3156
|
return (await action(client, {
|
|
2981
3157
|
...rest,
|
|
2982
3158
|
...call,
|
|
@@ -3004,7 +3180,7 @@ export namespace setRoleAdmin {
|
|
|
3004
3180
|
*
|
|
3005
3181
|
* const { result } = await client.sendCalls({
|
|
3006
3182
|
* calls: [
|
|
3007
|
-
* actions.token.setRoleAdmin.call({
|
|
3183
|
+
* actions.token.setRoleAdmin.call(client, {
|
|
3008
3184
|
* token: '0x20c0...babe',
|
|
3009
3185
|
* role: 'issuer',
|
|
3010
3186
|
* adminRole: 'admin',
|
|
@@ -3016,12 +3192,15 @@ export namespace setRoleAdmin {
|
|
|
3016
3192
|
* @param args - Arguments.
|
|
3017
3193
|
* @returns The call.
|
|
3018
3194
|
*/
|
|
3019
|
-
export function call
|
|
3195
|
+
export function call<chain extends Chain | undefined>(
|
|
3196
|
+
client: Client<Transport, chain>,
|
|
3197
|
+
args: Args,
|
|
3198
|
+
) {
|
|
3020
3199
|
const { token, role, adminRole } = args
|
|
3021
3200
|
const roleHash = TokenRole.serialize(role)
|
|
3022
3201
|
const adminRoleHash = TokenRole.serialize(adminRole)
|
|
3023
3202
|
return defineCall({
|
|
3024
|
-
address:
|
|
3203
|
+
address: resolveToken(client, { token }).address,
|
|
3025
3204
|
abi: Abis.tip20,
|
|
3026
3205
|
functionName: 'setRoleAdmin',
|
|
3027
3206
|
args: [roleHash, adminRoleHash],
|
|
@@ -3148,26 +3327,21 @@ export async function transfer<
|
|
|
3148
3327
|
}
|
|
3149
3328
|
|
|
3150
3329
|
export namespace transfer {
|
|
3151
|
-
export type Parameters<
|
|
3152
|
-
chain extends Chain | undefined = Chain | undefined,
|
|
3153
|
-
account extends Account | undefined = Account | undefined,
|
|
3154
|
-
> = WriteParameters<chain, account> & Args
|
|
3155
|
-
|
|
3156
3330
|
export type Args = {
|
|
3157
|
-
/** Amount of tokens to transfer. */
|
|
3158
|
-
amount:
|
|
3159
|
-
/** Address to transfer tokens from. */
|
|
3331
|
+
/** Amount of tokens to transfer, in base units or formatted decimal form. */
|
|
3332
|
+
amount: internal_Token.AmountInput
|
|
3333
|
+
/** Address to transfer tokens from (uses an allowance via `transferFrom`). */
|
|
3160
3334
|
from?: Address | undefined
|
|
3161
3335
|
/** Memo to include in the transfer. */
|
|
3162
3336
|
memo?: Hex.Hex | undefined
|
|
3163
|
-
/** Address or ID of the TIP20 token. */
|
|
3164
|
-
token: TokenId.TokenIdOrAddress
|
|
3165
3337
|
/** Address to transfer tokens to. */
|
|
3166
3338
|
to: Address
|
|
3167
|
-
}
|
|
3168
|
-
|
|
3339
|
+
} & TokenParameter
|
|
3340
|
+
export type Parameters<
|
|
3341
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
3342
|
+
account extends Account | undefined = Account | undefined,
|
|
3343
|
+
> = WriteParameters<chain, account> & Args
|
|
3169
3344
|
export type ReturnValue = WriteContractReturnType
|
|
3170
|
-
|
|
3171
3345
|
// TODO: exhaustive error type
|
|
3172
3346
|
export type ErrorType = BaseErrorType
|
|
3173
3347
|
|
|
@@ -3181,82 +3355,113 @@ export namespace transfer {
|
|
|
3181
3355
|
client: Client<Transport, chain, account>,
|
|
3182
3356
|
parameters: transfer.Parameters<chain, account>,
|
|
3183
3357
|
): Promise<ReturnType<action>> {
|
|
3184
|
-
const { amount, from, memo, token, to, ...rest } = parameters
|
|
3185
|
-
const call = transfer.call({ amount, from, memo, token, to })
|
|
3186
3358
|
return (await action(client, {
|
|
3187
|
-
...
|
|
3188
|
-
...call,
|
|
3359
|
+
...parameters,
|
|
3360
|
+
...transfer.call(client, parameters as never),
|
|
3189
3361
|
} as never)) as never
|
|
3190
3362
|
}
|
|
3191
3363
|
|
|
3192
3364
|
/**
|
|
3193
|
-
* Defines a call to the `transfer`, `transferFrom`, `transferWithMemo`, or
|
|
3194
|
-
*
|
|
3195
|
-
* Can be passed as a parameter to:
|
|
3196
|
-
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
|
|
3197
|
-
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
|
|
3198
|
-
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
|
|
3365
|
+
* Defines a call to the `transfer`, `transferFrom`, `transferWithMemo`, or
|
|
3366
|
+
* `transferFromWithMemo` function.
|
|
3199
3367
|
*
|
|
3200
|
-
*
|
|
3201
|
-
*
|
|
3202
|
-
*
|
|
3203
|
-
*
|
|
3204
|
-
*
|
|
3205
|
-
*
|
|
3206
|
-
* const client = createClient({
|
|
3207
|
-
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
|
|
3208
|
-
* transport: http(),
|
|
3209
|
-
* }).extend(walletActions)
|
|
3368
|
+
* Can be passed as a parameter to `estimateContractGas`, `simulateContract`,
|
|
3369
|
+
* `sendCalls`, `sendTransaction` (`calls`), or `multicall`. The token is
|
|
3370
|
+
* selected by `token`, which is either a TIP20 token id or a contract
|
|
3371
|
+
* `address`; `amount.decimals` is inferred from the client's declared
|
|
3372
|
+
* `tokens` when omitted.
|
|
3210
3373
|
*
|
|
3211
|
-
*
|
|
3212
|
-
*
|
|
3213
|
-
* actions.token.transfer.call({
|
|
3214
|
-
* to: '0x20c0...beef',
|
|
3215
|
-
* amount: 100n,
|
|
3216
|
-
* token: '0x20c0...babe',
|
|
3217
|
-
* }),
|
|
3218
|
-
* ]
|
|
3219
|
-
* })
|
|
3220
|
-
* ```
|
|
3221
|
-
*
|
|
3222
|
-
* @param args - Arguments.
|
|
3374
|
+
* @param client - Client.
|
|
3375
|
+
* @param parameters - Parameters.
|
|
3223
3376
|
* @returns The call.
|
|
3224
3377
|
*/
|
|
3225
|
-
export function call
|
|
3226
|
-
|
|
3378
|
+
export function call<chain extends Chain | undefined>(
|
|
3379
|
+
client: Client<Transport, chain>,
|
|
3380
|
+
parameters: Args,
|
|
3381
|
+
) {
|
|
3382
|
+
const { from, memo, to, token } = parameters
|
|
3383
|
+
const { address, decimals } = resolveToken(client, { token })
|
|
3384
|
+
const value = internal_Token.toBaseUnits(parameters.amount, decimals)
|
|
3227
3385
|
const callArgs = (() => {
|
|
3228
3386
|
if (memo && from)
|
|
3229
3387
|
return {
|
|
3230
3388
|
functionName: 'transferFromWithMemo',
|
|
3231
|
-
args: [from, to,
|
|
3389
|
+
args: [from, to, value, Hex.padLeft(memo, 32)],
|
|
3232
3390
|
} as const
|
|
3233
3391
|
if (memo)
|
|
3234
3392
|
return {
|
|
3235
3393
|
functionName: 'transferWithMemo',
|
|
3236
|
-
args: [to,
|
|
3394
|
+
args: [to, value, Hex.padLeft(memo, 32)],
|
|
3237
3395
|
} as const
|
|
3238
3396
|
if (from)
|
|
3239
3397
|
return {
|
|
3240
3398
|
functionName: 'transferFrom',
|
|
3241
|
-
args: [from, to,
|
|
3399
|
+
args: [from, to, value],
|
|
3242
3400
|
} as const
|
|
3243
3401
|
return {
|
|
3244
3402
|
functionName: 'transfer',
|
|
3245
|
-
args: [to,
|
|
3403
|
+
args: [to, value],
|
|
3246
3404
|
} as const
|
|
3247
3405
|
})()
|
|
3248
3406
|
return defineCall({
|
|
3249
|
-
address
|
|
3407
|
+
address,
|
|
3250
3408
|
abi: Abis.tip20,
|
|
3251
3409
|
...callArgs,
|
|
3252
3410
|
})
|
|
3253
3411
|
}
|
|
3254
3412
|
|
|
3255
3413
|
/**
|
|
3256
|
-
*
|
|
3414
|
+
* Estimates the gas required to transfer TIP20 tokens. `amount.decimals` is
|
|
3415
|
+
* inferred from the client's declared `tokens` when omitted.
|
|
3416
|
+
*
|
|
3417
|
+
* @param client - Client.
|
|
3418
|
+
* @param parameters - Parameters.
|
|
3419
|
+
* @returns The gas estimate.
|
|
3420
|
+
*/
|
|
3421
|
+
export async function estimateGas<
|
|
3422
|
+
chain extends Chain | undefined,
|
|
3423
|
+
account extends Account | undefined,
|
|
3424
|
+
>(
|
|
3425
|
+
client: Client<Transport, chain, account>,
|
|
3426
|
+
parameters: transfer.Parameters<chain, account>,
|
|
3427
|
+
): Promise<bigint> {
|
|
3428
|
+
return estimateContractGas(client, {
|
|
3429
|
+
...pickWriteParameters(parameters as never),
|
|
3430
|
+
...transfer.call(client, parameters as never),
|
|
3431
|
+
} as never)
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
/**
|
|
3435
|
+
* Simulates a transfer of TIP20 tokens. `amount.decimals` is inferred from
|
|
3436
|
+
* the client's declared `tokens` when omitted.
|
|
3437
|
+
*
|
|
3438
|
+
* @param client - Client.
|
|
3439
|
+
* @param parameters - Parameters.
|
|
3440
|
+
* @returns The simulation result and write request.
|
|
3441
|
+
*/
|
|
3442
|
+
export async function simulate<
|
|
3443
|
+
chain extends Chain | undefined,
|
|
3444
|
+
account extends Account | undefined,
|
|
3445
|
+
>(
|
|
3446
|
+
client: Client<Transport, chain, account>,
|
|
3447
|
+
parameters: transfer.Parameters<chain, account>,
|
|
3448
|
+
): Promise<
|
|
3449
|
+
SimulateContractReturnType<
|
|
3450
|
+
typeof Abis.tip20,
|
|
3451
|
+
'transfer' | 'transferFrom' | 'transferWithMemo' | 'transferFromWithMemo'
|
|
3452
|
+
>
|
|
3453
|
+
> {
|
|
3454
|
+
return simulateContract(client, {
|
|
3455
|
+
...pickWriteParameters(parameters as never),
|
|
3456
|
+
...transfer.call(client, parameters as never),
|
|
3457
|
+
} as never) as never
|
|
3458
|
+
}
|
|
3459
|
+
|
|
3460
|
+
/**
|
|
3461
|
+
* Extracts the `Transfer` event from logs.
|
|
3257
3462
|
*
|
|
3258
3463
|
* @param logs - Logs.
|
|
3259
|
-
* @returns The event.
|
|
3464
|
+
* @returns The `Transfer` event.
|
|
3260
3465
|
*/
|
|
3261
3466
|
export function extractEvent(logs: Log[]) {
|
|
3262
3467
|
const [log] = parseEventLogs({
|
|
@@ -3302,34 +3507,43 @@ export async function transferSync<
|
|
|
3302
3507
|
client: Client<Transport, chain, account>,
|
|
3303
3508
|
parameters: transferSync.Parameters<chain, account>,
|
|
3304
3509
|
): Promise<transferSync.ReturnValue> {
|
|
3305
|
-
const { throwOnReceiptRevert = true
|
|
3510
|
+
const { amount, token, throwOnReceiptRevert = true } = parameters
|
|
3511
|
+
const { decimals } = resolveToken(client, { token })
|
|
3512
|
+
const resolved = internal_Token.resolveAmountDecimals(amount, decimals)
|
|
3306
3513
|
const receipt = await transfer.inner(writeContractSync, client, {
|
|
3307
|
-
...
|
|
3514
|
+
...parameters,
|
|
3308
3515
|
throwOnReceiptRevert,
|
|
3309
3516
|
} as never)
|
|
3310
3517
|
const { args } = transfer.extractEvent(receipt.logs)
|
|
3311
3518
|
return {
|
|
3312
3519
|
...args,
|
|
3520
|
+
...(resolved === undefined
|
|
3521
|
+
? {}
|
|
3522
|
+
: { decimals: resolved, formatted: formatUnits(args.amount, resolved) }),
|
|
3313
3523
|
receipt,
|
|
3314
3524
|
} as never
|
|
3315
3525
|
}
|
|
3316
3526
|
|
|
3317
3527
|
export namespace transferSync {
|
|
3528
|
+
export type Args = transfer.Args
|
|
3318
3529
|
export type Parameters<
|
|
3319
3530
|
chain extends Chain | undefined = Chain | undefined,
|
|
3320
3531
|
account extends Account | undefined = Account | undefined,
|
|
3321
3532
|
> = transfer.Parameters<chain, account>
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3533
|
+
export type ReturnValue = Compute<
|
|
3534
|
+
GetEventArgs<
|
|
3535
|
+
typeof Abis.tip20,
|
|
3536
|
+
'Transfer',
|
|
3537
|
+
{ IndexedOnly: false; Required: true }
|
|
3538
|
+
> & {
|
|
3539
|
+
/** Token decimals used to derive `formatted`, if known. */
|
|
3540
|
+
decimals?: number | undefined
|
|
3541
|
+
/** Transferred amount formatted with the token's `decimals`, if known. */
|
|
3542
|
+
formatted?: string | undefined
|
|
3543
|
+
/** Transaction receipt. */
|
|
3544
|
+
receipt: TransactionReceipt
|
|
3545
|
+
}
|
|
3546
|
+
>
|
|
3333
3547
|
// TODO: exhaustive error type
|
|
3334
3548
|
export type ErrorType = BaseErrorType
|
|
3335
3549
|
}
|
|
@@ -3396,7 +3610,7 @@ export namespace unpause {
|
|
|
3396
3610
|
parameters: unpause.Parameters<chain, account>,
|
|
3397
3611
|
): Promise<ReturnType<action>> {
|
|
3398
3612
|
const { token, ...rest } = parameters
|
|
3399
|
-
const call = unpause.call({ token })
|
|
3613
|
+
const call = unpause.call(client, { token })
|
|
3400
3614
|
return (await action(client, {
|
|
3401
3615
|
...rest,
|
|
3402
3616
|
...call,
|
|
@@ -3424,7 +3638,7 @@ export namespace unpause {
|
|
|
3424
3638
|
*
|
|
3425
3639
|
* const { result } = await client.sendCalls({
|
|
3426
3640
|
* calls: [
|
|
3427
|
-
* actions.token.unpause.call({
|
|
3641
|
+
* actions.token.unpause.call(client, {
|
|
3428
3642
|
* token: '0x20c0...babe',
|
|
3429
3643
|
* }),
|
|
3430
3644
|
* ]
|
|
@@ -3434,10 +3648,13 @@ export namespace unpause {
|
|
|
3434
3648
|
* @param args - Arguments.
|
|
3435
3649
|
* @returns The call.
|
|
3436
3650
|
*/
|
|
3437
|
-
export function call
|
|
3651
|
+
export function call<chain extends Chain | undefined>(
|
|
3652
|
+
client: Client<Transport, chain>,
|
|
3653
|
+
args: Args,
|
|
3654
|
+
) {
|
|
3438
3655
|
const { token } = args
|
|
3439
3656
|
return defineCall({
|
|
3440
|
-
address:
|
|
3657
|
+
address: resolveToken(client, { token }).address,
|
|
3441
3658
|
abi: Abis.tip20,
|
|
3442
3659
|
functionName: 'unpause',
|
|
3443
3660
|
args: [],
|
|
@@ -3590,7 +3807,7 @@ export namespace prepareUpdateQuoteToken {
|
|
|
3590
3807
|
parameters: prepareUpdateQuoteToken.Parameters<chain, account>,
|
|
3591
3808
|
): Promise<ReturnType<action>> {
|
|
3592
3809
|
const { quoteToken, token, ...rest } = parameters
|
|
3593
|
-
const call = prepareUpdateQuoteToken.call({ quoteToken, token })
|
|
3810
|
+
const call = prepareUpdateQuoteToken.call(client, { quoteToken, token })
|
|
3594
3811
|
return (await action(client, {
|
|
3595
3812
|
...rest,
|
|
3596
3813
|
...call,
|
|
@@ -3618,7 +3835,7 @@ export namespace prepareUpdateQuoteToken {
|
|
|
3618
3835
|
*
|
|
3619
3836
|
* const { result } = await client.sendCalls({
|
|
3620
3837
|
* calls: [
|
|
3621
|
-
* actions.token.prepareUpdateQuoteToken.call({
|
|
3838
|
+
* actions.token.prepareUpdateQuoteToken.call(client, {
|
|
3622
3839
|
* token: '0x20c0...babe',
|
|
3623
3840
|
* quoteToken: '0x20c0...cafe',
|
|
3624
3841
|
* }),
|
|
@@ -3629,13 +3846,16 @@ export namespace prepareUpdateQuoteToken {
|
|
|
3629
3846
|
* @param args - Arguments.
|
|
3630
3847
|
* @returns The call.
|
|
3631
3848
|
*/
|
|
3632
|
-
export function call
|
|
3849
|
+
export function call<chain extends Chain | undefined>(
|
|
3850
|
+
client: Client<Transport, chain>,
|
|
3851
|
+
args: Args,
|
|
3852
|
+
) {
|
|
3633
3853
|
const { token, quoteToken } = args
|
|
3634
3854
|
return defineCall({
|
|
3635
|
-
address:
|
|
3855
|
+
address: resolveToken(client, { token }).address,
|
|
3636
3856
|
abi: Abis.tip20,
|
|
3637
3857
|
functionName: 'setNextQuoteToken',
|
|
3638
|
-
args: [
|
|
3858
|
+
args: [resolveToken(client, { token: quoteToken }).address],
|
|
3639
3859
|
})
|
|
3640
3860
|
}
|
|
3641
3861
|
|
|
@@ -3788,7 +4008,7 @@ export namespace updateQuoteToken {
|
|
|
3788
4008
|
parameters: updateQuoteToken.Parameters<chain, account>,
|
|
3789
4009
|
): Promise<ReturnType<action>> {
|
|
3790
4010
|
const { token, ...rest } = parameters
|
|
3791
|
-
const call = updateQuoteToken.call({ token })
|
|
4011
|
+
const call = updateQuoteToken.call(client, { token })
|
|
3792
4012
|
return (await action(client, {
|
|
3793
4013
|
...rest,
|
|
3794
4014
|
...call,
|
|
@@ -3816,7 +4036,7 @@ export namespace updateQuoteToken {
|
|
|
3816
4036
|
*
|
|
3817
4037
|
* const { result } = await client.sendCalls({
|
|
3818
4038
|
* calls: [
|
|
3819
|
-
* actions.token.updateQuoteToken.call({
|
|
4039
|
+
* actions.token.updateQuoteToken.call(client, {
|
|
3820
4040
|
* token: '0x20c0...babe',
|
|
3821
4041
|
* }),
|
|
3822
4042
|
* ]
|
|
@@ -3826,10 +4046,13 @@ export namespace updateQuoteToken {
|
|
|
3826
4046
|
* @param args - Arguments.
|
|
3827
4047
|
* @returns The call.
|
|
3828
4048
|
*/
|
|
3829
|
-
export function call
|
|
4049
|
+
export function call<chain extends Chain | undefined>(
|
|
4050
|
+
client: Client<Transport, chain>,
|
|
4051
|
+
args: Args,
|
|
4052
|
+
) {
|
|
3830
4053
|
const { token } = args
|
|
3831
4054
|
return defineCall({
|
|
3832
|
-
address:
|
|
4055
|
+
address: resolveToken(client, { token }).address,
|
|
3833
4056
|
abi: Abis.tip20,
|
|
3834
4057
|
functionName: 'completeQuoteTokenUpdate',
|
|
3835
4058
|
args: [],
|
|
@@ -3957,7 +4180,7 @@ export function watchApprove<
|
|
|
3957
4180
|
const { onApproval, token, ...rest } = parameters
|
|
3958
4181
|
return watchContractEvent(client, {
|
|
3959
4182
|
...rest,
|
|
3960
|
-
address:
|
|
4183
|
+
address: resolveToken(client, { token }).address,
|
|
3961
4184
|
abi: Abis.tip20,
|
|
3962
4185
|
eventName: 'Approval',
|
|
3963
4186
|
onLogs: (logs) => {
|
|
@@ -4025,7 +4248,7 @@ export function watchBurn<
|
|
|
4025
4248
|
const { onBurn, token, ...rest } = parameters
|
|
4026
4249
|
return watchContractEvent(client, {
|
|
4027
4250
|
...rest,
|
|
4028
|
-
address:
|
|
4251
|
+
address: resolveToken(client, { token }).address,
|
|
4029
4252
|
abi: Abis.tip20,
|
|
4030
4253
|
eventName: 'Burn',
|
|
4031
4254
|
onLogs: (logs) => {
|
|
@@ -4166,7 +4389,7 @@ export function watchMint<
|
|
|
4166
4389
|
const { onMint, token, ...rest } = parameters
|
|
4167
4390
|
return watchContractEvent(client, {
|
|
4168
4391
|
...rest,
|
|
4169
|
-
address:
|
|
4392
|
+
address: resolveToken(client, { token }).address,
|
|
4170
4393
|
abi: Abis.tip20,
|
|
4171
4394
|
eventName: 'Mint',
|
|
4172
4395
|
onLogs: (logs) => {
|
|
@@ -4239,7 +4462,7 @@ export function watchAdminRole<
|
|
|
4239
4462
|
const { onRoleAdminUpdated, token, ...rest } = parameters
|
|
4240
4463
|
return watchContractEvent(client, {
|
|
4241
4464
|
...rest,
|
|
4242
|
-
address:
|
|
4465
|
+
address: resolveToken(client, { token }).address,
|
|
4243
4466
|
abi: Abis.tip20,
|
|
4244
4467
|
eventName: 'RoleAdminUpdated',
|
|
4245
4468
|
onLogs: (logs) => {
|
|
@@ -4307,7 +4530,7 @@ export function watchRole<
|
|
|
4307
4530
|
const { onRoleUpdated, token, ...rest } = parameters
|
|
4308
4531
|
return watchContractEvent(client, {
|
|
4309
4532
|
...rest,
|
|
4310
|
-
address:
|
|
4533
|
+
address: resolveToken(client, { token }).address,
|
|
4311
4534
|
abi: Abis.tip20,
|
|
4312
4535
|
eventName: 'RoleMembershipUpdated',
|
|
4313
4536
|
onLogs: (logs) => {
|
|
@@ -4389,7 +4612,7 @@ export function watchTransfer<
|
|
|
4389
4612
|
const { onTransfer, token, ...rest } = parameters
|
|
4390
4613
|
return watchContractEvent(client, {
|
|
4391
4614
|
...rest,
|
|
4392
|
-
address:
|
|
4615
|
+
address: resolveToken(client, { token }).address,
|
|
4393
4616
|
abi: Abis.tip20,
|
|
4394
4617
|
eventName: 'Transfer',
|
|
4395
4618
|
onLogs: (logs) => {
|
|
@@ -4461,7 +4684,7 @@ export function watchUpdateQuoteToken<
|
|
|
4461
4684
|
parameters: watchUpdateQuoteToken.Parameters,
|
|
4462
4685
|
) {
|
|
4463
4686
|
const { onUpdateQuoteToken, token, ...rest } = parameters
|
|
4464
|
-
const address =
|
|
4687
|
+
const address = resolveToken(client, { token }).address
|
|
4465
4688
|
|
|
4466
4689
|
return watchContractEvent(client, {
|
|
4467
4690
|
...rest,
|