viem 0.0.0-w-20230829165118 → 0.0.0-w-20230904201641
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/README.md +6 -0
- package/dist/cjs/accounts/index.js +19 -19
- package/dist/cjs/accounts/index.js.map +1 -1
- package/dist/cjs/actions/getContract.js.map +1 -1
- package/dist/cjs/actions/public/call.js +1 -1
- package/dist/cjs/actions/public/call.js.map +1 -1
- package/dist/cjs/actions/public/getLogs.js.map +1 -1
- package/dist/cjs/actions/public/multicall.js +54 -31
- package/dist/cjs/actions/public/multicall.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +3 -2
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +2 -5
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/wallet/deployContract.js +3 -6
- package/dist/cjs/actions/wallet/deployContract.js.map +1 -1
- package/dist/cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/dist/cjs/actions/wallet/signTypedData.js +1 -13
- package/dist/cjs/actions/wallet/signTypedData.js.map +1 -1
- package/dist/cjs/chains/definitions/base.js +1 -3
- package/dist/cjs/chains/definitions/base.js.map +1 -1
- package/dist/cjs/chains/definitions/baseGoerli.js +1 -3
- package/dist/cjs/chains/definitions/baseGoerli.js.map +1 -1
- package/dist/cjs/chains/definitions/meter.js +22 -0
- package/dist/cjs/chains/definitions/meter.js.map +1 -0
- package/dist/cjs/chains/definitions/meterTestnet.js +25 -0
- package/dist/cjs/chains/definitions/meterTestnet.js.map +1 -0
- package/dist/cjs/chains/definitions/opBNB.js +28 -0
- package/dist/cjs/chains/definitions/opBNB.js.map +1 -0
- package/dist/cjs/chains/definitions/opBNBTestnet.js +29 -0
- package/dist/cjs/chains/definitions/opBNBTestnet.js.map +1 -0
- package/dist/cjs/chains/definitions/optimism.js +0 -2
- package/dist/cjs/chains/definitions/optimism.js.map +1 -1
- package/dist/cjs/chains/definitions/optimismGoerli.js +0 -2
- package/dist/cjs/chains/definitions/optimismGoerli.js.map +1 -1
- package/dist/cjs/chains/definitions/plinga.js +31 -0
- package/dist/cjs/chains/definitions/plinga.js.map +1 -0
- package/dist/cjs/chains/definitions/scrollSepolia.js +6 -0
- package/dist/cjs/chains/definitions/scrollSepolia.js.map +1 -1
- package/dist/cjs/chains/definitions/sepolia.js +5 -0
- package/dist/cjs/chains/definitions/sepolia.js.map +1 -1
- package/dist/cjs/chains/definitions/vechain.js +29 -0
- package/dist/cjs/chains/definitions/vechain.js.map +1 -0
- package/dist/cjs/chains/definitions/zora.js +0 -2
- package/dist/cjs/chains/definitions/zora.js.map +1 -1
- package/dist/cjs/chains/definitions/zoraTestnet.js +0 -2
- package/dist/cjs/chains/definitions/zoraTestnet.js.map +1 -1
- package/dist/cjs/chains/index.js +14 -2
- package/dist/cjs/chains/index.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/errors/node.js +1 -1
- package/dist/cjs/errors/node.js.map +1 -1
- package/dist/cjs/errors/utils.js +1 -1
- package/dist/cjs/errors/utils.js.map +1 -1
- package/dist/cjs/{version.js → errors/version.js} +1 -1
- package/dist/cjs/errors/version.js.map +1 -0
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/abi/decodeDeployData.js +2 -1
- package/dist/cjs/utils/abi/decodeDeployData.js.map +1 -1
- package/dist/cjs/utils/abi/decodeErrorResult.js +4 -3
- package/dist/cjs/utils/abi/decodeErrorResult.js.map +1 -1
- package/dist/cjs/utils/abi/decodeEventLog.js +4 -7
- package/dist/cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/cjs/utils/abi/decodeFunctionData.js +2 -1
- package/dist/cjs/utils/abi/decodeFunctionData.js.map +1 -1
- package/dist/cjs/utils/abi/decodeFunctionResult.js +5 -7
- package/dist/cjs/utils/abi/decodeFunctionResult.js.map +1 -1
- package/dist/cjs/utils/abi/encodeDeployData.js +2 -1
- package/dist/cjs/utils/abi/encodeDeployData.js.map +1 -1
- package/dist/cjs/utils/abi/encodeErrorResult.js +5 -7
- package/dist/cjs/utils/abi/encodeErrorResult.js.map +1 -1
- package/dist/cjs/utils/abi/encodeEventTopics.js +8 -13
- package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
- package/dist/cjs/utils/abi/encodeFunctionData.js +9 -10
- package/dist/cjs/utils/abi/encodeFunctionData.js.map +1 -1
- package/dist/cjs/utils/abi/encodeFunctionResult.js +7 -12
- package/dist/cjs/utils/abi/encodeFunctionResult.js.map +1 -1
- package/dist/cjs/utils/abi/getAbiItem.js +2 -1
- package/dist/cjs/utils/abi/getAbiItem.js.map +1 -1
- package/dist/cjs/utils/buildRequest.js +2 -0
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/cjs/utils/ccip.js.map +1 -1
- package/dist/cjs/utils/errors/getCallError.js +4 -3
- package/dist/cjs/utils/errors/getCallError.js.map +1 -1
- package/dist/cjs/utils/errors/getContractError.js +2 -1
- package/dist/cjs/utils/errors/getContractError.js.map +1 -1
- package/dist/cjs/utils/errors/getEstimateGasError.js +4 -3
- package/dist/cjs/utils/errors/getEstimateGasError.js.map +1 -1
- package/dist/cjs/utils/errors/getNodeError.js +16 -10
- package/dist/cjs/utils/errors/getNodeError.js.map +1 -1
- package/dist/cjs/utils/errors/getTransactionError.js +4 -3
- package/dist/cjs/utils/errors/getTransactionError.js.map +1 -1
- package/dist/cjs/utils/formatters/transaction.js +5 -5
- package/dist/cjs/utils/formatters/transaction.js.map +1 -1
- package/dist/cjs/utils/hash/getFunctionSelector.js.map +1 -1
- package/dist/cjs/utils/hash/hashFunction.js.map +1 -1
- package/dist/cjs/utils/rpc.js +10 -16
- package/dist/cjs/utils/rpc.js.map +1 -1
- package/dist/cjs/utils/signature/hashTypedData.js +3 -14
- package/dist/cjs/utils/signature/hashTypedData.js.map +1 -1
- package/dist/cjs/utils/signature/hexToSignature.js +1 -1
- package/dist/cjs/utils/signature/hexToSignature.js.map +1 -1
- package/dist/cjs/utils/typedData.js +27 -1
- package/dist/cjs/utils/typedData.js.map +1 -1
- package/dist/esm/accounts/index.js +9 -9
- package/dist/esm/accounts/index.js.map +1 -1
- package/dist/esm/actions/getContract.js.map +1 -1
- package/dist/esm/actions/public/call.js +1 -1
- package/dist/esm/actions/public/call.js.map +1 -1
- package/dist/esm/actions/public/getLogs.js.map +1 -1
- package/dist/esm/actions/public/multicall.js +66 -31
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +3 -2
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +2 -5
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/wallet/deployContract.js +3 -6
- package/dist/esm/actions/wallet/deployContract.js.map +1 -1
- package/dist/esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/dist/esm/actions/wallet/signTypedData.js +2 -14
- package/dist/esm/actions/wallet/signTypedData.js.map +1 -1
- package/dist/esm/chains/definitions/base.js +1 -3
- package/dist/esm/chains/definitions/base.js.map +1 -1
- package/dist/esm/chains/definitions/baseGoerli.js +1 -3
- package/dist/esm/chains/definitions/baseGoerli.js.map +1 -1
- package/dist/esm/chains/definitions/meter.js +19 -0
- package/dist/esm/chains/definitions/meter.js.map +1 -0
- package/dist/esm/chains/definitions/meterTestnet.js +22 -0
- package/dist/esm/chains/definitions/meterTestnet.js.map +1 -0
- package/dist/esm/chains/definitions/opBNB.js +25 -0
- package/dist/esm/chains/definitions/opBNB.js.map +1 -0
- package/dist/esm/chains/definitions/opBNBTestnet.js +26 -0
- package/dist/esm/chains/definitions/opBNBTestnet.js.map +1 -0
- package/dist/esm/chains/definitions/optimism.js +0 -2
- package/dist/esm/chains/definitions/optimism.js.map +1 -1
- package/dist/esm/chains/definitions/optimismGoerli.js +0 -2
- package/dist/esm/chains/definitions/optimismGoerli.js.map +1 -1
- package/dist/esm/chains/definitions/plinga.js +28 -0
- package/dist/esm/chains/definitions/plinga.js.map +1 -0
- package/dist/esm/chains/definitions/scrollSepolia.js +6 -0
- package/dist/esm/chains/definitions/scrollSepolia.js.map +1 -1
- package/dist/esm/chains/definitions/sepolia.js +5 -0
- package/dist/esm/chains/definitions/sepolia.js.map +1 -1
- package/dist/esm/chains/definitions/vechain.js +26 -0
- package/dist/esm/chains/definitions/vechain.js.map +1 -0
- package/dist/esm/chains/definitions/zora.js +0 -2
- package/dist/esm/chains/definitions/zora.js.map +1 -1
- package/dist/esm/chains/definitions/zoraTestnet.js +0 -2
- package/dist/esm/chains/definitions/zoraTestnet.js.map +1 -1
- package/dist/esm/chains/index.js +6 -0
- package/dist/esm/chains/index.js.map +1 -1
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/errors/node.js +1 -1
- package/dist/esm/errors/node.js.map +1 -1
- package/dist/esm/errors/utils.js +1 -1
- package/dist/esm/errors/utils.js.map +1 -1
- package/dist/esm/errors/version.js +2 -0
- package/dist/esm/errors/version.js.map +1 -0
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/contract.js.map +1 -1
- package/dist/esm/utils/abi/decodeDeployData.js +2 -1
- package/dist/esm/utils/abi/decodeDeployData.js.map +1 -1
- package/dist/esm/utils/abi/decodeErrorResult.js +4 -3
- package/dist/esm/utils/abi/decodeErrorResult.js.map +1 -1
- package/dist/esm/utils/abi/decodeEventLog.js +4 -7
- package/dist/esm/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/esm/utils/abi/decodeFunctionData.js +2 -1
- package/dist/esm/utils/abi/decodeFunctionData.js.map +1 -1
- package/dist/esm/utils/abi/decodeFunctionResult.js +5 -7
- package/dist/esm/utils/abi/decodeFunctionResult.js.map +1 -1
- package/dist/esm/utils/abi/encodeDeployData.js +2 -1
- package/dist/esm/utils/abi/encodeDeployData.js.map +1 -1
- package/dist/esm/utils/abi/encodeErrorResult.js +5 -7
- package/dist/esm/utils/abi/encodeErrorResult.js.map +1 -1
- package/dist/esm/utils/abi/encodeEventTopics.js +8 -13
- package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
- package/dist/esm/utils/abi/encodeFunctionData.js +9 -10
- package/dist/esm/utils/abi/encodeFunctionData.js.map +1 -1
- package/dist/esm/utils/abi/encodeFunctionResult.js +7 -12
- package/dist/esm/utils/abi/encodeFunctionResult.js.map +1 -1
- package/dist/esm/utils/abi/getAbiItem.js +2 -1
- package/dist/esm/utils/abi/getAbiItem.js.map +1 -1
- package/dist/esm/utils/buildRequest.js +4 -0
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/ccip.js.map +1 -1
- package/dist/esm/utils/errors/getCallError.js +5 -4
- package/dist/esm/utils/errors/getCallError.js.map +1 -1
- package/dist/esm/utils/errors/getContractError.js +2 -1
- package/dist/esm/utils/errors/getContractError.js.map +1 -1
- package/dist/esm/utils/errors/getEstimateGasError.js +5 -4
- package/dist/esm/utils/errors/getEstimateGasError.js.map +1 -1
- package/dist/esm/utils/errors/getNodeError.js +16 -10
- package/dist/esm/utils/errors/getNodeError.js.map +1 -1
- package/dist/esm/utils/errors/getTransactionError.js +5 -4
- package/dist/esm/utils/errors/getTransactionError.js.map +1 -1
- package/dist/esm/utils/formatters/transaction.js +5 -5
- package/dist/esm/utils/formatters/transaction.js.map +1 -1
- package/dist/esm/utils/hash/getFunctionSelector.js.map +1 -1
- package/dist/esm/utils/hash/hashFunction.js.map +1 -1
- package/dist/esm/utils/rpc.js +7 -16
- package/dist/esm/utils/rpc.js.map +1 -1
- package/dist/esm/utils/signature/hashTypedData.js +3 -15
- package/dist/esm/utils/signature/hashTypedData.js.map +1 -1
- package/dist/esm/utils/signature/hexToSignature.js +1 -1
- package/dist/esm/utils/signature/hexToSignature.js.map +1 -1
- package/dist/esm/utils/typedData.js +24 -0
- package/dist/esm/utils/typedData.js.map +1 -1
- package/dist/types/accounts/index.d.ts +9 -9
- package/dist/types/accounts/index.d.ts.map +1 -1
- package/dist/types/actions/getContract.d.ts +3 -3
- package/dist/types/actions/getContract.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts.map +1 -1
- package/dist/types/actions/public/multicall.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +29 -29
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +10 -6
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/prepareTransactionRequest.d.ts +1 -1
- package/dist/types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
- package/dist/types/chains/definitions/base.d.ts +1 -1
- package/dist/types/chains/definitions/base.d.ts.map +1 -1
- package/dist/types/chains/definitions/baseGoerli.d.ts +1 -1
- package/dist/types/chains/definitions/baseGoerli.d.ts.map +1 -1
- package/dist/types/chains/definitions/meter.d.ts +28 -0
- package/dist/types/chains/definitions/meter.d.ts.map +1 -0
- package/dist/types/chains/definitions/meterTestnet.d.ts +28 -0
- package/dist/types/chains/definitions/meterTestnet.d.ts.map +1 -0
- package/dist/types/chains/definitions/opBNB.d.ts +34 -0
- package/dist/types/chains/definitions/opBNB.d.ts.map +1 -0
- package/dist/types/chains/definitions/opBNBTestnet.d.ts +35 -0
- package/dist/types/chains/definitions/opBNBTestnet.d.ts.map +1 -0
- package/dist/types/chains/definitions/optimism.d.ts.map +1 -1
- package/dist/types/chains/definitions/optimismGoerli.d.ts.map +1 -1
- package/dist/types/chains/definitions/plinga.d.ts +34 -0
- package/dist/types/chains/definitions/plinga.d.ts.map +1 -0
- package/dist/types/chains/definitions/scrollSepolia.d.ts +6 -0
- package/dist/types/chains/definitions/scrollSepolia.d.ts.map +1 -1
- package/dist/types/chains/definitions/sepolia.d.ts +7 -0
- package/dist/types/chains/definitions/sepolia.d.ts.map +1 -1
- package/dist/types/chains/definitions/vechain.d.ts +32 -0
- package/dist/types/chains/definitions/vechain.d.ts.map +1 -0
- package/dist/types/chains/definitions/zora.d.ts.map +1 -1
- package/dist/types/chains/definitions/zoraTestnet.d.ts.map +1 -1
- package/dist/types/chains/index.d.ts +6 -0
- package/dist/types/chains/index.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +2 -2
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +1 -1
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +2 -0
- package/dist/types/errors/version.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +24 -20
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +48 -82
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/multicall.d.ts +4 -4
- package/dist/types/types/multicall.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeDeployData.d.ts +7 -6
- package/dist/types/utils/abi/decodeDeployData.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeErrorResult.d.ts +16 -11
- package/dist/types/utils/abi/decodeErrorResult.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeEventLog.d.ts +24 -17
- package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeFunctionData.d.ts +14 -10
- package/dist/types/utils/abi/decodeFunctionData.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeFunctionResult.d.ts +18 -11
- package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeDeployData.d.ts +13 -5
- package/dist/types/utils/abi/encodeDeployData.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeErrorResult.d.ts +16 -10
- package/dist/types/utils/abi/encodeErrorResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeEventTopics.d.ts +14 -12
- package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeFunctionData.d.ts +19 -10
- package/dist/types/utils/abi/encodeFunctionData.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeFunctionResult.d.ts +16 -12
- package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
- package/dist/types/utils/abi/getAbiItem.d.ts +11 -8
- package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
- package/dist/types/utils/buildRequest.d.ts.map +1 -1
- package/dist/types/utils/ccip.d.ts.map +1 -1
- package/dist/types/utils/errors/getCallError.d.ts.map +1 -1
- package/dist/types/utils/errors/getContractError.d.ts.map +1 -1
- package/dist/types/utils/errors/getEstimateGasError.d.ts.map +1 -1
- package/dist/types/utils/errors/getNodeError.d.ts +1 -1
- package/dist/types/utils/errors/getNodeError.d.ts.map +1 -1
- package/dist/types/utils/errors/getTransactionError.d.ts.map +1 -1
- package/dist/types/utils/hash/getEventSelector.d.ts +1 -1
- package/dist/types/utils/hash/getEventSelector.d.ts.map +1 -1
- package/dist/types/utils/hash/getFunctionSelector.d.ts.map +1 -1
- package/dist/types/utils/hash/hashFunction.d.ts.map +1 -1
- package/dist/types/utils/rpc.d.ts +3 -1
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/dist/types/utils/signature/hashTypedData.d.ts +10 -1
- package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
- package/dist/types/utils/signature/verifyMessage.d.ts +2 -2
- package/dist/types/utils/signature/verifyMessage.d.ts.map +1 -1
- package/dist/types/utils/typedData.d.ts +8 -1
- package/dist/types/utils/typedData.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/accounts/index.ts +10 -9
- package/src/actions/getContract.ts +5 -2
- package/src/actions/public/call.ts +1 -1
- package/src/actions/public/getLogs.ts +3 -3
- package/src/actions/public/multicall.ts +72 -29
- package/src/actions/public/watchContractEvent.ts +58 -52
- package/src/actions/public/watchEvent.ts +4 -7
- package/src/actions/wallet/deployContract.ts +29 -34
- package/src/actions/wallet/prepareTransactionRequest.ts +3 -6
- package/src/actions/wallet/signTypedData.ts +5 -14
- package/src/chains/definitions/base.ts +1 -3
- package/src/chains/definitions/baseGoerli.ts +1 -3
- package/src/chains/definitions/meter.ts +19 -0
- package/src/chains/definitions/meterTestnet.ts +22 -0
- package/src/chains/definitions/opBNB.ts +26 -0
- package/src/chains/definitions/opBNBTestnet.ts +26 -0
- package/src/chains/definitions/optimism.ts +0 -2
- package/src/chains/definitions/optimismGoerli.ts +0 -2
- package/src/chains/definitions/plinga.ts +28 -0
- package/src/chains/definitions/scrollSepolia.ts +6 -0
- package/src/chains/definitions/sepolia.ts +5 -0
- package/src/chains/definitions/vechain.ts +26 -0
- package/src/chains/definitions/zora.ts +0 -2
- package/src/chains/definitions/zoraTestnet.ts +0 -2
- package/src/chains/index.ts +6 -0
- package/src/clients/decorators/public.ts +2 -1
- package/src/clients/decorators/wallet.ts +3 -3
- package/src/errors/node.ts +1 -1
- package/src/errors/utils.ts +1 -1
- package/src/errors/version.ts +1 -0
- package/src/index.ts +10 -11
- package/src/types/chain.ts +48 -34
- package/src/types/contract.ts +183 -216
- package/src/types/multicall.ts +19 -13
- package/src/utils/abi/decodeDeployData.ts +16 -15
- package/src/utils/abi/decodeErrorResult.ts +41 -25
- package/src/utils/abi/decodeEventLog.ts +65 -67
- package/src/utils/abi/decodeFunctionData.ts +30 -22
- package/src/utils/abi/decodeFunctionResult.ts +124 -46
- package/src/utils/abi/encodeDeployData.ts +27 -16
- package/src/utils/abi/encodeErrorResult.ts +47 -26
- package/src/utils/abi/encodeEventTopics.ts +49 -30
- package/src/utils/abi/encodeFunctionData.ts +58 -32
- package/src/utils/abi/encodeFunctionResult.ts +53 -36
- package/src/utils/abi/getAbiItem.ts +68 -32
- package/src/utils/buildRequest.ts +4 -0
- package/src/utils/ccip.ts +1 -5
- package/src/utils/errors/getCallError.ts +4 -8
- package/src/utils/errors/getContractError.ts +2 -1
- package/src/utils/errors/getEstimateGasError.ts +4 -8
- package/src/utils/errors/getNodeError.ts +18 -13
- package/src/utils/errors/getTransactionError.ts +4 -8
- package/src/utils/formatters/transaction.ts +5 -5
- package/src/utils/hash/getEventSelector.ts +1 -1
- package/src/utils/hash/getFunctionSelector.ts +1 -1
- package/src/utils/hash/hashFunction.ts +1 -1
- package/src/utils/rpc.ts +9 -20
- package/src/utils/signature/hashTypedData.ts +4 -16
- package/src/utils/signature/hexToSignature.ts +1 -1
- package/src/utils/signature/verifyMessage.ts +2 -2
- package/src/utils/typedData.ts +29 -1
- package/dist/cjs/accounts/wordlists/czech.js +0 -6
- package/dist/cjs/accounts/wordlists/czech.js.map +0 -1
- package/dist/cjs/accounts/wordlists/english.js +0 -6
- package/dist/cjs/accounts/wordlists/english.js.map +0 -1
- package/dist/cjs/accounts/wordlists/french.js +0 -6
- package/dist/cjs/accounts/wordlists/french.js.map +0 -1
- package/dist/cjs/accounts/wordlists/italian.js +0 -6
- package/dist/cjs/accounts/wordlists/italian.js.map +0 -1
- package/dist/cjs/accounts/wordlists/japanese.js +0 -6
- package/dist/cjs/accounts/wordlists/japanese.js.map +0 -1
- package/dist/cjs/accounts/wordlists/korean.js +0 -6
- package/dist/cjs/accounts/wordlists/korean.js.map +0 -1
- package/dist/cjs/accounts/wordlists/simplifiedChinese.js +0 -6
- package/dist/cjs/accounts/wordlists/simplifiedChinese.js.map +0 -1
- package/dist/cjs/accounts/wordlists/spanish.js +0 -6
- package/dist/cjs/accounts/wordlists/spanish.js.map +0 -1
- package/dist/cjs/accounts/wordlists/traditionalChinese.js +0 -6
- package/dist/cjs/accounts/wordlists/traditionalChinese.js.map +0 -1
- package/dist/cjs/chains/optimism/fees.js +0 -7
- package/dist/cjs/chains/optimism/fees.js.map +0 -1
- package/dist/cjs/version.js.map +0 -1
- package/dist/esm/accounts/wordlists/czech.js +0 -2
- package/dist/esm/accounts/wordlists/czech.js.map +0 -1
- package/dist/esm/accounts/wordlists/english.js +0 -2
- package/dist/esm/accounts/wordlists/english.js.map +0 -1
- package/dist/esm/accounts/wordlists/french.js +0 -2
- package/dist/esm/accounts/wordlists/french.js.map +0 -1
- package/dist/esm/accounts/wordlists/italian.js +0 -2
- package/dist/esm/accounts/wordlists/italian.js.map +0 -1
- package/dist/esm/accounts/wordlists/japanese.js +0 -2
- package/dist/esm/accounts/wordlists/japanese.js.map +0 -1
- package/dist/esm/accounts/wordlists/korean.js +0 -2
- package/dist/esm/accounts/wordlists/korean.js.map +0 -1
- package/dist/esm/accounts/wordlists/simplifiedChinese.js +0 -2
- package/dist/esm/accounts/wordlists/simplifiedChinese.js.map +0 -1
- package/dist/esm/accounts/wordlists/spanish.js +0 -2
- package/dist/esm/accounts/wordlists/spanish.js.map +0 -1
- package/dist/esm/accounts/wordlists/traditionalChinese.js +0 -2
- package/dist/esm/accounts/wordlists/traditionalChinese.js.map +0 -1
- package/dist/esm/chains/optimism/fees.js +0 -4
- package/dist/esm/chains/optimism/fees.js.map +0 -1
- package/dist/esm/version.js +0 -2
- package/dist/esm/version.js.map +0 -1
- package/dist/types/accounts/wordlists/czech.d.ts +0 -2
- package/dist/types/accounts/wordlists/czech.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/english.d.ts +0 -2
- package/dist/types/accounts/wordlists/english.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/french.d.ts +0 -2
- package/dist/types/accounts/wordlists/french.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/italian.d.ts +0 -2
- package/dist/types/accounts/wordlists/italian.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/japanese.d.ts +0 -2
- package/dist/types/accounts/wordlists/japanese.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/korean.d.ts +0 -2
- package/dist/types/accounts/wordlists/korean.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/simplifiedChinese.d.ts +0 -2
- package/dist/types/accounts/wordlists/simplifiedChinese.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/spanish.d.ts +0 -2
- package/dist/types/accounts/wordlists/spanish.d.ts.map +0 -1
- package/dist/types/accounts/wordlists/traditionalChinese.d.ts +0 -2
- package/dist/types/accounts/wordlists/traditionalChinese.d.ts.map +0 -1
- package/dist/types/chains/optimism/fees.d.ts +0 -4
- package/dist/types/chains/optimism/fees.d.ts.map +0 -1
- package/dist/types/version.d.ts +0 -2
- package/dist/types/version.d.ts.map +0 -1
- package/src/accounts/wordlists/czech.ts +0 -1
- package/src/accounts/wordlists/english.ts +0 -1
- package/src/accounts/wordlists/french.ts +0 -1
- package/src/accounts/wordlists/italian.ts +0 -1
- package/src/accounts/wordlists/japanese.ts +0 -1
- package/src/accounts/wordlists/korean.ts +0 -1
- package/src/accounts/wordlists/simplifiedChinese.ts +0 -1
- package/src/accounts/wordlists/spanish.ts +0 -1
- package/src/accounts/wordlists/traditionalChinese.ts +0 -1
- package/src/chains/optimism/fees.ts +0 -5
- package/src/version.ts +0 -1
@@ -1,10 +1,10 @@
|
|
1
1
|
import type { Address } from 'abitype';
|
2
|
-
import type { ByteArray, Hex } from '../../types/misc.js';
|
2
|
+
import type { ByteArray, Hex, SignableMessage } from '../../types/misc.js';
|
3
3
|
export type VerifyMessageParameters = {
|
4
4
|
/** The address that signed the original message. */
|
5
5
|
address: Address;
|
6
6
|
/** The message to be verified. */
|
7
|
-
message:
|
7
|
+
message: SignableMessage;
|
8
8
|
/** The signature that was generated by signing the message with the address's private key. */
|
9
9
|
signature: Hex | ByteArray;
|
10
10
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"verifyMessage.d.ts","sourceRoot":"","sources":["../../../../src/utils/signature/verifyMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;
|
1
|
+
{"version":3,"file":"verifyMessage.d.ts","sourceRoot":"","sources":["../../../../src/utils/signature/verifyMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAM1E,MAAM,MAAM,uBAAuB,GAAG;IACpC,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAA;IAChB,kCAAkC;IAClC,OAAO,EAAE,eAAe,CAAA;IACxB,8FAA8F;IAC9F,SAAS,EAAE,GAAG,GAAG,SAAS,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAA;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,EAClC,OAAO,EACP,OAAO,EACP,SAAS,GACV,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAK5D"}
|
@@ -1,4 +1,11 @@
|
|
1
|
-
import type { TypedData } from 'abitype';
|
1
|
+
import type { TypedData, TypedDataDomain, TypedDataParameter } from 'abitype';
|
2
|
+
import type { Hex } from '../types/misc.js';
|
2
3
|
import type { TypedDataDefinition } from '../types/typedData.js';
|
3
4
|
export declare function validateTypedData<const typedData extends TypedData | Record<string, unknown>, primaryType extends keyof typedData | 'EIP712Domain'>(parameters: TypedDataDefinition<typedData, primaryType>): void;
|
5
|
+
export declare function getTypesForEIP712Domain({ domain, }: {
|
6
|
+
domain?: TypedDataDomain;
|
7
|
+
}): TypedDataParameter[];
|
8
|
+
export declare function domainSeparator({ domain }: {
|
9
|
+
domain: TypedDataDomain;
|
10
|
+
}): Hex;
|
4
11
|
//# sourceMappingURL=typedData.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../../../src/utils/typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"typedData.d.ts","sourceRoot":"","sources":["../../../src/utils/typedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAI7E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAQhE,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,EACpD,UAAU,EAAE,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,QAoDxD;AAED,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,GACP,EAAE;IAAE,MAAM,CAAC,EAAE,eAAe,CAAA;CAAE,GAAG,kBAAkB,EAAE,CAcrD;AAED,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,GAAG,CAO5E"}
|
package/package.json
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
"name": "viem",
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
4
4
|
"dependencies": {
|
5
|
-
"@adraffy/ens-normalize": "1.9.
|
6
|
-
"@noble/curves": "1.
|
7
|
-
"@noble/hashes": "1.3.
|
8
|
-
"@scure/bip32": "1.3.
|
9
|
-
"@scure/bip39": "1.2.
|
10
|
-
"@types/ws": "8.5.
|
5
|
+
"@adraffy/ens-normalize": "1.9.4",
|
6
|
+
"@noble/curves": "1.2.0",
|
7
|
+
"@noble/hashes": "1.3.2",
|
8
|
+
"@scure/bip32": "1.3.2",
|
9
|
+
"@scure/bip39": "1.2.1",
|
10
|
+
"@types/ws": "^8.5.5",
|
11
11
|
"abitype": "0.9.8",
|
12
12
|
"isomorphic-ws": "5.0.0",
|
13
|
-
"ws": "8.
|
13
|
+
"ws": "8.13.0"
|
14
14
|
},
|
15
15
|
"peerDependencies": {
|
16
16
|
"typescript": ">=5.0.4"
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"optional": true
|
21
21
|
}
|
22
22
|
},
|
23
|
-
"version": "0.0.0-w-
|
23
|
+
"version": "0.0.0-w-20230904201641",
|
24
24
|
"files": [
|
25
25
|
"dist",
|
26
26
|
"!dist/**/*.tsbuildinfo",
|
package/src/accounts/index.ts
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
export type { Address } from 'abitype'
|
2
2
|
export { HDKey } from '@scure/bip32'
|
3
|
+
export { wordlist as czech } from '@scure/bip39/wordlists/czech'
|
4
|
+
export { wordlist as english } from '@scure/bip39/wordlists/english'
|
5
|
+
export { wordlist as french } from '@scure/bip39/wordlists/french'
|
6
|
+
export { wordlist as italian } from '@scure/bip39/wordlists/italian'
|
7
|
+
export { wordlist as japanese } from '@scure/bip39/wordlists/japanese'
|
8
|
+
export { wordlist as korean } from '@scure/bip39/wordlists/korean'
|
9
|
+
export { wordlist as simplifiedChinese } from '@scure/bip39/wordlists/simplified-chinese'
|
10
|
+
export { wordlist as spanish } from '@scure/bip39/wordlists/spanish'
|
11
|
+
export { wordlist as traditionalChinese } from '@scure/bip39/wordlists/traditional-chinese'
|
12
|
+
|
3
13
|
export { generateMnemonic } from './generateMnemonic.js'
|
4
14
|
export { generatePrivateKey } from './generatePrivateKey.js'
|
5
15
|
export { hdKeyToAccount } from './hdKeyToAccount.js'
|
@@ -36,12 +46,3 @@ export {
|
|
36
46
|
export { parseAccount } from './utils/parseAccount.js'
|
37
47
|
export { publicKeyToAddress } from './utils/publicKeyToAddress.js'
|
38
48
|
export { privateKeyToAddress } from './utils/privateKeyToAddress.js'
|
39
|
-
export { czech } from './wordlists/czech.js'
|
40
|
-
export { english } from './wordlists/english.js'
|
41
|
-
export { french } from './wordlists/french.js'
|
42
|
-
export { italian } from './wordlists/italian.js'
|
43
|
-
export { japanese } from './wordlists/japanese.js'
|
44
|
-
export { korean } from './wordlists/korean.js'
|
45
|
-
export { simplifiedChinese } from './wordlists/simplifiedChinese.js'
|
46
|
-
export { spanish } from './wordlists/spanish.js'
|
47
|
-
export { traditionalChinese } from './wordlists/traditionalChinese.js'
|
@@ -17,6 +17,7 @@ import type { Transport } from '../clients/transports/createTransport.js'
|
|
17
17
|
import type { Chain } from '../types/chain.js'
|
18
18
|
import type {
|
19
19
|
AbiEventParametersToPrimitiveTypes,
|
20
|
+
ContractEventName,
|
20
21
|
ContractFunctionArgs,
|
21
22
|
ContractFunctionName,
|
22
23
|
MaybeExtractEventArgsFromAbi,
|
@@ -297,7 +298,9 @@ export type GetContractReturnType<
|
|
297
298
|
[EventName in _EventNames]: GetWatchEvent<
|
298
299
|
_Narrowable,
|
299
300
|
TAbi,
|
300
|
-
EventName
|
301
|
+
EventName extends ContractEventName<TAbi>
|
302
|
+
? EventName
|
303
|
+
: never
|
301
304
|
>
|
302
305
|
}
|
303
306
|
})
|
@@ -950,7 +953,7 @@ type GetEventFilter<
|
|
950
953
|
type GetWatchEvent<
|
951
954
|
Narrowable extends boolean,
|
952
955
|
TAbi extends Abi | readonly unknown[],
|
953
|
-
TEventName extends
|
956
|
+
TEventName extends ContractEventName<TAbi>,
|
954
957
|
TAbiEvent extends AbiEvent = TAbi extends Abi
|
955
958
|
? ExtractAbiEvent<TAbi, TEventName>
|
956
959
|
: AbiEvent,
|
@@ -89,7 +89,7 @@ export async function call<TChain extends Chain | undefined>(
|
|
89
89
|
args: CallParameters<TChain>,
|
90
90
|
): Promise<CallReturnType> {
|
91
91
|
const {
|
92
|
-
account: account_,
|
92
|
+
account: account_ = client.account,
|
93
93
|
batch = Boolean(client.batch?.multicall),
|
94
94
|
blockNumber,
|
95
95
|
blockTag = 'latest',
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { AbiEvent, Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
@@ -191,9 +191,9 @@ export async function getLogs<
|
|
191
191
|
try {
|
192
192
|
const { eventName, args } = events
|
193
193
|
? decodeEventLog({
|
194
|
-
abi: events
|
194
|
+
abi: events,
|
195
195
|
data: log.data,
|
196
|
-
topics: log.topics
|
196
|
+
topics: log.topics,
|
197
197
|
strict,
|
198
198
|
})
|
199
199
|
: { eventName: undefined, args: undefined }
|
@@ -4,7 +4,7 @@ import type { Client } from '../../clients/createClient.js'
|
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
5
|
import { multicall3Abi } from '../../constants/abis.js'
|
6
6
|
import { AbiDecodingZeroDataError } from '../../errors/abi.js'
|
7
|
-
import
|
7
|
+
import { BaseError } from '../../errors/base.js'
|
8
8
|
import { RawContractError } from '../../errors/contract.js'
|
9
9
|
import type { Chain } from '../../types/chain.js'
|
10
10
|
import type { ContractFunctionParameters } from '../../types/contract.js'
|
@@ -138,8 +138,17 @@ export async function multicall<
|
|
138
138
|
const { abi, address, args, functionName } = contracts[i]
|
139
139
|
try {
|
140
140
|
const callData = encodeFunctionData({ abi, args, functionName })
|
141
|
-
|
142
|
-
|
141
|
+
|
142
|
+
currentChunkSize += (callData.length - 2) / 2
|
143
|
+
// Check to see if we need to create a new chunk.
|
144
|
+
if (
|
145
|
+
// Check if batching is enabled.
|
146
|
+
batchSize > 0 &&
|
147
|
+
// Check if the current size of the batch exceeds the size limit.
|
148
|
+
currentChunkSize > batchSize &&
|
149
|
+
// Check if the current chunk is not already empty.
|
150
|
+
chunkedCalls[currentChunk].length > 0
|
151
|
+
) {
|
143
152
|
currentChunk++
|
144
153
|
currentChunkSize = (callData.length - 2) / 2
|
145
154
|
chunkedCalls[currentChunk] = []
|
@@ -173,7 +182,7 @@ export async function multicall<
|
|
173
182
|
}
|
174
183
|
}
|
175
184
|
|
176
|
-
const
|
185
|
+
const aggregate3Results = await Promise.allSettled(
|
177
186
|
chunkedCalls.map((calls) =>
|
178
187
|
readContract(client, {
|
179
188
|
abi: multicall3Abi,
|
@@ -186,30 +195,64 @@ export async function multicall<
|
|
186
195
|
),
|
187
196
|
)
|
188
197
|
|
189
|
-
|
190
|
-
|
191
|
-
const
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
198
|
+
const results = []
|
199
|
+
for (let i = 0; i < aggregate3Results.length; i++) {
|
200
|
+
const result = aggregate3Results[i]
|
201
|
+
|
202
|
+
// If an error occurred in a `readContract` invocation (ie. network error),
|
203
|
+
// then append the failure reason to each contract result.
|
204
|
+
if (result.status === 'rejected') {
|
205
|
+
if (!allowFailure) throw result.reason
|
206
|
+
for (let j = 0; j < chunkedCalls[i].length; j++) {
|
207
|
+
results.push({
|
208
|
+
status: 'failure',
|
209
|
+
error: result.reason,
|
210
|
+
result: undefined,
|
211
|
+
})
|
212
|
+
}
|
213
|
+
continue
|
214
|
+
}
|
215
|
+
|
216
|
+
// If the `readContract` call was successful, then decode the results.
|
217
|
+
const aggregate3Result = result.value
|
218
|
+
for (let j = 0; j < aggregate3Result.length; j++) {
|
219
|
+
// Extract the response from `readContract`
|
220
|
+
const { returnData, success } = aggregate3Result[j]
|
221
|
+
|
222
|
+
// Extract the request call data from the original call.
|
223
|
+
const { callData } = chunkedCalls[i][j]
|
224
|
+
|
225
|
+
// Extract the contract config for this call from the `contracts` argument
|
226
|
+
// for decoding.
|
227
|
+
const { abi, address, functionName, args } = contracts[
|
228
|
+
results.length
|
229
|
+
] as ContractFunctionParameters
|
230
|
+
|
231
|
+
try {
|
232
|
+
if (callData === '0x') throw new AbiDecodingZeroDataError()
|
233
|
+
if (!success) throw new RawContractError({ data: returnData })
|
234
|
+
const result = decodeFunctionResult({
|
235
|
+
abi,
|
236
|
+
args,
|
237
|
+
data: returnData,
|
238
|
+
functionName,
|
239
|
+
})
|
240
|
+
results.push(allowFailure ? { result, status: 'success' } : result)
|
241
|
+
} catch (err) {
|
242
|
+
const error = getContractError(err as BaseError, {
|
243
|
+
abi,
|
244
|
+
address,
|
245
|
+
args,
|
246
|
+
docsPath: '/docs/contract/multicall',
|
247
|
+
functionName,
|
248
|
+
})
|
249
|
+
if (!allowFailure) throw error
|
250
|
+
results.push({ error, result: undefined, status: 'failure' })
|
251
|
+
}
|
213
252
|
}
|
214
|
-
}
|
253
|
+
}
|
254
|
+
|
255
|
+
if (results.length !== contracts.length)
|
256
|
+
throw new BaseError('multicall results mismatch')
|
257
|
+
return results as MulticallResults<contracts, allowFailure>
|
215
258
|
}
|
@@ -3,7 +3,10 @@ import type { Abi, AbiEvent, Address, ExtractAbiEvent } from 'abitype'
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
5
5
|
import type { Chain } from '../../types/chain.js'
|
6
|
-
import type {
|
6
|
+
import type {
|
7
|
+
ContractEventArgs,
|
8
|
+
ContractEventName,
|
9
|
+
} from '../../types/contract.js'
|
7
10
|
import type { Filter } from '../../types/filter.js'
|
8
11
|
import type { Log } from '../../types/log.js'
|
9
12
|
import type { GetTransportConfig } from '../../types/transport.js'
|
@@ -37,74 +40,75 @@ import { getFilterChanges } from './getFilterChanges.js'
|
|
37
40
|
import { getLogs } from './getLogs.js'
|
38
41
|
import { uninstallFilter } from './uninstallFilter.js'
|
39
42
|
|
40
|
-
type PollOptions = {
|
41
|
-
/**
|
42
|
-
* Whether or not the transaction hashes should be batched on each invocation.
|
43
|
-
* @default true
|
44
|
-
*/
|
45
|
-
batch?: boolean
|
46
|
-
/**
|
47
|
-
* Polling frequency (in ms). Defaults to Client's pollingInterval config.
|
48
|
-
* @default client.pollingInterval
|
49
|
-
*/
|
50
|
-
pollingInterval?: number
|
51
|
-
}
|
52
|
-
|
53
43
|
export type WatchContractEventOnLogsParameter<
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
> =
|
58
|
-
?
|
44
|
+
abi extends Abi | readonly unknown[] = Abi,
|
45
|
+
eventName extends ContractEventName<abi> = ContractEventName<abi>,
|
46
|
+
strict extends boolean | undefined = undefined,
|
47
|
+
> = abi extends Abi
|
48
|
+
? Abi extends abi
|
49
|
+
? Log[]
|
50
|
+
: Log<bigint, number, false, ExtractAbiEvent<abi, eventName>, strict>[]
|
59
51
|
: Log[]
|
52
|
+
|
60
53
|
export type WatchContractEventOnLogsFn<
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
> = (logs: WatchContractEventOnLogsParameter<
|
54
|
+
abi extends Abi | readonly unknown[] = Abi,
|
55
|
+
eventName extends ContractEventName<abi> = ContractEventName<abi>,
|
56
|
+
strict extends boolean | undefined = undefined,
|
57
|
+
> = (logs: WatchContractEventOnLogsParameter<abi, eventName, strict>) => void
|
65
58
|
|
66
59
|
export type WatchContractEventParameters<
|
67
|
-
|
68
|
-
|
69
|
-
|
60
|
+
abi extends Abi | readonly unknown[] = Abi,
|
61
|
+
eventName extends ContractEventName<abi> = ContractEventName<abi>,
|
62
|
+
strict extends boolean | undefined = undefined,
|
70
63
|
> = {
|
71
64
|
/** The address of the contract. */
|
72
|
-
address?: Address | Address[]
|
65
|
+
address?: Address | Address[] | undefined
|
73
66
|
/** Contract ABI. */
|
74
|
-
abi:
|
75
|
-
args?:
|
67
|
+
abi: abi
|
68
|
+
args?: ContractEventArgs<abi, eventName> | undefined
|
76
69
|
/** Contract event. */
|
77
|
-
eventName?:
|
70
|
+
eventName?: eventName | ContractEventName<abi> | undefined
|
78
71
|
/** The callback to call when an error occurred when trying to get for a new block. */
|
79
|
-
onError?: (error: Error) => void
|
72
|
+
onError?: ((error: Error) => void) | undefined
|
80
73
|
/** The callback to call when new event logs are received. */
|
81
|
-
onLogs: WatchContractEventOnLogsFn<
|
74
|
+
onLogs: WatchContractEventOnLogsFn<abi, eventName, strict>
|
82
75
|
/**
|
83
76
|
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
84
77
|
* @default false
|
85
78
|
*/
|
86
|
-
strict?:
|
79
|
+
strict?: strict | undefined
|
87
80
|
} & (GetTransportConfig<Transport>['type'] extends 'webSocket'
|
88
81
|
?
|
89
82
|
| {
|
90
|
-
batch?:
|
83
|
+
batch?: undefined
|
91
84
|
/**
|
92
85
|
* Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`.
|
93
86
|
* @default false
|
94
87
|
*/
|
95
|
-
poll?: false
|
96
|
-
pollingInterval?:
|
88
|
+
poll?: false | undefined
|
89
|
+
pollingInterval?: undefined
|
97
90
|
}
|
98
91
|
| (PollOptions & {
|
99
92
|
/**
|
100
93
|
* Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`.
|
101
94
|
* @default true
|
102
95
|
*/
|
103
|
-
poll?: true
|
96
|
+
poll?: true | undefined
|
104
97
|
})
|
105
|
-
: PollOptions & {
|
106
|
-
|
107
|
-
|
98
|
+
: PollOptions & { poll?: true | undefined })
|
99
|
+
|
100
|
+
type PollOptions = {
|
101
|
+
/**
|
102
|
+
* Whether or not the transaction hashes should be batched on each invocation.
|
103
|
+
* @default true
|
104
|
+
*/
|
105
|
+
batch?: boolean | undefined
|
106
|
+
/**
|
107
|
+
* Polling frequency (in ms). Defaults to Client's pollingInterval config.
|
108
|
+
* @default client.pollingInterval
|
109
|
+
*/
|
110
|
+
pollingInterval?: number | undefined
|
111
|
+
}
|
108
112
|
|
109
113
|
export type WatchContractEventReturnType = () => void
|
110
114
|
|
@@ -139,13 +143,15 @@ export type WatchContractEventReturnType = () => void
|
|
139
143
|
* })
|
140
144
|
*/
|
141
145
|
export function watchContractEvent<
|
142
|
-
|
143
|
-
const
|
144
|
-
|
145
|
-
|
146
|
+
chain extends Chain | undefined,
|
147
|
+
const abi extends Abi | readonly unknown[],
|
148
|
+
eventName extends ContractEventName<abi>,
|
149
|
+
strict extends boolean | undefined = undefined,
|
146
150
|
>(
|
147
|
-
client: Client<Transport,
|
148
|
-
|
151
|
+
client: Client<Transport, chain>,
|
152
|
+
parameters: WatchContractEventParameters<abi, eventName, strict>,
|
153
|
+
): WatchContractEventReturnType {
|
154
|
+
const {
|
149
155
|
abi,
|
150
156
|
address,
|
151
157
|
args,
|
@@ -156,8 +162,8 @@ export function watchContractEvent<
|
|
156
162
|
poll: poll_,
|
157
163
|
pollingInterval = client.pollingInterval,
|
158
164
|
strict: strict_,
|
159
|
-
}
|
160
|
-
|
165
|
+
} = parameters
|
166
|
+
|
161
167
|
const enablePolling =
|
162
168
|
typeof poll_ !== 'undefined' ? poll_ : client.transport.type !== 'webSocket'
|
163
169
|
|
@@ -175,7 +181,7 @@ export function watchContractEvent<
|
|
175
181
|
|
176
182
|
return observe(observerId, { onLogs, onError }, (emit) => {
|
177
183
|
let previousBlockNumber: bigint
|
178
|
-
let filter: Filter<'event',
|
184
|
+
let filter: Filter<'event', abi, eventName> | undefined
|
179
185
|
let initialized = false
|
180
186
|
|
181
187
|
const unwatch = poll(
|
@@ -190,8 +196,8 @@ export function watchContractEvent<
|
|
190
196
|
strict,
|
191
197
|
} as unknown as CreateContractEventFilterParameters)) as Filter<
|
192
198
|
'event',
|
193
|
-
|
194
|
-
|
199
|
+
abi,
|
200
|
+
eventName
|
195
201
|
>
|
196
202
|
} catch {}
|
197
203
|
initialized = true
|
@@ -215,7 +221,7 @@ export function watchContractEvent<
|
|
215
221
|
if (previousBlockNumber && previousBlockNumber !== blockNumber) {
|
216
222
|
logs = await getLogs(client, {
|
217
223
|
address,
|
218
|
-
args,
|
224
|
+
args: args as any,
|
219
225
|
fromBlock: previousBlockNumber + 1n,
|
220
226
|
toBlock: blockNumber,
|
221
227
|
event: getAbiItem({
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { AbiEvent, Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
@@ -312,15 +312,12 @@ export function watchEvent<
|
|
312
312
|
const log = data.result
|
313
313
|
try {
|
314
314
|
const { eventName, args } = decodeEventLog({
|
315
|
-
abi: events_
|
315
|
+
abi: events_ ?? [],
|
316
316
|
data: log.data,
|
317
|
-
topics: log.topics
|
317
|
+
topics: log.topics,
|
318
318
|
strict,
|
319
319
|
})
|
320
|
-
const formatted = formatLog(log, {
|
321
|
-
args,
|
322
|
-
eventName: eventName as string,
|
323
|
-
})
|
320
|
+
const formatted = formatLog(log, { args, eventName })
|
324
321
|
onLogs([formatted] as any)
|
325
322
|
} catch (err) {
|
326
323
|
let eventName
|
@@ -5,9 +5,9 @@ import type { Client } from '../../clients/createClient.js'
|
|
5
5
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
6
6
|
import type { Chain } from '../../types/chain.js'
|
7
7
|
import type { GetChain } from '../../types/chain.js'
|
8
|
-
import type {
|
8
|
+
import type { ContractConstructorArgs } from '../../types/contract.js'
|
9
9
|
import type { Hex } from '../../types/misc.js'
|
10
|
-
import type { UnionOmit } from '../../types/utils.js'
|
10
|
+
import type { UnionEvaluate, UnionOmit } from '../../types/utils.js'
|
11
11
|
import { encodeDeployData } from '../../utils/abi/encodeDeployData.js'
|
12
12
|
|
13
13
|
import {
|
@@ -17,18 +17,25 @@ import {
|
|
17
17
|
} from './sendTransaction.js'
|
18
18
|
|
19
19
|
export type DeployContractParameters<
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
abi extends Abi | readonly unknown[] = Abi,
|
21
|
+
chain extends Chain | undefined = Chain | undefined,
|
22
|
+
account extends Account | undefined = Account | undefined,
|
23
|
+
chainOverride extends Chain | undefined = Chain | undefined,
|
24
|
+
///
|
25
|
+
allArgs = ContractConstructorArgs<abi>,
|
24
26
|
> = UnionOmit<
|
25
|
-
SendTransactionParameters<
|
27
|
+
SendTransactionParameters<chain, account, chainOverride>,
|
26
28
|
'accessList' | 'chain' | 'to' | 'data'
|
27
|
-
> &
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
> &
|
30
|
+
GetChain<chain, chainOverride> &
|
31
|
+
UnionEvaluate<
|
32
|
+
readonly [] extends allArgs
|
33
|
+
? { args?: allArgs | undefined }
|
34
|
+
: { args: allArgs }
|
35
|
+
> & {
|
36
|
+
abi: abi
|
37
|
+
bytecode: Hex
|
38
|
+
}
|
32
39
|
|
33
40
|
export type DeployContractReturnType = SendTransactionReturnType
|
34
41
|
|
@@ -60,31 +67,19 @@ export type DeployContractReturnType = SendTransactionReturnType
|
|
60
67
|
* })
|
61
68
|
*/
|
62
69
|
export function deployContract<
|
63
|
-
const
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
const abi extends Abi | readonly unknown[],
|
71
|
+
chain extends Chain | undefined,
|
72
|
+
account extends Account | undefined,
|
73
|
+
chainOverride extends Chain | undefined,
|
67
74
|
>(
|
68
|
-
walletClient: Client<Transport,
|
69
|
-
|
70
|
-
abi,
|
71
|
-
args,
|
72
|
-
bytecode,
|
73
|
-
...request
|
74
|
-
}: DeployContractParameters<TAbi, TChain, TAccount, TChainOverride>,
|
75
|
+
walletClient: Client<Transport, chain, account>,
|
76
|
+
parameters: DeployContractParameters<abi, chain, account, chainOverride>,
|
75
77
|
): Promise<DeployContractReturnType> {
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
bytecode,
|
80
|
-
} as unknown as DeployContractParameters<
|
81
|
-
TAbi,
|
82
|
-
TChain,
|
83
|
-
TAccount,
|
84
|
-
TChainOverride
|
85
|
-
>)
|
78
|
+
const { abi, args, bytecode, ...request } =
|
79
|
+
parameters as DeployContractParameters
|
80
|
+
const calldata = encodeDeployData({ abi, args, bytecode })
|
86
81
|
return sendTransaction(walletClient, {
|
87
82
|
...request,
|
88
83
|
data: calldata,
|
89
|
-
} as unknown as SendTransactionParameters<
|
84
|
+
} as unknown as SendTransactionParameters<chain, account, chainOverride>)
|
90
85
|
}
|
@@ -41,11 +41,8 @@ export type PrepareTransactionRequestReturnType<
|
|
41
41
|
TChain extends Chain | undefined = Chain | undefined,
|
42
42
|
TAccount extends Account | undefined = Account | undefined,
|
43
43
|
TChainOverride extends Chain | undefined = Chain | undefined,
|
44
|
-
> =
|
45
|
-
|
46
|
-
TChainOverride extends Chain ? TChainOverride : TChain
|
47
|
-
>,
|
48
|
-
'from'
|
44
|
+
> = FormattedTransactionRequest<
|
45
|
+
TChainOverride extends Chain ? TChainOverride : TChain
|
49
46
|
> &
|
50
47
|
GetAccountParameter<TAccount> &
|
51
48
|
GetChain<TChain, TChainOverride>
|
@@ -171,7 +168,7 @@ export async function prepareTransactionRequest<
|
|
171
168
|
|
172
169
|
assertRequest(request as AssertRequestParameters)
|
173
170
|
|
174
|
-
return request as PrepareTransactionRequestReturnType<
|
171
|
+
return request as unknown as PrepareTransactionRequestReturnType<
|
175
172
|
TChain,
|
176
173
|
TAccount,
|
177
174
|
TChainOverride
|
@@ -11,7 +11,10 @@ import type { Hex } from '../../types/misc.js'
|
|
11
11
|
import type { TypedDataDefinition } from '../../types/typedData.js'
|
12
12
|
import { isHex } from '../../utils/data/isHex.js'
|
13
13
|
import { stringify } from '../../utils/stringify.js'
|
14
|
-
import {
|
14
|
+
import {
|
15
|
+
getTypesForEIP712Domain,
|
16
|
+
validateTypedData,
|
17
|
+
} from '../../utils/typedData.js'
|
15
18
|
|
16
19
|
export type SignTypedDataParameters<
|
17
20
|
typedData extends TypedData | Record<string, unknown> = TypedData,
|
@@ -143,19 +146,7 @@ export async function signTypedData<
|
|
143
146
|
const account = parseAccount(account_)
|
144
147
|
|
145
148
|
const types = {
|
146
|
-
EIP712Domain:
|
147
|
-
typeof domain?.name === 'string' && { name: 'name', type: 'string' },
|
148
|
-
domain?.version && { name: 'version', type: 'string' },
|
149
|
-
typeof domain?.chainId === 'number' && {
|
150
|
-
name: 'chainId',
|
151
|
-
type: 'uint256',
|
152
|
-
},
|
153
|
-
domain?.verifyingContract && {
|
154
|
-
name: 'verifyingContract',
|
155
|
-
type: 'address',
|
156
|
-
},
|
157
|
-
domain?.salt && { name: 'salt', type: 'bytes32' },
|
158
|
-
].filter(Boolean),
|
149
|
+
EIP712Domain: getTypesForEIP712Domain({ domain }),
|
159
150
|
...parameters.types,
|
160
151
|
}
|
161
152
|
|