viem 2.18.7 → 2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +42 -0
- package/README.md +1 -1
- package/_cjs/account-abstraction/errors/bundler.js +36 -216
- package/_cjs/account-abstraction/errors/bundler.js.map +1 -1
- package/_cjs/account-abstraction/errors/userOperation.js +5 -26
- package/_cjs/account-abstraction/errors/userOperation.js.map +1 -1
- package/_cjs/accounts/index.js +3 -1
- package/_cjs/accounts/index.js.map +1 -1
- package/_cjs/accounts/privateKeyToAccount.js +4 -0
- package/_cjs/accounts/privateKeyToAccount.js.map +1 -1
- package/_cjs/accounts/toAccount.js +1 -0
- package/_cjs/accounts/toAccount.js.map +1 -1
- package/_cjs/accounts/utils/signAuthorization.js +22 -0
- package/_cjs/accounts/utils/signAuthorization.js.map +1 -0
- package/_cjs/actions/public/estimateGas.js +48 -10
- package/_cjs/actions/public/estimateGas.js.map +1 -1
- package/_cjs/actions/public/simulateContract.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +21 -3
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/abstractTestnet.js +26 -0
- package/_cjs/chains/definitions/abstractTestnet.js.map +1 -0
- package/_cjs/chains/definitions/b3Sepolia.js +28 -0
- package/_cjs/chains/definitions/b3Sepolia.js.map +1 -0
- package/_cjs/chains/definitions/{zkSync.js → zksync.js} +6 -5
- package/_cjs/chains/definitions/{zkSync.js.map → zksync.js.map} +1 -1
- package/_cjs/chains/definitions/{zkSyncInMemoryNode.js → zksyncInMemoryNode.js} +4 -4
- package/_cjs/chains/definitions/{zkSyncInMemoryNode.js.map → zksyncInMemoryNode.js.map} +1 -1
- package/_cjs/chains/definitions/{zkSyncLocalNode.js → zksyncLocalNode.js} +4 -4
- package/_cjs/chains/definitions/{zkSyncLocalNode.js.map → zksyncLocalNode.js.map} +1 -1
- package/_cjs/chains/definitions/{zkSyncSepoliaTestnet.js → zksyncSepoliaTestnet.js} +7 -5
- package/_cjs/chains/definitions/zksyncSepoliaTestnet.js.map +1 -0
- package/_cjs/chains/index.js +23 -17
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/abi.js +32 -163
- package/_cjs/errors/abi.js.map +1 -1
- package/_cjs/errors/account.js +2 -12
- package/_cjs/errors/account.js.map +1 -1
- package/_cjs/errors/address.js +1 -6
- package/_cjs/errors/address.js.map +1 -1
- package/_cjs/errors/base.js +29 -18
- package/_cjs/errors/base.js.map +1 -1
- package/_cjs/errors/blob.js +4 -25
- package/_cjs/errors/blob.js.map +1 -1
- package/_cjs/errors/block.js +1 -7
- package/_cjs/errors/block.js.map +1 -1
- package/_cjs/errors/ccip.js +3 -18
- package/_cjs/errors/ccip.js.map +1 -1
- package/_cjs/errors/chain.js +7 -31
- package/_cjs/errors/chain.js.map +1 -1
- package/_cjs/errors/contract.js +6 -37
- package/_cjs/errors/contract.js.map +1 -1
- package/_cjs/errors/cursor.js +4 -20
- package/_cjs/errors/cursor.js.map +1 -1
- package/_cjs/errors/data.js +3 -21
- package/_cjs/errors/data.js.map +1 -1
- package/_cjs/errors/eip712.js +1 -6
- package/_cjs/errors/eip712.js.map +1 -1
- package/_cjs/errors/encoding.js +6 -34
- package/_cjs/errors/encoding.js.map +1 -1
- package/_cjs/errors/ens.js +5 -26
- package/_cjs/errors/ens.js.map +1 -1
- package/_cjs/errors/estimateGas.js +1 -6
- package/_cjs/errors/estimateGas.js.map +1 -1
- package/_cjs/errors/fee.js +5 -19
- package/_cjs/errors/fee.js.map +1 -1
- package/_cjs/errors/log.js +2 -6
- package/_cjs/errors/log.js.map +1 -1
- package/_cjs/errors/node.js +12 -75
- package/_cjs/errors/node.js.map +1 -1
- package/_cjs/errors/request.js +5 -30
- package/_cjs/errors/request.js.map +1 -1
- package/_cjs/errors/rpc.js +22 -122
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/errors/siwe.js +1 -7
- package/_cjs/errors/siwe.js.map +1 -1
- package/_cjs/errors/stateOverride.js +4 -12
- package/_cjs/errors/stateOverride.js.map +1 -1
- package/_cjs/errors/transaction.js +15 -63
- package/_cjs/errors/transaction.js.map +1 -1
- package/_cjs/errors/transport.js +1 -0
- package/_cjs/errors/transport.js.map +1 -1
- package/_cjs/errors/utils.js +1 -4
- package/_cjs/errors/utils.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip5792/decorators/eip5792.js +2 -2
- package/_cjs/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_cjs/experimental/eip7702/actions/signAuthorization.js +41 -0
- package/_cjs/experimental/eip7702/actions/signAuthorization.js.map +1 -0
- package/_cjs/experimental/eip7702/decorators/eip7702.js +12 -0
- package/_cjs/experimental/eip7702/decorators/eip7702.js.map +1 -0
- package/_cjs/experimental/eip7702/types/authorization.js +3 -0
- package/_cjs/experimental/eip7702/types/authorization.js.map +1 -0
- package/_cjs/experimental/eip7702/types/rpc.js +3 -0
- package/_cjs/experimental/eip7702/types/rpc.js.map +1 -0
- package/_cjs/experimental/eip7702/utils/hashAuthorization.js +23 -0
- package/_cjs/experimental/eip7702/utils/hashAuthorization.js.map +1 -0
- package/_cjs/experimental/eip7702/utils/recoverAuthorizationAddress.js +13 -0
- package/_cjs/experimental/eip7702/utils/recoverAuthorizationAddress.js.map +1 -0
- package/_cjs/experimental/eip7702/utils/serializeAuthorizationList.js +21 -0
- package/_cjs/experimental/eip7702/utils/serializeAuthorizationList.js.map +1 -0
- package/_cjs/experimental/eip7702/utils/verifyAuthorization.js +13 -0
- package/_cjs/experimental/eip7702/utils/verifyAuthorization.js.map +1 -0
- package/_cjs/experimental/erc7715/decorators/erc7715.js +2 -2
- package/_cjs/experimental/erc7715/decorators/erc7715.js.map +1 -1
- package/_cjs/experimental/index.js +22 -8
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/index.js +7 -6
- package/_cjs/index.js.map +1 -1
- package/_cjs/op-stack/errors/withdrawal.js +2 -14
- package/_cjs/op-stack/errors/withdrawal.js.map +1 -1
- package/_cjs/utils/formatters/transaction.js +19 -0
- package/_cjs/utils/formatters/transaction.js.map +1 -1
- package/_cjs/utils/formatters/transactionRequest.js +19 -0
- package/_cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/_cjs/utils/transaction/assertTransaction.js +15 -3
- package/_cjs/utils/transaction/assertTransaction.js.map +1 -1
- package/_cjs/utils/transaction/getSerializedTransactionType.js +2 -0
- package/_cjs/utils/transaction/getSerializedTransactionType.js.map +1 -1
- package/_cjs/utils/transaction/getTransactionType.js +2 -0
- package/_cjs/utils/transaction/getTransactionType.js.map +1 -1
- package/_cjs/utils/transaction/parseTransaction.js +70 -0
- package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
- package/_cjs/utils/transaction/serializeTransaction.js +25 -0
- package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/_cjs/zksync/chains.js +9 -7
- package/_cjs/zksync/chains.js.map +1 -1
- package/_cjs/zksync/errors/bytecode.js +3 -21
- package/_cjs/zksync/errors/bytecode.js.map +1 -1
- package/_cjs/zksync/errors/token-is-eth.js +1 -7
- package/_cjs/zksync/errors/token-is-eth.js.map +1 -1
- package/_cjs/zksync/errors/transaction.js +1 -7
- package/_cjs/zksync/errors/transaction.js.map +1 -1
- package/_cjs/zksync/index.js +9 -4
- package/_cjs/zksync/index.js.map +1 -1
- package/_cjs/zksync/utils/getEip712Domain.js +1 -1
- package/_cjs/zksync/utils/isEip712Transaction.js.map +1 -1
- package/_esm/account-abstraction/errors/bundler.js +36 -216
- package/_esm/account-abstraction/errors/bundler.js.map +1 -1
- package/_esm/account-abstraction/errors/userOperation.js +5 -26
- package/_esm/account-abstraction/errors/userOperation.js.map +1 -1
- package/_esm/accounts/index.js +1 -0
- package/_esm/accounts/index.js.map +1 -1
- package/_esm/accounts/privateKeyToAccount.js +4 -0
- package/_esm/accounts/privateKeyToAccount.js.map +1 -1
- package/_esm/accounts/toAccount.js +1 -0
- package/_esm/accounts/toAccount.js.map +1 -1
- package/_esm/accounts/utils/signAuthorization.js +22 -0
- package/_esm/accounts/utils/signAuthorization.js.map +1 -0
- package/_esm/actions/public/estimateGas.js +55 -10
- package/_esm/actions/public/estimateGas.js.map +1 -1
- package/_esm/actions/public/simulateContract.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +25 -3
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/abstractTestnet.js +23 -0
- package/_esm/chains/definitions/abstractTestnet.js.map +1 -0
- package/_esm/chains/definitions/b3Sepolia.js +25 -0
- package/_esm/chains/definitions/b3Sepolia.js.map +1 -0
- package/_esm/chains/definitions/{zkSync.js → zksync.js} +5 -4
- package/_esm/chains/definitions/{zkSync.js.map → zksync.js.map} +1 -1
- package/_esm/chains/definitions/{zkSyncInMemoryNode.js → zksyncInMemoryNode.js} +3 -3
- package/_esm/chains/definitions/{zkSyncInMemoryNode.js.map → zksyncInMemoryNode.js.map} +1 -1
- package/_esm/chains/definitions/{zkSyncLocalNode.js → zksyncLocalNode.js} +3 -3
- package/_esm/chains/definitions/{zkSyncLocalNode.js.map → zksyncLocalNode.js.map} +1 -1
- package/_esm/chains/definitions/{zkSyncSepoliaTestnet.js → zksyncSepoliaTestnet.js} +6 -4
- package/_esm/chains/definitions/{zkSyncSepoliaTestnet.js.map → zksyncSepoliaTestnet.js.map} +1 -1
- package/_esm/chains/index.js +14 -5
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/abi.js +32 -163
- package/_esm/errors/abi.js.map +1 -1
- package/_esm/errors/account.js +2 -12
- package/_esm/errors/account.js.map +1 -1
- package/_esm/errors/address.js +1 -6
- package/_esm/errors/address.js.map +1 -1
- package/_esm/errors/base.js +27 -17
- package/_esm/errors/base.js.map +1 -1
- package/_esm/errors/blob.js +4 -25
- package/_esm/errors/blob.js.map +1 -1
- package/_esm/errors/block.js +1 -7
- package/_esm/errors/block.js.map +1 -1
- package/_esm/errors/ccip.js +3 -18
- package/_esm/errors/ccip.js.map +1 -1
- package/_esm/errors/chain.js +7 -31
- package/_esm/errors/chain.js.map +1 -1
- package/_esm/errors/contract.js +6 -37
- package/_esm/errors/contract.js.map +1 -1
- package/_esm/errors/cursor.js +4 -20
- package/_esm/errors/cursor.js.map +1 -1
- package/_esm/errors/data.js +3 -21
- package/_esm/errors/data.js.map +1 -1
- package/_esm/errors/eip712.js +1 -6
- package/_esm/errors/eip712.js.map +1 -1
- package/_esm/errors/encoding.js +6 -34
- package/_esm/errors/encoding.js.map +1 -1
- package/_esm/errors/ens.js +5 -26
- package/_esm/errors/ens.js.map +1 -1
- package/_esm/errors/estimateGas.js +1 -6
- package/_esm/errors/estimateGas.js.map +1 -1
- package/_esm/errors/fee.js +5 -19
- package/_esm/errors/fee.js.map +1 -1
- package/_esm/errors/log.js +2 -6
- package/_esm/errors/log.js.map +1 -1
- package/_esm/errors/node.js +12 -75
- package/_esm/errors/node.js.map +1 -1
- package/_esm/errors/request.js +5 -30
- package/_esm/errors/request.js.map +1 -1
- package/_esm/errors/rpc.js +22 -122
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/errors/siwe.js +1 -7
- package/_esm/errors/siwe.js.map +1 -1
- package/_esm/errors/stateOverride.js +4 -12
- package/_esm/errors/stateOverride.js.map +1 -1
- package/_esm/errors/transaction.js +15 -63
- package/_esm/errors/transaction.js.map +1 -1
- package/_esm/errors/transport.js +1 -0
- package/_esm/errors/transport.js.map +1 -1
- package/_esm/errors/utils.js +0 -2
- package/_esm/errors/utils.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip5792/decorators/eip5792.js +3 -3
- package/_esm/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_esm/experimental/eip7702/actions/signAuthorization.js +80 -0
- package/_esm/experimental/eip7702/actions/signAuthorization.js.map +1 -0
- package/_esm/experimental/eip7702/decorators/eip7702.js +24 -0
- package/_esm/experimental/eip7702/decorators/eip7702.js.map +1 -0
- package/_esm/experimental/eip7702/types/authorization.js +2 -0
- package/_esm/experimental/eip7702/types/authorization.js.map +1 -0
- package/_esm/experimental/eip7702/types/rpc.js +2 -0
- package/_esm/experimental/eip7702/types/rpc.js.map +1 -0
- package/_esm/experimental/eip7702/utils/hashAuthorization.js +23 -0
- package/_esm/experimental/eip7702/utils/hashAuthorization.js.map +1 -0
- package/_esm/experimental/eip7702/utils/recoverAuthorizationAddress.js +10 -0
- package/_esm/experimental/eip7702/utils/recoverAuthorizationAddress.js.map +1 -0
- package/_esm/experimental/eip7702/utils/serializeAuthorizationList.js +21 -0
- package/_esm/experimental/eip7702/utils/serializeAuthorizationList.js.map +1 -0
- package/_esm/experimental/eip7702/utils/verifyAuthorization.js +18 -0
- package/_esm/experimental/eip7702/utils/verifyAuthorization.js.map +1 -0
- package/_esm/experimental/erc7715/decorators/erc7715.js +3 -3
- package/_esm/experimental/erc7715/decorators/erc7715.js.map +1 -1
- package/_esm/experimental/index.js +16 -4
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/op-stack/errors/withdrawal.js +2 -14
- package/_esm/op-stack/errors/withdrawal.js.map +1 -1
- package/_esm/utils/formatters/transaction.js +20 -0
- package/_esm/utils/formatters/transaction.js.map +1 -1
- package/_esm/utils/formatters/transactionRequest.js +20 -0
- package/_esm/utils/formatters/transactionRequest.js.map +1 -1
- package/_esm/utils/transaction/assertTransaction.js +14 -3
- package/_esm/utils/transaction/assertTransaction.js.map +1 -1
- package/_esm/utils/transaction/getSerializedTransactionType.js +2 -0
- package/_esm/utils/transaction/getSerializedTransactionType.js.map +1 -1
- package/_esm/utils/transaction/getTransactionType.js +2 -0
- package/_esm/utils/transaction/getTransactionType.js.map +1 -1
- package/_esm/utils/transaction/parseTransaction.js +71 -1
- package/_esm/utils/transaction/parseTransaction.js.map +1 -1
- package/_esm/utils/transaction/serializeTransaction.js +26 -1
- package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/_esm/zksync/actions/deployContract.js +1 -1
- package/_esm/zksync/actions/sendEip712Transaction.js +4 -4
- package/_esm/zksync/actions/sendTransaction.js +4 -4
- package/_esm/zksync/actions/signEip712Transaction.js +4 -4
- package/_esm/zksync/actions/signTransaction.js +4 -4
- package/_esm/zksync/chains.js +4 -3
- package/_esm/zksync/chains.js.map +1 -1
- package/_esm/zksync/errors/bytecode.js +3 -21
- package/_esm/zksync/errors/bytecode.js.map +1 -1
- package/_esm/zksync/errors/token-is-eth.js +1 -7
- package/_esm/zksync/errors/token-is-eth.js.map +1 -1
- package/_esm/zksync/errors/transaction.js +1 -7
- package/_esm/zksync/errors/transaction.js.map +1 -1
- package/_esm/zksync/index.js +9 -1
- package/_esm/zksync/index.js.map +1 -1
- package/_esm/zksync/utils/getEip712Domain.js +1 -1
- package/_esm/zksync/utils/isEip712Transaction.js.map +1 -1
- package/_types/account-abstraction/errors/bundler.d.ts +0 -36
- package/_types/account-abstraction/errors/bundler.d.ts.map +1 -1
- package/_types/account-abstraction/errors/userOperation.d.ts +0 -4
- package/_types/account-abstraction/errors/userOperation.d.ts.map +1 -1
- package/_types/accounts/index.d.ts +1 -0
- package/_types/accounts/index.d.ts.map +1 -1
- package/_types/accounts/privateKeyToAccount.d.ts.map +1 -1
- package/_types/accounts/toAccount.d.ts.map +1 -1
- package/_types/accounts/types.d.ts +7 -3
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/accounts/utils/signAuthorization.d.ts +20 -0
- package/_types/accounts/utils/signAuthorization.d.ts.map +1 -0
- package/_types/actions/public/estimateGas.d.ts +2 -1
- package/_types/actions/public/estimateGas.d.ts.map +1 -1
- package/_types/actions/public/simulateContract.d.ts +18 -6
- package/_types/actions/public/simulateContract.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +2 -2
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +2 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +3 -2
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/celo/chainConfig.d.ts +144 -20
- package/_types/celo/chainConfig.d.ts.map +1 -1
- package/_types/celo/formatters.d.ts +72 -10
- package/_types/celo/formatters.d.ts.map +1 -1
- package/_types/celo/serializers.d.ts +1 -1
- package/_types/celo/serializers.d.ts.map +1 -1
- package/_types/chains/definitions/{zkSyncTestnet.d.ts → abstractTestnet.d.ts} +81 -27
- package/_types/chains/definitions/{zkSyncLocalNode.d.ts.map → abstractTestnet.d.ts.map} +1 -1
- package/_types/chains/definitions/ancient8.d.ts +32 -0
- package/_types/chains/definitions/ancient8.d.ts.map +1 -1
- package/_types/chains/definitions/ancient8Sepolia.d.ts +32 -0
- package/_types/chains/definitions/ancient8Sepolia.d.ts.map +1 -1
- package/_types/chains/definitions/b3Sepolia.d.ts +35 -0
- package/_types/chains/definitions/b3Sepolia.d.ts.map +1 -0
- package/_types/chains/definitions/base.d.ts +32 -0
- package/_types/chains/definitions/base.d.ts.map +1 -1
- package/_types/chains/definitions/baseGoerli.d.ts +32 -0
- package/_types/chains/definitions/baseGoerli.d.ts.map +1 -1
- package/_types/chains/definitions/baseSepolia.d.ts +32 -0
- package/_types/chains/definitions/baseSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/celo.d.ts +144 -20
- package/_types/chains/definitions/celo.d.ts.map +1 -1
- package/_types/chains/definitions/celoAlfajores.d.ts +144 -20
- package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
- package/_types/chains/definitions/dchain.d.ts +32 -0
- package/_types/chains/definitions/dchain.d.ts.map +1 -1
- package/_types/chains/definitions/dchainTestnet.d.ts +32 -0
- package/_types/chains/definitions/dchainTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/fraxtal.d.ts +32 -0
- package/_types/chains/definitions/fraxtal.d.ts.map +1 -1
- package/_types/chains/definitions/fraxtalTestnet.d.ts +32 -0
- package/_types/chains/definitions/fraxtalTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/funkiMainnet.d.ts +32 -0
- package/_types/chains/definitions/funkiMainnet.d.ts.map +1 -1
- package/_types/chains/definitions/funkiSepolia.d.ts +32 -0
- package/_types/chains/definitions/funkiSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/lisk.d.ts +32 -0
- package/_types/chains/definitions/lisk.d.ts.map +1 -1
- package/_types/chains/definitions/liskSepolia.d.ts +32 -0
- package/_types/chains/definitions/liskSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/metalL2.d.ts +32 -0
- package/_types/chains/definitions/metalL2.d.ts.map +1 -1
- package/_types/chains/definitions/modeTestnet.d.ts +32 -0
- package/_types/chains/definitions/modeTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/optimism.d.ts +32 -0
- package/_types/chains/definitions/optimism.d.ts.map +1 -1
- package/_types/chains/definitions/optimismGoerli.d.ts +32 -0
- package/_types/chains/definitions/optimismGoerli.d.ts.map +1 -1
- package/_types/chains/definitions/optimismSepolia.d.ts +32 -0
- package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/pgn.d.ts +32 -0
- package/_types/chains/definitions/pgn.d.ts.map +1 -1
- package/_types/chains/definitions/pgnTestnet.d.ts +32 -0
- package/_types/chains/definitions/pgnTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/playfiAlbireo.d.ts +64 -10
- package/_types/chains/definitions/playfiAlbireo.d.ts.map +1 -1
- package/_types/chains/definitions/rss3.d.ts +32 -0
- package/_types/chains/definitions/rss3.d.ts.map +1 -1
- package/_types/chains/definitions/rss3Sepolia.d.ts +32 -0
- package/_types/chains/definitions/rss3Sepolia.d.ts.map +1 -1
- package/_types/chains/definitions/{zkSync.d.ts → zksync.d.ts} +69 -14
- package/_types/chains/definitions/{zkSync.d.ts.map → zksync.d.ts.map} +1 -1
- package/_types/chains/definitions/{zkSyncInMemoryNode.d.ts → zksyncInMemoryNode.d.ts} +67 -13
- package/_types/chains/definitions/{zkSyncInMemoryNode.d.ts.map → zksyncInMemoryNode.d.ts.map} +1 -1
- package/_types/chains/definitions/{zkSyncLocalNode.d.ts → zksyncLocalNode.d.ts} +67 -13
- package/_types/chains/definitions/{zkSyncTestnet.d.ts.map → zksyncLocalNode.d.ts.map} +1 -1
- package/_types/chains/definitions/{zkSyncSepoliaTestnet.d.ts → zksyncSepoliaTestnet.d.ts} +70 -14
- package/_types/chains/definitions/{zkSyncSepoliaTestnet.d.ts.map → zksyncSepoliaTestnet.d.ts.map} +1 -1
- package/_types/chains/definitions/zora.d.ts +32 -0
- package/_types/chains/definitions/zora.d.ts.map +1 -1
- package/_types/chains/definitions/zoraSepolia.d.ts +32 -0
- package/_types/chains/definitions/zoraSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/zoraTestnet.d.ts +32 -0
- package/_types/chains/definitions/zoraTestnet.d.ts.map +1 -1
- package/_types/chains/index.d.ts +79 -10
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/abi.d.ts +0 -26
- package/_types/errors/abi.d.ts.map +1 -1
- package/_types/errors/account.d.ts +0 -2
- package/_types/errors/account.d.ts.map +1 -1
- package/_types/errors/address.d.ts +0 -1
- package/_types/errors/address.d.ts.map +1 -1
- package/_types/errors/base.d.ts +7 -1
- package/_types/errors/base.d.ts.map +1 -1
- package/_types/errors/blob.d.ts +0 -4
- package/_types/errors/blob.d.ts.map +1 -1
- package/_types/errors/block.d.ts +0 -1
- package/_types/errors/block.d.ts.map +1 -1
- package/_types/errors/ccip.d.ts +0 -3
- package/_types/errors/ccip.d.ts.map +1 -1
- package/_types/errors/chain.d.ts +0 -5
- package/_types/errors/chain.d.ts.map +1 -1
- package/_types/errors/contract.d.ts +0 -6
- package/_types/errors/contract.d.ts.map +1 -1
- package/_types/errors/cursor.d.ts +0 -3
- package/_types/errors/cursor.d.ts.map +1 -1
- package/_types/errors/data.d.ts +0 -3
- package/_types/errors/data.d.ts.map +1 -1
- package/_types/errors/eip712.d.ts +0 -1
- package/_types/errors/eip712.d.ts.map +1 -1
- package/_types/errors/encoding.d.ts +0 -5
- package/_types/errors/encoding.d.ts.map +1 -1
- package/_types/errors/ens.d.ts +0 -4
- package/_types/errors/ens.d.ts.map +1 -1
- package/_types/errors/estimateGas.d.ts +0 -1
- package/_types/errors/estimateGas.d.ts.map +1 -1
- package/_types/errors/fee.d.ts +0 -3
- package/_types/errors/fee.d.ts.map +1 -1
- package/_types/errors/log.d.ts +0 -1
- package/_types/errors/log.d.ts.map +1 -1
- package/_types/errors/node.d.ts +0 -12
- package/_types/errors/node.d.ts.map +1 -1
- package/_types/errors/request.d.ts +0 -5
- package/_types/errors/request.d.ts.map +1 -1
- package/_types/errors/rpc.d.ts +2 -22
- package/_types/errors/rpc.d.ts.map +1 -1
- package/_types/errors/siwe.d.ts +0 -1
- package/_types/errors/siwe.d.ts.map +1 -1
- package/_types/errors/stateOverride.d.ts +0 -2
- package/_types/errors/stateOverride.d.ts.map +1 -1
- package/_types/errors/transaction.d.ts +0 -10
- package/_types/errors/transaction.d.ts.map +1 -1
- package/_types/errors/transport.d.ts.map +1 -1
- package/_types/errors/utils.d.ts +0 -1
- package/_types/errors/utils.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip5792/decorators/eip5792.d.ts +12 -12
- package/_types/experimental/eip5792/decorators/eip5792.d.ts.map +1 -1
- package/_types/experimental/eip7702/actions/signAuthorization.d.ts +59 -0
- package/_types/experimental/eip7702/actions/signAuthorization.d.ts.map +1 -0
- package/_types/experimental/eip7702/decorators/eip7702.d.ts +69 -0
- package/_types/experimental/eip7702/decorators/eip7702.d.ts.map +1 -0
- package/_types/experimental/eip7702/types/authorization.d.ts +24 -0
- package/_types/experimental/eip7702/types/authorization.d.ts.map +1 -0
- package/_types/experimental/eip7702/types/rpc.d.ts +12 -0
- package/_types/experimental/eip7702/types/rpc.d.ts.map +1 -0
- package/_types/experimental/eip7702/utils/hashAuthorization.d.ts +21 -0
- package/_types/experimental/eip7702/utils/hashAuthorization.d.ts.map +1 -0
- package/_types/experimental/eip7702/utils/recoverAuthorizationAddress.d.ts +26 -0
- package/_types/experimental/eip7702/utils/recoverAuthorizationAddress.d.ts.map +1 -0
- package/_types/experimental/eip7702/utils/serializeAuthorizationList.d.ts +6 -0
- package/_types/experimental/eip7702/utils/serializeAuthorizationList.d.ts.map +1 -0
- package/_types/experimental/eip7702/utils/verifyAuthorization.d.ts +21 -0
- package/_types/experimental/eip7702/utils/verifyAuthorization.d.ts.map +1 -0
- package/_types/experimental/erc7715/decorators/erc7715.d.ts +6 -6
- package/_types/experimental/erc7715/decorators/erc7715.d.ts.map +1 -1
- package/_types/experimental/index.d.ts +20 -4
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/index.d.ts +3 -3
- package/_types/index.d.ts.map +1 -1
- package/_types/op-stack/chainConfig.d.ts +32 -0
- package/_types/op-stack/chainConfig.d.ts.map +1 -1
- package/_types/op-stack/errors/withdrawal.d.ts +0 -2
- package/_types/op-stack/errors/withdrawal.d.ts.map +1 -1
- package/_types/op-stack/formatters.d.ts +32 -0
- package/_types/op-stack/formatters.d.ts.map +1 -1
- package/_types/op-stack/serializers.d.ts +1 -1
- package/_types/op-stack/serializers.d.ts.map +1 -1
- package/_types/types/rpc.d.ts +9 -4
- package/_types/types/rpc.d.ts.map +1 -1
- package/_types/types/transaction.d.ts +50 -36
- package/_types/types/transaction.d.ts.map +1 -1
- package/_types/types/utils.d.ts +0 -14
- package/_types/types/utils.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +2 -1
- package/_types/utils/formatters/transaction.d.ts.map +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +2 -1
- package/_types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/_types/utils/index.d.ts +1 -1
- package/_types/utils/index.d.ts.map +1 -1
- package/_types/utils/signature/hashMessage.d.ts +2 -2
- package/_types/utils/signature/hashMessage.d.ts.map +1 -1
- package/_types/utils/transaction/assertTransaction.d.ts +3 -1
- package/_types/utils/transaction/assertTransaction.d.ts.map +1 -1
- package/_types/utils/transaction/getSerializedTransactionType.d.ts +2 -2
- package/_types/utils/transaction/getSerializedTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/getTransactionType.d.ts +12 -5
- package/_types/utils/transaction/getTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/parseTransaction.d.ts +6 -4
- package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts +4 -2
- package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/_types/zksync/actions/deployContract.d.ts +1 -1
- package/_types/zksync/actions/estimateFee.d.ts +4 -4
- package/_types/zksync/actions/estimateGasL1ToL2.d.ts +2 -2
- package/_types/zksync/actions/getAllBalances.d.ts +2 -2
- package/_types/zksync/actions/getBaseTokenL1Address.d.ts +2 -2
- package/_types/zksync/actions/getBlockDetails.d.ts +5 -5
- package/_types/zksync/actions/getBridgehubContractAddress.d.ts +2 -2
- package/_types/zksync/actions/getDefaultBridgeAddresses.d.ts +2 -2
- package/_types/zksync/actions/getL1BatchBlockRange.d.ts +2 -2
- package/_types/zksync/actions/getL1BatchDetails.d.ts +5 -5
- package/_types/zksync/actions/getL1BatchNumber.d.ts +2 -2
- package/_types/zksync/actions/getL1ChainId.d.ts +2 -2
- package/_types/zksync/actions/getLogProof.d.ts +2 -2
- package/_types/zksync/actions/getMainContractAddress.d.ts +2 -2
- package/_types/zksync/actions/getRawBlockTransactions.d.ts +6 -6
- package/_types/zksync/actions/getTestnetPaymasterAddress.d.ts +2 -2
- package/_types/zksync/actions/getTransactionDetails.d.ts +4 -4
- package/_types/zksync/actions/sendEip712Transaction.d.ts +4 -4
- package/_types/zksync/actions/sendTransaction.d.ts +4 -4
- package/_types/zksync/actions/signEip712Transaction.d.ts +4 -4
- package/_types/zksync/actions/signTransaction.d.ts +4 -4
- package/_types/zksync/chainConfig.d.ts +65 -11
- package/_types/zksync/chainConfig.d.ts.map +1 -1
- package/_types/zksync/chains.d.ts +4 -3
- package/_types/zksync/chains.d.ts.map +1 -1
- package/_types/zksync/decorators/eip712.d.ts +13 -13
- package/_types/zksync/decorators/publicL2.d.ts +37 -37
- package/_types/zksync/errors/bytecode.d.ts +0 -3
- package/_types/zksync/errors/bytecode.d.ts.map +1 -1
- package/_types/zksync/errors/token-is-eth.d.ts +0 -1
- package/_types/zksync/errors/token-is-eth.d.ts.map +1 -1
- package/_types/zksync/errors/transaction.d.ts +0 -1
- package/_types/zksync/errors/transaction.d.ts.map +1 -1
- package/_types/zksync/formatters.d.ts +75 -21
- package/_types/zksync/formatters.d.ts.map +1 -1
- package/_types/zksync/index.d.ts +77 -7
- package/_types/zksync/index.d.ts.map +1 -1
- package/_types/zksync/serializers.d.ts +2 -2
- package/_types/zksync/serializers.d.ts.map +1 -1
- package/_types/zksync/types/block.d.ts +6 -6
- package/_types/zksync/types/chain.d.ts +2 -2
- package/_types/zksync/types/eip1193.d.ts +8 -8
- package/_types/zksync/types/eip712.d.ts +3 -3
- package/_types/zksync/types/fee.d.ts +2 -2
- package/_types/zksync/types/log.d.ts +4 -4
- package/_types/zksync/types/transaction.d.ts +31 -31
- package/_types/zksync/utils/assertEip712Request.d.ts +2 -2
- package/_types/zksync/utils/assertEip712Transaction.d.ts +2 -2
- package/_types/zksync/utils/getEip712Domain.d.ts +2 -2
- package/_types/zksync/utils/isEip712Transaction.d.ts +3 -3
- package/_types/zksync/utils/isEip712Transaction.d.ts.map +1 -1
- package/account-abstraction/errors/bundler.ts +36 -48
- package/account-abstraction/errors/userOperation.ts +6 -6
- package/accounts/index.ts +6 -0
- package/accounts/privateKeyToAccount.ts +4 -0
- package/accounts/toAccount.ts +1 -0
- package/accounts/types.ts +11 -3
- package/accounts/utils/signAuthorization.ts +63 -0
- package/actions/public/estimateGas.ts +74 -11
- package/actions/public/simulateContract.ts +48 -14
- package/actions/wallet/prepareTransactionRequest.ts +3 -1
- package/actions/wallet/sendTransaction.ts +33 -4
- package/actions/wallet/writeContract.ts +5 -3
- package/chains/definitions/abstractTestnet.ts +23 -0
- package/chains/definitions/b3Sepolia.ts +26 -0
- package/chains/definitions/{zkSync.ts → zksync.ts} +4 -3
- package/chains/definitions/{zkSyncInMemoryNode.ts → zksyncInMemoryNode.ts} +2 -2
- package/chains/definitions/{zkSyncLocalNode.ts → zksyncLocalNode.ts} +2 -2
- package/chains/definitions/{zkSyncSepoliaTestnet.ts → zksyncSepoliaTestnet.ts} +5 -3
- package/chains/index.ts +115 -34
- package/errors/abi.ts +37 -37
- package/errors/account.ts +2 -2
- package/errors/address.ts +1 -1
- package/errors/base.ts +41 -22
- package/errors/blob.ts +4 -5
- package/errors/block.ts +1 -2
- package/errors/ccip.ts +3 -3
- package/errors/chain.ts +9 -10
- package/errors/contract.ts +6 -10
- package/errors/cursor.ts +5 -4
- package/errors/data.ts +3 -3
- package/errors/eip712.ts +1 -1
- package/errors/encoding.ts +7 -5
- package/errors/ens.ts +6 -5
- package/errors/estimateGas.ts +1 -2
- package/errors/fee.ts +7 -5
- package/errors/log.ts +3 -2
- package/errors/node.ts +12 -17
- package/errors/request.ts +5 -10
- package/errors/rpc.ts +29 -26
- package/errors/siwe.ts +1 -2
- package/errors/stateOverride.ts +6 -4
- package/errors/transaction.ts +19 -19
- package/errors/transport.ts +1 -0
- package/errors/utils.ts +0 -3
- package/errors/version.ts +1 -1
- package/experimental/eip5792/decorators/eip5792.ts +13 -13
- package/experimental/eip7702/actions/signAuthorization.ts +136 -0
- package/experimental/eip7702/decorators/eip7702.ts +86 -0
- package/experimental/eip7702/types/authorization.ts +30 -0
- package/experimental/eip7702/types/rpc.ts +12 -0
- package/experimental/eip7702/utils/hashAuthorization.ts +60 -0
- package/experimental/eip7702/utils/recoverAuthorizationAddress.ts +61 -0
- package/experimental/eip7702/utils/serializeAuthorizationList.ts +33 -0
- package/experimental/eip7702/utils/verifyAuthorization.ts +52 -0
- package/experimental/erc7715/decorators/erc7715.ts +7 -7
- package/experimental/index.ts +72 -18
- package/index.ts +29 -4
- package/op-stack/errors/withdrawal.ts +2 -3
- package/package.json +1 -1
- package/types/rpc.ts +21 -1
- package/types/transaction.ts +103 -54
- package/types/utils.ts +0 -15
- package/utils/formatters/transaction.ts +32 -0
- package/utils/formatters/transactionRequest.ts +31 -0
- package/utils/index.ts +1 -1
- package/utils/signature/hashMessage.ts +2 -2
- package/utils/transaction/assertTransaction.ts +24 -12
- package/utils/transaction/getSerializedTransactionType.ts +7 -0
- package/utils/transaction/getTransactionType.ts +95 -60
- package/utils/transaction/parseTransaction.ts +127 -0
- package/utils/transaction/serializeTransaction.ts +66 -0
- package/zksync/actions/deployContract.ts +1 -1
- package/zksync/actions/estimateFee.ts +4 -4
- package/zksync/actions/estimateGasL1ToL2.ts +2 -2
- package/zksync/actions/getAllBalances.ts +2 -2
- package/zksync/actions/getBaseTokenL1Address.ts +2 -2
- package/zksync/actions/getBlockDetails.ts +6 -6
- package/zksync/actions/getBridgehubContractAddress.ts +2 -2
- package/zksync/actions/getDefaultBridgeAddresses.ts +2 -2
- package/zksync/actions/getL1BatchBlockRange.ts +2 -2
- package/zksync/actions/getL1BatchDetails.ts +6 -6
- package/zksync/actions/getL1BatchNumber.ts +2 -2
- package/zksync/actions/getL1ChainId.ts +2 -2
- package/zksync/actions/getLogProof.ts +2 -2
- package/zksync/actions/getMainContractAddress.ts +2 -2
- package/zksync/actions/getRawBlockTransactions.ts +6 -6
- package/zksync/actions/getTestnetPaymasterAddress.ts +2 -2
- package/zksync/actions/getTransactionDetails.ts +4 -4
- package/zksync/actions/sendEip712Transaction.ts +4 -4
- package/zksync/actions/sendTransaction.ts +4 -4
- package/zksync/actions/signEip712Transaction.ts +4 -4
- package/zksync/actions/signTransaction.ts +4 -4
- package/zksync/chains.ts +4 -3
- package/zksync/decorators/eip712.ts +13 -13
- package/zksync/decorators/publicL2.ts +37 -37
- package/zksync/errors/bytecode.ts +3 -3
- package/zksync/errors/token-is-eth.ts +1 -2
- package/zksync/errors/transaction.ts +1 -2
- package/zksync/formatters.ts +22 -22
- package/zksync/index.ts +111 -32
- package/zksync/serializers.ts +7 -7
- package/zksync/types/block.ts +9 -9
- package/zksync/types/chain.ts +5 -5
- package/zksync/types/eip1193.ts +8 -8
- package/zksync/types/eip712.ts +3 -3
- package/zksync/types/fee.ts +2 -2
- package/zksync/types/log.ts +4 -4
- package/zksync/types/transaction.ts +45 -45
- package/zksync/utils/assertEip712Request.ts +2 -2
- package/zksync/utils/assertEip712Transaction.ts +4 -4
- package/zksync/utils/getEip712Domain.ts +9 -9
- package/zksync/utils/isEip712Transaction.ts +8 -3
- package/_cjs/chains/definitions/zkSyncSepoliaTestnet.js.map +0 -1
- package/_cjs/chains/definitions/zkSyncTestnet.js +0 -31
- package/_cjs/chains/definitions/zkSyncTestnet.js.map +0 -1
- package/_esm/chains/definitions/zkSyncTestnet.js +0 -29
- package/_esm/chains/definitions/zkSyncTestnet.js.map +0 -1
- package/chains/definitions/zkSyncTestnet.ts +0 -29
package/errors/transaction.ts
CHANGED
@@ -28,13 +28,13 @@ export type FeeConflictErrorType = FeeConflictError & {
|
|
28
28
|
name: 'FeeConflictError'
|
29
29
|
}
|
30
30
|
export class FeeConflictError extends BaseError {
|
31
|
-
override name = 'FeeConflictError'
|
32
31
|
constructor() {
|
33
32
|
super(
|
34
33
|
[
|
35
34
|
'Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.',
|
36
35
|
'Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others.',
|
37
36
|
].join('\n'),
|
37
|
+
{ name: 'FeeConflictError' },
|
38
38
|
)
|
39
39
|
}
|
40
40
|
}
|
@@ -43,10 +43,10 @@ export type InvalidLegacyVErrorType = InvalidLegacyVError & {
|
|
43
43
|
name: 'InvalidLegacyVError'
|
44
44
|
}
|
45
45
|
export class InvalidLegacyVError extends BaseError {
|
46
|
-
override name = 'InvalidLegacyVError'
|
47
|
-
|
48
46
|
constructor({ v }: { v: bigint }) {
|
49
|
-
super(`Invalid \`v\` value "${v}". Expected 27 or 28
|
47
|
+
super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, {
|
48
|
+
name: 'InvalidLegacyVError',
|
49
|
+
})
|
50
50
|
}
|
51
51
|
}
|
52
52
|
|
@@ -55,8 +55,6 @@ export type InvalidSerializableTransactionErrorType =
|
|
55
55
|
name: 'InvalidSerializableTransactionError'
|
56
56
|
}
|
57
57
|
export class InvalidSerializableTransactionError extends BaseError {
|
58
|
-
override name = 'InvalidSerializableTransactionError'
|
59
|
-
|
60
58
|
constructor({ transaction }: { transaction: Record<string, unknown> }) {
|
61
59
|
super('Cannot infer a transaction type from provided transaction.', {
|
62
60
|
metaMessages: [
|
@@ -70,8 +68,10 @@ export class InvalidSerializableTransactionError extends BaseError {
|
|
70
68
|
'- an EIP-1559 Transaction with `maxFeePerGas`, or',
|
71
69
|
'- an EIP-2930 Transaction with `gasPrice` & `accessList`, or',
|
72
70
|
'- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or',
|
71
|
+
'- an EIP-7702 Transaction with `authorizationList`, or',
|
73
72
|
'- a Legacy Transaction with `gasPrice`',
|
74
73
|
],
|
74
|
+
name: 'InvalidSerializableTransactionError',
|
75
75
|
})
|
76
76
|
}
|
77
77
|
}
|
@@ -81,12 +81,12 @@ export type InvalidSerializedTransactionTypeErrorType =
|
|
81
81
|
name: 'InvalidSerializedTransactionTypeError'
|
82
82
|
}
|
83
83
|
export class InvalidSerializedTransactionTypeError extends BaseError {
|
84
|
-
override name = 'InvalidSerializedTransactionType'
|
85
|
-
|
86
84
|
serializedType: Hex
|
87
85
|
|
88
86
|
constructor({ serializedType }: { serializedType: Hex }) {
|
89
|
-
super(`Serialized transaction type "${serializedType}" is invalid
|
87
|
+
super(`Serialized transaction type "${serializedType}" is invalid.`, {
|
88
|
+
name: 'InvalidSerializedTransactionType',
|
89
|
+
})
|
90
90
|
|
91
91
|
this.serializedType = serializedType
|
92
92
|
}
|
@@ -97,8 +97,6 @@ export type InvalidSerializedTransactionErrorType =
|
|
97
97
|
name: 'InvalidSerializedTransactionError'
|
98
98
|
}
|
99
99
|
export class InvalidSerializedTransactionError extends BaseError {
|
100
|
-
override name = 'InvalidSerializedTransactionError'
|
101
|
-
|
102
100
|
serializedTransaction: Hex
|
103
101
|
type: TransactionType
|
104
102
|
|
@@ -119,6 +117,7 @@ export class InvalidSerializedTransactionError extends BaseError {
|
|
119
117
|
`Serialized Transaction: "${serializedTransaction}"`,
|
120
118
|
missing.length > 0 ? `Missing Attributes: ${missing.join(', ')}` : '',
|
121
119
|
].filter(Boolean),
|
120
|
+
name: 'InvalidSerializedTransactionError',
|
122
121
|
})
|
123
122
|
|
124
123
|
this.serializedTransaction = serializedTransaction
|
@@ -130,13 +129,12 @@ export type InvalidStorageKeySizeErrorType = InvalidStorageKeySizeError & {
|
|
130
129
|
name: 'InvalidStorageKeySizeError'
|
131
130
|
}
|
132
131
|
export class InvalidStorageKeySizeError extends BaseError {
|
133
|
-
override name = 'InvalidStorageKeySizeError'
|
134
|
-
|
135
132
|
constructor({ storageKey }: { storageKey: Hex }) {
|
136
133
|
super(
|
137
134
|
`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor(
|
138
135
|
(storageKey.length - 2) / 2,
|
139
136
|
)} bytes.`,
|
137
|
+
{ name: 'InvalidStorageKeySizeError' },
|
140
138
|
)
|
141
139
|
}
|
142
140
|
}
|
@@ -147,8 +145,6 @@ export type TransactionExecutionErrorType = TransactionExecutionError & {
|
|
147
145
|
export class TransactionExecutionError extends BaseError {
|
148
146
|
override cause: BaseError
|
149
147
|
|
150
|
-
override name = 'TransactionExecutionError'
|
151
|
-
|
152
148
|
constructor(
|
153
149
|
cause: BaseError,
|
154
150
|
{
|
@@ -197,6 +193,7 @@ export class TransactionExecutionError extends BaseError {
|
|
197
193
|
'Request Arguments:',
|
198
194
|
prettyArgs,
|
199
195
|
].filter(Boolean) as string[],
|
196
|
+
name: 'TransactionExecutionError',
|
200
197
|
})
|
201
198
|
this.cause = cause
|
202
199
|
}
|
@@ -206,7 +203,6 @@ export type TransactionNotFoundErrorType = TransactionNotFoundError & {
|
|
206
203
|
name: 'TransactionNotFoundError'
|
207
204
|
}
|
208
205
|
export class TransactionNotFoundError extends BaseError {
|
209
|
-
override name = 'TransactionNotFoundError'
|
210
206
|
constructor({
|
211
207
|
blockHash,
|
212
208
|
blockNumber,
|
@@ -228,7 +224,9 @@ export class TransactionNotFoundError extends BaseError {
|
|
228
224
|
if (blockNumber && index !== undefined)
|
229
225
|
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`
|
230
226
|
if (hash) identifier = `Transaction with hash "${hash}"`
|
231
|
-
super(`${identifier} could not be found
|
227
|
+
super(`${identifier} could not be found.`, {
|
228
|
+
name: 'TransactionNotFoundError',
|
229
|
+
})
|
232
230
|
}
|
233
231
|
}
|
234
232
|
|
@@ -237,10 +235,12 @@ export type TransactionReceiptNotFoundErrorType =
|
|
237
235
|
name: 'TransactionReceiptNotFoundError'
|
238
236
|
}
|
239
237
|
export class TransactionReceiptNotFoundError extends BaseError {
|
240
|
-
override name = 'TransactionReceiptNotFoundError'
|
241
238
|
constructor({ hash }: { hash: Hash }) {
|
242
239
|
super(
|
243
240
|
`Transaction receipt with hash "${hash}" could not be found. The Transaction may not be processed on a block yet.`,
|
241
|
+
{
|
242
|
+
name: 'TransactionReceiptNotFoundError',
|
243
|
+
},
|
244
244
|
)
|
245
245
|
}
|
246
246
|
}
|
@@ -250,10 +250,10 @@ export type WaitForTransactionReceiptTimeoutErrorType =
|
|
250
250
|
name: 'WaitForTransactionReceiptTimeoutError'
|
251
251
|
}
|
252
252
|
export class WaitForTransactionReceiptTimeoutError extends BaseError {
|
253
|
-
override name = 'WaitForTransactionReceiptTimeoutError'
|
254
253
|
constructor({ hash }: { hash: Hash }) {
|
255
254
|
super(
|
256
255
|
`Timed out while waiting for transaction with hash "${hash}" to be confirmed.`,
|
256
|
+
{ name: 'WaitForTransactionReceiptTimeoutError' },
|
257
257
|
)
|
258
258
|
}
|
259
259
|
}
|
package/errors/transport.ts
CHANGED
package/errors/utils.ts
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import { version } from './version.js'
|
4
|
-
|
5
3
|
export type ErrorType<name extends string = 'Error'> = Error & { name: name }
|
6
4
|
|
7
5
|
export const getContractAddress = (address: Address) => address
|
8
6
|
export const getUrl = (url: string) => url
|
9
|
-
export const getVersion = () => `viem@${version}`
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.
|
1
|
+
export const version = '2.19.0'
|
@@ -28,7 +28,7 @@ import {
|
|
28
28
|
writeContracts,
|
29
29
|
} from '../actions/writeContracts.js'
|
30
30
|
|
31
|
-
export type
|
31
|
+
export type Eip5792Actions<
|
32
32
|
chain extends Chain | undefined = Chain | undefined,
|
33
33
|
account extends Account | undefined = Account | undefined,
|
34
34
|
> = {
|
@@ -44,12 +44,12 @@ export type WalletActionsEip5792<
|
|
44
44
|
* @example
|
45
45
|
* import { createWalletClient, custom } from 'viem'
|
46
46
|
* import { mainnet } from 'viem/chains'
|
47
|
-
* import {
|
47
|
+
* import { eip5792Actions } from 'viem/experimental'
|
48
48
|
*
|
49
49
|
* const client = createWalletClient({
|
50
50
|
* chain: mainnet,
|
51
51
|
* transport: custom(window.ethereum),
|
52
|
-
* }).extend(
|
52
|
+
* }).extend(eip5792Actions())
|
53
53
|
*
|
54
54
|
* const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
|
55
55
|
*/
|
@@ -68,12 +68,12 @@ export type WalletActionsEip5792<
|
|
68
68
|
* @example
|
69
69
|
* import { createWalletClient, custom } from 'viem'
|
70
70
|
* import { mainnet } from 'viem/chains'
|
71
|
-
* import {
|
71
|
+
* import { eip5792Actions } from 'viem/experimental'
|
72
72
|
*
|
73
73
|
* const client = createWalletClient({
|
74
74
|
* chain: mainnet,
|
75
75
|
* transport: custom(window.ethereum),
|
76
|
-
* }).extend(
|
76
|
+
* }).extend(eip5792Actions())
|
77
77
|
*
|
78
78
|
* const capabilities = await client.getCapabilities({
|
79
79
|
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
@@ -96,12 +96,12 @@ export type WalletActionsEip5792<
|
|
96
96
|
* @example
|
97
97
|
* import { createWalletClient, custom } from 'viem'
|
98
98
|
* import { mainnet } from 'viem/chains'
|
99
|
-
* import {
|
99
|
+
* import { eip5792Actions } from 'viem/experimental'
|
100
100
|
*
|
101
101
|
* const client = createWalletClient({
|
102
102
|
* chain: mainnet,
|
103
103
|
* transport: custom(window.ethereum),
|
104
|
-
* }).extend(
|
104
|
+
* }).extend(eip5792Actions())
|
105
105
|
*
|
106
106
|
* const id = await client.sendCalls({
|
107
107
|
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
@@ -133,12 +133,12 @@ export type WalletActionsEip5792<
|
|
133
133
|
* @example
|
134
134
|
* import { createWalletClient, custom } from 'viem'
|
135
135
|
* import { mainnet } from 'viem/chains'
|
136
|
-
* import {
|
136
|
+
* import { eip5792Actions } from 'viem/experimental'
|
137
137
|
*
|
138
138
|
* const client = createWalletClient({
|
139
139
|
* chain: mainnet,
|
140
140
|
* transport: custom(window.ethereum),
|
141
|
-
* }).extend(
|
141
|
+
* }).extend(eip5792Actions())
|
142
142
|
*
|
143
143
|
* await client.showCallsStatus({ id: '0xdeadbeef' })
|
144
144
|
*/
|
@@ -210,23 +210,23 @@ export type WalletActionsEip5792<
|
|
210
210
|
* @example
|
211
211
|
* import { createPublicClient, createWalletClient, http } from 'viem'
|
212
212
|
* import { mainnet } from 'viem/chains'
|
213
|
-
* import {
|
213
|
+
* import { eip5792Actions } from 'viem/experimental'
|
214
214
|
*
|
215
215
|
* const walletClient = createWalletClient({
|
216
216
|
* chain: mainnet,
|
217
217
|
* transport: http(),
|
218
|
-
* }).extend(
|
218
|
+
* }).extend(eip5792Actions())
|
219
219
|
*
|
220
220
|
* const hash = await walletClient.sendCalls({...})
|
221
221
|
*/
|
222
|
-
export function
|
222
|
+
export function eip5792Actions() {
|
223
223
|
return <
|
224
224
|
transport extends Transport,
|
225
225
|
chain extends Chain | undefined = Chain | undefined,
|
226
226
|
account extends Account | undefined = Account | undefined,
|
227
227
|
>(
|
228
228
|
client: Client<transport, chain, account>,
|
229
|
-
):
|
229
|
+
): Eip5792Actions<chain, account> => {
|
230
230
|
return {
|
231
231
|
getCallsStatus: (parameters) => getCallsStatus(client, parameters),
|
232
232
|
getCapabilities: ((parameters: any) =>
|
@@ -0,0 +1,136 @@
|
|
1
|
+
import type { Account } from '../../../accounts/types.js'
|
2
|
+
import {
|
3
|
+
type ParseAccountErrorType,
|
4
|
+
parseAccount,
|
5
|
+
} from '../../../accounts/utils/parseAccount.js'
|
6
|
+
import type {
|
7
|
+
SignAuthorizationErrorType as SignAuthorizationErrorType_account,
|
8
|
+
SignAuthorizationReturnType as SignAuthorizationReturnType_account,
|
9
|
+
} from '../../../accounts/utils/signAuthorization.js'
|
10
|
+
import { getChainId } from '../../../actions/public/getChainId.js'
|
11
|
+
import { getTransactionCount } from '../../../actions/public/getTransactionCount.js'
|
12
|
+
import type { Client } from '../../../clients/createClient.js'
|
13
|
+
import type { Transport } from '../../../clients/transports/createTransport.js'
|
14
|
+
import {
|
15
|
+
AccountNotFoundError,
|
16
|
+
type AccountNotFoundErrorType,
|
17
|
+
AccountTypeNotSupportedError,
|
18
|
+
type AccountTypeNotSupportedErrorType,
|
19
|
+
} from '../../../errors/account.js'
|
20
|
+
import type { ErrorType } from '../../../errors/utils.js'
|
21
|
+
import type { GetAccountParameter } from '../../../types/account.js'
|
22
|
+
import type { Chain } from '../../../types/chain.js'
|
23
|
+
import type { PartialBy } from '../../../types/utils.js'
|
24
|
+
import type { RequestErrorType } from '../../../utils/buildRequest.js'
|
25
|
+
import { getAction } from '../../../utils/getAction.js'
|
26
|
+
import type { Authorization } from '../types/authorization.js'
|
27
|
+
|
28
|
+
export type SignAuthorizationParameters<
|
29
|
+
account extends Account | undefined = Account | undefined,
|
30
|
+
> = GetAccountParameter<account> & PartialBy<Authorization, 'chainId' | 'nonce'>
|
31
|
+
|
32
|
+
export type SignAuthorizationReturnType = SignAuthorizationReturnType_account
|
33
|
+
|
34
|
+
export type SignAuthorizationErrorType =
|
35
|
+
| ParseAccountErrorType
|
36
|
+
| RequestErrorType
|
37
|
+
| AccountNotFoundErrorType
|
38
|
+
| AccountTypeNotSupportedErrorType
|
39
|
+
| SignAuthorizationErrorType_account
|
40
|
+
| ErrorType
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Signs an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object.
|
44
|
+
*
|
45
|
+
* With the calculated signature, you can:
|
46
|
+
* - use [`verifyAuthorization`](https://viem.sh/experimental/eip7702/verifyAuthorization) to verify the signed Authorization object,
|
47
|
+
* - use [`recoverAuthorizationAddress`](https://viem.sh/experimental/eip7702/recoverAuthorizationAddress) to recover the signing address from the signed Authorization object.
|
48
|
+
*
|
49
|
+
* @param client - Client to use
|
50
|
+
* @param parameters - {@link SignAuthorizationParameters}
|
51
|
+
* @returns The signed Authorization object. {@link SignAuthorizationReturnType}
|
52
|
+
*
|
53
|
+
* @example
|
54
|
+
* import { createClient, http } from 'viem'
|
55
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
56
|
+
* import { mainnet } from 'viem/chains'
|
57
|
+
* import { signAuthorization } from 'viem/experimental'
|
58
|
+
*
|
59
|
+
* const client = createClient({
|
60
|
+
* chain: mainnet,
|
61
|
+
* transport: http(),
|
62
|
+
* })
|
63
|
+
* const signature = await signAuthorization(client, {
|
64
|
+
* account: privateKeyToAccount('0x..'),
|
65
|
+
* address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
66
|
+
* })
|
67
|
+
*
|
68
|
+
* @example
|
69
|
+
* // Account Hoisting
|
70
|
+
* import { createClient, http } from 'viem'
|
71
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
72
|
+
* import { mainnet } from 'viem/chains'
|
73
|
+
* import { signAuthorization } from 'viem/experimental'
|
74
|
+
*
|
75
|
+
* const client = createClient({
|
76
|
+
* account: privateKeyToAccount('0x…'),
|
77
|
+
* chain: mainnet,
|
78
|
+
* transport: http(),
|
79
|
+
* })
|
80
|
+
* const signature = await signAuthorization(client, {
|
81
|
+
* address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
82
|
+
* })
|
83
|
+
*/
|
84
|
+
export async function signAuthorization<
|
85
|
+
chain extends Chain | undefined,
|
86
|
+
account extends Account | undefined,
|
87
|
+
>(
|
88
|
+
client: Client<Transport, chain, account>,
|
89
|
+
parameters: SignAuthorizationParameters<account>,
|
90
|
+
): Promise<SignAuthorizationReturnType> {
|
91
|
+
const {
|
92
|
+
account: account_ = client.account,
|
93
|
+
contractAddress,
|
94
|
+
chainId,
|
95
|
+
nonce,
|
96
|
+
} = parameters
|
97
|
+
|
98
|
+
if (!account_)
|
99
|
+
throw new AccountNotFoundError({
|
100
|
+
docsPath: '/experimental/eip7702/signAuthorization',
|
101
|
+
})
|
102
|
+
const account = parseAccount(account_)
|
103
|
+
|
104
|
+
if (!account.experimental_signAuthorization)
|
105
|
+
throw new AccountTypeNotSupportedError({
|
106
|
+
docsPath: '/experimental/eip7702/signAuthorization',
|
107
|
+
metaMessages: [
|
108
|
+
'The `signAuthorization` Action does not support JSON-RPC Accounts.',
|
109
|
+
],
|
110
|
+
type: account.type,
|
111
|
+
})
|
112
|
+
|
113
|
+
const authorization = {
|
114
|
+
contractAddress,
|
115
|
+
chainId,
|
116
|
+
nonce,
|
117
|
+
} as Authorization
|
118
|
+
|
119
|
+
if (typeof authorization.chainId === 'undefined')
|
120
|
+
authorization.chainId =
|
121
|
+
client.chain?.id ??
|
122
|
+
(await getAction(client, getChainId, 'getChainId')({}))
|
123
|
+
|
124
|
+
if (typeof authorization.nonce === 'undefined') {
|
125
|
+
authorization.nonce = await getAction(
|
126
|
+
client,
|
127
|
+
getTransactionCount,
|
128
|
+
'getTransactionCount',
|
129
|
+
)({
|
130
|
+
address: account.address,
|
131
|
+
blockTag: 'pending',
|
132
|
+
})
|
133
|
+
}
|
134
|
+
|
135
|
+
return account.experimental_signAuthorization(authorization)
|
136
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import type { Client } from '../../../clients/createClient.js'
|
2
|
+
import type { Transport } from '../../../clients/transports/createTransport.js'
|
3
|
+
import type { Account } from '../../../types/account.js'
|
4
|
+
import type { Chain } from '../../../types/chain.js'
|
5
|
+
import {
|
6
|
+
type SignAuthorizationParameters,
|
7
|
+
type SignAuthorizationReturnType,
|
8
|
+
signAuthorization,
|
9
|
+
} from '../actions/signAuthorization.js'
|
10
|
+
|
11
|
+
export type Eip7702Actions<
|
12
|
+
account extends Account | undefined = Account | undefined,
|
13
|
+
> = {
|
14
|
+
/**
|
15
|
+
* Signs an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object.
|
16
|
+
*
|
17
|
+
* With the calculated signature, you can:
|
18
|
+
* - use [`verifyAuthorization`](https://viem.sh/experimental/eip7702/verifyAuthorization) to verify the signed Authorization object,
|
19
|
+
* - use [`recoverAuthorizationAddress`](https://viem.sh/experimental/eip7702/recoverAuthorizationAddress) to recover the signing address from the signed Authorization object.
|
20
|
+
*
|
21
|
+
* @param client - Client to use
|
22
|
+
* @param parameters - {@link SignAuthorizationParameters}
|
23
|
+
* @returns The signed Authorization object. {@link SignAuthorizationReturnType}
|
24
|
+
*
|
25
|
+
* @example
|
26
|
+
* import { createClient, http } from 'viem'
|
27
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
28
|
+
* import { mainnet } from 'viem/chains'
|
29
|
+
* import { eip7702Actions } from 'viem/experimental'
|
30
|
+
*
|
31
|
+
* const client = createClient({
|
32
|
+
* chain: mainnet,
|
33
|
+
* transport: http(),
|
34
|
+
* }).extend(eip7702Actions())
|
35
|
+
*
|
36
|
+
* const signature = await client.signAuthorization({
|
37
|
+
* account: privateKeyToAccount('0x..'),
|
38
|
+
* authorization: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
39
|
+
* })
|
40
|
+
*
|
41
|
+
* @example
|
42
|
+
* // Account Hoisting
|
43
|
+
* import { createClient, http } from 'viem'
|
44
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
45
|
+
* import { mainnet } from 'viem/chains'
|
46
|
+
* import { eip7702Actions } from 'viem/experimental'
|
47
|
+
*
|
48
|
+
* const client = createClient({
|
49
|
+
* account: privateKeyToAccount('0x…'),
|
50
|
+
* chain: mainnet,
|
51
|
+
* transport: http(),
|
52
|
+
* }).extend(eip7702Actions())
|
53
|
+
*
|
54
|
+
* const signature = await client.signAuthorization({
|
55
|
+
* authorization: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
56
|
+
* })
|
57
|
+
*/
|
58
|
+
signAuthorization: (
|
59
|
+
parameters: SignAuthorizationParameters<account>,
|
60
|
+
) => Promise<SignAuthorizationReturnType>
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* A suite of EIP-7702 Actions.
|
65
|
+
*
|
66
|
+
* @example
|
67
|
+
* import { createClient, http } from 'viem'
|
68
|
+
* import { mainnet } from 'viem/chains'
|
69
|
+
* import { eip7702Actions } from 'viem/experimental'
|
70
|
+
*
|
71
|
+
* const client = createClient({
|
72
|
+
* chain: mainnet,
|
73
|
+
* transport: http(),
|
74
|
+
* }).extend(eip7702Actions())
|
75
|
+
*
|
76
|
+
* const hash = await client.signAuthorization({ ... })
|
77
|
+
*/
|
78
|
+
export function eip7702Actions() {
|
79
|
+
return <account extends Account | undefined = Account | undefined>(
|
80
|
+
client: Client<Transport, Chain | undefined, account>,
|
81
|
+
): Eip7702Actions<account> => {
|
82
|
+
return {
|
83
|
+
signAuthorization: (parameters) => signAuthorization(client, parameters),
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import type { Hex, Signature } from '../../../types/misc.js'
|
3
|
+
import type { ExactPartial } from '../../../types/utils.js'
|
4
|
+
|
5
|
+
export type Authorization<uint32 = number, signed extends boolean = false> = {
|
6
|
+
/** Address of the contract to set as code for the Authority. */
|
7
|
+
contractAddress: Address
|
8
|
+
/** Chain ID to authorize. */
|
9
|
+
chainId: uint32
|
10
|
+
/** Nonce of the Authority to authorize. */
|
11
|
+
nonce: uint32
|
12
|
+
} & (signed extends true ? Signature : ExactPartial<Signature>)
|
13
|
+
export type AuthorizationList<
|
14
|
+
uint32 = number,
|
15
|
+
signed extends boolean = false,
|
16
|
+
> = readonly Authorization<uint32, signed>[]
|
17
|
+
|
18
|
+
export type SignedAuthorization<uint32 = number> = Authorization<uint32, true>
|
19
|
+
export type SignedAuthorizationList<uint32 = number> =
|
20
|
+
readonly SignedAuthorization<uint32>[]
|
21
|
+
|
22
|
+
export type SerializedAuthorization = readonly [
|
23
|
+
chainId: Hex,
|
24
|
+
address: Hex,
|
25
|
+
nonce: Hex,
|
26
|
+
yParity: Hex,
|
27
|
+
r: Hex,
|
28
|
+
s: Hex,
|
29
|
+
]
|
30
|
+
export type SerializedAuthorizationList = readonly SerializedAuthorization[]
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import type { Hex, Signature } from '../../../types/misc.js'
|
3
|
+
|
4
|
+
export type RpcAuthorization = {
|
5
|
+
/** Address of the contract to set as code for the Authority. */
|
6
|
+
address: Address
|
7
|
+
/** Chain ID to authorize. */
|
8
|
+
chainId: Hex
|
9
|
+
/** Nonce of the Authority to authorize. */
|
10
|
+
nonce: Hex
|
11
|
+
} & Signature
|
12
|
+
export type RpcAuthorizationList = readonly RpcAuthorization[]
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import type { ErrorType } from '../../../errors/utils.js'
|
2
|
+
import type { ByteArray, Hex } from '../../../types/misc.js'
|
3
|
+
import {
|
4
|
+
type ConcatHexErrorType,
|
5
|
+
concatHex,
|
6
|
+
} from '../../../utils/data/concat.js'
|
7
|
+
import {
|
8
|
+
type HexToBytesErrorType,
|
9
|
+
hexToBytes,
|
10
|
+
} from '../../../utils/encoding/toBytes.js'
|
11
|
+
import {
|
12
|
+
type NumberToHexErrorType,
|
13
|
+
numberToHex,
|
14
|
+
} from '../../../utils/encoding/toHex.js'
|
15
|
+
import { type ToRlpErrorType, toRlp } from '../../../utils/encoding/toRlp.js'
|
16
|
+
import {
|
17
|
+
type Keccak256ErrorType,
|
18
|
+
keccak256,
|
19
|
+
} from '../../../utils/hash/keccak256.js'
|
20
|
+
import type { Authorization } from '../types/authorization.js'
|
21
|
+
|
22
|
+
type To = 'hex' | 'bytes'
|
23
|
+
|
24
|
+
export type HashAuthorizationParameters<to extends To> = Authorization & {
|
25
|
+
/** Output format. @default "hex" */
|
26
|
+
to?: to | To | undefined
|
27
|
+
}
|
28
|
+
|
29
|
+
export type HashAuthorizationReturnType<to extends To> =
|
30
|
+
| (to extends 'bytes' ? ByteArray : never)
|
31
|
+
| (to extends 'hex' ? Hex : never)
|
32
|
+
|
33
|
+
export type HashAuthorizationErrorType =
|
34
|
+
| Keccak256ErrorType
|
35
|
+
| ConcatHexErrorType
|
36
|
+
| ToRlpErrorType
|
37
|
+
| NumberToHexErrorType
|
38
|
+
| HexToBytesErrorType
|
39
|
+
| ErrorType
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Computes an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.
|
43
|
+
*/
|
44
|
+
export function hashAuthorization<to extends To = 'hex'>(
|
45
|
+
parameters: HashAuthorizationParameters<to>,
|
46
|
+
): HashAuthorizationReturnType<to> {
|
47
|
+
const { chainId, contractAddress, nonce, to } = parameters
|
48
|
+
const hash = keccak256(
|
49
|
+
concatHex([
|
50
|
+
'0x05',
|
51
|
+
toRlp([
|
52
|
+
numberToHex(chainId),
|
53
|
+
contractAddress,
|
54
|
+
[nonce ? numberToHex(nonce) : '0x'],
|
55
|
+
]),
|
56
|
+
]),
|
57
|
+
)
|
58
|
+
if (to === 'bytes') return hexToBytes(hash) as HashAuthorizationReturnType<to>
|
59
|
+
return hash as HashAuthorizationReturnType<to>
|
60
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
3
|
+
import type { ErrorType } from '../../../errors/utils.js'
|
4
|
+
import type { ByteArray, Hex, Signature } from '../../../types/misc.js'
|
5
|
+
import type { OneOf } from '../../../types/utils.js'
|
6
|
+
import {
|
7
|
+
type RecoverAddressErrorType,
|
8
|
+
recoverAddress,
|
9
|
+
} from '../../../utils/signature/recoverAddress.js'
|
10
|
+
import type {
|
11
|
+
Authorization,
|
12
|
+
SignedAuthorization,
|
13
|
+
} from '../types/authorization.js'
|
14
|
+
import {
|
15
|
+
type HashAuthorizationErrorType,
|
16
|
+
hashAuthorization,
|
17
|
+
} from './hashAuthorization.js'
|
18
|
+
|
19
|
+
export type RecoverAuthorizationAddressParameters<
|
20
|
+
authorization extends OneOf<Authorization | SignedAuthorization> = OneOf<
|
21
|
+
Authorization | SignedAuthorization
|
22
|
+
>,
|
23
|
+
//
|
24
|
+
_signature = Hex | ByteArray | OneOf<Signature | SignedAuthorization>,
|
25
|
+
> = {
|
26
|
+
/**
|
27
|
+
* The Authorization object.
|
28
|
+
*
|
29
|
+
* - If an unsigned `authorization` is provided, the `signature` property is required.
|
30
|
+
* - If a signed `authorization` is provided, the `signature` property does not need to be provided.
|
31
|
+
*/
|
32
|
+
authorization: authorization | OneOf<Authorization | SignedAuthorization>
|
33
|
+
} & (authorization extends SignedAuthorization
|
34
|
+
? {
|
35
|
+
/** Signature of the Authorization. Not required if the `authorization` is signed. */
|
36
|
+
signature?: _signature | undefined
|
37
|
+
}
|
38
|
+
: {
|
39
|
+
/** Signature of the Authorization. Not required if the `authorization` is signed. */
|
40
|
+
signature: _signature
|
41
|
+
})
|
42
|
+
|
43
|
+
export type RecoverAuthorizationAddressReturnType = Address
|
44
|
+
|
45
|
+
export type RecoverAuthorizationAddressErrorType =
|
46
|
+
| HashAuthorizationErrorType
|
47
|
+
| RecoverAddressErrorType
|
48
|
+
| ErrorType
|
49
|
+
|
50
|
+
export async function recoverAuthorizationAddress<
|
51
|
+
const authorization extends OneOf<Authorization | SignedAuthorization>,
|
52
|
+
>(
|
53
|
+
parameters: RecoverAuthorizationAddressParameters<authorization>,
|
54
|
+
): Promise<RecoverAuthorizationAddressReturnType> {
|
55
|
+
const { authorization, signature } = parameters
|
56
|
+
|
57
|
+
return recoverAddress({
|
58
|
+
hash: hashAuthorization(authorization as Authorization),
|
59
|
+
signature: (signature ?? authorization) as Signature,
|
60
|
+
})
|
61
|
+
}
|