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
|
@@ -265,6 +265,12 @@ import {
|
|
|
265
265
|
type VerifySiweMessageReturnType,
|
|
266
266
|
verifySiweMessage,
|
|
267
267
|
} from '../../actions/siwe/verifySiweMessage.js'
|
|
268
|
+
import {
|
|
269
|
+
getAllowance,
|
|
270
|
+
getMetadata,
|
|
271
|
+
getBalance as getTokenBalance,
|
|
272
|
+
getTotalSupply,
|
|
273
|
+
} from '../../actions/token/index.js'
|
|
268
274
|
import {
|
|
269
275
|
type PrepareTransactionRequestParameters,
|
|
270
276
|
type PrepareTransactionRequestRequest,
|
|
@@ -281,6 +287,7 @@ import {
|
|
|
281
287
|
type SendRawTransactionSyncReturnType,
|
|
282
288
|
sendRawTransactionSync,
|
|
283
289
|
} from '../../actions/wallet/sendRawTransactionSync.js'
|
|
290
|
+
import type { Tokens } from '../../tokens/defineToken.js'
|
|
284
291
|
import type { Account } from '../../types/account.js'
|
|
285
292
|
import type { BlockNumber, BlockTag } from '../../types/block.js'
|
|
286
293
|
import type { Chain } from '../../types/chain.js'
|
|
@@ -293,13 +300,17 @@ import type {
|
|
|
293
300
|
} from '../../types/contract.js'
|
|
294
301
|
import type { FeeValuesType } from '../../types/fee.js'
|
|
295
302
|
import type { FilterType } from '../../types/filter.js'
|
|
296
|
-
import type
|
|
303
|
+
import { bindActionDecorators, type Client } from '../createClient.js'
|
|
297
304
|
import type { Transport } from '../transports/createTransport.js'
|
|
298
305
|
|
|
306
|
+
/** @internal */
|
|
307
|
+
export type { TokenName } from '../../actions/token/internal.js'
|
|
308
|
+
|
|
299
309
|
export type PublicActions<
|
|
300
310
|
transport extends Transport = Transport,
|
|
301
311
|
chain extends Chain | undefined = Chain | undefined,
|
|
302
312
|
account extends Account | undefined = Account | undefined,
|
|
313
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
303
314
|
> = {
|
|
304
315
|
/**
|
|
305
316
|
* Executes a new message call immediately without submitting a transaction to the network.
|
|
@@ -2091,15 +2102,150 @@ export type PublicActions<
|
|
|
2091
2102
|
watchPendingTransactions: (
|
|
2092
2103
|
args: WatchPendingTransactionsParameters<transport>,
|
|
2093
2104
|
) => WatchPendingTransactionsReturnType
|
|
2105
|
+
/**
|
|
2106
|
+
* Read-only ERC-20 Actions, exposed under the `token` namespace.
|
|
2107
|
+
*
|
|
2108
|
+
* Every action selects its token by `token`, which is either a token symbol
|
|
2109
|
+
* (resolved from the Client's `tokens` array) or a contract `address`.
|
|
2110
|
+
*
|
|
2111
|
+
* - Docs: https://viem.sh/docs/token
|
|
2112
|
+
*/
|
|
2113
|
+
token: {
|
|
2114
|
+
/**
|
|
2115
|
+
* Gets the amount of tokens a `spender` is allowed to spend on behalf of an
|
|
2116
|
+
* `account`.
|
|
2117
|
+
*
|
|
2118
|
+
* - Docs: https://viem.sh/docs/token/getAllowance
|
|
2119
|
+
*
|
|
2120
|
+
* @param parameters - {@link getAllowance.Parameters}
|
|
2121
|
+
* @returns The remaining allowance, in base units and human-readable form. {@link getAllowance.ReturnValue}
|
|
2122
|
+
*
|
|
2123
|
+
* @example
|
|
2124
|
+
* import { createPublicClient, http } from 'viem'
|
|
2125
|
+
* import { mainnet } from 'viem/chains'
|
|
2126
|
+
*
|
|
2127
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
2128
|
+
*
|
|
2129
|
+
* const allowance = await client.token.getAllowance({
|
|
2130
|
+
* account: '0x…',
|
|
2131
|
+
* spender: '0x…',
|
|
2132
|
+
* token: 'usdc',
|
|
2133
|
+
* })
|
|
2134
|
+
*/
|
|
2135
|
+
getAllowance: ((
|
|
2136
|
+
parameters: getAllowance.Parameters<chain, tokens>,
|
|
2137
|
+
) => Promise<getAllowance.ReturnValue>) & {
|
|
2138
|
+
/**
|
|
2139
|
+
* Defines an `allowance` contract call, ready to pass to `multicall`,
|
|
2140
|
+
* `simulateContract`, or any other action that accepts a contract call.
|
|
2141
|
+
*
|
|
2142
|
+
* - Docs: https://viem.sh/docs/token/getAllowance#composing-calls
|
|
2143
|
+
*
|
|
2144
|
+
* @param args - {@link getAllowance.Args}
|
|
2145
|
+
* @returns The contract call.
|
|
2146
|
+
*/
|
|
2147
|
+
call: (
|
|
2148
|
+
args: getAllowance.Args<chain, tokens>,
|
|
2149
|
+
) => ReturnType<typeof getAllowance.call>
|
|
2150
|
+
}
|
|
2151
|
+
/**
|
|
2152
|
+
* Gets the token balance of an `account`.
|
|
2153
|
+
*
|
|
2154
|
+
* - Docs: https://viem.sh/docs/token/getBalance
|
|
2155
|
+
*
|
|
2156
|
+
* @param parameters - {@link getTokenBalance.Parameters}
|
|
2157
|
+
* @returns The token balance, in base units and human-readable form. {@link getTokenBalance.ReturnValue}
|
|
2158
|
+
*
|
|
2159
|
+
* @example
|
|
2160
|
+
* import { createPublicClient, http } from 'viem'
|
|
2161
|
+
* import { mainnet } from 'viem/chains'
|
|
2162
|
+
*
|
|
2163
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
2164
|
+
*
|
|
2165
|
+
* const balance = await client.token.getBalance({
|
|
2166
|
+
* account: '0x…',
|
|
2167
|
+
* token: 'usdc',
|
|
2168
|
+
* })
|
|
2169
|
+
*/
|
|
2170
|
+
getBalance: ((
|
|
2171
|
+
parameters: getTokenBalance.Parameters<chain, account, tokens>,
|
|
2172
|
+
) => Promise<getTokenBalance.ReturnValue>) & {
|
|
2173
|
+
/**
|
|
2174
|
+
* Defines a `balanceOf` contract call, ready to pass to `multicall`,
|
|
2175
|
+
* `simulateContract`, or any other action that accepts a contract call.
|
|
2176
|
+
*
|
|
2177
|
+
* - Docs: https://viem.sh/docs/token/getBalance#composing-calls
|
|
2178
|
+
*
|
|
2179
|
+
* @param args - {@link getTokenBalance.Args}
|
|
2180
|
+
* @returns The contract call.
|
|
2181
|
+
*/
|
|
2182
|
+
call: (
|
|
2183
|
+
args: getTokenBalance.Args<chain, account, tokens>,
|
|
2184
|
+
) => ReturnType<typeof getTokenBalance.call>
|
|
2185
|
+
}
|
|
2186
|
+
/**
|
|
2187
|
+
* Gets the metadata (`decimals`, `name`, `symbol`) of the token. Fields
|
|
2188
|
+
* declared on the Client's `tokens` array are used as-is; any missing field
|
|
2189
|
+
* is fetched from the token contract.
|
|
2190
|
+
*
|
|
2191
|
+
* - Docs: https://viem.sh/docs/token/getMetadata
|
|
2192
|
+
*
|
|
2193
|
+
* @param parameters - {@link getMetadata.Parameters}
|
|
2194
|
+
* @returns The token metadata (`decimals`, `name`, `symbol`). {@link getMetadata.ReturnValue}
|
|
2195
|
+
*
|
|
2196
|
+
* @example
|
|
2197
|
+
* import { createPublicClient, http } from 'viem'
|
|
2198
|
+
* import { mainnet } from 'viem/chains'
|
|
2199
|
+
*
|
|
2200
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
2201
|
+
*
|
|
2202
|
+
* const metadata = await client.token.getMetadata({ token: 'usdc' })
|
|
2203
|
+
*/
|
|
2204
|
+
getMetadata: (
|
|
2205
|
+
parameters: getMetadata.Parameters<chain, tokens>,
|
|
2206
|
+
) => Promise<getMetadata.ReturnValue>
|
|
2207
|
+
/**
|
|
2208
|
+
* Gets the total supply of the token.
|
|
2209
|
+
*
|
|
2210
|
+
* - Docs: https://viem.sh/docs/token/getTotalSupply
|
|
2211
|
+
*
|
|
2212
|
+
* @param parameters - {@link getTotalSupply.Parameters}
|
|
2213
|
+
* @returns The token total supply, in base units and human-readable form. {@link getTotalSupply.ReturnValue}
|
|
2214
|
+
*
|
|
2215
|
+
* @example
|
|
2216
|
+
* import { createPublicClient, http } from 'viem'
|
|
2217
|
+
* import { mainnet } from 'viem/chains'
|
|
2218
|
+
*
|
|
2219
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
2220
|
+
*
|
|
2221
|
+
* const totalSupply = await client.token.getTotalSupply({ token: 'usdc' })
|
|
2222
|
+
*/
|
|
2223
|
+
getTotalSupply: ((
|
|
2224
|
+
parameters: getTotalSupply.Parameters<chain, tokens>,
|
|
2225
|
+
) => Promise<getTotalSupply.ReturnValue>) & {
|
|
2226
|
+
/**
|
|
2227
|
+
* Defines a `totalSupply` contract call, ready to pass to `multicall`,
|
|
2228
|
+
* `simulateContract`, or any other action that accepts a contract call.
|
|
2229
|
+
*
|
|
2230
|
+
* - Docs: https://viem.sh/docs/token/getTotalSupply#composing-calls
|
|
2231
|
+
*
|
|
2232
|
+
* @param args - {@link getTotalSupply.Args}
|
|
2233
|
+
* @returns The contract call.
|
|
2234
|
+
*/
|
|
2235
|
+
call: (
|
|
2236
|
+
args: getTotalSupply.Args<chain, tokens>,
|
|
2237
|
+
) => ReturnType<typeof getTotalSupply.call>
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2094
2240
|
}
|
|
2095
|
-
|
|
2096
2241
|
export function publicActions<
|
|
2097
2242
|
transport extends Transport = Transport,
|
|
2098
2243
|
chain extends Chain | undefined = Chain | undefined,
|
|
2099
2244
|
account extends Account | undefined = Account | undefined,
|
|
2245
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
2100
2246
|
>(
|
|
2101
|
-
client: Client<transport, chain, account>,
|
|
2102
|
-
): PublicActions<transport, chain, account> {
|
|
2247
|
+
client: Client<transport, chain, account, undefined, undefined, tokens>,
|
|
2248
|
+
): PublicActions<transport, chain, account, tokens> {
|
|
2103
2249
|
return {
|
|
2104
2250
|
call: (args) => call(client, args),
|
|
2105
2251
|
createAccessList: (args) => createAccessList(client, args),
|
|
@@ -2166,5 +2312,21 @@ export function publicActions<
|
|
|
2166
2312
|
watchContractEvent: (args) => watchContractEvent(client, args),
|
|
2167
2313
|
watchEvent: (args) => watchEvent(client, args),
|
|
2168
2314
|
watchPendingTransactions: (args) => watchPendingTransactions(client, args),
|
|
2315
|
+
token: bindPublicToken(client) as never,
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
/**
|
|
2320
|
+
* Binds the read-only ERC-20 actions (and their `.call` helpers) to `client`.
|
|
2321
|
+
* Merged with the write actions from {@link walletActions} (when present) by the
|
|
2322
|
+
* Client's `extend`, which shallow-merges conflicting plain-object namespaces.
|
|
2323
|
+
* @internal
|
|
2324
|
+
*/
|
|
2325
|
+
function bindPublicToken(client: Client<Transport, Chain | undefined, any>) {
|
|
2326
|
+
return {
|
|
2327
|
+
getAllowance: bindActionDecorators(client, getAllowance),
|
|
2328
|
+
getBalance: bindActionDecorators(client, getTokenBalance),
|
|
2329
|
+
getMetadata: bindActionDecorators(client, getMetadata),
|
|
2330
|
+
getTotalSupply: bindActionDecorators(client, getTotalSupply),
|
|
2169
2331
|
}
|
|
2170
2332
|
}
|
|
@@ -10,6 +10,12 @@ import {
|
|
|
10
10
|
type GetChainIdReturnType,
|
|
11
11
|
getChainId,
|
|
12
12
|
} from '../../actions/public/getChainId.js'
|
|
13
|
+
import {
|
|
14
|
+
approve,
|
|
15
|
+
approveSync,
|
|
16
|
+
transfer,
|
|
17
|
+
transferSync,
|
|
18
|
+
} from '../../actions/token/index.js'
|
|
13
19
|
import {
|
|
14
20
|
type AddChainParameters,
|
|
15
21
|
addChain,
|
|
@@ -139,17 +145,19 @@ import {
|
|
|
139
145
|
type WriteContractSyncReturnType,
|
|
140
146
|
writeContractSync,
|
|
141
147
|
} from '../../actions/wallet/writeContractSync.js'
|
|
148
|
+
import type { Tokens } from '../../tokens/defineToken.js'
|
|
142
149
|
import type { Chain } from '../../types/chain.js'
|
|
143
150
|
import type {
|
|
144
151
|
ContractFunctionArgs,
|
|
145
152
|
ContractFunctionName,
|
|
146
153
|
} from '../../types/contract.js'
|
|
147
|
-
import type
|
|
154
|
+
import { bindActionDecorators, type Client } from '../createClient.js'
|
|
148
155
|
import type { Transport } from '../transports/createTransport.js'
|
|
149
156
|
|
|
150
157
|
export type WalletActions<
|
|
151
158
|
chain extends Chain | undefined = Chain | undefined,
|
|
152
159
|
account extends Account | undefined = Account | undefined,
|
|
160
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
153
161
|
> = {
|
|
154
162
|
/**
|
|
155
163
|
* Adds an EVM chain to the wallet.
|
|
@@ -1175,13 +1183,238 @@ export type WalletActions<
|
|
|
1175
1183
|
chainOverride
|
|
1176
1184
|
>,
|
|
1177
1185
|
) => Promise<WriteContractSyncReturnType>
|
|
1186
|
+
/**
|
|
1187
|
+
* Write ERC-20 Actions, exposed under the `token` namespace.
|
|
1188
|
+
*
|
|
1189
|
+
* Every action selects its token by `token`, which is either a token symbol
|
|
1190
|
+
* (resolved from the Client's `tokens` array) or a contract `address`. `amount`
|
|
1191
|
+
* inputs are base-unit `bigint` values, or
|
|
1192
|
+
* `{ decimals?: number, formatted: string }` to parse a human-readable decimal
|
|
1193
|
+
* string.
|
|
1194
|
+
*
|
|
1195
|
+
* - Docs: https://viem.sh/docs/token
|
|
1196
|
+
*/
|
|
1197
|
+
token: {
|
|
1198
|
+
/**
|
|
1199
|
+
* Approves a `spender` to transfer up to `amount` tokens on behalf of the
|
|
1200
|
+
* caller, and waits for the transaction to be confirmed.
|
|
1201
|
+
*
|
|
1202
|
+
* - Docs: https://viem.sh/docs/token/approve
|
|
1203
|
+
*
|
|
1204
|
+
* @param parameters - {@link approveSync.Parameters}
|
|
1205
|
+
* @returns The decoded `Approval` event and the transaction receipt. {@link approveSync.ReturnValue}
|
|
1206
|
+
*
|
|
1207
|
+
* @example
|
|
1208
|
+
* import { createWalletClient, http } from 'viem'
|
|
1209
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1210
|
+
* import { mainnet } from 'viem/chains'
|
|
1211
|
+
*
|
|
1212
|
+
* const client = createWalletClient({
|
|
1213
|
+
* account: privateKeyToAccount('0x…'),
|
|
1214
|
+
* chain: mainnet,
|
|
1215
|
+
* transport: http(),
|
|
1216
|
+
* })
|
|
1217
|
+
*
|
|
1218
|
+
* const { receipt, value } = await client.token.approveSync({
|
|
1219
|
+
* amount: { decimals: 6, formatted: '10.5' },
|
|
1220
|
+
* spender: '0x…',
|
|
1221
|
+
* token: 'usdc',
|
|
1222
|
+
* })
|
|
1223
|
+
*/
|
|
1224
|
+
approveSync: (
|
|
1225
|
+
parameters: approveSync.Parameters<chain, account, tokens>,
|
|
1226
|
+
) => Promise<approveSync.ReturnValue>
|
|
1227
|
+
/**
|
|
1228
|
+
* Approves a `spender` to transfer up to `amount` tokens on behalf of the
|
|
1229
|
+
* caller, and returns the transaction hash.
|
|
1230
|
+
*
|
|
1231
|
+
* - Docs: https://viem.sh/docs/token/approve#asynchronous-usage
|
|
1232
|
+
*
|
|
1233
|
+
* @param parameters - {@link approve.Parameters}
|
|
1234
|
+
* @returns The transaction hash. {@link approve.ReturnValue}
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* import { createWalletClient, http } from 'viem'
|
|
1238
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1239
|
+
* import { mainnet } from 'viem/chains'
|
|
1240
|
+
*
|
|
1241
|
+
* const client = createWalletClient({
|
|
1242
|
+
* account: privateKeyToAccount('0x…'),
|
|
1243
|
+
* chain: mainnet,
|
|
1244
|
+
* transport: http(),
|
|
1245
|
+
* })
|
|
1246
|
+
*
|
|
1247
|
+
* const hash = await client.token.approve({
|
|
1248
|
+
* amount: { decimals: 6, formatted: '10.5' },
|
|
1249
|
+
* spender: '0x…',
|
|
1250
|
+
* token: 'usdc',
|
|
1251
|
+
* })
|
|
1252
|
+
*/
|
|
1253
|
+
approve: ((
|
|
1254
|
+
parameters: approve.Parameters<chain, account, tokens>,
|
|
1255
|
+
) => Promise<approve.ReturnValue>) & {
|
|
1256
|
+
/**
|
|
1257
|
+
* Defines an `approve` contract call, ready to pass to `sendCalls`,
|
|
1258
|
+
* `sendTransaction` (`calls`), or `multicall`.
|
|
1259
|
+
*
|
|
1260
|
+
* - Docs: https://viem.sh/docs/token/approve#composing-calls
|
|
1261
|
+
*
|
|
1262
|
+
* @param args - {@link approve.Args}
|
|
1263
|
+
* @returns The contract call.
|
|
1264
|
+
*/
|
|
1265
|
+
call: (
|
|
1266
|
+
args: approve.Args<chain, tokens>,
|
|
1267
|
+
) => ReturnType<typeof approve.call>
|
|
1268
|
+
/**
|
|
1269
|
+
* Estimates the gas required to approve a `spender` to transfer up to
|
|
1270
|
+
* `amount` tokens on behalf of the caller.
|
|
1271
|
+
*
|
|
1272
|
+
* - Docs: https://viem.sh/docs/token/approve#estimate-gas--simulate
|
|
1273
|
+
*
|
|
1274
|
+
* @param parameters - {@link approve.Parameters}
|
|
1275
|
+
* @returns The gas estimate.
|
|
1276
|
+
*/
|
|
1277
|
+
estimateGas: (
|
|
1278
|
+
parameters: approve.Parameters<chain, account, tokens>,
|
|
1279
|
+
) => Promise<bigint>
|
|
1280
|
+
/**
|
|
1281
|
+
* Extracts the `Approval` event from transaction logs.
|
|
1282
|
+
*
|
|
1283
|
+
* - Docs: https://viem.sh/docs/token/approve
|
|
1284
|
+
*
|
|
1285
|
+
* @param logs - The logs.
|
|
1286
|
+
* @returns The decoded `Approval` event.
|
|
1287
|
+
*/
|
|
1288
|
+
extractEvent: typeof approve.extractEvent
|
|
1289
|
+
/**
|
|
1290
|
+
* Simulates approving a `spender` to transfer up to `amount` tokens on
|
|
1291
|
+
* behalf of the caller, returning the result and write request.
|
|
1292
|
+
*
|
|
1293
|
+
* - Docs: https://viem.sh/docs/token/approve#estimate-gas--simulate
|
|
1294
|
+
*
|
|
1295
|
+
* @param parameters - {@link approve.Parameters}
|
|
1296
|
+
* @returns The simulation result and write request.
|
|
1297
|
+
*/
|
|
1298
|
+
simulate: (
|
|
1299
|
+
parameters: approve.Parameters<chain, account, tokens>,
|
|
1300
|
+
) => ReturnType<typeof approve.simulate>
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Transfers `amount` tokens to a recipient, and waits for the transaction to
|
|
1304
|
+
* be confirmed. Pass `from` to transfer on behalf of another address using an
|
|
1305
|
+
* allowance (calls `transferFrom`).
|
|
1306
|
+
*
|
|
1307
|
+
* - Docs: https://viem.sh/docs/token/transfer
|
|
1308
|
+
*
|
|
1309
|
+
* @param parameters - {@link transferSync.Parameters}
|
|
1310
|
+
* @returns The decoded `Transfer` event and the transaction receipt. {@link transferSync.ReturnValue}
|
|
1311
|
+
*
|
|
1312
|
+
* @example
|
|
1313
|
+
* import { createWalletClient, http } from 'viem'
|
|
1314
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1315
|
+
* import { mainnet } from 'viem/chains'
|
|
1316
|
+
*
|
|
1317
|
+
* const client = createWalletClient({
|
|
1318
|
+
* account: privateKeyToAccount('0x…'),
|
|
1319
|
+
* chain: mainnet,
|
|
1320
|
+
* transport: http(),
|
|
1321
|
+
* })
|
|
1322
|
+
*
|
|
1323
|
+
* const { receipt, value } = await client.token.transferSync({
|
|
1324
|
+
* amount: { decimals: 6, formatted: '10.5' },
|
|
1325
|
+
* to: '0x…',
|
|
1326
|
+
* token: 'usdc',
|
|
1327
|
+
* })
|
|
1328
|
+
*/
|
|
1329
|
+
transferSync: (
|
|
1330
|
+
parameters: transferSync.Parameters<chain, account, tokens>,
|
|
1331
|
+
) => Promise<transferSync.ReturnValue>
|
|
1332
|
+
/**
|
|
1333
|
+
* Transfers `amount` tokens to a recipient, and returns the transaction hash.
|
|
1334
|
+
* Pass `from` to transfer on behalf of another address using an allowance
|
|
1335
|
+
* (calls `transferFrom`).
|
|
1336
|
+
*
|
|
1337
|
+
* - Docs: https://viem.sh/docs/token/transfer#asynchronous-usage
|
|
1338
|
+
*
|
|
1339
|
+
* @param parameters - {@link transfer.Parameters}
|
|
1340
|
+
* @returns The transaction hash. {@link transfer.ReturnValue}
|
|
1341
|
+
*
|
|
1342
|
+
* @example
|
|
1343
|
+
* import { createWalletClient, http } from 'viem'
|
|
1344
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
1345
|
+
* import { mainnet } from 'viem/chains'
|
|
1346
|
+
*
|
|
1347
|
+
* const client = createWalletClient({
|
|
1348
|
+
* account: privateKeyToAccount('0x…'),
|
|
1349
|
+
* chain: mainnet,
|
|
1350
|
+
* transport: http(),
|
|
1351
|
+
* })
|
|
1352
|
+
*
|
|
1353
|
+
* const hash = await client.token.transfer({
|
|
1354
|
+
* amount: { decimals: 6, formatted: '10.5' },
|
|
1355
|
+
* to: '0x…',
|
|
1356
|
+
* token: 'usdc',
|
|
1357
|
+
* })
|
|
1358
|
+
*/
|
|
1359
|
+
transfer: ((
|
|
1360
|
+
parameters: transfer.Parameters<chain, account, tokens>,
|
|
1361
|
+
) => Promise<transfer.ReturnValue>) & {
|
|
1362
|
+
/**
|
|
1363
|
+
* Defines a `transfer` (or `transferFrom`, when `from` is given) contract
|
|
1364
|
+
* call, ready to pass to `sendCalls`, `sendTransaction` (`calls`), or
|
|
1365
|
+
* `multicall`.
|
|
1366
|
+
*
|
|
1367
|
+
* - Docs: https://viem.sh/docs/token/transfer#composing-calls
|
|
1368
|
+
*
|
|
1369
|
+
* @param args - {@link transfer.Args}
|
|
1370
|
+
* @returns The contract call.
|
|
1371
|
+
*/
|
|
1372
|
+
call: (
|
|
1373
|
+
args: transfer.Args<chain, tokens>,
|
|
1374
|
+
) => ReturnType<typeof transfer.call>
|
|
1375
|
+
/**
|
|
1376
|
+
* Estimates the gas required to transfer `amount` tokens to a recipient.
|
|
1377
|
+
*
|
|
1378
|
+
* - Docs: https://viem.sh/docs/token/transfer#estimate-gas--simulate
|
|
1379
|
+
*
|
|
1380
|
+
* @param parameters - {@link transfer.Parameters}
|
|
1381
|
+
* @returns The gas estimate.
|
|
1382
|
+
*/
|
|
1383
|
+
estimateGas: (
|
|
1384
|
+
parameters: transfer.Parameters<chain, account, tokens>,
|
|
1385
|
+
) => Promise<bigint>
|
|
1386
|
+
/**
|
|
1387
|
+
* Extracts the `Transfer` event from transaction logs.
|
|
1388
|
+
*
|
|
1389
|
+
* - Docs: https://viem.sh/docs/token/transfer
|
|
1390
|
+
*
|
|
1391
|
+
* @param logs - The logs.
|
|
1392
|
+
* @returns The decoded `Transfer` event.
|
|
1393
|
+
*/
|
|
1394
|
+
extractEvent: typeof transfer.extractEvent
|
|
1395
|
+
/**
|
|
1396
|
+
* Simulates a transfer of `amount` tokens to a recipient, returning the
|
|
1397
|
+
* result and write request.
|
|
1398
|
+
*
|
|
1399
|
+
* - Docs: https://viem.sh/docs/token/transfer#estimate-gas--simulate
|
|
1400
|
+
*
|
|
1401
|
+
* @param parameters - {@link transfer.Parameters}
|
|
1402
|
+
* @returns The simulation result and write request.
|
|
1403
|
+
*/
|
|
1404
|
+
simulate: (
|
|
1405
|
+
parameters: transfer.Parameters<chain, account, tokens>,
|
|
1406
|
+
) => ReturnType<typeof transfer.simulate>
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1178
1409
|
}
|
|
1179
|
-
|
|
1180
1410
|
export function walletActions<
|
|
1181
1411
|
transport extends Transport,
|
|
1182
1412
|
chain extends Chain | undefined = Chain | undefined,
|
|
1183
1413
|
account extends Account | undefined = Account | undefined,
|
|
1184
|
-
|
|
1414
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
1415
|
+
>(
|
|
1416
|
+
client: Client<transport, chain, account, undefined, undefined, tokens>,
|
|
1417
|
+
): WalletActions<chain, account, tokens> {
|
|
1185
1418
|
return {
|
|
1186
1419
|
addChain: (args) => addChain(client, args),
|
|
1187
1420
|
deployContract: (args) => deployContract(client, args),
|
|
@@ -1212,5 +1445,11 @@ export function walletActions<
|
|
|
1212
1445
|
watchAsset: (args) => watchAsset(client, args),
|
|
1213
1446
|
writeContract: (args) => writeContract(client, args as any),
|
|
1214
1447
|
writeContractSync: (args) => writeContractSync(client, args as any),
|
|
1448
|
+
token: {
|
|
1449
|
+
approve: bindActionDecorators(client, approve),
|
|
1450
|
+
approveSync: bindActionDecorators(client, approveSync),
|
|
1451
|
+
transfer: bindActionDecorators(client, transfer),
|
|
1452
|
+
transferSync: bindActionDecorators(client, transferSync),
|
|
1453
|
+
} as never,
|
|
1215
1454
|
}
|
|
1216
1455
|
}
|
|
@@ -42,6 +42,8 @@ export type HttpTransportConfig<
|
|
|
42
42
|
* @link https://developer.mozilla.org/en-US/docs/Web/API/fetch
|
|
43
43
|
*/
|
|
44
44
|
fetchOptions?: HttpRpcClientOptions['fetchOptions'] | undefined
|
|
45
|
+
/** Maximum response body size in bytes. Set to `false` to disable. @default 10_485_760 */
|
|
46
|
+
maxResponseBodySize?: HttpRpcClientOptions['maxResponseBodySize'] | undefined
|
|
45
47
|
/** A callback to handle the response from `fetch`. */
|
|
46
48
|
onFetchRequest?: HttpRpcClientOptions['onRequest'] | undefined
|
|
47
49
|
/** A callback to handle the response from `fetch`. */
|
|
@@ -108,6 +110,7 @@ export function http<
|
|
|
108
110
|
fetchFn,
|
|
109
111
|
fetchOptions,
|
|
110
112
|
key = 'http',
|
|
113
|
+
maxResponseBodySize,
|
|
111
114
|
methods,
|
|
112
115
|
name = 'HTTP JSON-RPC',
|
|
113
116
|
onFetchRequest,
|
|
@@ -126,6 +129,7 @@ export function http<
|
|
|
126
129
|
const rpcClient = getHttpRpcClient(url_, {
|
|
127
130
|
fetchFn,
|
|
128
131
|
fetchOptions,
|
|
132
|
+
maxResponseBodySize,
|
|
129
133
|
onRequest: onFetchRequest,
|
|
130
134
|
onResponse: onFetchResponse,
|
|
131
135
|
timeout,
|
package/errors/encoding.ts
CHANGED
|
@@ -66,6 +66,17 @@ export class InvalidHexValueError extends BaseError {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
export type RlpDepthLimitExceededErrorType = RlpDepthLimitExceededError & {
|
|
70
|
+
name: 'RlpDepthLimitExceededError'
|
|
71
|
+
}
|
|
72
|
+
export class RlpDepthLimitExceededError extends BaseError {
|
|
73
|
+
constructor({ limit }: { limit: number }) {
|
|
74
|
+
super(`RLP depth limit of \`${limit}\` exceeded.`, {
|
|
75
|
+
name: 'RlpDepthLimitExceededError',
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
69
80
|
export type SizeOverflowErrorType = SizeOverflowError & {
|
|
70
81
|
name: 'SizeOverflowError'
|
|
71
82
|
}
|
package/errors/request.ts
CHANGED
|
@@ -44,6 +44,23 @@ export class HttpRequestError extends BaseError {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export type ResponseBodyTooLargeErrorType = ResponseBodyTooLargeError & {
|
|
48
|
+
name: 'ResponseBodyTooLargeError'
|
|
49
|
+
}
|
|
50
|
+
export class ResponseBodyTooLargeError extends BaseError {
|
|
51
|
+
maxSize: number
|
|
52
|
+
size: number
|
|
53
|
+
|
|
54
|
+
constructor({ maxSize, size }: { maxSize: number; size: number }) {
|
|
55
|
+
super('HTTP response body exceeded the size limit.', {
|
|
56
|
+
metaMessages: [`Max: ${maxSize} bytes`, `Received: ${size} bytes`],
|
|
57
|
+
name: 'ResponseBodyTooLargeError',
|
|
58
|
+
})
|
|
59
|
+
this.maxSize = maxSize
|
|
60
|
+
this.size = size
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
47
64
|
export type WebSocketRequestErrorType = WebSocketRequestError & {
|
|
48
65
|
name: 'WebSocketRequestError'
|
|
49
66
|
}
|
package/errors/transaction.ts
CHANGED
|
@@ -53,6 +53,17 @@ export class InvalidLegacyVError extends BaseError {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export type InvalidYParityErrorType = InvalidYParityError & {
|
|
57
|
+
name: 'InvalidYParityError'
|
|
58
|
+
}
|
|
59
|
+
export class InvalidYParityError extends BaseError {
|
|
60
|
+
constructor({ yParity }: { yParity: bigint }) {
|
|
61
|
+
super(`Invalid \`yParity\` value "${yParity}". Expected 0 or 1.`, {
|
|
62
|
+
name: 'InvalidYParityError',
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
56
67
|
export type InvalidSerializableTransactionErrorType =
|
|
57
68
|
InvalidSerializableTransactionError & {
|
|
58
69
|
name: 'InvalidSerializableTransactionError'
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.54.0'
|
package/index.ts
CHANGED
|
@@ -878,6 +878,8 @@ export {
|
|
|
878
878
|
type InvalidHexBooleanErrorType,
|
|
879
879
|
InvalidHexValueError,
|
|
880
880
|
type InvalidHexValueErrorType,
|
|
881
|
+
RlpDepthLimitExceededError,
|
|
882
|
+
type RlpDepthLimitExceededErrorType,
|
|
881
883
|
SizeOverflowError,
|
|
882
884
|
type SizeOverflowErrorType,
|
|
883
885
|
} from './errors/encoding.js'
|
|
@@ -938,6 +940,8 @@ export {
|
|
|
938
940
|
export {
|
|
939
941
|
HttpRequestError,
|
|
940
942
|
type HttpRequestErrorType,
|
|
943
|
+
ResponseBodyTooLargeError,
|
|
944
|
+
type ResponseBodyTooLargeErrorType,
|
|
941
945
|
RpcRequestError,
|
|
942
946
|
type RpcRequestErrorType,
|
|
943
947
|
SocketClosedError,
|
|
@@ -1025,6 +1029,8 @@ export {
|
|
|
1025
1029
|
type InvalidSerializedTransactionTypeErrorType,
|
|
1026
1030
|
InvalidStorageKeySizeError,
|
|
1027
1031
|
type InvalidStorageKeySizeErrorType,
|
|
1032
|
+
InvalidYParityError,
|
|
1033
|
+
type InvalidYParityErrorType,
|
|
1028
1034
|
TransactionExecutionError,
|
|
1029
1035
|
type TransactionExecutionErrorType,
|
|
1030
1036
|
TransactionNotFoundError,
|
|
@@ -1050,6 +1056,7 @@ export {
|
|
|
1050
1056
|
InvalidDecimalNumberError,
|
|
1051
1057
|
type InvalidDecimalNumberErrorType,
|
|
1052
1058
|
} from './errors/unit.js'
|
|
1059
|
+
export type { ResolvedToken, Tokens } from './tokens/defineToken.js'
|
|
1053
1060
|
export type {
|
|
1054
1061
|
DeriveAccount,
|
|
1055
1062
|
HDKey,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viem",
|
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.54.0",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -133,6 +133,11 @@
|
|
|
133
133
|
"import": "./_esm/tempo/zones/index.js",
|
|
134
134
|
"default": "./_cjs/tempo/zones/index.js"
|
|
135
135
|
},
|
|
136
|
+
"./tokens": {
|
|
137
|
+
"types": "./_types/tokens/index.d.ts",
|
|
138
|
+
"import": "./_esm/tokens/index.js",
|
|
139
|
+
"default": "./_cjs/tokens/index.js"
|
|
140
|
+
},
|
|
136
141
|
"./utils": {
|
|
137
142
|
"types": "./_types/utils/index.d.ts",
|
|
138
143
|
"import": "./_esm/utils/index.js",
|
package/tempo/Client.ts
CHANGED
|
@@ -88,8 +88,10 @@ export type Client<
|
|
|
88
88
|
chain,
|
|
89
89
|
account,
|
|
90
90
|
rpcSchema,
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
Omit<
|
|
92
|
+
PublicActions<transport, chain, account> & WalletActions<chain, account>,
|
|
93
|
+
'token'
|
|
94
|
+
> &
|
|
93
95
|
Decorator<chain, account>
|
|
94
96
|
>
|
|
95
97
|
>
|