viem 0.0.0-portable-types-20230523145621 → 0.0.0-tmm-sign-typed-data-types.20230619T221425
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 +12 -0
- package/dist/cjs/actions/ens/getEnsAddress.js +34 -23
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/getContract.js +22 -16
- 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/createContractEventFilter.js +2 -1
- package/dist/cjs/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/createEventFilter.js +2 -1
- package/dist/cjs/actions/public/createEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/estimateContractGas.js +1 -1
- package/dist/cjs/actions/public/estimateContractGas.js.map +1 -1
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/public/getBlock.js.map +1 -1
- package/dist/cjs/actions/public/getBlockTransactionCount.js +1 -1
- package/dist/cjs/actions/public/getBlockTransactionCount.js.map +1 -1
- package/dist/cjs/actions/public/getChainId.js +3 -1
- package/dist/cjs/actions/public/getChainId.js.map +1 -1
- package/dist/cjs/actions/public/getFilterChanges.js +15 -3
- package/dist/cjs/actions/public/getFilterChanges.js.map +1 -1
- package/dist/cjs/actions/public/getFilterLogs.js +14 -2
- package/dist/cjs/actions/public/getFilterLogs.js.map +1 -1
- package/dist/cjs/actions/public/getGasPrice.js.map +1 -1
- package/dist/cjs/actions/public/getLogs.js +15 -3
- package/dist/cjs/actions/public/getLogs.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionCount.js.map +1 -1
- package/dist/cjs/actions/public/verifyTypedData.js +6 -1
- package/dist/cjs/actions/public/verifyTypedData.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +3 -1
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +3 -1
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/test/getAutomine.js +4 -0
- package/dist/cjs/actions/test/getAutomine.js.map +1 -1
- package/dist/cjs/actions/test/mine.js +10 -4
- package/dist/cjs/actions/test/mine.js.map +1 -1
- package/dist/cjs/actions/test/sendUnsignedTransaction.js +21 -3
- package/dist/cjs/actions/test/sendUnsignedTransaction.js.map +1 -1
- package/dist/cjs/actions/test/setAutomine.js +11 -4
- package/dist/cjs/actions/test/setAutomine.js.map +1 -1
- package/dist/cjs/actions/test/setBalance.js +10 -4
- package/dist/cjs/actions/test/setBalance.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/signMessage.js +8 -1
- package/dist/cjs/actions/wallet/signMessage.js.map +1 -1
- package/dist/cjs/chains.js +14 -2
- package/dist/cjs/chains.js.map +1 -1
- package/dist/cjs/clients/createClient.js +1 -1
- package/dist/cjs/clients/createClient.js.map +1 -1
- package/dist/cjs/clients/createPublicClient.js.map +1 -1
- package/dist/cjs/clients/createTestClient.js.map +1 -1
- package/dist/cjs/clients/createWalletClient.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/clients/decorators/test.js.map +1 -1
- package/dist/cjs/clients/transports/createTransport.js.map +1 -1
- package/dist/cjs/clients/transports/custom.js.map +1 -1
- package/dist/cjs/clients/transports/fallback.js.map +1 -1
- package/dist/cjs/clients/transports/http.js +25 -7
- package/dist/cjs/clients/transports/http.js.map +1 -1
- package/dist/cjs/clients/transports/webSocket.js +22 -14
- package/dist/cjs/clients/transports/webSocket.js.map +1 -1
- package/dist/cjs/errors/abi.js +15 -1
- package/dist/cjs/errors/abi.js.map +1 -1
- package/dist/cjs/errors/base.js +4 -11
- package/dist/cjs/errors/base.js.map +1 -1
- package/dist/cjs/errors/request.js.map +1 -1
- package/dist/cjs/errors/rpc.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/errors/version.js.map +1 -1
- package/dist/cjs/index.js +26 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/eip1193.js.map +1 -1
- package/dist/cjs/utils/abi/decodeEventLog.js +33 -19
- package/dist/cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/cjs/utils/abi/encodeEventTopics.js +11 -7
- package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
- package/dist/cjs/utils/abi/getAbiItem.js +2 -0
- package/dist/cjs/utils/abi/getAbiItem.js.map +1 -1
- package/dist/cjs/utils/encoding/toBytes.js.map +1 -1
- package/dist/cjs/utils/encoding/toHex.js.map +1 -1
- package/dist/cjs/utils/ens/encodeLabelhash.js +8 -0
- package/dist/cjs/utils/ens/encodeLabelhash.js.map +1 -0
- package/dist/cjs/utils/ens/encodedLabelToLabelhash.js +18 -0
- package/dist/cjs/utils/ens/encodedLabelToLabelhash.js.map +1 -0
- package/dist/cjs/utils/ens/labelhash.js +2 -1
- package/dist/cjs/utils/ens/labelhash.js.map +1 -1
- package/dist/cjs/utils/ens/namehash.js +5 -1
- package/dist/cjs/utils/ens/namehash.js.map +1 -1
- package/dist/cjs/utils/ens/packetToBytes.js +10 -9
- package/dist/cjs/utils/ens/packetToBytes.js.map +1 -1
- package/dist/cjs/utils/filters/createFilterRequestScope.js.map +1 -1
- package/dist/cjs/utils/formatters/block.js +3 -1
- package/dist/cjs/utils/formatters/block.js.map +1 -1
- package/dist/cjs/utils/formatters/log.js +2 -2
- package/dist/cjs/utils/formatters/transaction.js +3 -1
- package/dist/cjs/utils/formatters/transaction.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionReceipt.js +1 -1
- package/dist/cjs/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/cjs/utils/hash/getEventSelector.js +5 -1
- package/dist/cjs/utils/hash/getEventSelector.js.map +1 -1
- package/dist/cjs/utils/hash/getFunctionSelector.js +5 -1
- package/dist/cjs/utils/hash/getFunctionSelector.js.map +1 -1
- package/dist/cjs/utils/hash/hashFunction.js +6 -4
- package/dist/cjs/utils/hash/hashFunction.js.map +1 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/observe.js.map +1 -1
- package/dist/cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/dist/cjs/utils/promise/withCache.js +8 -4
- package/dist/cjs/utils/promise/withCache.js.map +1 -1
- package/dist/cjs/utils/rpc.js +12 -17
- package/dist/cjs/utils/rpc.js.map +1 -1
- package/dist/cjs/utils/signature/hashMessage.js +7 -1
- package/dist/cjs/utils/signature/hashMessage.js.map +1 -1
- package/dist/cjs/utils/transaction/getTransactionType.js.map +1 -1
- package/dist/cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/cjs/utils/typedData.js.map +1 -1
- package/dist/cjs/utils/unit/parseUnits.js +13 -3
- package/dist/cjs/utils/unit/parseUnits.js.map +1 -1
- package/dist/esm/accounts/generateMnemonic.js +7 -0
- package/dist/esm/accounts/generateMnemonic.js.map +1 -1
- package/dist/esm/accounts/generatePrivateKey.js +5 -0
- package/dist/esm/accounts/generatePrivateKey.js.map +1 -1
- package/dist/esm/accounts/hdKeyToAccount.js +5 -0
- package/dist/esm/accounts/hdKeyToAccount.js.map +1 -1
- package/dist/esm/accounts/mnemonicToAccount.js +5 -0
- package/dist/esm/accounts/mnemonicToAccount.js.map +1 -1
- package/dist/esm/accounts/privateKeyToAccount.js +5 -0
- package/dist/esm/accounts/privateKeyToAccount.js.map +1 -1
- package/dist/esm/accounts/toAccount.js +5 -0
- package/dist/esm/accounts/toAccount.js.map +1 -1
- package/dist/esm/accounts/utils/publicKeyToAddress.js +7 -0
- package/dist/esm/accounts/utils/publicKeyToAddress.js.map +1 -1
- package/dist/esm/accounts/utils/sign.js +8 -0
- package/dist/esm/accounts/utils/sign.js.map +1 -1
- package/dist/esm/accounts/utils/signMessage.js +6 -0
- package/dist/esm/accounts/utils/signMessage.js.map +1 -1
- package/dist/esm/accounts/utils/signTypedData.js +6 -0
- package/dist/esm/accounts/utils/signTypedData.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js +62 -23
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAvatar.js +28 -0
- package/dist/esm/actions/ens/getEnsAvatar.js.map +1 -1
- package/dist/esm/actions/ens/getEnsName.js +27 -0
- package/dist/esm/actions/ens/getEnsName.js.map +1 -1
- package/dist/esm/actions/ens/getEnsResolver.js +28 -0
- package/dist/esm/actions/ens/getEnsResolver.js.map +1 -1
- package/dist/esm/actions/ens/getEnsText.js +29 -0
- package/dist/esm/actions/ens/getEnsText.js.map +1 -1
- package/dist/esm/actions/getContract.js +58 -16
- package/dist/esm/actions/getContract.js.map +1 -1
- package/dist/esm/actions/public/call.js +32 -1
- package/dist/esm/actions/public/call.js.map +1 -1
- package/dist/esm/actions/public/createBlockFilter.js +21 -0
- package/dist/esm/actions/public/createBlockFilter.js.map +1 -1
- package/dist/esm/actions/public/createContractEventFilter.js +24 -1
- package/dist/esm/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createEventFilter.js +25 -1
- package/dist/esm/actions/public/createEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createPendingTransactionFilter.js +21 -0
- package/dist/esm/actions/public/createPendingTransactionFilter.js.map +1 -1
- package/dist/esm/actions/public/estimateContractGas.js +28 -1
- package/dist/esm/actions/public/estimateContractGas.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +26 -0
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/getBalance.js +35 -0
- package/dist/esm/actions/public/getBalance.js.map +1 -1
- package/dist/esm/actions/public/getBlock.js +24 -0
- package/dist/esm/actions/public/getBlock.js.map +1 -1
- package/dist/esm/actions/public/getBlockNumber.js +23 -0
- package/dist/esm/actions/public/getBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/getBlockTransactionCount.js +24 -1
- package/dist/esm/actions/public/getBlockTransactionCount.js.map +1 -1
- package/dist/esm/actions/public/getBytecode.js +23 -0
- package/dist/esm/actions/public/getBytecode.js.map +1 -1
- package/dist/esm/actions/public/getChainId.js +24 -1
- package/dist/esm/actions/public/getChainId.js.map +1 -1
- package/dist/esm/actions/public/getFeeHistory.js +24 -0
- package/dist/esm/actions/public/getFeeHistory.js.map +1 -1
- package/dist/esm/actions/public/getFilterChanges.js +99 -3
- package/dist/esm/actions/public/getFilterChanges.js.map +1 -1
- package/dist/esm/actions/public/getFilterLogs.js +43 -2
- package/dist/esm/actions/public/getFilterLogs.js.map +1 -1
- package/dist/esm/actions/public/getGasPrice.js +20 -0
- package/dist/esm/actions/public/getGasPrice.js.map +1 -1
- package/dist/esm/actions/public/getLogs.js +39 -3
- package/dist/esm/actions/public/getLogs.js.map +1 -1
- package/dist/esm/actions/public/getStorageAt.js +24 -0
- package/dist/esm/actions/public/getStorageAt.js.map +1 -1
- package/dist/esm/actions/public/getTransaction.js +24 -0
- package/dist/esm/actions/public/getTransaction.js.map +1 -1
- package/dist/esm/actions/public/getTransactionConfirmations.js +24 -0
- package/dist/esm/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/esm/actions/public/getTransactionCount.js +23 -0
- package/dist/esm/actions/public/getTransactionCount.js.map +1 -1
- package/dist/esm/actions/public/getTransactionReceipt.js +24 -0
- package/dist/esm/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/multicall.js +40 -0
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/actions/public/readContract.js +31 -0
- package/dist/esm/actions/public/readContract.js.map +1 -1
- package/dist/esm/actions/public/simulateContract.js +31 -0
- package/dist/esm/actions/public/simulateContract.js.map +1 -1
- package/dist/esm/actions/public/uninstallFilter.js +24 -0
- package/dist/esm/actions/public/uninstallFilter.js.map +1 -1
- package/dist/esm/actions/public/verifyHash.js +10 -0
- package/dist/esm/actions/public/verifyHash.js.map +1 -1
- package/dist/esm/actions/public/verifyMessage.js +11 -0
- package/dist/esm/actions/public/verifyMessage.js.map +1 -1
- package/dist/esm/actions/public/verifyTypedData.js +16 -2
- package/dist/esm/actions/public/verifyTypedData.js.map +1 -1
- package/dist/esm/actions/public/waitForTransactionReceipt.js +52 -0
- package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js +31 -0
- package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js +35 -1
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +39 -1
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +41 -1
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/public/watchPendingTransactions.js +29 -0
- package/dist/esm/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/esm/actions/test/dropTransaction.js +22 -0
- package/dist/esm/actions/test/dropTransaction.js.map +1 -1
- package/dist/esm/actions/test/getAutomine.js +24 -0
- package/dist/esm/actions/test/getAutomine.js.map +1 -1
- package/dist/esm/actions/test/getTxpoolContent.js +20 -0
- package/dist/esm/actions/test/getTxpoolContent.js.map +1 -1
- package/dist/esm/actions/test/getTxpoolStatus.js +20 -0
- package/dist/esm/actions/test/getTxpoolStatus.js.map +1 -1
- package/dist/esm/actions/test/impersonateAccount.js +22 -0
- package/dist/esm/actions/test/impersonateAccount.js.map +1 -1
- package/dist/esm/actions/test/increaseTime.js +22 -0
- package/dist/esm/actions/test/increaseTime.js.map +1 -1
- package/dist/esm/actions/test/inspectTxpool.js +20 -0
- package/dist/esm/actions/test/inspectTxpool.js.map +1 -1
- package/dist/esm/actions/test/mine.js +30 -4
- package/dist/esm/actions/test/mine.js.map +1 -1
- package/dist/esm/actions/test/removeBlockTimestampInterval.js +19 -0
- package/dist/esm/actions/test/removeBlockTimestampInterval.js.map +1 -1
- package/dist/esm/actions/test/reset.js +20 -0
- package/dist/esm/actions/test/reset.js.map +1 -1
- package/dist/esm/actions/test/revert.js +20 -0
- package/dist/esm/actions/test/revert.js.map +1 -1
- package/dist/esm/actions/test/sendUnsignedTransaction.js +48 -4
- package/dist/esm/actions/test/sendUnsignedTransaction.js.map +1 -1
- package/dist/esm/actions/test/setAutomine.js +30 -4
- package/dist/esm/actions/test/setAutomine.js.map +1 -1
- package/dist/esm/actions/test/setBalance.js +33 -4
- package/dist/esm/actions/test/setBalance.js.map +1 -1
- package/dist/esm/actions/test/setBlockGasLimit.js +20 -0
- package/dist/esm/actions/test/setBlockGasLimit.js.map +1 -1
- package/dist/esm/actions/test/setBlockTimestampInterval.js +20 -0
- package/dist/esm/actions/test/setBlockTimestampInterval.js.map +1 -1
- package/dist/esm/actions/test/setCode.js +23 -0
- package/dist/esm/actions/test/setCode.js.map +1 -1
- package/dist/esm/actions/test/setCoinbase.js +22 -0
- package/dist/esm/actions/test/setCoinbase.js.map +1 -1
- package/dist/esm/actions/test/setIntervalMining.js +20 -0
- package/dist/esm/actions/test/setIntervalMining.js.map +1 -1
- package/dist/esm/actions/test/setLoggingEnabled.js +19 -0
- package/dist/esm/actions/test/setLoggingEnabled.js.map +1 -1
- package/dist/esm/actions/test/setMinGasPrice.js +24 -0
- package/dist/esm/actions/test/setMinGasPrice.js.map +1 -1
- package/dist/esm/actions/test/setNextBlockBaseFeePerGas.js +22 -0
- package/dist/esm/actions/test/setNextBlockBaseFeePerGas.js.map +1 -1
- package/dist/esm/actions/test/setNextBlockTimestamp.js +20 -0
- package/dist/esm/actions/test/setNextBlockTimestamp.js.map +1 -1
- package/dist/esm/actions/test/setNonce.js +23 -0
- package/dist/esm/actions/test/setNonce.js.map +1 -1
- package/dist/esm/actions/test/setRpcUrl.js +20 -0
- package/dist/esm/actions/test/setRpcUrl.js.map +1 -1
- package/dist/esm/actions/test/setStorageAt.js +24 -0
- package/dist/esm/actions/test/setStorageAt.js.map +1 -1
- package/dist/esm/actions/test/snapshot.js +19 -0
- package/dist/esm/actions/test/snapshot.js.map +1 -1
- package/dist/esm/actions/test/stopImpersonatingAccount.js +22 -0
- package/dist/esm/actions/test/stopImpersonatingAccount.js.map +1 -1
- package/dist/esm/actions/wallet/addChain.js +19 -0
- package/dist/esm/actions/wallet/addChain.js.map +1 -1
- package/dist/esm/actions/wallet/deployContract.js +27 -0
- package/dist/esm/actions/wallet/deployContract.js.map +1 -1
- package/dist/esm/actions/wallet/getAddresses.js +20 -0
- package/dist/esm/actions/wallet/getAddresses.js.map +1 -1
- package/dist/esm/actions/wallet/getPermissions.js +20 -0
- package/dist/esm/actions/wallet/getPermissions.js.map +1 -1
- package/dist/esm/actions/wallet/requestAddresses.js +24 -0
- package/dist/esm/actions/wallet/requestAddresses.js.map +1 -1
- package/dist/esm/actions/wallet/requestPermissions.js +23 -0
- package/dist/esm/actions/wallet/requestPermissions.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js +48 -1
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/signMessage.js +55 -2
- package/dist/esm/actions/wallet/signMessage.js.map +1 -1
- package/dist/esm/actions/wallet/signTypedData.js +100 -0
- package/dist/esm/actions/wallet/signTypedData.js.map +1 -1
- package/dist/esm/actions/wallet/switchChain.js +20 -0
- package/dist/esm/actions/wallet/switchChain.js.map +1 -1
- package/dist/esm/actions/wallet/watchAsset.js +28 -0
- package/dist/esm/actions/wallet/watchAsset.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js +50 -0
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/chains.js +99 -87
- package/dist/esm/chains.js.map +1 -1
- package/dist/esm/clients/createClient.js +4 -1
- package/dist/esm/clients/createClient.js.map +1 -1
- package/dist/esm/clients/createPublicClient.js +19 -0
- package/dist/esm/clients/createPublicClient.js.map +1 -1
- package/dist/esm/clients/createTestClient.js +23 -0
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/createWalletClient.js +36 -0
- package/dist/esm/clients/createWalletClient.js.map +1 -1
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/clients/decorators/test.js.map +1 -1
- package/dist/esm/clients/transports/createTransport.js +3 -0
- package/dist/esm/clients/transports/createTransport.js.map +1 -1
- package/dist/esm/clients/transports/custom.js +3 -0
- package/dist/esm/clients/transports/custom.js.map +1 -1
- package/dist/esm/clients/transports/fallback.js +11 -0
- package/dist/esm/clients/transports/fallback.js.map +1 -1
- package/dist/esm/clients/transports/http.js +31 -8
- package/dist/esm/clients/transports/http.js.map +1 -1
- package/dist/esm/clients/transports/webSocket.js +28 -15
- package/dist/esm/clients/transports/webSocket.js.map +1 -1
- package/dist/esm/constants/abis.js +6 -0
- package/dist/esm/constants/abis.js.map +1 -1
- package/dist/esm/constants/solidity.js +1 -0
- package/dist/esm/constants/solidity.js.map +1 -1
- package/dist/esm/contract.js +0 -1
- package/dist/esm/contract.js.map +1 -1
- package/dist/esm/errors/abi.js +15 -1
- package/dist/esm/errors/abi.js.map +1 -1
- package/dist/esm/errors/base.js +4 -11
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/node.js +9 -0
- package/dist/esm/errors/node.js.map +1 -1
- package/dist/esm/errors/request.js.map +1 -1
- package/dist/esm/errors/rpc.js +103 -0
- package/dist/esm/errors/rpc.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/errors/version.js.map +1 -1
- package/dist/esm/index.js +2 -52
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/types/account.js +1 -1
- package/dist/esm/types/account.js.map +1 -1
- package/dist/esm/types/eip1193.js +2 -0
- package/dist/esm/types/eip1193.js.map +1 -1
- package/dist/esm/utils/abi/decodeAbiParameters.js +29 -0
- package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/decodeEventLog.js +35 -19
- package/dist/esm/utils/abi/decodeEventLog.js.map +1 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js +10 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/encodeEventTopics.js +11 -7
- package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
- package/dist/esm/utils/abi/getAbiItem.js +9 -0
- package/dist/esm/utils/abi/getAbiItem.js.map +1 -1
- package/dist/esm/utils/accounts.js +3 -0
- package/dist/esm/utils/accounts.js.map +1 -1
- package/dist/esm/utils/buildRequest.js +2 -0
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/data/size.js +6 -0
- package/dist/esm/utils/data/size.js.map +1 -1
- package/dist/esm/utils/data/slice.js +21 -0
- package/dist/esm/utils/data/slice.js.map +1 -1
- package/dist/esm/utils/encoding/fromBytes.js +79 -0
- package/dist/esm/utils/encoding/fromBytes.js.map +1 -1
- package/dist/esm/utils/encoding/fromHex.js +106 -0
- package/dist/esm/utils/encoding/fromHex.js.map +1 -1
- package/dist/esm/utils/encoding/toBytes.js +102 -1
- package/dist/esm/utils/encoding/toBytes.js.map +1 -1
- package/dist/esm/utils/encoding/toHex.js +108 -2
- package/dist/esm/utils/encoding/toHex.js.map +1 -1
- package/dist/esm/utils/ens/avatar/parseAvatarRecord.js +6 -2
- package/dist/esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/dist/esm/utils/ens/avatar/utils.js +10 -0
- package/dist/esm/utils/ens/avatar/utils.js.map +1 -1
- package/dist/esm/utils/ens/encodeLabelhash.js +4 -0
- package/dist/esm/utils/ens/encodeLabelhash.js.map +1 -0
- package/dist/esm/utils/ens/encodedLabelToLabelhash.js +14 -0
- package/dist/esm/utils/ens/encodedLabelToLabelhash.js.map +1 -0
- package/dist/esm/utils/ens/labelhash.js +11 -1
- package/dist/esm/utils/ens/labelhash.js.map +1 -1
- package/dist/esm/utils/ens/namehash.js +18 -2
- package/dist/esm/utils/ens/namehash.js.map +1 -1
- package/dist/esm/utils/ens/normalize.js +10 -0
- package/dist/esm/utils/ens/normalize.js.map +1 -1
- package/dist/esm/utils/ens/packetToBytes.js +16 -9
- package/dist/esm/utils/ens/packetToBytes.js.map +1 -1
- package/dist/esm/utils/filters/createFilterRequestScope.js +5 -0
- package/dist/esm/utils/filters/createFilterRequestScope.js.map +1 -1
- package/dist/esm/utils/formatters/block.js +4 -1
- package/dist/esm/utils/formatters/block.js.map +1 -1
- package/dist/esm/utils/formatters/extract.js +3 -0
- package/dist/esm/utils/formatters/extract.js.map +1 -1
- package/dist/esm/utils/formatters/format.js +3 -0
- package/dist/esm/utils/formatters/format.js.map +1 -1
- package/dist/esm/utils/formatters/log.js +2 -2
- package/dist/esm/utils/formatters/transaction.js +3 -1
- package/dist/esm/utils/formatters/transaction.js.map +1 -1
- package/dist/esm/utils/formatters/transactionReceipt.js +2 -2
- package/dist/esm/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/esm/utils/formatters/transactionRequest.js +1 -1
- package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/esm/utils/hash/getEventSelector.js +6 -2
- package/dist/esm/utils/hash/getEventSelector.js.map +1 -1
- package/dist/esm/utils/hash/getFunctionSelector.js +6 -2
- package/dist/esm/utils/hash/getFunctionSelector.js.map +1 -1
- package/dist/esm/utils/hash/hashFunction.js +4 -3
- package/dist/esm/utils/hash/hashFunction.js.map +1 -1
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/observe.js +7 -2
- package/dist/esm/utils/observe.js.map +1 -1
- package/dist/esm/utils/poll.js +3 -0
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/esm/utils/promise/createBatchScheduler.js +1 -1
- package/dist/esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/dist/esm/utils/promise/withCache.js +23 -6
- package/dist/esm/utils/promise/withCache.js.map +1 -1
- package/dist/esm/utils/regex.js +4 -0
- package/dist/esm/utils/regex.js.map +1 -1
- package/dist/esm/utils/rpc.js +27 -19
- package/dist/esm/utils/rpc.js.map +1 -1
- package/dist/esm/utils/signature/hashMessage.js +8 -2
- package/dist/esm/utils/signature/hashMessage.js.map +1 -1
- package/dist/esm/utils/signature/hashTypedData.js +3 -0
- package/dist/esm/utils/signature/hashTypedData.js.map +1 -1
- package/dist/esm/utils/signature/recoverPublicKey.js +2 -0
- package/dist/esm/utils/signature/recoverPublicKey.js.map +1 -1
- package/dist/esm/utils/signature/verifyMessage.js +12 -0
- package/dist/esm/utils/signature/verifyMessage.js.map +1 -1
- package/dist/esm/utils/signature/verifyTypedData.js +12 -0
- package/dist/esm/utils/signature/verifyTypedData.js.map +1 -1
- package/dist/esm/utils/transaction/getTransactionType.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js +5 -1
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/utils/transaction/serializeTransaction.js +4 -2
- package/dist/esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/dist/esm/utils/typedData.js +4 -0
- package/dist/esm/utils/typedData.js.map +1 -1
- package/dist/esm/utils/unit/parseUnits.js +15 -3
- package/dist/esm/utils/unit/parseUnits.js.map +1 -1
- package/dist/types/accounts/types.d.ts +3 -5
- package/dist/types/accounts/types.d.ts.map +1 -1
- package/dist/types/accounts/utils/signMessage.d.ts +2 -2
- package/dist/types/accounts/utils/signMessage.d.ts.map +1 -1
- package/dist/types/accounts/utils/signTypedData.d.ts +3 -6
- package/dist/types/accounts/utils/signTypedData.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/getContract.d.ts +65 -21
- package/dist/types/actions/getContract.d.ts.map +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +8 -3
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +17 -5
- package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +4 -2
- package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/dist/types/actions/public/getBlockNumber.d.ts +2 -2
- package/dist/types/actions/public/getBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/getChainId.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts +4 -4
- package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts +4 -4
- package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts +10 -4
- package/dist/types/actions/public/getLogs.d.ts.map +1 -1
- package/dist/types/actions/public/verifyMessage.d.ts +2 -2
- package/dist/types/actions/public/verifyMessage.d.ts.map +1 -1
- package/dist/types/actions/public/verifyTypedData.d.ts +3 -4
- package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +10 -5
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +11 -5
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/test/getAutomine.d.ts.map +1 -1
- package/dist/types/actions/test/mine.d.ts.map +1 -1
- package/dist/types/actions/test/sendUnsignedTransaction.d.ts +8 -2
- package/dist/types/actions/test/sendUnsignedTransaction.d.ts.map +1 -1
- package/dist/types/actions/test/setAutomine.d.ts.map +1 -1
- package/dist/types/actions/test/setBalance.d.ts.map +1 -1
- package/dist/types/actions/wallet/signMessage.d.ts +2 -2
- package/dist/types/actions/wallet/signMessage.d.ts.map +1 -1
- package/dist/types/actions/wallet/signTypedData.d.ts +4 -7
- package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
- package/dist/types/chains.d.ts +364 -16
- package/dist/types/chains.d.ts.map +1 -1
- package/dist/types/clients/createClient.d.ts +5 -5
- package/dist/types/clients/createClient.d.ts.map +1 -1
- package/dist/types/clients/createPublicClient.d.ts +3 -3
- package/dist/types/clients/createPublicClient.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +2 -2
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/createWalletClient.d.ts +2 -2
- package/dist/types/clients/createWalletClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +8 -8
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/test.d.ts +1 -1
- package/dist/types/clients/decorators/test.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +1 -3
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/clients/transports/createTransport.d.ts +5 -8
- package/dist/types/clients/transports/createTransport.d.ts.map +1 -1
- package/dist/types/clients/transports/custom.d.ts +2 -2
- package/dist/types/clients/transports/custom.d.ts.map +1 -1
- package/dist/types/clients/transports/http.d.ts +11 -0
- package/dist/types/clients/transports/http.d.ts.map +1 -1
- package/dist/types/clients/transports/webSocket.d.ts.map +1 -1
- package/dist/types/contract.d.ts +1 -1
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/errors/abi.d.ts +6 -4
- package/dist/types/errors/abi.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +0 -1
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/request.d.ts +16 -8
- package/dist/types/errors/request.d.ts.map +1 -1
- package/dist/types/errors/rpc.d.ts +2 -2
- package/dist/types/errors/rpc.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/errors/version.d.ts.map +1 -1
- package/dist/types/index.d.ts +55 -53
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/account.d.ts +1 -1
- package/dist/types/types/account.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +11 -6
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/eip1193.d.ts +1042 -827
- package/dist/types/types/eip1193.d.ts.map +1 -1
- package/dist/types/types/filter.d.ts +12 -3
- package/dist/types/types/filter.d.ts.map +1 -1
- package/dist/types/types/log.d.ts +5 -3
- package/dist/types/types/log.d.ts.map +1 -1
- package/dist/types/types/misc.d.ts +4 -0
- package/dist/types/types/misc.d.ts.map +1 -1
- package/dist/types/types/rpc.d.ts +1 -1
- package/dist/types/types/rpc.d.ts.map +1 -1
- package/dist/types/types/transaction.d.ts +14 -5
- package/dist/types/types/transaction.d.ts.map +1 -1
- package/dist/types/types/typedData.d.ts +17 -29
- package/dist/types/types/typedData.d.ts.map +1 -1
- package/dist/types/types/utils.d.ts +11 -0
- package/dist/types/types/utils.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeEventLog.d.ts +6 -5
- package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
- package/dist/types/utils/abi/getAbiItem.d.ts.map +1 -1
- package/dist/types/utils/ens/encodeLabelhash.d.ts +3 -0
- package/dist/types/utils/ens/encodeLabelhash.d.ts.map +1 -0
- package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts +3 -0
- package/dist/types/utils/ens/encodedLabelToLabelhash.d.ts.map +1 -0
- package/dist/types/utils/ens/labelhash.d.ts.map +1 -1
- package/dist/types/utils/ens/namehash.d.ts.map +1 -1
- package/dist/types/utils/ens/packetToBytes.d.ts.map +1 -1
- package/dist/types/utils/filters/createFilterRequestScope.d.ts +6 -2
- package/dist/types/utils/filters/createFilterRequestScope.d.ts.map +1 -1
- package/dist/types/utils/formatters/block.d.ts.map +1 -1
- package/dist/types/utils/formatters/transaction.d.ts +1 -1
- package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
- package/dist/types/utils/hash/getEventSelector.d.ts +2 -1
- package/dist/types/utils/hash/getEventSelector.d.ts.map +1 -1
- package/dist/types/utils/hash/getFunctionSelector.d.ts +2 -1
- package/dist/types/utils/hash/getFunctionSelector.d.ts.map +1 -1
- package/dist/types/utils/hash/hashFunction.d.ts +2 -0
- package/dist/types/utils/hash/hashFunction.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/observe.d.ts.map +1 -1
- package/dist/types/utils/promise/withCache.d.ts.map +1 -1
- package/dist/types/utils/rpc.d.ts +18 -10
- package/dist/types/utils/rpc.d.ts.map +1 -1
- package/dist/types/utils/signature/hashMessage.d.ts +2 -2
- package/dist/types/utils/signature/hashMessage.d.ts.map +1 -1
- package/dist/types/utils/signature/hashTypedData.d.ts +3 -6
- package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverMessageAddress.d.ts +2 -2
- package/dist/types/utils/signature/recoverMessageAddress.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +3 -6
- package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
- package/dist/types/utils/signature/verifyTypedData.d.ts +3 -6
- package/dist/types/utils/signature/verifyTypedData.d.ts.map +1 -1
- package/dist/types/utils/transaction/getTransactionType.d.ts +2 -2
- package/dist/types/utils/transaction/getTransactionType.d.ts.map +1 -1
- package/dist/types/utils/typedData.d.ts +2 -3
- package/dist/types/utils/typedData.d.ts.map +1 -1
- package/dist/types/utils/unit/parseUnits.d.ts.map +1 -1
- package/package.json +7 -13
- package/src/accounts/types.ts +4 -4
- package/src/accounts/utils/signMessage.ts +2 -2
- package/src/accounts/utils/signTypedData.ts +4 -4
- package/src/actions/ens/getEnsAddress.ts +37 -22
- package/src/actions/getContract.ts +133 -69
- package/src/actions/public/call.ts +1 -1
- package/src/actions/public/createContractEventFilter.ts +21 -4
- package/src/actions/public/createEventFilter.ts +34 -13
- package/src/actions/public/estimateContractGas.ts +10 -4
- package/src/actions/public/estimateGas.ts +1 -1
- package/src/actions/public/getBlock.ts +2 -2
- package/src/actions/public/getBlockTransactionCount.ts +1 -1
- package/src/actions/public/getChainId.ts +3 -1
- package/src/actions/public/getFilterChanges.ts +32 -7
- package/src/actions/public/getFilterLogs.ts +34 -8
- package/src/actions/public/getGasPrice.ts +1 -1
- package/src/actions/public/getLogs.ts +39 -10
- package/src/actions/public/getTransactionCount.ts +1 -1
- package/src/actions/public/verifyMessage.ts +2 -2
- package/src/actions/public/verifyTypedData.ts +18 -6
- package/src/actions/public/watchContractEvent.ts +16 -4
- package/src/actions/public/watchEvent.ts +17 -4
- package/src/actions/test/getAutomine.ts +4 -0
- package/src/actions/test/mine.ts +10 -4
- package/src/actions/test/sendUnsignedTransaction.ts +54 -5
- package/src/actions/test/setAutomine.ts +8 -4
- package/src/actions/test/setBalance.ts +10 -4
- package/src/actions/wallet/sendTransaction.ts +1 -1
- package/src/actions/wallet/signMessage.ts +11 -4
- package/src/actions/wallet/signTypedData.ts +5 -5
- package/src/chains.ts +123 -88
- package/src/clients/createClient.ts +13 -11
- package/src/clients/createPublicClient.ts +3 -4
- package/src/clients/createTestClient.ts +2 -3
- package/src/clients/createWalletClient.ts +2 -3
- package/src/clients/decorators/public.ts +43 -17
- package/src/clients/decorators/test.ts +4 -3
- package/src/clients/decorators/wallet.ts +2 -2
- package/src/clients/transports/createTransport.ts +5 -9
- package/src/clients/transports/custom.ts +1 -2
- package/src/clients/transports/fallback.ts +1 -1
- package/src/clients/transports/http.ts +44 -7
- package/src/clients/transports/webSocket.ts +23 -15
- package/src/contract.ts +3 -3
- package/src/errors/abi.ts +16 -4
- package/src/errors/base.ts +6 -6
- package/src/errors/request.ts +4 -4
- package/src/errors/rpc.ts +3 -2
- package/src/errors/version.ts +1 -1
- package/src/index.ts +263 -249
- package/src/types/account.ts +9 -9
- package/src/types/contract.ts +33 -15
- package/src/types/eip1193.ts +1084 -827
- package/src/types/filter.ts +15 -3
- package/src/types/log.ts +13 -3
- package/src/types/misc.ts +6 -0
- package/src/types/rpc.ts +1 -1
- package/src/types/transaction.ts +24 -6
- package/src/types/typedData.ts +36 -45
- package/src/types/utils.ts +15 -0
- package/src/utils/abi/decodeEventLog.ts +47 -22
- package/src/utils/abi/encodeEventTopics.ts +16 -11
- package/src/utils/abi/getAbiItem.ts +1 -0
- package/src/utils/encoding/toBytes.ts +1 -1
- package/src/utils/encoding/toHex.ts +2 -2
- package/src/utils/ens/encodeLabelhash.ts +5 -0
- package/src/utils/ens/encodedLabelToLabelhash.ts +11 -0
- package/src/utils/ens/labelhash.ts +2 -1
- package/src/utils/ens/namehash.ts +6 -2
- package/src/utils/ens/packetToBytes.ts +12 -8
- package/src/utils/filters/createFilterRequestScope.ts +12 -4
- package/src/utils/formatters/block.ts +3 -1
- package/src/utils/formatters/log.ts +2 -2
- package/src/utils/formatters/transaction.ts +3 -1
- package/src/utils/formatters/transactionReceipt.ts +4 -2
- package/src/utils/formatters/transactionRequest.ts +1 -1
- package/src/utils/hash/getEventSelector.ts +6 -2
- package/src/utils/hash/getFunctionSelector.ts +6 -2
- package/src/utils/hash/hashFunction.ts +6 -2
- package/src/utils/index.ts +6 -0
- package/src/utils/observe.ts +2 -2
- package/src/utils/promise/createBatchScheduler.ts +1 -1
- package/src/utils/promise/withCache.ts +13 -11
- package/src/utils/rpc.ts +53 -53
- package/src/utils/signature/hashMessage.ts +8 -4
- package/src/utils/signature/hashTypedData.ts +4 -4
- package/src/utils/signature/recoverMessageAddress.ts +2 -2
- package/src/utils/signature/recoverTypedDataAddress.ts +4 -4
- package/src/utils/signature/verifyTypedData.ts +4 -4
- package/src/utils/transaction/getTransactionType.ts +10 -9
- package/src/utils/transaction/serializeTransaction.ts +3 -3
- package/src/utils/typedData.ts +3 -3
- package/src/utils/unit/parseUnits.ts +15 -5
- package/dist/cjs/adapters/ethers.js +0 -49
- package/dist/cjs/adapters/ethers.js.map +0 -1
- package/dist/cjs/ethers.js +0 -6
- package/dist/cjs/ethers.js.map +0 -1
- package/dist/esm/adapters/ethers.js +0 -45
- package/dist/esm/adapters/ethers.js.map +0 -1
- package/dist/esm/ethers.js +0 -2
- package/dist/esm/ethers.js.map +0 -1
- package/dist/types/adapters/ethers.d.ts +0 -27
- package/dist/types/adapters/ethers.d.ts.map +0 -1
- package/dist/types/ethers.d.ts +0 -2
- package/dist/types/ethers.d.ts.map +0 -1
- package/ethers/package.json +0 -5
- package/src/adapters/ethers.ts +0 -94
- package/src/ethers.ts +0 -1
@@ -68,11 +68,12 @@ export type GetContractParameters<
|
|
68
68
|
TWalletClient extends
|
69
69
|
| WalletClient<TTransport, TChain, TAccount>
|
70
70
|
| unknown = unknown,
|
71
|
+
TAddress extends Address = Address,
|
71
72
|
> = {
|
72
73
|
/** Contract ABI */
|
73
74
|
abi: Narrow<TAbi>
|
74
75
|
/** Contract address */
|
75
|
-
address:
|
76
|
+
address: TAddress
|
76
77
|
/**
|
77
78
|
* Public client
|
78
79
|
*
|
@@ -90,6 +91,7 @@ export type GetContractParameters<
|
|
90
91
|
*
|
91
92
|
* If you pass in a [`walletClient`](https://viem.sh/docs/clients/wallet.html), the following methods are available:
|
92
93
|
*
|
94
|
+
* - [`estimateGas`](https://viem.sh/docs/contract/estimateContractGas.html)
|
93
95
|
* - [`write`](https://viem.sh/docs/contract/writeContract.html)
|
94
96
|
*/
|
95
97
|
walletClient?: TWalletClient
|
@@ -99,6 +101,7 @@ export type GetContractReturnType<
|
|
99
101
|
TAbi extends Abi | readonly unknown[] = Abi,
|
100
102
|
TPublicClient extends PublicClient | unknown = unknown,
|
101
103
|
TWalletClient extends WalletClient | unknown = unknown,
|
104
|
+
TAddress extends Address = Address,
|
102
105
|
_EventNames extends string = TAbi extends Abi
|
103
106
|
? Abi extends TAbi
|
104
107
|
? string
|
@@ -163,7 +166,7 @@ export type GetContractReturnType<
|
|
163
166
|
* import { createPublicClient, getContract, http, parseAbi } from 'viem'
|
164
167
|
* import { mainnet } from 'viem/chains'
|
165
168
|
*
|
166
|
-
* const
|
169
|
+
* const publicClient = createPublicClient({
|
167
170
|
* chain: mainnet,
|
168
171
|
* transport: http(),
|
169
172
|
* })
|
@@ -179,9 +182,8 @@ export type GetContractReturnType<
|
|
179
182
|
estimateGas: {
|
180
183
|
[FunctionName in _WriteFunctionNames]: GetEstimateFunction<
|
181
184
|
_Narrowable,
|
182
|
-
TPublicClient
|
183
|
-
|
184
|
-
: undefined,
|
185
|
+
TPublicClient['chain'],
|
186
|
+
undefined,
|
185
187
|
TAbi,
|
186
188
|
FunctionName
|
187
189
|
>
|
@@ -197,7 +199,7 @@ export type GetContractReturnType<
|
|
197
199
|
* import { createPublicClient, getContract, http, parseAbi } from 'viem'
|
198
200
|
* import { mainnet } from 'viem/chains'
|
199
201
|
*
|
200
|
-
* const
|
202
|
+
* const publicClient = createPublicClient({
|
201
203
|
* chain: mainnet,
|
202
204
|
* transport: http(),
|
203
205
|
* })
|
@@ -213,9 +215,7 @@ export type GetContractReturnType<
|
|
213
215
|
simulate: {
|
214
216
|
[FunctionName in _WriteFunctionNames]: GetSimulateFunction<
|
215
217
|
_Narrowable,
|
216
|
-
TPublicClient
|
217
|
-
? TPublicClient['chain']
|
218
|
-
: undefined,
|
218
|
+
TPublicClient['chain'],
|
219
219
|
TAbi,
|
220
220
|
FunctionName
|
221
221
|
>
|
@@ -231,7 +231,7 @@ export type GetContractReturnType<
|
|
231
231
|
* import { createPublicClient, getContract, http, parseAbi } from 'viem'
|
232
232
|
* import { mainnet } from 'viem/chains'
|
233
233
|
*
|
234
|
-
* const
|
234
|
+
* const publicClient = createPublicClient({
|
235
235
|
* chain: mainnet,
|
236
236
|
* transport: http(),
|
237
237
|
* })
|
@@ -260,7 +260,7 @@ export type GetContractReturnType<
|
|
260
260
|
* import { createPublicClient, getContract, http, parseAbi } from 'viem'
|
261
261
|
* import { mainnet } from 'viem/chains'
|
262
262
|
*
|
263
|
-
* const
|
263
|
+
* const publicClient = createPublicClient({
|
264
264
|
* chain: mainnet,
|
265
265
|
* transport: http(),
|
266
266
|
* })
|
@@ -288,6 +288,35 @@ export type GetContractReturnType<
|
|
288
288
|
? IsNever<_WriteFunctionNames> extends true
|
289
289
|
? unknown
|
290
290
|
: {
|
291
|
+
/**
|
292
|
+
* Estimates the gas necessary to complete a transaction without submitting it to the network.
|
293
|
+
*
|
294
|
+
* @example
|
295
|
+
* import { createWalletClient, getContract, http, parseAbi } from 'viem'
|
296
|
+
* import { mainnet } from 'viem/chains'
|
297
|
+
*
|
298
|
+
* const walletClient = createWalletClient({
|
299
|
+
* chain: mainnet,
|
300
|
+
* transport: http(),
|
301
|
+
* })
|
302
|
+
* const contract = getContract({
|
303
|
+
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
304
|
+
* abi: parseAbi(['function mint() public']),
|
305
|
+
* walletClient,
|
306
|
+
* })
|
307
|
+
* const gas = await contract.estimateGas.mint({
|
308
|
+
* account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
|
309
|
+
* })
|
310
|
+
*/
|
311
|
+
estimateGas: {
|
312
|
+
[FunctionName in _WriteFunctionNames]: GetEstimateFunction<
|
313
|
+
_Narrowable,
|
314
|
+
TWalletClient['chain'],
|
315
|
+
TWalletClient['account'],
|
316
|
+
TAbi,
|
317
|
+
FunctionName
|
318
|
+
>
|
319
|
+
}
|
291
320
|
/**
|
292
321
|
* Executes a write function on a contract.
|
293
322
|
*
|
@@ -301,14 +330,14 @@ export type GetContractReturnType<
|
|
301
330
|
* import { createWalletClient, getContract, http, parseAbi } from 'viem'
|
302
331
|
* import { mainnet } from 'viem/chains'
|
303
332
|
*
|
304
|
-
* const
|
333
|
+
* const walletClient = createWalletClient({
|
305
334
|
* chain: mainnet,
|
306
335
|
* transport: http(),
|
307
336
|
* })
|
308
337
|
* const contract = getContract({
|
309
338
|
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
310
339
|
* abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
|
311
|
-
*
|
340
|
+
* walletClient,
|
312
341
|
* })
|
313
342
|
* const hash = await contract.write.min([69420], {
|
314
343
|
* address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
|
@@ -317,19 +346,15 @@ export type GetContractReturnType<
|
|
317
346
|
write: {
|
318
347
|
[FunctionName in _WriteFunctionNames]: GetWriteFunction<
|
319
348
|
_Narrowable,
|
320
|
-
TWalletClient
|
321
|
-
|
322
|
-
: undefined,
|
323
|
-
TWalletClient extends WalletClient
|
324
|
-
? TWalletClient['account']
|
325
|
-
: undefined,
|
349
|
+
TWalletClient['chain'],
|
350
|
+
TWalletClient['account'],
|
326
351
|
TAbi,
|
327
352
|
FunctionName
|
328
353
|
>
|
329
354
|
}
|
330
355
|
}
|
331
356
|
: unknown)
|
332
|
-
>
|
357
|
+
> & { address: TAddress; abi: TAbi }
|
333
358
|
|
334
359
|
/**
|
335
360
|
* Gets type-safe interface for performing contract-related actions with a specific `abi` and `address`.
|
@@ -358,6 +383,7 @@ export type GetContractReturnType<
|
|
358
383
|
*/
|
359
384
|
export function getContract<
|
360
385
|
TTransport extends Transport,
|
386
|
+
TAddress extends Address,
|
361
387
|
TAbi extends Abi | readonly unknown[],
|
362
388
|
TChain extends Chain | undefined = Chain | undefined,
|
363
389
|
TAccount extends Account | undefined = Account | undefined,
|
@@ -378,13 +404,16 @@ export function getContract<
|
|
378
404
|
TAccount,
|
379
405
|
TAbi,
|
380
406
|
TPublicClient,
|
381
|
-
TWalletClient
|
382
|
-
|
407
|
+
TWalletClient,
|
408
|
+
TAddress
|
409
|
+
>): GetContractReturnType<TAbi, TPublicClient, TWalletClient, TAddress> {
|
383
410
|
const hasPublicClient = publicClient !== undefined && publicClient !== null
|
384
411
|
const hasWalletClient = walletClient !== undefined && walletClient !== null
|
385
412
|
|
386
413
|
const contract: {
|
387
414
|
[_ in
|
415
|
+
| 'abi'
|
416
|
+
| 'address'
|
388
417
|
| 'createEventFilter'
|
389
418
|
| 'estimateGas'
|
390
419
|
| 'read'
|
@@ -434,32 +463,7 @@ export function getContract<
|
|
434
463
|
},
|
435
464
|
)
|
436
465
|
|
437
|
-
if (hasWriteFunction)
|
438
|
-
contract.estimateGas = new Proxy(
|
439
|
-
{},
|
440
|
-
{
|
441
|
-
get(_, functionName: string) {
|
442
|
-
return (
|
443
|
-
...parameters: [
|
444
|
-
args?: readonly unknown[],
|
445
|
-
options?: Omit<
|
446
|
-
EstimateContractGasParameters,
|
447
|
-
'abi' | 'address' | 'functionName' | 'args'
|
448
|
-
>,
|
449
|
-
]
|
450
|
-
) => {
|
451
|
-
const { args, options } = getFunctionParameters(parameters)
|
452
|
-
return estimateContractGas(publicClient, {
|
453
|
-
abi,
|
454
|
-
address,
|
455
|
-
functionName,
|
456
|
-
args,
|
457
|
-
...options,
|
458
|
-
} as EstimateContractGasParameters)
|
459
|
-
}
|
460
|
-
},
|
461
|
-
},
|
462
|
-
)
|
466
|
+
if (hasWriteFunction)
|
463
467
|
contract.simulate = new Proxy(
|
464
468
|
{},
|
465
469
|
{
|
@@ -485,7 +489,6 @@ export function getContract<
|
|
485
489
|
},
|
486
490
|
},
|
487
491
|
)
|
488
|
-
}
|
489
492
|
|
490
493
|
if (hasEvent) {
|
491
494
|
contract.createEventFilter = new Proxy(
|
@@ -545,7 +548,7 @@ export function getContract<
|
|
545
548
|
eventName,
|
546
549
|
args,
|
547
550
|
...options,
|
548
|
-
} as WatchContractEventParameters)
|
551
|
+
} as unknown as WatchContractEventParameters)
|
549
552
|
}
|
550
553
|
},
|
551
554
|
},
|
@@ -587,10 +590,45 @@ export function getContract<
|
|
587
590
|
)
|
588
591
|
}
|
589
592
|
|
593
|
+
if (hasPublicClient || hasWalletClient)
|
594
|
+
if (hasWriteFunction)
|
595
|
+
contract.estimateGas = new Proxy(
|
596
|
+
{},
|
597
|
+
{
|
598
|
+
get(_, functionName: string) {
|
599
|
+
return (
|
600
|
+
...parameters: [
|
601
|
+
args?: readonly unknown[],
|
602
|
+
options?: Omit<
|
603
|
+
EstimateContractGasParameters,
|
604
|
+
'abi' | 'address' | 'functionName' | 'args'
|
605
|
+
>,
|
606
|
+
]
|
607
|
+
) => {
|
608
|
+
const { args, options } = getFunctionParameters(parameters)
|
609
|
+
const client = (publicClient ?? walletClient)!
|
610
|
+
return estimateContractGas(client, {
|
611
|
+
abi,
|
612
|
+
address,
|
613
|
+
functionName,
|
614
|
+
args,
|
615
|
+
...options,
|
616
|
+
account:
|
617
|
+
(options as EstimateContractGasParameters).account ??
|
618
|
+
(walletClient as WalletClient).account,
|
619
|
+
} as EstimateContractGasParameters)
|
620
|
+
}
|
621
|
+
},
|
622
|
+
},
|
623
|
+
)
|
624
|
+
contract.address = address
|
625
|
+
contract.abi = abi
|
626
|
+
|
590
627
|
return contract as unknown as GetContractReturnType<
|
591
628
|
TAbi,
|
592
629
|
TPublicClient,
|
593
|
-
TWalletClient
|
630
|
+
TWalletClient,
|
631
|
+
TAddress
|
594
632
|
>
|
595
633
|
}
|
596
634
|
|
@@ -659,6 +697,7 @@ type GetReadFunction<
|
|
659
697
|
type GetEstimateFunction<
|
660
698
|
Narrowable extends boolean,
|
661
699
|
TChain extends Chain | undefined,
|
700
|
+
TAccount extends Account | undefined,
|
662
701
|
TAbi extends Abi | readonly unknown[],
|
663
702
|
TFunctionName extends string,
|
664
703
|
TAbiFunction extends AbiFunction = TAbi extends Abi
|
@@ -667,20 +706,36 @@ type GetEstimateFunction<
|
|
667
706
|
Args = AbiParametersToPrimitiveTypes<TAbiFunction['inputs']>,
|
668
707
|
Options = Prettify<
|
669
708
|
Omit<
|
670
|
-
EstimateContractGasParameters<TAbi, TFunctionName, TChain>,
|
709
|
+
EstimateContractGasParameters<TAbi, TFunctionName, TChain, TAccount>,
|
671
710
|
'abi' | 'address' | 'args' | 'functionName'
|
672
711
|
>
|
673
712
|
>,
|
713
|
+
// For making `options` parameter required if `TAccount`
|
714
|
+
IsOptionsRequired = IsUndefined<TAccount>,
|
674
715
|
> = Narrowable extends true
|
675
716
|
? (
|
676
717
|
...parameters: Args extends readonly []
|
677
|
-
?
|
678
|
-
|
718
|
+
? IsOptionsRequired extends true
|
719
|
+
? [options: Options]
|
720
|
+
: [options?: Options]
|
721
|
+
: [
|
722
|
+
args: Args,
|
723
|
+
...parameters: IsOptionsRequired extends true
|
724
|
+
? [options: Options]
|
725
|
+
: [options?: Options],
|
726
|
+
]
|
679
727
|
) => Promise<EstimateContractGasReturnType>
|
680
728
|
: (
|
681
729
|
...parameters:
|
682
|
-
|
|
683
|
-
|
730
|
+
| (IsOptionsRequired extends true
|
731
|
+
? [options: Options]
|
732
|
+
: [options?: Options])
|
733
|
+
| [
|
734
|
+
args: readonly unknown[],
|
735
|
+
...parameters: IsOptionsRequired extends true
|
736
|
+
? [options: Options]
|
737
|
+
: [options?: Options],
|
738
|
+
]
|
684
739
|
) => Promise<EstimateContractGasReturnType>
|
685
740
|
|
686
741
|
type GetSimulateFunction<
|
@@ -759,13 +814,17 @@ type GetWriteFunction<
|
|
759
814
|
'abi' | 'address' | 'args' | 'functionName'
|
760
815
|
>
|
761
816
|
>,
|
762
|
-
Rest extends IsOptionsRequired extends true
|
763
|
-
? [options: Options]
|
764
|
-
: [options?: Options],
|
765
817
|
>(
|
766
818
|
...parameters: Args extends readonly []
|
767
|
-
?
|
768
|
-
|
819
|
+
? IsOptionsRequired extends true
|
820
|
+
? [options: Options]
|
821
|
+
: [options?: Options]
|
822
|
+
: [
|
823
|
+
args: Args,
|
824
|
+
...parameters: IsOptionsRequired extends true
|
825
|
+
? [options: Options]
|
826
|
+
: [options?: Options],
|
827
|
+
]
|
769
828
|
) => Promise<WriteContractReturnType>
|
770
829
|
: <
|
771
830
|
TChainOverride extends Chain | undefined,
|
@@ -799,25 +858,30 @@ type GetEventFilter<
|
|
799
858
|
Options = Prettify<
|
800
859
|
Omit<
|
801
860
|
CreateContractEventFilterParameters<TAbi, TEventName>,
|
802
|
-
'abi' | 'address' | 'args' | 'eventName'
|
861
|
+
'abi' | 'address' | 'args' | 'eventName' | 'strict'
|
803
862
|
>
|
804
863
|
>,
|
805
864
|
IndexedInputs = Extract<TAbiEvent['inputs'][number], { indexed: true }>,
|
806
865
|
> = Narrowable extends true
|
807
|
-
? <
|
866
|
+
? <
|
867
|
+
TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined,
|
868
|
+
TStrict extends boolean | undefined = undefined,
|
869
|
+
>(
|
808
870
|
...parameters: IsNever<IndexedInputs> extends true
|
809
|
-
? [options?: Options]
|
871
|
+
? [options?: Options & { strict?: TStrict }]
|
810
872
|
: [
|
811
873
|
args: Args | (Args extends Narrow<TArgs> ? Narrow<TArgs> : never),
|
812
|
-
options?: Options,
|
874
|
+
options?: Options & { strict?: TStrict },
|
813
875
|
]
|
814
|
-
) => Promise<
|
815
|
-
|
876
|
+
) => Promise<
|
877
|
+
CreateContractEventFilterReturnType<TAbi, TEventName, TArgs, TStrict>
|
878
|
+
>
|
879
|
+
: <TStrict extends boolean | undefined = undefined>(
|
816
880
|
...parameters:
|
817
|
-
| [options?: Options]
|
881
|
+
| [options?: Options & { strict?: TStrict }]
|
818
882
|
| [
|
819
883
|
args: readonly unknown[] | CreateContractFilterOptions,
|
820
|
-
options?: Options,
|
884
|
+
options?: Options & { strict?: TStrict },
|
821
885
|
]
|
822
886
|
) => Promise<CreateContractEventFilterReturnType>
|
823
887
|
|
@@ -208,7 +208,7 @@ async function scheduleMulticall<TChain extends Chain | undefined>(
|
|
208
208
|
args: ScheduleMulticallParameters<TChain>,
|
209
209
|
) {
|
210
210
|
const { batchSize = 1024, wait = 0 } =
|
211
|
-
typeof client.batch?.multicall === 'object' ? client.batch
|
211
|
+
typeof client.batch?.multicall === 'object' ? client.batch.multicall : {}
|
212
212
|
const {
|
213
213
|
blockNumber,
|
214
214
|
blockTag = 'latest',
|
@@ -22,11 +22,17 @@ export type CreateContractEventFilterParameters<
|
|
22
22
|
TArgs extends
|
23
23
|
| MaybeExtractEventArgsFromAbi<TAbi, TEventName>
|
24
24
|
| undefined = undefined,
|
25
|
+
TStrict extends boolean | undefined = undefined,
|
25
26
|
> = {
|
26
27
|
address?: Address | Address[]
|
27
28
|
abi: Narrow<TAbi>
|
28
29
|
eventName?: InferEventName<TAbi, TEventName>
|
29
30
|
fromBlock?: BlockNumber | BlockTag
|
31
|
+
/**
|
32
|
+
* Whether or not the logs must match the indexed/non-indexed arguments in the event ABI item.
|
33
|
+
* @default false
|
34
|
+
*/
|
35
|
+
strict?: TStrict
|
30
36
|
toBlock?: BlockNumber | BlockTag
|
31
37
|
} & (undefined extends TEventName
|
32
38
|
? {
|
@@ -49,7 +55,8 @@ export type CreateContractEventFilterReturnType<
|
|
49
55
|
TArgs extends
|
50
56
|
| MaybeExtractEventArgsFromAbi<TAbi, TEventName>
|
51
57
|
| undefined = undefined,
|
52
|
-
|
58
|
+
TStrict extends boolean | undefined = undefined,
|
59
|
+
> = Filter<'event', TAbi, TEventName, TArgs, TStrict>
|
53
60
|
|
54
61
|
/**
|
55
62
|
* Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs.html).
|
@@ -78,6 +85,7 @@ export async function createContractEventFilter<
|
|
78
85
|
TAbi extends Abi | readonly unknown[],
|
79
86
|
TEventName extends string | undefined,
|
80
87
|
TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName> | undefined,
|
88
|
+
TStrict extends boolean | undefined = undefined,
|
81
89
|
>(
|
82
90
|
client: PublicClient<Transport, TChain>,
|
83
91
|
{
|
@@ -86,9 +94,12 @@ export async function createContractEventFilter<
|
|
86
94
|
args,
|
87
95
|
eventName,
|
88
96
|
fromBlock,
|
97
|
+
strict,
|
89
98
|
toBlock,
|
90
|
-
}: CreateContractEventFilterParameters<TAbi, TEventName, TArgs>,
|
91
|
-
): Promise<
|
99
|
+
}: CreateContractEventFilterParameters<TAbi, TEventName, TArgs, TStrict>,
|
100
|
+
): Promise<
|
101
|
+
CreateContractEventFilterReturnType<TAbi, TEventName, TArgs, TStrict>
|
102
|
+
> {
|
92
103
|
const getRequest = createFilterRequestScope(client, {
|
93
104
|
method: 'eth_newFilter',
|
94
105
|
})
|
@@ -119,6 +130,12 @@ export async function createContractEventFilter<
|
|
119
130
|
eventName,
|
120
131
|
id,
|
121
132
|
request: getRequest(id),
|
133
|
+
strict,
|
122
134
|
type: 'event',
|
123
|
-
} as unknown as CreateContractEventFilterReturnType<
|
135
|
+
} as unknown as CreateContractEventFilterReturnType<
|
136
|
+
TAbi,
|
137
|
+
TEventName,
|
138
|
+
TArgs,
|
139
|
+
TStrict
|
140
|
+
>
|
124
141
|
}
|
@@ -20,47 +20,61 @@ import { createFilterRequestScope } from '../../utils/filters/createFilterReques
|
|
20
20
|
|
21
21
|
export type CreateEventFilterParameters<
|
22
22
|
TAbiEvent extends AbiEvent | undefined = undefined,
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
TStrict extends boolean | undefined = undefined,
|
24
|
+
_Abi extends Abi | readonly unknown[] = [TAbiEvent],
|
25
|
+
_EventName extends string | undefined = MaybeAbiEventName<TAbiEvent>,
|
26
|
+
_Args extends
|
27
|
+
| MaybeExtractEventArgsFromAbi<_Abi, _EventName>
|
27
28
|
| undefined = undefined,
|
28
29
|
> = {
|
29
30
|
address?: Address | Address[]
|
30
31
|
fromBlock?: BlockNumber | BlockTag
|
31
32
|
toBlock?: BlockNumber | BlockTag
|
32
33
|
} & (MaybeExtractEventArgsFromAbi<
|
33
|
-
|
34
|
-
|
34
|
+
_Abi,
|
35
|
+
_EventName
|
35
36
|
> extends infer TEventFilterArgs
|
36
37
|
?
|
37
38
|
| {
|
38
39
|
args:
|
39
40
|
| TEventFilterArgs
|
40
|
-
| (
|
41
|
+
| (_Args extends TEventFilterArgs ? _Args : never)
|
41
42
|
event: Narrow<TAbiEvent>
|
43
|
+
/**
|
44
|
+
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
45
|
+
* @default false
|
46
|
+
*/
|
47
|
+
strict?: TStrict
|
42
48
|
}
|
43
49
|
| {
|
44
50
|
args?: never
|
45
51
|
event?: Narrow<TAbiEvent>
|
52
|
+
/**
|
53
|
+
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
54
|
+
* @default false
|
55
|
+
*/
|
56
|
+
strict?: TStrict
|
46
57
|
}
|
47
58
|
| {
|
48
59
|
args?: never
|
49
60
|
event?: never
|
61
|
+
strict?: never
|
50
62
|
}
|
51
63
|
: {
|
52
64
|
args?: never
|
53
65
|
event?: never
|
66
|
+
strict?: never
|
54
67
|
})
|
55
68
|
|
56
69
|
export type CreateEventFilterReturnType<
|
57
70
|
TAbiEvent extends AbiEvent | undefined = undefined,
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
71
|
+
TStrict extends boolean | undefined = undefined,
|
72
|
+
_Abi extends Abi | readonly unknown[] = [TAbiEvent],
|
73
|
+
_EventName extends string | undefined = MaybeAbiEventName<TAbiEvent>,
|
74
|
+
_Args extends
|
75
|
+
| MaybeExtractEventArgsFromAbi<_Abi, _EventName>
|
62
76
|
| undefined = undefined,
|
63
|
-
> = Prettify<Filter<'event',
|
77
|
+
> = Prettify<Filter<'event', _Abi, _EventName, _Args, TStrict>>
|
64
78
|
|
65
79
|
/**
|
66
80
|
* Creates a [`Filter`](https://viem.sh/docs/glossary/types.html#filter) to listen for new events that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges.html).
|
@@ -88,6 +102,7 @@ export type CreateEventFilterReturnType<
|
|
88
102
|
export async function createEventFilter<
|
89
103
|
TChain extends Chain | undefined,
|
90
104
|
TAbiEvent extends AbiEvent | undefined,
|
105
|
+
TStrict extends boolean | undefined = undefined,
|
91
106
|
_Abi extends Abi | readonly unknown[] = [TAbiEvent],
|
92
107
|
_EventName extends string | undefined = MaybeAbiEventName<TAbiEvent>,
|
93
108
|
_Args extends
|
@@ -100,14 +115,18 @@ export async function createEventFilter<
|
|
100
115
|
args,
|
101
116
|
event,
|
102
117
|
fromBlock,
|
118
|
+
strict,
|
103
119
|
toBlock,
|
104
120
|
}: CreateEventFilterParameters<
|
105
121
|
TAbiEvent,
|
122
|
+
TStrict,
|
106
123
|
_Abi,
|
107
124
|
_EventName,
|
108
125
|
_Args
|
109
126
|
> = {} as any,
|
110
|
-
): Promise<
|
127
|
+
): Promise<
|
128
|
+
CreateEventFilterReturnType<TAbiEvent, TStrict, _Abi, _EventName, _Args>
|
129
|
+
> {
|
111
130
|
const getRequest = createFilterRequestScope(client, {
|
112
131
|
method: 'eth_newFilter',
|
113
132
|
})
|
@@ -139,9 +158,11 @@ export async function createEventFilter<
|
|
139
158
|
eventName: event ? (event as AbiEvent).name : undefined,
|
140
159
|
id,
|
141
160
|
request: getRequest(id),
|
161
|
+
strict,
|
142
162
|
type: 'event',
|
143
163
|
} as unknown as CreateEventFilterReturnType<
|
144
164
|
TAbiEvent,
|
165
|
+
TStrict,
|
145
166
|
_Abi,
|
146
167
|
_EventName,
|
147
168
|
_Args
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { Abi } from 'abitype'
|
2
2
|
|
3
|
+
import type { Account } from '../../accounts/types.js'
|
3
4
|
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
4
5
|
import type { PublicClient } from '../../clients/createPublicClient.js'
|
5
6
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
@@ -12,14 +13,16 @@ import {
|
|
12
13
|
} from '../../utils/abi/encodeFunctionData.js'
|
13
14
|
import { getContractError } from '../../utils/errors/getContractError.js'
|
14
15
|
|
16
|
+
import type { WalletClient } from '../../clients/createWalletClient.js'
|
15
17
|
import { type EstimateGasParameters, estimateGas } from './estimateGas.js'
|
16
18
|
|
17
19
|
export type EstimateContractGasParameters<
|
18
20
|
TAbi extends Abi | readonly unknown[] = Abi,
|
19
21
|
TFunctionName extends string = string,
|
20
22
|
TChain extends Chain | undefined = Chain | undefined,
|
23
|
+
TAccount extends Account | undefined = undefined,
|
21
24
|
> = ContractFunctionConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> &
|
22
|
-
Omit<EstimateGasParameters<TChain>, 'data' | 'to' | 'value'> &
|
25
|
+
Omit<EstimateGasParameters<TChain, TAccount>, 'data' | 'to' | 'value'> &
|
23
26
|
GetValue<TAbi, TFunctionName, EstimateGasParameters<TChain>['value']>
|
24
27
|
|
25
28
|
export type EstimateContractGasReturnType = bigint
|
@@ -55,17 +58,19 @@ export async function estimateContractGas<
|
|
55
58
|
TAbi extends Abi | readonly unknown[],
|
56
59
|
TFunctionName extends string,
|
57
60
|
TChain extends Chain | undefined,
|
61
|
+
TAccount extends Account | undefined = undefined,
|
58
62
|
>(
|
59
|
-
client:
|
63
|
+
client:
|
64
|
+
| PublicClient<Transport, TChain>
|
65
|
+
| WalletClient<Transport, TChain, TAccount>,
|
60
66
|
{
|
61
67
|
abi,
|
62
68
|
address,
|
63
69
|
args,
|
64
70
|
functionName,
|
65
71
|
...request
|
66
|
-
}: EstimateContractGasParameters<TAbi, TFunctionName, TChain>,
|
72
|
+
}: EstimateContractGasParameters<TAbi, TFunctionName, TChain, TAccount>,
|
67
73
|
): Promise<EstimateContractGasReturnType> {
|
68
|
-
const account = parseAccount(request.account)
|
69
74
|
const data = encodeFunctionData({
|
70
75
|
abi,
|
71
76
|
args,
|
@@ -79,6 +84,7 @@ export async function estimateContractGas<
|
|
79
84
|
} as unknown as EstimateGasParameters<TChain>)
|
80
85
|
return gas
|
81
86
|
} catch (err) {
|
87
|
+
const account = request.account ? parseAccount(request.account) : undefined
|
82
88
|
throw getContractError(err as BaseError, {
|
83
89
|
abi: abi as Abi,
|
84
90
|
address,
|
@@ -89,12 +89,12 @@ export async function getBlock<
|
|
89
89
|
|
90
90
|
let block: RpcBlock | null = null
|
91
91
|
if (blockHash) {
|
92
|
-
block = await client.request({
|
92
|
+
block = await (client as PublicClient).request({
|
93
93
|
method: 'eth_getBlockByHash',
|
94
94
|
params: [blockHash, includeTransactions],
|
95
95
|
})
|
96
96
|
} else {
|
97
|
-
block = await client.request({
|
97
|
+
block = await (client as PublicClient).request({
|
98
98
|
method: 'eth_getBlockByNumber',
|
99
99
|
params: [blockNumberHex || blockTag, includeTransactions],
|
100
100
|
})
|
@@ -65,7 +65,7 @@ export async function getBlockTransactionCount<
|
|
65
65
|
const blockNumberHex =
|
66
66
|
blockNumber !== undefined ? numberToHex(blockNumber) : undefined
|
67
67
|
|
68
|
-
let count: Quantity
|
68
|
+
let count: Quantity
|
69
69
|
if (blockHash) {
|
70
70
|
count = await client.request({
|
71
71
|
method: 'eth_getBlockTransactionCountByHash',
|
@@ -36,6 +36,8 @@ export async function getChainId<
|
|
36
36
|
| PublicClient<Transport, TChain>
|
37
37
|
| WalletClient<Transport, TChain, TAccount>,
|
38
38
|
): Promise<GetChainIdReturnType> {
|
39
|
-
const chainIdHex = await client.request({
|
39
|
+
const chainIdHex = await (client as PublicClient).request({
|
40
|
+
method: 'eth_chainId',
|
41
|
+
})
|
40
42
|
return hexToNumber(chainIdHex)
|
41
43
|
}
|