viem 1.1.7 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/package.json +5 -0
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsAvatar.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsName.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsResolver.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsText.js.map +1 -1
- package/dist/cjs/actions/index.js +155 -0
- package/dist/cjs/actions/index.js.map +1 -0
- package/dist/cjs/actions/public/call.js.map +1 -1
- package/dist/cjs/actions/public/createBlockFilter.js.map +1 -1
- package/dist/cjs/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/createEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/createPendingTransactionFilter.js.map +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/getBalance.js.map +1 -1
- package/dist/cjs/actions/public/getBlock.js.map +1 -1
- package/dist/cjs/actions/public/getBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/getBlockTransactionCount.js.map +1 -1
- package/dist/cjs/actions/public/getBytecode.js.map +1 -1
- package/dist/cjs/actions/public/getChainId.js.map +1 -1
- package/dist/cjs/actions/public/getFeeHistory.js.map +1 -1
- package/dist/cjs/actions/public/getFilterChanges.js.map +1 -1
- 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.map +1 -1
- package/dist/cjs/actions/public/getStorageAt.js.map +1 -1
- package/dist/cjs/actions/public/getTransaction.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionCount.js.map +1 -1
- package/dist/cjs/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/multicall.js.map +1 -1
- package/dist/cjs/actions/public/readContract.js.map +1 -1
- package/dist/cjs/actions/public/simulateContract.js.map +1 -1
- package/dist/cjs/actions/public/uninstallFilter.js.map +1 -1
- package/dist/cjs/actions/public/verifyHash.js.map +1 -1
- package/dist/cjs/actions/public/verifyMessage.js.map +1 -1
- package/dist/cjs/actions/public/verifyTypedData.js +2 -2
- package/dist/cjs/actions/public/verifyTypedData.js.map +1 -1
- package/dist/cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/watchBlocks.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/cjs/actions/test/dropTransaction.js.map +1 -1
- package/dist/cjs/actions/test/getAutomine.js.map +1 -1
- package/dist/cjs/actions/test/getTxpoolContent.js.map +1 -1
- package/dist/cjs/actions/test/getTxpoolStatus.js.map +1 -1
- package/dist/cjs/actions/test/impersonateAccount.js.map +1 -1
- package/dist/cjs/actions/test/increaseTime.js.map +1 -1
- package/dist/cjs/actions/test/inspectTxpool.js.map +1 -1
- package/dist/cjs/actions/test/mine.js.map +1 -1
- package/dist/cjs/actions/test/removeBlockTimestampInterval.js.map +1 -1
- package/dist/cjs/actions/test/reset.js.map +1 -1
- package/dist/cjs/actions/test/revert.js.map +1 -1
- package/dist/cjs/actions/test/sendUnsignedTransaction.js.map +1 -1
- package/dist/cjs/actions/test/setAutomine.js.map +1 -1
- package/dist/cjs/actions/test/setBalance.js.map +1 -1
- package/dist/cjs/actions/test/setBlockGasLimit.js.map +1 -1
- package/dist/cjs/actions/test/setBlockTimestampInterval.js.map +1 -1
- package/dist/cjs/actions/test/setCode.js.map +1 -1
- package/dist/cjs/actions/test/setCoinbase.js.map +1 -1
- package/dist/cjs/actions/test/setIntervalMining.js.map +1 -1
- package/dist/cjs/actions/test/setLoggingEnabled.js.map +1 -1
- package/dist/cjs/actions/test/setMinGasPrice.js.map +1 -1
- package/dist/cjs/actions/test/setNextBlockBaseFeePerGas.js.map +1 -1
- package/dist/cjs/actions/test/setNextBlockTimestamp.js.map +1 -1
- package/dist/cjs/actions/test/setNonce.js.map +1 -1
- package/dist/cjs/actions/test/setRpcUrl.js.map +1 -1
- package/dist/cjs/actions/test/setStorageAt.js.map +1 -1
- package/dist/cjs/actions/test/snapshot.js.map +1 -1
- package/dist/cjs/actions/test/stopImpersonatingAccount.js.map +1 -1
- package/dist/cjs/actions/wallet/addChain.js.map +1 -1
- package/dist/cjs/actions/wallet/deployContract.js.map +1 -1
- package/dist/cjs/actions/wallet/getAddresses.js.map +1 -1
- package/dist/cjs/actions/wallet/getPermissions.js.map +1 -1
- package/dist/cjs/actions/wallet/requestAddresses.js.map +1 -1
- package/dist/cjs/actions/wallet/requestPermissions.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/signMessage.js.map +1 -1
- package/dist/cjs/actions/wallet/signTypedData.js.map +1 -1
- package/dist/cjs/actions/wallet/switchChain.js.map +1 -1
- package/dist/cjs/actions/wallet/watchAsset.js.map +1 -1
- package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
- package/dist/cjs/clients/createClient.js +18 -3
- package/dist/cjs/clients/createClient.js.map +1 -1
- package/dist/cjs/clients/createPublicClient.js +8 -14
- package/dist/cjs/clients/createPublicClient.js.map +1 -1
- package/dist/cjs/clients/createTestClient.js +12 -16
- package/dist/cjs/clients/createTestClient.js.map +1 -1
- package/dist/cjs/clients/createWalletClient.js +9 -16
- 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 +35 -30
- package/dist/cjs/clients/decorators/test.js.map +1 -1
- package/dist/cjs/clients/decorators/wallet.js.map +1 -1
- package/dist/cjs/errors/rpc.js +132 -18
- package/dist/cjs/errors/rpc.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js +11 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/buildRequest.js +42 -41
- package/dist/cjs/utils/buildRequest.js.map +1 -1
- package/dist/cjs/utils/ccip.js.map +1 -1
- package/dist/cjs/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/dist/cjs/utils/ens/avatar/utils.js.map +1 -1
- package/dist/cjs/utils/filters/createFilterRequestScope.js.map +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAvatar.js.map +1 -1
- package/dist/esm/actions/ens/getEnsName.js.map +1 -1
- package/dist/esm/actions/ens/getEnsResolver.js.map +1 -1
- package/dist/esm/actions/ens/getEnsText.js.map +1 -1
- package/dist/esm/actions/index.js +76 -0
- package/dist/esm/actions/index.js.map +1 -0
- package/dist/esm/actions/public/call.js.map +1 -1
- package/dist/esm/actions/public/createBlockFilter.js.map +1 -1
- package/dist/esm/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createPendingTransactionFilter.js.map +1 -1
- package/dist/esm/actions/public/estimateContractGas.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/getBalance.js.map +1 -1
- package/dist/esm/actions/public/getBlock.js.map +1 -1
- package/dist/esm/actions/public/getBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/getBlockTransactionCount.js.map +1 -1
- package/dist/esm/actions/public/getBytecode.js.map +1 -1
- package/dist/esm/actions/public/getChainId.js.map +1 -1
- package/dist/esm/actions/public/getFeeHistory.js.map +1 -1
- package/dist/esm/actions/public/getFilterChanges.js.map +1 -1
- package/dist/esm/actions/public/getFilterLogs.js.map +1 -1
- package/dist/esm/actions/public/getGasPrice.js.map +1 -1
- package/dist/esm/actions/public/getLogs.js.map +1 -1
- package/dist/esm/actions/public/getStorageAt.js.map +1 -1
- package/dist/esm/actions/public/getTransaction.js.map +1 -1
- package/dist/esm/actions/public/getTransactionConfirmations.js.map +1 -1
- package/dist/esm/actions/public/getTransactionCount.js.map +1 -1
- package/dist/esm/actions/public/getTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/actions/public/readContract.js.map +1 -1
- package/dist/esm/actions/public/simulateContract.js.map +1 -1
- package/dist/esm/actions/public/uninstallFilter.js.map +1 -1
- package/dist/esm/actions/public/verifyHash.js.map +1 -1
- package/dist/esm/actions/public/verifyMessage.js.map +1 -1
- package/dist/esm/actions/public/verifyTypedData.js +1 -1
- package/dist/esm/actions/public/verifyTypedData.js.map +1 -1
- package/dist/esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/public/watchPendingTransactions.js.map +1 -1
- package/dist/esm/actions/test/dropTransaction.js.map +1 -1
- package/dist/esm/actions/test/getAutomine.js.map +1 -1
- package/dist/esm/actions/test/getTxpoolContent.js.map +1 -1
- package/dist/esm/actions/test/getTxpoolStatus.js.map +1 -1
- package/dist/esm/actions/test/impersonateAccount.js.map +1 -1
- package/dist/esm/actions/test/increaseTime.js.map +1 -1
- package/dist/esm/actions/test/inspectTxpool.js.map +1 -1
- package/dist/esm/actions/test/mine.js.map +1 -1
- package/dist/esm/actions/test/removeBlockTimestampInterval.js.map +1 -1
- package/dist/esm/actions/test/reset.js.map +1 -1
- package/dist/esm/actions/test/revert.js.map +1 -1
- package/dist/esm/actions/test/sendUnsignedTransaction.js.map +1 -1
- package/dist/esm/actions/test/setAutomine.js.map +1 -1
- package/dist/esm/actions/test/setBalance.js.map +1 -1
- package/dist/esm/actions/test/setBlockGasLimit.js.map +1 -1
- package/dist/esm/actions/test/setBlockTimestampInterval.js.map +1 -1
- package/dist/esm/actions/test/setCode.js.map +1 -1
- package/dist/esm/actions/test/setCoinbase.js.map +1 -1
- package/dist/esm/actions/test/setIntervalMining.js.map +1 -1
- package/dist/esm/actions/test/setLoggingEnabled.js.map +1 -1
- package/dist/esm/actions/test/setMinGasPrice.js.map +1 -1
- package/dist/esm/actions/test/setNextBlockBaseFeePerGas.js.map +1 -1
- package/dist/esm/actions/test/setNextBlockTimestamp.js.map +1 -1
- package/dist/esm/actions/test/setNonce.js.map +1 -1
- package/dist/esm/actions/test/setRpcUrl.js.map +1 -1
- package/dist/esm/actions/test/setStorageAt.js.map +1 -1
- package/dist/esm/actions/test/snapshot.js.map +1 -1
- package/dist/esm/actions/test/stopImpersonatingAccount.js.map +1 -1
- package/dist/esm/actions/wallet/addChain.js.map +1 -1
- package/dist/esm/actions/wallet/deployContract.js.map +1 -1
- package/dist/esm/actions/wallet/getAddresses.js.map +1 -1
- package/dist/esm/actions/wallet/getPermissions.js.map +1 -1
- package/dist/esm/actions/wallet/requestAddresses.js.map +1 -1
- package/dist/esm/actions/wallet/requestPermissions.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/signMessage.js.map +1 -1
- package/dist/esm/actions/wallet/signTypedData.js.map +1 -1
- package/dist/esm/actions/wallet/switchChain.js.map +1 -1
- package/dist/esm/actions/wallet/watchAsset.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/clients/createClient.js +18 -3
- package/dist/esm/clients/createClient.js.map +1 -1
- package/dist/esm/clients/createPublicClient.js +8 -14
- package/dist/esm/clients/createPublicClient.js.map +1 -1
- package/dist/esm/clients/createTestClient.js +12 -16
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/createWalletClient.js +9 -16
- 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 +35 -30
- package/dist/esm/clients/decorators/test.js.map +1 -1
- package/dist/esm/clients/decorators/wallet.js.map +1 -1
- package/dist/esm/errors/rpc.js +168 -36
- package/dist/esm/errors/rpc.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/buildRequest.js +60 -41
- package/dist/esm/utils/buildRequest.js.map +1 -1
- package/dist/esm/utils/ccip.js.map +1 -1
- package/dist/esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
- package/dist/esm/utils/ens/avatar/utils.js.map +1 -1
- package/dist/esm/utils/filters/createFilterRequestScope.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/types/actions/ens/getEnsAddress.d.ts +2 -2
- package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsAvatar.d.ts +2 -2
- package/dist/types/actions/ens/getEnsAvatar.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsName.d.ts +2 -2
- package/dist/types/actions/ens/getEnsName.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsResolver.d.ts +2 -2
- package/dist/types/actions/ens/getEnsResolver.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsText.d.ts +2 -2
- package/dist/types/actions/ens/getEnsText.d.ts.map +1 -1
- package/dist/types/actions/index.d.ts +76 -0
- package/dist/types/actions/index.d.ts.map +1 -0
- package/dist/types/actions/public/call.d.ts +2 -2
- package/dist/types/actions/public/call.d.ts.map +1 -1
- package/dist/types/actions/public/createBlockFilter.d.ts +2 -2
- package/dist/types/actions/public/createBlockFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +2 -2
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +2 -2
- package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts +2 -2
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts.map +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +2 -3
- package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/dist/types/actions/public/estimateGas.d.ts +2 -3
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getBalance.d.ts +2 -2
- package/dist/types/actions/public/getBalance.d.ts.map +1 -1
- package/dist/types/actions/public/getBlock.d.ts +2 -3
- package/dist/types/actions/public/getBlock.d.ts.map +1 -1
- package/dist/types/actions/public/getBlockNumber.d.ts +4 -4
- package/dist/types/actions/public/getBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/getBlockTransactionCount.d.ts +2 -2
- package/dist/types/actions/public/getBlockTransactionCount.d.ts.map +1 -1
- package/dist/types/actions/public/getBytecode.d.ts +2 -2
- package/dist/types/actions/public/getBytecode.d.ts.map +1 -1
- package/dist/types/actions/public/getChainId.d.ts +2 -3
- package/dist/types/actions/public/getChainId.d.ts.map +1 -1
- package/dist/types/actions/public/getFeeHistory.d.ts +2 -2
- package/dist/types/actions/public/getFeeHistory.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts +2 -2
- package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts +2 -2
- package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getGasPrice.d.ts +2 -3
- package/dist/types/actions/public/getGasPrice.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts +2 -2
- package/dist/types/actions/public/getLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getStorageAt.d.ts +2 -2
- package/dist/types/actions/public/getStorageAt.d.ts.map +1 -1
- package/dist/types/actions/public/getTransaction.d.ts +2 -2
- package/dist/types/actions/public/getTransaction.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionConfirmations.d.ts +2 -2
- package/dist/types/actions/public/getTransactionConfirmations.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionCount.d.ts +2 -3
- package/dist/types/actions/public/getTransactionCount.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +2 -2
- package/dist/types/actions/public/getTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/multicall.d.ts +2 -2
- package/dist/types/actions/public/multicall.d.ts.map +1 -1
- package/dist/types/actions/public/readContract.d.ts +2 -2
- package/dist/types/actions/public/readContract.d.ts.map +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +2 -2
- package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
- package/dist/types/actions/public/uninstallFilter.d.ts +2 -2
- package/dist/types/actions/public/uninstallFilter.d.ts.map +1 -1
- package/dist/types/actions/public/verifyHash.d.ts +2 -2
- package/dist/types/actions/public/verifyHash.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 +2 -2
- package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts +2 -2
- package/dist/types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlockNumber.d.ts +2 -2
- package/dist/types/actions/public/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/watchBlocks.d.ts +2 -2
- package/dist/types/actions/public/watchBlocks.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +2 -2
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +2 -2
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchPendingTransactions.d.ts +2 -2
- package/dist/types/actions/public/watchPendingTransactions.d.ts.map +1 -1
- package/dist/types/actions/test/dropTransaction.d.ts +2 -1
- package/dist/types/actions/test/dropTransaction.d.ts.map +1 -1
- package/dist/types/actions/test/getAutomine.d.ts +2 -1
- package/dist/types/actions/test/getAutomine.d.ts.map +1 -1
- package/dist/types/actions/test/getTxpoolContent.d.ts +2 -1
- package/dist/types/actions/test/getTxpoolContent.d.ts.map +1 -1
- package/dist/types/actions/test/getTxpoolStatus.d.ts +2 -1
- package/dist/types/actions/test/getTxpoolStatus.d.ts.map +1 -1
- package/dist/types/actions/test/impersonateAccount.d.ts +2 -1
- package/dist/types/actions/test/impersonateAccount.d.ts.map +1 -1
- package/dist/types/actions/test/increaseTime.d.ts +2 -1
- package/dist/types/actions/test/increaseTime.d.ts.map +1 -1
- package/dist/types/actions/test/inspectTxpool.d.ts +2 -1
- package/dist/types/actions/test/inspectTxpool.d.ts.map +1 -1
- package/dist/types/actions/test/mine.d.ts +2 -1
- package/dist/types/actions/test/mine.d.ts.map +1 -1
- package/dist/types/actions/test/removeBlockTimestampInterval.d.ts +2 -1
- package/dist/types/actions/test/removeBlockTimestampInterval.d.ts.map +1 -1
- package/dist/types/actions/test/reset.d.ts +2 -1
- package/dist/types/actions/test/reset.d.ts.map +1 -1
- package/dist/types/actions/test/revert.d.ts +2 -1
- package/dist/types/actions/test/revert.d.ts.map +1 -1
- package/dist/types/actions/test/sendUnsignedTransaction.d.ts +2 -1
- package/dist/types/actions/test/sendUnsignedTransaction.d.ts.map +1 -1
- package/dist/types/actions/test/setAutomine.d.ts +2 -1
- package/dist/types/actions/test/setAutomine.d.ts.map +1 -1
- package/dist/types/actions/test/setBalance.d.ts +2 -1
- package/dist/types/actions/test/setBalance.d.ts.map +1 -1
- package/dist/types/actions/test/setBlockGasLimit.d.ts +2 -1
- package/dist/types/actions/test/setBlockGasLimit.d.ts.map +1 -1
- package/dist/types/actions/test/setBlockTimestampInterval.d.ts +2 -1
- package/dist/types/actions/test/setBlockTimestampInterval.d.ts.map +1 -1
- package/dist/types/actions/test/setCode.d.ts +2 -1
- package/dist/types/actions/test/setCode.d.ts.map +1 -1
- package/dist/types/actions/test/setCoinbase.d.ts +2 -1
- package/dist/types/actions/test/setCoinbase.d.ts.map +1 -1
- package/dist/types/actions/test/setIntervalMining.d.ts +2 -1
- package/dist/types/actions/test/setIntervalMining.d.ts.map +1 -1
- package/dist/types/actions/test/setLoggingEnabled.d.ts +2 -1
- package/dist/types/actions/test/setLoggingEnabled.d.ts.map +1 -1
- package/dist/types/actions/test/setMinGasPrice.d.ts +2 -1
- package/dist/types/actions/test/setMinGasPrice.d.ts.map +1 -1
- package/dist/types/actions/test/setNextBlockBaseFeePerGas.d.ts +2 -1
- package/dist/types/actions/test/setNextBlockBaseFeePerGas.d.ts.map +1 -1
- package/dist/types/actions/test/setNextBlockTimestamp.d.ts +2 -1
- package/dist/types/actions/test/setNextBlockTimestamp.d.ts.map +1 -1
- package/dist/types/actions/test/setNonce.d.ts +2 -1
- package/dist/types/actions/test/setNonce.d.ts.map +1 -1
- package/dist/types/actions/test/setRpcUrl.d.ts +2 -1
- package/dist/types/actions/test/setRpcUrl.d.ts.map +1 -1
- package/dist/types/actions/test/setStorageAt.d.ts +2 -1
- package/dist/types/actions/test/setStorageAt.d.ts.map +1 -1
- package/dist/types/actions/test/snapshot.d.ts +2 -1
- package/dist/types/actions/test/snapshot.d.ts.map +1 -1
- package/dist/types/actions/test/stopImpersonatingAccount.d.ts +2 -1
- package/dist/types/actions/test/stopImpersonatingAccount.d.ts.map +1 -1
- package/dist/types/actions/wallet/addChain.d.ts +2 -2
- package/dist/types/actions/wallet/addChain.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +2 -2
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/getAddresses.d.ts +2 -2
- package/dist/types/actions/wallet/getAddresses.d.ts.map +1 -1
- package/dist/types/actions/wallet/getPermissions.d.ts +2 -2
- package/dist/types/actions/wallet/getPermissions.d.ts.map +1 -1
- package/dist/types/actions/wallet/requestAddresses.d.ts +2 -2
- package/dist/types/actions/wallet/requestAddresses.d.ts.map +1 -1
- package/dist/types/actions/wallet/requestPermissions.d.ts +2 -2
- package/dist/types/actions/wallet/requestPermissions.d.ts.map +1 -1
- package/dist/types/actions/wallet/sendTransaction.d.ts +2 -2
- package/dist/types/actions/wallet/sendTransaction.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 +2 -2
- package/dist/types/actions/wallet/signTypedData.d.ts.map +1 -1
- package/dist/types/actions/wallet/switchChain.d.ts +2 -2
- package/dist/types/actions/wallet/switchChain.d.ts.map +1 -1
- package/dist/types/actions/wallet/watchAsset.d.ts +2 -2
- package/dist/types/actions/wallet/watchAsset.d.ts.map +1 -1
- package/dist/types/actions/wallet/writeContract.d.ts +2 -2
- package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
- package/dist/types/clients/createClient.d.ts +35 -3
- package/dist/types/clients/createClient.d.ts.map +1 -1
- package/dist/types/clients/createPublicClient.d.ts +3 -15
- package/dist/types/clients/createPublicClient.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +6 -3
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/createWalletClient.d.ts +5 -10
- package/dist/types/clients/createWalletClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +524 -5
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/test.d.ts +6 -2
- package/dist/types/clients/decorators/test.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +520 -2
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/errors/rpc.d.ts +18 -0
- package/dist/types/errors/rpc.d.ts.map +1 -1
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +6 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/account.d.ts +2 -2
- package/dist/types/types/account.d.ts.map +1 -1
- package/dist/types/types/utils.d.ts +2 -2
- package/dist/types/utils/buildRequest.d.ts.map +1 -1
- package/dist/types/utils/ccip.d.ts +2 -2
- package/dist/types/utils/ccip.d.ts.map +1 -1
- package/dist/types/utils/ens/avatar/parseAvatarRecord.d.ts +2 -2
- package/dist/types/utils/ens/avatar/parseAvatarRecord.d.ts.map +1 -1
- package/dist/types/utils/ens/avatar/utils.d.ts +2 -2
- package/dist/types/utils/ens/avatar/utils.d.ts.map +1 -1
- package/dist/types/utils/filters/createFilterRequestScope.d.ts +4 -3
- package/dist/types/utils/filters/createFilterRequestScope.d.ts.map +1 -1
- package/dist/types/utils/formatters/transaction.d.ts +1 -1
- package/dist/types/utils/transaction/prepareRequest.d.ts +2 -3
- package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
- package/package.json +11 -2
- package/src/actions/ens/getEnsAddress.ts +2 -2
- package/src/actions/ens/getEnsAvatar.ts +2 -2
- package/src/actions/ens/getEnsName.ts +2 -2
- package/src/actions/ens/getEnsResolver.ts +2 -2
- package/src/actions/ens/getEnsText.ts +2 -2
- package/src/actions/index.ts +324 -0
- package/src/actions/public/call.ts +4 -4
- package/src/actions/public/createBlockFilter.ts +2 -2
- package/src/actions/public/createContractEventFilter.ts +2 -2
- package/src/actions/public/createEventFilter.ts +2 -2
- package/src/actions/public/createPendingTransactionFilter.ts +2 -2
- package/src/actions/public/estimateContractGas.ts +2 -6
- package/src/actions/public/estimateGas.ts +4 -7
- package/src/actions/public/getBalance.ts +2 -2
- package/src/actions/public/getBlock.ts +4 -7
- package/src/actions/public/getBlockNumber.ts +2 -2
- package/src/actions/public/getBlockTransactionCount.ts +2 -2
- package/src/actions/public/getBytecode.ts +2 -2
- package/src/actions/public/getChainId.ts +3 -8
- package/src/actions/public/getFeeHistory.ts +2 -2
- package/src/actions/public/getFilterChanges.ts +2 -2
- package/src/actions/public/getFilterLogs.ts +2 -2
- package/src/actions/public/getGasPrice.ts +3 -8
- package/src/actions/public/getLogs.ts +2 -2
- package/src/actions/public/getStorageAt.ts +2 -2
- package/src/actions/public/getTransaction.ts +2 -2
- package/src/actions/public/getTransactionConfirmations.ts +2 -2
- package/src/actions/public/getTransactionCount.ts +3 -6
- package/src/actions/public/getTransactionReceipt.ts +2 -2
- package/src/actions/public/multicall.ts +2 -2
- package/src/actions/public/readContract.ts +2 -2
- package/src/actions/public/simulateContract.ts +2 -2
- package/src/actions/public/uninstallFilter.ts +2 -2
- package/src/actions/public/verifyHash.ts +2 -2
- package/src/actions/public/verifyMessage.ts +2 -2
- package/src/actions/public/verifyTypedData.ts +3 -3
- package/src/actions/public/waitForTransactionReceipt.ts +2 -2
- package/src/actions/public/watchBlockNumber.ts +2 -2
- package/src/actions/public/watchBlocks.ts +2 -2
- package/src/actions/public/watchContractEvent.ts +2 -2
- package/src/actions/public/watchEvent.ts +2 -2
- package/src/actions/public/watchPendingTransactions.ts +2 -2
- package/src/actions/test/dropTransaction.ts +6 -2
- package/src/actions/test/getAutomine.ts +6 -2
- package/src/actions/test/getTxpoolContent.ts +6 -2
- package/src/actions/test/getTxpoolStatus.ts +6 -2
- package/src/actions/test/impersonateAccount.ts +6 -2
- package/src/actions/test/increaseTime.ts +6 -2
- package/src/actions/test/inspectTxpool.ts +6 -2
- package/src/actions/test/mine.ts +6 -2
- package/src/actions/test/removeBlockTimestampInterval.ts +3 -1
- package/src/actions/test/reset.ts +6 -2
- package/src/actions/test/revert.ts +6 -2
- package/src/actions/test/sendUnsignedTransaction.ts +3 -1
- package/src/actions/test/setAutomine.ts +6 -2
- package/src/actions/test/setBalance.ts +6 -2
- package/src/actions/test/setBlockGasLimit.ts +6 -2
- package/src/actions/test/setBlockTimestampInterval.ts +3 -1
- package/src/actions/test/setCode.ts +6 -2
- package/src/actions/test/setCoinbase.ts +6 -2
- package/src/actions/test/setIntervalMining.ts +6 -2
- package/src/actions/test/setLoggingEnabled.ts +6 -2
- package/src/actions/test/setMinGasPrice.ts +6 -2
- package/src/actions/test/setNextBlockBaseFeePerGas.ts +3 -1
- package/src/actions/test/setNextBlockTimestamp.ts +6 -2
- package/src/actions/test/setNonce.ts +6 -2
- package/src/actions/test/setRpcUrl.ts +6 -2
- package/src/actions/test/setStorageAt.ts +6 -2
- package/src/actions/test/snapshot.ts +5 -3
- package/src/actions/test/stopImpersonatingAccount.ts +3 -1
- package/src/actions/wallet/addChain.ts +2 -5
- package/src/actions/wallet/deployContract.ts +2 -2
- package/src/actions/wallet/getAddresses.ts +2 -2
- package/src/actions/wallet/getPermissions.ts +2 -2
- package/src/actions/wallet/requestAddresses.ts +2 -2
- package/src/actions/wallet/requestPermissions.ts +2 -2
- package/src/actions/wallet/sendTransaction.ts +2 -2
- package/src/actions/wallet/signMessage.ts +2 -2
- package/src/actions/wallet/signTypedData.ts +2 -2
- package/src/actions/wallet/switchChain.ts +2 -5
- package/src/actions/wallet/watchAsset.ts +2 -2
- package/src/actions/wallet/writeContract.ts +2 -2
- package/src/clients/createClient.ts +83 -6
- package/src/clients/createPublicClient.ts +18 -38
- package/src/clients/createTestClient.ts +34 -23
- package/src/clients/createWalletClient.ts +22 -41
- package/src/clients/decorators/public.ts +10 -12
- package/src/clients/decorators/test.ts +56 -36
- package/src/clients/decorators/wallet.ts +3 -9
- package/src/errors/rpc.ts +42 -18
- package/src/errors/version.ts +1 -1
- package/src/index.ts +20 -4
- package/src/types/account.ts +9 -5
- package/src/types/utils.ts +2 -2
- package/src/utils/buildRequest.ts +59 -21
- package/src/utils/ccip.ts +3 -3
- package/src/utils/ens/avatar/parseAvatarRecord.ts +3 -3
- package/src/utils/ens/avatar/utils.ts +2 -2
- package/src/utils/filters/createFilterRequestScope.ts +4 -3
- package/src/utils/transaction/prepareRequest.ts +2 -5
@@ -1,16 +1,40 @@
|
|
1
|
+
import type { Address, Narrow } from 'abitype'
|
2
|
+
|
3
|
+
import type { Account, JsonRpcAccount } from '../accounts/types.js'
|
4
|
+
import type { ParseAccount } from '../types/account.js'
|
1
5
|
import type { Chain } from '../types/chain.js'
|
2
6
|
import type {
|
3
7
|
EIP1193RequestFn,
|
4
8
|
EIP1474Methods,
|
5
9
|
RpcSchema,
|
6
10
|
} from '../types/eip1193.js'
|
11
|
+
import type { Prettify } from '../types/utils.js'
|
12
|
+
import { parseAccount } from '../utils/accounts.js'
|
7
13
|
import { uid } from '../utils/uid.js'
|
8
14
|
import type { Transport } from './transports/createTransport.js'
|
9
15
|
|
16
|
+
export type MulticallBatchOptions = {
|
17
|
+
/** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
|
18
|
+
batchSize?: number
|
19
|
+
/** The maximum number of milliseconds to wait before sending a batch. @default 0 */
|
20
|
+
wait?: number
|
21
|
+
}
|
22
|
+
|
10
23
|
export type ClientConfig<
|
11
24
|
TTransport extends Transport = Transport,
|
12
25
|
TChain extends Chain | undefined = Chain | undefined,
|
26
|
+
TAccountOrAddress extends Account | Address | undefined =
|
27
|
+
| Account
|
28
|
+
| Address
|
29
|
+
| undefined,
|
13
30
|
> = {
|
31
|
+
/** The Account to use for the Client. This will be used for Actions that require an account as an argument. */
|
32
|
+
account?: TAccountOrAddress
|
33
|
+
/** Flags for batch settings. */
|
34
|
+
batch?: {
|
35
|
+
/** Toggle to enable `eth_call` multicall aggregation. */
|
36
|
+
multicall?: boolean | MulticallBatchOptions
|
37
|
+
}
|
14
38
|
/** Chain for the client. */
|
15
39
|
chain?: TChain
|
16
40
|
/** A key for the client. */
|
@@ -28,11 +52,19 @@ export type ClientConfig<
|
|
28
52
|
type?: string
|
29
53
|
}
|
30
54
|
|
31
|
-
|
55
|
+
type Client_Base<
|
32
56
|
TTransport extends Transport = Transport,
|
33
|
-
TRpcSchema extends RpcSchema | undefined = undefined,
|
34
57
|
TChain extends Chain | undefined = Chain | undefined,
|
58
|
+
TAccount extends Account | undefined = Account | undefined,
|
59
|
+
TRpcSchema extends RpcSchema | undefined = undefined,
|
35
60
|
> = {
|
61
|
+
/** The Account of the Client. */
|
62
|
+
account: TAccount
|
63
|
+
/** Flags for batch settings. */
|
64
|
+
batch?: {
|
65
|
+
/** Toggle to enable `eth_call` multicall aggregation. */
|
66
|
+
multicall?: boolean | MulticallBatchOptions
|
67
|
+
}
|
36
68
|
/** Chain for the client. */
|
37
69
|
chain: TChain
|
38
70
|
/** A key for the client. */
|
@@ -53,30 +85,75 @@ export type Client<
|
|
53
85
|
uid: string
|
54
86
|
}
|
55
87
|
|
88
|
+
type Extended = { [K in keyof Client_Base]?: undefined } & {
|
89
|
+
[key: string]: unknown
|
90
|
+
}
|
91
|
+
|
92
|
+
export type Client<
|
93
|
+
TTransport extends Transport = Transport,
|
94
|
+
TChain extends Chain | undefined = Chain | undefined,
|
95
|
+
TAccount extends Account | undefined = Account | undefined,
|
96
|
+
TRpcSchema extends RpcSchema | undefined = undefined,
|
97
|
+
TExtended extends Extended | undefined = Extended | undefined,
|
98
|
+
> = Client_Base<TTransport, TChain, TAccount, TRpcSchema> & {
|
99
|
+
extend: <TNextExtended extends Extended = Extended>(
|
100
|
+
fn: (
|
101
|
+
client: Client<TTransport, TChain, TAccount, TRpcSchema, TExtended>,
|
102
|
+
) => Narrow<TNextExtended>,
|
103
|
+
) => Client<
|
104
|
+
TTransport,
|
105
|
+
TChain,
|
106
|
+
TAccount,
|
107
|
+
TRpcSchema,
|
108
|
+
(TExtended extends Extended ? TExtended : {}) & TNextExtended
|
109
|
+
>
|
110
|
+
} & (TExtended extends Extended ? TExtended : {})
|
111
|
+
|
56
112
|
/**
|
57
113
|
* @description Creates a base client with the given transport.
|
58
114
|
*/
|
59
115
|
export function createClient<
|
60
116
|
TTransport extends Transport,
|
61
|
-
TRpcSchema extends RpcSchema | undefined = undefined,
|
62
117
|
TChain extends Chain | undefined = undefined,
|
118
|
+
TAccountOrAddress extends Account | Address | undefined = undefined,
|
63
119
|
>({
|
120
|
+
account,
|
121
|
+
batch,
|
64
122
|
chain,
|
65
123
|
key = 'base',
|
66
124
|
name = 'Base Client',
|
67
125
|
pollingInterval = 4_000,
|
68
126
|
transport,
|
69
127
|
type = 'base',
|
70
|
-
}: ClientConfig<TTransport, TChain>): Client<
|
128
|
+
}: ClientConfig<TTransport, TChain, TAccountOrAddress>): Client<
|
129
|
+
TTransport,
|
130
|
+
TChain,
|
131
|
+
TAccountOrAddress extends Address
|
132
|
+
? Prettify<JsonRpcAccount<TAccountOrAddress>>
|
133
|
+
: TAccountOrAddress
|
134
|
+
> {
|
71
135
|
const { config, request, value } = transport({ chain, pollingInterval })
|
72
|
-
|
136
|
+
const client = {
|
137
|
+
account: (account
|
138
|
+
? parseAccount(account)
|
139
|
+
: undefined) as ParseAccount<TAccountOrAddress>,
|
140
|
+
batch,
|
73
141
|
chain: chain as TChain,
|
74
142
|
key,
|
75
143
|
name,
|
76
144
|
pollingInterval,
|
77
|
-
request
|
145
|
+
request,
|
78
146
|
transport: { ...config, ...value },
|
79
147
|
type,
|
80
148
|
uid: uid(),
|
81
149
|
}
|
150
|
+
function extend(client_: typeof client) {
|
151
|
+
return (fn: (_: typeof client) => unknown) => {
|
152
|
+
const extended = fn(client_) as Extended
|
153
|
+
for (const key in client) delete extended[key]
|
154
|
+
const nextClient = { ...client_, ...extended }
|
155
|
+
return Object.assign(nextClient, { extend: extend(nextClient) })
|
156
|
+
}
|
157
|
+
}
|
158
|
+
return Object.assign(client, { extend: extend(client) as any })
|
82
159
|
}
|
@@ -5,35 +5,25 @@ import { type Client, type ClientConfig, createClient } from './createClient.js'
|
|
5
5
|
import { type PublicActions, publicActions } from './decorators/public.js'
|
6
6
|
import type { Transport } from './transports/createTransport.js'
|
7
7
|
|
8
|
-
export type MulticallBatchOptions = {
|
9
|
-
/** The maximum size (in bytes) for each calldata chunk. @default 1_024 */
|
10
|
-
batchSize?: number
|
11
|
-
/** The maximum number of milliseconds to wait before sending a batch. @default 0 */
|
12
|
-
wait?: number
|
13
|
-
}
|
14
|
-
|
15
8
|
export type PublicClientConfig<
|
16
9
|
TTransport extends Transport = Transport,
|
17
10
|
TChain extends Chain | undefined = Chain | undefined,
|
18
11
|
> = Pick<
|
19
12
|
ClientConfig<TTransport, TChain>,
|
20
|
-
'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
21
|
-
>
|
22
|
-
/** Flags for batch settings. */
|
23
|
-
batch?: {
|
24
|
-
/** Toggle to enable `eth_call` multicall aggregation. */
|
25
|
-
multicall?: boolean | MulticallBatchOptions
|
26
|
-
}
|
27
|
-
}
|
13
|
+
'batch' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
14
|
+
>
|
28
15
|
|
29
16
|
export type PublicClient<
|
30
17
|
TTransport extends Transport = Transport,
|
31
18
|
TChain extends Chain | undefined = Chain | undefined,
|
32
|
-
TIncludeActions extends boolean = true,
|
33
19
|
> = Prettify<
|
34
|
-
Client<
|
35
|
-
|
36
|
-
|
20
|
+
Client<
|
21
|
+
TTransport,
|
22
|
+
TChain,
|
23
|
+
undefined,
|
24
|
+
PublicRpcSchema,
|
25
|
+
PublicActions<TTransport, TChain>
|
26
|
+
>
|
37
27
|
>
|
38
28
|
|
39
29
|
/**
|
@@ -65,24 +55,14 @@ export function createPublicClient<
|
|
65
55
|
name = 'Public Client',
|
66
56
|
transport,
|
67
57
|
pollingInterval,
|
68
|
-
}: PublicClientConfig<TTransport, TChain>): PublicClient<
|
69
|
-
|
70
|
-
TChain,
|
71
|
-
true
|
72
|
-
> {
|
73
|
-
const client = {
|
58
|
+
}: PublicClientConfig<TTransport, TChain>): PublicClient<TTransport, TChain> {
|
59
|
+
return createClient({
|
74
60
|
batch,
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
}) as PublicClient<TTransport, TChain>),
|
83
|
-
}
|
84
|
-
return {
|
85
|
-
...client,
|
86
|
-
...publicActions(client),
|
87
|
-
}
|
61
|
+
chain,
|
62
|
+
key,
|
63
|
+
name,
|
64
|
+
pollingInterval,
|
65
|
+
transport,
|
66
|
+
type: 'publicClient',
|
67
|
+
}).extend(publicActions)
|
88
68
|
}
|
@@ -1,8 +1,11 @@
|
|
1
|
+
import type { Account } from '../accounts/types.js'
|
2
|
+
import type { ParseAccount } from '../types/account.js'
|
1
3
|
import type { Chain } from '../types/chain.js'
|
2
4
|
import type { TestRpcSchema } from '../types/eip1193.js'
|
3
5
|
import { type Client, type ClientConfig, createClient } from './createClient.js'
|
4
6
|
import { type TestActions, testActions } from './decorators/test.js'
|
5
7
|
import type { Transport } from './transports/createTransport.js'
|
8
|
+
import type { Address } from 'abitype'
|
6
9
|
|
7
10
|
export type TestClientMode = 'anvil' | 'hardhat' | 'ganache'
|
8
11
|
|
@@ -10,9 +13,13 @@ export type TestClientConfig<
|
|
10
13
|
TMode extends TestClientMode = TestClientMode,
|
11
14
|
TTransport extends Transport = Transport,
|
12
15
|
TChain extends Chain | undefined = Chain | undefined,
|
16
|
+
TAccountOrAddress extends Account | Address | undefined =
|
17
|
+
| Account
|
18
|
+
| Address
|
19
|
+
| undefined,
|
13
20
|
> = Pick<
|
14
|
-
ClientConfig<TTransport, TChain>,
|
15
|
-
'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
21
|
+
ClientConfig<TTransport, TChain, TAccountOrAddress>,
|
22
|
+
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
16
23
|
> & {
|
17
24
|
/** Mode of the test client. Available: "anvil" | "hardhat" | "ganache" */
|
18
25
|
mode: TMode
|
@@ -22,11 +29,17 @@ export type TestClient<
|
|
22
29
|
TMode extends TestClientMode = TestClientMode,
|
23
30
|
TTransport extends Transport = Transport,
|
24
31
|
TChain extends Chain | undefined = Chain | undefined,
|
32
|
+
TAccount extends Account | undefined = Account | undefined,
|
25
33
|
TIncludeActions extends boolean = true,
|
26
|
-
> = Client<
|
27
|
-
|
28
|
-
|
29
|
-
|
34
|
+
> = Client<
|
35
|
+
TTransport,
|
36
|
+
TChain,
|
37
|
+
TAccount,
|
38
|
+
TestRpcSchema<TMode>,
|
39
|
+
TIncludeActions extends true ? TestActions : Record<string, unknown>
|
40
|
+
> & {
|
41
|
+
mode: TMode
|
42
|
+
}
|
30
43
|
|
31
44
|
/**
|
32
45
|
* @description Creates a test client with a given transport.
|
@@ -55,32 +68,30 @@ export function createTestClient<
|
|
55
68
|
TMode extends TestClientMode,
|
56
69
|
TTransport extends Transport,
|
57
70
|
TChain extends Chain | undefined = undefined,
|
71
|
+
TAccountOrAddress extends Account | Address | undefined = undefined,
|
58
72
|
>({
|
73
|
+
account,
|
59
74
|
chain,
|
60
75
|
key = 'test',
|
61
76
|
name = 'Test Client',
|
62
77
|
mode,
|
63
78
|
pollingInterval,
|
64
79
|
transport,
|
65
|
-
}: TestClientConfig<TMode, TTransport, TChain>): TestClient<
|
80
|
+
}: TestClientConfig<TMode, TTransport, TChain, TAccountOrAddress>): TestClient<
|
66
81
|
TMode,
|
67
82
|
TTransport,
|
68
83
|
TChain,
|
69
|
-
|
84
|
+
ParseAccount<TAccountOrAddress>
|
70
85
|
> {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
mode
|
81
|
-
|
82
|
-
return {
|
83
|
-
...client,
|
84
|
-
...testActions(client),
|
85
|
-
}
|
86
|
+
return createClient({
|
87
|
+
account,
|
88
|
+
chain,
|
89
|
+
key,
|
90
|
+
name,
|
91
|
+
pollingInterval,
|
92
|
+
transport,
|
93
|
+
type: 'testClient',
|
94
|
+
})
|
95
|
+
.extend(() => ({ mode }))
|
96
|
+
.extend(testActions({ mode }))
|
86
97
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type { Account
|
4
|
-
import {
|
3
|
+
import type { Account } from '../accounts/types.js'
|
4
|
+
import type { ParseAccount } from '../types/account.js'
|
5
5
|
import type { Chain } from '../types/chain.js'
|
6
6
|
import type { WalletRpcSchema } from '../types/eip1193.js'
|
7
7
|
import type { Prettify } from '../types/utils.js'
|
@@ -17,26 +17,22 @@ export type WalletClientConfig<
|
|
17
17
|
| Address
|
18
18
|
| undefined,
|
19
19
|
> = Pick<
|
20
|
-
ClientConfig<TTransport, TChain>,
|
21
|
-
'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
22
|
-
>
|
23
|
-
/** The Account to use for the Wallet Client. This will be used for Actions that require an account as an argument. */
|
24
|
-
account?: TAccountOrAddress
|
25
|
-
}
|
20
|
+
ClientConfig<TTransport, TChain, TAccountOrAddress>,
|
21
|
+
'account' | 'chain' | 'key' | 'name' | 'pollingInterval' | 'transport'
|
22
|
+
>
|
26
23
|
|
27
24
|
export type WalletClient<
|
28
25
|
TTransport extends Transport = Transport,
|
29
26
|
TChain extends Chain | undefined = Chain | undefined,
|
30
27
|
TAccount extends Account | undefined = Account | undefined,
|
31
|
-
TIncludeActions extends boolean = true,
|
32
28
|
> = Prettify<
|
33
|
-
Client<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
Client<
|
30
|
+
TTransport,
|
31
|
+
TChain,
|
32
|
+
TAccount,
|
33
|
+
WalletRpcSchema,
|
34
|
+
WalletActions<TChain, TAccount>
|
35
|
+
>
|
40
36
|
>
|
41
37
|
|
42
38
|
/**
|
@@ -89,30 +85,15 @@ export function createWalletClient<
|
|
89
85
|
}: WalletClientConfig<TTransport, TChain, TAccountOrAddress>): WalletClient<
|
90
86
|
TTransport,
|
91
87
|
TChain,
|
92
|
-
TAccountOrAddress
|
93
|
-
? Prettify<JsonRpcAccount<TAccountOrAddress>>
|
94
|
-
: TAccountOrAddress,
|
95
|
-
true
|
88
|
+
ParseAccount<TAccountOrAddress>
|
96
89
|
> {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
account: account ? parseAccount(account) : undefined,
|
107
|
-
} as WalletClient<
|
108
|
-
TTransport,
|
109
|
-
TChain,
|
110
|
-
TAccountOrAddress extends Address
|
111
|
-
? JsonRpcAccount<TAccountOrAddress>
|
112
|
-
: TAccountOrAddress
|
113
|
-
>
|
114
|
-
return {
|
115
|
-
...client,
|
116
|
-
...walletActions(client),
|
117
|
-
}
|
90
|
+
return createClient({
|
91
|
+
account,
|
92
|
+
chain,
|
93
|
+
key,
|
94
|
+
name,
|
95
|
+
pollingInterval,
|
96
|
+
transport: (opts) => transport({ ...opts, retryCount: 0 }),
|
97
|
+
type: 'walletClient',
|
98
|
+
}).extend(walletActions)
|
118
99
|
}
|
@@ -196,6 +196,7 @@ import {
|
|
196
196
|
type WatchPendingTransactionsReturnType,
|
197
197
|
watchPendingTransactions,
|
198
198
|
} from '../../actions/public/watchPendingTransactions.js'
|
199
|
+
import type { Account } from '../../types/account.js'
|
199
200
|
import type { Chain } from '../../types/chain.js'
|
200
201
|
import type {
|
201
202
|
ContractFunctionConfig,
|
@@ -203,12 +204,13 @@ import type {
|
|
203
204
|
MaybeExtractEventArgsFromAbi,
|
204
205
|
} from '../../types/contract.js'
|
205
206
|
import type { FilterType } from '../../types/filter.js'
|
206
|
-
import type {
|
207
|
+
import type { Client } from '../createClient.js'
|
207
208
|
import type { Transport } from '../transports/createTransport.js'
|
208
209
|
|
209
210
|
export type PublicActions<
|
210
211
|
TTransport extends Transport = Transport,
|
211
212
|
TChain extends Chain | undefined = Chain | undefined,
|
213
|
+
TAccount extends Account | undefined = Account | undefined,
|
212
214
|
> = {
|
213
215
|
/**
|
214
216
|
* Executes a new message call immediately without submitting a transaction to the network.
|
@@ -375,7 +377,7 @@ export type PublicActions<
|
|
375
377
|
TAbi extends Abi | readonly unknown[],
|
376
378
|
TFunctionName extends string,
|
377
379
|
>(
|
378
|
-
args: EstimateContractGasParameters<TAbi, TFunctionName, TChain>,
|
380
|
+
args: EstimateContractGasParameters<TAbi, TFunctionName, TChain, TAccount>,
|
379
381
|
) => Promise<EstimateContractGasReturnType>
|
380
382
|
/**
|
381
383
|
* Estimates the gas necessary to complete a transaction without submitting it to the network.
|
@@ -401,7 +403,7 @@ export type PublicActions<
|
|
401
403
|
* })
|
402
404
|
*/
|
403
405
|
estimateGas: (
|
404
|
-
args: EstimateGasParameters<TChain>,
|
406
|
+
args: EstimateGasParameters<TChain, TAccount>,
|
405
407
|
) => Promise<EstimateGasReturnType>
|
406
408
|
/**
|
407
409
|
* Returns the balance of an address in wei.
|
@@ -1372,23 +1374,19 @@ export type PublicActions<
|
|
1372
1374
|
) => WatchPendingTransactionsReturnType
|
1373
1375
|
}
|
1374
1376
|
|
1375
|
-
export const publicActions
|
1377
|
+
export const publicActions = <
|
1376
1378
|
TTransport extends Transport = Transport,
|
1377
1379
|
TChain extends Chain | undefined = Chain | undefined,
|
1380
|
+
TAccount extends Account | undefined = Account | undefined,
|
1378
1381
|
>(
|
1379
|
-
client:
|
1380
|
-
)
|
1381
|
-
TTransport extends Transport = Transport,
|
1382
|
-
TChain extends Chain | undefined = Chain | undefined,
|
1383
|
-
>(
|
1384
|
-
client: PublicClient<TTransport, TChain>,
|
1385
|
-
): PublicActions<TTransport, TChain> => ({
|
1382
|
+
client: Client<TTransport, TChain, TAccount>,
|
1383
|
+
): PublicActions<TTransport, TChain, TAccount> => ({
|
1386
1384
|
call: (args) => call(client, args),
|
1387
1385
|
createBlockFilter: () => createBlockFilter(client),
|
1388
1386
|
createContractEventFilter: (args) => createContractEventFilter(client, args),
|
1389
1387
|
createEventFilter: (args) => createEventFilter(client, args),
|
1390
1388
|
createPendingTransactionFilter: () => createPendingTransactionFilter(client),
|
1391
|
-
estimateContractGas: (args) => estimateContractGas(client, args),
|
1389
|
+
estimateContractGas: (args) => estimateContractGas(client, args as any),
|
1392
1390
|
estimateGas: (args) => estimateGas(client, args),
|
1393
1391
|
getBalance: (args) => getBalance(client, args),
|
1394
1392
|
getBlock: (args) => getBlock(client, args),
|
@@ -84,9 +84,11 @@ import {
|
|
84
84
|
type StopImpersonatingAccountParameters,
|
85
85
|
stopImpersonatingAccount,
|
86
86
|
} from '../../actions/test/stopImpersonatingAccount.js'
|
87
|
+
import type { Account } from '../../types/account.js'
|
87
88
|
import type { Chain } from '../../types/chain.js'
|
88
89
|
import type { Quantity } from '../../types/rpc.js'
|
89
|
-
import type {
|
90
|
+
import type { Client } from '../createClient.js'
|
91
|
+
import type { TestClientMode } from '../createTestClient.js'
|
90
92
|
import type { Transport } from '../transports/createTransport.js'
|
91
93
|
|
92
94
|
export type TestActions = {
|
@@ -666,40 +668,58 @@ export type TestActions = {
|
|
666
668
|
) => Promise<void>
|
667
669
|
}
|
668
670
|
|
669
|
-
export function testActions<
|
670
|
-
|
671
|
-
):
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
671
|
+
export function testActions<TMode extends TestClientMode>({
|
672
|
+
mode,
|
673
|
+
}: { mode: TMode }): <
|
674
|
+
TTransport extends Transport = Transport,
|
675
|
+
TChain extends Chain | undefined = Chain | undefined,
|
676
|
+
TAccount extends Account | undefined = Account | undefined,
|
677
|
+
>(
|
678
|
+
client: Client<TTransport, TChain, TAccount>,
|
679
|
+
) => TestActions {
|
680
|
+
return <
|
681
|
+
TTransport extends Transport = Transport,
|
682
|
+
TChain extends Chain | undefined = Chain | undefined,
|
683
|
+
TAccount extends Account | undefined = Account | undefined,
|
684
|
+
>(
|
685
|
+
client_: Client<TTransport, TChain, TAccount>,
|
686
|
+
): TestActions => {
|
687
|
+
const client = client_.extend(() => ({
|
688
|
+
mode,
|
689
|
+
}))
|
690
|
+
return {
|
691
|
+
dropTransaction: (args) => dropTransaction(client, args),
|
692
|
+
getAutomine: () => getAutomine(client),
|
693
|
+
getTxpoolContent: () => getTxpoolContent(client),
|
694
|
+
getTxpoolStatus: () => getTxpoolStatus(client),
|
695
|
+
impersonateAccount: (args) => impersonateAccount(client, args),
|
696
|
+
increaseTime: (args) => increaseTime(client, args),
|
697
|
+
inspectTxpool: () => inspectTxpool(client),
|
698
|
+
mine: (args) => mine(client, args),
|
699
|
+
removeBlockTimestampInterval: () => removeBlockTimestampInterval(client),
|
700
|
+
reset: (args) => reset(client, args),
|
701
|
+
revert: (args) => revert(client, args),
|
702
|
+
sendUnsignedTransaction: (args) =>
|
703
|
+
sendUnsignedTransaction(client, args as any),
|
704
|
+
setAutomine: (args) => setAutomine(client, args),
|
705
|
+
setBalance: (args) => setBalance(client, args),
|
706
|
+
setBlockGasLimit: (args) => setBlockGasLimit(client, args),
|
707
|
+
setBlockTimestampInterval: (args) =>
|
708
|
+
setBlockTimestampInterval(client, args),
|
709
|
+
setCode: (args) => setCode(client, args),
|
710
|
+
setCoinbase: (args) => setCoinbase(client, args),
|
711
|
+
setIntervalMining: (args) => setIntervalMining(client, args),
|
712
|
+
setLoggingEnabled: (args) => setLoggingEnabled(client, args),
|
713
|
+
setMinGasPrice: (args) => setMinGasPrice(client, args),
|
714
|
+
setNextBlockBaseFeePerGas: (args) =>
|
715
|
+
setNextBlockBaseFeePerGas(client, args),
|
716
|
+
setNextBlockTimestamp: (args) => setNextBlockTimestamp(client, args),
|
717
|
+
setNonce: (args) => setNonce(client, args),
|
718
|
+
setRpcUrl: (args) => setRpcUrl(client, args),
|
719
|
+
setStorageAt: (args) => setStorageAt(client, args),
|
720
|
+
snapshot: () => snapshot(client),
|
721
|
+
stopImpersonatingAccount: (args) =>
|
722
|
+
stopImpersonatingAccount(client, args),
|
723
|
+
}
|
704
724
|
}
|
705
725
|
}
|
@@ -61,7 +61,7 @@ import {
|
|
61
61
|
writeContract,
|
62
62
|
} from '../../actions/wallet/writeContract.js'
|
63
63
|
import type { Chain } from '../../types/chain.js'
|
64
|
-
import type {
|
64
|
+
import type { Client } from '../createClient.js'
|
65
65
|
import type { Transport } from '../transports/createTransport.js'
|
66
66
|
|
67
67
|
export type WalletActions<
|
@@ -523,18 +523,12 @@ export type WalletActions<
|
|
523
523
|
) => Promise<WriteContractReturnType>
|
524
524
|
}
|
525
525
|
|
526
|
-
export const walletActions
|
526
|
+
export const walletActions = <
|
527
527
|
TTransport extends Transport,
|
528
528
|
TChain extends Chain | undefined = Chain | undefined,
|
529
529
|
TAccount extends Account | undefined = Account | undefined,
|
530
530
|
>(
|
531
|
-
client:
|
532
|
-
) => WalletActions<TChain, TAccount> = <
|
533
|
-
TTransport extends Transport,
|
534
|
-
TChain extends Chain | undefined = Chain | undefined,
|
535
|
-
TAccount extends Account | undefined = Account | undefined,
|
536
|
-
>(
|
537
|
-
client: WalletClient<TTransport, TChain, TAccount>,
|
531
|
+
client: Client<TTransport, TChain, TAccount>,
|
538
532
|
): WalletActions<TChain, TAccount> => ({
|
539
533
|
addChain: (args) => addChain(client, args),
|
540
534
|
deployContract: (args) => deployContract(client, args),
|