viem 0.0.0-portable-types-20230522163654 → 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 +3 -2
- 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 +8 -2
- 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 +3 -3
- 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/buildRequest.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/prepareRequest.js +1 -2
- package/dist/cjs/utils/transaction/prepareRequest.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 +29 -2
- 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 +111 -2
- 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 -51
- 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 +3 -1
- 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 -2
- 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/createBlockFilter.d.ts +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +9 -4
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +18 -6
- package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createPendingTransactionFilter.d.ts +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +5 -3
- package/dist/types/actions/public/estimateContractGas.d.ts.map +1 -1
- package/dist/types/actions/public/estimateGas.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 +8 -8
- 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/getTransaction.d.ts +1 -1
- package/dist/types/actions/public/getTransactionCount.d.ts +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
- package/dist/types/actions/public/multicall.d.ts +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/uninstallFilter.d.ts +3 -3
- 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 +11 -6
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +13 -7
- 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/test/setBlockTimestampInterval.d.ts +1 -1
- package/dist/types/actions/test/stopImpersonatingAccount.d.ts +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +1 -1
- package/dist/types/actions/wallet/signMessage.d.ts +4 -4
- 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/actions/wallet/writeContract.d.ts +3 -3
- 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 +4 -4
- package/dist/types/clients/createPublicClient.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +4 -4
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/createWalletClient.d.ts +4 -4
- package/dist/types/clients/createWalletClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +30 -30
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/test.d.ts +3 -3
- package/dist/types/clients/decorators/test.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +7 -9
- 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 +12 -8
- 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 +56 -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 +1048 -834
- 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/buildRequest.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/transaction/prepareRequest.d.ts +1 -1
- package/dist/types/utils/transaction/prepareRequest.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/createBlockFilter.ts +1 -1
- package/src/actions/public/createContractEventFilter.ts +22 -5
- package/src/actions/public/createEventFilter.ts +35 -14
- package/src/actions/public/createPendingTransactionFilter.ts +1 -1
- package/src/actions/public/estimateContractGas.ts +11 -5
- package/src/actions/public/estimateGas.ts +4 -3
- 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 +36 -11
- 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/getTransaction.ts +1 -1
- package/src/actions/public/getTransactionCount.ts +2 -2
- package/src/actions/public/getTransactionReceipt.ts +1 -1
- package/src/actions/public/multicall.ts +1 -1
- package/src/actions/public/readContract.ts +2 -2
- package/src/actions/public/simulateContract.ts +2 -2
- package/src/actions/public/uninstallFilter.ts +3 -3
- package/src/actions/public/verifyMessage.ts +2 -2
- package/src/actions/public/verifyTypedData.ts +18 -6
- package/src/actions/public/watchContractEvent.ts +17 -5
- package/src/actions/public/watchEvent.ts +19 -6
- 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/test/setBlockTimestampInterval.ts +1 -1
- package/src/actions/test/stopImpersonatingAccount.ts +1 -1
- package/src/actions/wallet/deployContract.ts +1 -1
- package/src/actions/wallet/sendTransaction.ts +1 -1
- package/src/actions/wallet/signMessage.ts +13 -6
- package/src/actions/wallet/signTypedData.ts +5 -5
- package/src/actions/wallet/writeContract.ts +3 -3
- package/src/chains.ts +123 -88
- package/src/clients/createClient.ts +13 -11
- package/src/clients/createPublicClient.ts +4 -5
- package/src/clients/createTestClient.ts +4 -5
- package/src/clients/createWalletClient.ts +4 -5
- package/src/clients/decorators/public.ts +65 -39
- package/src/clients/decorators/test.ts +6 -5
- package/src/clients/decorators/wallet.ts +8 -8
- 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 +43 -15
- package/src/errors/version.ts +1 -1
- package/src/index.ts +266 -247
- package/src/types/account.ts +9 -9
- package/src/types/contract.ts +33 -15
- package/src/types/eip1193.ts +1093 -839
- 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/buildRequest.ts +5 -1
- 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/prepareRequest.ts +1 -2
- 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
@@ -1,29 +1,33 @@
|
|
1
1
|
// Adapted from https://github.com/mafintosh/dns-packet
|
2
2
|
import type { ByteArray } from '../../types/misc.js'
|
3
3
|
import { stringToBytes } from '../encoding/toBytes.js'
|
4
|
+
import { encodeLabelhash } from './encodeLabelhash.js'
|
5
|
+
import { labelhash } from './labelhash.js'
|
4
6
|
|
5
7
|
/*
|
6
8
|
* @description Encodes a DNS packet into a ByteArray containing a UDP payload.
|
7
9
|
*/
|
8
10
|
export function packetToBytes(packet: string): ByteArray {
|
9
|
-
function length(value: string) {
|
10
|
-
if (value === '.' || value === '..') return 1
|
11
|
-
return stringToBytes(value.replace(/^\.|\.$/gm, '')).length + 2
|
12
|
-
}
|
13
|
-
|
14
|
-
const bytes = new Uint8Array(length(packet))
|
15
11
|
// strip leading and trailing `.`
|
16
12
|
const value = packet.replace(/^\.|\.$/gm, '')
|
17
|
-
if (
|
13
|
+
if (value.length === 0) return new Uint8Array(1)
|
14
|
+
|
15
|
+
const bytes = new Uint8Array(stringToBytes(value).byteLength + 2)
|
18
16
|
|
19
17
|
let offset = 0
|
20
18
|
const list = value.split('.')
|
21
19
|
for (let i = 0; i < list.length; i++) {
|
22
|
-
|
20
|
+
let encoded = stringToBytes(list[i])
|
21
|
+
// if the length is > 255, make the encoded label value a labelhash
|
22
|
+
// this is compatible with the universal resolver
|
23
|
+
if (encoded.byteLength > 255)
|
24
|
+
encoded = stringToBytes(encodeLabelhash(labelhash(list[i])))
|
23
25
|
bytes[offset] = encoded.length
|
24
26
|
bytes.set(encoded, offset + 1)
|
25
27
|
offset += encoded.length + 1
|
26
28
|
}
|
27
29
|
|
30
|
+
if (bytes.byteLength !== offset + 1) return bytes.slice(0, offset + 1)
|
31
|
+
|
28
32
|
return bytes
|
29
33
|
}
|
@@ -2,8 +2,9 @@ import type { PublicClient } from '../../clients/createPublicClient.js'
|
|
2
2
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
3
3
|
import type { OnResponseFn } from '../../clients/transports/fallback.js'
|
4
4
|
import type { Chain } from '../../types/chain.js'
|
5
|
-
import type {
|
5
|
+
import type { EIP1193RequestFn, PublicRpcSchema } from '../../types/eip1193.js'
|
6
6
|
import type { Hex } from '../../types/misc.js'
|
7
|
+
import type { Filter } from '../../types/utils.js'
|
7
8
|
|
8
9
|
type CreateFilterRequestScopeParameters = {
|
9
10
|
method:
|
@@ -11,8 +12,15 @@ type CreateFilterRequestScopeParameters = {
|
|
11
12
|
| 'eth_newPendingTransactionFilter'
|
12
13
|
| 'eth_newBlockFilter'
|
13
14
|
}
|
14
|
-
|
15
|
-
type
|
15
|
+
|
16
|
+
type FilterRpcSchema = Filter<
|
17
|
+
PublicRpcSchema,
|
18
|
+
{ Method: 'eth_getFilterLogs' | 'eth_getFilterChanges' }
|
19
|
+
>
|
20
|
+
|
21
|
+
type CreateFilterRequestScopeReturnType = (
|
22
|
+
id: Hex,
|
23
|
+
) => EIP1193RequestFn<FilterRpcSchema>
|
16
24
|
|
17
25
|
/**
|
18
26
|
* Scopes `request` to the filter ID. If the client is a fallback, it will
|
@@ -23,7 +31,7 @@ export function createFilterRequestScope<TChain extends Chain | undefined>(
|
|
23
31
|
client: PublicClient<Transport, TChain>,
|
24
32
|
{ method }: CreateFilterRequestScopeParameters,
|
25
33
|
): CreateFilterRequestScopeReturnType {
|
26
|
-
const requestMap: Record<Hex,
|
34
|
+
const requestMap: Record<Hex, EIP1193RequestFn> = {}
|
27
35
|
|
28
36
|
if (client.transport.type === 'fallback')
|
29
37
|
client.transport.onResponse?.(
|
@@ -9,10 +9,10 @@ export function formatLog(
|
|
9
9
|
...log,
|
10
10
|
blockHash: log.blockHash ? log.blockHash : null,
|
11
11
|
blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
|
12
|
-
logIndex: log.logIndex ?
|
12
|
+
logIndex: log.logIndex ? Number(log.logIndex) : null,
|
13
13
|
transactionHash: log.transactionHash ? log.transactionHash : null,
|
14
14
|
transactionIndex: log.transactionIndex
|
15
|
-
?
|
15
|
+
? Number(log.transactionIndex)
|
16
16
|
: null,
|
17
17
|
...(eventName ? { args, eventName } : {}),
|
18
18
|
} as Log
|
@@ -67,4 +67,6 @@ export function formatTransaction(transaction: Partial<RpcTransaction>) {
|
|
67
67
|
return transaction_ as Transaction
|
68
68
|
}
|
69
69
|
|
70
|
-
export const defineTransaction = defineFormatter({
|
70
|
+
export const defineTransaction = /*#__PURE__*/ defineFormatter({
|
71
|
+
format: formatTransaction,
|
72
|
+
})
|
@@ -62,11 +62,13 @@ export function formatTransactionReceipt(
|
|
62
62
|
? statuses[transactionReceipt.status]
|
63
63
|
: null,
|
64
64
|
type: transactionReceipt.type
|
65
|
-
? transactionType[
|
65
|
+
? transactionType[
|
66
|
+
transactionReceipt.type as keyof typeof transactionType
|
67
|
+
] || transactionReceipt.type
|
66
68
|
: null,
|
67
69
|
} as TransactionReceipt
|
68
70
|
}
|
69
71
|
|
70
|
-
export const defineTransactionReceipt = defineFormatter({
|
72
|
+
export const defineTransactionReceipt = /*#__PURE__*/ defineFormatter({
|
71
73
|
format: formatTransactionReceipt,
|
72
74
|
})
|
@@ -1,5 +1,9 @@
|
|
1
1
|
import type { EventDefinition } from '../../types/contract.js'
|
2
|
+
import type { AbiEvent } from 'abitype'
|
2
3
|
|
3
|
-
import { hashFunction } from './hashFunction.js'
|
4
|
+
import { hashAbiItem, hashFunction } from './hashFunction.js'
|
4
5
|
|
5
|
-
export const getEventSelector = (event: EventDefinition) =>
|
6
|
+
export const getEventSelector = (event: EventDefinition | AbiEvent) => {
|
7
|
+
if (typeof event === 'string') return hashFunction(event)
|
8
|
+
return hashAbiItem(event)
|
9
|
+
}
|
@@ -1,5 +1,9 @@
|
|
1
1
|
import { slice } from '../data/slice.js'
|
2
|
+
import type { AbiFunction } from 'abitype'
|
2
3
|
|
3
|
-
import { hashFunction } from './hashFunction.js'
|
4
|
+
import { hashAbiItem, hashFunction } from './hashFunction.js'
|
4
5
|
|
5
|
-
export const getFunctionSelector = (fn: string
|
6
|
+
export const getFunctionSelector = (fn: string | AbiFunction) => {
|
7
|
+
if (typeof fn === 'string') return slice(hashFunction(fn), 0, 4)
|
8
|
+
return slice(hashAbiItem(fn), 0, 4)
|
9
|
+
}
|
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
extractFunctionParams,
|
4
4
|
} from '../contract/extractFunctionParts.js'
|
5
5
|
import { toBytes } from '../encoding/toBytes.js'
|
6
|
+
import type { AbiEvent, AbiFunction } from 'abitype'
|
6
7
|
|
7
8
|
import { keccak256 } from './keccak256.js'
|
8
9
|
|
@@ -10,7 +11,10 @@ const hash = (value: string) => keccak256(toBytes(value))
|
|
10
11
|
|
11
12
|
export function hashFunction(def: string) {
|
12
13
|
const name = extractFunctionName(def)
|
13
|
-
const params = extractFunctionParams(def)
|
14
|
-
if (!params || params.length === 0) return hash(def.replace(/ /g, ''))
|
14
|
+
const params = extractFunctionParams(def) || []
|
15
15
|
return hash(`${name}(${params.map(({ type }) => type).join(',')})`)
|
16
16
|
}
|
17
|
+
|
18
|
+
export function hashAbiItem(def: AbiFunction | AbiEvent) {
|
19
|
+
return hash(`${def.name}(${def.inputs.map(({ type }) => type).join(',')})`)
|
20
|
+
}
|
package/src/utils/index.ts
CHANGED
@@ -17,8 +17,14 @@ export { arrayRegex, bytesRegex, integerRegex } from './regex.js'
|
|
17
17
|
|
18
18
|
export {
|
19
19
|
type HttpOptions,
|
20
|
+
type HttpReturnType,
|
21
|
+
type RpcRequest,
|
20
22
|
type RpcResponse,
|
21
23
|
type Socket,
|
24
|
+
type WebSocketAsyncOptions,
|
25
|
+
type WebSocketAsyncReturnType,
|
26
|
+
type WebSocketOptions,
|
27
|
+
type WebSocketReturnType,
|
22
28
|
getSocket,
|
23
29
|
rpc,
|
24
30
|
} from './rpc.js'
|
package/src/utils/observe.ts
CHANGED
@@ -3,11 +3,11 @@ import type { MaybePromise } from '../types/utils.js'
|
|
3
3
|
type Callback = ((...args: any[]) => any) | undefined
|
4
4
|
type Callbacks = Record<string, Callback>
|
5
5
|
|
6
|
-
export const listenersCache = new Map<
|
6
|
+
export const listenersCache = /*#__PURE__*/ new Map<
|
7
7
|
string,
|
8
8
|
{ id: number; fns: Callbacks }[]
|
9
9
|
>()
|
10
|
-
export const cleanupCache = new Map<string, () => void>()
|
10
|
+
export const cleanupCache = /*#__PURE__*/ new Map<string, () => void>()
|
11
11
|
|
12
12
|
type EmitFunction<TCallbacks extends Callbacks> = (
|
13
13
|
emit: TCallbacks,
|
@@ -29,7 +29,7 @@ export type CreateBatchSchedulerReturnType<
|
|
29
29
|
: (args: TParameters) => Promise<Resolved<TReturnType>>
|
30
30
|
}
|
31
31
|
|
32
|
-
const schedulerCache = new Map<number | string, SchedulerItem[]>()
|
32
|
+
const schedulerCache = /*#__PURE__*/ new Map<number | string, SchedulerItem[]>()
|
33
33
|
|
34
34
|
export function createBatchScheduler<
|
35
35
|
TParameters,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export const promiseCache = new Map()
|
2
|
-
export const responseCache = new Map()
|
1
|
+
export const promiseCache = /*#__PURE__*/ new Map()
|
2
|
+
export const responseCache = /*#__PURE__*/ new Map()
|
3
3
|
|
4
4
|
export function getCache<TData>(cacheKey: string) {
|
5
5
|
const buildCache = <TData>(cacheKey: string, cache: Map<string, TData>) => ({
|
@@ -59,15 +59,17 @@ export async function withCache<TData>(
|
|
59
59
|
cache.promise.set(promise)
|
60
60
|
}
|
61
61
|
|
62
|
-
|
62
|
+
try {
|
63
|
+
const data = await promise
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
// Store the response in the cache so that subsequent invocations
|
66
|
+
// will return the same response.
|
67
|
+
cache.response.set({ created: new Date(), data })
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
return data
|
70
|
+
} finally {
|
71
|
+
// Clear the promise cache so that subsequent invocations will
|
72
|
+
// invoke the promise again.
|
73
|
+
cache.promise.clear()
|
74
|
+
}
|
73
75
|
}
|
package/src/utils/rpc.ts
CHANGED
@@ -2,7 +2,6 @@ import type { MessageEvent, WebSocket } from 'isomorphic-ws'
|
|
2
2
|
|
3
3
|
import {
|
4
4
|
HttpRequestError,
|
5
|
-
RpcRequestError,
|
6
5
|
TimeoutError,
|
7
6
|
WebSocketRequestError,
|
8
7
|
} from '../errors/request.js'
|
@@ -41,7 +40,7 @@ type Subscription<TResult, TError> = {
|
|
41
40
|
)
|
42
41
|
}
|
43
42
|
|
44
|
-
type RpcRequest = { method: string; params?: any }
|
43
|
+
export type RpcRequest = { method: string; params?: any }
|
45
44
|
|
46
45
|
export type RpcResponse<TResult = any, TError = any> = {
|
47
46
|
jsonrpc: `${number}`
|
@@ -55,26 +54,39 @@ export type RpcResponse<TResult = any, TError = any> = {
|
|
55
54
|
///////////////////////////////////////////////////
|
56
55
|
// HTTP
|
57
56
|
|
58
|
-
export type HttpOptions =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
57
|
+
export type HttpOptions<TBody extends RpcRequest | RpcRequest[] = RpcRequest,> =
|
58
|
+
{
|
59
|
+
// The RPC request body.
|
60
|
+
body: TBody
|
61
|
+
// Request configuration to pass to `fetch`.
|
62
|
+
fetchOptions?: Omit<RequestInit, 'body'>
|
63
|
+
// The timeout (in ms) for the request.
|
64
|
+
timeout?: number
|
65
|
+
}
|
66
|
+
|
67
|
+
export type HttpReturnType<
|
68
|
+
TBody extends RpcRequest | RpcRequest[] = RpcRequest,
|
69
|
+
> = TBody extends RpcRequest[] ? RpcResponse[] : RpcResponse
|
66
70
|
|
67
|
-
async function http(
|
71
|
+
async function http<TBody extends RpcRequest | RpcRequest[]>(
|
68
72
|
url: string,
|
69
|
-
{ body, fetchOptions = {}, timeout = 10_000 }: HttpOptions
|
70
|
-
) {
|
73
|
+
{ body, fetchOptions = {}, timeout = 10_000 }: HttpOptions<TBody>,
|
74
|
+
): Promise<HttpReturnType<TBody>> {
|
71
75
|
const { headers, method, signal: signal_ } = fetchOptions
|
72
76
|
try {
|
73
77
|
const response = await withTimeout(
|
74
78
|
async ({ signal }) => {
|
75
79
|
const response = await fetch(url, {
|
76
80
|
...fetchOptions,
|
77
|
-
body:
|
81
|
+
body: Array.isArray(body)
|
82
|
+
? stringify(
|
83
|
+
body.map((body) => ({
|
84
|
+
jsonrpc: '2.0',
|
85
|
+
id: id++,
|
86
|
+
...body,
|
87
|
+
})),
|
88
|
+
)
|
89
|
+
: stringify({ jsonrpc: '2.0', id: id++, ...body }),
|
78
90
|
headers: {
|
79
91
|
...headers,
|
80
92
|
'Content-Type': 'application/json',
|
@@ -108,13 +120,9 @@ async function http(
|
|
108
120
|
})
|
109
121
|
}
|
110
122
|
|
111
|
-
|
112
|
-
throw new RpcRequestError({ body, error: data.error, url })
|
113
|
-
}
|
114
|
-
return data as RpcResponse
|
123
|
+
return data
|
115
124
|
} catch (err) {
|
116
125
|
if (err instanceof HttpRequestError) throw err
|
117
|
-
if (err instanceof RpcRequestError) throw err
|
118
126
|
if (err instanceof TimeoutError) throw err
|
119
127
|
throw new HttpRequestError({
|
120
128
|
body,
|
@@ -136,7 +144,7 @@ export type Socket = WebSocket & {
|
|
136
144
|
subscriptions: CallbackMap
|
137
145
|
}
|
138
146
|
|
139
|
-
const sockets = new Map<string, Socket>()
|
147
|
+
const sockets = /*#__PURE__*/ new Map<string, Socket>()
|
140
148
|
|
141
149
|
export async function getSocket(url_: string) {
|
142
150
|
const url = new URL(url_)
|
@@ -213,21 +221,19 @@ export async function getSocket(url_: string) {
|
|
213
221
|
return socket_
|
214
222
|
}
|
215
223
|
|
224
|
+
export type WebSocketOptions = {
|
225
|
+
/** The RPC request body. */
|
226
|
+
body: RpcRequest
|
227
|
+
/** The callback to invoke on response. */
|
228
|
+
onResponse?: (message: RpcResponse) => void
|
229
|
+
}
|
230
|
+
|
231
|
+
export type WebSocketReturnType = Socket
|
232
|
+
|
216
233
|
function webSocket(
|
217
234
|
socket: Socket,
|
218
|
-
{
|
219
|
-
|
220
|
-
onData,
|
221
|
-
onError,
|
222
|
-
}: {
|
223
|
-
// The RPC request body.
|
224
|
-
body: RpcRequest
|
225
|
-
// The callback to invoke when the request is successful.
|
226
|
-
onData?: (message: RpcResponse) => void
|
227
|
-
// The callback to invoke if the request errors.
|
228
|
-
onError?: (message: RpcResponse['error']) => void
|
229
|
-
},
|
230
|
-
) {
|
235
|
+
{ body, onResponse }: WebSocketOptions,
|
236
|
+
): WebSocketReturnType {
|
231
237
|
if (
|
232
238
|
socket.readyState === socket.CLOSED ||
|
233
239
|
socket.readyState === socket.CLOSING
|
@@ -245,13 +251,7 @@ function webSocket(
|
|
245
251
|
|
246
252
|
if (typeof message.id === 'number' && id_ !== message.id) return
|
247
253
|
|
248
|
-
|
249
|
-
onError?.(
|
250
|
-
new RpcRequestError({ body, error: message.error, url: socket.url }),
|
251
|
-
)
|
252
|
-
} else {
|
253
|
-
onData?.(message)
|
254
|
-
}
|
254
|
+
onResponse?.(message)
|
255
255
|
|
256
256
|
// If we are subscribing to a topic, we want to set up a listener for incoming
|
257
257
|
// messages.
|
@@ -271,25 +271,25 @@ function webSocket(
|
|
271
271
|
return socket
|
272
272
|
}
|
273
273
|
|
274
|
+
export type WebSocketAsyncOptions = {
|
275
|
+
/** The RPC request body. */
|
276
|
+
body: RpcRequest
|
277
|
+
/** The timeout (in ms) for the request. */
|
278
|
+
timeout?: number
|
279
|
+
}
|
280
|
+
|
281
|
+
export type WebSocketAsyncReturnType = RpcResponse
|
282
|
+
|
274
283
|
async function webSocketAsync(
|
275
284
|
socket: Socket,
|
276
|
-
{
|
277
|
-
|
278
|
-
timeout = 10_000,
|
279
|
-
}: {
|
280
|
-
// The RPC request body.
|
281
|
-
body: RpcRequest
|
282
|
-
// The timeout (in ms) for the request.
|
283
|
-
timeout?: number
|
284
|
-
},
|
285
|
-
) {
|
285
|
+
{ body, timeout = 10_000 }: WebSocketAsyncOptions,
|
286
|
+
): Promise<WebSocketAsyncReturnType> {
|
286
287
|
return withTimeout(
|
287
288
|
() =>
|
288
|
-
new Promise<RpcResponse>((
|
289
|
+
new Promise<RpcResponse>((onResponse) =>
|
289
290
|
rpc.webSocket(socket, {
|
290
291
|
body,
|
291
|
-
|
292
|
-
onError,
|
292
|
+
onResponse,
|
293
293
|
}),
|
294
294
|
),
|
295
295
|
{
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { ByteArray, Hex } from '../../types/misc.js'
|
1
|
+
import type { ByteArray, Hex, SignableMessage } from '../../types/misc.js'
|
2
2
|
import { concat } from '../data/concat.js'
|
3
|
-
import { stringToBytes } from '../encoding/toBytes.js'
|
3
|
+
import { stringToBytes, toBytes } from '../encoding/toBytes.js'
|
4
4
|
import { keccak256 } from '../hash/keccak256.js'
|
5
5
|
|
6
6
|
type To = 'hex' | 'bytes'
|
@@ -10,10 +10,14 @@ export type HashMessage<TTo extends To> =
|
|
10
10
|
| (TTo extends 'hex' ? Hex : never)
|
11
11
|
|
12
12
|
export function hashMessage<TTo extends To = 'hex'>(
|
13
|
-
message:
|
13
|
+
message: SignableMessage,
|
14
14
|
to_?: TTo,
|
15
15
|
): HashMessage<TTo> {
|
16
|
-
const messageBytes =
|
16
|
+
const messageBytes = (() => {
|
17
|
+
if (typeof message === 'string') return stringToBytes(message)
|
18
|
+
if (message.raw instanceof Uint8Array) return message.raw
|
19
|
+
return toBytes(message.raw)
|
20
|
+
})()
|
17
21
|
const prefixBytes = stringToBytes(
|
18
22
|
`\x19Ethereum Signed Message:\n${messageBytes.length}`,
|
19
23
|
)
|
@@ -16,15 +16,15 @@ type MessageTypeProperty = {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
export type HashTypedDataParameters<
|
19
|
-
TTypedData extends TypedData |
|
20
|
-
TPrimaryType extends
|
19
|
+
TTypedData extends TypedData | Record<string, unknown> = TypedData,
|
20
|
+
TPrimaryType extends keyof TTypedData = keyof TTypedData,
|
21
21
|
> = TypedDataDefinition<TTypedData, TPrimaryType>
|
22
22
|
|
23
23
|
export type HashTypedDataReturnType = Hex
|
24
24
|
|
25
25
|
export function hashTypedData<
|
26
|
-
TTypedData extends TypedData |
|
27
|
-
TPrimaryType extends
|
26
|
+
const TTypedData extends TypedData | Record<string, unknown>, // `Record<string, unknown>` allows for non-const asserted types
|
27
|
+
TPrimaryType extends keyof TTypedData,
|
28
28
|
>({
|
29
29
|
domain: domain_,
|
30
30
|
message,
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type { ByteArray, Hex } from '../../types/misc.js'
|
3
|
+
import type { ByteArray, Hex, SignableMessage } from '../../types/misc.js'
|
4
4
|
|
5
5
|
import { hashMessage } from './hashMessage.js'
|
6
6
|
import { recoverAddress } from './recoverAddress.js'
|
7
7
|
|
8
8
|
export type RecoverMessageAddressParameters = {
|
9
|
-
message:
|
9
|
+
message: SignableMessage
|
10
10
|
signature: Hex | ByteArray
|
11
11
|
}
|
12
12
|
export type RecoverMessageAddressReturnType = Address
|
@@ -7,16 +7,16 @@ import { hashTypedData } from './hashTypedData.js'
|
|
7
7
|
import { recoverAddress } from './recoverAddress.js'
|
8
8
|
|
9
9
|
export type RecoverTypedDataAddressParameters<
|
10
|
-
TTypedData extends TypedData |
|
11
|
-
TPrimaryType extends
|
10
|
+
TTypedData extends TypedData | Record<string, unknown> = TypedData,
|
11
|
+
TPrimaryType extends keyof TTypedData = keyof TTypedData,
|
12
12
|
> = TypedDataDefinition<TTypedData, TPrimaryType> & {
|
13
13
|
signature: Hex | ByteArray
|
14
14
|
}
|
15
15
|
export type RecoverTypedDataAddressReturnType = Address
|
16
16
|
|
17
17
|
export async function recoverTypedDataAddress<
|
18
|
-
TTypedData extends TypedData |
|
19
|
-
TPrimaryType extends
|
18
|
+
const TTypedData extends TypedData | Record<string, unknown>, // `Record<string, unknown>` allows for non-const asserted types
|
19
|
+
TPrimaryType extends keyof TTypedData,
|
20
20
|
>({
|
21
21
|
domain,
|
22
22
|
message,
|
@@ -11,8 +11,8 @@ import {
|
|
11
11
|
} from './recoverTypedDataAddress.js'
|
12
12
|
|
13
13
|
export type VerifyTypedDataParameters<
|
14
|
-
TTypedData extends TypedData |
|
15
|
-
TPrimaryType extends
|
14
|
+
TTypedData extends TypedData | Record<string, unknown> = TypedData,
|
15
|
+
TPrimaryType extends keyof TTypedData = keyof TTypedData,
|
16
16
|
> = TypedDataDefinition<TTypedData, TPrimaryType> & {
|
17
17
|
/** The address to verify the typed data for. */
|
18
18
|
address: Address
|
@@ -35,8 +35,8 @@ export type VerifyTypedDataReturnType = boolean
|
|
35
35
|
* @returns Whether or not the signature is valid. {@link VerifyTypedDataReturnType}
|
36
36
|
*/
|
37
37
|
export async function verifyTypedData<
|
38
|
-
TTypedData extends TypedData |
|
39
|
-
TPrimaryType extends
|
38
|
+
const TTypedData extends TypedData | Record<string, unknown>, // `Record<string, unknown>` allows for non-const asserted types
|
39
|
+
TPrimaryType extends keyof TTypedData,
|
40
40
|
>({
|
41
41
|
address,
|
42
42
|
domain,
|
@@ -1,24 +1,25 @@
|
|
1
1
|
import { InvalidSerializableTransactionError } from '../../errors/transaction.js'
|
2
2
|
import type {
|
3
|
-
AccessList,
|
4
3
|
TransactionSerializable,
|
4
|
+
TransactionSerializableEIP1559,
|
5
|
+
TransactionSerializableEIP2930,
|
6
|
+
TransactionSerializableGeneric,
|
7
|
+
TransactionSerializableLegacy,
|
5
8
|
} from '../../types/transaction.js'
|
6
9
|
|
7
10
|
export type GetTransactionType<
|
8
11
|
TTransactionSerializable extends TransactionSerializable = TransactionSerializable,
|
9
12
|
> =
|
10
|
-
| (TTransactionSerializable
|
11
|
-
? '
|
13
|
+
| (TTransactionSerializable extends TransactionSerializableLegacy
|
14
|
+
? 'legacy'
|
12
15
|
: never)
|
13
|
-
| (TTransactionSerializable
|
16
|
+
| (TTransactionSerializable extends TransactionSerializableEIP1559
|
14
17
|
? 'eip1559'
|
15
18
|
: never)
|
16
|
-
| (TTransactionSerializable
|
17
|
-
?
|
18
|
-
? 'eip2930'
|
19
|
-
: 'legacy'
|
19
|
+
| (TTransactionSerializable extends TransactionSerializableEIP2930
|
20
|
+
? 'eip2930'
|
20
21
|
: never)
|
21
|
-
| (TTransactionSerializable
|
22
|
+
| (TTransactionSerializable extends TransactionSerializableGeneric
|
22
23
|
? TTransactionSerializable['type']
|
23
24
|
: never)
|
24
25
|
|
@@ -17,7 +17,6 @@ import { AccountNotFoundError } from '../../errors/account.js'
|
|
17
17
|
import { BaseError } from '../../errors/base.js'
|
18
18
|
import type { GetAccountParameter } from '../../types/account.js'
|
19
19
|
import type { Chain } from '../../types/chain.js'
|
20
|
-
import { parseGwei } from '../unit/parseGwei.js'
|
21
20
|
|
22
21
|
import { assertRequest } from './assertRequest.js'
|
23
22
|
|
@@ -43,7 +42,7 @@ export type PrepareRequestReturnType<
|
|
43
42
|
nonce: SendTransactionParameters['nonce']
|
44
43
|
}
|
45
44
|
|
46
|
-
export const defaultTip =
|
45
|
+
export const defaultTip = 1_500_000_000n // 1.5 gwei
|
47
46
|
|
48
47
|
export async function prepareRequest<
|
49
48
|
TChain extends Chain | undefined,
|
@@ -49,18 +49,18 @@ export function serializeTransaction<
|
|
49
49
|
return serializeTransactionEIP1559(
|
50
50
|
transaction as TransactionSerializableEIP1559,
|
51
51
|
signature,
|
52
|
-
) as SerializedTransactionReturnType
|
52
|
+
) as SerializedTransactionReturnType<TTransactionSerializable>
|
53
53
|
|
54
54
|
if (type === 'eip2930')
|
55
55
|
return serializeTransactionEIP2930(
|
56
56
|
transaction as TransactionSerializableEIP2930,
|
57
57
|
signature,
|
58
|
-
) as SerializedTransactionReturnType
|
58
|
+
) as SerializedTransactionReturnType<TTransactionSerializable>
|
59
59
|
|
60
60
|
return serializeTransactionLegacy(
|
61
61
|
transaction as TransactionSerializableLegacy,
|
62
62
|
signature,
|
63
|
-
) as SerializedTransactionReturnType
|
63
|
+
) as SerializedTransactionReturnType<TTransactionSerializable>
|
64
64
|
}
|
65
65
|
|
66
66
|
function serializeTransactionEIP1559(
|
package/src/utils/typedData.ts
CHANGED
@@ -11,8 +11,8 @@ import { numberToHex } from './encoding/toHex.js'
|
|
11
11
|
import { bytesRegex, integerRegex } from './regex.js'
|
12
12
|
|
13
13
|
export function validateTypedData<
|
14
|
-
TTypedData extends TypedData |
|
15
|
-
TPrimaryType extends
|
14
|
+
const TTypedData extends TypedData | Record<string, unknown>, // `Record<string, unknown>` allows for non-const asserted types
|
15
|
+
TPrimaryType extends keyof TTypedData,
|
16
16
|
>({
|
17
17
|
domain,
|
18
18
|
message,
|
@@ -68,7 +68,7 @@ export function validateTypedData<
|
|
68
68
|
|
69
69
|
if (primaryType !== 'EIP712Domain') {
|
70
70
|
// Validate message types.
|
71
|
-
const type = types[primaryType]
|
71
|
+
const type = types[primaryType as string]
|
72
72
|
validateData(type, message as Record<string, unknown>)
|
73
73
|
}
|
74
74
|
}
|