viem 2.53.1 → 2.54.1
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 +65 -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 +3 -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/cirbtc.js +16 -0
- package/_cjs/tokens/definitions/cirbtc.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/eurc.js +24 -0
- package/_cjs/tokens/definitions/eurc.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 +59 -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/usyc.js +18 -0
- package/_cjs/tokens/definitions/usyc.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 +72 -0
- package/_cjs/tokens/index.js.map +1 -0
- package/_cjs/tokens/sets.js +102 -0
- package/_cjs/tokens/sets.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 +3 -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/cirbtc.js +21 -0
- package/_esm/tokens/definitions/cirbtc.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/eurc.js +29 -0
- package/_esm/tokens/definitions/eurc.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 +85 -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/usyc.js +23 -0
- package/_esm/tokens/definitions/usyc.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 +36 -0
- package/_esm/tokens/index.js.map +1 -0
- package/_esm/tokens/sets.js +104 -0
- package/_esm/tokens/sets.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/cirbtc.d.ts +21 -0
- package/_types/tokens/definitions/cirbtc.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/eurc.d.ts +29 -0
- package/_types/tokens/definitions/eurc.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 +85 -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/usyc.d.ts +23 -0
- package/_types/tokens/definitions/usyc.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 +35 -0
- package/_types/tokens/index.d.ts.map +1 -0
- package/_types/tokens/sets.d.ts +607 -0
- package/_types/tokens/sets.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 +7 -3
- 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/cirbtc.ts +21 -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/eurc.ts +29 -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 +85 -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/usyc.ts +23 -0
- package/tokens/definitions/wsrusd.ts +13 -0
- package/tokens/index.ts +35 -0
- package/tokens/package.json +6 -0
- package/tokens/sets.ts +109 -0
- package/utils/encoding/fromRlp.ts +22 -3
- package/utils/rpc/http.ts +70 -2
- package/utils/transaction/parseTransaction.ts +7 -2
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Account } from '../../accounts/types.js'
|
|
2
|
+
import type { Client } from '../../clients/createClient.js'
|
|
3
|
+
import type { Transport } from '../../clients/transports/createTransport.js'
|
|
4
|
+
import type { erc20Abi } from '../../constants/abis.js'
|
|
5
|
+
import type { BaseErrorType } from '../../errors/base.js'
|
|
6
|
+
import type { Tokens } from '../../tokens/defineToken.js'
|
|
7
|
+
import type { Chain } from '../../types/chain.js'
|
|
8
|
+
import type { GetEventArgs } from '../../types/contract.js'
|
|
9
|
+
import type { TransactionReceipt } from '../../types/transaction.js'
|
|
10
|
+
import type { Compute } from '../../types/utils.js'
|
|
11
|
+
import { formatUnits } from '../../utils/unit/formatUnits.js'
|
|
12
|
+
import { writeContractSync } from '../wallet/writeContractSync.js'
|
|
13
|
+
import { resolveAmountDecimals, resolveToken } from './internal.js'
|
|
14
|
+
import { transfer } from './transfer.js'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Transfers ERC-20 tokens to another address, and waits for the transaction to
|
|
18
|
+
* be confirmed.
|
|
19
|
+
*
|
|
20
|
+
* Pass `from` to transfer on behalf of another address using an allowance
|
|
21
|
+
* (calls `transferFrom`); otherwise transfers from the caller (calls
|
|
22
|
+
* `transfer`).
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { createClient, http } from 'viem'
|
|
27
|
+
* import { mainnet } from 'viem/chains'
|
|
28
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
29
|
+
* import { token } from 'viem/actions'
|
|
30
|
+
*
|
|
31
|
+
* const client = createClient({
|
|
32
|
+
* account: privateKeyToAccount('0x...'),
|
|
33
|
+
* chain: mainnet,
|
|
34
|
+
* transport: http(),
|
|
35
|
+
* })
|
|
36
|
+
*
|
|
37
|
+
* const { receipt, ...event } = await token.transferSync(client, {
|
|
38
|
+
* amount: 100000000n,
|
|
39
|
+
* to: '0x...',
|
|
40
|
+
* token: '0x...',
|
|
41
|
+
* })
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param client - Client.
|
|
45
|
+
* @param parameters - Parameters.
|
|
46
|
+
* @returns The transaction receipt and event data.
|
|
47
|
+
*/
|
|
48
|
+
export async function transferSync<
|
|
49
|
+
chain extends Chain | undefined,
|
|
50
|
+
account extends Account | undefined,
|
|
51
|
+
tokens extends Tokens | undefined = undefined,
|
|
52
|
+
>(
|
|
53
|
+
client: Client<Transport, chain, account, undefined, undefined, tokens>,
|
|
54
|
+
parameters: transferSync.Parameters<chain, account, tokens>,
|
|
55
|
+
): Promise<transferSync.ReturnValue> {
|
|
56
|
+
const { amount, token, throwOnReceiptRevert = true } = parameters
|
|
57
|
+
const { decimals } = resolveToken(client, { token })
|
|
58
|
+
const resolved = resolveAmountDecimals(amount, decimals)
|
|
59
|
+
const receipt = await transfer.inner(writeContractSync, client, {
|
|
60
|
+
...parameters,
|
|
61
|
+
throwOnReceiptRevert,
|
|
62
|
+
} as never)
|
|
63
|
+
const { args } = transfer.extractEvent(receipt.logs)
|
|
64
|
+
return {
|
|
65
|
+
...args,
|
|
66
|
+
...(resolved === undefined
|
|
67
|
+
? {}
|
|
68
|
+
: { decimals: resolved, formatted: formatUnits(args.value, resolved) }),
|
|
69
|
+
receipt,
|
|
70
|
+
} as never
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export namespace transferSync {
|
|
74
|
+
export type Parameters<
|
|
75
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
76
|
+
account extends Account | undefined = Account | undefined,
|
|
77
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
78
|
+
> = transfer.Parameters<chain, account, tokens>
|
|
79
|
+
export type Args<
|
|
80
|
+
chain extends Chain | undefined = Chain | undefined,
|
|
81
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
82
|
+
> = transfer.Args<chain, tokens>
|
|
83
|
+
export type ReturnValue = Compute<
|
|
84
|
+
GetEventArgs<
|
|
85
|
+
typeof erc20Abi,
|
|
86
|
+
'Transfer',
|
|
87
|
+
{ IndexedOnly: false; Required: true }
|
|
88
|
+
> & {
|
|
89
|
+
/** Token decimals used to derive `formatted`, if known. */
|
|
90
|
+
decimals?: number | undefined
|
|
91
|
+
/** Transferred amount formatted with the token's `decimals`, if known. */
|
|
92
|
+
formatted?: string | undefined
|
|
93
|
+
/** Transaction receipt. */
|
|
94
|
+
receipt: TransactionReceipt
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
// TODO: exhaustive error type
|
|
98
|
+
export type ErrorType = BaseErrorType
|
|
99
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
import { chainConfig } from '../../zksync/chainConfig.js'
|
|
3
|
+
|
|
4
|
+
export const battlechain = /*#__PURE__*/ defineChain({
|
|
5
|
+
...chainConfig,
|
|
6
|
+
id: 626,
|
|
7
|
+
name: 'BattleChain Mainnet',
|
|
8
|
+
network: 'battlechain',
|
|
9
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
10
|
+
rpcUrls: {
|
|
11
|
+
default: {
|
|
12
|
+
http: ['https://mainnet.battlechain.com'],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
blockExplorers: {
|
|
16
|
+
default: {
|
|
17
|
+
name: 'BattleChain Explorer',
|
|
18
|
+
url: 'https://explorer.battlechain.com',
|
|
19
|
+
apiUrl: 'https://block-explorer-api.battlechain.com/api',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
contracts: {
|
|
23
|
+
multicall3: {
|
|
24
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
25
|
+
blockCreated: 40,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const marooTestnet = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 450_815,
|
|
5
|
+
name: 'Maroo Testnet',
|
|
6
|
+
nativeCurrency: { name: 'Testnet OKRW', symbol: 'tOKRW', decimals: 18 },
|
|
7
|
+
rpcUrls: {
|
|
8
|
+
default: {
|
|
9
|
+
http: ['https://rpc-testnet.maroo.io'],
|
|
10
|
+
webSocket: ['wss://ws-testnet.maroo.io'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
blockExplorers: {
|
|
14
|
+
default: {
|
|
15
|
+
name: 'Blockscout',
|
|
16
|
+
url: 'https://explorer-testnet.maroo.io',
|
|
17
|
+
apiUrl: 'https://explorer-testnet.maroo.io/blockscout/api',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
contracts: {
|
|
21
|
+
multicall3: {
|
|
22
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
23
|
+
blockCreated: 0,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
testnet: true,
|
|
27
|
+
})
|
package/chains/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ export { base, basePreconf } from './definitions/base.js'
|
|
|
63
63
|
export { basecampTestnet } from './definitions/basecampTestnet.js'
|
|
64
64
|
export { baseGoerli } from './definitions/baseGoerli.js'
|
|
65
65
|
export { baseSepolia, baseSepoliaPreconf } from './definitions/baseSepolia.js'
|
|
66
|
+
export { battlechain } from './definitions/battlechain.js'
|
|
66
67
|
export { battlechainTestnet } from './definitions/battlechainTestnet.js'
|
|
67
68
|
export { beam } from './definitions/beam.js'
|
|
68
69
|
export { beamTestnet } from './definitions/beamTestnet.js'
|
|
@@ -390,6 +391,7 @@ export { mantleTestnet } from './definitions/mantleTestnet.js'
|
|
|
390
391
|
export { mantraDuKongEVMTestnet } from './definitions/mantraDuKongEVMTestnet.js'
|
|
391
392
|
export { mantraEVM } from './definitions/mantraEVM.js'
|
|
392
393
|
export { mapProtocol } from './definitions/mapProtocol.js'
|
|
394
|
+
export { marooTestnet } from './definitions/marooTestnet.js'
|
|
393
395
|
export { matchain } from './definitions/matchain.js'
|
|
394
396
|
export { matchainTestnet } from './definitions/matchainTestnet.js'
|
|
395
397
|
export { mchVerse } from './definitions/mchVerse.js'
|
package/clients/createClient.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
parseAccount,
|
|
7
7
|
} from '../accounts/utils/parseAccount.js'
|
|
8
8
|
import type { ErrorType } from '../errors/utils.js'
|
|
9
|
+
import type { Tokens } from '../tokens/defineToken.js'
|
|
9
10
|
import type { Account } from '../types/account.js'
|
|
10
11
|
import type { BlockTag } from '../types/block.js'
|
|
11
12
|
import type { Chain } from '../types/chain.js'
|
|
@@ -33,6 +34,7 @@ export type ClientConfig<
|
|
|
33
34
|
| Address
|
|
34
35
|
| undefined,
|
|
35
36
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
37
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
36
38
|
> = {
|
|
37
39
|
/** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
|
|
38
40
|
account?: accountOrAddress | Account | Address | undefined
|
|
@@ -90,6 +92,12 @@ export type ClientConfig<
|
|
|
90
92
|
* Typed JSON-RPC schema for the client.
|
|
91
93
|
*/
|
|
92
94
|
rpcSchema?: rpcSchema | undefined
|
|
95
|
+
/**
|
|
96
|
+
* Collection of tokens to declare on the Client. A token's symbol becomes
|
|
97
|
+
* available to token Actions (e.g. `token.transfer`) only when its `addresses`
|
|
98
|
+
* map includes the Client's `chain.id`.
|
|
99
|
+
*/
|
|
100
|
+
tokens?: tokens | undefined
|
|
93
101
|
/** The RPC transport */
|
|
94
102
|
transport: transport
|
|
95
103
|
/** The type of client. */
|
|
@@ -104,8 +112,9 @@ type ExtendableProtectedActions<
|
|
|
104
112
|
transport extends Transport = Transport,
|
|
105
113
|
chain extends Chain | undefined = Chain | undefined,
|
|
106
114
|
account extends Account | undefined = Account | undefined,
|
|
115
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
107
116
|
> = Pick<
|
|
108
|
-
PublicActions<transport, chain, account>,
|
|
117
|
+
PublicActions<transport, chain, account, tokens>,
|
|
109
118
|
| 'call'
|
|
110
119
|
| 'createContractEventFilter'
|
|
111
120
|
| 'createEventFilter'
|
|
@@ -130,7 +139,10 @@ type ExtendableProtectedActions<
|
|
|
130
139
|
| 'watchBlockNumber'
|
|
131
140
|
| 'watchContractEvent'
|
|
132
141
|
> &
|
|
133
|
-
Pick<
|
|
142
|
+
Pick<
|
|
143
|
+
WalletActions<chain, account, tokens>,
|
|
144
|
+
'sendTransaction' | 'writeContract'
|
|
145
|
+
>
|
|
134
146
|
|
|
135
147
|
// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.
|
|
136
148
|
// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.
|
|
@@ -140,21 +152,25 @@ export type Client<
|
|
|
140
152
|
account extends Account | undefined = Account | undefined,
|
|
141
153
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
142
154
|
extended extends Extended | undefined = Extended | undefined,
|
|
143
|
-
|
|
155
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
156
|
+
> = Client_Base<transport, chain, account, rpcSchema, tokens> &
|
|
144
157
|
(extended extends Extended ? extended : unknown) & {
|
|
145
158
|
extend: <
|
|
146
159
|
const client extends Extended &
|
|
147
|
-
ExactPartial<
|
|
160
|
+
ExactPartial<
|
|
161
|
+
ExtendableProtectedActions<transport, chain, account, tokens>
|
|
162
|
+
>,
|
|
148
163
|
>(
|
|
149
164
|
fn: (
|
|
150
|
-
client: Client<transport, chain, account, rpcSchema, extended>,
|
|
165
|
+
client: Client<transport, chain, account, rpcSchema, extended, tokens>,
|
|
151
166
|
) => client,
|
|
152
167
|
) => Client<
|
|
153
168
|
transport,
|
|
154
169
|
chain,
|
|
155
170
|
account,
|
|
156
171
|
rpcSchema,
|
|
157
|
-
Prettify<client> & (extended extends Extended ? extended : unknown)
|
|
172
|
+
Prettify<client> & (extended extends Extended ? extended : unknown),
|
|
173
|
+
tokens
|
|
158
174
|
>
|
|
159
175
|
}
|
|
160
176
|
|
|
@@ -163,6 +179,7 @@ type Client_Base<
|
|
|
163
179
|
chain extends Chain | undefined = Chain | undefined,
|
|
164
180
|
account extends Account | undefined = Account | undefined,
|
|
165
181
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
182
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
166
183
|
> = {
|
|
167
184
|
/** The Account of the Client. */
|
|
168
185
|
account: account
|
|
@@ -188,6 +205,8 @@ type Client_Base<
|
|
|
188
205
|
request: EIP1193RequestFn<
|
|
189
206
|
rpcSchema extends undefined ? EIP1474Methods : rpcSchema
|
|
190
207
|
>
|
|
208
|
+
/** Collection of tokens declared on the Client. */
|
|
209
|
+
tokens: tokens
|
|
191
210
|
/** The RPC transport */
|
|
192
211
|
transport: ReturnType<transport>['config'] & ReturnType<transport>['value']
|
|
193
212
|
/** The type of client. */
|
|
@@ -219,8 +238,15 @@ export function createClient<
|
|
|
219
238
|
chain extends Chain | undefined = undefined,
|
|
220
239
|
accountOrAddress extends Account | Address | undefined = undefined,
|
|
221
240
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
241
|
+
const tokens extends Tokens | undefined = undefined,
|
|
222
242
|
>(
|
|
223
|
-
parameters: ClientConfig<
|
|
243
|
+
parameters: ClientConfig<
|
|
244
|
+
transport,
|
|
245
|
+
chain,
|
|
246
|
+
accountOrAddress,
|
|
247
|
+
rpcSchema,
|
|
248
|
+
tokens
|
|
249
|
+
>,
|
|
224
250
|
): Prettify<
|
|
225
251
|
Client<
|
|
226
252
|
transport,
|
|
@@ -228,7 +254,9 @@ export function createClient<
|
|
|
228
254
|
accountOrAddress extends Address
|
|
229
255
|
? Prettify<JsonRpcAccount<accountOrAddress>>
|
|
230
256
|
: accountOrAddress,
|
|
231
|
-
rpcSchema
|
|
257
|
+
rpcSchema,
|
|
258
|
+
undefined,
|
|
259
|
+
tokens
|
|
232
260
|
>
|
|
233
261
|
>
|
|
234
262
|
|
|
@@ -240,6 +268,7 @@ export function createClient(parameters: ClientConfig): Client {
|
|
|
240
268
|
dataSuffix,
|
|
241
269
|
key = 'base',
|
|
242
270
|
name = 'Base Client',
|
|
271
|
+
tokens,
|
|
243
272
|
type = 'base',
|
|
244
273
|
} = parameters
|
|
245
274
|
|
|
@@ -278,6 +307,7 @@ export function createClient(parameters: ClientConfig): Client {
|
|
|
278
307
|
name,
|
|
279
308
|
pollingInterval,
|
|
280
309
|
request,
|
|
310
|
+
tokens,
|
|
281
311
|
transport,
|
|
282
312
|
type,
|
|
283
313
|
uid: uid(),
|
|
@@ -290,6 +320,17 @@ export function createClient(parameters: ClientConfig): Client {
|
|
|
290
320
|
const extended = extendFn(base) as Extended
|
|
291
321
|
for (const key in client) delete extended[key]
|
|
292
322
|
const combined = { ...base, ...extended }
|
|
323
|
+
// For keys that exist on both the base client and the extension and
|
|
324
|
+
// resolve to plain objects (e.g. namespaces like `token`), shallow-merge
|
|
325
|
+
// their members instead of overwriting. This lets decorators contribute
|
|
326
|
+
// to the same namespace (e.g. `publicActions` adds read actions and
|
|
327
|
+
// `walletActions` adds write actions to `client.token`).
|
|
328
|
+
for (const key in extended) {
|
|
329
|
+
const a = (base as Record<string, unknown>)[key]
|
|
330
|
+
const b = (extended as Record<string, unknown>)[key]
|
|
331
|
+
if (isPlainObject(a) && isPlainObject(b))
|
|
332
|
+
(combined as Record<string, unknown>)[key] = { ...a, ...b }
|
|
333
|
+
}
|
|
293
334
|
return Object.assign(combined, { extend: extend(combined as any) })
|
|
294
335
|
}
|
|
295
336
|
}
|
|
@@ -297,6 +338,47 @@ export function createClient(parameters: ClientConfig): Client {
|
|
|
297
338
|
return Object.assign(client, { extend: extend(client) as any })
|
|
298
339
|
}
|
|
299
340
|
|
|
341
|
+
/** Whether `value` is a plain object (`{}`), as opposed to a function, array,
|
|
342
|
+
* or class instance. Used to decide which extension namespaces to merge. */
|
|
343
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
344
|
+
if (typeof value !== 'object' || value === null) return false
|
|
345
|
+
const prototype = Object.getPrototypeOf(value)
|
|
346
|
+
return prototype === Object.prototype || prototype === null
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Binds an action function to a `client`, returning a parameter-only version
|
|
351
|
+
* along with any helpers the action exposes. Helpers that need a client
|
|
352
|
+
* (`.call`, `.calls`, `.callWithPeriod`, `.estimateGas`, `.simulate`) are bound
|
|
353
|
+
* to `client`; pure helpers (`.extractEvent`, `.extractEvents`) are copied
|
|
354
|
+
* as-is. Used by decorators that attach namespaced actions to a Client.
|
|
355
|
+
* @internal
|
|
356
|
+
*/
|
|
357
|
+
export function bindActionDecorators(
|
|
358
|
+
client: Client<Transport, Chain | undefined, any>,
|
|
359
|
+
action: any,
|
|
360
|
+
) {
|
|
361
|
+
const wrapped: any = (parameters: any = {}) => action(client, parameters)
|
|
362
|
+
for (const key of [
|
|
363
|
+
'call',
|
|
364
|
+
'calls',
|
|
365
|
+
'callWithPeriod',
|
|
366
|
+
'estimateGas',
|
|
367
|
+
'simulate',
|
|
368
|
+
] as const)
|
|
369
|
+
if (Object.hasOwn(action, key)) {
|
|
370
|
+
const helper = action[key]
|
|
371
|
+
wrapped[key] = (args: any = {}) => {
|
|
372
|
+
if (helper.length >= 2) return helper(client, args)
|
|
373
|
+
if (helper.length === 0) return helper()
|
|
374
|
+
return helper(args)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
for (const key of ['extractEvent', 'extractEvents'] as const)
|
|
378
|
+
if (Object.hasOwn(action, key)) wrapped[key] = action[key]
|
|
379
|
+
return wrapped
|
|
380
|
+
}
|
|
381
|
+
|
|
300
382
|
/**
|
|
301
383
|
* Defines a typed JSON-RPC schema for the client.
|
|
302
384
|
* Note: This is a runtime noop function.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Address } from 'abitype'
|
|
2
2
|
import type { ErrorType } from '../errors/utils.js'
|
|
3
|
+
import type { Tokens } from '../tokens/defineToken.js'
|
|
3
4
|
import type { Account, ParseAccount } from '../types/account.js'
|
|
4
5
|
import type { Chain } from '../types/chain.js'
|
|
5
6
|
import type { PublicRpcSchema, RpcSchema } from '../types/eip1193.js'
|
|
@@ -18,9 +19,10 @@ export type PublicClientConfig<
|
|
|
18
19
|
chain extends Chain | undefined = Chain | undefined,
|
|
19
20
|
accountOrAddress extends Account | Address | undefined = undefined,
|
|
20
21
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
22
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
21
23
|
> = Prettify<
|
|
22
24
|
Pick<
|
|
23
|
-
ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
|
|
25
|
+
ClientConfig<transport, chain, accountOrAddress, rpcSchema, tokens>,
|
|
24
26
|
| 'batch'
|
|
25
27
|
| 'cacheTime'
|
|
26
28
|
| 'ccipRead'
|
|
@@ -30,6 +32,7 @@ export type PublicClientConfig<
|
|
|
30
32
|
| 'name'
|
|
31
33
|
| 'pollingInterval'
|
|
32
34
|
| 'rpcSchema'
|
|
35
|
+
| 'tokens'
|
|
33
36
|
| 'transport'
|
|
34
37
|
>
|
|
35
38
|
>
|
|
@@ -39,6 +42,7 @@ export type PublicClient<
|
|
|
39
42
|
chain extends Chain | undefined = Chain | undefined,
|
|
40
43
|
accountOrAddress extends Account | undefined = undefined,
|
|
41
44
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
45
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
42
46
|
> = Prettify<
|
|
43
47
|
Client<
|
|
44
48
|
transport,
|
|
@@ -47,7 +51,8 @@ export type PublicClient<
|
|
|
47
51
|
rpcSchema extends RpcSchema
|
|
48
52
|
? [...PublicRpcSchema, ...rpcSchema]
|
|
49
53
|
: PublicRpcSchema,
|
|
50
|
-
PublicActions<transport, chain
|
|
54
|
+
PublicActions<transport, chain, accountOrAddress, tokens>,
|
|
55
|
+
tokens
|
|
51
56
|
>
|
|
52
57
|
>
|
|
53
58
|
|
|
@@ -77,9 +82,22 @@ export function createPublicClient<
|
|
|
77
82
|
chain extends Chain | undefined = undefined,
|
|
78
83
|
accountOrAddress extends Account | Address | undefined = undefined,
|
|
79
84
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
85
|
+
const tokens extends Tokens | undefined = undefined,
|
|
80
86
|
>(
|
|
81
|
-
parameters: PublicClientConfig<
|
|
82
|
-
|
|
87
|
+
parameters: PublicClientConfig<
|
|
88
|
+
transport,
|
|
89
|
+
chain,
|
|
90
|
+
accountOrAddress,
|
|
91
|
+
rpcSchema,
|
|
92
|
+
tokens
|
|
93
|
+
>,
|
|
94
|
+
): PublicClient<
|
|
95
|
+
transport,
|
|
96
|
+
chain,
|
|
97
|
+
ParseAccount<accountOrAddress>,
|
|
98
|
+
rpcSchema,
|
|
99
|
+
tokens
|
|
100
|
+
> {
|
|
83
101
|
const { key = 'public', name = 'Public Client' } = parameters
|
|
84
102
|
const client = createClient({
|
|
85
103
|
...parameters,
|
|
@@ -2,6 +2,7 @@ import type { Address } from 'abitype'
|
|
|
2
2
|
|
|
3
3
|
import type { Account } from '../accounts/types.js'
|
|
4
4
|
import type { ErrorType } from '../errors/utils.js'
|
|
5
|
+
import type { Tokens } from '../tokens/defineToken.js'
|
|
5
6
|
import type { ParseAccount } from '../types/account.js'
|
|
6
7
|
import type { Chain } from '../types/chain.js'
|
|
7
8
|
import type { RpcSchema, WalletRpcSchema } from '../types/eip1193.js'
|
|
@@ -23,9 +24,10 @@ export type WalletClientConfig<
|
|
|
23
24
|
| Address
|
|
24
25
|
| undefined,
|
|
25
26
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
27
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
26
28
|
> = Prettify<
|
|
27
29
|
Pick<
|
|
28
|
-
ClientConfig<transport, chain, accountOrAddress, rpcSchema>,
|
|
30
|
+
ClientConfig<transport, chain, accountOrAddress, rpcSchema, tokens>,
|
|
29
31
|
| 'account'
|
|
30
32
|
| 'cacheTime'
|
|
31
33
|
| 'ccipRead'
|
|
@@ -35,6 +37,7 @@ export type WalletClientConfig<
|
|
|
35
37
|
| 'name'
|
|
36
38
|
| 'pollingInterval'
|
|
37
39
|
| 'rpcSchema'
|
|
40
|
+
| 'tokens'
|
|
38
41
|
| 'transport'
|
|
39
42
|
>
|
|
40
43
|
>
|
|
@@ -44,6 +47,7 @@ export type WalletClient<
|
|
|
44
47
|
chain extends Chain | undefined = Chain | undefined,
|
|
45
48
|
account extends Account | undefined = Account | undefined,
|
|
46
49
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
50
|
+
tokens extends Tokens | undefined = Tokens | undefined,
|
|
47
51
|
> = Prettify<
|
|
48
52
|
Client<
|
|
49
53
|
transport,
|
|
@@ -52,7 +56,8 @@ export type WalletClient<
|
|
|
52
56
|
rpcSchema extends RpcSchema
|
|
53
57
|
? [...WalletRpcSchema, ...rpcSchema]
|
|
54
58
|
: WalletRpcSchema,
|
|
55
|
-
WalletActions<chain, account
|
|
59
|
+
WalletActions<chain, account, tokens>,
|
|
60
|
+
tokens
|
|
56
61
|
>
|
|
57
62
|
>
|
|
58
63
|
|
|
@@ -99,9 +104,22 @@ export function createWalletClient<
|
|
|
99
104
|
chain extends Chain | undefined = undefined,
|
|
100
105
|
accountOrAddress extends Account | Address | undefined = undefined,
|
|
101
106
|
rpcSchema extends RpcSchema | undefined = undefined,
|
|
107
|
+
const tokens extends Tokens | undefined = undefined,
|
|
102
108
|
>(
|
|
103
|
-
parameters: WalletClientConfig<
|
|
104
|
-
|
|
109
|
+
parameters: WalletClientConfig<
|
|
110
|
+
transport,
|
|
111
|
+
chain,
|
|
112
|
+
accountOrAddress,
|
|
113
|
+
rpcSchema,
|
|
114
|
+
tokens
|
|
115
|
+
>,
|
|
116
|
+
): WalletClient<
|
|
117
|
+
transport,
|
|
118
|
+
chain,
|
|
119
|
+
ParseAccount<accountOrAddress>,
|
|
120
|
+
rpcSchema,
|
|
121
|
+
tokens
|
|
122
|
+
>
|
|
105
123
|
|
|
106
124
|
export function createWalletClient(
|
|
107
125
|
parameters: WalletClientConfig,
|