viem 0.0.1-alpha.2 → 0.0.1-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chains/package.json +1 -1
- package/clients/package.json +1 -1
- package/dist/{rpc-655c0ba4.d.ts → chain-32f56cfa.d.ts} +78 -17
- package/dist/chain-f12cdc7f.d.ts +5 -0
- package/dist/chains.d.ts +1291 -74
- package/dist/chains.js +125 -129
- package/dist/chains.js.map +1 -0
- package/dist/chains.mjs +129 -0
- package/dist/chains.mjs.map +1 -0
- package/dist/{chunk-YQRTXQ2G.js → chunk-46BO7YAQ.mjs} +3 -15
- package/dist/chunk-46BO7YAQ.mjs.map +1 -0
- package/dist/chunk-57ZOFERP.mjs +256 -0
- package/dist/chunk-57ZOFERP.mjs.map +1 -0
- package/dist/{chunk-3EOU525X.js → chunk-62VTYU2V.mjs} +1207 -564
- package/dist/chunk-62VTYU2V.mjs.map +1 -0
- package/dist/{chunk-4HNVS7AM.js → chunk-DGO77E2H.mjs} +330 -539
- package/dist/chunk-DGO77E2H.mjs.map +1 -0
- package/dist/chunk-DSPMAIDO.mjs +176 -0
- package/dist/chunk-DSPMAIDO.mjs.map +1 -0
- package/dist/chunk-EC3NUIJE.js +176 -0
- package/dist/chunk-EC3NUIJE.js.map +1 -0
- package/dist/chunk-KEHGSYDO.js +259 -0
- package/dist/chunk-KEHGSYDO.js.map +1 -0
- package/dist/chunk-KZMJR27B.js +889 -0
- package/dist/chunk-KZMJR27B.js.map +1 -0
- package/dist/chunk-O2GYLJVD.js +2689 -0
- package/dist/chunk-O2GYLJVD.js.map +1 -0
- package/dist/chunk-W7BWWAC4.js +256 -0
- package/dist/chunk-W7BWWAC4.js.map +1 -0
- package/dist/clients/index.d.ts +8 -7
- package/dist/clients/index.js +24 -25
- package/dist/clients/index.js.map +1 -0
- package/dist/clients/index.mjs +24 -0
- package/dist/clients/index.mjs.map +1 -0
- package/dist/contract-9af4608b.d.ts +142 -0
- package/dist/createClient-5d316c7e.d.ts +62 -0
- package/dist/createPublicClient-9d2b42e1.d.ts +19 -0
- package/dist/createTestClient-79498dab.d.ts +34 -0
- package/dist/createWalletClient-f69a5230.d.ts +30 -0
- package/dist/{eip1193-8f7c22ce.d.ts → eip1193-6c485d63.d.ts} +13 -10
- package/dist/index.d.ts +424 -11
- package/dist/index.js +395 -292
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +395 -0
- package/dist/index.mjs.map +1 -0
- package/dist/{parseGwei-fd7a0f7d.d.ts → parseGwei-4308ad80.d.ts} +82 -139
- package/dist/public.d.ts +11 -0
- package/dist/public.js +59 -0
- package/dist/public.js.map +1 -0
- package/dist/public.mjs +59 -0
- package/dist/public.mjs.map +1 -0
- package/dist/{rpc-3c0e3985.d.ts → rpc-26932bae.d.ts} +1 -38
- package/dist/sendTransaction-1c8290a9.d.ts +12 -0
- package/dist/stopImpersonatingAccount-7781842a.d.ts +156 -0
- package/dist/test.d.ts +6 -0
- package/dist/test.js +60 -0
- package/dist/test.js.map +1 -0
- package/dist/test.mjs +60 -0
- package/dist/test.mjs.map +1 -0
- package/dist/transactionRequest-341b6ed2.d.ts +15 -0
- package/dist/utils/index.d.ts +51 -8
- package/dist/utils/index.js +171 -156
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +171 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/wallet.d.ts +8 -0
- package/dist/wallet.js +24 -0
- package/dist/wallet.js.map +1 -0
- package/dist/wallet.mjs +24 -0
- package/dist/wallet.mjs.map +1 -0
- package/dist/watchAsset-afaad3c7.d.ts +38 -0
- package/dist/{watchAsset-04ab8db5.d.ts → watchPendingTransactions-3b722547.d.ts} +67 -217
- package/dist/{webSocket-c6e0d26f.d.ts → webSocket-b180e679.d.ts} +4 -9
- package/dist/window.d.ts +3 -2
- package/dist/window.js +1 -0
- package/dist/window.js.map +1 -0
- package/dist/window.mjs +1 -0
- package/dist/window.mjs.map +1 -0
- package/package.json +30 -66
- package/src/_test/abis.ts +1413 -0
- package/src/_test/bench.ts +15 -0
- package/src/_test/constants.ts +60 -0
- package/src/_test/globalSetup.ts +11 -0
- package/src/_test/index.ts +23 -0
- package/src/_test/setup.ts +8 -0
- package/src/_test/utils.ts +112 -0
- package/src/actions/index.test.ts +78 -0
- package/src/actions/index.ts +174 -0
- package/src/actions/public/call.bench.ts +48 -0
- package/src/actions/public/call.test.ts +99 -0
- package/src/actions/public/call.ts +97 -0
- package/src/actions/public/createBlockFilter.bench.ts +11 -0
- package/src/actions/public/createBlockFilter.test.ts +9 -0
- package/src/actions/public/createBlockFilter.ts +14 -0
- package/src/actions/public/createContractEventFilter.test.ts +119 -0
- package/src/actions/public/createContractEventFilter.ts +69 -0
- package/src/actions/public/createEventFilter.test.ts +245 -0
- package/src/actions/public/createEventFilter.ts +76 -0
- package/src/actions/public/createPendingTransactionFilter.bench.ts +11 -0
- package/src/actions/public/createPendingTransactionFilter.test.ts +9 -0
- package/src/actions/public/createPendingTransactionFilter.ts +14 -0
- package/src/actions/public/deployContract.test.ts +56 -0
- package/src/actions/public/deployContract.ts +38 -0
- package/src/actions/public/estimateGas.bench.ts +46 -0
- package/src/actions/public/estimateGas.test.ts +92 -0
- package/src/actions/public/estimateGas.ts +61 -0
- package/src/actions/public/getBalance.test.ts +83 -0
- package/src/actions/public/getBalance.ts +37 -0
- package/src/actions/public/getBlock.bench.ts +28 -0
- package/src/actions/public/getBlock.test.ts +575 -0
- package/src/actions/public/getBlock.ts +65 -0
- package/src/actions/public/getBlockNumber.bench.ts +28 -0
- package/src/actions/public/getBlockNumber.test.ts +27 -0
- package/src/actions/public/getBlockNumber.ts +32 -0
- package/src/actions/public/getBlockTransactionCount.bench.ts +15 -0
- package/src/actions/public/getBlockTransactionCount.test.ts +57 -0
- package/src/actions/public/getBlockTransactionCount.ts +52 -0
- package/src/actions/public/getBytecode.test.ts +27 -0
- package/src/actions/public/getBytecode.ts +32 -0
- package/src/actions/public/getChainId.bench.ts +15 -0
- package/src/actions/public/getChainId.test.ts +8 -0
- package/src/actions/public/getChainId.ts +7 -0
- package/src/actions/public/getFeeHistory.bench.ts +18 -0
- package/src/actions/public/getFeeHistory.test.ts +137 -0
- package/src/actions/public/getFeeHistory.ts +44 -0
- package/src/actions/public/getFilterChanges.bench.ts +13 -0
- package/src/actions/public/getFilterChanges.test.ts +189 -0
- package/src/actions/public/getFilterChanges.ts +23 -0
- package/src/actions/public/getFilterLogs.test.ts +104 -0
- package/src/actions/public/getFilterLogs.ts +20 -0
- package/src/actions/public/getGasPrice.bench.ts +28 -0
- package/src/actions/public/getGasPrice.test.ts +8 -0
- package/src/actions/public/getGasPrice.ts +15 -0
- package/src/actions/public/getLogs.test.ts +107 -0
- package/src/actions/public/getLogs.ts +84 -0
- package/src/actions/public/getStorageAt.test.ts +34 -0
- package/src/actions/public/getStorageAt.ts +32 -0
- package/src/actions/public/getTransaction.bench.ts +33 -0
- package/src/actions/public/getTransaction.test.ts +311 -0
- package/src/actions/public/getTransaction.ts +95 -0
- package/src/actions/public/getTransactionConfirmations.test.ts +69 -0
- package/src/actions/public/getTransactionConfirmations.ts +38 -0
- package/src/actions/public/getTransactionCount.test.ts +56 -0
- package/src/actions/public/getTransactionCount.ts +34 -0
- package/src/actions/public/getTransactionReceipt.bench.ts +33 -0
- package/src/actions/public/getTransactionReceipt.test.ts +179 -0
- package/src/actions/public/getTransactionReceipt.ts +34 -0
- package/src/actions/public/index.test.ts +43 -0
- package/src/actions/public/index.ts +149 -0
- package/src/actions/public/readContract.test.ts +128 -0
- package/src/actions/public/readContract.ts +87 -0
- package/src/actions/public/simulateContract.bench.ts +31 -0
- package/src/actions/public/simulateContract.test.ts +238 -0
- package/src/actions/public/simulateContract.ts +98 -0
- package/src/actions/public/uninstallFilter.bench.ts +13 -0
- package/src/actions/public/uninstallFilter.test.ts +65 -0
- package/src/actions/public/uninstallFilter.ts +17 -0
- package/src/actions/public/waitForTransactionReceipt.test.ts +322 -0
- package/src/actions/public/waitForTransactionReceipt.ts +170 -0
- package/src/actions/public/watchBlockNumber.test.ts +166 -0
- package/src/actions/public/watchBlockNumber.ts +79 -0
- package/src/actions/public/watchBlocks.test.ts +210 -0
- package/src/actions/public/watchBlocks.ts +114 -0
- package/src/actions/public/watchContractEvent.test.ts +301 -0
- package/src/actions/public/watchContractEvent.ts +108 -0
- package/src/actions/public/watchEvent.test.ts +190 -0
- package/src/actions/public/watchEvent.ts +95 -0
- package/src/actions/public/watchPendingTransactions.test.ts +116 -0
- package/src/actions/public/watchPendingTransactions.ts +74 -0
- package/src/actions/test/dropTransaction.test.ts +34 -0
- package/src/actions/test/dropTransaction.ts +17 -0
- package/src/actions/test/getAutomine.test.ts +14 -0
- package/src/actions/test/getAutomine.ts +11 -0
- package/src/actions/test/getTxpoolContent.test.ts +45 -0
- package/src/actions/test/getTxpoolContent.ts +7 -0
- package/src/actions/test/getTxpoolStatus.test.ts +41 -0
- package/src/actions/test/getTxpoolStatus.ts +12 -0
- package/src/actions/test/impersonateAccount.test.ts +28 -0
- package/src/actions/test/impersonateAccount.ts +17 -0
- package/src/actions/test/increaseTime.test.ts +18 -0
- package/src/actions/test/increaseTime.ts +17 -0
- package/src/actions/test/index.test.ts +38 -0
- package/src/actions/test/index.ts +77 -0
- package/src/actions/test/inspectTxpool.test.ts +50 -0
- package/src/actions/test/inspectTxpool.ts +7 -0
- package/src/actions/test/mine.test.ts +20 -0
- package/src/actions/test/mine.ts +16 -0
- package/src/actions/test/removeBlockTimestampInterval.test.ts +23 -0
- package/src/actions/test/removeBlockTimestampInterval.ts +7 -0
- package/src/actions/test/reset.test.ts +19 -0
- package/src/actions/test/reset.ts +18 -0
- package/src/actions/test/revert.test.ts +39 -0
- package/src/actions/test/revert.ts +14 -0
- package/src/actions/test/sendUnsignedTransaction.test.ts +52 -0
- package/src/actions/test/sendUnsignedTransaction.ts +19 -0
- package/src/actions/test/setAutomine.test.ts +14 -0
- package/src/actions/test/setAutomine.ts +8 -0
- package/src/actions/test/setBalance.test.ts +29 -0
- package/src/actions/test/setBalance.ts +20 -0
- package/src/actions/test/setBlockGasLimit.test.ts +21 -0
- package/src/actions/test/setBlockGasLimit.ts +17 -0
- package/src/actions/test/setBlockTimestampInterval.test.ts +23 -0
- package/src/actions/test/setBlockTimestampInterval.ts +16 -0
- package/src/actions/test/setCode.test.ts +26 -0
- package/src/actions/test/setCode.ts +19 -0
- package/src/actions/test/setCoinbase.test.ts +11 -0
- package/src/actions/test/setCoinbase.ts +17 -0
- package/src/actions/test/setIntervalMining.test.ts +30 -0
- package/src/actions/test/setIntervalMining.ts +16 -0
- package/src/actions/test/setLoggingEnabled.test.ts +10 -0
- package/src/actions/test/setLoggingEnabled.ts +8 -0
- package/src/actions/test/setMinGasPrice.test.ts +22 -0
- package/src/actions/test/setMinGasPrice.ts +17 -0
- package/src/actions/test/setNextBlockBaseFeePerGas.test.ts +23 -0
- package/src/actions/test/setNextBlockBaseFeePerGas.ts +17 -0
- package/src/actions/test/setNextBlockTimestamp.test.ts +19 -0
- package/src/actions/test/setNextBlockTimestamp.ts +17 -0
- package/src/actions/test/setNonce.test.ts +28 -0
- package/src/actions/test/setNonce.ts +20 -0
- package/src/actions/test/setRpcUrl.test.ts +9 -0
- package/src/actions/test/setRpcUrl.ts +8 -0
- package/src/actions/test/setStorageAt.test.ts +36 -0
- package/src/actions/test/setStorageAt.ts +26 -0
- package/src/actions/test/snapshot.test.ts +18 -0
- package/src/actions/test/snapshot.ts +7 -0
- package/src/actions/test/stopImpersonatingAccount.test.ts +31 -0
- package/src/actions/test/stopImpersonatingAccount.ts +17 -0
- package/src/actions/wallet/addChain.test.ts +14 -0
- package/src/actions/wallet/addChain.ts +21 -0
- package/src/actions/wallet/getAccounts.test.ts +22 -0
- package/src/actions/wallet/getAccounts.ts +7 -0
- package/src/actions/wallet/getPermissions.test.ts +24 -0
- package/src/actions/wallet/getPermissions.ts +9 -0
- package/src/actions/wallet/index.test.ts +20 -0
- package/src/actions/wallet/index.ts +30 -0
- package/src/actions/wallet/requestAccounts.test.ts +13 -0
- package/src/actions/wallet/requestAccounts.ts +7 -0
- package/src/actions/wallet/requestPermissions.test.ts +26 -0
- package/src/actions/wallet/requestPermissions.ts +19 -0
- package/src/actions/wallet/sendTransaction.bench.ts +57 -0
- package/src/actions/wallet/sendTransaction.test.ts +440 -0
- package/src/actions/wallet/sendTransaction.ts +77 -0
- package/src/actions/wallet/signMessage.test.ts +62 -0
- package/src/actions/wallet/signMessage.ts +35 -0
- package/src/actions/wallet/switchChain.test.ts +22 -0
- package/src/actions/wallet/switchChain.ts +19 -0
- package/src/actions/wallet/watchAsset.test.ts +41 -0
- package/src/actions/wallet/watchAsset.ts +16 -0
- package/src/actions/wallet/writeContract.test.ts +54 -0
- package/src/actions/wallet/writeContract.ts +56 -0
- package/src/chains.test.ts +1912 -0
- package/src/chains.ts +99 -0
- package/src/clients/createClient.test.ts +295 -0
- package/src/clients/createClient.ts +81 -0
- package/src/clients/createPublicClient.test.ts +165 -0
- package/src/clients/createPublicClient.ts +49 -0
- package/src/clients/createTestClient.test.ts +145 -0
- package/src/clients/createTestClient.ts +72 -0
- package/src/clients/createWalletClient.test.ts +121 -0
- package/src/clients/createWalletClient.ts +54 -0
- package/src/clients/index.test.ts +19 -0
- package/src/clients/index.ts +31 -0
- package/src/clients/transports/createTransport.test.ts +58 -0
- package/src/clients/transports/createTransport.ts +48 -0
- package/src/clients/transports/custom.test.ts +98 -0
- package/src/clients/transports/custom.ts +34 -0
- package/src/clients/transports/fallback.test.ts +223 -0
- package/src/clients/transports/fallback.ts +48 -0
- package/src/clients/transports/http.test.ts +110 -0
- package/src/clients/transports/http.ts +51 -0
- package/src/clients/transports/index.test.ts +15 -0
- package/src/clients/transports/index.ts +17 -0
- package/src/clients/transports/webSocket.test.ts +164 -0
- package/src/clients/transports/webSocket.ts +117 -0
- package/src/errors/abi.test.ts +83 -0
- package/src/errors/abi.ts +238 -0
- package/src/errors/address.test.ts +14 -0
- package/src/errors/address.ts +9 -0
- package/src/errors/base.test.ts +72 -0
- package/src/errors/base.ts +57 -0
- package/src/errors/block.test.ts +24 -0
- package/src/errors/block.ts +18 -0
- package/src/errors/contract.ts +125 -0
- package/src/errors/data.ts +20 -0
- package/src/errors/encoding.ts +60 -0
- package/src/errors/index.ts +77 -0
- package/src/errors/log.ts +8 -0
- package/src/errors/request.test.ts +331 -0
- package/src/errors/request.ts +163 -0
- package/src/errors/rpc.test.ts +88 -0
- package/src/errors/rpc.ts +113 -0
- package/src/errors/transaction.test.ts +83 -0
- package/src/errors/transaction.ts +54 -0
- package/src/errors/transport.test.ts +12 -0
- package/src/errors/transport.ts +12 -0
- package/src/index.test.ts +214 -0
- package/src/index.ts +373 -0
- package/src/public.ts +80 -0
- package/src/test.ts +51 -0
- package/src/types/block.ts +71 -0
- package/src/types/chain.ts +6 -0
- package/src/types/contract.ts +342 -0
- package/src/types/eip1193.ts +1041 -0
- package/src/types/fee.ts +47 -0
- package/src/types/filter.ts +8 -0
- package/src/types/formatter.ts +23 -0
- package/src/types/index.ts +78 -0
- package/src/types/log.ts +22 -0
- package/src/types/misc.ts +5 -0
- package/src/types/rpc.ts +35 -0
- package/src/types/transaction.ts +145 -0
- package/src/types/utils.ts +67 -0
- package/src/types/window.ts +9 -0
- package/src/utils/abi/decodeAbi.bench.ts +135 -0
- package/src/utils/abi/decodeAbi.test.ts +1615 -0
- package/src/utils/abi/decodeAbi.ts +296 -0
- package/src/utils/abi/decodeDeployData.test.ts +159 -0
- package/src/utils/abi/decodeDeployData.ts +41 -0
- package/src/utils/abi/decodeErrorResult.test.ts +130 -0
- package/src/utils/abi/decodeErrorResult.ts +28 -0
- package/src/utils/abi/decodeFunctionData.test.ts +140 -0
- package/src/utils/abi/decodeFunctionData.ts +29 -0
- package/src/utils/abi/decodeFunctionResult.test.ts +262 -0
- package/src/utils/abi/decodeFunctionResult.ts +53 -0
- package/src/utils/abi/encodeAbi.bench.ts +163 -0
- package/src/utils/abi/encodeAbi.test.ts +1448 -0
- package/src/utils/abi/encodeAbi.ts +264 -0
- package/src/utils/abi/encodeDeployData.test.ts +131 -0
- package/src/utils/abi/encodeDeployData.ts +37 -0
- package/src/utils/abi/encodeErrorResult.test.ts +197 -0
- package/src/utils/abi/encodeErrorResult.ts +40 -0
- package/src/utils/abi/encodeEventTopics.test.ts +348 -0
- package/src/utils/abi/encodeEventTopics.ts +69 -0
- package/src/utils/abi/encodeFunctionData.test.ts +140 -0
- package/src/utils/abi/encodeFunctionData.ts +38 -0
- package/src/utils/abi/encodeFunctionResult.test.ts +284 -0
- package/src/utils/abi/encodeFunctionResult.ts +39 -0
- package/src/utils/abi/formatAbiItem.test.ts +335 -0
- package/src/utils/abi/formatAbiItem.ts +41 -0
- package/src/utils/abi/formatAbiItemWithArgs.test.ts +291 -0
- package/src/utils/abi/formatAbiItemWithArgs.ts +27 -0
- package/src/utils/abi/getAbiItem.ts +5 -0
- package/src/utils/abi/index.test.ts +23 -0
- package/src/utils/abi/index.ts +38 -0
- package/src/utils/address/getAddress.bench.ts +22 -0
- package/src/utils/address/getAddress.test.ts +46 -0
- package/src/utils/address/getAddress.ts +28 -0
- package/src/utils/address/getContractAddress.bench.ts +20 -0
- package/src/utils/address/getContractAddress.test.ts +78 -0
- package/src/utils/address/getContractAddress.ts +59 -0
- package/src/utils/address/index.test.ts +17 -0
- package/src/utils/address/index.ts +16 -0
- package/src/utils/address/isAddress.test.ts +10 -0
- package/src/utils/address/isAddress.ts +10 -0
- package/src/utils/address/isAddressEqual.test.ts +55 -0
- package/src/utils/address/isAddressEqual.ts +6 -0
- package/src/utils/buildRequest.test.ts +365 -0
- package/src/utils/buildRequest.ts +45 -0
- package/src/utils/chain.test.ts +43 -0
- package/src/utils/chain.ts +8 -0
- package/src/utils/contract/extractFunctionParts.test.ts +109 -0
- package/src/utils/contract/extractFunctionParts.ts +27 -0
- package/src/utils/contract/getContractError.test.ts +97 -0
- package/src/utils/contract/getContractError.ts +66 -0
- package/src/utils/contract/index.test.ts +15 -0
- package/src/utils/contract/index.ts +8 -0
- package/src/utils/data/concat.test.ts +35 -0
- package/src/utils/data/concat.ts +34 -0
- package/src/utils/data/index.test.ts +23 -0
- package/src/utils/data/index.ts +13 -0
- package/src/utils/data/isBytes.test.ts +9 -0
- package/src/utils/data/isBytes.ts +7 -0
- package/src/utils/data/isHex.test.ts +13 -0
- package/src/utils/data/isHex.ts +5 -0
- package/src/utils/data/pad.bench.ts +39 -0
- package/src/utils/data/pad.test.ts +367 -0
- package/src/utils/data/pad.ts +53 -0
- package/src/utils/data/size.test.ts +18 -0
- package/src/utils/data/size.ts +13 -0
- package/src/utils/data/slice.test.ts +203 -0
- package/src/utils/data/slice.ts +60 -0
- package/src/utils/data/trim.bench.ts +50 -0
- package/src/utils/data/trim.test.ts +175 -0
- package/src/utils/data/trim.ts +33 -0
- package/src/utils/encoding/decodeBytes.bench.ts +40 -0
- package/src/utils/encoding/decodeBytes.test.ts +144 -0
- package/src/utils/encoding/decodeBytes.ts +63 -0
- package/src/utils/encoding/decodeHex.bench.ts +24 -0
- package/src/utils/encoding/decodeHex.test.ts +167 -0
- package/src/utils/encoding/decodeHex.ts +76 -0
- package/src/utils/encoding/decodeRlp.bench.ts +34 -0
- package/src/utils/encoding/decodeRlp.test.ts +350 -0
- package/src/utils/encoding/decodeRlp.ts +121 -0
- package/src/utils/encoding/encodeBytes.bench.ts +41 -0
- package/src/utils/encoding/encodeBytes.test.ts +676 -0
- package/src/utils/encoding/encodeBytes.ts +59 -0
- package/src/utils/encoding/encodeHex.bench.ts +60 -0
- package/src/utils/encoding/encodeHex.test.ts +232 -0
- package/src/utils/encoding/encodeHex.ts +104 -0
- package/src/utils/encoding/encodeRlp.bench.ts +54 -0
- package/src/utils/encoding/encodeRlp.test.ts +254 -0
- package/src/utils/encoding/encodeRlp.ts +48 -0
- package/src/utils/encoding/index.test.ts +32 -0
- package/src/utils/encoding/index.ts +36 -0
- package/src/utils/formatters/block.bench.ts +51 -0
- package/src/utils/formatters/block.test.ts +115 -0
- package/src/utils/formatters/block.ts +37 -0
- package/src/utils/formatters/extract.test.ts +14 -0
- package/src/utils/formatters/extract.ts +18 -0
- package/src/utils/formatters/feeHistory.test.ts +66 -0
- package/src/utils/formatters/feeHistory.ts +12 -0
- package/src/utils/formatters/format.test.ts +93 -0
- package/src/utils/formatters/format.ts +90 -0
- package/src/utils/formatters/index.test.ts +27 -0
- package/src/utils/formatters/index.ts +34 -0
- package/src/utils/formatters/log.test.ts +79 -0
- package/src/utils/formatters/log.ts +12 -0
- package/src/utils/formatters/transaction.test.ts +271 -0
- package/src/utils/formatters/transaction.ts +63 -0
- package/src/utils/formatters/transactionReceipt.bench.ts +73 -0
- package/src/utils/formatters/transactionReceipt.test.ts +151 -0
- package/src/utils/formatters/transactionReceipt.ts +63 -0
- package/src/utils/formatters/transactionRequest.bench.ts +29 -0
- package/src/utils/formatters/transactionRequest.test.ts +237 -0
- package/src/utils/formatters/transactionRequest.ts +56 -0
- package/src/utils/hash/getEventSignature.test.ts +61 -0
- package/src/utils/hash/getEventSignature.ts +4 -0
- package/src/utils/hash/getFunctionSignature.test.ts +22 -0
- package/src/utils/hash/getFunctionSignature.ts +5 -0
- package/src/utils/hash/hashFunction.test.ts +65 -0
- package/src/utils/hash/hashFunction.ts +12 -0
- package/src/utils/hash/index.test.ts +13 -0
- package/src/utils/hash/index.ts +5 -0
- package/src/utils/hash/keccak256.test.ts +59 -0
- package/src/utils/hash/keccak256.ts +23 -0
- package/src/utils/index.test.ts +110 -0
- package/src/utils/index.ts +137 -0
- package/src/utils/observe.test.ts +176 -0
- package/src/utils/observe.ts +66 -0
- package/src/utils/poll.test.ts +127 -0
- package/src/utils/poll.ts +42 -0
- package/src/utils/promise/index.test.ts +14 -0
- package/src/utils/promise/index.ts +3 -0
- package/src/utils/promise/withCache.test.ts +97 -0
- package/src/utils/promise/withCache.ts +73 -0
- package/src/utils/promise/withRetry.test.ts +231 -0
- package/src/utils/promise/withRetry.ts +61 -0
- package/src/utils/promise/withTimeout.test.ts +37 -0
- package/src/utils/promise/withTimeout.ts +39 -0
- package/src/utils/rpc.test.ts +992 -0
- package/src/utils/rpc.ts +292 -0
- package/src/utils/stringify.test.ts +13 -0
- package/src/utils/stringify.ts +5 -0
- package/src/utils/uid.ts +14 -0
- package/src/utils/unit/constants.test.ts +22 -0
- package/src/utils/unit/constants.ts +12 -0
- package/src/utils/unit/formatEther.test.ts +75 -0
- package/src/utils/unit/formatEther.ts +6 -0
- package/src/utils/unit/formatGwei.test.ts +32 -0
- package/src/utils/unit/formatGwei.ts +6 -0
- package/src/utils/unit/formatUnit.bench.ts +26 -0
- package/src/utils/unit/formatUnit.test.ts +40 -0
- package/src/utils/unit/formatUnit.ts +16 -0
- package/src/utils/unit/index.test.ts +28 -0
- package/src/utils/unit/index.ts +7 -0
- package/src/utils/unit/parseEther.test.ts +126 -0
- package/src/utils/unit/parseEther.ts +6 -0
- package/src/utils/unit/parseGwei.test.ts +50 -0
- package/src/utils/unit/parseGwei.ts +6 -0
- package/src/utils/unit/parseUnit.bench.ts +26 -0
- package/src/utils/unit/parseUnit.test.ts +54 -0
- package/src/utils/unit/parseUnit.ts +27 -0
- package/src/utils/wait.ts +3 -0
- package/src/wallet.ts +23 -0
- package/src/window.ts +1 -0
- package/utils/package.json +1 -1
- package/window/package.json +1 -1
- package/actions/package.json +0 -4
- package/dist/BaseError-7688f84e.d.ts +0 -18
- package/dist/actions/index.d.ts +0 -8
- package/dist/actions/index.js +0 -123
- package/dist/createWalletClient-915223f3.d.ts +0 -130
- package/dist/transactionRequest-ade896ac.d.ts +0 -44
@@ -8,10 +8,10 @@ var __publicField = (obj, key, value) => {
|
|
8
8
|
// package.json
|
9
9
|
var package_default = {
|
10
10
|
name: "viem",
|
11
|
-
description: "TypeScript
|
12
|
-
version: "0.0.1-alpha.
|
11
|
+
description: "TypeScript Interface for Ethereum",
|
12
|
+
version: "0.0.1-alpha.21",
|
13
13
|
scripts: {
|
14
|
-
anvil: "source .env && anvil --fork-url $
|
14
|
+
anvil: "source .env && anvil --fork-url $VITE_ANVIL_FORK_URL --fork-block-number $VITE_ANVIL_BLOCK_NUMBER --block-time $VITE_ANVIL_BLOCK_TIME",
|
15
15
|
bench: "vitest bench --no-threads",
|
16
16
|
"bench:ci": "CI=true vitest bench --no-threads",
|
17
17
|
build: "tsup",
|
@@ -27,10 +27,12 @@ var package_default = {
|
|
27
27
|
"playground:benchmark": "pnpm --filter playground-benchmark dev",
|
28
28
|
postinstall: "pnpm dev",
|
29
29
|
preinstall: "npx only-allow pnpm",
|
30
|
+
prepublishOnly: "pnpm ts-node scripts/generate-package-json.ts",
|
30
31
|
prepare: "npx simple-git-hooks",
|
31
32
|
test: "vitest dev --coverage --no-threads",
|
32
33
|
"test:ci": "CI=true vitest --coverage --no-threads",
|
33
34
|
"test:ui": "vitest dev --ui --no-threads",
|
35
|
+
"ts-node": "node --loader esbuild-register/loader -r esbuild-register",
|
34
36
|
typecheck: "tsc --noEmit"
|
35
37
|
},
|
36
38
|
files: [
|
@@ -38,6 +40,7 @@ var package_default = {
|
|
38
40
|
"/chains",
|
39
41
|
"/dist",
|
40
42
|
"/clients",
|
43
|
+
"/src",
|
41
44
|
"/types",
|
42
45
|
"/utils",
|
43
46
|
"/window"
|
@@ -45,38 +48,54 @@ var package_default = {
|
|
45
48
|
exports: {
|
46
49
|
".": {
|
47
50
|
types: "./dist/index.d.ts",
|
51
|
+
module: "./dist/index.mjs",
|
48
52
|
default: "./dist/index.js"
|
49
53
|
},
|
50
|
-
"./actions": {
|
51
|
-
types: "./dist/actions/index.d.ts",
|
52
|
-
default: "./dist/actions/index.js"
|
53
|
-
},
|
54
54
|
"./chains": {
|
55
55
|
types: "./dist/chains.d.ts",
|
56
|
+
module: "./dist/chains.mjs",
|
56
57
|
default: "./dist/chains.js"
|
57
58
|
},
|
58
59
|
"./clients": {
|
59
60
|
types: "./dist/clients/index.d.ts",
|
61
|
+
module: "./dist/clients/index.mjs",
|
60
62
|
default: "./dist/clients/index.js"
|
61
63
|
},
|
64
|
+
"./public": {
|
65
|
+
types: "./dist/public.d.ts",
|
66
|
+
module: "./dist/public.mjs",
|
67
|
+
default: "./dist/public.js"
|
68
|
+
},
|
69
|
+
"./test": {
|
70
|
+
types: "./dist/test.d.ts",
|
71
|
+
module: "./dist/test.mjs",
|
72
|
+
default: "./dist/test.js"
|
73
|
+
},
|
62
74
|
"./utils": {
|
63
75
|
types: "./dist/utils/index.d.ts",
|
76
|
+
module: "./dist/utils/index.mjs",
|
64
77
|
default: "./dist/utils/index.js"
|
65
78
|
},
|
79
|
+
"./wallet": {
|
80
|
+
types: "./dist/wallet.d.ts",
|
81
|
+
module: "./dist/wallet.mjs",
|
82
|
+
default: "./dist/wallet.js"
|
83
|
+
},
|
66
84
|
"./window": {
|
67
85
|
types: "./dist/window.d.ts",
|
86
|
+
module: "./dist/window.mjs",
|
68
87
|
default: "./dist/window.js"
|
69
88
|
},
|
70
89
|
"./package.json": "./package.json"
|
71
90
|
},
|
72
|
-
type: "module",
|
73
91
|
main: "dist/index.js",
|
92
|
+
module: "dist/index.mjs",
|
74
93
|
types: "dist/index.d.ts",
|
75
94
|
sideEffects: false,
|
76
95
|
dependencies: {
|
77
96
|
"@noble/hashes": "^1.1.2",
|
78
|
-
"@wagmi/chains": "
|
79
|
-
abitype: "
|
97
|
+
"@wagmi/chains": "~0.2.6",
|
98
|
+
abitype: "~0.2.5"
|
80
99
|
},
|
81
100
|
devDependencies: {
|
82
101
|
"@actions/core": "^1.10.0",
|
@@ -129,30 +148,706 @@ var package_default = {
|
|
129
148
|
}
|
130
149
|
};
|
131
150
|
|
132
|
-
// src/utils/
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
this
|
151
|
+
// src/utils/stringify.ts
|
152
|
+
function stringify(value) {
|
153
|
+
return JSON.stringify(
|
154
|
+
value,
|
155
|
+
(_, value2) => typeof value2 === "bigint" ? value2.toString() : value2
|
156
|
+
);
|
157
|
+
}
|
158
|
+
|
159
|
+
// src/errors/base.ts
|
160
|
+
var version = process.env.TEST ? "1.0.2" : package_default.version;
|
161
|
+
var BaseError = class extends Error {
|
162
|
+
constructor(humanMessage, args = {}) {
|
163
|
+
const details = args.cause instanceof BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details;
|
164
|
+
const docsPath5 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
|
165
|
+
const message = [
|
166
|
+
humanMessage,
|
167
|
+
...docsPath5 ? ["", `Docs: https://viem.sh${docsPath5}`] : [],
|
168
|
+
"",
|
169
|
+
...details ? [`Details: ${details}`] : [],
|
170
|
+
`Version: viem@${version}`,
|
171
|
+
...args.cause && !(args.cause instanceof BaseError) && Object.keys(args.cause).length > 0 ? [`Internal Error: ${stringify(args.cause)}`] : []
|
172
|
+
].join("\n");
|
173
|
+
super(message);
|
174
|
+
__publicField(this, "humanMessage");
|
175
|
+
__publicField(this, "details");
|
176
|
+
__publicField(this, "docsPath");
|
177
|
+
__publicField(this, "name", "ViemError");
|
178
|
+
if (args.cause)
|
179
|
+
this.cause = args.cause;
|
180
|
+
this.details = details;
|
181
|
+
this.docsPath = docsPath5;
|
182
|
+
this.humanMessage = humanMessage;
|
183
|
+
}
|
184
|
+
};
|
185
|
+
|
186
|
+
// src/errors/abi.ts
|
187
|
+
var AbiConstructorNotFoundError = class extends BaseError {
|
188
|
+
constructor({ docsPath: docsPath5 }) {
|
189
|
+
super(
|
190
|
+
[
|
191
|
+
"A constructor was not found on the ABI.",
|
192
|
+
"Make sure you are using the correct ABI and that the constructor exists on it."
|
193
|
+
].join("\n"),
|
194
|
+
{
|
195
|
+
docsPath: docsPath5
|
196
|
+
}
|
197
|
+
);
|
198
|
+
__publicField(this, "name", "AbiConstructorNotFoundError");
|
199
|
+
}
|
200
|
+
};
|
201
|
+
var AbiConstructorParamsNotFoundError = class extends BaseError {
|
202
|
+
constructor({ docsPath: docsPath5 }) {
|
203
|
+
super(
|
204
|
+
[
|
205
|
+
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
|
206
|
+
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
|
207
|
+
].join("\n"),
|
208
|
+
{
|
209
|
+
docsPath: docsPath5
|
210
|
+
}
|
211
|
+
);
|
212
|
+
__publicField(this, "name", "AbiConstructorParamsNotFoundError");
|
213
|
+
}
|
214
|
+
};
|
215
|
+
var AbiDecodingDataSizeInvalidError = class extends BaseError {
|
216
|
+
constructor(size2) {
|
217
|
+
super(
|
218
|
+
[
|
219
|
+
`Data size of ${size2} bytes is invalid.`,
|
220
|
+
"Size must be in increments of 32 bytes (size % 32 === 0)."
|
221
|
+
].join("\n")
|
222
|
+
);
|
223
|
+
__publicField(this, "name", "AbiDecodingDataSizeInvalidError");
|
224
|
+
}
|
225
|
+
};
|
226
|
+
var AbiDecodingZeroDataError = class extends BaseError {
|
227
|
+
constructor() {
|
228
|
+
super('Cannot decode zero data ("0x") with ABI parameters.');
|
229
|
+
__publicField(this, "name", "AbiDecodingZeroDataError");
|
230
|
+
}
|
231
|
+
};
|
232
|
+
var AbiEncodingArrayLengthMismatchError = class extends BaseError {
|
233
|
+
constructor({
|
234
|
+
expectedLength,
|
235
|
+
givenLength,
|
236
|
+
type
|
237
|
+
}) {
|
238
|
+
super(
|
239
|
+
[
|
240
|
+
`ABI encoding array length mismatch for type ${type}.`,
|
241
|
+
`Expected length: ${expectedLength}`,
|
242
|
+
`Given length: ${givenLength}`
|
243
|
+
].join("\n")
|
244
|
+
);
|
245
|
+
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
246
|
+
}
|
247
|
+
};
|
248
|
+
var AbiEncodingLengthMismatchError = class extends BaseError {
|
249
|
+
constructor({
|
250
|
+
expectedLength,
|
251
|
+
givenLength
|
252
|
+
}) {
|
253
|
+
super(
|
254
|
+
[
|
255
|
+
"ABI encoding params/values length mismatch.",
|
256
|
+
`Expected length (params): ${expectedLength}`,
|
257
|
+
`Given length (values): ${givenLength}`
|
258
|
+
].join("\n")
|
259
|
+
);
|
260
|
+
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
261
|
+
}
|
262
|
+
};
|
263
|
+
var AbiErrorInputsNotFoundError = class extends BaseError {
|
264
|
+
constructor(errorName, { docsPath: docsPath5 }) {
|
265
|
+
super(
|
266
|
+
[
|
267
|
+
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
|
268
|
+
"Cannot encode error result without knowing what the parameter types are.",
|
269
|
+
"Make sure you are using the correct ABI and that the inputs exist on it."
|
270
|
+
].join("\n"),
|
271
|
+
{
|
272
|
+
docsPath: docsPath5
|
273
|
+
}
|
274
|
+
);
|
275
|
+
__publicField(this, "name", "AbiErrorInputsNotFoundError");
|
276
|
+
}
|
277
|
+
};
|
278
|
+
var AbiErrorNotFoundError = class extends BaseError {
|
279
|
+
constructor(errorName, { docsPath: docsPath5 }) {
|
280
|
+
super(
|
281
|
+
[
|
282
|
+
`Error "${errorName}" not found on ABI.`,
|
283
|
+
"Make sure you are using the correct ABI and that the error exists on it."
|
284
|
+
].join("\n"),
|
285
|
+
{
|
286
|
+
docsPath: docsPath5
|
287
|
+
}
|
288
|
+
);
|
289
|
+
__publicField(this, "name", "AbiErrorNotFoundError");
|
290
|
+
}
|
291
|
+
};
|
292
|
+
var AbiErrorSignatureNotFoundError = class extends BaseError {
|
293
|
+
constructor(signature, { docsPath: docsPath5 }) {
|
294
|
+
super(
|
295
|
+
[
|
296
|
+
`Encoded error signature "${signature}" not found on ABI.`,
|
297
|
+
"Make sure you are using the correct ABI and that the error exists on it.",
|
298
|
+
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
299
|
+
].join("\n"),
|
300
|
+
{
|
301
|
+
docsPath: docsPath5
|
302
|
+
}
|
303
|
+
);
|
304
|
+
__publicField(this, "name", "AbiErrorSignatureNotFoundError");
|
305
|
+
}
|
306
|
+
};
|
307
|
+
var AbiEventNotFoundError = class extends BaseError {
|
308
|
+
constructor(eventName, { docsPath: docsPath5 }) {
|
309
|
+
super(
|
310
|
+
[
|
311
|
+
`Event "${eventName}" not found on ABI.`,
|
312
|
+
"Make sure you are using the correct ABI and that the event exists on it."
|
313
|
+
].join("\n"),
|
314
|
+
{
|
315
|
+
docsPath: docsPath5
|
316
|
+
}
|
317
|
+
);
|
318
|
+
__publicField(this, "name", "AbiEventNotFoundError");
|
319
|
+
}
|
320
|
+
};
|
321
|
+
var AbiFunctionNotFoundError = class extends BaseError {
|
322
|
+
constructor(functionName, { docsPath: docsPath5 }) {
|
323
|
+
super(
|
324
|
+
[
|
325
|
+
`Function "${functionName}" not found on ABI.`,
|
326
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
327
|
+
].join("\n"),
|
328
|
+
{
|
329
|
+
docsPath: docsPath5
|
330
|
+
}
|
331
|
+
);
|
332
|
+
__publicField(this, "name", "AbiFunctionNotFoundError");
|
333
|
+
}
|
334
|
+
};
|
335
|
+
var AbiFunctionOutputsNotFoundError = class extends BaseError {
|
336
|
+
constructor(functionName, { docsPath: docsPath5 }) {
|
337
|
+
super(
|
338
|
+
[
|
339
|
+
`Function "${functionName}" does not contain any \`outputs\` on ABI.`,
|
340
|
+
"Cannot decode function result without knowing what the parameter types are.",
|
341
|
+
"Make sure you are using the correct ABI and that the function exists on it."
|
342
|
+
].join("\n"),
|
343
|
+
{
|
344
|
+
docsPath: docsPath5
|
345
|
+
}
|
346
|
+
);
|
347
|
+
__publicField(this, "name", "AbiFunctionOutputsNotFoundError");
|
348
|
+
}
|
349
|
+
};
|
350
|
+
var AbiFunctionSignatureNotFoundError = class extends BaseError {
|
351
|
+
constructor(signature, { docsPath: docsPath5 }) {
|
352
|
+
super(
|
353
|
+
[
|
354
|
+
`Encoded function signature "${signature}" not found on ABI.`,
|
355
|
+
"Make sure you are using the correct ABI and that the function exists on it.",
|
356
|
+
`You can look up the signature "${signature}" here: https://sig.eth.samczsun.com/.`
|
357
|
+
].join("\n"),
|
358
|
+
{
|
359
|
+
docsPath: docsPath5
|
360
|
+
}
|
361
|
+
);
|
362
|
+
__publicField(this, "name", "AbiFunctionSignatureNotFoundError");
|
363
|
+
}
|
364
|
+
};
|
365
|
+
var InvalidAbiEncodingTypeError = class extends BaseError {
|
366
|
+
constructor(type, { docsPath: docsPath5 }) {
|
367
|
+
super(
|
368
|
+
[
|
369
|
+
`Type "${type}" is not a valid encoding type.`,
|
370
|
+
"Please provide a valid ABI type."
|
371
|
+
].join("\n"),
|
372
|
+
{ docsPath: docsPath5 }
|
373
|
+
);
|
374
|
+
__publicField(this, "name", "InvalidAbiEncodingType");
|
375
|
+
}
|
376
|
+
};
|
377
|
+
var InvalidAbiDecodingTypeError = class extends BaseError {
|
378
|
+
constructor(type, { docsPath: docsPath5 }) {
|
379
|
+
super(
|
380
|
+
[
|
381
|
+
`Type "${type}" is not a valid decoding type.`,
|
382
|
+
"Please provide a valid ABI type."
|
383
|
+
].join("\n"),
|
384
|
+
{ docsPath: docsPath5 }
|
385
|
+
);
|
386
|
+
__publicField(this, "name", "InvalidAbiDecodingType");
|
387
|
+
}
|
388
|
+
};
|
389
|
+
var InvalidArrayError = class extends BaseError {
|
390
|
+
constructor(value) {
|
391
|
+
super([`Value "${value}" is not a valid array.`].join("\n"));
|
392
|
+
__publicField(this, "name", "InvalidArrayError");
|
393
|
+
}
|
394
|
+
};
|
395
|
+
var InvalidDefinitionTypeError = class extends BaseError {
|
396
|
+
constructor(type) {
|
397
|
+
super(
|
398
|
+
[
|
399
|
+
`"${type}" is not a valid definition type.`,
|
400
|
+
'Valid types: "function", "event", "error"'
|
401
|
+
].join("\n")
|
402
|
+
);
|
403
|
+
__publicField(this, "name", "InvalidDefinitionTypeError");
|
404
|
+
}
|
405
|
+
};
|
406
|
+
|
407
|
+
// src/errors/address.ts
|
408
|
+
var InvalidAddressError = class extends BaseError {
|
409
|
+
constructor({ address }) {
|
410
|
+
super(`Address "${address}" is invalid.`);
|
411
|
+
__publicField(this, "name", "InvalidAddressError");
|
412
|
+
}
|
413
|
+
};
|
414
|
+
|
415
|
+
// src/errors/block.ts
|
416
|
+
var BlockNotFoundError = class extends BaseError {
|
417
|
+
constructor({
|
418
|
+
blockHash,
|
419
|
+
blockNumber
|
420
|
+
}) {
|
421
|
+
let identifier = "Block";
|
422
|
+
if (blockHash)
|
423
|
+
identifier = `Block at hash "${blockHash}"`;
|
424
|
+
if (blockNumber)
|
425
|
+
identifier = `Block at number "${blockNumber}"`;
|
426
|
+
super(`${identifier} could not be found.`);
|
427
|
+
__publicField(this, "name", "BlockNotFoundError");
|
428
|
+
}
|
429
|
+
};
|
430
|
+
|
431
|
+
// src/errors/contract.ts
|
432
|
+
var ContractMethodExecutionError = class extends BaseError {
|
433
|
+
constructor(message, {
|
434
|
+
abi,
|
435
|
+
args,
|
436
|
+
cause,
|
437
|
+
contractAddress,
|
438
|
+
formattedArgs,
|
439
|
+
functionName,
|
440
|
+
functionWithParams,
|
441
|
+
sender
|
442
|
+
} = {}) {
|
443
|
+
super(
|
444
|
+
[
|
445
|
+
message,
|
446
|
+
" ",
|
447
|
+
sender && `Sender: ${sender}`,
|
448
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
449
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
450
|
+
formattedArgs && `Arguments: ${[...Array(functionName?.length ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`
|
451
|
+
].filter(Boolean).join("\n"),
|
452
|
+
{
|
453
|
+
cause
|
454
|
+
}
|
455
|
+
);
|
456
|
+
__publicField(this, "abi");
|
457
|
+
__publicField(this, "args");
|
458
|
+
__publicField(this, "contractAddress");
|
459
|
+
__publicField(this, "formattedArgs");
|
460
|
+
__publicField(this, "functionName");
|
461
|
+
__publicField(this, "reason");
|
462
|
+
__publicField(this, "sender");
|
463
|
+
__publicField(this, "name", "ContractMethodExecutionError");
|
464
|
+
if (message)
|
465
|
+
this.reason = message;
|
466
|
+
this.abi = abi;
|
467
|
+
this.args = args;
|
468
|
+
this.contractAddress = contractAddress;
|
469
|
+
this.functionName = functionName;
|
470
|
+
this.sender = sender;
|
471
|
+
}
|
472
|
+
};
|
473
|
+
var ContractMethodZeroDataError = class extends BaseError {
|
474
|
+
constructor({
|
475
|
+
abi,
|
476
|
+
args,
|
477
|
+
cause,
|
478
|
+
contractAddress,
|
479
|
+
functionName,
|
480
|
+
functionWithParams
|
481
|
+
} = {}) {
|
482
|
+
super(
|
483
|
+
[
|
484
|
+
`The contract method "${functionName}" returned no data ("0x"). This could be due to any of the following:`,
|
485
|
+
`- The contract does not have the function "${functionName}",`,
|
486
|
+
"- The parameters passed to the contract function may be invalid, or",
|
487
|
+
"- The address is not a contract.",
|
488
|
+
" ",
|
489
|
+
contractAddress && `Contract: ${process.env.TEST ? "0x0000000000000000000000000000000000000000" : contractAddress}`,
|
490
|
+
functionWithParams && `Function: ${functionWithParams}`,
|
491
|
+
functionWithParams && ` > "0x"`
|
492
|
+
].filter(Boolean).join("\n"),
|
493
|
+
{
|
494
|
+
cause
|
495
|
+
}
|
496
|
+
);
|
497
|
+
__publicField(this, "abi");
|
498
|
+
__publicField(this, "args");
|
499
|
+
__publicField(this, "contractAddress");
|
500
|
+
__publicField(this, "functionName");
|
501
|
+
__publicField(this, "functionWithParams");
|
502
|
+
__publicField(this, "name", "ContractMethodZeroDataError");
|
503
|
+
this.abi = abi;
|
504
|
+
this.args = args;
|
505
|
+
this.contractAddress = contractAddress;
|
506
|
+
this.functionName = functionName;
|
507
|
+
}
|
508
|
+
};
|
509
|
+
|
510
|
+
// src/errors/data.ts
|
511
|
+
var SizeExceedsPaddingSizeError = class extends BaseError {
|
512
|
+
constructor({
|
513
|
+
size: size2,
|
514
|
+
targetSize,
|
515
|
+
type
|
516
|
+
}) {
|
517
|
+
super(
|
518
|
+
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
|
519
|
+
);
|
520
|
+
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
521
|
+
}
|
522
|
+
};
|
523
|
+
|
524
|
+
// src/errors/encoding.ts
|
525
|
+
var DataLengthTooLongError = class extends BaseError {
|
526
|
+
constructor({ consumed, length }) {
|
527
|
+
super(
|
528
|
+
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
529
|
+
);
|
530
|
+
__publicField(this, "name", "DataLengthTooLongError");
|
531
|
+
}
|
532
|
+
};
|
533
|
+
var DataLengthTooShortError = class extends BaseError {
|
534
|
+
constructor({ length, dataLength }) {
|
535
|
+
super(
|
536
|
+
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
537
|
+
);
|
538
|
+
__publicField(this, "name", "DataLengthTooShortError");
|
539
|
+
}
|
540
|
+
};
|
541
|
+
var InvalidBytesBooleanError = class extends BaseError {
|
542
|
+
constructor(bytes) {
|
543
|
+
super(
|
544
|
+
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
545
|
+
);
|
546
|
+
__publicField(this, "name", "InvalidBytesBooleanError");
|
547
|
+
}
|
548
|
+
};
|
549
|
+
var InvalidHexBooleanError = class extends BaseError {
|
550
|
+
constructor(hex) {
|
551
|
+
super(
|
552
|
+
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
553
|
+
);
|
554
|
+
__publicField(this, "name", "InvalidHexBooleanError");
|
555
|
+
}
|
556
|
+
};
|
557
|
+
var InvalidHexValueError = class extends BaseError {
|
558
|
+
constructor(value) {
|
559
|
+
super(
|
560
|
+
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
561
|
+
);
|
562
|
+
__publicField(this, "name", "InvalidHexValueError");
|
563
|
+
}
|
564
|
+
};
|
565
|
+
var OffsetOutOfBoundsError = class extends BaseError {
|
566
|
+
constructor({ nextOffset, offset }) {
|
567
|
+
super(
|
568
|
+
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
569
|
+
);
|
570
|
+
__publicField(this, "name", "OffsetOutOfBoundsError");
|
571
|
+
}
|
572
|
+
};
|
573
|
+
|
574
|
+
// src/errors/log.ts
|
575
|
+
var FilterTypeNotSupportedError = class extends BaseError {
|
576
|
+
constructor(type) {
|
577
|
+
super(`Filter type "${type}" is not supported.`);
|
578
|
+
__publicField(this, "name", "FilterTypeNotSupportedError");
|
579
|
+
}
|
580
|
+
};
|
581
|
+
|
582
|
+
// src/errors/request.ts
|
583
|
+
var RequestError = class extends BaseError {
|
584
|
+
constructor(err, { docsPath: docsPath5, humanMessage }) {
|
585
|
+
super(humanMessage, {
|
586
|
+
cause: err,
|
587
|
+
docsPath: docsPath5
|
588
|
+
});
|
589
|
+
this.name = err.name;
|
590
|
+
}
|
591
|
+
};
|
592
|
+
var RpcRequestError = class extends RequestError {
|
593
|
+
constructor(err, { docsPath: docsPath5, humanMessage }) {
|
594
|
+
super(err, { docsPath: docsPath5, humanMessage });
|
595
|
+
__publicField(this, "code");
|
596
|
+
this.code = err.code;
|
597
|
+
this.name = err.name;
|
598
|
+
}
|
599
|
+
};
|
600
|
+
var ParseRpcError = class extends RpcRequestError {
|
601
|
+
constructor(err) {
|
602
|
+
super(err, {
|
603
|
+
humanMessage: "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."
|
604
|
+
});
|
605
|
+
__publicField(this, "name", "ParseRpcError");
|
606
|
+
__publicField(this, "code", -32700);
|
607
|
+
}
|
608
|
+
};
|
609
|
+
var InvalidRequestRpcError = class extends RpcRequestError {
|
610
|
+
constructor(err) {
|
611
|
+
super(err, { humanMessage: "JSON is not a valid request object." });
|
612
|
+
__publicField(this, "name", "InvalidRequestRpcError");
|
613
|
+
__publicField(this, "code", -32600);
|
614
|
+
}
|
615
|
+
};
|
616
|
+
var MethodNotFoundRpcError = class extends RpcRequestError {
|
617
|
+
constructor(err) {
|
618
|
+
super(err, {
|
619
|
+
humanMessage: "The method does not exist / is not available."
|
620
|
+
});
|
621
|
+
__publicField(this, "name", "MethodNotFoundRpcError");
|
622
|
+
__publicField(this, "code", -32601);
|
623
|
+
}
|
624
|
+
};
|
625
|
+
var InvalidParamsRpcError = class extends RpcRequestError {
|
626
|
+
constructor(err) {
|
627
|
+
super(err, {
|
628
|
+
humanMessage: [
|
629
|
+
"Invalid parameters were provided to the RPC method.",
|
630
|
+
"Double check you have provided the correct parameters."
|
631
|
+
].join("\n")
|
632
|
+
});
|
633
|
+
__publicField(this, "name", "InvalidParamsRpcError");
|
634
|
+
__publicField(this, "code", -32602);
|
635
|
+
}
|
636
|
+
};
|
637
|
+
var InternalRpcError = class extends RpcRequestError {
|
638
|
+
constructor(err) {
|
639
|
+
super(err, { humanMessage: "An internal error was received." });
|
640
|
+
__publicField(this, "name", "InternalRpcError");
|
641
|
+
__publicField(this, "code", -32603);
|
642
|
+
}
|
643
|
+
};
|
644
|
+
var InvalidInputRpcError = class extends RpcRequestError {
|
645
|
+
constructor(err) {
|
646
|
+
super(err, {
|
647
|
+
humanMessage: [
|
648
|
+
"Missing or invalid parameters.",
|
649
|
+
"Double check you have provided the correct parameters."
|
650
|
+
].join("\n")
|
651
|
+
});
|
652
|
+
__publicField(this, "name", "InvalidInputRpcError");
|
653
|
+
__publicField(this, "code", -32e3);
|
654
|
+
}
|
655
|
+
};
|
656
|
+
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
657
|
+
constructor(err) {
|
658
|
+
super(err, { humanMessage: "Requested resource not found." });
|
659
|
+
__publicField(this, "name", "ResourceNotFoundRpcError");
|
660
|
+
__publicField(this, "code", -32001);
|
661
|
+
}
|
662
|
+
};
|
663
|
+
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
664
|
+
constructor(err) {
|
665
|
+
super(err, { humanMessage: "Requested resource not available." });
|
666
|
+
__publicField(this, "name", "ResourceUnavailableRpcError");
|
667
|
+
__publicField(this, "code", -32002);
|
668
|
+
}
|
669
|
+
};
|
670
|
+
var TransactionRejectedRpcError = class extends RpcRequestError {
|
671
|
+
constructor(err) {
|
672
|
+
super(err, { humanMessage: "Transaction creation failed." });
|
673
|
+
__publicField(this, "name", "TransactionRejectedRpcError");
|
674
|
+
__publicField(this, "code", -32003);
|
675
|
+
}
|
676
|
+
};
|
677
|
+
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
678
|
+
constructor(err) {
|
679
|
+
super(err, { humanMessage: "Method is not implemented." });
|
680
|
+
__publicField(this, "name", "MethodNotSupportedRpcError");
|
681
|
+
__publicField(this, "code", -32004);
|
682
|
+
}
|
683
|
+
};
|
684
|
+
var LimitExceededRpcError = class extends RpcRequestError {
|
685
|
+
constructor(err) {
|
686
|
+
super(err, { humanMessage: "Request exceeds defined limit." });
|
687
|
+
__publicField(this, "name", "LimitExceededRpcError");
|
688
|
+
__publicField(this, "code", -32005);
|
689
|
+
}
|
690
|
+
};
|
691
|
+
var JsonRpcVersionUnsupportedError = class extends RpcRequestError {
|
692
|
+
constructor(err) {
|
693
|
+
super(err, {
|
694
|
+
humanMessage: "Version of JSON-RPC protocol is not supported."
|
695
|
+
});
|
696
|
+
__publicField(this, "name", "JsonRpcVersionUnsupportedError");
|
697
|
+
__publicField(this, "code", -32006);
|
698
|
+
}
|
699
|
+
};
|
700
|
+
var UnknownRpcError = class extends RequestError {
|
701
|
+
constructor(err) {
|
702
|
+
super(err, {
|
703
|
+
humanMessage: "An unknown RPC error occurred."
|
704
|
+
});
|
705
|
+
__publicField(this, "name", "UnknownRpcError");
|
706
|
+
}
|
707
|
+
};
|
708
|
+
|
709
|
+
// src/errors/rpc.ts
|
710
|
+
var HttpRequestError = class extends BaseError {
|
711
|
+
constructor({
|
712
|
+
body,
|
713
|
+
details,
|
714
|
+
status,
|
715
|
+
url
|
716
|
+
}) {
|
717
|
+
super(
|
718
|
+
[
|
719
|
+
"HTTP request failed.",
|
720
|
+
"",
|
721
|
+
`Status: ${status}`,
|
722
|
+
`URL: ${url}`,
|
723
|
+
`Request body: ${stringify(body)}`
|
724
|
+
].join("\n"),
|
725
|
+
{
|
726
|
+
details
|
727
|
+
}
|
728
|
+
);
|
729
|
+
__publicField(this, "name", "HttpRequestError");
|
730
|
+
__publicField(this, "status");
|
731
|
+
this.status = status;
|
732
|
+
}
|
733
|
+
};
|
734
|
+
var WebSocketRequestError = class extends BaseError {
|
735
|
+
constructor({
|
736
|
+
body,
|
737
|
+
details,
|
738
|
+
url
|
739
|
+
}) {
|
740
|
+
super(
|
741
|
+
[
|
742
|
+
"WebSocket request failed.",
|
743
|
+
"",
|
744
|
+
`URL: ${url}`,
|
745
|
+
`Request body: ${stringify(body)}`
|
746
|
+
].join("\n"),
|
747
|
+
{
|
748
|
+
details
|
749
|
+
}
|
750
|
+
);
|
751
|
+
__publicField(this, "name", "WebSocketRequestError");
|
752
|
+
}
|
753
|
+
};
|
754
|
+
var RpcError = class extends BaseError {
|
755
|
+
constructor({
|
756
|
+
body,
|
757
|
+
error,
|
758
|
+
url
|
759
|
+
}) {
|
760
|
+
super(
|
761
|
+
[
|
762
|
+
"RPC Request failed.",
|
763
|
+
"",
|
764
|
+
`URL: ${url}`,
|
765
|
+
`Request body: ${stringify(body)}`
|
766
|
+
].join("\n"),
|
767
|
+
{
|
768
|
+
cause: error,
|
769
|
+
details: error.message
|
770
|
+
}
|
771
|
+
);
|
772
|
+
__publicField(this, "code");
|
773
|
+
__publicField(this, "name", "RpcError");
|
774
|
+
this.code = error.code;
|
775
|
+
}
|
776
|
+
};
|
777
|
+
var TimeoutError = class extends BaseError {
|
778
|
+
constructor({
|
779
|
+
body,
|
780
|
+
url
|
781
|
+
}) {
|
782
|
+
super(
|
783
|
+
[
|
784
|
+
"The request took too long to respond.",
|
785
|
+
"",
|
786
|
+
`URL: ${url}`,
|
787
|
+
`Request body: ${stringify(body)}`
|
788
|
+
].join("\n"),
|
789
|
+
{
|
790
|
+
details: "The request timed out."
|
791
|
+
}
|
792
|
+
);
|
793
|
+
__publicField(this, "name", "TimeoutError");
|
794
|
+
}
|
795
|
+
};
|
796
|
+
|
797
|
+
// src/errors/transaction.ts
|
798
|
+
var InvalidGasArgumentsError = class extends BaseError {
|
799
|
+
constructor() {
|
800
|
+
super("`maxFeePerGas` cannot be less than `maxPriorityFeePerGas`");
|
801
|
+
__publicField(this, "name", "InvalidGasArgumentsError");
|
802
|
+
}
|
803
|
+
};
|
804
|
+
var TransactionNotFoundError = class extends BaseError {
|
805
|
+
constructor({
|
806
|
+
blockHash,
|
807
|
+
blockNumber,
|
808
|
+
blockTag,
|
809
|
+
hash: hash2,
|
810
|
+
index
|
811
|
+
}) {
|
812
|
+
let identifier = "Transaction";
|
813
|
+
if (blockTag && index !== void 0)
|
814
|
+
identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
|
815
|
+
if (blockHash && index !== void 0)
|
816
|
+
identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
|
817
|
+
if (blockNumber && index !== void 0)
|
818
|
+
identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
|
819
|
+
if (hash2)
|
820
|
+
identifier = `Transaction with hash "${hash2}"`;
|
821
|
+
super(`${identifier} could not be found.`);
|
822
|
+
__publicField(this, "name", "TransactionNotFoundError");
|
823
|
+
}
|
824
|
+
};
|
825
|
+
var TransactionReceiptNotFoundError = class extends BaseError {
|
826
|
+
constructor({ hash: hash2 }) {
|
827
|
+
super(
|
828
|
+
`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`
|
829
|
+
);
|
830
|
+
__publicField(this, "name", "TransactionReceiptNotFoundError");
|
831
|
+
}
|
832
|
+
};
|
833
|
+
var WaitForTransactionReceiptTimeoutError = class extends BaseError {
|
834
|
+
constructor({ hash: hash2 }) {
|
835
|
+
super(
|
836
|
+
`Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`
|
837
|
+
);
|
838
|
+
__publicField(this, "name", "WaitForTransactionReceiptTimeoutError");
|
839
|
+
}
|
840
|
+
};
|
841
|
+
|
842
|
+
// src/errors/transport.ts
|
843
|
+
var UrlRequiredError = class extends BaseError {
|
844
|
+
constructor() {
|
845
|
+
super(
|
846
|
+
"No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",
|
847
|
+
{
|
848
|
+
docsPath: "/docs/clients/intro"
|
849
|
+
}
|
850
|
+
);
|
156
851
|
}
|
157
852
|
};
|
158
853
|
|
@@ -233,18 +928,6 @@ function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
|
233
928
|
}
|
234
929
|
return paddedBytes;
|
235
930
|
}
|
236
|
-
var SizeExceedsPaddingSizeError = class extends BaseError {
|
237
|
-
constructor({
|
238
|
-
size: size2,
|
239
|
-
targetSize,
|
240
|
-
type
|
241
|
-
}) {
|
242
|
-
super(
|
243
|
-
`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`
|
244
|
-
);
|
245
|
-
__publicField(this, "name", "SizeExceedsPaddingSizeError");
|
246
|
-
}
|
247
|
-
};
|
248
931
|
|
249
932
|
// src/utils/data/trim.ts
|
250
933
|
function trim(hexOrBytes, { dir = "left" } = {}) {
|
@@ -457,14 +1140,6 @@ function hexToString(hex) {
|
|
457
1140
|
const bytes = hexToBytes(hex);
|
458
1141
|
return new TextDecoder().decode(bytes);
|
459
1142
|
}
|
460
|
-
var InvalidHexBooleanError = class extends BaseError {
|
461
|
-
constructor(hex) {
|
462
|
-
super(
|
463
|
-
`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`
|
464
|
-
);
|
465
|
-
__publicField(this, "name", "InvalidHexBooleanError");
|
466
|
-
}
|
467
|
-
};
|
468
1143
|
|
469
1144
|
// src/utils/encoding/decodeBytes.ts
|
470
1145
|
function decodeBytes(bytes, to) {
|
@@ -494,14 +1169,6 @@ function bytesToNumber(bytes) {
|
|
494
1169
|
function bytesToString(bytes) {
|
495
1170
|
return new TextDecoder().decode(bytes);
|
496
1171
|
}
|
497
|
-
var InvalidBytesBooleanError = class extends BaseError {
|
498
|
-
constructor(bytes) {
|
499
|
-
super(
|
500
|
-
`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`
|
501
|
-
);
|
502
|
-
__publicField(this, "name", "InvalidBytesBooleanError");
|
503
|
-
}
|
504
|
-
};
|
505
1172
|
|
506
1173
|
// src/utils/encoding/decodeRlp.ts
|
507
1174
|
function decodeRlp(value, to) {
|
@@ -583,40 +1250,8 @@ function rlpToBytes(bytes, offset = 0) {
|
|
583
1250
|
}
|
584
1251
|
return [result, consumed];
|
585
1252
|
}
|
586
|
-
var DataLengthTooLongError = class extends BaseError {
|
587
|
-
constructor({ consumed, length }) {
|
588
|
-
super(
|
589
|
-
`Consumed bytes (${consumed}) is shorter than data length (${length - 1}).`
|
590
|
-
);
|
591
|
-
__publicField(this, "name", "DataLengthTooLongError");
|
592
|
-
}
|
593
|
-
};
|
594
|
-
var DataLengthTooShortError = class extends BaseError {
|
595
|
-
constructor({ length, dataLength }) {
|
596
|
-
super(
|
597
|
-
`Data length (${dataLength - 1}) is shorter than prefix length (${length - 1}).`
|
598
|
-
);
|
599
|
-
__publicField(this, "name", "DataLengthTooShortError");
|
600
|
-
}
|
601
|
-
};
|
602
|
-
var InvalidHexValueError = class extends BaseError {
|
603
|
-
constructor(value) {
|
604
|
-
super(
|
605
|
-
`Hex value "${value}" is an odd length (${value.length}). It must be an even length.`
|
606
|
-
);
|
607
|
-
__publicField(this, "name", "InvalidHexValueError");
|
608
|
-
}
|
609
|
-
};
|
610
|
-
var OffsetOutOfBoundsError = class extends BaseError {
|
611
|
-
constructor({ nextOffset, offset }) {
|
612
|
-
super(
|
613
|
-
`Next offset (${nextOffset}) is greater than previous offset + consumed bytes (${offset})`
|
614
|
-
);
|
615
|
-
__publicField(this, "name", "OffsetOutOfBoundsError");
|
616
|
-
}
|
617
|
-
};
|
618
1253
|
|
619
|
-
// src/utils/
|
1254
|
+
// src/utils/contract/extractFunctionParts.ts
|
620
1255
|
var paramsRegex = /((function|event)\s)?(.*)(\((.*)\))/;
|
621
1256
|
function extractFunctionParts(def) {
|
622
1257
|
const parts = def.match(paramsRegex);
|
@@ -641,6 +1276,49 @@ function extractFunctionType(def) {
|
|
641
1276
|
return extractFunctionParts(def).type;
|
642
1277
|
}
|
643
1278
|
|
1279
|
+
// src/utils/contract/getContractError.ts
|
1280
|
+
function getContractError(err, {
|
1281
|
+
abi,
|
1282
|
+
address,
|
1283
|
+
args,
|
1284
|
+
functionName,
|
1285
|
+
sender
|
1286
|
+
}) {
|
1287
|
+
const { code, message } = err.cause || {};
|
1288
|
+
const abiItem = getAbiItem({ abi, name: functionName });
|
1289
|
+
const formattedArgs = abiItem ? formatAbiItemWithArgs({
|
1290
|
+
abiItem,
|
1291
|
+
args,
|
1292
|
+
includeFunctionName: false,
|
1293
|
+
includeName: false
|
1294
|
+
}) : void 0;
|
1295
|
+
const functionWithParams = abiItem ? formatAbiItem(abiItem, { includeName: true }) : void 0;
|
1296
|
+
if (err instanceof AbiDecodingZeroDataError) {
|
1297
|
+
return new ContractMethodZeroDataError({
|
1298
|
+
abi,
|
1299
|
+
args,
|
1300
|
+
cause: err,
|
1301
|
+
contractAddress: address,
|
1302
|
+
functionName,
|
1303
|
+
functionWithParams
|
1304
|
+
});
|
1305
|
+
}
|
1306
|
+
if (code === 3 || message?.includes("execution reverted")) {
|
1307
|
+
const message_ = message?.replace("execution reverted: ", "");
|
1308
|
+
return new ContractMethodExecutionError(message_, {
|
1309
|
+
abi,
|
1310
|
+
args,
|
1311
|
+
cause: err,
|
1312
|
+
contractAddress: address,
|
1313
|
+
formattedArgs,
|
1314
|
+
functionName,
|
1315
|
+
functionWithParams,
|
1316
|
+
sender
|
1317
|
+
});
|
1318
|
+
}
|
1319
|
+
return err;
|
1320
|
+
}
|
1321
|
+
|
644
1322
|
// src/utils/hash/keccak256.ts
|
645
1323
|
import { keccak_256 } from "@noble/hashes/sha3";
|
646
1324
|
function keccak256(value, to_) {
|
@@ -674,10 +1352,10 @@ function checksumAddress(address_) {
|
|
674
1352
|
const hash2 = keccak256(stringToBytes(hexAddress), "bytes");
|
675
1353
|
let address = hexAddress.split("");
|
676
1354
|
for (let i = 0; i < 40; i += 2) {
|
677
|
-
if (hash2?.[i >> 1] >> 4 >= 8) {
|
1355
|
+
if (hash2?.[i >> 1] >> 4 >= 8 && address[i]) {
|
678
1356
|
address[i] = address[i].toUpperCase();
|
679
1357
|
}
|
680
|
-
if ((hash2[i >> 1] & 15) >= 8) {
|
1358
|
+
if ((hash2[i >> 1] & 15) >= 8 && address[i + 1]) {
|
681
1359
|
address[i + 1] = address[i + 1].toUpperCase();
|
682
1360
|
}
|
683
1361
|
}
|
@@ -688,12 +1366,6 @@ function getAddress(address) {
|
|
688
1366
|
throw new InvalidAddressError({ address });
|
689
1367
|
return checksumAddress(address);
|
690
1368
|
}
|
691
|
-
var InvalidAddressError = class extends BaseError {
|
692
|
-
constructor({ address }) {
|
693
|
-
super(`Address "${address}" is invalid.`);
|
694
|
-
__publicField(this, "name", "InvalidAddressError");
|
695
|
-
}
|
696
|
-
};
|
697
1369
|
|
698
1370
|
// src/utils/address/getContractAddress.ts
|
699
1371
|
function getContractAddress(opts) {
|
@@ -756,7 +1428,7 @@ function encodeAbi({
|
|
756
1428
|
const preparedParams = prepareParams({ params, values });
|
757
1429
|
const data = encodeParams(preparedParams);
|
758
1430
|
if (data.length === 0)
|
759
|
-
return
|
1431
|
+
return "0x";
|
760
1432
|
return data;
|
761
1433
|
}
|
762
1434
|
function prepareParams({
|
@@ -799,7 +1471,9 @@ function prepareParam({
|
|
799
1471
|
if (param.type === "string") {
|
800
1472
|
return encodeString(value);
|
801
1473
|
}
|
802
|
-
throw new InvalidAbiEncodingTypeError(param.type
|
1474
|
+
throw new InvalidAbiEncodingTypeError(param.type, {
|
1475
|
+
docsPath: "/docs/contract/encodeAbi"
|
1476
|
+
});
|
803
1477
|
}
|
804
1478
|
function encodeParams(preparedParams) {
|
805
1479
|
let staticSize = 0;
|
@@ -825,6 +1499,9 @@ function encodeParams(preparedParams) {
|
|
825
1499
|
}
|
826
1500
|
return concat([...staticParams, ...dynamicParams]);
|
827
1501
|
}
|
1502
|
+
function encodeAddress(value) {
|
1503
|
+
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
1504
|
+
}
|
828
1505
|
function encodeArray(value, {
|
829
1506
|
length,
|
830
1507
|
param
|
@@ -863,125 +1540,84 @@ function encodeArray(value, {
|
|
863
1540
|
encoded: concat(preparedParams.map(({ encoded }) => encoded))
|
864
1541
|
};
|
865
1542
|
}
|
866
|
-
function encodeTuple(value, { param }) {
|
867
|
-
let dynamic = false;
|
868
|
-
let preparedParams = [];
|
869
|
-
for (let i = 0; i < param.components.length; i++) {
|
870
|
-
const param_ = param.components[i];
|
871
|
-
const index = Array.isArray(value) ? i : param_.name;
|
872
|
-
const preparedParam = prepareParam({
|
873
|
-
param: param_,
|
874
|
-
value: value[index]
|
875
|
-
});
|
876
|
-
preparedParams.push(preparedParam);
|
877
|
-
dynamic = preparedParam.dynamic;
|
878
|
-
}
|
879
|
-
return {
|
880
|
-
dynamic,
|
881
|
-
encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
|
882
|
-
};
|
883
|
-
}
|
884
|
-
function encodeAddress(value) {
|
885
|
-
return { dynamic: false, encoded: padHex(value.toLowerCase()) };
|
886
|
-
}
|
887
1543
|
function encodeBytes2(value, { param }) {
|
888
1544
|
const [_, size_] = param.type.split("bytes");
|
889
|
-
if (!size_)
|
1545
|
+
if (!size_) {
|
1546
|
+
const partsLength = Math.floor(size(value) / 32);
|
1547
|
+
const parts = [];
|
1548
|
+
for (let i = 0; i < partsLength + 1; i++) {
|
1549
|
+
parts.push(padHex(slice(value, i * 32, (i + 1) * 32), { dir: "right" }));
|
1550
|
+
}
|
890
1551
|
return {
|
891
1552
|
dynamic: true,
|
892
1553
|
encoded: concat([
|
893
1554
|
padHex(numberToHex(size(value), { size: 32 })),
|
894
|
-
|
1555
|
+
...parts
|
895
1556
|
])
|
896
1557
|
};
|
1558
|
+
}
|
897
1559
|
return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
|
898
1560
|
}
|
899
1561
|
function encodeBool(value) {
|
900
|
-
return { dynamic: false, encoded: padHex(boolToHex(value)) };
|
901
|
-
}
|
902
|
-
function encodeNumber(value, { signed }) {
|
903
|
-
return {
|
904
|
-
dynamic: false,
|
905
|
-
encoded: numberToHex(value, {
|
906
|
-
size: 32,
|
907
|
-
signed
|
908
|
-
})
|
909
|
-
};
|
910
|
-
}
|
911
|
-
function encodeString(value) {
|
912
|
-
return {
|
913
|
-
dynamic: true,
|
914
|
-
encoded: concat([
|
915
|
-
padHex(numberToHex(value.length, { size: 32 })),
|
916
|
-
padHex(stringToHex(value), { dir: "right" })
|
917
|
-
])
|
918
|
-
};
|
919
|
-
}
|
920
|
-
function
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
`ABI encoding array length mismatch for type ${type}.`,
|
933
|
-
`Expected length: ${expectedLength}`,
|
934
|
-
`Given length: ${givenLength}`
|
935
|
-
].join("\n")
|
936
|
-
);
|
937
|
-
__publicField(this, "name", "AbiEncodingArrayLengthMismatchError");
|
938
|
-
}
|
939
|
-
};
|
940
|
-
var AbiEncodingLengthMismatchError = class extends BaseError {
|
941
|
-
constructor({
|
942
|
-
expectedLength,
|
943
|
-
givenLength
|
944
|
-
}) {
|
945
|
-
super(
|
946
|
-
[
|
947
|
-
"ABI encoding params/values length mismatch.",
|
948
|
-
`Expected length (params): ${expectedLength}`,
|
949
|
-
`Given length (values): ${givenLength}`
|
950
|
-
].join("\n")
|
951
|
-
);
|
952
|
-
__publicField(this, "name", "AbiEncodingLengthMismatchError");
|
953
|
-
}
|
954
|
-
};
|
955
|
-
var InvalidAbiEncodingTypeError = class extends BaseError {
|
956
|
-
constructor(type) {
|
957
|
-
super(
|
958
|
-
[
|
959
|
-
`Type "${type}" is not a valid encoding type.`,
|
960
|
-
"Please provide a valid ABI type."
|
961
|
-
].join("\n"),
|
962
|
-
{ docsPath: "/docs/contract/encodeAbi#params" }
|
963
|
-
);
|
964
|
-
__publicField(this, "name", "InvalidAbiEncodingType");
|
965
|
-
}
|
966
|
-
};
|
967
|
-
var InvalidArrayError = class extends BaseError {
|
968
|
-
constructor(value) {
|
969
|
-
super([`Value "${value}" is not a valid array.`].join("\n"));
|
970
|
-
__publicField(this, "name", "InvalidArrayError");
|
1562
|
+
return { dynamic: false, encoded: padHex(boolToHex(value)) };
|
1563
|
+
}
|
1564
|
+
function encodeNumber(value, { signed }) {
|
1565
|
+
return {
|
1566
|
+
dynamic: false,
|
1567
|
+
encoded: numberToHex(value, {
|
1568
|
+
size: 32,
|
1569
|
+
signed
|
1570
|
+
})
|
1571
|
+
};
|
1572
|
+
}
|
1573
|
+
function encodeString(value) {
|
1574
|
+
return {
|
1575
|
+
dynamic: true,
|
1576
|
+
encoded: concat([
|
1577
|
+
padHex(numberToHex(value.length, { size: 32 })),
|
1578
|
+
padHex(stringToHex(value), { dir: "right" })
|
1579
|
+
])
|
1580
|
+
};
|
1581
|
+
}
|
1582
|
+
function encodeTuple(value, { param }) {
|
1583
|
+
let dynamic = false;
|
1584
|
+
let preparedParams = [];
|
1585
|
+
for (let i = 0; i < param.components.length; i++) {
|
1586
|
+
const param_ = param.components[i];
|
1587
|
+
const index = Array.isArray(value) ? i : param_.name;
|
1588
|
+
const preparedParam = prepareParam({
|
1589
|
+
param: param_,
|
1590
|
+
value: value[index]
|
1591
|
+
});
|
1592
|
+
preparedParams.push(preparedParam);
|
1593
|
+
dynamic = preparedParam.dynamic;
|
971
1594
|
}
|
972
|
-
|
1595
|
+
return {
|
1596
|
+
dynamic,
|
1597
|
+
encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
|
1598
|
+
};
|
1599
|
+
}
|
1600
|
+
function getArrayComponents(type) {
|
1601
|
+
const matches = type.match(/^(.*)\[(\d+)?\]$/);
|
1602
|
+
return matches ? [matches[2] ? Number(matches[2]) : null, matches[1]] : void 0;
|
1603
|
+
}
|
973
1604
|
|
974
1605
|
// src/utils/abi/decodeAbi.ts
|
975
1606
|
function decodeAbi({
|
976
1607
|
data,
|
977
1608
|
params
|
978
1609
|
}) {
|
1610
|
+
if (data === "0x" && params.length > 0)
|
1611
|
+
throw new AbiDecodingZeroDataError();
|
979
1612
|
if (size(data) % 32 !== 0)
|
980
1613
|
throw new AbiDecodingDataSizeInvalidError(size(data));
|
981
|
-
|
1614
|
+
const values = decodeParams({
|
982
1615
|
data,
|
983
1616
|
params
|
984
1617
|
});
|
1618
|
+
if (values.length === 0)
|
1619
|
+
return void 0;
|
1620
|
+
return values;
|
985
1621
|
}
|
986
1622
|
function decodeParams({
|
987
1623
|
data,
|
@@ -1030,7 +1666,12 @@ function decodeParam({
|
|
1030
1666
|
if (param.type === "bool") {
|
1031
1667
|
return decodeBool(value);
|
1032
1668
|
}
|
1033
|
-
throw new InvalidAbiDecodingTypeError(param.type
|
1669
|
+
throw new InvalidAbiDecodingTypeError(param.type, {
|
1670
|
+
docsPath: "/docs/contract/decodeAbi"
|
1671
|
+
});
|
1672
|
+
}
|
1673
|
+
function decodeAddress(value) {
|
1674
|
+
return { consumed: 32, value: checksumAddress(slice(value, -20)) };
|
1034
1675
|
}
|
1035
1676
|
function decodeArray(data, {
|
1036
1677
|
param,
|
@@ -1083,9 +1724,6 @@ function decodeArray(data, {
|
|
1083
1724
|
}
|
1084
1725
|
return { value, consumed };
|
1085
1726
|
}
|
1086
|
-
function decodeAddress(value) {
|
1087
|
-
return { consumed: 32, value: checksumAddress(trim(value)) };
|
1088
|
-
}
|
1089
1727
|
function decodeBool(value) {
|
1090
1728
|
return { consumed: 32, value: hexToBool(value) };
|
1091
1729
|
}
|
@@ -1161,277 +1799,283 @@ function hasDynamicChild(param) {
|
|
1161
1799
|
return true;
|
1162
1800
|
return false;
|
1163
1801
|
}
|
1164
|
-
var AbiDecodingDataSizeInvalidError = class extends BaseError {
|
1165
|
-
constructor(size2) {
|
1166
|
-
super(
|
1167
|
-
[
|
1168
|
-
`Data size of ${size2} bytes is invalid.`,
|
1169
|
-
"Size must be in increments of 32 bytes (size % 32 === 0)."
|
1170
|
-
].join("\n")
|
1171
|
-
);
|
1172
|
-
__publicField(this, "name", "AbiDecodingDataSizeInvalidError");
|
1173
|
-
}
|
1174
|
-
};
|
1175
|
-
var InvalidAbiDecodingTypeError = class extends BaseError {
|
1176
|
-
constructor(type) {
|
1177
|
-
super(
|
1178
|
-
[
|
1179
|
-
`Type "${type}" is not a valid decoding type.`,
|
1180
|
-
"Please provide a valid ABI type."
|
1181
|
-
].join("\n"),
|
1182
|
-
{ docsPath: "/docs/contract/decodeAbi#params" }
|
1183
|
-
);
|
1184
|
-
__publicField(this, "name", "InvalidAbiDecodingType");
|
1185
|
-
}
|
1186
|
-
};
|
1187
1802
|
|
1188
|
-
// src/utils/abi/
|
1189
|
-
function
|
1190
|
-
if (
|
1191
|
-
throw new InvalidDefinitionTypeError(
|
1192
|
-
return `${
|
1803
|
+
// src/utils/abi/formatAbiItem.ts
|
1804
|
+
function formatAbiItem(abiItem, { includeName = false } = {}) {
|
1805
|
+
if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
|
1806
|
+
throw new InvalidDefinitionTypeError(abiItem.type);
|
1807
|
+
return `${abiItem.name}(${getParams(abiItem.inputs, { includeName })})`;
|
1193
1808
|
}
|
1194
|
-
function getParams(params) {
|
1809
|
+
function getParams(params, { includeName }) {
|
1195
1810
|
if (!params)
|
1196
1811
|
return "";
|
1197
|
-
return params.map(getParam).join(",");
|
1812
|
+
return params.map((param) => getParam(param, { includeName })).join(includeName ? ", " : ",");
|
1198
1813
|
}
|
1199
|
-
function getParam(param) {
|
1814
|
+
function getParam(param, { includeName }) {
|
1200
1815
|
if (param.type.startsWith("tuple")) {
|
1201
1816
|
return `(${getParams(
|
1202
|
-
param.components
|
1817
|
+
param.components,
|
1818
|
+
{ includeName }
|
1203
1819
|
)})${param.type.slice("tuple".length)}`;
|
1204
1820
|
}
|
1205
|
-
return param.type;
|
1821
|
+
return param.type + (includeName && param.name ? ` ${param.name}` : "");
|
1206
1822
|
}
|
1207
|
-
var InvalidDefinitionTypeError = class extends BaseError {
|
1208
|
-
constructor(type) {
|
1209
|
-
super(
|
1210
|
-
[
|
1211
|
-
`"${type}" is not a valid definition type.`,
|
1212
|
-
'Valid types: "function", "event", "error"'
|
1213
|
-
].join("\n"),
|
1214
|
-
{
|
1215
|
-
docsPath: "/docs/contract/getDefinition"
|
1216
|
-
}
|
1217
|
-
);
|
1218
|
-
}
|
1219
|
-
};
|
1220
1823
|
|
1221
|
-
// src/utils/abi/
|
1222
|
-
function
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
const description = abi.find((x) => "name" in x && x.name === functionName);
|
1824
|
+
// src/utils/abi/decodeErrorResult.ts
|
1825
|
+
function decodeErrorResult({ abi, data }) {
|
1826
|
+
const signature = slice(data, 0, 4);
|
1827
|
+
const description = abi.find(
|
1828
|
+
(x) => signature === getFunctionSignature(formatAbiItem(x))
|
1829
|
+
);
|
1228
1830
|
if (!description)
|
1229
|
-
throw new
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
}
|
1236
|
-
return concatHex([signature, data ?? "0x"]);
|
1831
|
+
throw new AbiErrorSignatureNotFoundError(signature, {
|
1832
|
+
docsPath: "/docs/contract/decodeErrorResult"
|
1833
|
+
});
|
1834
|
+
return {
|
1835
|
+
errorName: description.name,
|
1836
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
|
1837
|
+
};
|
1237
1838
|
}
|
1238
|
-
var AbiFunctionNotFoundError = class extends BaseError {
|
1239
|
-
constructor(functionName) {
|
1240
|
-
super(
|
1241
|
-
[
|
1242
|
-
`Function "${functionName}" not found on ABI.`,
|
1243
|
-
"Make sure you are using the correct ABI and that the function exists on it."
|
1244
|
-
].join("\n"),
|
1245
|
-
{
|
1246
|
-
docsPath: "/docs/contract/encodeFunctionParams"
|
1247
|
-
}
|
1248
|
-
);
|
1249
|
-
}
|
1250
|
-
};
|
1251
1839
|
|
1252
|
-
// src/utils/
|
1253
|
-
function
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
if (err.code === -32602)
|
1266
|
-
throw new InvalidParamsRpcError(err);
|
1267
|
-
if (err.code === -32603)
|
1268
|
-
throw new InternalRpcError(err);
|
1269
|
-
if (err.code === -32e3)
|
1270
|
-
throw new InvalidInputRpcError(err);
|
1271
|
-
if (err.code === -32001)
|
1272
|
-
throw new ResourceNotFoundRpcError(err);
|
1273
|
-
if (err.code === -32002)
|
1274
|
-
throw new ResourceUnavailableRpcError(err);
|
1275
|
-
if (err.code === -32003)
|
1276
|
-
throw new TransactionRejectedRpcError(err);
|
1277
|
-
if (err.code === -32004)
|
1278
|
-
throw new MethodNotSupportedRpcError(err);
|
1279
|
-
if (err.code === -32005)
|
1280
|
-
throw new LimitExceededRpcError(err);
|
1281
|
-
if (err.code === -32006)
|
1282
|
-
throw new JsonRpcVersionUnsupportedError(err);
|
1283
|
-
if (err_ instanceof BaseError)
|
1284
|
-
throw err_;
|
1285
|
-
throw new UnknownRpcError(err);
|
1286
|
-
}
|
1840
|
+
// src/utils/abi/decodeFunctionData.ts
|
1841
|
+
function decodeFunctionData({ abi, data }) {
|
1842
|
+
const signature = slice(data, 0, 4);
|
1843
|
+
const description = abi.find(
|
1844
|
+
(x) => signature === getFunctionSignature(formatAbiItem(x))
|
1845
|
+
);
|
1846
|
+
if (!description)
|
1847
|
+
throw new AbiFunctionSignatureNotFoundError(signature, {
|
1848
|
+
docsPath: "/docs/contract/decodeFunctionData"
|
1849
|
+
});
|
1850
|
+
return {
|
1851
|
+
functionName: description.name,
|
1852
|
+
args: "inputs" in description && description.inputs && description.inputs.length > 0 ? decodeAbi({ data: slice(data, 4), params: description.inputs }) : void 0
|
1287
1853
|
};
|
1288
1854
|
}
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
}
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
}
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
humanMessage: [
|
1354
|
-
"Missing or invalid parameters.",
|
1355
|
-
"Double check you have provided the correct parameters."
|
1356
|
-
].join("\n")
|
1357
|
-
});
|
1358
|
-
__publicField(this, "name", "InvalidInputRpcError");
|
1359
|
-
__publicField(this, "code", -32e3);
|
1360
|
-
}
|
1361
|
-
};
|
1362
|
-
var ResourceNotFoundRpcError = class extends RpcRequestError {
|
1363
|
-
constructor(err) {
|
1364
|
-
super(err, { humanMessage: "Requested resource not found." });
|
1365
|
-
__publicField(this, "name", "ResourceNotFoundRpcError");
|
1366
|
-
__publicField(this, "code", -32001);
|
1367
|
-
}
|
1368
|
-
};
|
1369
|
-
var ResourceUnavailableRpcError = class extends RpcRequestError {
|
1370
|
-
constructor(err) {
|
1371
|
-
super(err, { humanMessage: "Requested resource not available." });
|
1372
|
-
__publicField(this, "name", "ResourceUnavailableRpcError");
|
1373
|
-
__publicField(this, "code", -32002);
|
1374
|
-
}
|
1375
|
-
};
|
1376
|
-
var TransactionRejectedRpcError = class extends RpcRequestError {
|
1377
|
-
constructor(err) {
|
1378
|
-
super(err, { humanMessage: "Transaction creation failed." });
|
1379
|
-
__publicField(this, "name", "TransactionRejectedRpcError");
|
1380
|
-
__publicField(this, "code", -32003);
|
1381
|
-
}
|
1382
|
-
};
|
1383
|
-
var MethodNotSupportedRpcError = class extends RpcRequestError {
|
1384
|
-
constructor(err) {
|
1385
|
-
super(err, { humanMessage: "Method is not implemented." });
|
1386
|
-
__publicField(this, "name", "MethodNotSupportedRpcError");
|
1387
|
-
__publicField(this, "code", -32004);
|
1388
|
-
}
|
1389
|
-
};
|
1390
|
-
var LimitExceededRpcError = class extends RpcRequestError {
|
1391
|
-
constructor(err) {
|
1392
|
-
super(err, { humanMessage: "Request exceeds defined limit." });
|
1393
|
-
__publicField(this, "name", "LimitExceededRpcError");
|
1394
|
-
__publicField(this, "code", -32005);
|
1855
|
+
|
1856
|
+
// src/utils/abi/decodeFunctionResult.ts
|
1857
|
+
var docsPath = "/docs/contract/decodeFunctionResult";
|
1858
|
+
function decodeFunctionResult({
|
1859
|
+
abi,
|
1860
|
+
functionName,
|
1861
|
+
data
|
1862
|
+
}) {
|
1863
|
+
const description = abi.find(
|
1864
|
+
(x) => "name" in x && x.name === functionName
|
1865
|
+
);
|
1866
|
+
if (!description)
|
1867
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath });
|
1868
|
+
if (!("outputs" in description))
|
1869
|
+
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath });
|
1870
|
+
const values = decodeAbi({ data, params: description.outputs });
|
1871
|
+
if (values && values.length > 1)
|
1872
|
+
return values;
|
1873
|
+
if (values && values.length === 1)
|
1874
|
+
return values[0];
|
1875
|
+
return void 0;
|
1876
|
+
}
|
1877
|
+
|
1878
|
+
// src/utils/abi/encodeDeployData.ts
|
1879
|
+
var docsPath2 = "/docs/contract/encodeDeployData";
|
1880
|
+
function encodeDeployData({
|
1881
|
+
abi,
|
1882
|
+
args,
|
1883
|
+
bytecode
|
1884
|
+
}) {
|
1885
|
+
if (!args || args.length === 0)
|
1886
|
+
return bytecode;
|
1887
|
+
const description = abi.find((x) => "type" in x && x.type === "constructor");
|
1888
|
+
if (!description)
|
1889
|
+
throw new AbiConstructorNotFoundError({ docsPath: docsPath2 });
|
1890
|
+
if (!("inputs" in description))
|
1891
|
+
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
1892
|
+
if (!description.inputs || description.inputs.length === 0)
|
1893
|
+
throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath2 });
|
1894
|
+
const data = encodeAbi({
|
1895
|
+
params: description.inputs,
|
1896
|
+
values: args
|
1897
|
+
});
|
1898
|
+
return concatHex([bytecode, data]);
|
1899
|
+
}
|
1900
|
+
|
1901
|
+
// src/utils/abi/getAbiItem.ts
|
1902
|
+
function getAbiItem({ abi, name }) {
|
1903
|
+
return abi.find((x) => "name" in x && x.name === name);
|
1904
|
+
}
|
1905
|
+
|
1906
|
+
// src/utils/abi/encodeErrorResult.ts
|
1907
|
+
var docsPath3 = "/docs/contract/encodeErrorResult";
|
1908
|
+
function encodeErrorResult({ abi, errorName, args }) {
|
1909
|
+
const description = getAbiItem({ abi, name: errorName });
|
1910
|
+
if (!description)
|
1911
|
+
throw new AbiErrorNotFoundError(errorName, { docsPath: docsPath3 });
|
1912
|
+
const definition = formatAbiItem(description);
|
1913
|
+
const signature = getFunctionSignature(definition);
|
1914
|
+
let data = "0x";
|
1915
|
+
if (args && args.length > 0) {
|
1916
|
+
if (!("inputs" in description && description.inputs))
|
1917
|
+
throw new AbiErrorInputsNotFoundError(errorName, { docsPath: docsPath3 });
|
1918
|
+
data = encodeAbi({ params: description.inputs, values: args });
|
1395
1919
|
}
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1920
|
+
return concatHex([signature, data]);
|
1921
|
+
}
|
1922
|
+
|
1923
|
+
// src/utils/abi/encodeEventTopics.ts
|
1924
|
+
function encodeEventTopics({ abi, eventName, args }) {
|
1925
|
+
const abiItem = getAbiItem({ abi, name: eventName });
|
1926
|
+
if (!abiItem)
|
1927
|
+
throw new AbiEventNotFoundError(eventName, {
|
1928
|
+
docsPath: "/docs/contract/encodeEventTopics"
|
1401
1929
|
});
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1930
|
+
const definition = formatAbiItem(abiItem);
|
1931
|
+
const signature = getEventSignature(definition);
|
1932
|
+
let topics = [];
|
1933
|
+
if (args && "inputs" in abiItem) {
|
1934
|
+
const args_ = Array.isArray(args) ? args : abiItem.inputs?.map((x) => args[x.name]) ?? [];
|
1935
|
+
topics = abiItem.inputs?.filter((param) => "indexed" in param && param.indexed).map(
|
1936
|
+
(param, i) => Array.isArray(args_[i]) ? args_[i].map(
|
1937
|
+
(_, j) => encodeArg({ param, value: args_[i][j] })
|
1938
|
+
) : args_[i] ? encodeArg({ param, value: args_[i] }) : null
|
1939
|
+
) ?? [];
|
1940
|
+
}
|
1941
|
+
return [signature, ...topics];
|
1942
|
+
}
|
1943
|
+
function encodeArg({
|
1944
|
+
param,
|
1945
|
+
value
|
1946
|
+
}) {
|
1947
|
+
if (param.type === "string" || param.type === "bytes")
|
1948
|
+
return keccak256(encodeBytes(value));
|
1949
|
+
if (param.type === "tuple" || param.type.match(/^(.*)\[(\d+)?\]$/))
|
1950
|
+
throw new FilterTypeNotSupportedError(param.type);
|
1951
|
+
return encodeAbi({ params: [param], values: [value] });
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
// src/utils/abi/encodeFunctionData.ts
|
1955
|
+
function encodeFunctionData({ abi, args, functionName }) {
|
1956
|
+
const description = getAbiItem({ abi, name: functionName });
|
1957
|
+
if (!description)
|
1958
|
+
throw new AbiFunctionNotFoundError(functionName, {
|
1959
|
+
docsPath: "/docs/contract/encodeFunctionData"
|
1410
1960
|
});
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1961
|
+
const definition = formatAbiItem(description);
|
1962
|
+
const signature = getFunctionSignature(definition);
|
1963
|
+
const data = "inputs" in description && description.inputs ? encodeAbi({
|
1964
|
+
params: description.inputs,
|
1965
|
+
values: args ?? []
|
1966
|
+
}) : void 0;
|
1967
|
+
return concatHex([signature, data ?? "0x"]);
|
1968
|
+
}
|
1414
1969
|
|
1415
|
-
// src/
|
1416
|
-
var
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1970
|
+
// src/utils/abi/encodeFunctionResult.ts
|
1971
|
+
var docsPath4 = "/docs/contract/encodeFunctionResult";
|
1972
|
+
function encodeFunctionResult({
|
1973
|
+
abi,
|
1974
|
+
functionName,
|
1975
|
+
result
|
1976
|
+
}) {
|
1977
|
+
const description = abi.find((x) => "name" in x && x.name === functionName);
|
1978
|
+
if (!description)
|
1979
|
+
throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath4 });
|
1980
|
+
if (!("outputs" in description))
|
1981
|
+
throw new AbiFunctionOutputsNotFoundError(functionName, { docsPath: docsPath4 });
|
1982
|
+
let values = Array.isArray(result) ? result : [result];
|
1983
|
+
if (description.outputs.length === 0 && !values[0])
|
1984
|
+
values = [];
|
1985
|
+
return encodeAbi({ params: description.outputs, values });
|
1986
|
+
}
|
1987
|
+
|
1988
|
+
// src/utils/abi/formatAbiItemWithArgs.ts
|
1989
|
+
function formatAbiItemWithArgs({
|
1990
|
+
abiItem,
|
1991
|
+
args,
|
1992
|
+
includeFunctionName = true,
|
1993
|
+
includeName = false
|
1994
|
+
}) {
|
1995
|
+
if (!("name" in abiItem))
|
1996
|
+
return;
|
1997
|
+
if (!("inputs" in abiItem))
|
1998
|
+
return;
|
1999
|
+
if (!abiItem.inputs)
|
2000
|
+
return;
|
2001
|
+
return `${includeFunctionName ? abiItem.name : ""}(${abiItem.inputs.map(
|
2002
|
+
(input, i) => `${includeName && input.name ? `${input.name}: ` : ""}${typeof args[i] === "object" ? stringify(args[i]) : args[i]}`
|
2003
|
+
).join(", ")})`;
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
// src/utils/buildRequest.ts
|
2007
|
+
function buildRequest(request) {
|
2008
|
+
return async (args) => {
|
2009
|
+
try {
|
2010
|
+
return await request(args);
|
2011
|
+
} catch (err_) {
|
2012
|
+
let err = err_;
|
2013
|
+
if (err.code === -32700)
|
2014
|
+
throw new ParseRpcError(err);
|
2015
|
+
if (err.code === -32600)
|
2016
|
+
throw new InvalidRequestRpcError(err);
|
2017
|
+
if (err.code === -32601)
|
2018
|
+
throw new MethodNotFoundRpcError(err);
|
2019
|
+
if (err.code === -32602)
|
2020
|
+
throw new InvalidParamsRpcError(err);
|
2021
|
+
if (err.code === -32603)
|
2022
|
+
throw new InternalRpcError(err);
|
2023
|
+
if (err.code === -32e3)
|
2024
|
+
throw new InvalidInputRpcError(err);
|
2025
|
+
if (err.code === -32001)
|
2026
|
+
throw new ResourceNotFoundRpcError(err);
|
2027
|
+
if (err.code === -32002)
|
2028
|
+
throw new ResourceUnavailableRpcError(err);
|
2029
|
+
if (err.code === -32003)
|
2030
|
+
throw new TransactionRejectedRpcError(err);
|
2031
|
+
if (err.code === -32004)
|
2032
|
+
throw new MethodNotSupportedRpcError(err);
|
2033
|
+
if (err.code === -32005)
|
2034
|
+
throw new LimitExceededRpcError(err);
|
2035
|
+
if (err.code === -32006)
|
2036
|
+
throw new JsonRpcVersionUnsupportedError(err);
|
2037
|
+
if (err_ instanceof BaseError)
|
2038
|
+
throw err_;
|
2039
|
+
throw new UnknownRpcError(err);
|
2040
|
+
}
|
2041
|
+
};
|
2042
|
+
}
|
2043
|
+
|
2044
|
+
// src/utils/chain.ts
|
2045
|
+
function defineChain(chain) {
|
2046
|
+
return chain;
|
2047
|
+
}
|
2048
|
+
|
2049
|
+
// src/utils/formatters/format.ts
|
2050
|
+
function format3(data, { formatter }) {
|
2051
|
+
return formatter(data);
|
2052
|
+
}
|
2053
|
+
function defineFormatter({
|
2054
|
+
format: format4
|
2055
|
+
}) {
|
2056
|
+
return ({
|
2057
|
+
exclude,
|
2058
|
+
format: formatOverride
|
2059
|
+
}) => (data) => {
|
2060
|
+
const formatted = format4(data);
|
2061
|
+
if (exclude) {
|
2062
|
+
for (const key of exclude) {
|
2063
|
+
delete formatted[key];
|
2064
|
+
}
|
2065
|
+
}
|
2066
|
+
return {
|
2067
|
+
...formatted,
|
2068
|
+
...formatOverride?.(data)
|
2069
|
+
};
|
2070
|
+
};
|
2071
|
+
}
|
2072
|
+
|
2073
|
+
// src/utils/formatters/transaction.ts
|
1428
2074
|
var transactionType = {
|
1429
2075
|
"0x0": "legacy",
|
1430
2076
|
"0x1": "eip2930",
|
1431
2077
|
"0x2": "eip1559"
|
1432
2078
|
};
|
1433
|
-
|
1434
|
-
// src/utils/formatters/transaction.ts
|
1435
2079
|
function formatTransaction(transaction) {
|
1436
2080
|
const transaction_ = {
|
1437
2081
|
...transaction,
|
@@ -1457,6 +2101,7 @@ function formatTransaction(transaction) {
|
|
1457
2101
|
}
|
1458
2102
|
return transaction_;
|
1459
2103
|
}
|
2104
|
+
var defineTransaction = defineFormatter({ format: formatTransaction });
|
1460
2105
|
|
1461
2106
|
// src/utils/formatters/block.ts
|
1462
2107
|
function formatBlock(block) {
|
@@ -1478,6 +2123,21 @@ function formatBlock(block) {
|
|
1478
2123
|
totalDifficulty: block.totalDifficulty ? BigInt(block.totalDifficulty) : null
|
1479
2124
|
};
|
1480
2125
|
}
|
2126
|
+
var defineBlock = defineFormatter({ format: formatBlock });
|
2127
|
+
|
2128
|
+
// src/utils/formatters/extract.ts
|
2129
|
+
function extract(value, { formatter }) {
|
2130
|
+
if (!formatter)
|
2131
|
+
return {};
|
2132
|
+
const keys = Object.keys(formatter({}));
|
2133
|
+
return keys.reduce((data, key) => {
|
2134
|
+
if (value?.hasOwnProperty(key)) {
|
2135
|
+
;
|
2136
|
+
data[key] = value[key];
|
2137
|
+
}
|
2138
|
+
return data;
|
2139
|
+
}, {});
|
2140
|
+
}
|
1481
2141
|
|
1482
2142
|
// src/utils/formatters/feeHistory.ts
|
1483
2143
|
function formatFeeHistory(feeHistory) {
|
@@ -1491,11 +2151,6 @@ function formatFeeHistory(feeHistory) {
|
|
1491
2151
|
};
|
1492
2152
|
}
|
1493
2153
|
|
1494
|
-
// src/utils/formatters/format.ts
|
1495
|
-
function format3(data, { formatter }) {
|
1496
|
-
return formatter(data);
|
1497
|
-
}
|
1498
|
-
|
1499
2154
|
// src/utils/formatters/log.ts
|
1500
2155
|
function formatLog(log) {
|
1501
2156
|
return {
|
@@ -1524,6 +2179,9 @@ function formatTransactionReceipt(transactionReceipt) {
|
|
1524
2179
|
type: transactionReceipt.type ? transactionType[transactionReceipt.type] : null
|
1525
2180
|
};
|
1526
2181
|
}
|
2182
|
+
var defineTransactionReceipt = defineFormatter({
|
2183
|
+
format: formatTransactionReceipt
|
2184
|
+
});
|
1527
2185
|
|
1528
2186
|
// src/utils/formatters/transactionRequest.ts
|
1529
2187
|
function formatTransactionRequest(transactionRequest) {
|
@@ -1537,6 +2195,9 @@ function formatTransactionRequest(transactionRequest) {
|
|
1537
2195
|
value: typeof transactionRequest.value !== "undefined" ? numberToHex(transactionRequest.value) : void 0
|
1538
2196
|
};
|
1539
2197
|
}
|
2198
|
+
var defineTransactionRequest = defineFormatter({
|
2199
|
+
format: formatTransactionRequest
|
2200
|
+
});
|
1540
2201
|
|
1541
2202
|
// src/utils/promise/withCache.ts
|
1542
2203
|
var promiseCache = /* @__PURE__ */ new Map();
|
@@ -1664,7 +2325,7 @@ async function http(url, {
|
|
1664
2325
|
"Content-Type": "application/json"
|
1665
2326
|
},
|
1666
2327
|
method: "POST",
|
1667
|
-
body:
|
2328
|
+
body: stringify({ jsonrpc: "2.0", id: id++, ...body }),
|
1668
2329
|
signal: timeout > 0 ? signal : void 0
|
1669
2330
|
});
|
1670
2331
|
return response2;
|
@@ -1701,7 +2362,7 @@ async function http(url, {
|
|
1701
2362
|
if (!response.ok) {
|
1702
2363
|
throw new HttpRequestError({
|
1703
2364
|
body,
|
1704
|
-
details:
|
2365
|
+
details: stringify(data.error) || response.statusText,
|
1705
2366
|
status: response.status,
|
1706
2367
|
url
|
1707
2368
|
});
|
@@ -1809,91 +2470,19 @@ var rpc = {
|
|
1809
2470
|
webSocket,
|
1810
2471
|
webSocketAsync
|
1811
2472
|
};
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
url
|
1818
|
-
}) {
|
1819
|
-
super(
|
1820
|
-
[
|
1821
|
-
"HTTP request failed.",
|
1822
|
-
"",
|
1823
|
-
`Status: ${status}`,
|
1824
|
-
`URL: ${url}`,
|
1825
|
-
`Request body: ${JSON.stringify(body)}`
|
1826
|
-
].join("\n"),
|
1827
|
-
{
|
1828
|
-
details
|
1829
|
-
}
|
1830
|
-
);
|
1831
|
-
__publicField(this, "name", "HttpRequestError");
|
1832
|
-
__publicField(this, "status");
|
1833
|
-
this.status = status;
|
1834
|
-
}
|
1835
|
-
};
|
1836
|
-
var WebSocketRequestError = class extends BaseError {
|
1837
|
-
constructor({
|
1838
|
-
body,
|
1839
|
-
details,
|
1840
|
-
url
|
1841
|
-
}) {
|
1842
|
-
super(
|
1843
|
-
[
|
1844
|
-
"WebSocket request failed.",
|
1845
|
-
"",
|
1846
|
-
`URL: ${url}`,
|
1847
|
-
`Request body: ${JSON.stringify(body)}`
|
1848
|
-
].join("\n"),
|
1849
|
-
{
|
1850
|
-
details
|
1851
|
-
}
|
1852
|
-
);
|
1853
|
-
__publicField(this, "name", "WebSocketRequestError");
|
1854
|
-
}
|
2473
|
+
|
2474
|
+
// src/utils/unit/constants.ts
|
2475
|
+
var etherUnits = {
|
2476
|
+
gwei: 9,
|
2477
|
+
wei: 18
|
1855
2478
|
};
|
1856
|
-
var
|
1857
|
-
|
1858
|
-
|
1859
|
-
error,
|
1860
|
-
url
|
1861
|
-
}) {
|
1862
|
-
super(
|
1863
|
-
[
|
1864
|
-
"RPC Request failed.",
|
1865
|
-
"",
|
1866
|
-
`URL: ${url}`,
|
1867
|
-
`Request body: ${JSON.stringify(body)}`
|
1868
|
-
].join("\n"),
|
1869
|
-
{
|
1870
|
-
cause: error,
|
1871
|
-
details: error.message
|
1872
|
-
}
|
1873
|
-
);
|
1874
|
-
__publicField(this, "code");
|
1875
|
-
__publicField(this, "name", "RpcError");
|
1876
|
-
this.code = error.code;
|
1877
|
-
}
|
2479
|
+
var gweiUnits = {
|
2480
|
+
ether: -9,
|
2481
|
+
wei: 9
|
1878
2482
|
};
|
1879
|
-
var
|
1880
|
-
|
1881
|
-
|
1882
|
-
url
|
1883
|
-
}) {
|
1884
|
-
super(
|
1885
|
-
[
|
1886
|
-
"The request took too long to respond.",
|
1887
|
-
"",
|
1888
|
-
`URL: ${url}`,
|
1889
|
-
`Request body: ${JSON.stringify(body)}`
|
1890
|
-
].join("\n"),
|
1891
|
-
{
|
1892
|
-
details: "The request timed out."
|
1893
|
-
}
|
1894
|
-
);
|
1895
|
-
__publicField(this, "name", "TimeoutError");
|
1896
|
-
}
|
2483
|
+
var weiUnits = {
|
2484
|
+
ether: -18,
|
2485
|
+
gwei: -9
|
1897
2486
|
};
|
1898
2487
|
|
1899
2488
|
// src/utils/unit/formatUnit.ts
|
@@ -1954,8 +2543,49 @@ function parseGwei(ether, unit = "wei") {
|
|
1954
2543
|
}
|
1955
2544
|
|
1956
2545
|
export {
|
1957
|
-
|
2546
|
+
stringify,
|
1958
2547
|
BaseError,
|
2548
|
+
AbiConstructorNotFoundError,
|
2549
|
+
AbiConstructorParamsNotFoundError,
|
2550
|
+
AbiDecodingDataSizeInvalidError,
|
2551
|
+
AbiEncodingArrayLengthMismatchError,
|
2552
|
+
AbiEncodingLengthMismatchError,
|
2553
|
+
AbiErrorInputsNotFoundError,
|
2554
|
+
AbiErrorNotFoundError,
|
2555
|
+
AbiErrorSignatureNotFoundError,
|
2556
|
+
AbiEventNotFoundError,
|
2557
|
+
AbiFunctionNotFoundError,
|
2558
|
+
AbiFunctionOutputsNotFoundError,
|
2559
|
+
AbiFunctionSignatureNotFoundError,
|
2560
|
+
InvalidAbiEncodingTypeError,
|
2561
|
+
InvalidAbiDecodingTypeError,
|
2562
|
+
InvalidArrayError,
|
2563
|
+
InvalidDefinitionTypeError,
|
2564
|
+
InvalidAddressError,
|
2565
|
+
BlockNotFoundError,
|
2566
|
+
SizeExceedsPaddingSizeError,
|
2567
|
+
DataLengthTooLongError,
|
2568
|
+
DataLengthTooShortError,
|
2569
|
+
InvalidBytesBooleanError,
|
2570
|
+
InvalidHexBooleanError,
|
2571
|
+
InvalidHexValueError,
|
2572
|
+
OffsetOutOfBoundsError,
|
2573
|
+
FilterTypeNotSupportedError,
|
2574
|
+
RequestError,
|
2575
|
+
RpcRequestError,
|
2576
|
+
ParseRpcError,
|
2577
|
+
InvalidRequestRpcError,
|
2578
|
+
MethodNotFoundRpcError,
|
2579
|
+
InvalidParamsRpcError,
|
2580
|
+
InternalRpcError,
|
2581
|
+
InvalidInputRpcError,
|
2582
|
+
ResourceNotFoundRpcError,
|
2583
|
+
ResourceUnavailableRpcError,
|
2584
|
+
TransactionRejectedRpcError,
|
2585
|
+
MethodNotSupportedRpcError,
|
2586
|
+
LimitExceededRpcError,
|
2587
|
+
JsonRpcVersionUnsupportedError,
|
2588
|
+
UnknownRpcError,
|
1959
2589
|
isBytes,
|
1960
2590
|
isHex,
|
1961
2591
|
pad,
|
@@ -1988,9 +2618,11 @@ export {
|
|
1988
2618
|
bytesToNumber,
|
1989
2619
|
bytesToString,
|
1990
2620
|
decodeRlp,
|
2621
|
+
extractFunctionParts,
|
1991
2622
|
extractFunctionName,
|
1992
2623
|
extractFunctionParams,
|
1993
2624
|
extractFunctionType,
|
2625
|
+
getContractError,
|
1994
2626
|
keccak256,
|
1995
2627
|
getEventSignature,
|
1996
2628
|
getFunctionSignature,
|
@@ -2003,44 +2635,55 @@ export {
|
|
2003
2635
|
isAddressEqual,
|
2004
2636
|
encodeAbi,
|
2005
2637
|
decodeAbi,
|
2006
|
-
|
2638
|
+
formatAbiItem,
|
2639
|
+
decodeErrorResult,
|
2640
|
+
decodeFunctionData,
|
2641
|
+
decodeFunctionResult,
|
2642
|
+
encodeDeployData,
|
2643
|
+
getAbiItem,
|
2644
|
+
encodeErrorResult,
|
2645
|
+
encodeEventTopics,
|
2646
|
+
encodeFunctionData,
|
2647
|
+
encodeFunctionResult,
|
2648
|
+
formatAbiItemWithArgs,
|
2007
2649
|
buildRequest,
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
MethodNotFoundRpcError,
|
2012
|
-
InvalidParamsRpcError,
|
2013
|
-
InternalRpcError,
|
2014
|
-
InvalidInputRpcError,
|
2015
|
-
ResourceNotFoundRpcError,
|
2016
|
-
ResourceUnavailableRpcError,
|
2017
|
-
TransactionRejectedRpcError,
|
2018
|
-
MethodNotSupportedRpcError,
|
2019
|
-
LimitExceededRpcError,
|
2020
|
-
JsonRpcVersionUnsupportedError,
|
2021
|
-
etherUnits,
|
2022
|
-
gweiUnits,
|
2023
|
-
weiUnits,
|
2650
|
+
defineChain,
|
2651
|
+
format3 as format,
|
2652
|
+
defineFormatter,
|
2024
2653
|
transactionType,
|
2025
2654
|
formatTransaction,
|
2655
|
+
defineTransaction,
|
2026
2656
|
formatBlock,
|
2657
|
+
defineBlock,
|
2658
|
+
extract,
|
2027
2659
|
formatFeeHistory,
|
2028
|
-
format3 as format,
|
2029
2660
|
formatLog,
|
2030
2661
|
formatTransactionReceipt,
|
2662
|
+
defineTransactionReceipt,
|
2031
2663
|
formatTransactionRequest,
|
2664
|
+
defineTransactionRequest,
|
2032
2665
|
getCache,
|
2033
2666
|
withCache,
|
2034
2667
|
wait,
|
2035
2668
|
getSocket,
|
2036
2669
|
rpc,
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2670
|
+
etherUnits,
|
2671
|
+
gweiUnits,
|
2672
|
+
weiUnits,
|
2040
2673
|
formatUnit,
|
2041
2674
|
formatEther,
|
2042
2675
|
formatGwei,
|
2043
2676
|
parseUnit,
|
2044
2677
|
parseEther,
|
2045
|
-
parseGwei
|
2678
|
+
parseGwei,
|
2679
|
+
HttpRequestError,
|
2680
|
+
WebSocketRequestError,
|
2681
|
+
RpcError,
|
2682
|
+
TimeoutError,
|
2683
|
+
InvalidGasArgumentsError,
|
2684
|
+
TransactionNotFoundError,
|
2685
|
+
TransactionReceiptNotFoundError,
|
2686
|
+
WaitForTransactionReceiptTimeoutError,
|
2687
|
+
UrlRequiredError
|
2046
2688
|
};
|
2689
|
+
//# sourceMappingURL=chunk-62VTYU2V.mjs.map
|