viem 0.0.1-sushi.26 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +132 -2
- package/abi/package.json +4 -0
- package/dist/abi.d.ts +6 -0
- package/dist/abi.js +21 -0
- package/dist/abi.js.map +1 -0
- package/dist/abi.mjs +21 -0
- package/dist/abi.mjs.map +1 -0
- package/dist/chain-819c7ff7.d.ts +553 -0
- package/dist/{chain-c4ccb458.d.ts → chain-a4f98ba3.d.ts} +1 -1
- package/dist/chains.d.ts +5 -3
- package/dist/chains.js +46 -46
- package/dist/chains.mjs +1 -1
- package/dist/chunk-APZXOA44.mjs +208 -0
- package/dist/chunk-APZXOA44.mjs.map +1 -0
- package/dist/chunk-HCZO3OIX.js +208 -0
- package/dist/chunk-HCZO3OIX.js.map +1 -0
- package/dist/{chunk-SD5X7F4U.mjs → chunk-I7AINPMM.mjs} +2756 -456
- package/dist/chunk-I7AINPMM.mjs.map +1 -0
- package/dist/chunk-QJNPIGP5.js +5326 -0
- package/dist/chunk-QJNPIGP5.js.map +1 -0
- package/dist/contract.d.ts +9 -122
- package/dist/contract.js +4 -4
- package/dist/contract.mjs +18 -18
- package/dist/{createClient-68ee4bb4.d.ts → createClient-a47ae6f5.d.ts} +13 -13
- package/dist/createPublicClient-e2eae0fc.d.ts +771 -0
- package/dist/{eip1193-6f9ba163.d.ts → eip1193-a882d1b8.d.ts} +14 -3
- package/dist/encodeFunctionResult-9eb553ce.d.ts +75 -0
- package/dist/encodePacked-4c019ed8.d.ts +12 -0
- package/dist/ens.d.ts +8 -69
- package/dist/ens.js +4 -199
- package/dist/ens.js.map +1 -1
- package/dist/ens.mjs +6 -201
- package/dist/ens.mjs.map +1 -1
- package/dist/formatAbiItem-622d2303.d.ts +14 -0
- package/dist/getAbiItem-159f3263.d.ts +22 -0
- package/dist/index.d.ts +106 -55
- package/dist/index.js +451 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +445 -35
- package/dist/index.mjs.map +1 -1
- package/dist/namehash-afff0feb.d.ts +25 -0
- package/dist/parseGwei-a2d0d77a.d.ts +497 -0
- package/dist/public.d.ts +11 -336
- package/dist/public.js +4 -3
- package/dist/public.mjs +3 -2
- package/dist/test-13f4413b.d.ts +205 -0
- package/dist/test.d.ts +8 -149
- package/dist/test.js +19 -222
- package/dist/test.js.map +1 -1
- package/dist/test.mjs +29 -232
- package/dist/test.mjs.map +1 -1
- package/dist/utils/index.d.ts +44 -231
- package/dist/utils/index.js +30 -2
- package/dist/utils/index.mjs +61 -33
- package/dist/wallet.d.ts +6 -41
- package/dist/wallet.js +2 -3
- package/dist/wallet.mjs +5 -6
- package/dist/window.d.ts +4 -2
- package/package.json +11 -6
- package/public/package.json +4 -0
- package/test/package.json +4 -0
- package/dist/call-ac509982.d.ts +0 -23
- package/dist/chain-f16512e8.d.ts +0 -372
- package/dist/chunk-2PFNLP3F.js +0 -192
- package/dist/chunk-2PFNLP3F.js.map +0 -1
- package/dist/chunk-5ND4P6QL.mjs +0 -192
- package/dist/chunk-5ND4P6QL.mjs.map +0 -1
- package/dist/chunk-NXCI5KQC.js +0 -3026
- package/dist/chunk-NXCI5KQC.js.map +0 -1
- package/dist/chunk-O7T5NQLB.mjs +0 -1091
- package/dist/chunk-O7T5NQLB.mjs.map +0 -1
- package/dist/chunk-SD5X7F4U.mjs.map +0 -1
- package/dist/chunk-UTL6F7UN.js +0 -1091
- package/dist/chunk-UTL6F7UN.js.map +0 -1
- package/dist/contract-9e76e561.d.ts +0 -166
- package/dist/createPublicClient-b732194e.d.ts +0 -19
- package/dist/createTestClient-dedf321e.d.ts +0 -34
- package/dist/createWalletClient-75813d83.d.ts +0 -30
- package/dist/decodeErrorResult-0b934d23.d.ts +0 -16
- package/dist/getAbiItem-c8e6e7d4.d.ts +0 -97
- package/dist/readContract-4f6e2692.d.ts +0 -10
- package/dist/rpc-a5a7f376.d.ts +0 -121
- package/dist/sendTransaction-e713f90c.d.ts +0 -12
- package/dist/transactionReceipt-2a86c7c7.d.ts +0 -26
- package/dist/transactionRequest-c7794f5e.d.ts +0 -15
- package/dist/watchEvent-c346c12d.d.ts +0 -41
- package/src/_test/abis.ts +0 -1420
- package/src/_test/bench.ts +0 -15
- package/src/_test/constants.ts +0 -63
- package/src/_test/generated.ts +0 -128
- package/src/_test/globalSetup.ts +0 -11
- package/src/_test/index.ts +0 -25
- package/src/_test/setup.ts +0 -8
- package/src/_test/utils.ts +0 -155
- package/src/actions/ens/getEnsAddress.bench.ts +0 -26
- package/src/actions/ens/getEnsAddress.test.ts +0 -97
- package/src/actions/ens/getEnsAddress.ts +0 -122
- package/src/actions/ens/getEnsName.bench.ts +0 -30
- package/src/actions/ens/getEnsName.test.ts +0 -101
- package/src/actions/ens/getEnsName.ts +0 -106
- package/src/actions/ens/index.test.ts +0 -12
- package/src/actions/ens/index.ts +0 -3
- package/src/actions/index.test.ts +0 -81
- package/src/actions/index.ts +0 -182
- package/src/actions/public/call.bench.ts +0 -48
- package/src/actions/public/call.test.ts +0 -99
- package/src/actions/public/call.ts +0 -97
- package/src/actions/public/createBlockFilter.bench.ts +0 -11
- package/src/actions/public/createBlockFilter.test.ts +0 -9
- package/src/actions/public/createBlockFilter.ts +0 -14
- package/src/actions/public/createContractEventFilter.test.ts +0 -119
- package/src/actions/public/createContractEventFilter.ts +0 -69
- package/src/actions/public/createEventFilter.test.ts +0 -277
- package/src/actions/public/createEventFilter.ts +0 -93
- package/src/actions/public/createPendingTransactionFilter.bench.ts +0 -11
- package/src/actions/public/createPendingTransactionFilter.test.ts +0 -9
- package/src/actions/public/createPendingTransactionFilter.ts +0 -14
- package/src/actions/public/estimateGas.bench.ts +0 -46
- package/src/actions/public/estimateGas.test.ts +0 -92
- package/src/actions/public/estimateGas.ts +0 -61
- package/src/actions/public/getBalance.test.ts +0 -83
- package/src/actions/public/getBalance.ts +0 -37
- package/src/actions/public/getBlock.bench.ts +0 -28
- package/src/actions/public/getBlock.test.ts +0 -575
- package/src/actions/public/getBlock.ts +0 -65
- package/src/actions/public/getBlockNumber.bench.ts +0 -28
- package/src/actions/public/getBlockNumber.test.ts +0 -27
- package/src/actions/public/getBlockNumber.ts +0 -32
- package/src/actions/public/getBlockTransactionCount.bench.ts +0 -15
- package/src/actions/public/getBlockTransactionCount.test.ts +0 -57
- package/src/actions/public/getBlockTransactionCount.ts +0 -52
- package/src/actions/public/getBytecode.test.ts +0 -27
- package/src/actions/public/getBytecode.ts +0 -32
- package/src/actions/public/getChainId.bench.ts +0 -15
- package/src/actions/public/getChainId.test.ts +0 -8
- package/src/actions/public/getChainId.ts +0 -7
- package/src/actions/public/getFeeHistory.bench.ts +0 -18
- package/src/actions/public/getFeeHistory.test.ts +0 -137
- package/src/actions/public/getFeeHistory.ts +0 -44
- package/src/actions/public/getFilterChanges.bench.ts +0 -13
- package/src/actions/public/getFilterChanges.test.ts +0 -383
- package/src/actions/public/getFilterChanges.ts +0 -23
- package/src/actions/public/getFilterLogs.test.ts +0 -297
- package/src/actions/public/getFilterLogs.ts +0 -20
- package/src/actions/public/getGasPrice.bench.ts +0 -19
- package/src/actions/public/getGasPrice.test.ts +0 -8
- package/src/actions/public/getGasPrice.ts +0 -15
- package/src/actions/public/getLogs.test.ts +0 -306
- package/src/actions/public/getLogs.ts +0 -84
- package/src/actions/public/getStorageAt.test.ts +0 -34
- package/src/actions/public/getStorageAt.ts +0 -32
- package/src/actions/public/getTransaction.bench.ts +0 -33
- package/src/actions/public/getTransaction.test.ts +0 -311
- package/src/actions/public/getTransaction.ts +0 -95
- package/src/actions/public/getTransactionConfirmations.test.ts +0 -69
- package/src/actions/public/getTransactionConfirmations.ts +0 -38
- package/src/actions/public/getTransactionCount.test.ts +0 -56
- package/src/actions/public/getTransactionCount.ts +0 -34
- package/src/actions/public/getTransactionReceipt.bench.ts +0 -33
- package/src/actions/public/getTransactionReceipt.test.ts +0 -179
- package/src/actions/public/getTransactionReceipt.ts +0 -34
- package/src/actions/public/index.test.ts +0 -43
- package/src/actions/public/index.ts +0 -146
- package/src/actions/public/multicall.test.ts +0 -452
- package/src/actions/public/multicall.ts +0 -108
- package/src/actions/public/readContract.test.ts +0 -328
- package/src/actions/public/readContract.ts +0 -73
- package/src/actions/public/simulateContract.bench.ts +0 -41
- package/src/actions/public/simulateContract.test.ts +0 -410
- package/src/actions/public/simulateContract.ts +0 -91
- package/src/actions/public/uninstallFilter.bench.ts +0 -13
- package/src/actions/public/uninstallFilter.test.ts +0 -65
- package/src/actions/public/uninstallFilter.ts +0 -17
- package/src/actions/public/waitForTransactionReceipt.test.ts +0 -322
- package/src/actions/public/waitForTransactionReceipt.ts +0 -170
- package/src/actions/public/watchBlockNumber.test.ts +0 -166
- package/src/actions/public/watchBlockNumber.ts +0 -79
- package/src/actions/public/watchBlocks.test.ts +0 -210
- package/src/actions/public/watchBlocks.ts +0 -114
- package/src/actions/public/watchContractEvent.test.ts +0 -305
- package/src/actions/public/watchContractEvent.ts +0 -108
- package/src/actions/public/watchEvent.test.ts +0 -195
- package/src/actions/public/watchEvent.ts +0 -95
- package/src/actions/public/watchPendingTransactions.test.ts +0 -116
- package/src/actions/public/watchPendingTransactions.ts +0 -74
- package/src/actions/test/dropTransaction.test.ts +0 -34
- package/src/actions/test/dropTransaction.ts +0 -17
- package/src/actions/test/getAutomine.test.ts +0 -14
- package/src/actions/test/getAutomine.ts +0 -11
- package/src/actions/test/getTxpoolContent.test.ts +0 -45
- package/src/actions/test/getTxpoolContent.ts +0 -7
- package/src/actions/test/getTxpoolStatus.test.ts +0 -41
- package/src/actions/test/getTxpoolStatus.ts +0 -12
- package/src/actions/test/impersonateAccount.test.ts +0 -26
- package/src/actions/test/impersonateAccount.ts +0 -17
- package/src/actions/test/increaseTime.test.ts +0 -18
- package/src/actions/test/increaseTime.ts +0 -17
- package/src/actions/test/index.test.ts +0 -38
- package/src/actions/test/index.ts +0 -77
- package/src/actions/test/inspectTxpool.test.ts +0 -50
- package/src/actions/test/inspectTxpool.ts +0 -7
- package/src/actions/test/mine.test.ts +0 -20
- package/src/actions/test/mine.ts +0 -16
- package/src/actions/test/removeBlockTimestampInterval.test.ts +0 -23
- package/src/actions/test/removeBlockTimestampInterval.ts +0 -7
- package/src/actions/test/reset.test.ts +0 -19
- package/src/actions/test/reset.ts +0 -18
- package/src/actions/test/revert.test.ts +0 -39
- package/src/actions/test/revert.ts +0 -14
- package/src/actions/test/sendUnsignedTransaction.test.ts +0 -52
- package/src/actions/test/sendUnsignedTransaction.ts +0 -19
- package/src/actions/test/setAutomine.test.ts +0 -14
- package/src/actions/test/setAutomine.ts +0 -8
- package/src/actions/test/setBalance.test.ts +0 -29
- package/src/actions/test/setBalance.ts +0 -20
- package/src/actions/test/setBlockGasLimit.test.ts +0 -21
- package/src/actions/test/setBlockGasLimit.ts +0 -17
- package/src/actions/test/setBlockTimestampInterval.test.ts +0 -23
- package/src/actions/test/setBlockTimestampInterval.ts +0 -16
- package/src/actions/test/setCode.test.ts +0 -26
- package/src/actions/test/setCode.ts +0 -19
- package/src/actions/test/setCoinbase.test.ts +0 -11
- package/src/actions/test/setCoinbase.ts +0 -17
- package/src/actions/test/setIntervalMining.test.ts +0 -30
- package/src/actions/test/setIntervalMining.ts +0 -16
- package/src/actions/test/setLoggingEnabled.test.ts +0 -10
- package/src/actions/test/setLoggingEnabled.ts +0 -8
- package/src/actions/test/setMinGasPrice.test.ts +0 -22
- package/src/actions/test/setMinGasPrice.ts +0 -17
- package/src/actions/test/setNextBlockBaseFeePerGas.test.ts +0 -23
- package/src/actions/test/setNextBlockBaseFeePerGas.ts +0 -17
- package/src/actions/test/setNextBlockTimestamp.test.ts +0 -19
- package/src/actions/test/setNextBlockTimestamp.ts +0 -17
- package/src/actions/test/setNonce.test.ts +0 -28
- package/src/actions/test/setNonce.ts +0 -20
- package/src/actions/test/setRpcUrl.test.ts +0 -9
- package/src/actions/test/setRpcUrl.ts +0 -8
- package/src/actions/test/setStorageAt.test.ts +0 -36
- package/src/actions/test/setStorageAt.ts +0 -26
- package/src/actions/test/snapshot.test.ts +0 -18
- package/src/actions/test/snapshot.ts +0 -7
- package/src/actions/test/stopImpersonatingAccount.test.ts +0 -29
- package/src/actions/test/stopImpersonatingAccount.ts +0 -17
- package/src/actions/wallet/addChain.test.ts +0 -14
- package/src/actions/wallet/addChain.ts +0 -21
- package/src/actions/wallet/deployContract.test.ts +0 -55
- package/src/actions/wallet/deployContract.ts +0 -38
- package/src/actions/wallet/getAccounts.test.ts +0 -22
- package/src/actions/wallet/getAccounts.ts +0 -7
- package/src/actions/wallet/getPermissions.test.ts +0 -24
- package/src/actions/wallet/getPermissions.ts +0 -9
- package/src/actions/wallet/index.test.ts +0 -21
- package/src/actions/wallet/index.ts +0 -36
- package/src/actions/wallet/requestAccounts.test.ts +0 -13
- package/src/actions/wallet/requestAccounts.ts +0 -7
- package/src/actions/wallet/requestPermissions.test.ts +0 -26
- package/src/actions/wallet/requestPermissions.ts +0 -19
- package/src/actions/wallet/sendTransaction.bench.ts +0 -57
- package/src/actions/wallet/sendTransaction.test.ts +0 -440
- package/src/actions/wallet/sendTransaction.ts +0 -77
- package/src/actions/wallet/signMessage.test.ts +0 -61
- package/src/actions/wallet/signMessage.ts +0 -35
- package/src/actions/wallet/switchChain.test.ts +0 -21
- package/src/actions/wallet/switchChain.ts +0 -19
- package/src/actions/wallet/watchAsset.test.ts +0 -40
- package/src/actions/wallet/watchAsset.ts +0 -16
- package/src/actions/wallet/writeContract.test.ts +0 -84
- package/src/actions/wallet/writeContract.ts +0 -47
- package/src/chains.test.ts +0 -439
- package/src/chains.ts +0 -99
- package/src/clients/createClient.test.ts +0 -295
- package/src/clients/createClient.ts +0 -81
- package/src/clients/createPublicClient.test.ts +0 -165
- package/src/clients/createPublicClient.ts +0 -49
- package/src/clients/createTestClient.test.ts +0 -145
- package/src/clients/createTestClient.ts +0 -72
- package/src/clients/createWalletClient.test.ts +0 -121
- package/src/clients/createWalletClient.ts +0 -54
- package/src/clients/index.test.ts +0 -19
- package/src/clients/index.ts +0 -31
- package/src/clients/transports/createTransport.test.ts +0 -58
- package/src/clients/transports/createTransport.ts +0 -48
- package/src/clients/transports/custom.test.ts +0 -98
- package/src/clients/transports/custom.ts +0 -34
- package/src/clients/transports/fallback.test.ts +0 -393
- package/src/clients/transports/fallback.ts +0 -58
- package/src/clients/transports/http.test.ts +0 -109
- package/src/clients/transports/http.ts +0 -51
- package/src/clients/transports/index.test.ts +0 -15
- package/src/clients/transports/index.ts +0 -17
- package/src/clients/transports/webSocket.test.ts +0 -164
- package/src/clients/transports/webSocket.ts +0 -118
- package/src/constants/abis.test.ts +0 -53
- package/src/constants/abis.ts +0 -44
- package/src/constants/index.test.ts +0 -14
- package/src/constants/index.ts +0 -3
- package/src/constants/solidity.test.ts +0 -41
- package/src/constants/solidity.ts +0 -35
- package/src/contract.test.ts +0 -32
- package/src/contract.ts +0 -68
- package/src/ens.test.ts +0 -15
- package/src/ens.ts +0 -8
- package/src/errors/abi.test.ts +0 -81
- package/src/errors/abi.ts +0 -254
- package/src/errors/address.test.ts +0 -14
- package/src/errors/address.ts +0 -9
- package/src/errors/base.test.ts +0 -114
- package/src/errors/base.ts +0 -57
- package/src/errors/block.test.ts +0 -24
- package/src/errors/block.ts +0 -18
- package/src/errors/chain.test.ts +0 -46
- package/src/errors/chain.ts +0 -33
- package/src/errors/contract.test.ts +0 -233
- package/src/errors/contract.ts +0 -178
- package/src/errors/data.ts +0 -20
- package/src/errors/encoding.ts +0 -60
- package/src/errors/index.ts +0 -82
- package/src/errors/log.ts +0 -8
- package/src/errors/request.test.ts +0 -330
- package/src/errors/request.ts +0 -163
- package/src/errors/rpc.test.ts +0 -87
- package/src/errors/rpc.ts +0 -113
- package/src/errors/transaction.test.ts +0 -83
- package/src/errors/transaction.ts +0 -54
- package/src/errors/transport.test.ts +0 -11
- package/src/errors/transport.ts +0 -12
- package/src/index.test.ts +0 -116
- package/src/index.ts +0 -132
- package/src/public.test.ts +0 -36
- package/src/public.ts +0 -76
- package/src/test.test.ts +0 -38
- package/src/test.ts +0 -52
- package/src/types/block.ts +0 -71
- package/src/types/chain.ts +0 -6
- package/src/types/contract.ts +0 -497
- package/src/types/eip1193.ts +0 -1041
- package/src/types/fee.ts +0 -47
- package/src/types/filter.ts +0 -8
- package/src/types/formatter.ts +0 -23
- package/src/types/index.ts +0 -84
- package/src/types/log.ts +0 -22
- package/src/types/misc.ts +0 -5
- package/src/types/multicall.ts +0 -82
- package/src/types/rpc.ts +0 -35
- package/src/types/transaction.ts +0 -145
- package/src/types/utils.ts +0 -88
- package/src/types/window.ts +0 -9
- package/src/utils/abi/decodeAbi.bench.ts +0 -135
- package/src/utils/abi/decodeAbi.test.ts +0 -1614
- package/src/utils/abi/decodeAbi.ts +0 -300
- package/src/utils/abi/decodeDeployData.test.ts +0 -151
- package/src/utils/abi/decodeDeployData.ts +0 -44
- package/src/utils/abi/decodeErrorResult.test.ts +0 -230
- package/src/utils/abi/decodeErrorResult.ts +0 -45
- package/src/utils/abi/decodeEventLog.test.ts +0 -542
- package/src/utils/abi/decodeEventLog.ts +0 -107
- package/src/utils/abi/decodeFunctionData.test.ts +0 -138
- package/src/utils/abi/decodeFunctionData.ts +0 -32
- package/src/utils/abi/decodeFunctionResult.test.ts +0 -333
- package/src/utils/abi/decodeFunctionResult.ts +0 -57
- package/src/utils/abi/encodeAbi.bench.ts +0 -163
- package/src/utils/abi/encodeAbi.test.ts +0 -1447
- package/src/utils/abi/encodeAbi.ts +0 -273
- package/src/utils/abi/encodeDeployData.test.ts +0 -124
- package/src/utils/abi/encodeDeployData.ts +0 -40
- package/src/utils/abi/encodeErrorResult.test.ts +0 -192
- package/src/utils/abi/encodeErrorResult.ts +0 -47
- package/src/utils/abi/encodeEventTopics.test.ts +0 -345
- package/src/utils/abi/encodeEventTopics.ts +0 -75
- package/src/utils/abi/encodeFunctionData.test.ts +0 -138
- package/src/utils/abi/encodeFunctionData.ts +0 -42
- package/src/utils/abi/encodeFunctionResult.test.ts +0 -279
- package/src/utils/abi/encodeFunctionResult.ts +0 -41
- package/src/utils/abi/formatAbiItem.test.ts +0 -335
- package/src/utils/abi/formatAbiItem.ts +0 -41
- package/src/utils/abi/formatAbiItemWithArgs.test.ts +0 -291
- package/src/utils/abi/formatAbiItemWithArgs.ts +0 -27
- package/src/utils/abi/getAbiItem.test.ts +0 -547
- package/src/utils/abi/getAbiItem.ts +0 -95
- package/src/utils/abi/index.test.ts +0 -24
- package/src/utils/abi/index.ts +0 -48
- package/src/utils/address/getAddress.bench.ts +0 -22
- package/src/utils/address/getAddress.test.ts +0 -46
- package/src/utils/address/getAddress.ts +0 -28
- package/src/utils/address/getContractAddress.bench.ts +0 -20
- package/src/utils/address/getContractAddress.test.ts +0 -78
- package/src/utils/address/getContractAddress.ts +0 -59
- package/src/utils/address/index.test.ts +0 -17
- package/src/utils/address/index.ts +0 -16
- package/src/utils/address/isAddress.test.ts +0 -10
- package/src/utils/address/isAddress.ts +0 -10
- package/src/utils/address/isAddressEqual.test.ts +0 -55
- package/src/utils/address/isAddressEqual.ts +0 -6
- package/src/utils/buildRequest.test.ts +0 -428
- package/src/utils/buildRequest.ts +0 -72
- package/src/utils/chain.test.ts +0 -43
- package/src/utils/chain.ts +0 -8
- package/src/utils/contract/extractFunctionParts.test.ts +0 -109
- package/src/utils/contract/extractFunctionParts.ts +0 -27
- package/src/utils/contract/getContractError.test.ts +0 -282
- package/src/utils/contract/getContractError.ts +0 -58
- package/src/utils/contract/index.test.ts +0 -15
- package/src/utils/contract/index.ts +0 -8
- package/src/utils/data/concat.test.ts +0 -35
- package/src/utils/data/concat.ts +0 -34
- package/src/utils/data/index.test.ts +0 -23
- package/src/utils/data/index.ts +0 -13
- package/src/utils/data/isBytes.test.ts +0 -9
- package/src/utils/data/isBytes.ts +0 -7
- package/src/utils/data/isHex.test.ts +0 -13
- package/src/utils/data/isHex.ts +0 -5
- package/src/utils/data/pad.bench.ts +0 -30
- package/src/utils/data/pad.test.ts +0 -367
- package/src/utils/data/pad.ts +0 -53
- package/src/utils/data/size.test.ts +0 -18
- package/src/utils/data/size.ts +0 -13
- package/src/utils/data/slice.test.ts +0 -203
- package/src/utils/data/slice.ts +0 -60
- package/src/utils/data/trim.bench.ts +0 -34
- package/src/utils/data/trim.test.ts +0 -175
- package/src/utils/data/trim.ts +0 -33
- package/src/utils/encoding/decodeBytes.bench.ts +0 -40
- package/src/utils/encoding/decodeBytes.test.ts +0 -144
- package/src/utils/encoding/decodeBytes.ts +0 -63
- package/src/utils/encoding/decodeHex.bench.ts +0 -24
- package/src/utils/encoding/decodeHex.test.ts +0 -167
- package/src/utils/encoding/decodeHex.ts +0 -76
- package/src/utils/encoding/decodeRlp.bench.ts +0 -34
- package/src/utils/encoding/decodeRlp.test.ts +0 -350
- package/src/utils/encoding/decodeRlp.ts +0 -121
- package/src/utils/encoding/encodeBytes.bench.ts +0 -29
- package/src/utils/encoding/encodeBytes.test.ts +0 -676
- package/src/utils/encoding/encodeBytes.ts +0 -59
- package/src/utils/encoding/encodeHex.bench.ts +0 -49
- package/src/utils/encoding/encodeHex.test.ts +0 -232
- package/src/utils/encoding/encodeHex.ts +0 -104
- package/src/utils/encoding/encodeRlp.bench.ts +0 -54
- package/src/utils/encoding/encodeRlp.test.ts +0 -254
- package/src/utils/encoding/encodeRlp.ts +0 -48
- package/src/utils/encoding/index.test.ts +0 -32
- package/src/utils/encoding/index.ts +0 -36
- package/src/utils/ens/index.test.ts +0 -14
- package/src/utils/ens/index.ts +0 -7
- package/src/utils/ens/labelhash.test.ts +0 -55
- package/src/utils/ens/labelhash.ts +0 -16
- package/src/utils/ens/namehash.test.ts +0 -65
- package/src/utils/ens/namehash.ts +0 -28
- package/src/utils/ens/normalize.bench.ts +0 -14
- package/src/utils/ens/normalize.test.ts +0 -35
- package/src/utils/ens/normalize.ts +0 -14
- package/src/utils/ens/packetToBytes.test.ts +0 -11
- package/src/utils/ens/packetToBytes.ts +0 -29
- package/src/utils/formatters/block.bench.ts +0 -51
- package/src/utils/formatters/block.test.ts +0 -115
- package/src/utils/formatters/block.ts +0 -37
- package/src/utils/formatters/extract.test.ts +0 -14
- package/src/utils/formatters/extract.ts +0 -18
- package/src/utils/formatters/feeHistory.test.ts +0 -66
- package/src/utils/formatters/feeHistory.ts +0 -12
- package/src/utils/formatters/format.test.ts +0 -93
- package/src/utils/formatters/format.ts +0 -90
- package/src/utils/formatters/index.test.ts +0 -27
- package/src/utils/formatters/index.ts +0 -34
- package/src/utils/formatters/log.test.ts +0 -79
- package/src/utils/formatters/log.ts +0 -12
- package/src/utils/formatters/transaction.test.ts +0 -271
- package/src/utils/formatters/transaction.ts +0 -63
- package/src/utils/formatters/transactionReceipt.bench.ts +0 -73
- package/src/utils/formatters/transactionReceipt.test.ts +0 -151
- package/src/utils/formatters/transactionReceipt.ts +0 -63
- package/src/utils/formatters/transactionRequest.bench.ts +0 -29
- package/src/utils/formatters/transactionRequest.test.ts +0 -237
- package/src/utils/formatters/transactionRequest.ts +0 -56
- package/src/utils/hash/getEventSignature.test.ts +0 -61
- package/src/utils/hash/getEventSignature.ts +0 -4
- package/src/utils/hash/getFunctionSignature.test.ts +0 -22
- package/src/utils/hash/getFunctionSignature.ts +0 -5
- package/src/utils/hash/hashFunction.test.ts +0 -65
- package/src/utils/hash/hashFunction.ts +0 -12
- package/src/utils/hash/index.test.ts +0 -13
- package/src/utils/hash/index.ts +0 -5
- package/src/utils/hash/keccak256.test.ts +0 -59
- package/src/utils/hash/keccak256.ts +0 -21
- package/src/utils/index.test.ts +0 -111
- package/src/utils/index.ts +0 -142
- package/src/utils/observe.test.ts +0 -176
- package/src/utils/observe.ts +0 -66
- package/src/utils/poll.test.ts +0 -127
- package/src/utils/poll.ts +0 -42
- package/src/utils/promise/index.test.ts +0 -14
- package/src/utils/promise/index.ts +0 -3
- package/src/utils/promise/withCache.test.ts +0 -97
- package/src/utils/promise/withCache.ts +0 -73
- package/src/utils/promise/withRetry.test.ts +0 -231
- package/src/utils/promise/withRetry.ts +0 -61
- package/src/utils/promise/withTimeout.test.ts +0 -37
- package/src/utils/promise/withTimeout.ts +0 -39
- package/src/utils/rpc.test.ts +0 -990
- package/src/utils/rpc.ts +0 -294
- package/src/utils/stringify.test.ts +0 -13
- package/src/utils/stringify.ts +0 -5
- package/src/utils/uid.ts +0 -14
- package/src/utils/unit/constants.test.ts +0 -22
- package/src/utils/unit/constants.ts +0 -12
- package/src/utils/unit/formatEther.test.ts +0 -75
- package/src/utils/unit/formatEther.ts +0 -6
- package/src/utils/unit/formatGwei.test.ts +0 -32
- package/src/utils/unit/formatGwei.ts +0 -6
- package/src/utils/unit/formatUnit.bench.ts +0 -21
- package/src/utils/unit/formatUnit.test.ts +0 -40
- package/src/utils/unit/formatUnit.ts +0 -16
- package/src/utils/unit/index.test.ts +0 -28
- package/src/utils/unit/index.ts +0 -7
- package/src/utils/unit/parseEther.test.ts +0 -126
- package/src/utils/unit/parseEther.ts +0 -6
- package/src/utils/unit/parseGwei.test.ts +0 -50
- package/src/utils/unit/parseGwei.ts +0 -6
- package/src/utils/unit/parseUnit.bench.ts +0 -21
- package/src/utils/unit/parseUnit.test.ts +0 -54
- package/src/utils/unit/parseUnit.ts +0 -27
- package/src/utils/wait.ts +0 -3
- package/src/wallet.test.ts +0 -19
- package/src/wallet.ts +0 -23
- package/src/window.ts +0 -1
@@ -5,11 +5,19 @@ var __publicField = (obj, key, value) => {
|
|
5
5
|
return value;
|
6
6
|
};
|
7
7
|
|
8
|
+
// src/utils/abi/index.ts
|
9
|
+
import {
|
10
|
+
parseAbi,
|
11
|
+
parseAbiItem,
|
12
|
+
parseAbiParameter,
|
13
|
+
parseAbiParameters
|
14
|
+
} from "abitype";
|
15
|
+
|
8
16
|
// package.json
|
9
17
|
var package_default = {
|
10
18
|
name: "viem",
|
11
19
|
description: "TypeScript Interface for Ethereum",
|
12
|
-
version: "0.
|
20
|
+
version: "0.1.0",
|
13
21
|
scripts: {
|
14
22
|
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
23
|
bench: "vitest bench --no-threads",
|
@@ -18,30 +26,47 @@ var package_default = {
|
|
18
26
|
changeset: "changeset",
|
19
27
|
"changeset:release": "pnpm build && changeset publish",
|
20
28
|
"changeset:version": "changeset version && pnpm install --lockfile-only",
|
29
|
+
clean: "rimraf dist abi chains contract ens public test utils wallet window",
|
21
30
|
"contracts:build": "wagmi generate",
|
22
31
|
dev: "DEV=true tsup",
|
23
32
|
"dev:docs": "pnpm -r --filter site dev",
|
24
|
-
format: "rome format src/
|
33
|
+
format: "rome format src/ --write",
|
25
34
|
lint: "rome check .",
|
26
35
|
"lint:fix": "pnpm lint --apply-suggested",
|
27
|
-
playground: "pnpm --filter playground-
|
36
|
+
playground: "pnpm --filter playground-browser dev",
|
28
37
|
postinstall: "pnpm dev && pnpm contracts:build",
|
29
38
|
preinstall: "npx only-allow pnpm",
|
30
|
-
prepublishOnly: "pnpm
|
39
|
+
prepublishOnly: "pnpm bun scripts/prepublishOnly.ts",
|
31
40
|
prepare: "npx simple-git-hooks",
|
32
41
|
test: "vitest dev --no-threads",
|
42
|
+
"test:cov": "vitest dev --coverage --no-threads",
|
33
43
|
"test:ci": "CI=true vitest --coverage --no-threads",
|
34
44
|
"test:ui": "vitest dev --ui --no-threads",
|
35
|
-
"ts-node": "
|
45
|
+
"ts-node": "bun",
|
36
46
|
typecheck: "tsc --noEmit"
|
37
47
|
},
|
48
|
+
tsup: {
|
49
|
+
entry: [
|
50
|
+
"src/index.ts",
|
51
|
+
"src/abi.ts",
|
52
|
+
"src/chains.ts",
|
53
|
+
"src/contract.ts",
|
54
|
+
"src/ens.ts",
|
55
|
+
"src/public.ts",
|
56
|
+
"src/test.ts",
|
57
|
+
"src/utils/index.ts",
|
58
|
+
"src/wallet.ts",
|
59
|
+
"src/window.ts"
|
60
|
+
]
|
61
|
+
},
|
38
62
|
files: [
|
63
|
+
"/abi",
|
64
|
+
"/dist",
|
39
65
|
"/chains",
|
40
66
|
"/contract",
|
41
|
-
"/dist",
|
42
67
|
"/ens",
|
43
|
-
"/
|
44
|
-
"/
|
68
|
+
"/public",
|
69
|
+
"/test",
|
45
70
|
"/utils",
|
46
71
|
"/wallet",
|
47
72
|
"/window"
|
@@ -49,47 +74,52 @@ var package_default = {
|
|
49
74
|
exports: {
|
50
75
|
".": {
|
51
76
|
types: "./dist/index.d.ts",
|
52
|
-
module: "./dist/index.
|
77
|
+
module: "./dist/index.mts",
|
53
78
|
default: "./dist/index.js"
|
54
79
|
},
|
80
|
+
"./abi": {
|
81
|
+
types: "./dist/abi.d.ts",
|
82
|
+
module: "./dist/abi.mts",
|
83
|
+
default: "./dist/abi.js"
|
84
|
+
},
|
55
85
|
"./chains": {
|
56
86
|
types: "./dist/chains.d.ts",
|
57
|
-
module: "./dist/chains.
|
87
|
+
module: "./dist/chains.mts",
|
58
88
|
default: "./dist/chains.js"
|
59
89
|
},
|
60
90
|
"./contract": {
|
61
91
|
types: "./dist/contract.d.ts",
|
62
|
-
module: "./dist/contract.
|
92
|
+
module: "./dist/contract.mts",
|
63
93
|
default: "./dist/contract.js"
|
64
94
|
},
|
65
95
|
"./ens": {
|
66
96
|
types: "./dist/ens.d.ts",
|
67
|
-
module: "./dist/ens.
|
97
|
+
module: "./dist/ens.mts",
|
68
98
|
default: "./dist/ens.js"
|
69
99
|
},
|
70
100
|
"./public": {
|
71
101
|
types: "./dist/public.d.ts",
|
72
|
-
module: "./dist/public.
|
102
|
+
module: "./dist/public.mts",
|
73
103
|
default: "./dist/public.js"
|
74
104
|
},
|
75
105
|
"./test": {
|
76
106
|
types: "./dist/test.d.ts",
|
77
|
-
module: "./dist/test.
|
107
|
+
module: "./dist/test.mts",
|
78
108
|
default: "./dist/test.js"
|
79
109
|
},
|
80
110
|
"./utils": {
|
81
111
|
types: "./dist/utils/index.d.ts",
|
82
|
-
module: "./dist/utils/index.
|
112
|
+
module: "./dist/utils/index.mts",
|
83
113
|
default: "./dist/utils/index.js"
|
84
114
|
},
|
85
115
|
"./wallet": {
|
86
116
|
types: "./dist/wallet.d.ts",
|
87
|
-
module: "./dist/wallet.
|
117
|
+
module: "./dist/wallet.mts",
|
88
118
|
default: "./dist/wallet.js"
|
89
119
|
},
|
90
120
|
"./window": {
|
91
121
|
types: "./dist/window.d.ts",
|
92
|
-
module: "./dist/window.
|
122
|
+
module: "./dist/window.mts",
|
93
123
|
default: "./dist/window.js"
|
94
124
|
},
|
95
125
|
"./package.json": "./package.json"
|
@@ -101,9 +131,8 @@ var package_default = {
|
|
101
131
|
dependencies: {
|
102
132
|
"@noble/hashes": "^1.1.2",
|
103
133
|
"@wagmi/chains": "~0.2.8",
|
104
|
-
abitype: "~0.
|
134
|
+
abitype: "~0.6.2",
|
105
135
|
"idna-uts46-hx": "^4.1.2",
|
106
|
-
"isomorphic-unfetch": "^4.0.2",
|
107
136
|
"isomorphic-ws": "^5.0.0",
|
108
137
|
ws: "^8.12.0"
|
109
138
|
},
|
@@ -117,24 +146,23 @@ var package_default = {
|
|
117
146
|
"@types/fs-extra": "^9.0.13",
|
118
147
|
"@types/node": "^17.0.45",
|
119
148
|
"@types/ws": "^8.5.4",
|
120
|
-
"@vitest/coverage-c8": "^0.
|
121
|
-
"@vitest/ui": "^0.
|
149
|
+
"@vitest/coverage-c8": "^0.29.2",
|
150
|
+
"@vitest/ui": "^0.29.2",
|
122
151
|
"@wagmi/cli": "^0.1.6",
|
152
|
+
bun: "^0.5.5",
|
123
153
|
bundlewatch: "^0.3.3",
|
124
154
|
dedent: "^0.7.0",
|
125
|
-
esbuild: "^0.16.17",
|
126
|
-
"esbuild-register": "^3.4.2",
|
127
155
|
ethers: "^5.7.2",
|
128
156
|
"ethers@6": "npm:ethers@^6.0.2",
|
129
157
|
execa: "^6.1.0",
|
130
158
|
"fs-extra": "^10.1.0",
|
159
|
+
rimraf: "^4.1.2",
|
131
160
|
rome: "^11.0.0",
|
132
161
|
"simple-git-hooks": "^2.8.1",
|
133
162
|
tsup: "^6.6.0",
|
134
163
|
typescript: "^4.9.4",
|
135
|
-
vite: "^
|
136
|
-
vitest: "
|
137
|
-
web3: "^1.8.1"
|
164
|
+
vite: "^4.1.4",
|
165
|
+
vitest: "~0.29.2"
|
138
166
|
},
|
139
167
|
license: "MIT",
|
140
168
|
repository: "wagmi-dev/viem",
|
@@ -150,17 +178,21 @@ var package_default = {
|
|
150
178
|
"web3"
|
151
179
|
],
|
152
180
|
"simple-git-hooks": {
|
153
|
-
"pre-commit": "pnpm format
|
181
|
+
"pre-commit": "pnpm format && pnpm lint:fix"
|
154
182
|
},
|
155
183
|
pnpm: {
|
156
184
|
patchedDependencies: {
|
157
|
-
"vitepress@1.0.0-alpha.
|
185
|
+
"vitepress@1.0.0-alpha.49": "patches/vitepress@1.0.0-alpha.49.patch"
|
158
186
|
}
|
159
187
|
}
|
160
188
|
};
|
161
189
|
|
190
|
+
// src/errors/utils.ts
|
191
|
+
var getContractAddress = (address) => address;
|
192
|
+
var getUrl = (url) => url;
|
193
|
+
var getVersion = () => `${package_default.name}@${package_default.version}`;
|
194
|
+
|
162
195
|
// src/errors/base.ts
|
163
|
-
var version = process.env.TEST ? "1.0.2" : package_default.version;
|
164
196
|
var BaseError = class extends Error {
|
165
197
|
constructor(shortMessage, args = {}) {
|
166
198
|
const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
|
@@ -171,7 +203,7 @@ var BaseError = class extends Error {
|
|
171
203
|
...args.metaMessages ? [...args.metaMessages, ""] : [],
|
172
204
|
...docsPath5 ? [`Docs: https://viem.sh${docsPath5}`] : [],
|
173
205
|
...details ? [`Details: ${details}`] : [],
|
174
|
-
`Version:
|
206
|
+
`Version: ${getVersion()}`
|
175
207
|
].join("\n");
|
176
208
|
super(message);
|
177
209
|
__publicField(this, "details");
|
@@ -250,6 +282,16 @@ var AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
|
250
282
|
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
251
283
|
}
|
252
284
|
};
|
285
|
+
var AbiEncodingBytesSizeMismatchError = class extends BaseError {
|
286
|
+
constructor({ expectedSize, value }) {
|
287
|
+
super(
|
288
|
+
`Size of bytes "${value}" (bytes${size(
|
289
|
+
value
|
290
|
+
)}) does not match expected size (bytes${expectedSize}).`
|
291
|
+
);
|
292
|
+
__publicField(this, "name", "AbiEncodingBytesSizeMismatchError");
|
293
|
+
}
|
294
|
+
};
|
253
295
|
var AbiEncodingLengthMismatchError = class extends BaseError {
|
254
296
|
constructor({
|
255
297
|
expectedLength,
|
@@ -382,6 +424,15 @@ var AbiFunctionSignatureNotFoundError = class extends BaseError {
|
|
382
424
|
__publicField(this, "name", "AbiFunctionSignatureNotFoundError");
|
383
425
|
}
|
384
426
|
};
|
427
|
+
var BytesSizeMismatchError = class extends BaseError {
|
428
|
+
constructor({
|
429
|
+
expectedSize,
|
430
|
+
givenSize
|
431
|
+
}) {
|
432
|
+
super(`Expected bytes${expectedSize}, got bytes${givenSize}.`);
|
433
|
+
__publicField(this, "name", "BytesSizeMismatchError");
|
434
|
+
}
|
435
|
+
};
|
385
436
|
var InvalidAbiEncodingTypeError = class extends BaseError {
|
386
437
|
constructor(type, { docsPath: docsPath5 }) {
|
387
438
|
super(
|
@@ -423,6 +474,12 @@ var InvalidDefinitionTypeError = class extends BaseError {
|
|
423
474
|
__publicField(this, "name", "InvalidDefinitionTypeError");
|
424
475
|
}
|
425
476
|
};
|
477
|
+
var UnsupportedPackedAbiType = class extends BaseError {
|
478
|
+
constructor(type) {
|
479
|
+
super(`Type "${type}" is not supported for packed encoding.`);
|
480
|
+
__publicField(this, "name", "UnsupportedPackedAbiType");
|
481
|
+
}
|
482
|
+
};
|
426
483
|
|
427
484
|
// src/errors/address.ts
|
428
485
|
var InvalidAddressError = class extends BaseError {
|
@@ -471,6 +528,23 @@ var ChainDoesNotSupportContract = class extends BaseError {
|
|
471
528
|
__publicField(this, "name", "ChainDoesNotSupportContract");
|
472
529
|
}
|
473
530
|
};
|
531
|
+
var ChainMismatchError = class extends BaseError {
|
532
|
+
constructor({
|
533
|
+
chain,
|
534
|
+
currentChainId
|
535
|
+
}) {
|
536
|
+
super(
|
537
|
+
`The current chain (id: ${currentChainId}) does not match the chain passed to the request (id: ${chain.id} \u2013 ${chain.name}).`,
|
538
|
+
{
|
539
|
+
metaMessages: [
|
540
|
+
`Current Chain ID: ${currentChainId}`,
|
541
|
+
`Expected Chain ID: ${chain.id} \u2013 ${chain.name}`
|
542
|
+
]
|
543
|
+
}
|
544
|
+
);
|
545
|
+
__publicField(this, "name", "ChainMismatchError");
|
546
|
+
}
|
547
|
+
};
|
474
548
|
|
475
549
|
// src/constants/abis.ts
|
476
550
|
var multicall3Abi = [
|
@@ -550,7 +624,159 @@ var solidityPanic = {
|
|
550
624
|
type: "error"
|
551
625
|
};
|
552
626
|
|
627
|
+
// src/constants/unit.ts
|
628
|
+
var etherUnits = {
|
629
|
+
gwei: 9,
|
630
|
+
wei: 18
|
631
|
+
};
|
632
|
+
var gweiUnits = {
|
633
|
+
ether: -9,
|
634
|
+
wei: 9
|
635
|
+
};
|
636
|
+
var weiUnits = {
|
637
|
+
ether: -18,
|
638
|
+
gwei: -9
|
639
|
+
};
|
640
|
+
|
641
|
+
// src/errors/transaction.ts
|
642
|
+
function prettyPrint(args) {
|
643
|
+
const entries = Object.entries(args).map(([key, value]) => {
|
644
|
+
if (value === void 0 || value === false)
|
645
|
+
return null;
|
646
|
+
return [key, value];
|
647
|
+
}).filter(Boolean);
|
648
|
+
const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
|
649
|
+
return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
|
650
|
+
}
|
651
|
+
var FeeConflictError = class extends BaseError {
|
652
|
+
constructor() {
|
653
|
+
super(
|
654
|
+
[
|
655
|
+
"Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
|
656
|
+
"Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
|
657
|
+
].join("\n")
|
658
|
+
);
|
659
|
+
__publicField(this, "name", "FeeConflictError");
|
660
|
+
}
|
661
|
+
};
|
662
|
+
var TransactionExecutionError = class extends BaseError {
|
663
|
+
constructor(cause, {
|
664
|
+
account,
|
665
|
+
docsPath: docsPath5,
|
666
|
+
chain,
|
667
|
+
data,
|
668
|
+
gas,
|
669
|
+
gasPrice,
|
670
|
+
maxFeePerGas,
|
671
|
+
maxPriorityFeePerGas,
|
672
|
+
nonce,
|
673
|
+
to,
|
674
|
+
value
|
675
|
+
}) {
|
676
|
+
const prettyArgs = prettyPrint({
|
677
|
+
chain: chain && `${chain?.name} (id: ${chain?.id})`,
|
678
|
+
from: account.address,
|
679
|
+
to,
|
680
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
681
|
+
data,
|
682
|
+
gas,
|
683
|
+
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
684
|
+
maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
|
685
|
+
maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
|
686
|
+
nonce
|
687
|
+
});
|
688
|
+
super(cause.shortMessage, {
|
689
|
+
cause,
|
690
|
+
docsPath: docsPath5,
|
691
|
+
metaMessages: [
|
692
|
+
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
|
693
|
+
"Request Arguments:",
|
694
|
+
prettyArgs
|
695
|
+
].filter(Boolean)
|
696
|
+
});
|
697
|
+
__publicField(this, "cause");
|
698
|
+
__publicField(this, "name", "TransactionExecutionError");
|
699
|
+
this.cause = cause;
|
700
|
+
}
|
701
|
+
};
|
702
|
+
var TransactionNotFoundError = class extends BaseError {
|
703
|
+
constructor({
|
704
|
+
blockHash,
|
705
|
+
blockNumber,
|
706
|
+
blockTag,
|
707
|
+
hash: hash2,
|
708
|
+
index
|
709
|
+
}) {
|
710
|
+
let identifier = "Transaction";
|
711
|
+
if (blockTag && index !== void 0)
|
712
|
+
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
713
|
+
if (blockHash && index !== void 0)
|
714
|
+
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
715
|
+
if (blockNumber && index !== void 0)
|
716
|
+
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
717
|
+
if (hash2)
|
718
|
+
identifier = `Transaction with hash "${hash2}"`;
|
719
|
+
super(`${identifier} could not be found.`);
|
720
|
+
__publicField(this, "name", "TransactionNotFoundError");
|
721
|
+
}
|
722
|
+
};
|
723
|
+
var TransactionReceiptNotFoundError = class extends BaseError {
|
724
|
+
constructor({ hash: hash2 }) {
|
725
|
+
super(
|
726
|
+
`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
|
727
|
+
);
|
728
|
+
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
729
|
+
}
|
730
|
+
};
|
731
|
+
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
732
|
+
constructor({ hash: hash2 }) {
|
733
|
+
super(
|
734
|
+
`Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
|
735
|
+
);
|
736
|
+
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
737
|
+
}
|
738
|
+
};
|
739
|
+
|
553
740
|
// src/errors/contract.ts
|
741
|
+
var CallExecutionError = class extends BaseError {
|
742
|
+
constructor(cause, {
|
743
|
+
account,
|
744
|
+
docsPath: docsPath5,
|
745
|
+
chain,
|
746
|
+
data,
|
747
|
+
gas,
|
748
|
+
gasPrice,
|
749
|
+
maxFeePerGas,
|
750
|
+
maxPriorityFeePerGas,
|
751
|
+
nonce,
|
752
|
+
to,
|
753
|
+
value
|
754
|
+
}) {
|
755
|
+
const prettyArgs = prettyPrint({
|
756
|
+
from: account?.address,
|
757
|
+
to,
|
758
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
759
|
+
data,
|
760
|
+
gas,
|
761
|
+
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
762
|
+
maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
|
763
|
+
maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
|
764
|
+
nonce
|
765
|
+
});
|
766
|
+
super(cause.shortMessage, {
|
767
|
+
cause,
|
768
|
+
docsPath: docsPath5,
|
769
|
+
metaMessages: [
|
770
|
+
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
|
771
|
+
"Raw Call Arguments:",
|
772
|
+
prettyArgs
|
773
|
+
].filter(Boolean)
|
774
|
+
});
|
775
|
+
__publicField(this, "cause");
|
776
|
+
__publicField(this, "name", "CallExecutionError");
|
777
|
+
this.cause = cause;
|
778
|
+
}
|
779
|
+
};
|
554
780
|
var ContractFunctionExecutionError = class extends BaseError {
|
555
781
|
constructor(cause, {
|
556
782
|
abi,
|
@@ -568,6 +794,12 @@ var ContractFunctionExecutionError = class extends BaseError {
|
|
568
794
|
includeName: false
|
569
795
|
}) : void 0;
|
570
796
|
const functionWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
|
797
|
+
const prettyArgs = prettyPrint({
|
798
|
+
address: contractAddress && getContractAddress(contractAddress),
|
799
|
+
function: functionWithParams,
|
800
|
+
args: formattedArgs && formattedArgs !== "()" && `${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`,
|
801
|
+
sender
|
802
|
+
});
|
571
803
|
super(
|
572
804
|
cause.shortMessage || `An unknown error occurred while executing the contract function "${functionName}".`,
|
573
805
|
{
|
@@ -575,11 +807,8 @@ var ContractFunctionExecutionError = class extends BaseError {
|
|
575
807
|
docsPath: docsPath5,
|
576
808
|
metaMessages: [
|
577
809
|
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
|
578
|
-
|
579
|
-
|
580
|
-
functionWithParams && `Function: ${functionWithParams}`,
|
581
|
-
formattedArgs && formattedArgs !== "()" && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`,
|
582
|
-
sender && `Sender: ${sender}`
|
810
|
+
"Contract Call:",
|
811
|
+
prettyArgs
|
583
812
|
].filter(Boolean)
|
584
813
|
}
|
585
814
|
);
|
@@ -626,8 +855,8 @@ var ContractFunctionRevertedError = class extends BaseError {
|
|
626
855
|
includeName: false
|
627
856
|
}) : void 0;
|
628
857
|
metaMessages = [
|
629
|
-
errorWithParams ? `Error:
|
630
|
-
formattedArgs && formattedArgs !== "()" ? `
|
858
|
+
errorWithParams ? `Error: ${errorWithParams}` : "",
|
859
|
+
formattedArgs && formattedArgs !== "()" ? ` ${[...Array(errorName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}` : ""
|
631
860
|
];
|
632
861
|
}
|
633
862
|
} else if (message)
|
@@ -653,9 +882,9 @@ var ContractFunctionZeroDataError = class extends BaseError {
|
|
653
882
|
super(`The contract function "${functionName}" returned no data ("0x").`, {
|
654
883
|
metaMessages: [
|
655
884
|
"This could be due to any of the following:",
|
656
|
-
|
657
|
-
"- The parameters passed to the contract function may be invalid, or",
|
658
|
-
"- The address is not a contract."
|
885
|
+
` - The contract does not have the function "${functionName}",`,
|
886
|
+
" - The parameters passed to the contract function may be invalid, or",
|
887
|
+
" - The address is not a contract."
|
659
888
|
]
|
660
889
|
});
|
661
890
|
__publicField(this, "name", "ContractFunctionZeroDataError");
|
@@ -735,6 +964,47 @@ var OffsetOutOfBoundsError = class extends BaseError {
|
|
735
964
|
}
|
736
965
|
};
|
737
966
|
|
967
|
+
// src/errors/estimateGas.ts
|
968
|
+
var EstimateGasExecutionError = class extends BaseError {
|
969
|
+
constructor(cause, {
|
970
|
+
account,
|
971
|
+
docsPath: docsPath5,
|
972
|
+
chain,
|
973
|
+
data,
|
974
|
+
gas,
|
975
|
+
gasPrice,
|
976
|
+
maxFeePerGas,
|
977
|
+
maxPriorityFeePerGas,
|
978
|
+
nonce,
|
979
|
+
to,
|
980
|
+
value
|
981
|
+
}) {
|
982
|
+
const prettyArgs = prettyPrint({
|
983
|
+
from: account.address,
|
984
|
+
to,
|
985
|
+
value: typeof value !== "undefined" && `${formatEther(value)} ${chain?.nativeCurrency.symbol || "ETH"}`,
|
986
|
+
data,
|
987
|
+
gas,
|
988
|
+
gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
|
989
|
+
maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
|
990
|
+
maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
|
991
|
+
nonce
|
992
|
+
});
|
993
|
+
super(cause.shortMessage, {
|
994
|
+
cause,
|
995
|
+
docsPath: docsPath5,
|
996
|
+
metaMessages: [
|
997
|
+
...cause.metaMessages ? [...cause.metaMessages, " "] : [],
|
998
|
+
"Estimate Gas Arguments:",
|
999
|
+
prettyArgs
|
1000
|
+
].filter(Boolean)
|
1001
|
+
});
|
1002
|
+
__publicField(this, "cause");
|
1003
|
+
__publicField(this, "name", "EstimateGasExecutionError");
|
1004
|
+
this.cause = cause;
|
1005
|
+
}
|
1006
|
+
};
|
1007
|
+
|
738
1008
|
// src/errors/log.ts
|
739
1009
|
var FilterTypeNotSupportedError = class extends BaseError {
|
740
1010
|
constructor(type) {
|
@@ -743,19 +1013,189 @@ var FilterTypeNotSupportedError = class extends BaseError {
|
|
743
1013
|
}
|
744
1014
|
};
|
745
1015
|
|
1016
|
+
// src/errors/node.ts
|
1017
|
+
var ExecutionRevertedError = class extends BaseError {
|
1018
|
+
constructor({
|
1019
|
+
cause,
|
1020
|
+
message
|
1021
|
+
} = {}) {
|
1022
|
+
const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", "");
|
1023
|
+
super(
|
1024
|
+
`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`,
|
1025
|
+
{
|
1026
|
+
cause
|
1027
|
+
}
|
1028
|
+
);
|
1029
|
+
__publicField(this, "name", "ExecutionRevertedError");
|
1030
|
+
}
|
1031
|
+
};
|
1032
|
+
__publicField(ExecutionRevertedError, "code", 3);
|
1033
|
+
__publicField(ExecutionRevertedError, "nodeMessage", /execution reverted/);
|
1034
|
+
var FeeCapTooHighError = class extends BaseError {
|
1035
|
+
constructor({
|
1036
|
+
cause,
|
1037
|
+
maxFeePerGas
|
1038
|
+
} = {}) {
|
1039
|
+
super(
|
1040
|
+
`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`,
|
1041
|
+
{
|
1042
|
+
cause
|
1043
|
+
}
|
1044
|
+
);
|
1045
|
+
__publicField(this, "name", "FeeCapTooHigh");
|
1046
|
+
}
|
1047
|
+
};
|
1048
|
+
__publicField(FeeCapTooHighError, "nodeMessage", /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/);
|
1049
|
+
var FeeCapTooLowError = class extends BaseError {
|
1050
|
+
constructor({
|
1051
|
+
cause,
|
1052
|
+
maxFeePerGas
|
1053
|
+
} = {}) {
|
1054
|
+
super(
|
1055
|
+
`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`,
|
1056
|
+
{
|
1057
|
+
cause
|
1058
|
+
}
|
1059
|
+
);
|
1060
|
+
__publicField(this, "name", "FeeCapTooLow");
|
1061
|
+
}
|
1062
|
+
};
|
1063
|
+
__publicField(FeeCapTooLowError, "nodeMessage", /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/);
|
1064
|
+
var NonceTooHighError = class extends BaseError {
|
1065
|
+
constructor({ cause, nonce } = {}) {
|
1066
|
+
super(
|
1067
|
+
`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`,
|
1068
|
+
{ cause }
|
1069
|
+
);
|
1070
|
+
__publicField(this, "name", "NonceTooHighError");
|
1071
|
+
}
|
1072
|
+
};
|
1073
|
+
__publicField(NonceTooHighError, "nodeMessage", /nonce too high/);
|
1074
|
+
var NonceTooLowError = class extends BaseError {
|
1075
|
+
constructor({ cause, nonce } = {}) {
|
1076
|
+
super(
|
1077
|
+
[
|
1078
|
+
`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
|
1079
|
+
"Try increasing the nonce or find the latest nonce with `getTransactionCount`."
|
1080
|
+
].join("\n"),
|
1081
|
+
{ cause }
|
1082
|
+
);
|
1083
|
+
__publicField(this, "name", "NonceTooLowError");
|
1084
|
+
}
|
1085
|
+
};
|
1086
|
+
__publicField(NonceTooLowError, "nodeMessage", /nonce too low|transaction already imported/);
|
1087
|
+
var NonceMaxValueError = class extends BaseError {
|
1088
|
+
constructor({ cause, nonce } = {}) {
|
1089
|
+
super(
|
1090
|
+
`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`,
|
1091
|
+
{ cause }
|
1092
|
+
);
|
1093
|
+
__publicField(this, "name", "NonceMaxValueError");
|
1094
|
+
}
|
1095
|
+
};
|
1096
|
+
__publicField(NonceMaxValueError, "nodeMessage", /nonce has max value/);
|
1097
|
+
var InsufficientFundsError = class extends BaseError {
|
1098
|
+
constructor({ cause } = {}) {
|
1099
|
+
super(
|
1100
|
+
[
|
1101
|
+
"The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
|
1102
|
+
].join("\n"),
|
1103
|
+
{
|
1104
|
+
cause,
|
1105
|
+
metaMessages: [
|
1106
|
+
"This error could arise when the account does not have enough funds to:",
|
1107
|
+
" - pay for the total gas fee,",
|
1108
|
+
" - pay for the value to send.",
|
1109
|
+
" ",
|
1110
|
+
"The cost of the transaction is calculated as `gas * gas fee + value`, where:",
|
1111
|
+
" - `gas` is the amount of gas needed for transaction to execute,",
|
1112
|
+
" - `gas fee` is the gas fee,",
|
1113
|
+
" - `value` is the amount of ether to send to the recipient."
|
1114
|
+
]
|
1115
|
+
}
|
1116
|
+
);
|
1117
|
+
__publicField(this, "name", "InsufficientFundsError");
|
1118
|
+
}
|
1119
|
+
};
|
1120
|
+
__publicField(InsufficientFundsError, "nodeMessage", /insufficient funds/);
|
1121
|
+
var IntrinsicGasTooHighError = class extends BaseError {
|
1122
|
+
constructor({ cause, gas } = {}) {
|
1123
|
+
super(
|
1124
|
+
`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`,
|
1125
|
+
{
|
1126
|
+
cause
|
1127
|
+
}
|
1128
|
+
);
|
1129
|
+
__publicField(this, "name", "IntrinsicGasTooHighError");
|
1130
|
+
}
|
1131
|
+
};
|
1132
|
+
__publicField(IntrinsicGasTooHighError, "nodeMessage", /intrinsic gas too high|gas limit reached/);
|
1133
|
+
var IntrinsicGasTooLowError = class extends BaseError {
|
1134
|
+
constructor({ cause, gas } = {}) {
|
1135
|
+
super(
|
1136
|
+
`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`,
|
1137
|
+
{
|
1138
|
+
cause
|
1139
|
+
}
|
1140
|
+
);
|
1141
|
+
__publicField(this, "name", "IntrinsicGasTooLowError");
|
1142
|
+
}
|
1143
|
+
};
|
1144
|
+
__publicField(IntrinsicGasTooLowError, "nodeMessage", /intrinsic gas too low/);
|
1145
|
+
var TransactionTypeNotSupportedError = class extends BaseError {
|
1146
|
+
constructor({ cause }) {
|
1147
|
+
super("The transaction type is not supported for this chain.", {
|
1148
|
+
cause
|
1149
|
+
});
|
1150
|
+
__publicField(this, "name", "TransactionTypeNotSupportedError");
|
1151
|
+
}
|
1152
|
+
};
|
1153
|
+
__publicField(TransactionTypeNotSupportedError, "nodeMessage", /transaction type not valid/);
|
1154
|
+
var TipAboveFeeCapError = class extends BaseError {
|
1155
|
+
constructor({
|
1156
|
+
cause,
|
1157
|
+
maxPriorityFeePerGas,
|
1158
|
+
maxFeePerGas
|
1159
|
+
} = {}) {
|
1160
|
+
super(
|
1161
|
+
[
|
1162
|
+
`The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
|
1163
|
+
].join("\n"),
|
1164
|
+
{
|
1165
|
+
cause
|
1166
|
+
}
|
1167
|
+
);
|
1168
|
+
__publicField(this, "name", "TipAboveFeeCapError");
|
1169
|
+
}
|
1170
|
+
};
|
1171
|
+
__publicField(TipAboveFeeCapError, "nodeMessage", /max priority fee per gas higher than max fee per gas|tip higher than fee cap/);
|
1172
|
+
var UnknownNodeError = class extends BaseError {
|
1173
|
+
constructor({ cause }) {
|
1174
|
+
super(`An error occurred while executing: ${cause?.message}`, {
|
1175
|
+
cause
|
1176
|
+
});
|
1177
|
+
__publicField(this, "name", "UnknownNodeError");
|
1178
|
+
}
|
1179
|
+
};
|
1180
|
+
|
746
1181
|
// src/errors/request.ts
|
747
1182
|
var RequestError = class extends BaseError {
|
748
|
-
constructor(err, {
|
1183
|
+
constructor(err, {
|
1184
|
+
docsPath: docsPath5,
|
1185
|
+
metaMessages,
|
1186
|
+
shortMessage
|
1187
|
+
}) {
|
749
1188
|
super(shortMessage, {
|
750
1189
|
cause: err,
|
751
|
-
docsPath: docsPath5
|
1190
|
+
docsPath: docsPath5,
|
1191
|
+
metaMessages
|
752
1192
|
});
|
753
1193
|
this.name = err.name;
|
754
1194
|
}
|
755
1195
|
};
|
756
1196
|
var RpcRequestError = class extends RequestError {
|
757
1197
|
constructor(err, { docsPath: docsPath5, shortMessage }) {
|
758
|
-
super(err, { docsPath: docsPath5, shortMessage });
|
1198
|
+
super(err, { docsPath: docsPath5, metaMessages: err.metaMessages, shortMessage });
|
759
1199
|
__publicField(this, "code");
|
760
1200
|
this.code = err.code;
|
761
1201
|
this.name = err.name;
|
@@ -861,6 +1301,24 @@ var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
|
861
1301
|
__publicField(this, "code", -32006);
|
862
1302
|
}
|
863
1303
|
};
|
1304
|
+
var UserRejectedRequestError = class extends RpcRequestError {
|
1305
|
+
constructor(err) {
|
1306
|
+
super(err, {
|
1307
|
+
shortMessage: "User rejected the request."
|
1308
|
+
});
|
1309
|
+
__publicField(this, "name", "UserRejectedRequestError");
|
1310
|
+
__publicField(this, "code", 4001);
|
1311
|
+
}
|
1312
|
+
};
|
1313
|
+
var SwitchChainError = class extends RpcRequestError {
|
1314
|
+
constructor(err) {
|
1315
|
+
super(err, {
|
1316
|
+
shortMessage: "An error occurred when attempting to switch chain."
|
1317
|
+
});
|
1318
|
+
__publicField(this, "name", "SwitchChainError");
|
1319
|
+
__publicField(this, "code", 4902);
|
1320
|
+
}
|
1321
|
+
};
|
864
1322
|
var UnknownRpcError = class extends RequestError {
|
865
1323
|
constructor(err) {
|
866
1324
|
super(err, {
|
@@ -875,24 +1333,27 @@ var HttpRequestError = class extends BaseError {
|
|
875
1333
|
constructor({
|
876
1334
|
body,
|
877
1335
|
details,
|
1336
|
+
headers,
|
878
1337
|
status,
|
879
1338
|
url
|
880
1339
|
}) {
|
881
|
-
super(
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
`
|
886
|
-
`URL: ${url}`,
|
1340
|
+
super("HTTP request failed.", {
|
1341
|
+
details,
|
1342
|
+
metaMessages: [
|
1343
|
+
status && `Status: ${status}`,
|
1344
|
+
`URL: ${getUrl(url)}`,
|
887
1345
|
`Request body: ${stringify(body)}`
|
888
|
-
].
|
889
|
-
|
890
|
-
details
|
891
|
-
}
|
892
|
-
);
|
1346
|
+
].filter(Boolean)
|
1347
|
+
});
|
893
1348
|
__publicField(this, "name", "HttpRequestError");
|
1349
|
+
__publicField(this, "body");
|
1350
|
+
__publicField(this, "headers");
|
894
1351
|
__publicField(this, "status");
|
1352
|
+
__publicField(this, "url");
|
1353
|
+
this.body = body;
|
1354
|
+
this.headers = headers;
|
895
1355
|
this.status = status;
|
1356
|
+
this.url = url;
|
896
1357
|
}
|
897
1358
|
};
|
898
1359
|
var WebSocketRequestError = class extends BaseError {
|
@@ -901,17 +1362,10 @@ var WebSocketRequestError = class extends BaseError {
|
|
901
1362
|
details,
|
902
1363
|
url
|
903
1364
|
}) {
|
904
|
-
super(
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
`URL: ${url}`,
|
909
|
-
`Request body: ${stringify(body)}`
|
910
|
-
].join("\n"),
|
911
|
-
{
|
912
|
-
details
|
913
|
-
}
|
914
|
-
);
|
1365
|
+
super("WebSocket request failed.", {
|
1366
|
+
details,
|
1367
|
+
metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`]
|
1368
|
+
});
|
915
1369
|
__publicField(this, "name", "WebSocketRequestError");
|
916
1370
|
}
|
917
1371
|
};
|
@@ -921,18 +1375,11 @@ var RpcError = class extends BaseError {
|
|
921
1375
|
error,
|
922
1376
|
url
|
923
1377
|
}) {
|
924
|
-
super(
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
`Request body: ${stringify(body)}`
|
930
|
-
].join("\n"),
|
931
|
-
{
|
932
|
-
cause: error,
|
933
|
-
details: error.message
|
934
|
-
}
|
935
|
-
);
|
1378
|
+
super("RPC Request failed.", {
|
1379
|
+
cause: error,
|
1380
|
+
details: error.message,
|
1381
|
+
metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`]
|
1382
|
+
});
|
936
1383
|
__publicField(this, "code");
|
937
1384
|
__publicField(this, "name", "RpcError");
|
938
1385
|
this.code = error.code;
|
@@ -943,73 +1390,21 @@ var TimeoutError = class extends BaseError {
|
|
943
1390
|
body,
|
944
1391
|
url
|
945
1392
|
}) {
|
1393
|
+
super("The request took too long to respond.", {
|
1394
|
+
details: "The request timed out.",
|
1395
|
+
metaMessages: [`URL: ${getUrl(url)}`, `Request body: ${stringify(body)}`]
|
1396
|
+
});
|
1397
|
+
__publicField(this, "name", "TimeoutError");
|
1398
|
+
}
|
1399
|
+
};
|
1400
|
+
|
1401
|
+
// src/errors/transport.ts
|
1402
|
+
var UrlRequiredError = class extends BaseError {
|
1403
|
+
constructor() {
|
946
1404
|
super(
|
947
|
-
|
948
|
-
"The request took too long to respond.",
|
949
|
-
"",
|
950
|
-
`URL: ${url}`,
|
951
|
-
`Request body: ${stringify(body)}`
|
952
|
-
].join("\n"),
|
1405
|
+
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
953
1406
|
{
|
954
|
-
|
955
|
-
}
|
956
|
-
);
|
957
|
-
__publicField(this, "name", "TimeoutError");
|
958
|
-
}
|
959
|
-
};
|
960
|
-
|
961
|
-
// src/errors/transaction.ts
|
962
|
-
var InvalidGasArgumentsError = class extends BaseError {
|
963
|
-
constructor() {
|
964
|
-
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
965
|
-
__publicField(this, "name", "InvalidGasArgumentsError");
|
966
|
-
}
|
967
|
-
};
|
968
|
-
var TransactionNotFoundError = class extends BaseError {
|
969
|
-
constructor({
|
970
|
-
blockHash,
|
971
|
-
blockNumber,
|
972
|
-
blockTag,
|
973
|
-
hash: hash2,
|
974
|
-
index
|
975
|
-
}) {
|
976
|
-
let identifier = "Transaction";
|
977
|
-
if (blockTag && index !== void 0)
|
978
|
-
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
979
|
-
if (blockHash && index !== void 0)
|
980
|
-
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
981
|
-
if (blockNumber && index !== void 0)
|
982
|
-
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
983
|
-
if (hash2)
|
984
|
-
identifier = `Transaction with hash "${hash2}"`;
|
985
|
-
super(`${identifier} could not be found.`);
|
986
|
-
__publicField(this, "name", "TransactionNotFoundError");
|
987
|
-
}
|
988
|
-
};
|
989
|
-
var TransactionReceiptNotFoundError = class extends BaseError {
|
990
|
-
constructor({ hash: hash2 }) {
|
991
|
-
super(
|
992
|
-
`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
|
993
|
-
);
|
994
|
-
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
995
|
-
}
|
996
|
-
};
|
997
|
-
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
998
|
-
constructor({ hash: hash2 }) {
|
999
|
-
super(
|
1000
|
-
`Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
|
1001
|
-
);
|
1002
|
-
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
1003
|
-
}
|
1004
|
-
};
|
1005
|
-
|
1006
|
-
// src/errors/transport.ts
|
1007
|
-
var UrlRequiredError = class extends BaseError {
|
1008
|
-
constructor() {
|
1009
|
-
super(
|
1010
|
-
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
1011
|
-
{
|
1012
|
-
docsPath: "/docs/clients/intro"
|
1407
|
+
docsPath: "/docs/clients/intro"
|
1013
1408
|
}
|
1014
1409
|
);
|
1015
1410
|
}
|
@@ -1047,6 +1442,8 @@ function isBytes(value) {
|
|
1047
1442
|
return false;
|
1048
1443
|
if (typeof value !== "object")
|
1049
1444
|
return false;
|
1445
|
+
if (!("BYTES_PER_ELEMENT" in value))
|
1446
|
+
return false;
|
1050
1447
|
return value.BYTES_PER_ELEMENT === 1 && value.constructor.name === "Uint8Array";
|
1051
1448
|
}
|
1052
1449
|
|
@@ -1066,6 +1463,8 @@ function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
|
|
1066
1463
|
return padBytes(hexOrBytes, { dir, size: size2 });
|
1067
1464
|
}
|
1068
1465
|
function padHex(hex_, { dir, size: size2 = 32 } = {}) {
|
1466
|
+
if (size2 === null)
|
1467
|
+
return hex_;
|
1069
1468
|
let hex = hex_.replace("0x", "");
|
1070
1469
|
if (hex.length > size2 * 2)
|
1071
1470
|
throw new SizeExceedsPaddingSizeError({
|
@@ -1079,6 +1478,8 @@ function padHex(hex_, { dir, size: size2 = 32 } = {}) {
|
|
1079
1478
|
)}`;
|
1080
1479
|
}
|
1081
1480
|
function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
1481
|
+
if (size2 === null)
|
1482
|
+
return bytes;
|
1082
1483
|
if (bytes.length > size2)
|
1083
1484
|
throw new SizeExceedsPaddingSizeError({
|
1084
1485
|
size: bytes.length,
|
@@ -1143,10 +1544,10 @@ function sliceHex(value_, start, end) {
|
|
1143
1544
|
return `0x${value}`;
|
1144
1545
|
}
|
1145
1546
|
|
1146
|
-
// src/utils/encoding/
|
1547
|
+
// src/utils/encoding/toHex.ts
|
1147
1548
|
var hexes = Array.from(
|
1148
1549
|
{ length: 256 },
|
1149
|
-
(
|
1550
|
+
(_v, i) => i.toString(16).padStart(2, "0")
|
1150
1551
|
);
|
1151
1552
|
function boolToHex(value) {
|
1152
1553
|
return `0x${Number(value)}`;
|
@@ -1158,7 +1559,7 @@ function bytesToHex(value) {
|
|
1158
1559
|
}
|
1159
1560
|
return `0x${hex}`;
|
1160
1561
|
}
|
1161
|
-
function
|
1562
|
+
function toHex(value) {
|
1162
1563
|
if (typeof value === "number" || typeof value === "bigint")
|
1163
1564
|
return numberToHex(value);
|
1164
1565
|
if (typeof value === "string") {
|
@@ -1200,14 +1601,9 @@ function stringToHex(value) {
|
|
1200
1601
|
return `0x${hex}`;
|
1201
1602
|
}
|
1202
1603
|
|
1203
|
-
// src/utils/encoding/
|
1604
|
+
// src/utils/encoding/toBytes.ts
|
1204
1605
|
var encoder = new TextEncoder();
|
1205
|
-
function
|
1206
|
-
const bytes = new Uint8Array(1);
|
1207
|
-
bytes[0] = Number(value);
|
1208
|
-
return bytes;
|
1209
|
-
}
|
1210
|
-
function encodeBytes(value) {
|
1606
|
+
function toBytes(value) {
|
1211
1607
|
if (typeof value === "number" || typeof value === "bigint")
|
1212
1608
|
return numberToBytes(value);
|
1213
1609
|
if (typeof value === "boolean")
|
@@ -1216,6 +1612,11 @@ function encodeBytes(value) {
|
|
1216
1612
|
return hexToBytes(value);
|
1217
1613
|
return stringToBytes(value);
|
1218
1614
|
}
|
1615
|
+
function boolToBytes(value) {
|
1616
|
+
const bytes = new Uint8Array(1);
|
1617
|
+
bytes[0] = Number(value);
|
1618
|
+
return bytes;
|
1619
|
+
}
|
1219
1620
|
function hexToBytes(hex_) {
|
1220
1621
|
let hex = hex_.slice(2);
|
1221
1622
|
if (hex.length % 2)
|
@@ -1226,7 +1627,7 @@ function hexToBytes(hex_) {
|
|
1226
1627
|
const hexByte = hex.slice(start, start + 2);
|
1227
1628
|
const byte = Number.parseInt(hexByte, 16);
|
1228
1629
|
if (Number.isNaN(byte) || byte < 0)
|
1229
|
-
throw new
|
1630
|
+
throw new BaseError(`Invalid byte sequence ("${hexByte}" in "${hex}").`);
|
1230
1631
|
bytes[index] = byte;
|
1231
1632
|
}
|
1232
1633
|
return bytes;
|
@@ -1239,15 +1640,15 @@ function stringToBytes(value) {
|
|
1239
1640
|
return encoder.encode(value);
|
1240
1641
|
}
|
1241
1642
|
|
1242
|
-
// src/utils/encoding/
|
1243
|
-
function
|
1643
|
+
// src/utils/encoding/toRlp.ts
|
1644
|
+
function toRlp(hexOrBytes, to_) {
|
1244
1645
|
const to = to_ || "hex";
|
1245
1646
|
return format(bytesToRlp(parse(hexOrBytes)), to);
|
1246
1647
|
}
|
1247
1648
|
function parse(hexOrBytes) {
|
1248
1649
|
if (Array.isArray(hexOrBytes))
|
1249
1650
|
return hexOrBytes.map(parse);
|
1250
|
-
return typeof hexOrBytes === "string" ?
|
1651
|
+
return typeof hexOrBytes === "string" ? toBytes(hexOrBytes) : hexOrBytes;
|
1251
1652
|
}
|
1252
1653
|
function format(bytes, type = "bytes") {
|
1253
1654
|
return type === "hex" ? bytesToHex(bytes) : bytes;
|
@@ -1264,11 +1665,11 @@ function bytesToRlp(bytes) {
|
|
1264
1665
|
function encodeLength(length, offset) {
|
1265
1666
|
if (length < 56)
|
1266
1667
|
return [offset + length];
|
1267
|
-
return [
|
1668
|
+
return [toBytes(length).length + offset + 55, ...toBytes(length)];
|
1268
1669
|
}
|
1269
1670
|
|
1270
|
-
// src/utils/encoding/
|
1271
|
-
function
|
1671
|
+
// src/utils/encoding/fromHex.ts
|
1672
|
+
function fromHex(hex, to) {
|
1272
1673
|
if (to === "number")
|
1273
1674
|
return hexToNumber(hex);
|
1274
1675
|
if (to === "bigint")
|
@@ -1305,8 +1706,8 @@ function hexToString(hex) {
|
|
1305
1706
|
return new TextDecoder().decode(bytes);
|
1306
1707
|
}
|
1307
1708
|
|
1308
|
-
// src/utils/encoding/
|
1309
|
-
function
|
1709
|
+
// src/utils/encoding/fromBytes.ts
|
1710
|
+
function fromBytes(bytes, to) {
|
1310
1711
|
if (to === "number")
|
1311
1712
|
return bytesToNumber(bytes);
|
1312
1713
|
if (to === "bigint")
|
@@ -1334,8 +1735,8 @@ function bytesToString(bytes) {
|
|
1334
1735
|
return new TextDecoder().decode(bytes);
|
1335
1736
|
}
|
1336
1737
|
|
1337
|
-
// src/utils/encoding/
|
1338
|
-
function
|
1738
|
+
// src/utils/encoding/fromRlp.ts
|
1739
|
+
function fromRlp(value, to) {
|
1339
1740
|
const bytes = parse2(value);
|
1340
1741
|
const [data, consumed] = rlpToBytes(bytes);
|
1341
1742
|
if (consumed < bytes.length)
|
@@ -1440,50 +1841,18 @@ function extractFunctionType(def) {
|
|
1440
1841
|
return extractFunctionParts(def).type;
|
1441
1842
|
}
|
1442
1843
|
|
1443
|
-
// src/utils/contract/getContractError.ts
|
1444
|
-
var EXECUTION_REVERTED_ERROR_CODE = 3;
|
1445
|
-
function getContractError(err, {
|
1446
|
-
abi,
|
1447
|
-
address,
|
1448
|
-
args,
|
1449
|
-
docsPath: docsPath5,
|
1450
|
-
functionName,
|
1451
|
-
sender
|
1452
|
-
}) {
|
1453
|
-
const { code, data, message } = err instanceof RawContractError ? err : err.cause || {};
|
1454
|
-
let cause = err;
|
1455
|
-
if (err instanceof AbiDecodingZeroDataError) {
|
1456
|
-
cause = new ContractFunctionZeroDataError({ functionName });
|
1457
|
-
} else if (code === EXECUTION_REVERTED_ERROR_CODE && (data || message)) {
|
1458
|
-
cause = new ContractFunctionRevertedError({
|
1459
|
-
abi,
|
1460
|
-
data,
|
1461
|
-
functionName,
|
1462
|
-
message
|
1463
|
-
});
|
1464
|
-
}
|
1465
|
-
return new ContractFunctionExecutionError(cause, {
|
1466
|
-
abi,
|
1467
|
-
args,
|
1468
|
-
contractAddress: address,
|
1469
|
-
docsPath: docsPath5,
|
1470
|
-
functionName,
|
1471
|
-
sender
|
1472
|
-
});
|
1473
|
-
}
|
1474
|
-
|
1475
1844
|
// src/utils/hash/keccak256.ts
|
1476
1845
|
import { keccak_256 } from "@noble/hashes/sha3";
|
1477
1846
|
function keccak256(value, to_) {
|
1478
1847
|
const to = to_ || "hex";
|
1479
|
-
const bytes = keccak_256(value);
|
1848
|
+
const bytes = keccak_256(isHex(value) ? toBytes(value) : value);
|
1480
1849
|
if (to === "bytes")
|
1481
1850
|
return bytes;
|
1482
|
-
return
|
1851
|
+
return toHex(bytes);
|
1483
1852
|
}
|
1484
1853
|
|
1485
1854
|
// src/utils/hash/hashFunction.ts
|
1486
|
-
var hash = (value) => keccak256(
|
1855
|
+
var hash = (value) => keccak256(toBytes(value));
|
1487
1856
|
function hashFunction(def) {
|
1488
1857
|
const name = extractFunctionName(def);
|
1489
1858
|
const params = extractFunctionParams(def);
|
@@ -1492,20 +1861,25 @@ function hashFunction(def) {
|
|
1492
1861
|
return hash(`${name}(${params.map(({ type }) => type).join(",")})`);
|
1493
1862
|
}
|
1494
1863
|
|
1495
|
-
// src/utils/hash/
|
1496
|
-
var
|
1864
|
+
// src/utils/hash/getEventSelector.ts
|
1865
|
+
var getEventSelector = (event) => hashFunction(event);
|
1497
1866
|
|
1498
|
-
// src/utils/hash/
|
1499
|
-
var
|
1867
|
+
// src/utils/hash/getFunctionSelector.ts
|
1868
|
+
var getFunctionSelector = (fn) => slice(hashFunction(fn), 0, 4);
|
1869
|
+
|
1870
|
+
// src/utils/address/isAddress.ts
|
1871
|
+
var addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
1872
|
+
function isAddress(address) {
|
1873
|
+
return addressRegex.test(address);
|
1874
|
+
}
|
1500
1875
|
|
1501
1876
|
// src/utils/address/getAddress.ts
|
1502
|
-
var addressRegex = /^(0x)?[a-fA-F0-9]{40}$/;
|
1503
1877
|
function checksumAddress(address_) {
|
1504
1878
|
const hexAddress = address_.substring(2).toLowerCase();
|
1505
1879
|
const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
|
1506
1880
|
let address = hexAddress.split("");
|
1507
1881
|
for (let i = 0; i < 40; i += 2) {
|
1508
|
-
if (hash2
|
1882
|
+
if (hash2[i >> 1] >> 4 >= 8 && address[i]) {
|
1509
1883
|
address[i] = address[i].toUpperCase();
|
1510
1884
|
}
|
1511
1885
|
if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
|
@@ -1515,61 +1889,52 @@ function checksumAddress(address_) {
|
|
1515
1889
|
return `0x${address.join("")}`;
|
1516
1890
|
}
|
1517
1891
|
function getAddress(address) {
|
1518
|
-
if (!
|
1892
|
+
if (!isAddress(address))
|
1519
1893
|
throw new InvalidAddressError({ address });
|
1520
1894
|
return checksumAddress(address);
|
1521
1895
|
}
|
1522
1896
|
|
1523
1897
|
// src/utils/address/getContractAddress.ts
|
1524
|
-
function
|
1898
|
+
function getContractAddress2(opts) {
|
1525
1899
|
if (opts.opcode === "CREATE2")
|
1526
1900
|
return getCreate2Address(opts);
|
1527
1901
|
return getCreateAddress(opts);
|
1528
1902
|
}
|
1529
1903
|
function getCreateAddress(opts) {
|
1530
|
-
const from =
|
1531
|
-
let nonce =
|
1904
|
+
const from = toBytes(getAddress(opts.from));
|
1905
|
+
let nonce = toBytes(opts.nonce);
|
1532
1906
|
if (nonce[0] === 0)
|
1533
1907
|
nonce = new Uint8Array([]);
|
1534
1908
|
return getAddress(
|
1535
|
-
`0x${keccak256(
|
1909
|
+
`0x${keccak256(toRlp([from, nonce], "bytes")).slice(26)}`
|
1536
1910
|
);
|
1537
1911
|
}
|
1538
1912
|
function getCreate2Address(opts) {
|
1539
|
-
const from =
|
1540
|
-
const salt = pad(
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
const bytecodeHash = encodeBytes(
|
1913
|
+
const from = toBytes(getAddress(opts.from));
|
1914
|
+
const salt = pad(isBytes(opts.salt) ? opts.salt : toBytes(opts.salt), {
|
1915
|
+
size: 32
|
1916
|
+
});
|
1917
|
+
const bytecodeHash = toBytes(
|
1545
1918
|
keccak256(
|
1546
|
-
isBytes(opts.bytecode) ? opts.bytecode :
|
1919
|
+
isBytes(opts.bytecode) ? opts.bytecode : toBytes(opts.bytecode)
|
1547
1920
|
)
|
1548
1921
|
);
|
1549
1922
|
return getAddress(
|
1550
|
-
slice(
|
1551
|
-
keccak256(concat([encodeBytes("0xff"), from, salt, bytecodeHash])),
|
1552
|
-
12
|
1553
|
-
)
|
1923
|
+
slice(keccak256(concat([toBytes("0xff"), from, salt, bytecodeHash])), 12)
|
1554
1924
|
);
|
1555
1925
|
}
|
1556
1926
|
|
1557
|
-
// src/utils/address/isAddress.ts
|
1558
|
-
function isAddress(address) {
|
1559
|
-
try {
|
1560
|
-
return Boolean(getAddress(address));
|
1561
|
-
} catch {
|
1562
|
-
return false;
|
1563
|
-
}
|
1564
|
-
}
|
1565
|
-
|
1566
1927
|
// src/utils/address/isAddressEqual.ts
|
1567
1928
|
function isAddressEqual(a, b) {
|
1568
|
-
|
1929
|
+
if (!isAddress(a))
|
1930
|
+
throw new InvalidAddressError({ address: a });
|
1931
|
+
if (!isAddress(b))
|
1932
|
+
throw new InvalidAddressError({ address: b });
|
1933
|
+
return a.toLowerCase() === b.toLowerCase();
|
1569
1934
|
}
|
1570
1935
|
|
1571
|
-
// src/utils/abi/
|
1572
|
-
function
|
1936
|
+
// src/utils/abi/encodeAbiParameters.ts
|
1937
|
+
function encodeAbiParameters(params, values) {
|
1573
1938
|
if (params.length !== values.length)
|
1574
1939
|
throw new AbiEncodingLengthMismatchError({
|
1575
1940
|
expectedLength: params.length,
|
@@ -1619,13 +1984,13 @@ function prepareParam({
|
|
1619
1984
|
return encodeNumber(value, { signed });
|
1620
1985
|
}
|
1621
1986
|
if (param.type.startsWith("bytes")) {
|
1622
|
-
return
|
1987
|
+
return encodeBytes(value, { param });
|
1623
1988
|
}
|
1624
1989
|
if (param.type === "string") {
|
1625
1990
|
return encodeString(value);
|
1626
1991
|
}
|
1627
1992
|
throw new InvalidAbiEncodingTypeError(param.type, {
|
1628
|
-
docsPath: "/docs/contract/
|
1993
|
+
docsPath: "/docs/contract/encodeAbiParameters"
|
1629
1994
|
});
|
1630
1995
|
}
|
1631
1996
|
function encodeParams(preparedParams) {
|
@@ -1653,6 +2018,8 @@ function encodeParams(preparedParams) {
|
|
1653
2018
|
return concat([...staticParams, ...dynamicParams]);
|
1654
2019
|
}
|
1655
2020
|
function encodeAddress(value) {
|
2021
|
+
if (!isAddress(value))
|
2022
|
+
throw new InvalidAddressError({ address: value });
|
1656
2023
|
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
1657
2024
|
}
|
1658
2025
|
function encodeArray(value, {
|
@@ -1693,13 +2060,17 @@ function encodeArray(value, {
|
|
1693
2060
|
encoded: concat(preparedParams.map(({ encoded }) => encoded))
|
1694
2061
|
};
|
1695
2062
|
}
|
1696
|
-
function
|
2063
|
+
function encodeBytes(value, { param }) {
|
1697
2064
|
const [_, size_] = param.type.split("bytes");
|
1698
2065
|
if (!size_) {
|
1699
2066
|
const partsLength = Math.floor(size(value) / 32);
|
1700
2067
|
const parts = [];
|
1701
2068
|
for (let i = 0; i < partsLength + 1; i++) {
|
1702
|
-
parts.push(
|
2069
|
+
parts.push(
|
2070
|
+
padHex(slice(value, i * 32, (i + 1) * 32), {
|
2071
|
+
dir: "right"
|
2072
|
+
})
|
2073
|
+
);
|
1703
2074
|
}
|
1704
2075
|
return {
|
1705
2076
|
dynamic: true,
|
@@ -1709,6 +2080,11 @@ function encodeBytes2(value, { param }) {
|
|
1709
2080
|
])
|
1710
2081
|
};
|
1711
2082
|
}
|
2083
|
+
if (size(value) !== parseInt(size_))
|
2084
|
+
throw new AbiEncodingBytesSizeMismatchError({
|
2085
|
+
expectedSize: parseInt(size_),
|
2086
|
+
value
|
2087
|
+
});
|
1712
2088
|
return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
|
1713
2089
|
}
|
1714
2090
|
function encodeBool(value) {
|
@@ -1743,7 +2119,8 @@ function encodeTuple(value, { param }) {
|
|
1743
2119
|
value: value[index]
|
1744
2120
|
});
|
1745
2121
|
preparedParams.push(preparedParam);
|
1746
|
-
|
2122
|
+
if (preparedParam.dynamic)
|
2123
|
+
dynamic = true;
|
1747
2124
|
}
|
1748
2125
|
return {
|
1749
2126
|
dynamic,
|
@@ -1758,19 +2135,16 @@ function getArrayComponents(type) {
|
|
1758
2135
|
) : void 0;
|
1759
2136
|
}
|
1760
2137
|
|
1761
|
-
// src/utils/abi/
|
1762
|
-
function
|
2138
|
+
// src/utils/abi/decodeAbiParameters.ts
|
2139
|
+
function decodeAbiParameters(params, data) {
|
1763
2140
|
if (data === "0x" && params.length > 0)
|
1764
2141
|
throw new AbiDecodingZeroDataError();
|
1765
2142
|
if (size(data) % 32 !== 0)
|
1766
2143
|
throw new AbiDecodingDataSizeInvalidError(size(data));
|
1767
|
-
|
2144
|
+
return decodeParams({
|
1768
2145
|
data,
|
1769
2146
|
params
|
1770
2147
|
});
|
1771
|
-
if (values.length === 0)
|
1772
|
-
return void 0;
|
1773
|
-
return values;
|
1774
2148
|
}
|
1775
2149
|
function decodeParams({
|
1776
2150
|
data,
|
@@ -1807,7 +2181,7 @@ function decodeParam({
|
|
1807
2181
|
return decodeString(data, { position });
|
1808
2182
|
}
|
1809
2183
|
if (param.type.startsWith("bytes")) {
|
1810
|
-
return
|
2184
|
+
return decodeBytes(data, { param, position });
|
1811
2185
|
}
|
1812
2186
|
let value = slice(data, position, position + 32);
|
1813
2187
|
if (param.type.startsWith("uint") || param.type.startsWith("int")) {
|
@@ -1820,7 +2194,7 @@ function decodeParam({
|
|
1820
2194
|
return decodeBool(value);
|
1821
2195
|
}
|
1822
2196
|
throw new InvalidAbiDecodingTypeError(param.type, {
|
1823
|
-
docsPath: "/docs/contract/
|
2197
|
+
docsPath: "/docs/contract/decodeAbiParameters"
|
1824
2198
|
});
|
1825
2199
|
}
|
1826
2200
|
function decodeAddress(value) {
|
@@ -1880,12 +2254,15 @@ function decodeArray(data, {
|
|
1880
2254
|
function decodeBool(value) {
|
1881
2255
|
return { consumed: 32, value: hexToBool(value) };
|
1882
2256
|
}
|
1883
|
-
function
|
2257
|
+
function decodeBytes(data, { param, position }) {
|
1884
2258
|
const [_, size2] = param.type.split("bytes");
|
1885
2259
|
if (!size2) {
|
1886
2260
|
const offset = hexToNumber(slice(data, position, position + 32));
|
1887
2261
|
const length = hexToNumber(slice(data, offset, offset + 32));
|
1888
|
-
const value2 =
|
2262
|
+
const value2 = (
|
2263
|
+
// If there is no length, we have zero data.
|
2264
|
+
length === 0 ? "0x" : slice(data, offset + 32, offset + 32 + length)
|
2265
|
+
);
|
1889
2266
|
return { consumed: 32, value: value2 };
|
1890
2267
|
}
|
1891
2268
|
const value = slice(data, position, position + parseInt(size2));
|
@@ -1984,7 +2361,7 @@ function decodeErrorResult({
|
|
1984
2361
|
throw new AbiDecodingZeroDataError();
|
1985
2362
|
const abi_ = [...abi || [], solidityError, solidityPanic];
|
1986
2363
|
const abiItem = abi_.find(
|
1987
|
-
(x) => x.type === "error" && signature ===
|
2364
|
+
(x) => x.type === "error" && signature === getFunctionSelector(formatAbiItem(x))
|
1988
2365
|
);
|
1989
2366
|
if (!abiItem)
|
1990
2367
|
throw new AbiErrorSignatureNotFoundError(signature, {
|
@@ -1992,7 +2369,7 @@ function decodeErrorResult({
|
|
1992
2369
|
});
|
1993
2370
|
return {
|
1994
2371
|
abiItem,
|
1995
|
-
args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ?
|
2372
|
+
args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbiParameters(abiItem.inputs, slice(data, 4)) : void 0,
|
1996
2373
|
errorName: abiItem.name
|
1997
2374
|
};
|
1998
2375
|
}
|
@@ -2005,7 +2382,7 @@ function decodeEventLog({
|
|
2005
2382
|
}) {
|
2006
2383
|
const [signature, ...argTopics] = topics;
|
2007
2384
|
const abiItem = abi.find(
|
2008
|
-
(x) => signature ===
|
2385
|
+
(x) => signature === getEventSelector(formatAbiItem(x))
|
2009
2386
|
);
|
2010
2387
|
if (!(abiItem && "name" in abiItem))
|
2011
2388
|
throw new AbiEventSignatureNotFoundError(signature, {
|
@@ -2027,9 +2404,9 @@ function decodeEventLog({
|
|
2027
2404
|
args[param.name || i] = decodeTopic({ param, value: topic });
|
2028
2405
|
}
|
2029
2406
|
}
|
2030
|
-
if (data) {
|
2407
|
+
if (data && data !== "0x") {
|
2031
2408
|
const params = inputs.filter((x) => !("indexed" in x && x.indexed));
|
2032
|
-
const decodedData =
|
2409
|
+
const decodedData = decodeAbiParameters(params, data);
|
2033
2410
|
if (decodedData) {
|
2034
2411
|
if (isUnnamed)
|
2035
2412
|
args = [...args, ...decodedData];
|
@@ -2048,15 +2425,18 @@ function decodeEventLog({
|
|
2048
2425
|
function decodeTopic({ param, value }) {
|
2049
2426
|
if (param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
2050
2427
|
return value;
|
2051
|
-
const decodedArg =
|
2428
|
+
const decodedArg = decodeAbiParameters([param], value) || [];
|
2052
2429
|
return decodedArg[0];
|
2053
2430
|
}
|
2054
2431
|
|
2055
2432
|
// src/utils/abi/decodeFunctionData.ts
|
2056
|
-
function decodeFunctionData({
|
2433
|
+
function decodeFunctionData({
|
2434
|
+
abi,
|
2435
|
+
data
|
2436
|
+
}) {
|
2057
2437
|
const signature = slice(data, 0, 4);
|
2058
2438
|
const description = abi.find(
|
2059
|
-
(x) => signature ===
|
2439
|
+
(x) => signature === getFunctionSelector(formatAbiItem(x))
|
2060
2440
|
);
|
2061
2441
|
if (!description)
|
2062
2442
|
throw new AbiFunctionSignatureNotFoundError(signature, {
|
@@ -2064,12 +2444,16 @@ function decodeFunctionData({ abi, data }) {
|
|
2064
2444
|
});
|
2065
2445
|
return {
|
2066
2446
|
functionName: description.name,
|
2067
|
-
args: "inputs" in description && description.inputs && description.inputs.length > 0 ?
|
2447
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbiParameters(description.inputs, slice(data, 4)) : void 0
|
2068
2448
|
};
|
2069
2449
|
}
|
2070
2450
|
|
2071
2451
|
// src/utils/abi/getAbiItem.ts
|
2072
|
-
function getAbiItem({
|
2452
|
+
function getAbiItem({
|
2453
|
+
abi,
|
2454
|
+
args = [],
|
2455
|
+
name
|
2456
|
+
}) {
|
2073
2457
|
const abiItems = abi.filter((x) => "name" in x && x.name === name);
|
2074
2458
|
if (abiItems.length === 0)
|
2075
2459
|
return void 0;
|
@@ -2157,7 +2541,7 @@ function decodeFunctionResult({
|
|
2157
2541
|
throw new AbiFunctionNotFoundError(functionName, { docsPath });
|
2158
2542
|
if (!("outputs" in description))
|
2159
2543
|
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
|
2160
|
-
const values =
|
2544
|
+
const values = decodeAbiParameters(description.outputs, data);
|
2161
2545
|
if (values && values.length > 1)
|
2162
2546
|
return values;
|
2163
2547
|
if (values && values.length === 1)
|
@@ -2183,10 +2567,10 @@ function encodeDeployData({
|
|
2183
2567
|
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
2184
2568
|
if (!description.inputs || description.inputs.length === 0)
|
2185
2569
|
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
2186
|
-
const data =
|
2187
|
-
|
2188
|
-
|
2189
|
-
|
2570
|
+
const data = encodeAbiParameters(
|
2571
|
+
description.inputs,
|
2572
|
+
args
|
2573
|
+
);
|
2190
2574
|
return concatHex([bytecode, data]);
|
2191
2575
|
}
|
2192
2576
|
|
@@ -2201,25 +2585,29 @@ function encodeErrorResult({ abi, errorName, args }) {
|
|
2201
2585
|
if (!description)
|
2202
2586
|
throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
|
2203
2587
|
const definition = formatAbiItem(description);
|
2204
|
-
const signature =
|
2588
|
+
const signature = getFunctionSelector(definition);
|
2205
2589
|
let data = "0x";
|
2206
2590
|
if (args && args.length > 0) {
|
2207
2591
|
if (!("inputs" in description && description.inputs))
|
2208
2592
|
throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
|
2209
|
-
data =
|
2593
|
+
data = encodeAbiParameters(description.inputs, args);
|
2210
2594
|
}
|
2211
2595
|
return concatHex([signature, data]);
|
2212
2596
|
}
|
2213
2597
|
|
2214
2598
|
// src/utils/abi/encodeEventTopics.ts
|
2215
2599
|
function encodeEventTopics({ abi, eventName, args }) {
|
2216
|
-
const abiItem = getAbiItem({
|
2600
|
+
const abiItem = getAbiItem({
|
2601
|
+
abi,
|
2602
|
+
args,
|
2603
|
+
name: eventName
|
2604
|
+
});
|
2217
2605
|
if (!abiItem)
|
2218
2606
|
throw new AbiEventNotFoundError(eventName, {
|
2219
2607
|
docsPath: "/docs/contract/encodeEventTopics"
|
2220
2608
|
});
|
2221
2609
|
const definition = formatAbiItem(abiItem);
|
2222
|
-
const signature =
|
2610
|
+
const signature = getEventSelector(definition);
|
2223
2611
|
let topics = [];
|
2224
2612
|
if (args && "inputs" in abiItem) {
|
2225
2613
|
const args_ = Array.isArray(args) ? args : abiItem.inputs?.map((x) => args[x.name]) ?? [];
|
@@ -2236,14 +2624,18 @@ function encodeArg({
|
|
2236
2624
|
value
|
2237
2625
|
}) {
|
2238
2626
|
if (param.type === "string" || param.type === "bytes")
|
2239
|
-
return keccak256(
|
2627
|
+
return keccak256(toBytes(value));
|
2240
2628
|
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
2241
2629
|
throw new FilterTypeNotSupportedError(param.type);
|
2242
|
-
return
|
2630
|
+
return encodeAbiParameters([param], [value]);
|
2243
2631
|
}
|
2244
2632
|
|
2245
2633
|
// src/utils/abi/encodeFunctionData.ts
|
2246
|
-
function encodeFunctionData({
|
2634
|
+
function encodeFunctionData({
|
2635
|
+
abi,
|
2636
|
+
args,
|
2637
|
+
functionName
|
2638
|
+
}) {
|
2247
2639
|
const description = getAbiItem({
|
2248
2640
|
abi,
|
2249
2641
|
args,
|
@@ -2254,11 +2646,11 @@ function encodeFunctionData({ abi, args, functionName }) {
|
|
2254
2646
|
docsPath: "/docs/contract/encodeFunctionData"
|
2255
2647
|
});
|
2256
2648
|
const definition = formatAbiItem(description);
|
2257
|
-
const signature =
|
2258
|
-
const data = "inputs" in description && description.inputs ?
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2649
|
+
const signature = getFunctionSelector(definition);
|
2650
|
+
const data = "inputs" in description && description.inputs ? encodeAbiParameters(
|
2651
|
+
description.inputs,
|
2652
|
+
args ?? []
|
2653
|
+
) : void 0;
|
2262
2654
|
return concatHex([signature, data ?? "0x"]);
|
2263
2655
|
}
|
2264
2656
|
|
@@ -2279,7 +2671,73 @@ function encodeFunctionResult({
|
|
2279
2671
|
let values = Array.isArray(result) ? result : [result];
|
2280
2672
|
if (description.outputs.length === 0 && !values[0])
|
2281
2673
|
values = [];
|
2282
|
-
return
|
2674
|
+
return encodeAbiParameters(description.outputs, values);
|
2675
|
+
}
|
2676
|
+
|
2677
|
+
// src/utils/regex.ts
|
2678
|
+
var arrayRegex = /^(.*)\[([0-9]*)\]$/;
|
2679
|
+
var bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
|
2680
|
+
var integerRegex = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
|
2681
|
+
|
2682
|
+
// src/utils/abi/encodePacked.ts
|
2683
|
+
function encodePacked(types, values) {
|
2684
|
+
if (types.length !== values.length)
|
2685
|
+
throw new AbiEncodingLengthMismatchError({
|
2686
|
+
expectedLength: types.length,
|
2687
|
+
givenLength: values.length
|
2688
|
+
});
|
2689
|
+
let data = [];
|
2690
|
+
for (let i = 0; i < types.length; i++) {
|
2691
|
+
const type = types[i];
|
2692
|
+
const value = values[i];
|
2693
|
+
data.push(encode(type, value));
|
2694
|
+
}
|
2695
|
+
return concat(data);
|
2696
|
+
}
|
2697
|
+
function encode(type, value, isArray = false) {
|
2698
|
+
if (type === "address") {
|
2699
|
+
let address = value;
|
2700
|
+
if (!isAddress(address))
|
2701
|
+
throw new InvalidAddressError({ address });
|
2702
|
+
return pad(address.toLowerCase(), {
|
2703
|
+
size: isArray ? 32 : null
|
2704
|
+
});
|
2705
|
+
}
|
2706
|
+
if (type === "string")
|
2707
|
+
return stringToHex(value);
|
2708
|
+
if (type === "bytes")
|
2709
|
+
return value;
|
2710
|
+
if (type === "bool")
|
2711
|
+
return pad(boolToHex(value), { size: isArray ? 32 : 1 });
|
2712
|
+
const intMatch = type.match(integerRegex);
|
2713
|
+
if (intMatch) {
|
2714
|
+
const [_type, baseType, bits = "256"] = intMatch;
|
2715
|
+
const size2 = parseInt(bits) / 8;
|
2716
|
+
return numberToHex(value, {
|
2717
|
+
size: isArray ? 32 : size2,
|
2718
|
+
signed: baseType === "int"
|
2719
|
+
});
|
2720
|
+
}
|
2721
|
+
const bytesMatch = type.match(bytesRegex);
|
2722
|
+
if (bytesMatch) {
|
2723
|
+
const [_type, size2] = bytesMatch;
|
2724
|
+
if (parseInt(size2) !== (value.length - 2) / 2)
|
2725
|
+
throw new BytesSizeMismatchError({
|
2726
|
+
expectedSize: parseInt(size2),
|
2727
|
+
givenSize: (value.length - 2) / 2
|
2728
|
+
});
|
2729
|
+
return pad(value, { dir: "right", size: isArray ? 32 : null });
|
2730
|
+
}
|
2731
|
+
const arrayMatch = type.match(arrayRegex);
|
2732
|
+
if (arrayMatch && Array.isArray(value)) {
|
2733
|
+
const [_type, childType] = arrayMatch;
|
2734
|
+
let data = [];
|
2735
|
+
for (let i = 0; i < value.length; i++) {
|
2736
|
+
data.push(encode(childType, value[i], true));
|
2737
|
+
}
|
2738
|
+
return concat(data);
|
2739
|
+
}
|
2740
|
+
throw new UnsupportedPackedAbiType(type);
|
2283
2741
|
}
|
2284
2742
|
|
2285
2743
|
// src/utils/abi/formatAbiItemWithArgs.ts
|
@@ -2300,18 +2758,33 @@ function formatAbiItemWithArgs({
|
|
2300
2758
|
).join(", ")})`;
|
2301
2759
|
}
|
2302
2760
|
|
2761
|
+
// src/utils/account.ts
|
2762
|
+
function getAccount(account) {
|
2763
|
+
if (typeof account === "string") {
|
2764
|
+
if (!isAddress(account))
|
2765
|
+
throw new InvalidAddressError({ address: account });
|
2766
|
+
return { address: account, type: "json-rpc" };
|
2767
|
+
}
|
2768
|
+
if (!isAddress(account.address))
|
2769
|
+
throw new InvalidAddressError({ address: account.address });
|
2770
|
+
return {
|
2771
|
+
...account,
|
2772
|
+
type: "local"
|
2773
|
+
};
|
2774
|
+
}
|
2775
|
+
|
2303
2776
|
// src/utils/promise/withCache.ts
|
2304
2777
|
var promiseCache = /* @__PURE__ */ new Map();
|
2305
2778
|
var responseCache = /* @__PURE__ */ new Map();
|
2306
|
-
function getCache(
|
2307
|
-
const buildCache = (
|
2308
|
-
clear: () => cache.delete(
|
2309
|
-
get: () => cache.get(
|
2310
|
-
set: (data) => cache.set(
|
2779
|
+
function getCache(cacheKey2) {
|
2780
|
+
const buildCache = (cacheKey3, cache) => ({
|
2781
|
+
clear: () => cache.delete(cacheKey3),
|
2782
|
+
get: () => cache.get(cacheKey3),
|
2783
|
+
set: (data) => cache.set(cacheKey3, data)
|
2311
2784
|
});
|
2312
|
-
const promise = buildCache(
|
2785
|
+
const promise = buildCache(cacheKey2, promiseCache);
|
2313
2786
|
const response = buildCache(
|
2314
|
-
|
2787
|
+
cacheKey2,
|
2315
2788
|
responseCache
|
2316
2789
|
);
|
2317
2790
|
return {
|
@@ -2323,8 +2796,8 @@ function getCache(cacheKey) {
|
|
2323
2796
|
response
|
2324
2797
|
};
|
2325
2798
|
}
|
2326
|
-
async function withCache(fn, { cacheKey, maxAge = Infinity }) {
|
2327
|
-
const cache = getCache(
|
2799
|
+
async function withCache(fn, { cacheKey: cacheKey2, maxAge = Infinity }) {
|
2800
|
+
const cache = getCache(cacheKey2);
|
2328
2801
|
const response = cache.response.get();
|
2329
2802
|
if (response && maxAge > 0) {
|
2330
2803
|
const age = (/* @__PURE__ */ new Date()).getTime() - response.created.getTime();
|
@@ -2351,25 +2824,22 @@ async function wait(time) {
|
|
2351
2824
|
function withRetry(fn, {
|
2352
2825
|
delay: delay_ = 100,
|
2353
2826
|
retryCount = 2,
|
2354
|
-
|
2355
|
-
shouldRetryOnError = () => false
|
2827
|
+
shouldRetry = () => true
|
2356
2828
|
} = {}) {
|
2357
2829
|
return new Promise((resolve, reject) => {
|
2358
2830
|
const attemptRetry = async ({ count = 0 } = {}) => {
|
2359
|
-
const retry = async ({
|
2360
|
-
const delay = typeof delay_ === "function" ? delay_({ count,
|
2831
|
+
const retry = async ({ error }) => {
|
2832
|
+
const delay = typeof delay_ === "function" ? delay_({ count, error }) : delay_;
|
2361
2833
|
if (delay)
|
2362
2834
|
await wait(delay);
|
2363
2835
|
attemptRetry({ count: count + 1 });
|
2364
2836
|
};
|
2365
2837
|
try {
|
2366
2838
|
const data = await fn();
|
2367
|
-
if (count < retryCount && await shouldRetryOnResponse({ count, data }))
|
2368
|
-
return retry({ data });
|
2369
2839
|
resolve(data);
|
2370
2840
|
} catch (err) {
|
2371
|
-
if (count < retryCount && await
|
2372
|
-
return retry();
|
2841
|
+
if (count < retryCount && await shouldRetry({ count, error: err }))
|
2842
|
+
return retry({ error: err });
|
2373
2843
|
reject(err);
|
2374
2844
|
}
|
2375
2845
|
};
|
@@ -2411,11 +2881,11 @@ function withTimeout(fn, {
|
|
2411
2881
|
}
|
2412
2882
|
|
2413
2883
|
// src/utils/buildRequest.ts
|
2414
|
-
var
|
2415
|
-
if (error instanceof UnknownRpcError)
|
2416
|
-
return true;
|
2884
|
+
var isDeterministicError = (error) => {
|
2417
2885
|
if ("code" in error)
|
2418
|
-
return error.code
|
2886
|
+
return error.code !== -32603 && error.code !== -32005;
|
2887
|
+
if (error instanceof HttpRequestError && error.status)
|
2888
|
+
return error.status !== 408 && error.status !== 413 && error.status !== 429 && error.status !== 500 && error.status !== 502 && error.status !== 503 && error.status !== 504;
|
2419
2889
|
return false;
|
2420
2890
|
};
|
2421
2891
|
function buildRequest(request, {
|
@@ -2427,7 +2897,7 @@ function buildRequest(request, {
|
|
2427
2897
|
try {
|
2428
2898
|
return await request(args);
|
2429
2899
|
} catch (err_) {
|
2430
|
-
|
2900
|
+
const err = err_;
|
2431
2901
|
if (err.code === -32700)
|
2432
2902
|
throw new ParseRpcError(err);
|
2433
2903
|
if (err.code === -32600)
|
@@ -2452,15 +2922,26 @@ function buildRequest(request, {
|
|
2452
2922
|
throw new LimitExceededRpcError(err);
|
2453
2923
|
if (err.code === -32006)
|
2454
2924
|
throw new JsonRpcVersionUnsupportedError(err);
|
2925
|
+
if (err.code === 4001)
|
2926
|
+
throw new UserRejectedRequestError(err);
|
2927
|
+
if (err.code === 4902)
|
2928
|
+
throw new SwitchChainError(err);
|
2455
2929
|
if (err_ instanceof BaseError)
|
2456
2930
|
throw err_;
|
2457
2931
|
throw new UnknownRpcError(err);
|
2458
2932
|
}
|
2459
2933
|
},
|
2460
2934
|
{
|
2461
|
-
delay: ({ count }) =>
|
2935
|
+
delay: ({ count, error }) => {
|
2936
|
+
if (error && error instanceof HttpRequestError) {
|
2937
|
+
const retryAfter = error?.headers?.get("Retry-After");
|
2938
|
+
if (retryAfter?.match(/\d/))
|
2939
|
+
return parseInt(retryAfter) * 1e3;
|
2940
|
+
}
|
2941
|
+
return ~~(1 << count) * retryDelay;
|
2942
|
+
},
|
2462
2943
|
retryCount,
|
2463
|
-
|
2944
|
+
shouldRetry: ({ error }) => !isDeterministicError(error)
|
2464
2945
|
}
|
2465
2946
|
);
|
2466
2947
|
}
|
@@ -2504,6 +2985,7 @@ function formatTransaction(transaction) {
|
|
2504
2985
|
const transaction_ = {
|
2505
2986
|
...transaction,
|
2506
2987
|
blockNumber: transaction.blockNumber ? BigInt(transaction.blockNumber) : null,
|
2988
|
+
chainId: transaction.chainId ? hexToNumber(transaction.chainId) : void 0,
|
2507
2989
|
gas: transaction.gas ? BigInt(transaction.gas) : void 0,
|
2508
2990
|
gasPrice: transaction.gasPrice ? BigInt(transaction.gasPrice) : void 0,
|
2509
2991
|
maxFeePerGas: transaction.maxFeePerGas ? BigInt(transaction.maxFeePerGas) : void 0,
|
@@ -2576,12 +3058,13 @@ function formatFeeHistory(feeHistory) {
|
|
2576
3058
|
}
|
2577
3059
|
|
2578
3060
|
// src/utils/formatters/log.ts
|
2579
|
-
function formatLog(log) {
|
3061
|
+
function formatLog(log, { args, eventName } = {}) {
|
2580
3062
|
return {
|
2581
3063
|
...log,
|
2582
3064
|
blockNumber: log.blockNumber ? BigInt(log.blockNumber) : null,
|
2583
3065
|
logIndex: log.logIndex ? BigInt(log.logIndex) : null,
|
2584
|
-
transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null
|
3066
|
+
transactionIndex: log.transactionIndex ? BigInt(log.transactionIndex) : null,
|
3067
|
+
...eventName ? { args, eventName } : {}
|
2585
3068
|
};
|
2586
3069
|
}
|
2587
3070
|
|
@@ -2597,7 +3080,7 @@ function formatTransactionReceipt(transactionReceipt) {
|
|
2597
3080
|
cumulativeGasUsed: transactionReceipt.cumulativeGasUsed ? BigInt(transactionReceipt.cumulativeGasUsed) : null,
|
2598
3081
|
effectiveGasPrice: transactionReceipt.effectiveGasPrice ? BigInt(transactionReceipt.effectiveGasPrice) : null,
|
2599
3082
|
gasUsed: transactionReceipt.gasUsed ? BigInt(transactionReceipt.gasUsed) : null,
|
2600
|
-
logs: transactionReceipt.logs ? transactionReceipt.logs.map(formatLog) : null,
|
3083
|
+
logs: transactionReceipt.logs ? transactionReceipt.logs.map((log) => formatLog(log)) : null,
|
2601
3084
|
transactionIndex: transactionReceipt.transactionIndex ? hexToNumber(transactionReceipt.transactionIndex) : null,
|
2602
3085
|
status: transactionReceipt.status ? statuses[transactionReceipt.status] : null,
|
2603
3086
|
type: transactionReceipt.type ? transactionType[transactionReceipt.type] : null
|
@@ -2623,36 +3106,155 @@ var defineTransactionRequest = defineFormatter({
|
|
2623
3106
|
format: formatTransactionRequest
|
2624
3107
|
});
|
2625
3108
|
|
3109
|
+
// src/utils/errors/getNodeError.ts
|
3110
|
+
function containsNodeError(err) {
|
3111
|
+
return err instanceof TransactionRejectedRpcError || err instanceof InvalidInputRpcError || err instanceof RpcError && err.code === ExecutionRevertedError.code;
|
3112
|
+
}
|
3113
|
+
function getNodeError(err, args) {
|
3114
|
+
const message = err.details.toLowerCase();
|
3115
|
+
if (FeeCapTooHighError.nodeMessage.test(message))
|
3116
|
+
return new FeeCapTooHighError({
|
3117
|
+
cause: err,
|
3118
|
+
maxFeePerGas: args?.maxFeePerGas
|
3119
|
+
});
|
3120
|
+
else if (FeeCapTooLowError.nodeMessage.test(message))
|
3121
|
+
return new FeeCapTooLowError({
|
3122
|
+
cause: err,
|
3123
|
+
maxFeePerGas: args?.maxFeePerGas
|
3124
|
+
});
|
3125
|
+
else if (NonceTooHighError.nodeMessage.test(message))
|
3126
|
+
return new NonceTooHighError({ cause: err, nonce: args?.nonce });
|
3127
|
+
else if (NonceTooLowError.nodeMessage.test(message))
|
3128
|
+
return new NonceTooLowError({ cause: err, nonce: args?.nonce });
|
3129
|
+
else if (NonceMaxValueError.nodeMessage.test(message))
|
3130
|
+
return new NonceMaxValueError({ cause: err, nonce: args?.nonce });
|
3131
|
+
else if (InsufficientFundsError.nodeMessage.test(message))
|
3132
|
+
return new InsufficientFundsError({ cause: err });
|
3133
|
+
else if (IntrinsicGasTooHighError.nodeMessage.test(message))
|
3134
|
+
return new IntrinsicGasTooHighError({ cause: err, gas: args?.gas });
|
3135
|
+
else if (IntrinsicGasTooLowError.nodeMessage.test(message))
|
3136
|
+
return new IntrinsicGasTooLowError({ cause: err, gas: args?.gas });
|
3137
|
+
else if (TransactionTypeNotSupportedError.nodeMessage.test(message))
|
3138
|
+
return new TransactionTypeNotSupportedError({ cause: err });
|
3139
|
+
else if (TipAboveFeeCapError.nodeMessage.test(message))
|
3140
|
+
return new TipAboveFeeCapError({
|
3141
|
+
cause: err,
|
3142
|
+
maxFeePerGas: args?.maxFeePerGas,
|
3143
|
+
maxPriorityFeePerGas: args?.maxPriorityFeePerGas
|
3144
|
+
});
|
3145
|
+
else if (message.match(ExecutionRevertedError.nodeMessage) || "code" in err.cause && err.cause?.code === ExecutionRevertedError.code)
|
3146
|
+
return new ExecutionRevertedError({
|
3147
|
+
cause: err,
|
3148
|
+
message: err.cause.details
|
3149
|
+
});
|
3150
|
+
return new UnknownNodeError({
|
3151
|
+
cause: err.cause.cause
|
3152
|
+
});
|
3153
|
+
}
|
3154
|
+
|
3155
|
+
// src/utils/errors/getCallError.ts
|
3156
|
+
function getCallError(err, {
|
3157
|
+
docsPath: docsPath5,
|
3158
|
+
...args
|
3159
|
+
}) {
|
3160
|
+
let cause = err;
|
3161
|
+
if (containsNodeError(err))
|
3162
|
+
cause = getNodeError(err, args);
|
3163
|
+
return new CallExecutionError(cause, {
|
3164
|
+
docsPath: docsPath5,
|
3165
|
+
...args
|
3166
|
+
});
|
3167
|
+
}
|
3168
|
+
|
3169
|
+
// src/utils/errors/getContractError.ts
|
3170
|
+
var EXECUTION_REVERTED_ERROR_CODE = 3;
|
3171
|
+
function getContractError(err, {
|
3172
|
+
abi,
|
3173
|
+
address,
|
3174
|
+
args,
|
3175
|
+
docsPath: docsPath5,
|
3176
|
+
functionName,
|
3177
|
+
sender
|
3178
|
+
}) {
|
3179
|
+
const { code, data, message } = err instanceof RawContractError ? err : err instanceof CallExecutionError || err instanceof EstimateGasExecutionError ? err.cause?.cause?.cause || {} : err.cause || {};
|
3180
|
+
let cause = err;
|
3181
|
+
if (err instanceof AbiDecodingZeroDataError) {
|
3182
|
+
cause = new ContractFunctionZeroDataError({ functionName });
|
3183
|
+
} else if (code === EXECUTION_REVERTED_ERROR_CODE && (data || message)) {
|
3184
|
+
cause = new ContractFunctionRevertedError({
|
3185
|
+
abi,
|
3186
|
+
data,
|
3187
|
+
functionName,
|
3188
|
+
message
|
3189
|
+
});
|
3190
|
+
}
|
3191
|
+
return new ContractFunctionExecutionError(cause, {
|
3192
|
+
abi,
|
3193
|
+
args,
|
3194
|
+
contractAddress: address,
|
3195
|
+
docsPath: docsPath5,
|
3196
|
+
functionName,
|
3197
|
+
sender
|
3198
|
+
});
|
3199
|
+
}
|
3200
|
+
|
3201
|
+
// src/utils/errors/getEstimateGasError.ts
|
3202
|
+
function getEstimateGasError(err, {
|
3203
|
+
docsPath: docsPath5,
|
3204
|
+
...args
|
3205
|
+
}) {
|
3206
|
+
let cause = err;
|
3207
|
+
if (containsNodeError(err))
|
3208
|
+
cause = getNodeError(err, args);
|
3209
|
+
return new EstimateGasExecutionError(cause, {
|
3210
|
+
docsPath: docsPath5,
|
3211
|
+
...args
|
3212
|
+
});
|
3213
|
+
}
|
3214
|
+
|
3215
|
+
// src/utils/errors/getTransactionError.ts
|
3216
|
+
function getTransactionError(err, {
|
3217
|
+
docsPath: docsPath5,
|
3218
|
+
...args
|
3219
|
+
}) {
|
3220
|
+
let cause = err;
|
3221
|
+
if (containsNodeError(err))
|
3222
|
+
cause = getNodeError(err, args);
|
3223
|
+
return new TransactionExecutionError(cause, {
|
3224
|
+
docsPath: docsPath5,
|
3225
|
+
...args
|
3226
|
+
});
|
3227
|
+
}
|
3228
|
+
|
2626
3229
|
// src/utils/rpc.ts
|
2627
|
-
import fetch from "isomorphic-unfetch";
|
2628
3230
|
import WebSocket from "isomorphic-ws";
|
2629
3231
|
|
2630
3232
|
// src/utils/stringify.ts
|
2631
|
-
|
2632
|
-
|
2633
|
-
|
2634
|
-
|
2635
|
-
|
2636
|
-
}
|
3233
|
+
var stringify = (value, replacer, space) => JSON.stringify(
|
3234
|
+
value,
|
3235
|
+
(key, value_) => {
|
3236
|
+
const value2 = typeof value_ === "bigint" ? value_.toString() : value_;
|
3237
|
+
return typeof replacer === "function" ? replacer(key, value2) : value2;
|
3238
|
+
},
|
3239
|
+
space
|
3240
|
+
);
|
2637
3241
|
|
2638
3242
|
// src/utils/rpc.ts
|
2639
3243
|
var id = 0;
|
2640
|
-
async function http(url, {
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
timeout = 0
|
2645
|
-
}) {
|
2646
|
-
const response = await withRetry(
|
2647
|
-
() => withTimeout(
|
3244
|
+
async function http(url, { body, fetchOptions = {}, timeout = 1e4 }) {
|
3245
|
+
const { headers, method, signal: signal_ } = fetchOptions;
|
3246
|
+
try {
|
3247
|
+
const response = await withTimeout(
|
2648
3248
|
async ({ signal }) => {
|
2649
3249
|
const response2 = await fetch(url, {
|
3250
|
+
...fetchOptions,
|
3251
|
+
body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
|
2650
3252
|
headers: {
|
3253
|
+
...headers,
|
2651
3254
|
"Content-Type": "application/json"
|
2652
3255
|
},
|
2653
|
-
method: "POST",
|
2654
|
-
|
2655
|
-
signal: timeout > 0 ? signal : void 0
|
3256
|
+
method: method || "POST",
|
3257
|
+
signal: signal_ || (timeout > 0 ? signal : void 0)
|
2656
3258
|
});
|
2657
3259
|
return response2;
|
2658
3260
|
},
|
@@ -2661,42 +3263,39 @@ async function http(url, {
|
|
2661
3263
|
timeout,
|
2662
3264
|
signal: true
|
2663
3265
|
}
|
2664
|
-
)
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2670
|
-
return ~~(1 << count) * retryDelay;
|
2671
|
-
},
|
2672
|
-
retryCount,
|
2673
|
-
shouldRetryOnResponse: async ({ data: data2 }) => {
|
2674
|
-
if (data2.status >= 500)
|
2675
|
-
return true;
|
2676
|
-
if ([408, 413, 429].includes(data2.status))
|
2677
|
-
return true;
|
2678
|
-
return false;
|
2679
|
-
}
|
3266
|
+
);
|
3267
|
+
let data;
|
3268
|
+
if (response.headers.get("Content-Type")?.startsWith("application/json")) {
|
3269
|
+
data = await response.json();
|
3270
|
+
} else {
|
3271
|
+
data = await response.text();
|
2680
3272
|
}
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
3273
|
+
if (!response.ok) {
|
3274
|
+
throw new HttpRequestError({
|
3275
|
+
body,
|
3276
|
+
details: stringify(data.error) || response.statusText,
|
3277
|
+
headers: response.headers,
|
3278
|
+
status: response.status,
|
3279
|
+
url
|
3280
|
+
});
|
3281
|
+
}
|
3282
|
+
if (data.error) {
|
3283
|
+
throw new RpcError({ body, error: data.error, url });
|
3284
|
+
}
|
3285
|
+
return data;
|
3286
|
+
} catch (err) {
|
3287
|
+
if (err instanceof HttpRequestError)
|
3288
|
+
throw err;
|
3289
|
+
if (err instanceof RpcError)
|
3290
|
+
throw err;
|
3291
|
+
if (err instanceof TimeoutError)
|
3292
|
+
throw err;
|
2689
3293
|
throw new HttpRequestError({
|
2690
3294
|
body,
|
2691
|
-
details:
|
2692
|
-
status: response.status,
|
3295
|
+
details: err.message,
|
2693
3296
|
url
|
2694
3297
|
});
|
2695
3298
|
}
|
2696
|
-
if (data.error) {
|
2697
|
-
throw new RpcError({ body, error: data.error, url });
|
2698
|
-
}
|
2699
|
-
return data;
|
2700
3299
|
}
|
2701
3300
|
var sockets = /* @__PURE__ */ new Map();
|
2702
3301
|
async function getSocket(url_) {
|
@@ -2775,7 +3374,7 @@ function webSocket(socket, {
|
|
2775
3374
|
}
|
2776
3375
|
async function webSocketAsync(socket, {
|
2777
3376
|
body,
|
2778
|
-
timeout =
|
3377
|
+
timeout = 1e4
|
2779
3378
|
}) {
|
2780
3379
|
return withTimeout(
|
2781
3380
|
() => new Promise(
|
@@ -2797,47 +3396,1584 @@ var rpc = {
|
|
2797
3396
|
webSocketAsync
|
2798
3397
|
};
|
2799
3398
|
|
2800
|
-
// src/utils/
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
};
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
};
|
3399
|
+
// src/utils/transaction/assertRequest.ts
|
3400
|
+
function assertRequest(args) {
|
3401
|
+
const { account, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to } = args;
|
3402
|
+
if (account && !isAddress(account.address))
|
3403
|
+
throw new InvalidAddressError({ address: account.address });
|
3404
|
+
if (to && !isAddress(to))
|
3405
|
+
throw new InvalidAddressError({ address: to });
|
3406
|
+
if (typeof gasPrice !== "undefined" && (typeof maxFeePerGas !== "undefined" || typeof maxPriorityFeePerGas !== "undefined"))
|
3407
|
+
throw new FeeConflictError();
|
3408
|
+
if (maxFeePerGas && maxFeePerGas > 2n ** 256n - 1n)
|
3409
|
+
throw new FeeCapTooHighError({ maxFeePerGas });
|
3410
|
+
if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
|
3411
|
+
throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
3412
|
+
}
|
3413
|
+
|
3414
|
+
// src/actions/public/call.ts
|
3415
|
+
async function call(client, args) {
|
3416
|
+
const {
|
3417
|
+
account,
|
3418
|
+
blockNumber,
|
3419
|
+
blockTag = "latest",
|
3420
|
+
accessList,
|
3421
|
+
data,
|
3422
|
+
gas,
|
3423
|
+
gasPrice,
|
3424
|
+
maxFeePerGas,
|
3425
|
+
maxPriorityFeePerGas,
|
3426
|
+
nonce,
|
3427
|
+
to,
|
3428
|
+
value,
|
3429
|
+
...rest
|
3430
|
+
} = args;
|
3431
|
+
try {
|
3432
|
+
assertRequest(args);
|
3433
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3434
|
+
const formatter = client.chain?.formatters?.transactionRequest;
|
3435
|
+
const request_ = format3(
|
3436
|
+
{
|
3437
|
+
from: account?.address,
|
3438
|
+
accessList,
|
3439
|
+
data,
|
3440
|
+
gas,
|
3441
|
+
gasPrice,
|
3442
|
+
maxFeePerGas,
|
3443
|
+
maxPriorityFeePerGas,
|
3444
|
+
nonce,
|
3445
|
+
to,
|
3446
|
+
value,
|
3447
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
3448
|
+
...extract(rest, { formatter })
|
3449
|
+
},
|
3450
|
+
{
|
3451
|
+
formatter: formatter || formatTransactionRequest
|
3452
|
+
}
|
3453
|
+
);
|
3454
|
+
const response = await client.request({
|
3455
|
+
method: "eth_call",
|
3456
|
+
params: [request_, blockNumberHex || blockTag]
|
3457
|
+
});
|
3458
|
+
if (response === "0x")
|
3459
|
+
return { data: void 0 };
|
3460
|
+
return { data: response };
|
3461
|
+
} catch (err) {
|
3462
|
+
throw getCallError(err, {
|
3463
|
+
...args,
|
3464
|
+
chain: client.chain
|
3465
|
+
});
|
3466
|
+
}
|
3467
|
+
}
|
3468
|
+
|
3469
|
+
// src/actions/public/simulateContract.ts
|
3470
|
+
async function simulateContract(client, {
|
3471
|
+
abi,
|
3472
|
+
address,
|
3473
|
+
args,
|
3474
|
+
functionName,
|
3475
|
+
...callRequest
|
3476
|
+
}) {
|
3477
|
+
const calldata = encodeFunctionData({
|
3478
|
+
abi,
|
3479
|
+
args,
|
3480
|
+
functionName
|
3481
|
+
});
|
3482
|
+
try {
|
3483
|
+
const { data } = await call(client, {
|
3484
|
+
data: calldata,
|
3485
|
+
to: address,
|
3486
|
+
...callRequest
|
3487
|
+
});
|
3488
|
+
const result = decodeFunctionResult({
|
3489
|
+
abi,
|
3490
|
+
args,
|
3491
|
+
functionName,
|
3492
|
+
data: data || "0x"
|
3493
|
+
});
|
3494
|
+
return {
|
3495
|
+
result,
|
3496
|
+
request: {
|
3497
|
+
abi,
|
3498
|
+
address,
|
3499
|
+
args,
|
3500
|
+
functionName,
|
3501
|
+
...callRequest
|
3502
|
+
}
|
3503
|
+
};
|
3504
|
+
} catch (err) {
|
3505
|
+
throw getContractError(err, {
|
3506
|
+
abi,
|
3507
|
+
address,
|
3508
|
+
args,
|
3509
|
+
docsPath: "/docs/contract/simulateContract",
|
3510
|
+
functionName,
|
3511
|
+
sender: callRequest.account?.address
|
3512
|
+
});
|
3513
|
+
}
|
3514
|
+
}
|
3515
|
+
|
3516
|
+
// src/actions/public/createPendingTransactionFilter.ts
|
3517
|
+
async function createPendingTransactionFilter(client) {
|
3518
|
+
const id2 = await client.request({
|
3519
|
+
method: "eth_newPendingTransactionFilter"
|
3520
|
+
});
|
3521
|
+
return { id: id2, type: "transaction" };
|
3522
|
+
}
|
3523
|
+
|
3524
|
+
// src/actions/public/createBlockFilter.ts
|
3525
|
+
async function createBlockFilter(client) {
|
3526
|
+
const id2 = await client.request({
|
3527
|
+
method: "eth_newBlockFilter"
|
3528
|
+
});
|
3529
|
+
return { id: id2, type: "block" };
|
3530
|
+
}
|
3531
|
+
|
3532
|
+
// src/actions/public/createEventFilter.ts
|
3533
|
+
async function createEventFilter(client, {
|
3534
|
+
address,
|
3535
|
+
args,
|
3536
|
+
event,
|
3537
|
+
fromBlock,
|
3538
|
+
toBlock
|
3539
|
+
} = {}) {
|
3540
|
+
let topics = [];
|
3541
|
+
if (event)
|
3542
|
+
topics = encodeEventTopics({
|
3543
|
+
abi: [event],
|
3544
|
+
eventName: event.name,
|
3545
|
+
args
|
3546
|
+
});
|
3547
|
+
const id2 = await client.request({
|
3548
|
+
method: "eth_newFilter",
|
3549
|
+
params: [
|
3550
|
+
{
|
3551
|
+
address,
|
3552
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
3553
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
3554
|
+
...topics.length ? { topics } : {}
|
3555
|
+
}
|
3556
|
+
]
|
3557
|
+
});
|
3558
|
+
return {
|
3559
|
+
abi: event ? [event] : void 0,
|
3560
|
+
args,
|
3561
|
+
eventName: event ? event.name : void 0,
|
3562
|
+
id: id2,
|
3563
|
+
type: "event"
|
3564
|
+
};
|
3565
|
+
}
|
3566
|
+
|
3567
|
+
// src/actions/public/createContractEventFilter.ts
|
3568
|
+
async function createContractEventFilter(client, {
|
3569
|
+
address,
|
3570
|
+
abi,
|
3571
|
+
args,
|
3572
|
+
eventName,
|
3573
|
+
fromBlock,
|
3574
|
+
toBlock
|
3575
|
+
}) {
|
3576
|
+
const topics = eventName ? encodeEventTopics({
|
3577
|
+
abi,
|
3578
|
+
args,
|
3579
|
+
eventName
|
3580
|
+
}) : void 0;
|
3581
|
+
const id2 = await client.request({
|
3582
|
+
method: "eth_newFilter",
|
3583
|
+
params: [
|
3584
|
+
{
|
3585
|
+
address,
|
3586
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
3587
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock,
|
3588
|
+
topics
|
3589
|
+
}
|
3590
|
+
]
|
3591
|
+
});
|
3592
|
+
return {
|
3593
|
+
abi,
|
3594
|
+
args,
|
3595
|
+
eventName,
|
3596
|
+
id: id2,
|
3597
|
+
type: "event"
|
3598
|
+
};
|
3599
|
+
}
|
3600
|
+
|
3601
|
+
// src/actions/public/estimateGas.ts
|
3602
|
+
async function estimateGas(client, args) {
|
3603
|
+
try {
|
3604
|
+
const {
|
3605
|
+
account,
|
3606
|
+
accessList,
|
3607
|
+
blockNumber,
|
3608
|
+
blockTag = "latest",
|
3609
|
+
data,
|
3610
|
+
gas,
|
3611
|
+
gasPrice,
|
3612
|
+
maxFeePerGas,
|
3613
|
+
maxPriorityFeePerGas,
|
3614
|
+
nonce,
|
3615
|
+
to,
|
3616
|
+
value,
|
3617
|
+
...rest
|
3618
|
+
} = args.account.type === "local" ? await prepareRequest(client, args) : args;
|
3619
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3620
|
+
assertRequest(args);
|
3621
|
+
const formatter = client.chain?.formatters?.transactionRequest;
|
3622
|
+
const request = format3(
|
3623
|
+
{
|
3624
|
+
from: account.address,
|
3625
|
+
accessList,
|
3626
|
+
data,
|
3627
|
+
gas,
|
3628
|
+
gasPrice,
|
3629
|
+
maxFeePerGas,
|
3630
|
+
maxPriorityFeePerGas,
|
3631
|
+
nonce,
|
3632
|
+
to,
|
3633
|
+
value,
|
3634
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
3635
|
+
...extract(rest, { formatter })
|
3636
|
+
},
|
3637
|
+
{
|
3638
|
+
formatter: formatter || formatTransactionRequest
|
3639
|
+
}
|
3640
|
+
);
|
3641
|
+
const balance = await client.request({
|
3642
|
+
method: "eth_estimateGas",
|
3643
|
+
params: [request, blockNumberHex || blockTag]
|
3644
|
+
});
|
3645
|
+
return BigInt(balance);
|
3646
|
+
} catch (err) {
|
3647
|
+
throw getEstimateGasError(err, {
|
3648
|
+
...args,
|
3649
|
+
chain: client.chain
|
3650
|
+
});
|
3651
|
+
}
|
3652
|
+
}
|
3653
|
+
|
3654
|
+
// src/actions/public/estimateContractGas.ts
|
3655
|
+
async function estimateContractGas(client, {
|
3656
|
+
abi,
|
3657
|
+
address,
|
3658
|
+
args,
|
3659
|
+
functionName,
|
3660
|
+
...request
|
3661
|
+
}) {
|
3662
|
+
const data = encodeFunctionData({
|
3663
|
+
abi,
|
3664
|
+
args,
|
3665
|
+
functionName
|
3666
|
+
});
|
3667
|
+
try {
|
3668
|
+
const gas = await estimateGas(client, {
|
3669
|
+
data,
|
3670
|
+
to: address,
|
3671
|
+
...request
|
3672
|
+
});
|
3673
|
+
return gas;
|
3674
|
+
} catch (err) {
|
3675
|
+
throw getContractError(err, {
|
3676
|
+
abi,
|
3677
|
+
address,
|
3678
|
+
args,
|
3679
|
+
docsPath: "/docs/contract/simulateContract",
|
3680
|
+
functionName,
|
3681
|
+
sender: request.account?.address
|
3682
|
+
});
|
3683
|
+
}
|
3684
|
+
}
|
3685
|
+
|
3686
|
+
// src/actions/public/getBalance.ts
|
3687
|
+
async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
|
3688
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3689
|
+
const balance = await client.request({
|
3690
|
+
method: "eth_getBalance",
|
3691
|
+
params: [address, blockNumberHex || blockTag]
|
3692
|
+
});
|
3693
|
+
return BigInt(balance);
|
3694
|
+
}
|
3695
|
+
|
3696
|
+
// src/actions/public/getBlock.ts
|
3697
|
+
async function getBlock(client, {
|
3698
|
+
blockHash,
|
3699
|
+
blockNumber,
|
3700
|
+
blockTag = "latest",
|
3701
|
+
includeTransactions = false
|
3702
|
+
} = {}) {
|
3703
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3704
|
+
let block = null;
|
3705
|
+
if (blockHash) {
|
3706
|
+
block = await client.request({
|
3707
|
+
method: "eth_getBlockByHash",
|
3708
|
+
params: [blockHash, includeTransactions]
|
3709
|
+
});
|
3710
|
+
} else {
|
3711
|
+
block = await client.request({
|
3712
|
+
method: "eth_getBlockByNumber",
|
3713
|
+
params: [blockNumberHex || blockTag, includeTransactions]
|
3714
|
+
});
|
3715
|
+
}
|
3716
|
+
if (!block)
|
3717
|
+
throw new BlockNotFoundError({ blockHash, blockNumber });
|
3718
|
+
return format3(block, {
|
3719
|
+
formatter: client.chain?.formatters?.block || formatBlock
|
3720
|
+
});
|
3721
|
+
}
|
3722
|
+
|
3723
|
+
// src/actions/public/getBlockNumber.ts
|
3724
|
+
var cacheKey = (id2) => `blockNumber.${id2}`;
|
3725
|
+
function getBlockNumberCache(id2) {
|
3726
|
+
return getCache(cacheKey(id2));
|
3727
|
+
}
|
3728
|
+
async function getBlockNumber(client, { maxAge = client.pollingInterval } = {}) {
|
3729
|
+
const blockNumberHex = await withCache(
|
3730
|
+
() => client.request({
|
3731
|
+
method: "eth_blockNumber"
|
3732
|
+
}),
|
3733
|
+
{ cacheKey: cacheKey(client.uid), maxAge }
|
3734
|
+
);
|
3735
|
+
return BigInt(blockNumberHex);
|
3736
|
+
}
|
3737
|
+
|
3738
|
+
// src/actions/public/getBlockTransactionCount.ts
|
3739
|
+
async function getBlockTransactionCount(client, {
|
3740
|
+
blockHash,
|
3741
|
+
blockNumber,
|
3742
|
+
blockTag = "latest"
|
3743
|
+
} = {}) {
|
3744
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3745
|
+
let count = null;
|
3746
|
+
if (blockHash) {
|
3747
|
+
count = await client.request({
|
3748
|
+
method: "eth_getBlockTransactionCountByHash",
|
3749
|
+
params: [blockHash]
|
3750
|
+
});
|
3751
|
+
} else {
|
3752
|
+
count = await client.request({
|
3753
|
+
method: "eth_getBlockTransactionCountByNumber",
|
3754
|
+
params: [blockNumberHex || blockTag]
|
3755
|
+
});
|
3756
|
+
}
|
3757
|
+
return hexToNumber(count);
|
3758
|
+
}
|
3759
|
+
|
3760
|
+
// src/actions/public/getBytecode.ts
|
3761
|
+
async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
|
3762
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3763
|
+
const hex = await client.request({
|
3764
|
+
method: "eth_getCode",
|
3765
|
+
params: [address, blockNumberHex || blockTag]
|
3766
|
+
});
|
3767
|
+
if (hex === "0x")
|
3768
|
+
return void 0;
|
3769
|
+
return hex;
|
3770
|
+
}
|
3771
|
+
|
3772
|
+
// src/actions/public/getChainId.ts
|
3773
|
+
async function getChainId(client) {
|
3774
|
+
const chainIdHex = await client.request({ method: "eth_chainId" });
|
3775
|
+
return hexToNumber(chainIdHex);
|
3776
|
+
}
|
3777
|
+
|
3778
|
+
// src/actions/public/getFeeHistory.ts
|
3779
|
+
async function getFeeHistory(client, {
|
3780
|
+
blockCount,
|
3781
|
+
blockNumber,
|
3782
|
+
blockTag = "latest",
|
3783
|
+
rewardPercentiles
|
3784
|
+
}) {
|
3785
|
+
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
|
3786
|
+
const feeHistory = await client.request({
|
3787
|
+
method: "eth_feeHistory",
|
3788
|
+
params: [
|
3789
|
+
numberToHex(blockCount),
|
3790
|
+
blockNumberHex || blockTag,
|
3791
|
+
rewardPercentiles
|
3792
|
+
]
|
3793
|
+
});
|
3794
|
+
return formatFeeHistory(feeHistory);
|
3795
|
+
}
|
3796
|
+
|
3797
|
+
// src/actions/public/getFilterChanges.ts
|
3798
|
+
async function getFilterChanges(client, {
|
3799
|
+
filter
|
3800
|
+
}) {
|
3801
|
+
const logs = await client.request({
|
3802
|
+
method: "eth_getFilterChanges",
|
3803
|
+
params: [filter.id]
|
3804
|
+
});
|
3805
|
+
return logs.map((log) => {
|
3806
|
+
if (typeof log === "string")
|
3807
|
+
return log;
|
3808
|
+
const { eventName, args } = "abi" in filter && filter.abi ? decodeEventLog({
|
3809
|
+
abi: filter.abi,
|
3810
|
+
data: log.data,
|
3811
|
+
topics: log.topics
|
3812
|
+
}) : { eventName: void 0, args: void 0 };
|
3813
|
+
return formatLog(log, { args, eventName });
|
3814
|
+
});
|
3815
|
+
}
|
3816
|
+
|
3817
|
+
// src/actions/public/getFilterLogs.ts
|
3818
|
+
async function getFilterLogs(client, { filter }) {
|
3819
|
+
const logs = await client.request({
|
3820
|
+
method: "eth_getFilterLogs",
|
3821
|
+
params: [filter.id]
|
3822
|
+
});
|
3823
|
+
return logs.map((log) => {
|
3824
|
+
const { eventName, args } = "abi" in filter && filter.abi ? decodeEventLog({
|
3825
|
+
abi: filter.abi,
|
3826
|
+
data: log.data,
|
3827
|
+
topics: log.topics
|
3828
|
+
}) : { eventName: void 0, args: void 0 };
|
3829
|
+
return formatLog(log, { args, eventName });
|
3830
|
+
});
|
3831
|
+
}
|
3832
|
+
|
3833
|
+
// src/actions/public/getGasPrice.ts
|
3834
|
+
async function getGasPrice(client) {
|
3835
|
+
const gasPrice = await client.request({
|
3836
|
+
method: "eth_gasPrice"
|
3837
|
+
});
|
3838
|
+
return BigInt(gasPrice);
|
3839
|
+
}
|
3840
|
+
|
3841
|
+
// src/actions/public/getLogs.ts
|
3842
|
+
async function getLogs(client, {
|
3843
|
+
address,
|
3844
|
+
blockHash,
|
3845
|
+
fromBlock,
|
3846
|
+
toBlock,
|
3847
|
+
event,
|
3848
|
+
args
|
3849
|
+
} = {}) {
|
3850
|
+
let topics = [];
|
3851
|
+
if (event)
|
3852
|
+
topics = encodeEventTopics({
|
3853
|
+
abi: [event],
|
3854
|
+
eventName: event.name,
|
3855
|
+
args
|
3856
|
+
});
|
3857
|
+
let logs;
|
3858
|
+
if (blockHash) {
|
3859
|
+
logs = await client.request({
|
3860
|
+
method: "eth_getLogs",
|
3861
|
+
params: [{ address, topics, blockHash }]
|
3862
|
+
});
|
3863
|
+
} else {
|
3864
|
+
logs = await client.request({
|
3865
|
+
method: "eth_getLogs",
|
3866
|
+
params: [
|
3867
|
+
{
|
3868
|
+
address,
|
3869
|
+
topics,
|
3870
|
+
fromBlock: typeof fromBlock === "bigint" ? numberToHex(fromBlock) : fromBlock,
|
3871
|
+
toBlock: typeof toBlock === "bigint" ? numberToHex(toBlock) : toBlock
|
3872
|
+
}
|
3873
|
+
]
|
3874
|
+
});
|
3875
|
+
}
|
3876
|
+
return logs.map((log) => {
|
3877
|
+
const { eventName, args: args2 } = event ? decodeEventLog({
|
3878
|
+
abi: [event],
|
3879
|
+
data: log.data,
|
3880
|
+
topics: log.topics
|
3881
|
+
}) : { eventName: void 0, args: void 0 };
|
3882
|
+
return formatLog(log, { args: args2, eventName });
|
3883
|
+
});
|
3884
|
+
}
|
3885
|
+
|
3886
|
+
// src/actions/public/getStorageAt.ts
|
3887
|
+
async function getStorageAt(client, { address, blockNumber, blockTag = "latest", slot }) {
|
3888
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3889
|
+
const data = await client.request({
|
3890
|
+
method: "eth_getStorageAt",
|
3891
|
+
params: [address, slot, blockNumberHex || blockTag]
|
3892
|
+
});
|
3893
|
+
return data;
|
3894
|
+
}
|
3895
|
+
|
3896
|
+
// src/actions/public/getTransaction.ts
|
3897
|
+
async function getTransaction(client, {
|
3898
|
+
blockHash,
|
3899
|
+
blockNumber,
|
3900
|
+
blockTag = "latest",
|
3901
|
+
hash: hash2,
|
3902
|
+
index
|
3903
|
+
}) {
|
3904
|
+
const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
|
3905
|
+
let transaction = null;
|
3906
|
+
if (hash2) {
|
3907
|
+
transaction = await client.request({
|
3908
|
+
method: "eth_getTransactionByHash",
|
3909
|
+
params: [hash2]
|
3910
|
+
});
|
3911
|
+
} else if (blockHash) {
|
3912
|
+
transaction = await client.request({
|
3913
|
+
method: "eth_getTransactionByBlockHashAndIndex",
|
3914
|
+
params: [blockHash, numberToHex(index)]
|
3915
|
+
});
|
3916
|
+
} else if (blockNumberHex || blockTag) {
|
3917
|
+
transaction = await client.request({
|
3918
|
+
method: "eth_getTransactionByBlockNumberAndIndex",
|
3919
|
+
params: [blockNumberHex || blockTag, numberToHex(index)]
|
3920
|
+
});
|
3921
|
+
}
|
3922
|
+
if (!transaction)
|
3923
|
+
throw new TransactionNotFoundError({
|
3924
|
+
blockHash,
|
3925
|
+
blockNumber,
|
3926
|
+
blockTag,
|
3927
|
+
hash: hash2,
|
3928
|
+
index
|
3929
|
+
});
|
3930
|
+
return format3(transaction, {
|
3931
|
+
formatter: client.chain?.formatters?.transaction || formatTransaction
|
3932
|
+
});
|
3933
|
+
}
|
3934
|
+
|
3935
|
+
// src/actions/public/getTransactionConfirmations.ts
|
3936
|
+
async function getTransactionConfirmations(client, { hash: hash2, transactionReceipt }) {
|
3937
|
+
const [blockNumber, transaction] = await Promise.all([
|
3938
|
+
getBlockNumber(client),
|
3939
|
+
hash2 ? getTransaction(client, { hash: hash2 }) : void 0
|
3940
|
+
]);
|
3941
|
+
const transactionBlockNumber = transactionReceipt?.blockNumber || transaction?.blockNumber;
|
3942
|
+
if (!transactionBlockNumber)
|
3943
|
+
return 0n;
|
3944
|
+
return blockNumber - transactionBlockNumber + 1n;
|
3945
|
+
}
|
3946
|
+
|
3947
|
+
// src/actions/public/getTransactionCount.ts
|
3948
|
+
async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
|
3949
|
+
const count = await client.request({
|
3950
|
+
method: "eth_getTransactionCount",
|
3951
|
+
params: [address, blockNumber ? numberToHex(blockNumber) : blockTag]
|
3952
|
+
});
|
3953
|
+
return hexToNumber(count);
|
3954
|
+
}
|
3955
|
+
|
3956
|
+
// src/actions/public/getTransactionReceipt.ts
|
3957
|
+
async function getTransactionReceipt(client, { hash: hash2 }) {
|
3958
|
+
const receipt = await client.request({
|
3959
|
+
method: "eth_getTransactionReceipt",
|
3960
|
+
params: [hash2]
|
3961
|
+
});
|
3962
|
+
if (!receipt)
|
3963
|
+
throw new TransactionReceiptNotFoundError({ hash: hash2 });
|
3964
|
+
return format3(receipt, {
|
3965
|
+
formatter: client.chain?.formatters?.transactionReceipt || formatTransactionReceipt
|
3966
|
+
});
|
3967
|
+
}
|
3968
|
+
|
3969
|
+
// src/actions/public/readContract.ts
|
3970
|
+
async function readContract(client, {
|
3971
|
+
abi,
|
3972
|
+
address,
|
3973
|
+
args,
|
3974
|
+
functionName,
|
3975
|
+
...callRequest
|
3976
|
+
}) {
|
3977
|
+
const calldata = encodeFunctionData({
|
3978
|
+
abi,
|
3979
|
+
args,
|
3980
|
+
functionName
|
3981
|
+
});
|
3982
|
+
try {
|
3983
|
+
const { data } = await call(client, {
|
3984
|
+
data: calldata,
|
3985
|
+
to: address,
|
3986
|
+
...callRequest
|
3987
|
+
});
|
3988
|
+
return decodeFunctionResult({
|
3989
|
+
abi,
|
3990
|
+
args,
|
3991
|
+
functionName,
|
3992
|
+
data: data || "0x"
|
3993
|
+
});
|
3994
|
+
} catch (err) {
|
3995
|
+
throw getContractError(err, {
|
3996
|
+
abi,
|
3997
|
+
address,
|
3998
|
+
args,
|
3999
|
+
docsPath: "/docs/contract/readContract",
|
4000
|
+
functionName
|
4001
|
+
});
|
4002
|
+
}
|
4003
|
+
}
|
4004
|
+
|
4005
|
+
// src/actions/public/multicall.ts
|
4006
|
+
async function multicall(client, args) {
|
4007
|
+
const {
|
4008
|
+
allowFailure = true,
|
4009
|
+
blockNumber,
|
4010
|
+
blockTag,
|
4011
|
+
contracts,
|
4012
|
+
multicallAddress
|
4013
|
+
} = args;
|
4014
|
+
const calls = contracts.map(({ abi, address, args: args2, functionName }) => {
|
4015
|
+
try {
|
4016
|
+
const callData = encodeFunctionData({
|
4017
|
+
abi,
|
4018
|
+
args: args2,
|
4019
|
+
functionName
|
4020
|
+
});
|
4021
|
+
return {
|
4022
|
+
allowFailure: true,
|
4023
|
+
callData,
|
4024
|
+
target: address
|
4025
|
+
};
|
4026
|
+
} catch (err) {
|
4027
|
+
const error = getContractError(err, {
|
4028
|
+
abi,
|
4029
|
+
address,
|
4030
|
+
args: args2,
|
4031
|
+
docsPath: "/docs/contract/multicall",
|
4032
|
+
functionName
|
4033
|
+
});
|
4034
|
+
if (!allowFailure)
|
4035
|
+
throw error;
|
4036
|
+
return {
|
4037
|
+
allowFailure: true,
|
4038
|
+
callData: "0x",
|
4039
|
+
target: address
|
4040
|
+
};
|
4041
|
+
}
|
4042
|
+
});
|
4043
|
+
const results = await readContract(client, {
|
4044
|
+
abi: multicall3Abi,
|
4045
|
+
address: multicallAddress,
|
4046
|
+
args: [calls],
|
4047
|
+
blockNumber,
|
4048
|
+
blockTag,
|
4049
|
+
functionName: "aggregate3"
|
4050
|
+
});
|
4051
|
+
return results.map(({ returnData, success }, i) => {
|
4052
|
+
const { callData } = calls[i];
|
4053
|
+
const { abi, address, functionName, args: args2 } = contracts[i];
|
4054
|
+
try {
|
4055
|
+
if (callData === "0x")
|
4056
|
+
throw new AbiDecodingZeroDataError();
|
4057
|
+
if (!success)
|
4058
|
+
throw new RawContractError({ data: returnData });
|
4059
|
+
const result = decodeFunctionResult({
|
4060
|
+
abi,
|
4061
|
+
data: returnData,
|
4062
|
+
functionName
|
4063
|
+
});
|
4064
|
+
return { result, status: "success" };
|
4065
|
+
} catch (err) {
|
4066
|
+
const error = getContractError(err, {
|
4067
|
+
abi,
|
4068
|
+
address,
|
4069
|
+
args: args2,
|
4070
|
+
docsPath: "/docs/contract/multicall",
|
4071
|
+
functionName
|
4072
|
+
});
|
4073
|
+
if (!allowFailure)
|
4074
|
+
throw error;
|
4075
|
+
return { error, result: void 0, status: "failure" };
|
4076
|
+
}
|
4077
|
+
});
|
4078
|
+
}
|
4079
|
+
|
4080
|
+
// src/actions/public/uninstallFilter.ts
|
4081
|
+
async function uninstallFilter(client, { filter }) {
|
4082
|
+
return client.request({
|
4083
|
+
method: "eth_uninstallFilter",
|
4084
|
+
params: [filter.id]
|
4085
|
+
});
|
4086
|
+
}
|
4087
|
+
|
4088
|
+
// src/utils/observe.ts
|
4089
|
+
var listenersCache = /* @__PURE__ */ new Map();
|
4090
|
+
var cleanupCache = /* @__PURE__ */ new Map();
|
4091
|
+
var callbackCount = 0;
|
4092
|
+
function observe(observerId, callbacks, fn) {
|
4093
|
+
const callbackId = ++callbackCount;
|
4094
|
+
const getListeners = () => listenersCache.get(observerId) || [];
|
4095
|
+
const unsubscribe = () => {
|
4096
|
+
const listeners2 = getListeners();
|
4097
|
+
listenersCache.set(
|
4098
|
+
observerId,
|
4099
|
+
listeners2.filter((cb) => cb.id !== callbackId)
|
4100
|
+
);
|
4101
|
+
};
|
4102
|
+
const unwatch = () => {
|
4103
|
+
const cleanup2 = cleanupCache.get(observerId);
|
4104
|
+
if (getListeners().length === 1 && cleanup2)
|
4105
|
+
cleanup2();
|
4106
|
+
unsubscribe();
|
4107
|
+
};
|
4108
|
+
const listeners = getListeners();
|
4109
|
+
listenersCache.set(observerId, [
|
4110
|
+
...listeners,
|
4111
|
+
{ id: callbackId, fns: callbacks }
|
4112
|
+
]);
|
4113
|
+
if (listeners && listeners.length > 0)
|
4114
|
+
return unwatch;
|
4115
|
+
let emit = {};
|
4116
|
+
for (const key in callbacks) {
|
4117
|
+
emit[key] = (...args) => {
|
4118
|
+
const listeners2 = getListeners();
|
4119
|
+
if (listeners2.length === 0)
|
4120
|
+
return;
|
4121
|
+
listeners2.forEach((listener) => listener.fns[key]?.(...args));
|
4122
|
+
};
|
4123
|
+
}
|
4124
|
+
const cleanup = fn(emit);
|
4125
|
+
if (typeof cleanup === "function")
|
4126
|
+
cleanupCache.set(observerId, cleanup);
|
4127
|
+
return unwatch;
|
4128
|
+
}
|
4129
|
+
|
4130
|
+
// src/actions/public/waitForTransactionReceipt.ts
|
4131
|
+
async function waitForTransactionReceipt(client, {
|
4132
|
+
confirmations = 1,
|
4133
|
+
hash: hash2,
|
4134
|
+
onReplaced,
|
4135
|
+
pollingInterval = client.pollingInterval,
|
4136
|
+
timeout
|
4137
|
+
}) {
|
4138
|
+
const observerId = JSON.stringify([
|
4139
|
+
"waitForTransactionReceipt",
|
4140
|
+
client.uid,
|
4141
|
+
hash2
|
4142
|
+
]);
|
4143
|
+
let transaction;
|
4144
|
+
let replacedTransaction;
|
4145
|
+
let receipt;
|
4146
|
+
return new Promise((resolve, reject) => {
|
4147
|
+
if (timeout)
|
4148
|
+
setTimeout(
|
4149
|
+
() => reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 })),
|
4150
|
+
timeout
|
4151
|
+
);
|
4152
|
+
const _unobserve = observe(
|
4153
|
+
observerId,
|
4154
|
+
{ onReplaced, resolve, reject },
|
4155
|
+
(emit) => {
|
4156
|
+
const unwatch = watchBlockNumber(client, {
|
4157
|
+
emitMissed: true,
|
4158
|
+
emitOnBegin: true,
|
4159
|
+
pollingInterval,
|
4160
|
+
async onBlockNumber(blockNumber) {
|
4161
|
+
const done = async (fn) => {
|
4162
|
+
unwatch();
|
4163
|
+
fn();
|
4164
|
+
_unobserve();
|
4165
|
+
};
|
4166
|
+
try {
|
4167
|
+
if (receipt) {
|
4168
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
4169
|
+
return;
|
4170
|
+
done(() => emit.resolve(receipt));
|
4171
|
+
return;
|
4172
|
+
}
|
4173
|
+
transaction = await getTransaction(client, { hash: hash2 });
|
4174
|
+
receipt = await getTransactionReceipt(client, { hash: hash2 });
|
4175
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
4176
|
+
return;
|
4177
|
+
done(() => emit.resolve(receipt));
|
4178
|
+
} catch (err) {
|
4179
|
+
if (transaction && (err instanceof TransactionNotFoundError || err instanceof TransactionReceiptNotFoundError)) {
|
4180
|
+
replacedTransaction = transaction;
|
4181
|
+
const block = await getBlock(client, {
|
4182
|
+
blockNumber,
|
4183
|
+
includeTransactions: true
|
4184
|
+
});
|
4185
|
+
const replacementTransaction = block.transactions.find(
|
4186
|
+
({ from, nonce }) => from === replacedTransaction.from && nonce === replacedTransaction.nonce
|
4187
|
+
);
|
4188
|
+
if (!replacementTransaction)
|
4189
|
+
return;
|
4190
|
+
receipt = await getTransactionReceipt(client, {
|
4191
|
+
hash: replacementTransaction.hash
|
4192
|
+
});
|
4193
|
+
if (blockNumber - receipt.blockNumber + 1n < confirmations)
|
4194
|
+
return;
|
4195
|
+
let reason = "replaced";
|
4196
|
+
if (replacementTransaction.to === replacedTransaction.to && replacementTransaction.value === replacedTransaction.value) {
|
4197
|
+
reason = "repriced";
|
4198
|
+
} else if (replacementTransaction.from === replacementTransaction.to && replacementTransaction.value === 0n) {
|
4199
|
+
reason = "cancelled";
|
4200
|
+
}
|
4201
|
+
done(() => {
|
4202
|
+
emit.onReplaced?.({
|
4203
|
+
reason,
|
4204
|
+
replacedTransaction,
|
4205
|
+
transaction: replacementTransaction,
|
4206
|
+
transactionReceipt: receipt
|
4207
|
+
});
|
4208
|
+
emit.resolve(receipt);
|
4209
|
+
});
|
4210
|
+
} else {
|
4211
|
+
done(() => emit.reject(err));
|
4212
|
+
}
|
4213
|
+
}
|
4214
|
+
}
|
4215
|
+
});
|
4216
|
+
return unwatch;
|
4217
|
+
}
|
4218
|
+
);
|
4219
|
+
});
|
4220
|
+
}
|
4221
|
+
|
4222
|
+
// src/utils/poll.ts
|
4223
|
+
function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
|
4224
|
+
let active = true;
|
4225
|
+
const unwatch = () => active = false;
|
4226
|
+
const watch = async () => {
|
4227
|
+
let data;
|
4228
|
+
if (emitOnBegin)
|
4229
|
+
data = await fn({ unpoll: unwatch });
|
4230
|
+
const initialWait = await initialWaitTime?.(data) ?? interval;
|
4231
|
+
await wait(initialWait);
|
4232
|
+
const poll2 = async () => {
|
4233
|
+
if (!active)
|
4234
|
+
return;
|
4235
|
+
await fn({ unpoll: unwatch });
|
4236
|
+
await wait(interval);
|
4237
|
+
poll2();
|
4238
|
+
};
|
4239
|
+
poll2();
|
4240
|
+
};
|
4241
|
+
watch();
|
4242
|
+
return unwatch;
|
4243
|
+
}
|
4244
|
+
|
4245
|
+
// src/actions/public/watchBlockNumber.ts
|
4246
|
+
function watchBlockNumber(client, {
|
4247
|
+
emitOnBegin = false,
|
4248
|
+
emitMissed = false,
|
4249
|
+
onBlockNumber,
|
4250
|
+
onError,
|
4251
|
+
pollingInterval = client.pollingInterval
|
4252
|
+
}) {
|
4253
|
+
const observerId = JSON.stringify([
|
4254
|
+
"watchBlockNumber",
|
4255
|
+
client.uid,
|
4256
|
+
emitOnBegin,
|
4257
|
+
emitMissed,
|
4258
|
+
pollingInterval
|
4259
|
+
]);
|
4260
|
+
let prevBlockNumber;
|
4261
|
+
return observe(
|
4262
|
+
observerId,
|
4263
|
+
{ onBlockNumber, onError },
|
4264
|
+
(emit) => poll(
|
4265
|
+
async () => {
|
4266
|
+
try {
|
4267
|
+
const blockNumber = await getBlockNumber(client, { maxAge: 0 });
|
4268
|
+
if (prevBlockNumber) {
|
4269
|
+
if (blockNumber === prevBlockNumber)
|
4270
|
+
return;
|
4271
|
+
if (blockNumber - prevBlockNumber > 1 && emitMissed) {
|
4272
|
+
for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {
|
4273
|
+
emit.onBlockNumber(i, prevBlockNumber);
|
4274
|
+
prevBlockNumber = i;
|
4275
|
+
}
|
4276
|
+
}
|
4277
|
+
}
|
4278
|
+
prevBlockNumber = blockNumber;
|
4279
|
+
emit.onBlockNumber(blockNumber, prevBlockNumber);
|
4280
|
+
} catch (err) {
|
4281
|
+
emit.onError?.(err);
|
4282
|
+
}
|
4283
|
+
},
|
4284
|
+
{
|
4285
|
+
emitOnBegin,
|
4286
|
+
interval: pollingInterval
|
4287
|
+
}
|
4288
|
+
)
|
4289
|
+
);
|
4290
|
+
}
|
4291
|
+
|
4292
|
+
// src/actions/public/watchBlocks.ts
|
4293
|
+
function watchBlocks(client, {
|
4294
|
+
blockTag = "latest",
|
4295
|
+
emitMissed = false,
|
4296
|
+
emitOnBegin = false,
|
4297
|
+
onBlock,
|
4298
|
+
onError,
|
4299
|
+
includeTransactions = false,
|
4300
|
+
pollingInterval = client.pollingInterval
|
4301
|
+
}) {
|
4302
|
+
const observerId = JSON.stringify([
|
4303
|
+
"watchBlocks",
|
4304
|
+
client.uid,
|
4305
|
+
emitMissed,
|
4306
|
+
emitOnBegin,
|
4307
|
+
includeTransactions,
|
4308
|
+
pollingInterval
|
4309
|
+
]);
|
4310
|
+
let prevBlock;
|
4311
|
+
return observe(
|
4312
|
+
observerId,
|
4313
|
+
{ onBlock, onError },
|
4314
|
+
(emit) => poll(
|
4315
|
+
async () => {
|
4316
|
+
try {
|
4317
|
+
const block = await getBlock(client, {
|
4318
|
+
blockTag,
|
4319
|
+
includeTransactions
|
4320
|
+
});
|
4321
|
+
if (block.number && prevBlock?.number) {
|
4322
|
+
if (block.number === prevBlock.number)
|
4323
|
+
return;
|
4324
|
+
if (block.number - prevBlock.number > 1 && emitMissed) {
|
4325
|
+
for (let i = prevBlock?.number + 1n; i < block.number; i++) {
|
4326
|
+
const block2 = await getBlock(client, {
|
4327
|
+
blockNumber: i,
|
4328
|
+
includeTransactions
|
4329
|
+
});
|
4330
|
+
emit.onBlock(block2, prevBlock);
|
4331
|
+
prevBlock = block2;
|
4332
|
+
}
|
4333
|
+
}
|
4334
|
+
}
|
4335
|
+
emit.onBlock(block, prevBlock);
|
4336
|
+
prevBlock = block;
|
4337
|
+
} catch (err) {
|
4338
|
+
emit.onError?.(err);
|
4339
|
+
}
|
4340
|
+
},
|
4341
|
+
{
|
4342
|
+
emitOnBegin,
|
4343
|
+
interval: pollingInterval
|
4344
|
+
}
|
4345
|
+
)
|
4346
|
+
);
|
4347
|
+
}
|
4348
|
+
|
4349
|
+
// src/actions/public/watchContractEvent.ts
|
4350
|
+
function watchContractEvent(client, {
|
4351
|
+
abi,
|
4352
|
+
address,
|
4353
|
+
args,
|
4354
|
+
batch = true,
|
4355
|
+
eventName,
|
4356
|
+
onError,
|
4357
|
+
onLogs,
|
4358
|
+
pollingInterval = client.pollingInterval
|
4359
|
+
}) {
|
4360
|
+
const observerId = JSON.stringify([
|
4361
|
+
"watchContractEvent",
|
4362
|
+
address,
|
4363
|
+
args,
|
4364
|
+
batch,
|
4365
|
+
client.uid,
|
4366
|
+
eventName,
|
4367
|
+
pollingInterval
|
4368
|
+
]);
|
4369
|
+
return observe(observerId, { onLogs, onError }, (emit) => {
|
4370
|
+
let currentBlockNumber;
|
4371
|
+
let filter;
|
4372
|
+
let initialized = false;
|
4373
|
+
const unwatch = poll(
|
4374
|
+
async () => {
|
4375
|
+
if (!initialized) {
|
4376
|
+
try {
|
4377
|
+
filter = await createContractEventFilter(client, {
|
4378
|
+
abi,
|
4379
|
+
address,
|
4380
|
+
args,
|
4381
|
+
eventName
|
4382
|
+
});
|
4383
|
+
} catch {
|
4384
|
+
}
|
4385
|
+
initialized = true;
|
4386
|
+
return;
|
4387
|
+
}
|
4388
|
+
try {
|
4389
|
+
let logs;
|
4390
|
+
if (filter) {
|
4391
|
+
logs = await getFilterChanges(client, { filter });
|
4392
|
+
} else {
|
4393
|
+
const blockNumber = await getBlockNumber(client);
|
4394
|
+
if (currentBlockNumber && currentBlockNumber !== blockNumber) {
|
4395
|
+
logs = await getLogs(client, {
|
4396
|
+
address,
|
4397
|
+
args,
|
4398
|
+
fromBlock: blockNumber,
|
4399
|
+
toBlock: blockNumber,
|
4400
|
+
event: getAbiItem({
|
4401
|
+
abi,
|
4402
|
+
name: eventName
|
4403
|
+
})
|
4404
|
+
});
|
4405
|
+
} else {
|
4406
|
+
logs = [];
|
4407
|
+
}
|
4408
|
+
currentBlockNumber = blockNumber;
|
4409
|
+
}
|
4410
|
+
if (logs.length === 0)
|
4411
|
+
return;
|
4412
|
+
if (batch)
|
4413
|
+
emit.onLogs(logs);
|
4414
|
+
else
|
4415
|
+
logs.forEach((log) => emit.onLogs([log]));
|
4416
|
+
} catch (err) {
|
4417
|
+
emit.onError?.(err);
|
4418
|
+
}
|
4419
|
+
},
|
4420
|
+
{
|
4421
|
+
emitOnBegin: true,
|
4422
|
+
interval: pollingInterval
|
4423
|
+
}
|
4424
|
+
);
|
4425
|
+
return async () => {
|
4426
|
+
if (filter)
|
4427
|
+
await uninstallFilter(client, { filter });
|
4428
|
+
unwatch();
|
4429
|
+
};
|
4430
|
+
});
|
4431
|
+
}
|
4432
|
+
|
4433
|
+
// src/actions/public/watchEvent.ts
|
4434
|
+
function watchEvent(client, {
|
4435
|
+
address,
|
4436
|
+
args,
|
4437
|
+
batch = true,
|
4438
|
+
event,
|
4439
|
+
onError,
|
4440
|
+
onLogs,
|
4441
|
+
pollingInterval = client.pollingInterval
|
4442
|
+
}) {
|
4443
|
+
const observerId = JSON.stringify([
|
4444
|
+
"watchEvent",
|
4445
|
+
address,
|
4446
|
+
args,
|
4447
|
+
batch,
|
4448
|
+
client.uid,
|
4449
|
+
event,
|
4450
|
+
pollingInterval
|
4451
|
+
]);
|
4452
|
+
return observe(observerId, { onLogs, onError }, (emit) => {
|
4453
|
+
let currentBlockNumber;
|
4454
|
+
let filter;
|
4455
|
+
let initialized = false;
|
4456
|
+
const unwatch = poll(
|
4457
|
+
async () => {
|
4458
|
+
if (!initialized) {
|
4459
|
+
try {
|
4460
|
+
filter = await createEventFilter(client, {
|
4461
|
+
address,
|
4462
|
+
args,
|
4463
|
+
event
|
4464
|
+
});
|
4465
|
+
} catch {
|
4466
|
+
}
|
4467
|
+
initialized = true;
|
4468
|
+
return;
|
4469
|
+
}
|
4470
|
+
try {
|
4471
|
+
let logs;
|
4472
|
+
if (filter) {
|
4473
|
+
logs = await getFilterChanges(client, { filter });
|
4474
|
+
} else {
|
4475
|
+
const blockNumber = await getBlockNumber(client);
|
4476
|
+
if (currentBlockNumber && currentBlockNumber !== blockNumber) {
|
4477
|
+
logs = await getLogs(client, {
|
4478
|
+
address,
|
4479
|
+
args,
|
4480
|
+
fromBlock: blockNumber,
|
4481
|
+
toBlock: blockNumber,
|
4482
|
+
event
|
4483
|
+
});
|
4484
|
+
} else {
|
4485
|
+
logs = [];
|
4486
|
+
}
|
4487
|
+
currentBlockNumber = blockNumber;
|
4488
|
+
}
|
4489
|
+
if (logs.length === 0)
|
4490
|
+
return;
|
4491
|
+
if (batch)
|
4492
|
+
emit.onLogs(logs);
|
4493
|
+
else
|
4494
|
+
logs.forEach((log) => emit.onLogs([log]));
|
4495
|
+
} catch (err) {
|
4496
|
+
emit.onError?.(err);
|
4497
|
+
}
|
4498
|
+
},
|
4499
|
+
{
|
4500
|
+
emitOnBegin: true,
|
4501
|
+
interval: pollingInterval
|
4502
|
+
}
|
4503
|
+
);
|
4504
|
+
return async () => {
|
4505
|
+
if (filter)
|
4506
|
+
await uninstallFilter(client, { filter });
|
4507
|
+
unwatch();
|
4508
|
+
};
|
4509
|
+
});
|
4510
|
+
}
|
4511
|
+
|
4512
|
+
// src/actions/public/watchPendingTransactions.ts
|
4513
|
+
function watchPendingTransactions(client, {
|
4514
|
+
batch = true,
|
4515
|
+
onError,
|
4516
|
+
onTransactions,
|
4517
|
+
pollingInterval = client.pollingInterval
|
4518
|
+
}) {
|
4519
|
+
const observerId = JSON.stringify([
|
4520
|
+
"watchPendingTransactions",
|
4521
|
+
client.uid,
|
4522
|
+
batch,
|
4523
|
+
pollingInterval
|
4524
|
+
]);
|
4525
|
+
return observe(observerId, { onTransactions, onError }, (emit) => {
|
4526
|
+
let filter;
|
4527
|
+
const unwatch = poll(
|
4528
|
+
async () => {
|
4529
|
+
try {
|
4530
|
+
if (!filter) {
|
4531
|
+
try {
|
4532
|
+
filter = await createPendingTransactionFilter(client);
|
4533
|
+
return;
|
4534
|
+
} catch (err) {
|
4535
|
+
unwatch();
|
4536
|
+
throw err;
|
4537
|
+
}
|
4538
|
+
}
|
4539
|
+
const hashes = await getFilterChanges(client, { filter });
|
4540
|
+
if (hashes.length === 0)
|
4541
|
+
return;
|
4542
|
+
if (batch)
|
4543
|
+
emit.onTransactions(hashes);
|
4544
|
+
else
|
4545
|
+
hashes.forEach((hash2) => emit.onTransactions([hash2]));
|
4546
|
+
} catch (err) {
|
4547
|
+
emit.onError?.(err);
|
4548
|
+
}
|
4549
|
+
},
|
4550
|
+
{
|
4551
|
+
emitOnBegin: true,
|
4552
|
+
interval: pollingInterval
|
4553
|
+
}
|
4554
|
+
);
|
4555
|
+
return async () => {
|
4556
|
+
if (filter)
|
4557
|
+
await uninstallFilter(client, { filter });
|
4558
|
+
unwatch();
|
4559
|
+
};
|
4560
|
+
});
|
4561
|
+
}
|
4562
|
+
|
4563
|
+
// src/actions/test/dropTransaction.ts
|
4564
|
+
async function dropTransaction(client, { hash: hash2 }) {
|
4565
|
+
return await client.request({
|
4566
|
+
method: `${client.mode}_dropTransaction`,
|
4567
|
+
params: [hash2]
|
4568
|
+
});
|
4569
|
+
}
|
4570
|
+
|
4571
|
+
// src/actions/test/getAutomine.ts
|
4572
|
+
async function getAutomine(client) {
|
4573
|
+
return await client.request({
|
4574
|
+
method: `${client.mode}_getAutomine`
|
4575
|
+
});
|
4576
|
+
}
|
4577
|
+
|
4578
|
+
// src/actions/test/getTxpoolContent.ts
|
4579
|
+
async function getTxpoolContent(client) {
|
4580
|
+
return await client.request({
|
4581
|
+
method: "txpool_content"
|
4582
|
+
});
|
4583
|
+
}
|
4584
|
+
|
4585
|
+
// src/actions/test/getTxpoolStatus.ts
|
4586
|
+
async function getTxpoolStatus(client) {
|
4587
|
+
const { pending, queued } = await client.request({
|
4588
|
+
method: "txpool_status"
|
4589
|
+
});
|
4590
|
+
return {
|
4591
|
+
pending: hexToNumber(pending),
|
4592
|
+
queued: hexToNumber(queued)
|
4593
|
+
};
|
4594
|
+
}
|
4595
|
+
|
4596
|
+
// src/actions/test/impersonateAccount.ts
|
4597
|
+
async function impersonateAccount(client, { address }) {
|
4598
|
+
return await client.request({
|
4599
|
+
method: `${client.mode}_impersonateAccount`,
|
4600
|
+
params: [address]
|
4601
|
+
});
|
4602
|
+
}
|
2813
4603
|
|
2814
|
-
// src/
|
2815
|
-
function
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
let [integer, fraction] = [
|
2821
|
-
display.slice(0, display.length - decimals),
|
2822
|
-
display.slice(display.length - decimals)
|
2823
|
-
];
|
2824
|
-
fraction = fraction.padStart(decimals, "0");
|
2825
|
-
fraction = fraction.replace(/(0+)$/, "");
|
2826
|
-
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
4604
|
+
// src/actions/test/increaseTime.ts
|
4605
|
+
async function increaseTime(client, { seconds }) {
|
4606
|
+
return await client.request({
|
4607
|
+
method: "evm_increaseTime",
|
4608
|
+
params: [numberToHex(seconds)]
|
4609
|
+
});
|
2827
4610
|
}
|
2828
4611
|
|
2829
|
-
// src/
|
2830
|
-
function
|
2831
|
-
return
|
4612
|
+
// src/actions/test/inspectTxpool.ts
|
4613
|
+
async function inspectTxpool(client) {
|
4614
|
+
return await client.request({
|
4615
|
+
method: "txpool_inspect"
|
4616
|
+
});
|
2832
4617
|
}
|
2833
4618
|
|
2834
|
-
// src/
|
2835
|
-
function
|
2836
|
-
return
|
4619
|
+
// src/actions/test/mine.ts
|
4620
|
+
async function mine(client, { blocks, interval }) {
|
4621
|
+
return await client.request({
|
4622
|
+
method: `${client.mode}_mine`,
|
4623
|
+
params: [numberToHex(blocks), numberToHex(interval || 0)]
|
4624
|
+
});
|
4625
|
+
}
|
4626
|
+
|
4627
|
+
// src/actions/test/removeBlockTimestampInterval.ts
|
4628
|
+
async function removeBlockTimestampInterval(client) {
|
4629
|
+
return await client.request({
|
4630
|
+
method: `${client.mode}_removeBlockTimestampInterval`
|
4631
|
+
});
|
4632
|
+
}
|
4633
|
+
|
4634
|
+
// src/actions/test/reset.ts
|
4635
|
+
async function reset(client, { blockNumber, jsonRpcUrl } = {}) {
|
4636
|
+
return await client.request({
|
4637
|
+
method: `${client.mode}_reset`,
|
4638
|
+
params: [{ forking: { blockNumber: Number(blockNumber), jsonRpcUrl } }]
|
4639
|
+
});
|
4640
|
+
}
|
4641
|
+
|
4642
|
+
// src/actions/test/revert.ts
|
4643
|
+
async function revert(client, { id: id2 }) {
|
4644
|
+
return await client.request({
|
4645
|
+
method: "evm_revert",
|
4646
|
+
params: [id2]
|
4647
|
+
});
|
4648
|
+
}
|
4649
|
+
|
4650
|
+
// src/actions/test/sendUnsignedTransaction.ts
|
4651
|
+
async function sendUnsignedTransaction(client, request) {
|
4652
|
+
const request_ = formatTransactionRequest(request);
|
4653
|
+
const hash2 = await client.request({
|
4654
|
+
method: "eth_sendUnsignedTransaction",
|
4655
|
+
params: [request_]
|
4656
|
+
});
|
4657
|
+
return hash2;
|
4658
|
+
}
|
4659
|
+
|
4660
|
+
// src/actions/test/setAutomine.ts
|
4661
|
+
async function setAutomine(client, enabled) {
|
4662
|
+
return await client.request({
|
4663
|
+
method: "evm_setAutomine",
|
4664
|
+
params: [enabled]
|
4665
|
+
});
|
4666
|
+
}
|
4667
|
+
|
4668
|
+
// src/actions/test/setBalance.ts
|
4669
|
+
async function setBalance(client, { address, value }) {
|
4670
|
+
return await client.request({
|
4671
|
+
method: `${client.mode}_setBalance`,
|
4672
|
+
params: [address, numberToHex(value)]
|
4673
|
+
});
|
4674
|
+
}
|
4675
|
+
|
4676
|
+
// src/actions/test/setBlockGasLimit.ts
|
4677
|
+
async function setBlockGasLimit(client, { gasLimit }) {
|
4678
|
+
return await client.request({
|
4679
|
+
method: "evm_setBlockGasLimit",
|
4680
|
+
params: [numberToHex(gasLimit)]
|
4681
|
+
});
|
4682
|
+
}
|
4683
|
+
|
4684
|
+
// src/actions/test/setBlockTimestampInterval.ts
|
4685
|
+
async function setBlockTimestampInterval(client, { interval }) {
|
4686
|
+
return await client.request({
|
4687
|
+
method: `${client.mode}_setBlockTimestampInterval`,
|
4688
|
+
params: [interval]
|
4689
|
+
});
|
4690
|
+
}
|
4691
|
+
|
4692
|
+
// src/actions/test/setCode.ts
|
4693
|
+
async function setCode(client, { address, bytecode }) {
|
4694
|
+
return await client.request({
|
4695
|
+
method: `${client.mode}_setCode`,
|
4696
|
+
params: [address, bytecode]
|
4697
|
+
});
|
4698
|
+
}
|
4699
|
+
|
4700
|
+
// src/actions/test/setCoinbase.ts
|
4701
|
+
async function setCoinbase(client, { address }) {
|
4702
|
+
return await client.request({
|
4703
|
+
method: `${client.mode}_setCoinbase`,
|
4704
|
+
params: [address]
|
4705
|
+
});
|
4706
|
+
}
|
4707
|
+
|
4708
|
+
// src/actions/test/setIntervalMining.ts
|
4709
|
+
async function setIntervalMining(client, { interval }) {
|
4710
|
+
return await client.request({
|
4711
|
+
method: "evm_setIntervalMining",
|
4712
|
+
params: [interval]
|
4713
|
+
});
|
4714
|
+
}
|
4715
|
+
|
4716
|
+
// src/actions/test/setLoggingEnabled.ts
|
4717
|
+
async function setLoggingEnabled(client, enabled) {
|
4718
|
+
return await client.request({
|
4719
|
+
method: `${client.mode}_setLoggingEnabled`,
|
4720
|
+
params: [enabled]
|
4721
|
+
});
|
4722
|
+
}
|
4723
|
+
|
4724
|
+
// src/actions/test/setMinGasPrice.ts
|
4725
|
+
async function setMinGasPrice(client, { gasPrice }) {
|
4726
|
+
return await client.request({
|
4727
|
+
method: `${client.mode}_setMinGasPrice`,
|
4728
|
+
params: [numberToHex(gasPrice)]
|
4729
|
+
});
|
4730
|
+
}
|
4731
|
+
|
4732
|
+
// src/actions/test/setNextBlockBaseFeePerGas.ts
|
4733
|
+
async function setNextBlockBaseFeePerGas(client, { baseFeePerGas }) {
|
4734
|
+
return await client.request({
|
4735
|
+
method: `${client.mode}_setNextBlockBaseFeePerGas`,
|
4736
|
+
params: [numberToHex(baseFeePerGas)]
|
4737
|
+
});
|
4738
|
+
}
|
4739
|
+
|
4740
|
+
// src/actions/test/setNextBlockTimestamp.ts
|
4741
|
+
async function setNextBlockTimestamp(client, { timestamp }) {
|
4742
|
+
return await client.request({
|
4743
|
+
method: "evm_setNextBlockTimestamp",
|
4744
|
+
params: [numberToHex(timestamp)]
|
4745
|
+
});
|
4746
|
+
}
|
4747
|
+
|
4748
|
+
// src/actions/test/setNonce.ts
|
4749
|
+
async function setNonce(client, { address, nonce }) {
|
4750
|
+
return await client.request({
|
4751
|
+
method: `${client.mode}_setNonce`,
|
4752
|
+
params: [address, numberToHex(nonce)]
|
4753
|
+
});
|
4754
|
+
}
|
4755
|
+
|
4756
|
+
// src/actions/test/setRpcUrl.ts
|
4757
|
+
async function setRpcUrl(client, jsonRpcUrl) {
|
4758
|
+
return await client.request({
|
4759
|
+
method: `${client.mode}_setRpcUrl`,
|
4760
|
+
params: [jsonRpcUrl]
|
4761
|
+
});
|
4762
|
+
}
|
4763
|
+
|
4764
|
+
// src/actions/test/setStorageAt.ts
|
4765
|
+
async function setStorageAt(client, { address, index, value }) {
|
4766
|
+
return await client.request({
|
4767
|
+
method: `${client.mode}_setStorageAt`,
|
4768
|
+
params: [
|
4769
|
+
address,
|
4770
|
+
typeof index === "number" ? numberToHex(index) : index,
|
4771
|
+
value
|
4772
|
+
]
|
4773
|
+
});
|
4774
|
+
}
|
4775
|
+
|
4776
|
+
// src/actions/test/snapshot.ts
|
4777
|
+
async function snapshot(client) {
|
4778
|
+
return await client.request({
|
4779
|
+
method: "evm_snapshot"
|
4780
|
+
});
|
4781
|
+
}
|
4782
|
+
|
4783
|
+
// src/actions/test/stopImpersonatingAccount.ts
|
4784
|
+
async function stopImpersonatingAccount(client, { address }) {
|
4785
|
+
return await client.request({
|
4786
|
+
method: `${client.mode}_stopImpersonatingAccount`,
|
4787
|
+
params: [address]
|
4788
|
+
});
|
4789
|
+
}
|
4790
|
+
|
4791
|
+
// src/actions/wallet/addChain.ts
|
4792
|
+
async function addChain(client, { chain }) {
|
4793
|
+
const { id: id2, name, nativeCurrency, rpcUrls, blockExplorers } = chain;
|
4794
|
+
await client.request({
|
4795
|
+
method: "wallet_addEthereumChain",
|
4796
|
+
params: [
|
4797
|
+
{
|
4798
|
+
chainId: numberToHex(id2),
|
4799
|
+
chainName: name,
|
4800
|
+
nativeCurrency,
|
4801
|
+
rpcUrls: rpcUrls.default.http,
|
4802
|
+
blockExplorerUrls: blockExplorers ? Object.values(blockExplorers).map(({ url }) => url) : void 0
|
4803
|
+
}
|
4804
|
+
]
|
4805
|
+
});
|
4806
|
+
}
|
4807
|
+
|
4808
|
+
// src/actions/wallet/deployContract.ts
|
4809
|
+
function deployContract(walletClient, { abi, args, bytecode, ...request }) {
|
4810
|
+
const calldata = encodeDeployData({
|
4811
|
+
abi,
|
4812
|
+
args,
|
4813
|
+
bytecode
|
4814
|
+
});
|
4815
|
+
return sendTransaction(walletClient, {
|
4816
|
+
...request,
|
4817
|
+
data: calldata
|
4818
|
+
});
|
4819
|
+
}
|
4820
|
+
|
4821
|
+
// src/actions/wallet/getAddresses.ts
|
4822
|
+
async function getAddresses(client) {
|
4823
|
+
const addresses = await client.request({ method: "eth_accounts" });
|
4824
|
+
return addresses.map((address) => checksumAddress(address));
|
4825
|
+
}
|
4826
|
+
|
4827
|
+
// src/actions/wallet/getPermissions.ts
|
4828
|
+
async function getPermissions(client) {
|
4829
|
+
const permissions = await client.request({ method: "wallet_getPermissions" });
|
4830
|
+
return permissions;
|
4831
|
+
}
|
4832
|
+
|
4833
|
+
// src/actions/wallet/requestAddresses.ts
|
4834
|
+
async function requestAddresses(client) {
|
4835
|
+
const addresses = await client.request({ method: "eth_requestAccounts" });
|
4836
|
+
return addresses.map((address) => getAddress(address));
|
4837
|
+
}
|
4838
|
+
|
4839
|
+
// src/actions/wallet/requestPermissions.ts
|
4840
|
+
async function requestPermissions(client, permissions) {
|
4841
|
+
return client.request({
|
4842
|
+
method: "wallet_requestPermissions",
|
4843
|
+
params: [permissions]
|
4844
|
+
});
|
4845
|
+
}
|
4846
|
+
|
4847
|
+
// src/actions/wallet/sendTransaction.ts
|
4848
|
+
async function sendTransaction(client, args) {
|
4849
|
+
const {
|
4850
|
+
account,
|
4851
|
+
chain,
|
4852
|
+
accessList,
|
4853
|
+
assertChain = true,
|
4854
|
+
data,
|
4855
|
+
gas,
|
4856
|
+
gasPrice,
|
4857
|
+
maxFeePerGas,
|
4858
|
+
maxPriorityFeePerGas,
|
4859
|
+
nonce,
|
4860
|
+
to,
|
4861
|
+
value,
|
4862
|
+
...rest
|
4863
|
+
} = args;
|
4864
|
+
try {
|
4865
|
+
assertRequest(args);
|
4866
|
+
const currentChainId = await getChainId(client);
|
4867
|
+
if (assertChain && chain && currentChainId !== chain?.id)
|
4868
|
+
throw new ChainMismatchError({ chain, currentChainId });
|
4869
|
+
if (account.type === "local") {
|
4870
|
+
const chainId = chain?.id ?? currentChainId;
|
4871
|
+
const request2 = await prepareRequest(client, {
|
4872
|
+
account,
|
4873
|
+
accessList,
|
4874
|
+
chain,
|
4875
|
+
data,
|
4876
|
+
gas,
|
4877
|
+
gasPrice,
|
4878
|
+
maxFeePerGas,
|
4879
|
+
maxPriorityFeePerGas,
|
4880
|
+
nonce,
|
4881
|
+
to,
|
4882
|
+
value,
|
4883
|
+
...rest
|
4884
|
+
});
|
4885
|
+
const signedRequest = await account.signTransaction({
|
4886
|
+
chainId,
|
4887
|
+
...request2
|
4888
|
+
});
|
4889
|
+
return await client.request({
|
4890
|
+
method: "eth_sendRawTransaction",
|
4891
|
+
params: [signedRequest]
|
4892
|
+
});
|
4893
|
+
}
|
4894
|
+
const formatter = chain?.formatters?.transactionRequest;
|
4895
|
+
const request = format3(
|
4896
|
+
{
|
4897
|
+
accessList,
|
4898
|
+
data,
|
4899
|
+
from: account.address,
|
4900
|
+
gas,
|
4901
|
+
gasPrice,
|
4902
|
+
maxFeePerGas,
|
4903
|
+
maxPriorityFeePerGas,
|
4904
|
+
nonce,
|
4905
|
+
to,
|
4906
|
+
value,
|
4907
|
+
// Pick out extra data that might exist on the chain's transaction request type.
|
4908
|
+
...extract(rest, { formatter })
|
4909
|
+
},
|
4910
|
+
{
|
4911
|
+
formatter: formatter || formatTransactionRequest
|
4912
|
+
}
|
4913
|
+
);
|
4914
|
+
return await client.request({
|
4915
|
+
method: "eth_sendTransaction",
|
4916
|
+
params: [request]
|
4917
|
+
});
|
4918
|
+
} catch (err) {
|
4919
|
+
throw getTransactionError(err, args);
|
4920
|
+
}
|
4921
|
+
}
|
4922
|
+
|
4923
|
+
// src/actions/wallet/signMessage.ts
|
4924
|
+
async function signMessage(client, { account, data }) {
|
4925
|
+
if (account.type === "local")
|
4926
|
+
return account.signMessage(data);
|
4927
|
+
return client.request({
|
4928
|
+
method: "personal_sign",
|
4929
|
+
params: [toHex(data), account.address]
|
4930
|
+
});
|
4931
|
+
}
|
4932
|
+
|
4933
|
+
// src/actions/wallet/switchChain.ts
|
4934
|
+
async function switchChain(client, { id: id2 }) {
|
4935
|
+
await client.request({
|
4936
|
+
method: "wallet_switchEthereumChain",
|
4937
|
+
params: [
|
4938
|
+
{
|
4939
|
+
chainId: numberToHex(id2)
|
4940
|
+
}
|
4941
|
+
]
|
4942
|
+
});
|
4943
|
+
}
|
4944
|
+
|
4945
|
+
// src/actions/wallet/watchAsset.ts
|
4946
|
+
async function watchAsset(client, params) {
|
4947
|
+
const added = await client.request({
|
4948
|
+
method: "wallet_watchAsset",
|
4949
|
+
params: [params]
|
4950
|
+
});
|
4951
|
+
return added;
|
4952
|
+
}
|
4953
|
+
|
4954
|
+
// src/actions/wallet/writeContract.ts
|
4955
|
+
async function writeContract(client, {
|
4956
|
+
abi,
|
4957
|
+
address,
|
4958
|
+
args,
|
4959
|
+
functionName,
|
4960
|
+
...request
|
4961
|
+
}) {
|
4962
|
+
const data = encodeFunctionData({
|
4963
|
+
abi,
|
4964
|
+
args,
|
4965
|
+
functionName
|
4966
|
+
});
|
4967
|
+
const hash2 = await sendTransaction(client, {
|
4968
|
+
data,
|
4969
|
+
to: address,
|
4970
|
+
...request
|
4971
|
+
});
|
4972
|
+
return hash2;
|
2837
4973
|
}
|
2838
4974
|
|
2839
|
-
// src/utils/unit/
|
2840
|
-
function
|
4975
|
+
// src/utils/unit/parseUnits.ts
|
4976
|
+
function parseUnits(value, decimals) {
|
2841
4977
|
let [integer, fraction = "0"] = value.split(".");
|
2842
4978
|
const negative = integer.startsWith("-");
|
2843
4979
|
if (negative)
|
@@ -2858,14 +4994,79 @@ function parseUnit(value, decimals) {
|
|
2858
4994
|
return BigInt(`${negative ? "-" : ""}${integer}${fraction}`);
|
2859
4995
|
}
|
2860
4996
|
|
2861
|
-
// src/utils/unit/parseEther.ts
|
2862
|
-
function parseEther(ether, unit = "wei") {
|
2863
|
-
return parseUnit(ether, etherUnits[unit]);
|
2864
|
-
}
|
2865
|
-
|
2866
4997
|
// src/utils/unit/parseGwei.ts
|
2867
4998
|
function parseGwei(ether, unit = "wei") {
|
2868
|
-
return
|
4999
|
+
return parseUnits(ether, gweiUnits[unit]);
|
5000
|
+
}
|
5001
|
+
|
5002
|
+
// src/utils/transaction/prepareRequest.ts
|
5003
|
+
var defaultTip = parseGwei("1.5");
|
5004
|
+
async function prepareRequest(client, args) {
|
5005
|
+
const { account, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce } = args;
|
5006
|
+
const block = await getBlock(client, { blockTag: "latest" });
|
5007
|
+
const request = { ...args, from: account.address };
|
5008
|
+
if (typeof nonce === "undefined")
|
5009
|
+
request.nonce = await getTransactionCount(client, {
|
5010
|
+
address: account.address,
|
5011
|
+
blockTag: "pending"
|
5012
|
+
});
|
5013
|
+
if (block.baseFeePerGas) {
|
5014
|
+
if (typeof gasPrice !== "undefined")
|
5015
|
+
throw new BaseError("Chain does not support legacy `gasPrice`.");
|
5016
|
+
if (typeof maxFeePerGas === "undefined") {
|
5017
|
+
request.maxPriorityFeePerGas = maxPriorityFeePerGas ?? defaultTip;
|
5018
|
+
request.maxFeePerGas = block.baseFeePerGas * 120n / 100n + request.maxPriorityFeePerGas;
|
5019
|
+
} else {
|
5020
|
+
if (typeof maxPriorityFeePerGas === "undefined" && maxFeePerGas < defaultTip)
|
5021
|
+
throw new BaseError(
|
5022
|
+
"`maxFeePerGas` cannot be less than the default `maxPriorityFeePerGas` (1.5 gwei)."
|
5023
|
+
);
|
5024
|
+
request.maxFeePerGas = maxFeePerGas;
|
5025
|
+
request.maxPriorityFeePerGas = maxPriorityFeePerGas ?? defaultTip;
|
5026
|
+
}
|
5027
|
+
} else {
|
5028
|
+
if (typeof maxFeePerGas !== "undefined" || typeof maxPriorityFeePerGas !== "undefined")
|
5029
|
+
throw new BaseError("Chain does not support EIP-1559 fees.");
|
5030
|
+
if (typeof gasPrice === "undefined")
|
5031
|
+
request.gasPrice = await getGasPrice(client) * 120n / 100n;
|
5032
|
+
}
|
5033
|
+
if (typeof gas === "undefined")
|
5034
|
+
request.gas = await estimateGas(client, {
|
5035
|
+
...request,
|
5036
|
+
account: { address: account.address, type: "json-rpc" }
|
5037
|
+
});
|
5038
|
+
assertRequest(request);
|
5039
|
+
return request;
|
5040
|
+
}
|
5041
|
+
|
5042
|
+
// src/utils/unit/formatUnits.ts
|
5043
|
+
function formatUnits(value, decimals) {
|
5044
|
+
let display = value.toString();
|
5045
|
+
const negative = display.startsWith("-");
|
5046
|
+
if (negative)
|
5047
|
+
display = display.slice(1);
|
5048
|
+
display = display.padStart(decimals, "0");
|
5049
|
+
let [integer, fraction] = [
|
5050
|
+
display.slice(0, display.length - decimals),
|
5051
|
+
display.slice(display.length - decimals)
|
5052
|
+
];
|
5053
|
+
fraction = fraction.replace(/(0+)$/, "");
|
5054
|
+
return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
|
5055
|
+
}
|
5056
|
+
|
5057
|
+
// src/utils/unit/formatEther.ts
|
5058
|
+
function formatEther(wei, unit = "wei") {
|
5059
|
+
return formatUnits(wei, etherUnits[unit]);
|
5060
|
+
}
|
5061
|
+
|
5062
|
+
// src/utils/unit/formatGwei.ts
|
5063
|
+
function formatGwei(wei, unit = "wei") {
|
5064
|
+
return formatUnits(wei, gweiUnits[unit]);
|
5065
|
+
}
|
5066
|
+
|
5067
|
+
// src/utils/unit/parseEther.ts
|
5068
|
+
function parseEther(ether, unit = "wei") {
|
5069
|
+
return parseUnits(ether, etherUnits[unit]);
|
2869
5070
|
}
|
2870
5071
|
|
2871
5072
|
export {
|
@@ -2879,6 +5080,7 @@ export {
|
|
2879
5080
|
AbiErrorInputsNotFoundError,
|
2880
5081
|
AbiErrorNotFoundError,
|
2881
5082
|
AbiErrorSignatureNotFoundError,
|
5083
|
+
AbiEventSignatureNotFoundError,
|
2882
5084
|
AbiEventNotFoundError,
|
2883
5085
|
AbiFunctionNotFoundError,
|
2884
5086
|
AbiFunctionOutputsNotFoundError,
|
@@ -2892,6 +5094,61 @@ export {
|
|
2892
5094
|
ChainDoesNotSupportContract,
|
2893
5095
|
multicall3Abi,
|
2894
5096
|
panicReasons,
|
5097
|
+
etherUnits,
|
5098
|
+
gweiUnits,
|
5099
|
+
weiUnits,
|
5100
|
+
TransactionExecutionError,
|
5101
|
+
TransactionNotFoundError,
|
5102
|
+
TransactionReceiptNotFoundError,
|
5103
|
+
WaitForTransactionReceiptTimeoutError,
|
5104
|
+
CallExecutionError,
|
5105
|
+
ContractFunctionExecutionError,
|
5106
|
+
ContractFunctionRevertedError,
|
5107
|
+
ContractFunctionZeroDataError,
|
5108
|
+
RawContractError,
|
5109
|
+
SizeExceedsPaddingSizeError,
|
5110
|
+
DataLengthTooLongError,
|
5111
|
+
DataLengthTooShortError,
|
5112
|
+
InvalidBytesBooleanError,
|
5113
|
+
InvalidHexBooleanError,
|
5114
|
+
InvalidHexValueError,
|
5115
|
+
OffsetOutOfBoundsError,
|
5116
|
+
EstimateGasExecutionError,
|
5117
|
+
FilterTypeNotSupportedError,
|
5118
|
+
ExecutionRevertedError,
|
5119
|
+
FeeCapTooHighError,
|
5120
|
+
FeeCapTooLowError,
|
5121
|
+
NonceTooHighError,
|
5122
|
+
NonceTooLowError,
|
5123
|
+
NonceMaxValueError,
|
5124
|
+
InsufficientFundsError,
|
5125
|
+
IntrinsicGasTooHighError,
|
5126
|
+
IntrinsicGasTooLowError,
|
5127
|
+
TransactionTypeNotSupportedError,
|
5128
|
+
TipAboveFeeCapError,
|
5129
|
+
UnknownNodeError,
|
5130
|
+
RequestError,
|
5131
|
+
RpcRequestError,
|
5132
|
+
ParseRpcError,
|
5133
|
+
InvalidRequestRpcError,
|
5134
|
+
MethodNotFoundRpcError,
|
5135
|
+
InvalidParamsRpcError,
|
5136
|
+
InternalRpcError,
|
5137
|
+
InvalidInputRpcError,
|
5138
|
+
ResourceNotFoundRpcError,
|
5139
|
+
ResourceUnavailableRpcError,
|
5140
|
+
TransactionRejectedRpcError,
|
5141
|
+
MethodNotSupportedRpcError,
|
5142
|
+
LimitExceededRpcError,
|
5143
|
+
JsonRpcVersionUnsupportedError,
|
5144
|
+
UserRejectedRequestError,
|
5145
|
+
SwitchChainError,
|
5146
|
+
UnknownRpcError,
|
5147
|
+
HttpRequestError,
|
5148
|
+
WebSocketRequestError,
|
5149
|
+
RpcError,
|
5150
|
+
TimeoutError,
|
5151
|
+
UrlRequiredError,
|
2895
5152
|
concat,
|
2896
5153
|
isBytes,
|
2897
5154
|
isHex,
|
@@ -2905,43 +5162,41 @@ export {
|
|
2905
5162
|
sliceHex,
|
2906
5163
|
boolToHex,
|
2907
5164
|
bytesToHex,
|
2908
|
-
|
5165
|
+
toHex,
|
2909
5166
|
numberToHex,
|
2910
5167
|
stringToHex,
|
5168
|
+
toBytes,
|
2911
5169
|
boolToBytes,
|
2912
|
-
encodeBytes,
|
2913
5170
|
hexToBytes,
|
2914
5171
|
numberToBytes,
|
2915
5172
|
stringToBytes,
|
2916
|
-
|
2917
|
-
|
5173
|
+
toRlp,
|
5174
|
+
fromHex,
|
2918
5175
|
hexToBigInt,
|
2919
5176
|
hexToBool,
|
2920
5177
|
hexToNumber,
|
2921
5178
|
hexToString,
|
2922
|
-
|
5179
|
+
fromBytes,
|
2923
5180
|
bytesToBigint,
|
2924
5181
|
bytesToBool,
|
2925
5182
|
bytesToNumber,
|
2926
5183
|
bytesToString,
|
2927
|
-
|
5184
|
+
fromRlp,
|
2928
5185
|
extractFunctionParts,
|
2929
5186
|
extractFunctionName,
|
2930
5187
|
extractFunctionParams,
|
2931
5188
|
extractFunctionType,
|
2932
|
-
getContractError,
|
2933
5189
|
keccak256,
|
2934
|
-
|
2935
|
-
|
2936
|
-
|
5190
|
+
getEventSelector,
|
5191
|
+
getFunctionSelector,
|
5192
|
+
isAddress,
|
2937
5193
|
getAddress,
|
2938
|
-
getContractAddress,
|
5194
|
+
getContractAddress2 as getContractAddress,
|
2939
5195
|
getCreateAddress,
|
2940
5196
|
getCreate2Address,
|
2941
|
-
isAddress,
|
2942
5197
|
isAddressEqual,
|
2943
|
-
|
2944
|
-
|
5198
|
+
encodeAbiParameters,
|
5199
|
+
decodeAbiParameters,
|
2945
5200
|
formatAbiItem,
|
2946
5201
|
decodeErrorResult,
|
2947
5202
|
decodeEventLog,
|
@@ -2953,11 +5208,17 @@ export {
|
|
2953
5208
|
encodeEventTopics,
|
2954
5209
|
encodeFunctionData,
|
2955
5210
|
encodeFunctionResult,
|
5211
|
+
arrayRegex,
|
5212
|
+
bytesRegex,
|
5213
|
+
integerRegex,
|
5214
|
+
encodePacked,
|
2956
5215
|
formatAbiItemWithArgs,
|
2957
|
-
|
2958
|
-
|
2959
|
-
|
2960
|
-
|
5216
|
+
parseAbi,
|
5217
|
+
parseAbiItem,
|
5218
|
+
parseAbiParameter,
|
5219
|
+
parseAbiParameters,
|
5220
|
+
getAccount,
|
5221
|
+
isDeterministicError,
|
2961
5222
|
buildRequest,
|
2962
5223
|
defineChain,
|
2963
5224
|
format3 as format,
|
@@ -2968,59 +5229,98 @@ export {
|
|
2968
5229
|
formatBlock,
|
2969
5230
|
defineBlock,
|
2970
5231
|
extract,
|
2971
|
-
formatFeeHistory,
|
2972
|
-
formatLog,
|
2973
|
-
formatTransactionReceipt,
|
2974
5232
|
defineTransactionReceipt,
|
2975
5233
|
formatTransactionRequest,
|
2976
5234
|
defineTransactionRequest,
|
5235
|
+
containsNodeError,
|
5236
|
+
getNodeError,
|
5237
|
+
getCallError,
|
5238
|
+
getContractError,
|
5239
|
+
getEstimateGasError,
|
5240
|
+
getTransactionError,
|
2977
5241
|
stringify,
|
2978
5242
|
getSocket,
|
2979
5243
|
rpc,
|
2980
|
-
|
2981
|
-
|
2982
|
-
|
2983
|
-
|
5244
|
+
assertRequest,
|
5245
|
+
call,
|
5246
|
+
simulateContract,
|
5247
|
+
createPendingTransactionFilter,
|
5248
|
+
createBlockFilter,
|
5249
|
+
createEventFilter,
|
5250
|
+
createContractEventFilter,
|
5251
|
+
estimateGas,
|
5252
|
+
estimateContractGas,
|
5253
|
+
getBalance,
|
5254
|
+
getBlock,
|
5255
|
+
getBlockNumberCache,
|
5256
|
+
getBlockNumber,
|
5257
|
+
getBlockTransactionCount,
|
5258
|
+
getBytecode,
|
5259
|
+
getChainId,
|
5260
|
+
getFeeHistory,
|
5261
|
+
getFilterChanges,
|
5262
|
+
getFilterLogs,
|
5263
|
+
getGasPrice,
|
5264
|
+
getLogs,
|
5265
|
+
getStorageAt,
|
5266
|
+
getTransaction,
|
5267
|
+
getTransactionConfirmations,
|
5268
|
+
getTransactionCount,
|
5269
|
+
getTransactionReceipt,
|
5270
|
+
readContract,
|
5271
|
+
multicall,
|
5272
|
+
uninstallFilter,
|
5273
|
+
waitForTransactionReceipt,
|
5274
|
+
watchBlockNumber,
|
5275
|
+
watchBlocks,
|
5276
|
+
watchContractEvent,
|
5277
|
+
watchEvent,
|
5278
|
+
watchPendingTransactions,
|
5279
|
+
dropTransaction,
|
5280
|
+
getAutomine,
|
5281
|
+
getTxpoolContent,
|
5282
|
+
getTxpoolStatus,
|
5283
|
+
impersonateAccount,
|
5284
|
+
increaseTime,
|
5285
|
+
inspectTxpool,
|
5286
|
+
mine,
|
5287
|
+
removeBlockTimestampInterval,
|
5288
|
+
reset,
|
5289
|
+
revert,
|
5290
|
+
sendUnsignedTransaction,
|
5291
|
+
setAutomine,
|
5292
|
+
setBalance,
|
5293
|
+
setBlockGasLimit,
|
5294
|
+
setBlockTimestampInterval,
|
5295
|
+
setCode,
|
5296
|
+
setCoinbase,
|
5297
|
+
setIntervalMining,
|
5298
|
+
setLoggingEnabled,
|
5299
|
+
setMinGasPrice,
|
5300
|
+
setNextBlockBaseFeePerGas,
|
5301
|
+
setNextBlockTimestamp,
|
5302
|
+
setNonce,
|
5303
|
+
setRpcUrl,
|
5304
|
+
setStorageAt,
|
5305
|
+
snapshot,
|
5306
|
+
stopImpersonatingAccount,
|
5307
|
+
addChain,
|
5308
|
+
deployContract,
|
5309
|
+
getAddresses,
|
5310
|
+
getPermissions,
|
5311
|
+
requestAddresses,
|
5312
|
+
requestPermissions,
|
5313
|
+
sendTransaction,
|
5314
|
+
signMessage,
|
5315
|
+
switchChain,
|
5316
|
+
watchAsset,
|
5317
|
+
writeContract,
|
5318
|
+
parseUnits,
|
5319
|
+
parseGwei,
|
5320
|
+
prepareRequest,
|
5321
|
+
formatUnits,
|
2984
5322
|
formatEther,
|
2985
5323
|
formatGwei,
|
2986
|
-
|
2987
|
-
parseEther,
|
2988
|
-
parseGwei,
|
2989
|
-
ContractFunctionExecutionError,
|
2990
|
-
ContractFunctionRevertedError,
|
2991
|
-
ContractFunctionZeroDataError,
|
2992
|
-
RawContractError,
|
2993
|
-
SizeExceedsPaddingSizeError,
|
2994
|
-
DataLengthTooLongError,
|
2995
|
-
DataLengthTooShortError,
|
2996
|
-
InvalidBytesBooleanError,
|
2997
|
-
InvalidHexBooleanError,
|
2998
|
-
InvalidHexValueError,
|
2999
|
-
OffsetOutOfBoundsError,
|
3000
|
-
FilterTypeNotSupportedError,
|
3001
|
-
RequestError,
|
3002
|
-
RpcRequestError,
|
3003
|
-
ParseRpcError,
|
3004
|
-
InvalidRequestRpcError,
|
3005
|
-
MethodNotFoundRpcError,
|
3006
|
-
InvalidParamsRpcError,
|
3007
|
-
InternalRpcError,
|
3008
|
-
InvalidInputRpcError,
|
3009
|
-
ResourceNotFoundRpcError,
|
3010
|
-
ResourceUnavailableRpcError,
|
3011
|
-
TransactionRejectedRpcError,
|
3012
|
-
MethodNotSupportedRpcError,
|
3013
|
-
LimitExceededRpcError,
|
3014
|
-
JsonRpcVersionUnsupportedError,
|
3015
|
-
UnknownRpcError,
|
3016
|
-
HttpRequestError,
|
3017
|
-
WebSocketRequestError,
|
3018
|
-
RpcError,
|
3019
|
-
TimeoutError,
|
3020
|
-
InvalidGasArgumentsError,
|
3021
|
-
TransactionNotFoundError,
|
3022
|
-
TransactionReceiptNotFoundError,
|
3023
|
-
WaitForTransactionReceiptTimeoutError,
|
3024
|
-
UrlRequiredError
|
5324
|
+
parseEther
|
3025
5325
|
};
|
3026
|
-
//# sourceMappingURL=chunk-
|
5326
|
+
//# sourceMappingURL=chunk-I7AINPMM.mjs.map
|