viem 1.5.4 → 1.6.2
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/chains/utils/package.json +5 -0
- package/dist/cjs/accounts/index.js +5 -1
- 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/signTransaction.js.map +1 -1
- package/dist/cjs/actions/getContract.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/multicall.js +2 -3
- package/dist/cjs/actions/public/multicall.js.map +1 -1
- package/dist/cjs/actions/public/watchContractEvent.js +134 -67
- package/dist/cjs/actions/public/watchContractEvent.js.map +1 -1
- package/dist/cjs/actions/public/watchEvent.js +136 -62
- 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 +32 -16
- 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/decorators/public.js.map +1 -1
- package/dist/cjs/constants/number.js +96 -96
- package/dist/cjs/constants/number.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/index.js.map +1 -1
- package/dist/cjs/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/decodeDeployData.js.map +1 -1
- package/dist/cjs/utils/abi/decodeErrorResult.js.map +1 -1
- package/dist/cjs/utils/abi/decodeFunctionResult.js.map +1 -1
- package/dist/cjs/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/cjs/utils/abi/encodeDeployData.js.map +1 -1
- package/dist/cjs/utils/abi/encodeEventTopics.js.map +1 -1
- 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.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/poll.js +1 -1
- package/dist/cjs/utils/poll.js.map +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js +15 -6
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/cjs/utils/typedData.js +2 -2
- package/dist/cjs/utils/typedData.js.map +1 -1
- package/dist/esm/accounts/index.js +2 -0
- 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/signTransaction.js.map +1 -1
- package/dist/esm/actions/getContract.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/multicall.js +2 -4
- package/dist/esm/actions/public/multicall.js.map +1 -1
- package/dist/esm/actions/public/watchContractEvent.js +145 -76
- package/dist/esm/actions/public/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/public/watchEvent.js +146 -70
- 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 +23 -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/decorators/public.js.map +1 -1
- package/dist/esm/constants/number.js +96 -96
- package/dist/esm/constants/number.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/index.js.map +1 -1
- package/dist/esm/utils/abi/decodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/decodeDeployData.js.map +1 -1
- package/dist/esm/utils/abi/decodeErrorResult.js.map +1 -1
- package/dist/esm/utils/abi/decodeFunctionResult.js.map +1 -1
- package/dist/esm/utils/abi/encodeAbiParameters.js.map +1 -1
- package/dist/esm/utils/abi/encodeDeployData.js.map +1 -1
- package/dist/esm/utils/abi/encodeEventTopics.js.map +1 -1
- 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.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/poll.js +1 -1
- package/dist/esm/utils/poll.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js +14 -5
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/utils/typedData.js +2 -2
- package/dist/esm/utils/typedData.js.map +1 -1
- package/dist/types/accounts/index.d.ts +2 -0
- package/dist/types/accounts/index.d.ts.map +1 -1
- package/dist/types/accounts/types.d.ts +1 -1
- package/dist/types/accounts/types.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/accounts/utils/signTypedData.d.ts +1 -1
- package/dist/types/accounts/utils/signTypedData.d.ts.map +1 -1
- package/dist/types/actions/getContract.d.ts +5 -5
- package/dist/types/actions/getContract.d.ts.map +1 -1
- package/dist/types/actions/public/createContractEventFilter.d.ts +3 -3
- package/dist/types/actions/public/createContractEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/createEventFilter.d.ts +5 -5
- package/dist/types/actions/public/createEventFilter.d.ts.map +1 -1
- package/dist/types/actions/public/estimateContractGas.d.ts +1 -1
- 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/getFilterChanges.d.ts +1 -1
- package/dist/types/actions/public/getFilterChanges.d.ts.map +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts +1 -1
- package/dist/types/actions/public/getFilterLogs.d.ts.map +1 -1
- package/dist/types/actions/public/getLogs.d.ts +4 -4
- package/dist/types/actions/public/getLogs.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/multicall.d.ts +1 -1
- package/dist/types/actions/public/multicall.d.ts.map +1 -1
- package/dist/types/actions/public/readContract.d.ts +1 -1
- package/dist/types/actions/public/readContract.d.ts.map +1 -1
- package/dist/types/actions/public/simulateContract.d.ts +3 -3
- package/dist/types/actions/public/simulateContract.d.ts.map +1 -1
- package/dist/types/actions/public/watchContractEvent.d.ts +34 -8
- package/dist/types/actions/public/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/public/watchEvent.d.ts +35 -12
- package/dist/types/actions/public/watchEvent.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +4 -4
- 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/signTypedData.d.ts +1 -1
- package/dist/types/actions/wallet/signTypedData.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} +26 -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 +2681 -2790
- 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} +77 -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/decorators/public.d.ts +10 -10
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/clients/decorators/wallet.d.ts +3 -3
- package/dist/types/clients/decorators/wallet.d.ts.map +1 -1
- package/dist/types/constants/number.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/index.d.ts +14 -4
- package/dist/types/index.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/multicall.d.ts +8 -8
- package/dist/types/types/multicall.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/typedData.d.ts +3 -3
- package/dist/types/types/typedData.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/decodeAbiParameters.d.ts +2 -2
- package/dist/types/utils/abi/decodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeDeployData.d.ts +3 -3
- package/dist/types/utils/abi/decodeDeployData.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeErrorResult.d.ts +3 -3
- package/dist/types/utils/abi/decodeErrorResult.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeEventLog.d.ts +3 -3
- package/dist/types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/dist/types/utils/abi/decodeFunctionResult.d.ts +4 -4
- package/dist/types/utils/abi/decodeFunctionResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeAbiParameters.d.ts +2 -2
- package/dist/types/utils/abi/encodeAbiParameters.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeDeployData.d.ts +3 -3
- package/dist/types/utils/abi/encodeDeployData.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeErrorResult.d.ts +4 -4
- package/dist/types/utils/abi/encodeErrorResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeEventTopics.d.ts +4 -4
- package/dist/types/utils/abi/encodeEventTopics.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeFunctionData.d.ts +4 -4
- package/dist/types/utils/abi/encodeFunctionData.d.ts.map +1 -1
- package/dist/types/utils/abi/encodeFunctionResult.d.ts +4 -4
- package/dist/types/utils/abi/encodeFunctionResult.d.ts.map +1 -1
- package/dist/types/utils/abi/encodePacked.d.ts +3 -3
- package/dist/types/utils/abi/encodePacked.d.ts.map +1 -1
- package/dist/types/utils/abi/getAbiItem.d.ts +3 -3
- package/dist/types/utils/abi/getAbiItem.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 +7 -3
- 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 +1 -1
- package/dist/types/utils/formatters/transaction.d.ts +8 -4
- package/dist/types/utils/formatters/transaction.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionReceipt.d.ts +3 -4
- package/dist/types/utils/formatters/transactionReceipt.d.ts.map +1 -1
- package/dist/types/utils/formatters/transactionRequest.d.ts +4 -5
- package/dist/types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/dist/types/utils/signature/hashTypedData.d.ts +1 -1
- package/dist/types/utils/signature/hashTypedData.d.ts.map +1 -1
- package/dist/types/utils/signature/recoverTypedDataAddress.d.ts +1 -1
- package/dist/types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
- package/dist/types/utils/signature/verifyTypedData.d.ts +1 -1
- package/dist/types/utils/signature/verifyTypedData.d.ts.map +1 -1
- 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/typedData.d.ts +1 -1
- package/dist/types/utils/typedData.d.ts.map +1 -1
- package/package.json +9 -3
- package/src/accounts/index.ts +6 -0
- package/src/accounts/types.ts +1 -1
- package/src/accounts/utils/privateKeyToAddress.ts +20 -0
- package/src/accounts/utils/signTransaction.ts +2 -2
- package/src/accounts/utils/signTypedData.ts +1 -1
- package/src/actions/getContract.ts +6 -5
- package/src/actions/public/createContractEventFilter.ts +3 -3
- package/src/actions/public/createEventFilter.ts +6 -6
- package/src/actions/public/estimateContractGas.ts +1 -1
- package/src/actions/public/estimateGas.ts +11 -2
- package/src/actions/public/getFilterChanges.ts +1 -1
- package/src/actions/public/getFilterLogs.ts +1 -1
- package/src/actions/public/getLogs.ts +5 -5
- package/src/actions/public/multicall.ts +9 -8
- package/src/actions/public/readContract.ts +1 -1
- package/src/actions/public/simulateContract.ts +3 -3
- package/src/actions/public/watchContractEvent.ts +204 -90
- package/src/actions/public/watchEvent.ts +232 -111
- package/src/actions/wallet/deployContract.ts +4 -4
- package/src/actions/wallet/sendTransaction.ts +9 -6
- package/src/actions/wallet/signTypedData.ts +1 -1
- package/src/actions/wallet/writeContract.ts +12 -8
- 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 +23 -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/decorators/public.ts +16 -16
- package/src/clients/decorators/wallet.ts +3 -3
- package/src/constants/number.ts +96 -96
- package/src/errors/node.ts +2 -1
- package/src/errors/version.ts +1 -1
- package/src/index.ts +25 -8
- package/src/types/chain.ts +91 -14
- package/src/types/multicall.ts +14 -11
- package/src/types/rpc.ts +2 -6
- package/src/types/typedData.ts +2 -3
- package/src/types/utils.ts +11 -0
- package/src/utils/abi/decodeAbiParameters.ts +7 -8
- package/src/utils/abi/decodeDeployData.ts +3 -3
- package/src/utils/abi/decodeErrorResult.ts +3 -8
- package/src/utils/abi/decodeEventLog.ts +3 -3
- package/src/utils/abi/decodeFunctionResult.ts +4 -6
- package/src/utils/abi/encodeAbiParameters.ts +8 -9
- package/src/utils/abi/encodeDeployData.ts +3 -3
- package/src/utils/abi/encodeErrorResult.ts +4 -4
- package/src/utils/abi/encodeEventTopics.ts +4 -9
- package/src/utils/abi/encodeFunctionData.ts +4 -4
- package/src/utils/abi/encodeFunctionResult.ts +4 -4
- package/src/utils/abi/encodePacked.ts +6 -8
- package/src/utils/abi/getAbiItem.ts +3 -3
- package/src/utils/chain.ts +21 -10
- package/src/utils/formatters/block.ts +8 -6
- package/src/utils/formatters/extract.ts +2 -2
- package/src/utils/formatters/formatter.ts +2 -2
- package/src/utils/formatters/transaction.ts +8 -6
- package/src/utils/formatters/transactionReceipt.ts +9 -3
- package/src/utils/formatters/transactionRequest.ts +9 -3
- package/src/utils/poll.ts +1 -1
- package/src/utils/signature/hashTypedData.ts +1 -1
- package/src/utils/signature/recoverTypedDataAddress.ts +1 -1
- package/src/utils/signature/verifyTypedData.ts +1 -1
- package/src/utils/transaction/prepareRequest.ts +48 -22
- package/src/utils/typedData.ts +2 -3
- 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/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/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 -17
- 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/chains/formatters/optimism.ts +0 -91
- package/src/types/formatter.ts +0 -42
- package/src/types/serializer.ts +0 -19
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { AbiEvent, Address
|
1
|
+
import type { Abi, AbiEvent, Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Client } from '../../clients/createClient.js'
|
4
4
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
@@ -9,11 +9,23 @@ import type {
|
|
9
9
|
} from '../../types/contract.js'
|
10
10
|
import type { Filter } from '../../types/filter.js'
|
11
11
|
import type { Log } from '../../types/log.js'
|
12
|
+
import type { LogTopic } from '../../types/misc.js'
|
13
|
+
import type { GetTransportConfig } from '../../types/transport.js'
|
14
|
+
import type { EncodeEventTopicsParameters } from '../../utils/index.js'
|
12
15
|
import { observe } from '../../utils/observe.js'
|
13
16
|
import { poll } from '../../utils/poll.js'
|
14
17
|
import { stringify } from '../../utils/stringify.js'
|
15
18
|
|
19
|
+
import {
|
20
|
+
DecodeLogDataMismatch,
|
21
|
+
DecodeLogTopicsMismatch,
|
22
|
+
} from '../../errors/abi.js'
|
16
23
|
import { InvalidInputRpcError } from '../../errors/rpc.js'
|
24
|
+
import {
|
25
|
+
decodeEventLog,
|
26
|
+
encodeEventTopics,
|
27
|
+
formatLog,
|
28
|
+
} from '../../utils/index.js'
|
17
29
|
import {
|
18
30
|
type CreateEventFilterParameters,
|
19
31
|
createEventFilter,
|
@@ -23,6 +35,19 @@ import { getFilterChanges } from './getFilterChanges.js'
|
|
23
35
|
import { type GetLogsParameters, getLogs } from './getLogs.js'
|
24
36
|
import { uninstallFilter } from './uninstallFilter.js'
|
25
37
|
|
38
|
+
type PollOptions = {
|
39
|
+
/**
|
40
|
+
* Whether or not the transaction hashes should be batched on each invocation.
|
41
|
+
* @default true
|
42
|
+
*/
|
43
|
+
batch?: boolean
|
44
|
+
/**
|
45
|
+
* Polling frequency (in ms). Defaults to Client's pollingInterval config.
|
46
|
+
* @default client.pollingInterval
|
47
|
+
*/
|
48
|
+
pollingInterval?: number
|
49
|
+
}
|
50
|
+
|
26
51
|
export type WatchEventOnLogsParameter<
|
27
52
|
TAbiEvent extends AbiEvent | undefined = undefined,
|
28
53
|
TAbiEvents extends
|
@@ -55,45 +80,59 @@ export type WatchEventParameters<
|
|
55
80
|
> = {
|
56
81
|
/** The address of the contract. */
|
57
82
|
address?: Address | Address[]
|
58
|
-
/**
|
59
|
-
* Whether or not the event logs should be batched on each invocation.
|
60
|
-
* @default true
|
61
|
-
*/
|
62
|
-
batch?: boolean
|
63
83
|
/** The callback to call when an error occurred when trying to get for a new block. */
|
64
84
|
onError?: (error: Error) => void
|
65
85
|
/** The callback to call when new event logs are received. */
|
66
86
|
onLogs: WatchEventOnLogsFn<TAbiEvent, TAbiEvents, TStrict, _EventName>
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
87
|
+
} & (GetTransportConfig<Transport>['type'] extends 'webSocket'
|
88
|
+
?
|
89
|
+
| {
|
90
|
+
batch?: never
|
91
|
+
/**
|
92
|
+
* Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`.
|
93
|
+
* @default false
|
94
|
+
*/
|
95
|
+
poll?: false
|
96
|
+
pollingInterval?: never
|
97
|
+
}
|
98
|
+
| (PollOptions & {
|
99
|
+
/**
|
100
|
+
* Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`.
|
101
|
+
* @default true
|
102
|
+
*/
|
103
|
+
poll?: true
|
104
|
+
})
|
105
|
+
: PollOptions & {
|
106
|
+
poll?: true
|
107
|
+
}) &
|
108
|
+
(
|
109
|
+
| {
|
110
|
+
event: TAbiEvent
|
111
|
+
events?: never
|
112
|
+
args?: MaybeExtractEventArgsFromAbi<TAbiEvents, _EventName>
|
113
|
+
/**
|
114
|
+
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
115
|
+
* @default false
|
116
|
+
*/
|
117
|
+
strict?: TStrict
|
118
|
+
}
|
119
|
+
| {
|
120
|
+
event?: never
|
121
|
+
events?: TAbiEvents
|
122
|
+
args?: never
|
123
|
+
/**
|
124
|
+
* Whether or not the logs must match the indexed/non-indexed arguments on `event`.
|
125
|
+
* @default false
|
126
|
+
*/
|
127
|
+
strict?: TStrict
|
128
|
+
}
|
129
|
+
| {
|
130
|
+
event?: never
|
131
|
+
events?: never
|
132
|
+
args?: never
|
133
|
+
strict?: never
|
134
|
+
}
|
135
|
+
)
|
97
136
|
|
98
137
|
export type WatchEventReturnType = () => void
|
99
138
|
|
@@ -131,8 +170,8 @@ export type WatchEventReturnType = () => void
|
|
131
170
|
*/
|
132
171
|
export function watchEvent<
|
133
172
|
TChain extends Chain | undefined,
|
134
|
-
TAbiEvent extends AbiEvent | undefined = undefined,
|
135
|
-
TAbiEvents extends
|
173
|
+
const TAbiEvent extends AbiEvent | undefined = undefined,
|
174
|
+
const TAbiEvents extends
|
136
175
|
| readonly AbiEvent[]
|
137
176
|
| readonly unknown[]
|
138
177
|
| undefined = TAbiEvent extends AbiEvent ? [TAbiEvent] : undefined,
|
@@ -148,94 +187,176 @@ export function watchEvent<
|
|
148
187
|
events,
|
149
188
|
onError,
|
150
189
|
onLogs,
|
190
|
+
poll: poll_,
|
151
191
|
pollingInterval = client.pollingInterval,
|
152
192
|
strict: strict_,
|
153
193
|
}: WatchEventParameters<TAbiEvent, TAbiEvents, TStrict>,
|
154
194
|
): WatchEventReturnType {
|
155
|
-
const
|
156
|
-
'
|
157
|
-
address,
|
158
|
-
args,
|
159
|
-
batch,
|
160
|
-
client.uid,
|
161
|
-
event,
|
162
|
-
pollingInterval,
|
163
|
-
])
|
195
|
+
const enablePolling =
|
196
|
+
typeof poll_ !== 'undefined' ? poll_ : client.transport.type !== 'webSocket'
|
164
197
|
const strict = strict_ ?? false
|
165
198
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
199
|
+
const pollEvent = () => {
|
200
|
+
const observerId = stringify([
|
201
|
+
'watchEvent',
|
202
|
+
address,
|
203
|
+
args,
|
204
|
+
batch,
|
205
|
+
client.uid,
|
206
|
+
event,
|
207
|
+
pollingInterval,
|
208
|
+
])
|
170
209
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
filter = (await createEventFilter(client, {
|
176
|
-
address,
|
177
|
-
args,
|
178
|
-
event: event!,
|
179
|
-
events,
|
180
|
-
strict,
|
181
|
-
} as unknown as CreateEventFilterParameters)) as unknown as Filter<
|
182
|
-
'event',
|
183
|
-
TAbiEvents,
|
184
|
-
_EventName
|
185
|
-
>
|
186
|
-
} catch {}
|
187
|
-
initialized = true
|
188
|
-
return
|
189
|
-
}
|
210
|
+
return observe(observerId, { onLogs, onError }, (emit) => {
|
211
|
+
let previousBlockNumber: bigint
|
212
|
+
let filter: Filter<'event', TAbiEvents, _EventName, any>
|
213
|
+
let initialized = false
|
190
214
|
|
191
|
-
|
192
|
-
|
193
|
-
if (
|
194
|
-
|
195
|
-
|
196
|
-
// If the filter doesn't exist, we will fall back to use `getLogs`.
|
197
|
-
// The fall back exists because some RPC Providers do not support filters.
|
198
|
-
|
199
|
-
// Fetch the block number to use for `getLogs`.
|
200
|
-
const blockNumber = await getBlockNumber(client)
|
201
|
-
|
202
|
-
// If the block number has changed, we will need to fetch the logs.
|
203
|
-
// If the block number doesn't exist, we are yet to reach the first poll interval,
|
204
|
-
// so do not emit any logs.
|
205
|
-
if (previousBlockNumber && previousBlockNumber !== blockNumber) {
|
206
|
-
logs = await getLogs(client, {
|
215
|
+
const unwatch = poll(
|
216
|
+
async () => {
|
217
|
+
if (!initialized) {
|
218
|
+
try {
|
219
|
+
filter = (await createEventFilter(client, {
|
207
220
|
address,
|
208
221
|
args,
|
209
222
|
event: event!,
|
210
223
|
events,
|
211
|
-
|
212
|
-
|
213
|
-
|
224
|
+
strict,
|
225
|
+
} as unknown as CreateEventFilterParameters)) as unknown as Filter<
|
226
|
+
'event',
|
227
|
+
TAbiEvents,
|
228
|
+
_EventName
|
229
|
+
>
|
230
|
+
} catch {}
|
231
|
+
initialized = true
|
232
|
+
return
|
233
|
+
}
|
234
|
+
|
235
|
+
try {
|
236
|
+
let logs: Log[]
|
237
|
+
if (filter) {
|
238
|
+
logs = await getFilterChanges(client, { filter })
|
214
239
|
} else {
|
215
|
-
|
240
|
+
// If the filter doesn't exist, we will fall back to use `getLogs`.
|
241
|
+
// The fall back exists because some RPC Providers do not support filters.
|
242
|
+
|
243
|
+
// Fetch the block number to use for `getLogs`.
|
244
|
+
const blockNumber = await getBlockNumber(client)
|
245
|
+
|
246
|
+
// If the block number has changed, we will need to fetch the logs.
|
247
|
+
// If the block number doesn't exist, we are yet to reach the first poll interval,
|
248
|
+
// so do not emit any logs.
|
249
|
+
if (previousBlockNumber && previousBlockNumber !== blockNumber) {
|
250
|
+
logs = await getLogs(client, {
|
251
|
+
address,
|
252
|
+
args,
|
253
|
+
event: event!,
|
254
|
+
events,
|
255
|
+
fromBlock: previousBlockNumber + 1n,
|
256
|
+
toBlock: blockNumber,
|
257
|
+
} as unknown as GetLogsParameters)
|
258
|
+
} else {
|
259
|
+
logs = []
|
260
|
+
}
|
261
|
+
previousBlockNumber = blockNumber
|
216
262
|
}
|
217
|
-
|
263
|
+
|
264
|
+
if (logs.length === 0) return
|
265
|
+
if (batch) emit.onLogs(logs as any)
|
266
|
+
else logs.forEach((log) => emit.onLogs([log] as any))
|
267
|
+
} catch (err) {
|
268
|
+
// If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.
|
269
|
+
// Reinitalize the filter when this occurs
|
270
|
+
if (filter && err instanceof InvalidInputRpcError)
|
271
|
+
initialized = false
|
272
|
+
emit.onError?.(err as Error)
|
218
273
|
}
|
274
|
+
},
|
275
|
+
{
|
276
|
+
emitOnBegin: true,
|
277
|
+
interval: pollingInterval,
|
278
|
+
},
|
279
|
+
)
|
280
|
+
|
281
|
+
return async () => {
|
282
|
+
if (filter) await uninstallFilter(client, { filter })
|
283
|
+
unwatch()
|
284
|
+
}
|
285
|
+
})
|
286
|
+
}
|
219
287
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
288
|
+
const subscribeEvent = () => {
|
289
|
+
let active = true
|
290
|
+
let unsubscribe = () => (active = false)
|
291
|
+
;(async () => {
|
292
|
+
try {
|
293
|
+
const events_ = events ?? (event ? [event] : undefined)
|
294
|
+
let topics: LogTopic[] = []
|
295
|
+
if (events_) {
|
296
|
+
topics = [
|
297
|
+
(events_ as AbiEvent[]).flatMap((event) =>
|
298
|
+
encodeEventTopics({
|
299
|
+
abi: [event],
|
300
|
+
eventName: (event as AbiEvent).name,
|
301
|
+
args,
|
302
|
+
} as EncodeEventTopicsParameters),
|
303
|
+
),
|
304
|
+
]
|
305
|
+
if (event) topics = topics[0] as LogTopic[]
|
228
306
|
}
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
307
|
+
|
308
|
+
const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({
|
309
|
+
params: ['logs', { address, topics }],
|
310
|
+
onData(data: any) {
|
311
|
+
if (!active) return
|
312
|
+
const log = data.result
|
313
|
+
try {
|
314
|
+
const { eventName, args } = decodeEventLog({
|
315
|
+
abi: events_ as Abi,
|
316
|
+
data: log.data,
|
317
|
+
topics: log.topics as any,
|
318
|
+
strict,
|
319
|
+
})
|
320
|
+
const formatted = formatLog(log, {
|
321
|
+
args,
|
322
|
+
eventName: eventName as string,
|
323
|
+
})
|
324
|
+
onLogs([formatted] as any)
|
325
|
+
} catch (err) {
|
326
|
+
let eventName
|
327
|
+
let isUnnamed
|
328
|
+
if (
|
329
|
+
err instanceof DecodeLogDataMismatch ||
|
330
|
+
err instanceof DecodeLogTopicsMismatch
|
331
|
+
) {
|
332
|
+
// If strict mode is on, and log data/topics do not match event definition, skip.
|
333
|
+
if (strict_) return
|
334
|
+
eventName = err.abiItem.name
|
335
|
+
isUnnamed = err.abiItem.inputs?.some(
|
336
|
+
(x) => !('name' in x && x.name),
|
337
|
+
)
|
338
|
+
}
|
339
|
+
|
340
|
+
// Set args to empty if there is an error decoding (e.g. indexed/non-indexed params mismatch).
|
341
|
+
const formatted = formatLog(log, {
|
342
|
+
args: isUnnamed ? [] : {},
|
343
|
+
eventName,
|
344
|
+
})
|
345
|
+
onLogs([formatted] as any)
|
346
|
+
}
|
347
|
+
},
|
348
|
+
onError(error: Error) {
|
349
|
+
onError?.(error)
|
350
|
+
},
|
351
|
+
})
|
352
|
+
unsubscribe = unsubscribe_
|
353
|
+
if (!active) unsubscribe()
|
354
|
+
} catch (err) {
|
355
|
+
onError?.(err as Error)
|
356
|
+
}
|
357
|
+
})()
|
358
|
+
return unsubscribe
|
359
|
+
}
|
360
|
+
|
361
|
+
return enablePolling ? pollEvent() : subscribeEvent()
|
241
362
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Abi
|
1
|
+
import type { Abi } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
4
|
import type { Client } from '../../clients/createClient.js'
|
@@ -19,12 +19,12 @@ export type DeployContractParameters<
|
|
19
19
|
TAbi extends Abi | readonly unknown[] = Abi,
|
20
20
|
TChain extends Chain | undefined = Chain | undefined,
|
21
21
|
TAccount extends Account | undefined = Account | undefined,
|
22
|
-
TChainOverride extends Chain | undefined = undefined,
|
22
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
23
23
|
> = UnionOmit<
|
24
24
|
SendTransactionParameters<TChain, TAccount, TChainOverride>,
|
25
25
|
'accessList' | 'chain' | 'to' | 'data'
|
26
26
|
> & {
|
27
|
-
abi:
|
27
|
+
abi: TAbi
|
28
28
|
bytecode: Hex
|
29
29
|
} & GetChain<TChain, TChainOverride> &
|
30
30
|
GetConstructorArgs<TAbi>
|
@@ -59,7 +59,7 @@ export type DeployContractReturnType = SendTransactionReturnType
|
|
59
59
|
* })
|
60
60
|
*/
|
61
61
|
export function deployContract<
|
62
|
-
TAbi extends Abi | readonly unknown[],
|
62
|
+
const TAbi extends Abi | readonly unknown[],
|
63
63
|
TChain extends Chain | undefined,
|
64
64
|
TAccount extends Account | undefined,
|
65
65
|
TChainOverride extends Chain | undefined,
|
@@ -11,7 +11,7 @@ import type {
|
|
11
11
|
TransactionRequest,
|
12
12
|
TransactionSerializable,
|
13
13
|
} from '../../types/transaction.js'
|
14
|
-
import type {
|
14
|
+
import type { UnionOmit } from '../../types/utils.js'
|
15
15
|
import { assertCurrentChain } from '../../utils/chain.js'
|
16
16
|
import { getTransactionError } from '../../utils/errors/getTransactionError.js'
|
17
17
|
import { extract } from '../../utils/formatters/extract.js'
|
@@ -19,17 +19,20 @@ import {
|
|
19
19
|
type FormattedTransactionRequest,
|
20
20
|
formatTransactionRequest,
|
21
21
|
} from '../../utils/formatters/transactionRequest.js'
|
22
|
-
import {
|
22
|
+
import {
|
23
|
+
type AssertRequestParameters,
|
24
|
+
assertRequest,
|
25
|
+
} from '../../utils/transaction/assertRequest.js'
|
23
26
|
import { prepareRequest } from '../../utils/transaction/prepareRequest.js'
|
24
27
|
import { getChainId } from '../public/getChainId.js'
|
25
28
|
|
26
29
|
export type SendTransactionParameters<
|
27
30
|
TChain extends Chain | undefined = Chain | undefined,
|
28
31
|
TAccount extends Account | undefined = Account | undefined,
|
29
|
-
TChainOverride extends Chain | undefined = Chain,
|
32
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
30
33
|
> = UnionOmit<
|
31
34
|
FormattedTransactionRequest<
|
32
|
-
|
35
|
+
TChainOverride extends Chain ? TChainOverride : TChain
|
33
36
|
>,
|
34
37
|
'from'
|
35
38
|
> &
|
@@ -113,7 +116,7 @@ export async function sendTransaction<
|
|
113
116
|
const account = parseAccount(account_)
|
114
117
|
|
115
118
|
try {
|
116
|
-
assertRequest(args)
|
119
|
+
assertRequest(args as AssertRequestParameters)
|
117
120
|
|
118
121
|
let chainId
|
119
122
|
if (chain !== null) {
|
@@ -139,7 +142,7 @@ export async function sendTransaction<
|
|
139
142
|
to,
|
140
143
|
value,
|
141
144
|
...rest,
|
142
|
-
})
|
145
|
+
} as any)
|
143
146
|
|
144
147
|
if (!chainId) chainId = await getChainId(client)
|
145
148
|
|
@@ -121,7 +121,7 @@ export type SignTypedDataReturnType = Hex
|
|
121
121
|
* })
|
122
122
|
*/
|
123
123
|
export async function signTypedData<
|
124
|
-
TTypedData extends TypedData | { [key: string]: unknown },
|
124
|
+
const TTypedData extends TypedData | { [key: string]: unknown },
|
125
125
|
TPrimaryType extends string,
|
126
126
|
TChain extends Chain | undefined,
|
127
127
|
TAccount extends Account | undefined,
|
@@ -3,6 +3,7 @@ import type { Abi } from 'abitype'
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
4
|
import type { Client } from '../../clients/createClient.js'
|
5
5
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
6
|
+
import type { GetAccountParameter } from '../../types/account.js'
|
6
7
|
import type { Chain, GetChain } from '../../types/chain.js'
|
7
8
|
import type { ContractFunctionConfig, GetValue } from '../../types/contract.js'
|
8
9
|
import type { Hex } from '../../types/misc.js'
|
@@ -11,7 +12,7 @@ import {
|
|
11
12
|
type EncodeFunctionDataParameters,
|
12
13
|
encodeFunctionData,
|
13
14
|
} from '../../utils/abi/encodeFunctionData.js'
|
14
|
-
|
15
|
+
import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
15
16
|
import {
|
16
17
|
type SendTransactionParameters,
|
17
18
|
type SendTransactionReturnType,
|
@@ -22,14 +23,17 @@ export type WriteContractParameters<
|
|
22
23
|
TAbi extends Abi | readonly unknown[] = Abi,
|
23
24
|
TFunctionName extends string = string,
|
24
25
|
TChain extends Chain | undefined = Chain,
|
25
|
-
TAccount extends Account | undefined = undefined,
|
26
|
-
TChainOverride extends Chain | undefined = undefined,
|
26
|
+
TAccount extends Account | undefined = Account | undefined,
|
27
|
+
TChainOverride extends Chain | undefined = Chain | undefined,
|
27
28
|
> = ContractFunctionConfig<TAbi, TFunctionName, 'payable' | 'nonpayable'> &
|
29
|
+
GetAccountParameter<TAccount> &
|
30
|
+
GetChain<TChain, TChainOverride> &
|
28
31
|
UnionOmit<
|
29
|
-
|
30
|
-
|
32
|
+
FormattedTransactionRequest<
|
33
|
+
TChainOverride extends Chain ? TChainOverride : TChain
|
34
|
+
>,
|
35
|
+
'from' | 'to' | 'data' | 'value'
|
31
36
|
> &
|
32
|
-
GetChain<TChain, TChainOverride> &
|
33
37
|
GetValue<
|
34
38
|
TAbi,
|
35
39
|
TFunctionName,
|
@@ -100,9 +104,9 @@ export type WriteContractReturnType = SendTransactionReturnType
|
|
100
104
|
export async function writeContract<
|
101
105
|
TChain extends Chain | undefined,
|
102
106
|
TAccount extends Account | undefined,
|
103
|
-
TAbi extends Abi | readonly unknown[],
|
107
|
+
const TAbi extends Abi | readonly unknown[],
|
104
108
|
TFunctionName extends string,
|
105
|
-
TChainOverride extends Chain | undefined
|
109
|
+
TChainOverride extends Chain | undefined,
|
106
110
|
>(
|
107
111
|
client: Client<Transport, TChain, TAccount>,
|
108
112
|
{
|
@@ -1,9 +1,5 @@
|
|
1
|
-
import type
|
2
|
-
|
3
|
-
import { type Formatters } from '../../types/formatter.js'
|
4
|
-
import type { Hash, Hex } from '../../types/misc.js'
|
5
|
-
import type { RpcTransaction } from '../../types/rpc.js'
|
6
|
-
import type { Transaction } from '../../types/transaction.js'
|
1
|
+
import { type ChainFormatters } from '../../types/chain.js'
|
2
|
+
import type { Hash } from '../../types/misc.js'
|
7
3
|
import { hexToBigInt } from '../../utils/encoding/fromHex.js'
|
8
4
|
import { numberToHex } from '../../utils/encoding/toHex.js'
|
9
5
|
import { defineBlock } from '../../utils/formatters/block.js'
|
@@ -13,47 +9,28 @@ import {
|
|
13
9
|
} from '../../utils/formatters/transaction.js'
|
14
10
|
import { defineTransactionReceipt } from '../../utils/formatters/transactionReceipt.js'
|
15
11
|
import { defineTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
gatewayFee: Hex | null
|
28
|
-
gatewayFeeRecipient: Address | null
|
29
|
-
})[]
|
30
|
-
}
|
31
|
-
RpcTransaction: {
|
32
|
-
feeCurrency: Address | null
|
33
|
-
gatewayFee: Hex | null
|
34
|
-
gatewayFeeRecipient: Address | null
|
35
|
-
}
|
36
|
-
RpcTransactionReceipt: {
|
37
|
-
feeCurrency: Address | null
|
38
|
-
gatewayFee: Hex | null
|
39
|
-
gatewayFeeRecipient: Address | null
|
40
|
-
}
|
41
|
-
TransactionRequest: {
|
42
|
-
feeCurrency?: Address
|
43
|
-
gatewayFee?: bigint
|
44
|
-
gatewayFeeRecipient?: Address
|
45
|
-
}
|
46
|
-
Transaction: {
|
47
|
-
feeCurrency: Address | null
|
48
|
-
gatewayFee: bigint | null
|
49
|
-
gatewayFeeRecipient: Address | null
|
50
|
-
}
|
51
|
-
}
|
12
|
+
import type {
|
13
|
+
CeloBlockOverrides,
|
14
|
+
CeloRpcTransaction,
|
15
|
+
CeloRpcTransactionOverrides,
|
16
|
+
CeloRpcTransactionReceiptOverrides,
|
17
|
+
CeloRpcTransactionRequestOverrides,
|
18
|
+
CeloTransaction,
|
19
|
+
CeloTransactionOverrides,
|
20
|
+
CeloTransactionReceiptOverrides,
|
21
|
+
CeloTransactionRequestOverrides,
|
22
|
+
} from './types.js'
|
52
23
|
|
53
24
|
export const formattersCelo = {
|
54
25
|
block: /*#__PURE__*/ defineBlock({
|
55
26
|
exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
|
56
|
-
format(
|
27
|
+
format(
|
28
|
+
args: CeloBlockOverrides & {
|
29
|
+
transactions: Hash[] | CeloRpcTransaction[]
|
30
|
+
},
|
31
|
+
): CeloBlockOverrides & {
|
32
|
+
transactions: Hash[] | CeloTransaction[]
|
33
|
+
} {
|
57
34
|
const transactions = args.transactions?.map((transaction) => {
|
58
35
|
if (typeof transaction === 'string') return transaction
|
59
36
|
return {
|
@@ -64,7 +41,7 @@ export const formattersCelo = {
|
|
64
41
|
: null,
|
65
42
|
gatewayFeeRecipient: transaction.gatewayFeeRecipient,
|
66
43
|
}
|
67
|
-
}) as Hash[] |
|
44
|
+
}) as Hash[] | CeloTransaction[]
|
68
45
|
return {
|
69
46
|
randomness: args.randomness,
|
70
47
|
transactions,
|
@@ -72,7 +49,7 @@ export const formattersCelo = {
|
|
72
49
|
},
|
73
50
|
}),
|
74
51
|
transaction: /*#__PURE__*/ defineTransaction({
|
75
|
-
format(args:
|
52
|
+
format(args: CeloRpcTransactionOverrides): CeloTransactionOverrides {
|
76
53
|
return {
|
77
54
|
feeCurrency: args.feeCurrency,
|
78
55
|
gatewayFee: args.gatewayFee ? hexToBigInt(args.gatewayFee) : null,
|
@@ -81,7 +58,9 @@ export const formattersCelo = {
|
|
81
58
|
},
|
82
59
|
}),
|
83
60
|
transactionReceipt: /*#__PURE__*/ defineTransactionReceipt({
|
84
|
-
format(
|
61
|
+
format(
|
62
|
+
args: CeloRpcTransactionReceiptOverrides,
|
63
|
+
): CeloTransactionReceiptOverrides {
|
85
64
|
return {
|
86
65
|
feeCurrency: args.feeCurrency,
|
87
66
|
gatewayFee: args.gatewayFee ? hexToBigInt(args.gatewayFee) : null,
|
@@ -90,7 +69,9 @@ export const formattersCelo = {
|
|
90
69
|
},
|
91
70
|
}),
|
92
71
|
transactionRequest: /*#__PURE__*/ defineTransactionRequest({
|
93
|
-
format(
|
72
|
+
format(
|
73
|
+
args: CeloTransactionRequestOverrides,
|
74
|
+
): CeloRpcTransactionRequestOverrides {
|
94
75
|
return {
|
95
76
|
feeCurrency: args.feeCurrency,
|
96
77
|
gatewayFee:
|
@@ -101,4 +82,4 @@ export const formattersCelo = {
|
|
101
82
|
}
|
102
83
|
},
|
103
84
|
}),
|
104
|
-
} as const satisfies
|
85
|
+
} as const satisfies ChainFormatters
|