viem 0.0.0-w-20230725184008 → 0.0.0-w-20230810155401
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/chains/utils/package.json +5 -0
- package/dist/cjs/accounts/index.js +6 -2
- package/dist/cjs/accounts/index.js.map +1 -1
- package/dist/cjs/accounts/utils/privateKeyToAddress.js +12 -0
- package/dist/cjs/accounts/utils/privateKeyToAddress.js.map +1 -0
- package/dist/cjs/accounts/utils/signMessage.js +1 -1
- package/dist/cjs/accounts/utils/signMessage.js.map +1 -1
- package/dist/cjs/accounts/utils/signTransaction.js.map +1 -1
- package/dist/cjs/accounts/utils/signTypedData.js +1 -1
- package/dist/cjs/accounts/utils/signTypedData.js.map +1 -1
- package/dist/cjs/actions/ens/getEnsAddress.js +18 -13
- package/dist/cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/cjs/actions/index.js.map +1 -1
- package/dist/cjs/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/cjs/actions/public/createEventFilter.js +16 -8
- 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 -1
- package/dist/cjs/actions/public/estimateGas.js.map +1 -1
- package/dist/cjs/actions/public/getBlock.js +3 -1
- package/dist/cjs/actions/public/getBlock.js.map +1 -1
- package/dist/cjs/actions/public/getBlockNumber.js +2 -2
- package/dist/cjs/actions/public/getBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/getFilterChanges.js.map +1 -1
- package/dist/cjs/actions/public/getFilterLogs.js +1 -1
- package/dist/cjs/actions/public/getFilterLogs.js.map +1 -1
- package/dist/cjs/actions/public/getLogs.js +16 -10
- package/dist/cjs/actions/public/getLogs.js.map +1 -1
- package/dist/cjs/actions/public/getTransaction.js +2 -1
- package/dist/cjs/actions/public/getTransaction.js.map +1 -1
- package/dist/cjs/actions/public/watchBlockNumber.js +1 -1
- package/dist/cjs/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/cjs/actions/public/watchBlocks.js +2 -1
- package/dist/cjs/actions/public/watchBlocks.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +135 -65
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +138 -59
- package/dist/cjs/actions/public/watchEvent.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
- package/dist/cjs/chains/{formatters/celo.js → celo/formatters.js} +1 -1
- package/dist/cjs/chains/celo/formatters.js.map +1 -0
- package/dist/cjs/chains/{serializers/celo.js → celo/serializers.js} +1 -1
- package/dist/cjs/chains/celo/serializers.js.map +1 -0
- package/dist/cjs/{types/formatter.js → chains/celo/types.js} +1 -1
- package/dist/cjs/chains/celo/types.js.map +1 -0
- package/dist/cjs/chains/index.js +30 -15
- package/dist/cjs/chains/index.js.map +1 -1
- package/dist/cjs/chains/optimism/fees.js +7 -0
- package/dist/cjs/chains/optimism/fees.js.map +1 -0
- package/dist/cjs/chains/{formatters/optimism.js → optimism/formatters.js} +13 -1
- package/dist/cjs/chains/optimism/formatters.js.map +1 -0
- package/dist/cjs/{types/serializer.js → chains/optimism/types.js} +1 -1
- package/dist/cjs/chains/optimism/types.js.map +1 -0
- package/dist/cjs/chains/utils.js +11 -0
- package/dist/cjs/chains/utils.js.map +1 -0
- package/dist/cjs/clients/createClient.js +2 -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/constants/abis.js +12 -2
- package/dist/cjs/constants/abis.js.map +1 -1
- package/dist/cjs/constants/number.js +101 -0
- package/dist/cjs/constants/number.js.map +1 -0
- package/dist/cjs/contract.js.map +1 -1
- package/dist/cjs/errors/abi.js +8 -1
- package/dist/cjs/errors/abi.js.map +1 -1
- package/dist/cjs/errors/contract.js +56 -32
- package/dist/cjs/errors/contract.js.map +1 -1
- package/dist/cjs/errors/node.js +1 -1
- package/dist/cjs/errors/node.js.map +1 -1
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/errors/version.js.map +1 -1
- package/dist/cjs/index.js +110 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/public.js.map +1 -1
- package/dist/cjs/utils/abi/encodeAbiParameters.js +11 -14
- package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/encodePacked.js +2 -0
- package/dist/cjs/utils/abi/encodePacked.js.map +1 -1
- package/dist/cjs/utils/chain.js +5 -3
- package/dist/cjs/utils/chain.js.map +1 -1
- package/dist/cjs/utils/formatters/block.js.map +1 -1
- package/dist/cjs/utils/formatters/extract.js.map +1 -1
- package/dist/cjs/utils/formatters/formatter.js +1 -0
- package/dist/cjs/utils/formatters/formatter.js.map +1 -1
- package/dist/cjs/utils/formatters/transaction.js.map +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/hashFunction.js +3 -2
- package/dist/cjs/utils/hash/hashFunction.js.map +1 -1
- package/dist/cjs/utils/promise/withCache.js +3 -3
- package/dist/cjs/utils/promise/withCache.js.map +1 -1
- package/dist/cjs/utils/signature/hexToSignature.js +12 -0
- package/dist/cjs/utils/signature/hexToSignature.js.map +1 -0
- package/dist/cjs/utils/signature/signatureToHex.js.map +1 -0
- package/dist/cjs/utils/transaction/prepareRequest.js +19 -12
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/cjs/utils/unit/parseUnits.js +2 -1
- package/dist/cjs/utils/unit/parseUnits.js.map +1 -1
- package/dist/esm/accounts/index.js +3 -1
- package/dist/esm/accounts/index.js.map +1 -1
- package/dist/esm/accounts/utils/privateKeyToAddress.js +15 -0
- package/dist/esm/accounts/utils/privateKeyToAddress.js.map +1 -0
- package/dist/esm/accounts/utils/signMessage.js +1 -1
- package/dist/esm/accounts/utils/signMessage.js.map +1 -1
- package/dist/esm/accounts/utils/signTransaction.js.map +1 -1
- package/dist/esm/accounts/utils/signTypedData.js +1 -1
- package/dist/esm/accounts/utils/signTypedData.js.map +1 -1
- package/dist/esm/actions/ens/getEnsAddress.js +19 -14
- package/dist/esm/actions/ens/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/index.js.map +1 -1
- package/dist/esm/actions/public/createContractEventFilter.js.map +1 -1
- package/dist/esm/actions/public/createEventFilter.js +16 -8
- package/dist/esm/actions/public/createEventFilter.js.map +1 -1
- package/dist/esm/actions/public/estimateContractGas.js +1 -1
- package/dist/esm/actions/public/estimateContractGas.js.map +1 -1
- package/dist/esm/actions/public/estimateGas.js +4 -2
- package/dist/esm/actions/public/estimateGas.js.map +1 -1
- package/dist/esm/actions/public/getBlock.js +3 -1
- package/dist/esm/actions/public/getBlock.js.map +1 -1
- package/dist/esm/actions/public/getBlockNumber.js +2 -2
- package/dist/esm/actions/public/getBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/getFilterChanges.js.map +1 -1
- package/dist/esm/actions/public/getFilterLogs.js +1 -1
- package/dist/esm/actions/public/getFilterLogs.js.map +1 -1
- package/dist/esm/actions/public/getLogs.js +16 -10
- package/dist/esm/actions/public/getLogs.js.map +1 -1
- package/dist/esm/actions/public/getTransaction.js +2 -1
- package/dist/esm/actions/public/getTransaction.js.map +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js +1 -1
- package/dist/esm/actions/public/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/public/watchBlocks.js +2 -1
- package/dist/esm/actions/public/watchBlocks.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +145 -71
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +148 -65
- package/dist/esm/actions/public/watchEvent.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/chains/{formatters/celo.js → celo/formatters.js} +2 -2
- package/dist/esm/chains/celo/formatters.js.map +1 -0
- package/dist/esm/chains/{serializers/celo.js → celo/serializers.js} +1 -1
- package/dist/esm/chains/celo/serializers.js.map +1 -0
- package/dist/esm/chains/celo/types.js +2 -0
- package/dist/esm/chains/celo/types.js.map +1 -0
- package/dist/esm/chains/index.js +22 -7
- package/dist/esm/chains/index.js.map +1 -1
- package/dist/esm/chains/optimism/fees.js +4 -0
- package/dist/esm/chains/optimism/fees.js.map +1 -0
- package/dist/esm/chains/{formatters/optimism.js → optimism/formatters.js} +15 -2
- package/dist/esm/chains/optimism/formatters.js.map +1 -0
- package/dist/esm/chains/optimism/types.js +2 -0
- package/dist/esm/chains/optimism/types.js.map +1 -0
- package/dist/esm/chains/utils.js +4 -0
- package/dist/esm/chains/utils.js.map +1 -0
- package/dist/esm/clients/createClient.js +2 -1
- package/dist/esm/clients/createClient.js.map +1 -1
- package/dist/esm/clients/createPublicClient.js.map +1 -1
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/createWalletClient.js.map +1 -1
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/constants/abis.js +11 -1
- package/dist/esm/constants/abis.js.map +1 -1
- package/dist/esm/constants/number.js +97 -0
- package/dist/esm/constants/number.js.map +1 -0
- package/dist/esm/contract.js.map +1 -1
- package/dist/esm/errors/abi.js +8 -1
- package/dist/esm/errors/abi.js.map +1 -1
- package/dist/esm/errors/contract.js +56 -32
- package/dist/esm/errors/contract.js.map +1 -1
- package/dist/esm/errors/node.js +1 -1
- package/dist/esm/errors/node.js.map +1 -1
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/errors/version.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/public.js.map +1 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js +13 -14
- package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/encodePacked.js +2 -0
- package/dist/esm/utils/abi/encodePacked.js.map +1 -1
- package/dist/esm/utils/chain.js +5 -3
- package/dist/esm/utils/chain.js.map +1 -1
- package/dist/esm/utils/formatters/block.js.map +1 -1
- package/dist/esm/utils/formatters/extract.js.map +1 -1
- package/dist/esm/utils/formatters/formatter.js +1 -0
- package/dist/esm/utils/formatters/formatter.js.map +1 -1
- package/dist/esm/utils/formatters/transaction.js.map +1 -1
- package/dist/esm/utils/formatters/transactionReceipt.js.map +1 -1
- package/dist/esm/utils/formatters/transactionRequest.js.map +1 -1
- package/dist/esm/utils/hash/hashFunction.js +3 -2
- package/dist/esm/utils/hash/hashFunction.js.map +1 -1
- package/dist/esm/utils/promise/withCache.js +3 -3
- package/dist/esm/utils/promise/withCache.js.map +1 -1
- package/dist/esm/utils/signature/hexToSignature.js +18 -0
- package/dist/esm/utils/signature/hexToSignature.js.map +1 -0
- package/dist/esm/utils/signature/signatureToHex.js +21 -0
- package/dist/esm/utils/signature/signatureToHex.js.map +1 -0
- package/dist/esm/utils/transaction/prepareRequest.js +20 -13
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/utils/unit/parseUnits.js +2 -1
- package/dist/esm/utils/unit/parseUnits.js.map +1 -1
- package/dist/types/accounts/index.d.ts +3 -1
- package/dist/types/accounts/index.d.ts.map +1 -1
- package/dist/types/accounts/utils/privateKeyToAddress.d.ts +11 -0
- package/dist/types/accounts/utils/privateKeyToAddress.d.ts.map +1 -0
- package/dist/types/accounts/utils/signTransaction.d.ts +2 -2
- package/dist/types/accounts/utils/signTransaction.d.ts.map +1 -1
- package/dist/types/actions/ens/getEnsAddress.d.ts +3 -1
- package/dist/types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/index.d.ts +5 -1
- package/dist/types/actions/index.d.ts.map +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +5 -5
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +20 -7
- package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/public/getBlock.d.ts +5 -5
- package/dist/types/actions/public/getBlock.d.ts.map +1 -1
- package/dist/types/actions/public/getBlockNumber.d.ts +4 -2
- package/dist/types/actions/public/getBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts +5 -8
- package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts +5 -4
- package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts +17 -6
- package/dist/types/actions/public/getLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getTransaction.d.ts +4 -4
- package/dist/types/actions/public/getTransaction.d.ts.map +1 -1
- package/dist/types/actions/public/getTransactionReceipt.d.ts +1 -1
- package/dist/types/actions/public/getTransactionReceipt.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/watchBlocks.d.ts +10 -10
- package/dist/types/actions/public/watchBlocks.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +35 -9
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +48 -14
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +1 -1
- package/dist/types/actions/wallet/deployContract.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/writeContract.d.ts +4 -2
- package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
- package/dist/types/chains/{formatters/celo.d.ts → celo/formatters.d.ts} +30 -85
- package/dist/types/chains/celo/formatters.d.ts.map +1 -0
- package/dist/types/chains/{serializers/celo.d.ts → celo/serializers.d.ts} +4 -4
- package/dist/types/chains/celo/serializers.d.ts.map +1 -0
- package/dist/types/chains/celo/types.d.ts +60 -0
- package/dist/types/chains/celo/types.d.ts.map +1 -0
- package/dist/types/chains/index.d.ts +2527 -2722
- package/dist/types/chains/index.d.ts.map +1 -1
- package/dist/types/chains/optimism/fees.d.ts +4 -0
- package/dist/types/chains/optimism/fees.d.ts.map +1 -0
- package/dist/types/chains/{formatters/optimism.d.ts → optimism/formatters.d.ts} +79 -54
- package/dist/types/chains/optimism/formatters.d.ts.map +1 -0
- package/dist/types/chains/optimism/types.d.ts +53 -0
- package/dist/types/chains/optimism/types.d.ts.map +1 -0
- package/dist/types/chains/utils.d.ts +6 -0
- package/dist/types/chains/utils.d.ts.map +1 -0
- package/dist/types/clients/createClient.d.ts +7 -0
- package/dist/types/clients/createClient.d.ts.map +1 -1
- package/dist/types/clients/createPublicClient.d.ts +1 -1
- package/dist/types/clients/createPublicClient.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +1 -1
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/createWalletClient.d.ts +1 -1
- package/dist/types/clients/createWalletClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +11 -10
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/constants/abis.d.ts +16 -1
- package/dist/types/constants/abis.d.ts.map +1 -1
- package/dist/types/constants/number.d.ts +97 -0
- package/dist/types/constants/number.d.ts.map +1 -0
- package/dist/types/contract.d.ts +5 -1
- package/dist/types/contract.d.ts.map +1 -1
- package/dist/types/errors/abi.d.ts +1 -0
- package/dist/types/errors/abi.d.ts.map +1 -1
- package/dist/types/errors/contract.d.ts +1 -0
- package/dist/types/errors/contract.d.ts.map +1 -1
- package/dist/types/errors/node.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 +24 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/public.d.ts +5 -1
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/types/block.d.ts +7 -7
- package/dist/types/types/block.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +52 -8
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/types/contract.d.ts +1 -1
- package/dist/types/types/contract.d.ts.map +1 -1
- package/dist/types/types/filter.d.ts +7 -3
- package/dist/types/types/filter.d.ts.map +1 -1
- package/dist/types/types/log.d.ts +8 -8
- package/dist/types/types/log.d.ts.map +1 -1
- package/dist/types/types/misc.d.ts.map +1 -1
- package/dist/types/types/rpc.d.ts +3 -3
- package/dist/types/types/rpc.d.ts.map +1 -1
- package/dist/types/types/transaction.d.ts +8 -8
- package/dist/types/types/transaction.d.ts.map +1 -1
- package/dist/types/types/utils.d.ts +10 -0
- package/dist/types/types/utils.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/chain.d.ts +3 -6
- package/dist/types/utils/chain.d.ts.map +1 -1
- package/dist/types/utils/formatters/block.d.ts +18 -4
- package/dist/types/utils/formatters/block.d.ts.map +1 -1
- package/dist/types/utils/formatters/extract.d.ts +2 -2
- package/dist/types/utils/formatters/extract.d.ts.map +1 -1
- package/dist/types/utils/formatters/formatter.d.ts +2 -1
- package/dist/types/utils/formatters/formatter.d.ts.map +1 -1
- package/dist/types/utils/formatters/transaction.d.ts +15 -4
- package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionReceipt.d.ts +4 -4
- package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionRequest.d.ts +5 -5
- package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/dist/types/utils/hash/hashFunction.d.ts +1 -1
- package/dist/types/utils/hash/hashFunction.d.ts.map +1 -1
- package/dist/types/utils/promise/withCache.d.ts +3 -3
- package/dist/types/utils/promise/withCache.d.ts.map +1 -1
- package/dist/types/utils/signature/hexToSignature.d.ts +13 -0
- package/dist/types/utils/signature/hexToSignature.d.ts.map +1 -0
- package/dist/types/utils/signature/signatureToHex.d.ts +17 -0
- package/dist/types/utils/signature/signatureToHex.d.ts.map +1 -0
- package/dist/types/utils/transaction/prepareRequest.d.ts +6 -11
- package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
- package/dist/types/utils/unit/parseUnits.d.ts.map +1 -1
- package/package.json +9 -2
- package/src/accounts/index.ts +7 -1
- package/src/accounts/utils/privateKeyToAddress.ts +20 -0
- package/src/accounts/utils/signMessage.ts +1 -1
- package/src/accounts/utils/signTransaction.ts +2 -2
- package/src/accounts/utils/signTypedData.ts +1 -1
- package/src/actions/ens/getEnsAddress.ts +24 -15
- package/src/actions/index.ts +6 -2
- package/src/actions/public/createContractEventFilter.ts +30 -7
- package/src/actions/public/createEventFilter.ts +78 -24
- package/src/actions/public/estimateContractGas.ts +1 -1
- package/src/actions/public/estimateGas.ts +11 -2
- package/src/actions/public/getBlock.ts +18 -8
- package/src/actions/public/getBlockNumber.ts +5 -3
- package/src/actions/public/getFilterChanges.ts +46 -10
- package/src/actions/public/getFilterLogs.ts +26 -10
- package/src/actions/public/getLogs.ts +73 -18
- package/src/actions/public/getTransaction.ts +15 -8
- package/src/actions/public/simulateContract.ts +2 -2
- package/src/actions/public/watchBlockNumber.ts +1 -1
- package/src/actions/public/watchBlocks.ts +37 -18
- package/src/actions/public/watchContractEvent.ts +208 -90
- package/src/actions/public/watchEvent.ts +262 -104
- package/src/actions/wallet/deployContract.ts +1 -1
- package/src/actions/wallet/sendTransaction.ts +9 -6
- package/src/actions/wallet/writeContract.ts +11 -7
- package/src/chains/{formatters/celo.ts → celo/formatters.ts} +29 -48
- package/src/chains/{serializers/celo.ts → celo/serializers.ts} +5 -5
- package/src/chains/celo/types.ts +111 -0
- package/src/chains/index.ts +22 -7
- package/src/chains/optimism/fees.ts +5 -0
- package/src/chains/optimism/formatters.ts +74 -0
- package/src/chains/optimism/types.ts +102 -0
- package/src/chains/utils.ts +41 -0
- package/src/clients/createClient.ts +9 -0
- package/src/clients/createPublicClient.ts +7 -1
- package/src/clients/createTestClient.ts +7 -1
- package/src/clients/createWalletClient.ts +7 -1
- package/src/clients/decorators/public.ts +117 -28
- package/src/constants/abis.ts +11 -1
- package/src/constants/number.ts +98 -0
- package/src/contract.ts +6 -2
- package/src/errors/abi.ts +5 -1
- package/src/errors/contract.ts +52 -31
- package/src/errors/node.ts +2 -1
- package/src/errors/version.ts +1 -1
- package/src/index.ts +133 -11
- package/src/public.ts +6 -2
- package/src/types/block.ts +25 -10
- package/src/types/chain.ts +91 -14
- package/src/types/contract.ts +7 -3
- package/src/types/filter.ts +32 -26
- package/src/types/log.ts +13 -8
- package/src/types/misc.ts +3 -0
- package/src/types/rpc.ts +16 -6
- package/src/types/transaction.ts +22 -11
- package/src/types/utils.ts +11 -0
- package/src/utils/abi/encodeAbiParameters.ts +14 -17
- package/src/utils/abi/encodePacked.ts +1 -0
- package/src/utils/chain.ts +21 -10
- package/src/utils/formatters/block.ts +34 -5
- package/src/utils/formatters/extract.ts +2 -2
- package/src/utils/formatters/formatter.ts +3 -2
- package/src/utils/formatters/transaction.ts +28 -3
- package/src/utils/formatters/transactionReceipt.ts +9 -3
- package/src/utils/formatters/transactionRequest.ts +9 -3
- package/src/utils/hash/hashFunction.ts +3 -2
- package/src/utils/promise/withCache.ts +5 -5
- package/src/utils/signature/hexToSignature.ts +20 -0
- package/src/utils/signature/signatureToHex.ts +26 -0
- package/src/utils/transaction/prepareRequest.ts +55 -30
- package/src/utils/unit/parseUnits.ts +2 -1
- package/dist/cjs/accounts/utils/signatureToHex.js.map +0 -1
- package/dist/cjs/chains/formatters/celo.js.map +0 -1
- package/dist/cjs/chains/formatters/optimism.js.map +0 -1
- package/dist/cjs/chains/serializers/celo.js.map +0 -1
- package/dist/cjs/types/formatter.js.map +0 -1
- package/dist/cjs/types/serializer.js.map +0 -1
- package/dist/esm/accounts/utils/signatureToHex.js +0 -7
- package/dist/esm/accounts/utils/signatureToHex.js.map +0 -1
- package/dist/esm/chains/formatters/celo.js.map +0 -1
- package/dist/esm/chains/formatters/optimism.js.map +0 -1
- package/dist/esm/chains/serializers/celo.js.map +0 -1
- package/dist/esm/types/formatter.js +0 -2
- package/dist/esm/types/formatter.js.map +0 -1
- package/dist/esm/types/serializer.js +0 -2
- package/dist/esm/types/serializer.js.map +0 -1
- package/dist/types/accounts/utils/signatureToHex.d.ts +0 -3
- package/dist/types/accounts/utils/signatureToHex.d.ts.map +0 -1
- package/dist/types/chains/formatters/celo.d.ts.map +0 -1
- package/dist/types/chains/formatters/optimism.d.ts.map +0 -1
- package/dist/types/chains/serializers/celo.d.ts.map +0 -1
- package/dist/types/types/formatter.d.ts +0 -14
- package/dist/types/types/formatter.d.ts.map +0 -1
- package/dist/types/types/serializer.d.ts +0 -7
- package/dist/types/types/serializer.d.ts.map +0 -1
- package/src/accounts/utils/signatureToHex.ts +0 -12
- package/src/chains/formatters/optimism.ts +0 -91
- package/src/types/formatter.ts +0 -33
- package/src/types/serializer.ts +0 -19
- /package/dist/cjs/{accounts/utils → utils/signature}/signatureToHex.js +0 -0
package/src/index.ts
CHANGED
@@ -162,8 +162,12 @@ export type {
|
|
162
162
|
WatchBlockNumberReturnType,
|
163
163
|
} from './actions/public/watchBlockNumber.js'
|
164
164
|
export type {
|
165
|
-
|
166
|
-
|
165
|
+
WatchEventOnLogsFn,
|
166
|
+
/** @deprecated - use `WatchEventOnLogsFn` instead. */
|
167
|
+
WatchEventOnLogsFn as OnLogFn,
|
168
|
+
WatchEventOnLogsParameter,
|
169
|
+
/** @deprecated - use `WatchEventOnLogsParameter` instead. */
|
170
|
+
WatchEventOnLogsParameter as OnLogParameter,
|
167
171
|
WatchEventParameters,
|
168
172
|
WatchEventReturnType,
|
169
173
|
} from './actions/public/watchEvent.js'
|
@@ -239,6 +243,7 @@ export type {
|
|
239
243
|
VerifyHashReturnType,
|
240
244
|
} from './actions/public/verifyHash.js'
|
241
245
|
export type {
|
246
|
+
WatchContractEventOnLogsParameter,
|
242
247
|
WatchContractEventParameters,
|
243
248
|
WatchContractEventReturnType,
|
244
249
|
} from './actions/public/watchContractEvent.js'
|
@@ -305,8 +310,106 @@ export {
|
|
305
310
|
webSocket,
|
306
311
|
} from './clients/transports/webSocket.js'
|
307
312
|
export { multicall3Abi } from './constants/abis.js'
|
308
|
-
export { etherUnits, gweiUnits, weiUnits } from './constants/unit.js'
|
309
313
|
export { zeroAddress } from './constants/address.js'
|
314
|
+
export { etherUnits, gweiUnits, weiUnits } from './constants/unit.js'
|
315
|
+
export {
|
316
|
+
maxInt8,
|
317
|
+
maxInt16,
|
318
|
+
maxInt24,
|
319
|
+
maxInt32,
|
320
|
+
maxInt40,
|
321
|
+
maxInt48,
|
322
|
+
maxInt56,
|
323
|
+
maxInt64,
|
324
|
+
maxInt72,
|
325
|
+
maxInt80,
|
326
|
+
maxInt88,
|
327
|
+
maxInt96,
|
328
|
+
maxInt104,
|
329
|
+
maxInt112,
|
330
|
+
maxInt120,
|
331
|
+
maxInt128,
|
332
|
+
maxInt136,
|
333
|
+
maxInt144,
|
334
|
+
maxInt152,
|
335
|
+
maxInt160,
|
336
|
+
maxInt168,
|
337
|
+
maxInt176,
|
338
|
+
maxInt184,
|
339
|
+
maxInt192,
|
340
|
+
maxInt200,
|
341
|
+
maxInt208,
|
342
|
+
maxInt216,
|
343
|
+
maxInt224,
|
344
|
+
maxInt232,
|
345
|
+
maxInt240,
|
346
|
+
maxInt248,
|
347
|
+
maxInt256,
|
348
|
+
maxUint8,
|
349
|
+
maxUint16,
|
350
|
+
maxUint24,
|
351
|
+
maxUint32,
|
352
|
+
maxUint40,
|
353
|
+
maxUint48,
|
354
|
+
maxUint56,
|
355
|
+
maxUint64,
|
356
|
+
maxUint72,
|
357
|
+
maxUint80,
|
358
|
+
maxUint88,
|
359
|
+
maxUint96,
|
360
|
+
maxUint104,
|
361
|
+
maxUint112,
|
362
|
+
maxUint120,
|
363
|
+
maxUint128,
|
364
|
+
maxUint136,
|
365
|
+
maxUint144,
|
366
|
+
maxUint152,
|
367
|
+
maxUint160,
|
368
|
+
maxUint168,
|
369
|
+
maxUint176,
|
370
|
+
maxUint184,
|
371
|
+
maxUint192,
|
372
|
+
maxUint200,
|
373
|
+
maxUint208,
|
374
|
+
maxUint216,
|
375
|
+
maxUint224,
|
376
|
+
maxUint232,
|
377
|
+
maxUint240,
|
378
|
+
maxUint248,
|
379
|
+
maxUint256,
|
380
|
+
minInt8,
|
381
|
+
minInt16,
|
382
|
+
minInt24,
|
383
|
+
minInt32,
|
384
|
+
minInt40,
|
385
|
+
minInt48,
|
386
|
+
minInt56,
|
387
|
+
minInt64,
|
388
|
+
minInt72,
|
389
|
+
minInt80,
|
390
|
+
minInt88,
|
391
|
+
minInt96,
|
392
|
+
minInt104,
|
393
|
+
minInt112,
|
394
|
+
minInt120,
|
395
|
+
minInt128,
|
396
|
+
minInt136,
|
397
|
+
minInt144,
|
398
|
+
minInt152,
|
399
|
+
minInt160,
|
400
|
+
minInt168,
|
401
|
+
minInt176,
|
402
|
+
minInt184,
|
403
|
+
minInt192,
|
404
|
+
minInt200,
|
405
|
+
minInt208,
|
406
|
+
minInt216,
|
407
|
+
minInt224,
|
408
|
+
minInt232,
|
409
|
+
minInt240,
|
410
|
+
minInt248,
|
411
|
+
minInt256,
|
412
|
+
} from './constants/number.js'
|
310
413
|
export {
|
311
414
|
AbiConstructorNotFoundError,
|
312
415
|
AbiConstructorParamsNotFoundError,
|
@@ -474,7 +577,30 @@ export type {
|
|
474
577
|
Signature,
|
475
578
|
SignableMessage,
|
476
579
|
} from './types/misc.js'
|
477
|
-
export type {
|
580
|
+
export type {
|
581
|
+
Chain,
|
582
|
+
ChainContract,
|
583
|
+
ChainFees,
|
584
|
+
ChainFormatter,
|
585
|
+
/** @deprecated use `ChainFormatter` instead. */
|
586
|
+
ChainFormatter as Formatter,
|
587
|
+
ChainFormatters,
|
588
|
+
/** @deprecated use `ChainFormatters` instead. */
|
589
|
+
ChainFormatters as Formatters,
|
590
|
+
ChainSerializers,
|
591
|
+
/** @deprecated use `ChainSerializers` instead. */
|
592
|
+
ChainSerializers as Serializers,
|
593
|
+
ExtractChainFormatterExclude,
|
594
|
+
/** @deprecated use `ExtractChainFormatterExclude` instead. */
|
595
|
+
ExtractChainFormatterExclude as ExtractFormatterExclude,
|
596
|
+
ExtractChainFormatterParameters,
|
597
|
+
/** @deprecated use `ExtractChainFormatterParameters` instead. */
|
598
|
+
ExtractChainFormatterParameters as ExtractFormatterParameters,
|
599
|
+
ExtractChainFormatterReturnType,
|
600
|
+
/** @deprecated use `ExtractChainFormatterReturnType` instead. */
|
601
|
+
ExtractChainFormatterReturnType as ExtractFormatterReturnType,
|
602
|
+
GetChain,
|
603
|
+
} from './types/chain.js'
|
478
604
|
export type {
|
479
605
|
AddEthereumChainParameter,
|
480
606
|
EIP1193Events,
|
@@ -501,13 +627,7 @@ export type {
|
|
501
627
|
FeeValuesEIP1559,
|
502
628
|
FeeValuesLegacy,
|
503
629
|
} from './types/fee.js'
|
504
|
-
export type {
|
505
|
-
Formatter,
|
506
|
-
Formatters,
|
507
|
-
ExtractFormatterParameters,
|
508
|
-
ExtractFormatterReturnType,
|
509
|
-
} from './types/formatter.js'
|
510
|
-
export type { Serializers } from './types/serializer.js'
|
630
|
+
export type { Filter } from './types/filter.js'
|
511
631
|
export type { TypedDataDefinition } from './types/typedData.js'
|
512
632
|
export type { GetTransportConfig } from './types/transport.js'
|
513
633
|
export type { HDKey } from '@scure/bip32'
|
@@ -630,6 +750,7 @@ export {
|
|
630
750
|
type HashTypedDataReturnType,
|
631
751
|
hashTypedData,
|
632
752
|
} from './utils/signature/hashTypedData.js'
|
753
|
+
export { hexToSignature } from './utils/signature/hexToSignature.js'
|
633
754
|
export {
|
634
755
|
type RecoverAddressParameters,
|
635
756
|
type RecoverAddressReturnType,
|
@@ -650,6 +771,7 @@ export {
|
|
650
771
|
type RecoverTypedDataAddressReturnType,
|
651
772
|
recoverTypedDataAddress,
|
652
773
|
} from './utils/signature/recoverTypedDataAddress.js'
|
774
|
+
export { signatureToHex } from './utils/signature/signatureToHex.js'
|
653
775
|
export { type ToRlpReturnType, toRlp } from './utils/encoding/toRlp.js'
|
654
776
|
export {
|
655
777
|
type VerifyMessageParameters,
|
package/src/public.ts
CHANGED
@@ -114,8 +114,12 @@ export {
|
|
114
114
|
} from './actions/public/watchBlocks.js'
|
115
115
|
export {
|
116
116
|
watchEvent,
|
117
|
-
type
|
118
|
-
|
117
|
+
type WatchEventOnLogsFn,
|
118
|
+
/** @deprecated - use `WatchEventOnLogsFn` instead. */
|
119
|
+
type WatchEventOnLogsFn as OnLogsFn,
|
120
|
+
type WatchEventOnLogsParameter,
|
121
|
+
/** @deprecated - use `WatchEventOnLogsParameter` instead. */
|
122
|
+
type WatchEventOnLogsParameter as OnLogsParameter,
|
119
123
|
} from './actions/public/watchEvent.js'
|
120
124
|
export {
|
121
125
|
watchPendingTransactions,
|
package/src/types/block.ts
CHANGED
@@ -3,7 +3,16 @@ import type { Address } from 'abitype'
|
|
3
3
|
import type { Hash, Hex } from './misc.js'
|
4
4
|
import type { Transaction } from './transaction.js'
|
5
5
|
|
6
|
-
export type Block<
|
6
|
+
export type Block<
|
7
|
+
TQuantity = bigint,
|
8
|
+
TIncludeTransactions extends boolean = boolean,
|
9
|
+
TBlockTag extends BlockTag = BlockTag,
|
10
|
+
TTransaction = Transaction<
|
11
|
+
bigint,
|
12
|
+
number,
|
13
|
+
TBlockTag extends 'pending' ? true : false
|
14
|
+
>,
|
15
|
+
> = {
|
7
16
|
/** Base fee per gas */
|
8
17
|
baseFeePerGas: TQuantity | null
|
9
18
|
/** Difficulty for this block */
|
@@ -15,17 +24,17 @@ export type Block<TQuantity = bigint, TTransaction = Transaction> = {
|
|
15
24
|
/** Total used gas by all transactions in this block */
|
16
25
|
gasUsed: TQuantity
|
17
26
|
/** Block hash or `null` if pending */
|
18
|
-
hash:
|
27
|
+
hash: TBlockTag extends 'pending' ? null : Hash
|
19
28
|
/** Logs bloom filter or `null` if pending */
|
20
|
-
logsBloom:
|
29
|
+
logsBloom: TBlockTag extends 'pending' ? null : Hex
|
21
30
|
/** Address that received this block’s mining rewards */
|
22
31
|
miner: Address
|
23
32
|
/** Unique identifier for the block. */
|
24
33
|
mixHash: Hash
|
25
34
|
/** Proof-of-work hash or `null` if pending */
|
26
|
-
nonce:
|
35
|
+
nonce: TBlockTag extends 'pending' ? null : Hex
|
27
36
|
/** Block number or `null` if pending */
|
28
|
-
number:
|
37
|
+
number: TBlockTag extends 'pending' ? null : TQuantity
|
29
38
|
/** Parent block hash */
|
30
39
|
parentHash: Hash
|
31
40
|
/** Root of the this block’s receipts trie */
|
@@ -42,7 +51,7 @@ export type Block<TQuantity = bigint, TTransaction = Transaction> = {
|
|
42
51
|
/** Total difficulty of the chain until this block */
|
43
52
|
totalDifficulty: TQuantity | null
|
44
53
|
/** List of transaction objects or hashes */
|
45
|
-
transactions:
|
54
|
+
transactions: TIncludeTransactions extends true ? TTransaction[] : Hash[]
|
46
55
|
/** Root of this block’s transaction trie */
|
47
56
|
transactionsRoot: Hash
|
48
57
|
/** List of uncle hashes */
|
@@ -67,7 +76,13 @@ export type BlockNumber<TQuantity = bigint> = TQuantity
|
|
67
76
|
|
68
77
|
export type BlockTag = 'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'
|
69
78
|
|
70
|
-
export type Uncle<
|
71
|
-
TQuantity,
|
72
|
-
|
73
|
-
|
79
|
+
export type Uncle<
|
80
|
+
TQuantity = bigint,
|
81
|
+
TIncludeTransactions extends boolean = boolean,
|
82
|
+
TBlockTag extends BlockTag = BlockTag,
|
83
|
+
TTransaction = Transaction<
|
84
|
+
bigint,
|
85
|
+
number,
|
86
|
+
TBlockTag extends 'pending' ? true : false
|
87
|
+
>,
|
88
|
+
> = Block<TQuantity, TIncludeTransactions, TBlockTag, TTransaction>
|
package/src/types/chain.ts
CHANGED
@@ -1,17 +1,24 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import type {
|
3
|
+
import type { FormattedBlock } from '../utils/formatters/block.js'
|
4
|
+
import type { PrepareRequestParameters } from '../utils/transaction/prepareRequest.js'
|
5
|
+
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
6
|
+
import type {
|
7
|
+
TransactionSerializable,
|
8
|
+
TransactionSerializableGeneric,
|
9
|
+
} from './transaction.js'
|
10
|
+
import type { IsUndefined, Prettify } from './utils.js'
|
6
11
|
|
7
12
|
export type Chain<
|
8
|
-
formatters extends
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
14
|
+
> = import('@wagmi/chains').Chain & ChainConfig<formatters>
|
15
|
+
|
16
|
+
export type ChainConfig<
|
17
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
18
|
+
> = {
|
13
19
|
formatters?: formatters | undefined
|
14
|
-
serializers?:
|
20
|
+
serializers?: ChainSerializers<formatters> | undefined
|
21
|
+
fees?: ChainFees<formatters> | undefined
|
15
22
|
}
|
16
23
|
|
17
24
|
export type ChainContract = {
|
@@ -19,9 +26,79 @@ export type ChainContract = {
|
|
19
26
|
blockCreated?: number
|
20
27
|
}
|
21
28
|
|
29
|
+
export type ChainFees<
|
30
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
31
|
+
> = {
|
32
|
+
defaultPriorityFee:
|
33
|
+
| bigint
|
34
|
+
| ((args: {
|
35
|
+
block: Prettify<FormattedBlock<{ formatters: formatters }>>
|
36
|
+
request: PrepareRequestParameters<
|
37
|
+
Omit<Chain, 'formatters'> & { formatters: formatters }
|
38
|
+
>
|
39
|
+
}) => Promise<bigint> | bigint)
|
40
|
+
}
|
41
|
+
|
42
|
+
export type ChainFormatters = {
|
43
|
+
block?: ChainFormatter<'block'>
|
44
|
+
transaction?: ChainFormatter<'transaction'>
|
45
|
+
transactionReceipt?: ChainFormatter<'transactionReceipt'>
|
46
|
+
transactionRequest?: ChainFormatter<'transactionRequest'>
|
47
|
+
}
|
48
|
+
|
49
|
+
export type ChainFormatter<type extends string = string> = {
|
50
|
+
format: (args: any) => any
|
51
|
+
type: type
|
52
|
+
}
|
53
|
+
|
54
|
+
export type ChainSerializers<
|
55
|
+
formatters extends ChainFormatters | undefined = undefined,
|
56
|
+
> = {
|
57
|
+
transaction?: SerializeTransactionFn<
|
58
|
+
formatters extends ChainFormatters
|
59
|
+
? formatters['transactionRequest'] extends ChainFormatter
|
60
|
+
? TransactionSerializableGeneric &
|
61
|
+
Parameters<formatters['transactionRequest']['format']>[0]
|
62
|
+
: TransactionSerializable
|
63
|
+
: TransactionSerializable
|
64
|
+
>
|
65
|
+
}
|
66
|
+
|
67
|
+
/////////////////////////////////////////////////////////////////////
|
68
|
+
// Utils
|
69
|
+
|
70
|
+
export type ExtractChainFormatterExclude<
|
71
|
+
chain extends { formatters?: Chain['formatters'] } | undefined,
|
72
|
+
type extends keyof ChainFormatters,
|
73
|
+
> = chain extends { formatters?: infer _Formatters extends ChainFormatters }
|
74
|
+
? _Formatters[type] extends { exclude: infer Exclude }
|
75
|
+
? Extract<Exclude, string[]>[number]
|
76
|
+
: ''
|
77
|
+
: ''
|
78
|
+
|
79
|
+
export type ExtractChainFormatterParameters<
|
80
|
+
chain extends { formatters?: Chain['formatters'] } | undefined,
|
81
|
+
type extends keyof ChainFormatters,
|
82
|
+
fallback,
|
83
|
+
> = chain extends { formatters?: infer _Formatters extends ChainFormatters }
|
84
|
+
? _Formatters[type] extends ChainFormatter
|
85
|
+
? Parameters<_Formatters[type]['format']>[0]
|
86
|
+
: fallback
|
87
|
+
: fallback
|
88
|
+
|
89
|
+
export type ExtractChainFormatterReturnType<
|
90
|
+
chain extends { formatters?: Chain['formatters'] } | undefined,
|
91
|
+
type extends keyof ChainFormatters,
|
92
|
+
fallback,
|
93
|
+
> = chain extends { formatters?: infer _Formatters extends ChainFormatters }
|
94
|
+
? _Formatters[type] extends ChainFormatter
|
95
|
+
? ReturnType<_Formatters[type]['format']>
|
96
|
+
: fallback
|
97
|
+
: fallback
|
98
|
+
|
22
99
|
export type GetChain<
|
23
|
-
|
24
|
-
|
25
|
-
> = IsUndefined<
|
26
|
-
? { chain:
|
27
|
-
: { chain?:
|
100
|
+
chain extends Chain | undefined,
|
101
|
+
chainOverride extends Chain | undefined = undefined,
|
102
|
+
> = IsUndefined<chain> extends true
|
103
|
+
? { chain: chainOverride | null }
|
104
|
+
: { chain?: chainOverride | null }
|
package/src/types/contract.ts
CHANGED
@@ -83,9 +83,13 @@ export type MaybeAbiEventName<TAbiEvent extends AbiEvent | undefined> =
|
|
83
83
|
TAbiEvent extends AbiEvent ? TAbiEvent['name'] : undefined
|
84
84
|
|
85
85
|
export type MaybeExtractEventArgsFromAbi<
|
86
|
-
TAbi extends Abi | readonly unknown[]
|
87
|
-
TEventName extends string | undefined
|
88
|
-
> =
|
86
|
+
TAbi extends Abi | readonly unknown[] | undefined,
|
87
|
+
TEventName extends string | undefined,
|
88
|
+
> = TAbi extends Abi | readonly unknown[]
|
89
|
+
? TEventName extends string
|
90
|
+
? GetEventArgs<TAbi, TEventName>
|
91
|
+
: undefined
|
92
|
+
: undefined
|
89
93
|
|
90
94
|
//////////////////////////////////////////////////////////////////////
|
91
95
|
// ABI item name
|
package/src/types/filter.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { Abi } from 'abitype'
|
2
2
|
|
3
|
+
import type { BlockNumber, BlockTag } from './block.js'
|
3
4
|
import type { MaybeExtractEventArgsFromAbi } from './contract.js'
|
4
5
|
import type { EIP1193RequestFn, PublicRpcSchema } from './eip1193.js'
|
5
6
|
import type { Hex } from './misc.js'
|
@@ -16,42 +17,47 @@ type FilterRpcSchema = Filter_<
|
|
16
17
|
|
17
18
|
export type Filter<
|
18
19
|
TFilterType extends FilterType = 'event',
|
19
|
-
TAbi extends Abi | readonly unknown[] =
|
20
|
+
TAbi extends Abi | readonly unknown[] | undefined = undefined,
|
20
21
|
TEventName extends string | undefined = undefined,
|
21
22
|
TArgs extends
|
22
23
|
| MaybeExtractEventArgsFromAbi<TAbi, TEventName>
|
23
24
|
| undefined = MaybeExtractEventArgsFromAbi<TAbi, TEventName>,
|
24
25
|
TStrict extends boolean | undefined = undefined,
|
26
|
+
TFromBlock extends BlockNumber | BlockTag | undefined = undefined,
|
27
|
+
TToBlock extends BlockNumber | BlockTag | undefined = undefined,
|
25
28
|
> = {
|
26
29
|
id: Hex
|
27
30
|
request: EIP1193RequestFn<FilterRpcSchema>
|
28
31
|
type: TFilterType
|
29
32
|
} & (TFilterType extends 'event'
|
30
|
-
?
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
33
|
+
? {
|
34
|
+
fromBlock?: TFromBlock
|
35
|
+
toBlock?: TToBlock
|
36
|
+
} & (TAbi extends Abi
|
37
|
+
? undefined extends TEventName
|
38
|
+
? {
|
39
|
+
abi: TAbi
|
40
|
+
args?: never
|
41
|
+
eventName?: never
|
42
|
+
strict: TStrict
|
43
|
+
}
|
44
|
+
: TArgs extends MaybeExtractEventArgsFromAbi<TAbi, TEventName>
|
45
|
+
? {
|
46
|
+
abi: TAbi
|
47
|
+
args: TArgs
|
48
|
+
eventName: TEventName
|
49
|
+
strict: TStrict
|
50
|
+
}
|
51
|
+
: {
|
52
|
+
abi: TAbi
|
53
|
+
args?: never
|
54
|
+
eventName: TEventName
|
55
|
+
strict: TStrict
|
56
|
+
}
|
45
57
|
: {
|
46
|
-
abi
|
58
|
+
abi?: never
|
47
59
|
args?: never
|
48
|
-
eventName
|
49
|
-
strict
|
50
|
-
}
|
51
|
-
: {
|
52
|
-
abi?: never
|
53
|
-
args?: never
|
54
|
-
eventName?: never
|
55
|
-
strict?: never
|
56
|
-
}
|
60
|
+
eventName?: never
|
61
|
+
strict?: never
|
62
|
+
})
|
57
63
|
: {})
|
package/src/types/log.ts
CHANGED
@@ -15,9 +15,12 @@ import type { Hash, Hex } from './misc.js'
|
|
15
15
|
export type Log<
|
16
16
|
TQuantity = bigint,
|
17
17
|
TIndex = number,
|
18
|
+
TPending extends boolean = boolean,
|
18
19
|
TAbiEvent extends AbiEvent | undefined = undefined,
|
19
20
|
TStrict extends boolean | undefined = undefined,
|
20
|
-
TAbi extends Abi | readonly unknown[] =
|
21
|
+
TAbi extends Abi | readonly unknown[] | undefined = TAbiEvent extends AbiEvent
|
22
|
+
? [TAbiEvent]
|
23
|
+
: undefined,
|
21
24
|
TEventName extends string | undefined = TAbiEvent extends AbiEvent
|
22
25
|
? TAbiEvent['name']
|
23
26
|
: undefined,
|
@@ -25,17 +28,17 @@ export type Log<
|
|
25
28
|
/** The address from which this log originated */
|
26
29
|
address: Address
|
27
30
|
/** Hash of block containing this log or `null` if pending */
|
28
|
-
blockHash:
|
31
|
+
blockHash: TPending extends true ? null : Hash
|
29
32
|
/** Number of block containing this log or `null` if pending */
|
30
|
-
blockNumber:
|
33
|
+
blockNumber: TPending extends true ? null : TQuantity
|
31
34
|
/** Contains the non-indexed arguments of the log */
|
32
35
|
data: Hex
|
33
36
|
/** Index of this log within its block or `null` if pending */
|
34
|
-
logIndex:
|
37
|
+
logIndex: TPending extends true ? null : TIndex
|
35
38
|
/** Hash of the transaction that created this log or `null` if pending */
|
36
|
-
transactionHash:
|
39
|
+
transactionHash: TPending extends true ? null : Hash
|
37
40
|
/** Index of the transaction that created this log or `null` if pending */
|
38
|
-
transactionIndex:
|
41
|
+
transactionIndex: TPending extends true ? null : TIndex
|
39
42
|
/** `true` if this filter has been destroyed and is invalid */
|
40
43
|
removed: boolean
|
41
44
|
} & GetInferredLogValues<TAbiEvent, TAbi, TEventName, TStrict>
|
@@ -79,7 +82,9 @@ type GetTopics<
|
|
79
82
|
|
80
83
|
type GetInferredLogValues<
|
81
84
|
TAbiEvent extends AbiEvent | undefined = undefined,
|
82
|
-
TAbi extends Abi | readonly unknown[] =
|
85
|
+
TAbi extends Abi | readonly unknown[] | undefined = TAbiEvent extends AbiEvent
|
86
|
+
? [TAbiEvent]
|
87
|
+
: undefined,
|
83
88
|
TEventName extends string | undefined = TAbiEvent extends AbiEvent
|
84
89
|
? TAbiEvent['name']
|
85
90
|
: undefined,
|
@@ -110,7 +115,7 @@ type GetInferredLogValues<
|
|
110
115
|
[TName in _EventNames]: {
|
111
116
|
args: GetEventArgs<
|
112
117
|
TAbi,
|
113
|
-
|
118
|
+
TName,
|
114
119
|
{
|
115
120
|
EnableUnion: false
|
116
121
|
IndexedOnly: false
|
package/src/types/misc.ts
CHANGED
package/src/types/rpc.ts
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
import type {
|
1
|
+
import type {
|
2
|
+
Block,
|
3
|
+
BlockIdentifier,
|
4
|
+
BlockNumber,
|
5
|
+
BlockTag,
|
6
|
+
Uncle,
|
7
|
+
} from './block.js'
|
2
8
|
import type { FeeHistory, FeeValues } from './fee.js'
|
3
9
|
import type { Log } from './log.js'
|
4
10
|
import type {
|
@@ -17,7 +23,11 @@ export type Quantity = `0x${string}`
|
|
17
23
|
export type Status = '0x0' | '0x1'
|
18
24
|
export type TransactionType = '0x0' | '0x1' | '0x2' | (string & {})
|
19
25
|
|
20
|
-
export type RpcBlock
|
26
|
+
export type RpcBlock<
|
27
|
+
TBlockTag extends BlockTag = BlockTag,
|
28
|
+
TIncludeTransactions extends boolean = boolean,
|
29
|
+
TTransaction = RpcTransaction<TBlockTag extends 'pending' ? true : false>,
|
30
|
+
> = Block<Quantity, TIncludeTransactions, TBlockTag, TTransaction>
|
21
31
|
export type RpcBlockNumber = BlockNumber<Quantity>
|
22
32
|
export type RpcBlockIdentifier = BlockIdentifier<Quantity>
|
23
33
|
export type RpcUncle = Uncle<Quantity>
|
@@ -34,9 +44,9 @@ export type RpcTransactionRequest =
|
|
34
44
|
| TransactionRequestLegacy<Quantity, Index, '0x0'>
|
35
45
|
| TransactionRequestEIP2930<Quantity, Index, '0x1'>
|
36
46
|
| TransactionRequestEIP1559<Quantity, Index, '0x2'>
|
37
|
-
export type RpcTransaction = UnionOmit<
|
38
|
-
| TransactionLegacy<Quantity, Index, '0x0'>
|
39
|
-
| TransactionEIP2930<Quantity, Index, '0x1'>
|
40
|
-
| TransactionEIP1559<Quantity, Index, '0x2'>,
|
47
|
+
export type RpcTransaction<TPending extends boolean = boolean> = UnionOmit<
|
48
|
+
| TransactionLegacy<Quantity, Index, TPending, '0x0'>
|
49
|
+
| TransactionEIP2930<Quantity, Index, TPending, '0x1'>
|
50
|
+
| TransactionEIP1559<Quantity, Index, TPending, '0x2'>,
|
41
51
|
'typeHex'
|
42
52
|
>
|
package/src/types/transaction.ts
CHANGED
@@ -47,11 +47,15 @@ export type TransactionReceipt<
|
|
47
47
|
type: TType
|
48
48
|
}
|
49
49
|
|
50
|
-
export type TransactionBase<
|
50
|
+
export type TransactionBase<
|
51
|
+
TQuantity = bigint,
|
52
|
+
TIndex = number,
|
53
|
+
TPending extends boolean = boolean,
|
54
|
+
> = {
|
51
55
|
/** Hash of block containing this transaction or `null` if pending */
|
52
|
-
blockHash:
|
56
|
+
blockHash: TPending extends true ? null : Hash
|
53
57
|
/** Number of block containing this transaction or `null` if pending */
|
54
|
-
blockNumber:
|
58
|
+
blockNumber: TPending extends true ? null : TQuantity
|
55
59
|
/** Transaction sender */
|
56
60
|
from: Address
|
57
61
|
/** Gas provided for transaction execution */
|
@@ -69,7 +73,7 @@ export type TransactionBase<TQuantity = bigint, TIndex = number> = {
|
|
69
73
|
/** Transaction recipient or `null` if deploying a contract */
|
70
74
|
to: Address | null
|
71
75
|
/** Index of this transaction in the block or `null` if pending */
|
72
|
-
transactionIndex:
|
76
|
+
transactionIndex: TPending extends true ? null : TIndex
|
73
77
|
/** The type represented as hex. */
|
74
78
|
typeHex: Hex | null
|
75
79
|
/** ECDSA recovery ID */
|
@@ -80,8 +84,9 @@ export type TransactionBase<TQuantity = bigint, TIndex = number> = {
|
|
80
84
|
export type TransactionLegacy<
|
81
85
|
TQuantity = bigint,
|
82
86
|
TIndex = number,
|
87
|
+
TPending extends boolean = boolean,
|
83
88
|
TType = 'legacy',
|
84
|
-
> = TransactionBase<TQuantity, TIndex> &
|
89
|
+
> = TransactionBase<TQuantity, TIndex, TPending> &
|
85
90
|
FeeValuesLegacy<TQuantity> & {
|
86
91
|
accessList?: never
|
87
92
|
chainId?: TIndex
|
@@ -90,8 +95,9 @@ export type TransactionLegacy<
|
|
90
95
|
export type TransactionEIP2930<
|
91
96
|
TQuantity = bigint,
|
92
97
|
TIndex = number,
|
98
|
+
TPending extends boolean = boolean,
|
93
99
|
TType = 'eip2930',
|
94
|
-
> = TransactionBase<TQuantity, TIndex> &
|
100
|
+
> = TransactionBase<TQuantity, TIndex, TPending> &
|
95
101
|
FeeValuesLegacy<TQuantity> & {
|
96
102
|
accessList: AccessList
|
97
103
|
chainId: TIndex
|
@@ -100,17 +106,22 @@ export type TransactionEIP2930<
|
|
100
106
|
export type TransactionEIP1559<
|
101
107
|
TQuantity = bigint,
|
102
108
|
TIndex = number,
|
109
|
+
TPending extends boolean = boolean,
|
103
110
|
TType = 'eip1559',
|
104
|
-
> = TransactionBase<TQuantity, TIndex> &
|
111
|
+
> = TransactionBase<TQuantity, TIndex, TPending> &
|
105
112
|
FeeValuesEIP1559<TQuantity> & {
|
106
113
|
accessList: AccessList
|
107
114
|
chainId: TIndex
|
108
115
|
type: TType
|
109
116
|
}
|
110
|
-
export type Transaction<
|
111
|
-
|
112
|
-
|
113
|
-
|
117
|
+
export type Transaction<
|
118
|
+
TQuantity = bigint,
|
119
|
+
TIndex = number,
|
120
|
+
TPending extends boolean = boolean,
|
121
|
+
> =
|
122
|
+
| TransactionLegacy<TQuantity, TIndex, TPending>
|
123
|
+
| TransactionEIP2930<TQuantity, TIndex, TPending>
|
124
|
+
| TransactionEIP1559<TQuantity, TIndex, TPending>
|
114
125
|
|
115
126
|
export type TransactionRequestBase<TQuantity = bigint, TIndex = number> = {
|
116
127
|
/** Contract code or a hashed method call with encoded args */
|