voltaire-effect 0.2.23 → 0.2.25
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/dist/KZGService-B7PJerOb.d.ts +146 -0
- package/dist/ProviderService-BZ5pqDrD.d.ts +319 -0
- package/dist/{X25519Test-DGsk1V9o.d.ts → X25519Test-D5Q-5fL9.d.ts} +4 -143
- package/dist/crypto/index.d.ts +5 -6
- package/dist/crypto/index.js +227 -201
- package/dist/{index-IgkEHjBe.d.ts → index-BCOuszKZ.d.ts} +17634 -11962
- package/dist/index.d.ts +3195 -976
- package/dist/index.js +6994 -4679
- package/dist/native/index.d.ts +25 -16
- package/dist/native/index.js +7020 -4705
- package/dist/primitives/index.d.ts +14 -8
- package/dist/primitives/index.js +4060 -2539
- package/dist/services/index.d.ts +9054 -30
- package/dist/services/index.js +1592 -1331
- package/package.json +2 -2
- package/src/crypto/ERC6492/ERC6492.test.ts +32 -14
- package/src/crypto/ERC6492/verifySignature.ts +4 -5
- package/src/crypto/Keccak256/Keccak256.test.ts +42 -1
- package/src/crypto/Keccak256/hashSync.ts +53 -0
- package/src/crypto/Keccak256/index.ts +2 -0
- package/src/index.ts +7 -2
- package/src/primitives/Abi/decode.test.ts +38 -0
- package/src/primitives/Abi/decode.ts +67 -0
- package/src/primitives/Abi/decodeData.test.ts +37 -0
- package/src/primitives/Abi/decodeData.ts +77 -0
- package/src/primitives/Abi/decodeLog.test.ts +32 -0
- package/src/primitives/Abi/decodeLog.ts +81 -0
- package/src/primitives/Abi/decodeWrappedError.test.ts +41 -0
- package/src/primitives/Abi/decodeWrappedError.ts +68 -0
- package/src/primitives/Abi/encode.test.ts +43 -0
- package/src/primitives/Abi/encode.ts +67 -0
- package/src/primitives/Abi/encodePacked.test.ts +35 -0
- package/src/primitives/Abi/encodePacked.ts +62 -0
- package/src/primitives/Abi/encodeWrappedError.test.ts +21 -0
- package/src/primitives/Abi/encodeWrappedError.ts +64 -0
- package/src/primitives/Abi/findSelectorCollisions.test.ts +50 -0
- package/src/primitives/Abi/findSelectorCollisions.ts +83 -0
- package/src/primitives/Abi/index.ts +33 -7
- package/src/primitives/Abi/parseLogs.test.ts +37 -0
- package/src/primitives/Abi/parseLogs.ts +62 -0
- package/src/primitives/AccessList/AccessList.test.ts +229 -0
- package/src/primitives/AccessList/AccessListTypeSchema.ts +16 -0
- package/src/primitives/AccessList/addressCount.ts +21 -0
- package/src/primitives/AccessList/assertValid.ts +37 -0
- package/src/primitives/AccessList/create.ts +19 -0
- package/src/primitives/AccessList/deduplicate.ts +23 -0
- package/src/primitives/AccessList/from.ts +39 -0
- package/src/primitives/AccessList/fromBytes.ts +36 -0
- package/src/primitives/AccessList/gasCost.ts +22 -0
- package/src/primitives/AccessList/gasSavings.ts +26 -0
- package/src/primitives/AccessList/hasSavings.ts +23 -0
- package/src/primitives/AccessList/includesAddress.ts +25 -0
- package/src/primitives/AccessList/includesStorageKey.ts +28 -0
- package/src/primitives/AccessList/index.ts +99 -19
- package/src/primitives/AccessList/is.ts +23 -0
- package/src/primitives/AccessList/isEmpty.ts +23 -0
- package/src/primitives/AccessList/isItem.ts +22 -0
- package/src/primitives/AccessList/keysFor.ts +29 -0
- package/src/primitives/AccessList/merge.ts +24 -0
- package/src/primitives/AccessList/storageKeyCount.ts +21 -0
- package/src/primitives/AccessList/toBytes.ts +23 -0
- package/src/primitives/AccessList/withAddress.ts +27 -0
- package/src/primitives/AccessList/withStorageKey.ts +30 -0
- package/src/primitives/Address/Address.test.ts +146 -0
- package/src/primitives/Address/assert.ts +51 -0
- package/src/primitives/Address/calculateCreate2Address.ts +33 -0
- package/src/primitives/Address/calculateCreateAddress.ts +30 -0
- package/src/primitives/Address/deduplicateAddresses.ts +20 -0
- package/src/primitives/Address/from.ts +41 -0
- package/src/primitives/Address/fromAbiEncoded.ts +35 -0
- package/src/primitives/Address/fromBase64.ts +25 -0
- package/src/primitives/Address/fromBytes.ts +25 -0
- package/src/primitives/Address/fromHex.ts +31 -0
- package/src/primitives/Address/fromNumber.ts +25 -0
- package/src/primitives/Address/fromPrivateKey.ts +25 -0
- package/src/primitives/Address/fromPublicKey.ts +56 -0
- package/src/primitives/Address/index.ts +99 -35
- package/src/primitives/Address/is.ts +20 -0
- package/src/primitives/Address/isAddress.ts +22 -0
- package/src/primitives/Address/sortAddresses.ts +19 -0
- package/src/primitives/Address/toChecksummed.ts +32 -0
- package/src/primitives/Address/toHex.ts +18 -0
- package/src/primitives/Address/zero.ts +18 -0
- package/src/primitives/Base64/Base64.test.ts +75 -0
- package/src/primitives/Base64/convert.ts +37 -0
- package/src/primitives/Base64/decode.ts +59 -0
- package/src/primitives/Base64/encode.ts +42 -0
- package/src/primitives/Base64/from.ts +39 -0
- package/src/primitives/Base64/index.ts +81 -1
- package/src/primitives/Base64/size.ts +16 -0
- package/src/primitives/Base64/validation.ts +16 -0
- package/src/primitives/Blob/Blob.test.ts +292 -0
- package/src/primitives/Blob/calculateGas.ts +30 -0
- package/src/primitives/Blob/estimateBlobCount.ts +30 -0
- package/src/primitives/Blob/from.ts +38 -0
- package/src/primitives/Blob/fromData.ts +36 -0
- package/src/primitives/Blob/index.ts +99 -12
- package/src/primitives/Blob/isValidVersion.ts +27 -0
- package/src/primitives/Blob/joinData.ts +43 -0
- package/src/primitives/Blob/splitData.ts +36 -0
- package/src/primitives/Blob/toCommitment.ts +43 -0
- package/src/primitives/Blob/toProof.ts +50 -0
- package/src/primitives/Blob/toVersionedHash.ts +35 -0
- package/src/primitives/Blob/verify.ts +49 -0
- package/src/primitives/Blob/verifyBatch.ts +119 -0
- package/src/primitives/BloomFilter/BloomFilter.test.ts +138 -0
- package/src/primitives/BloomFilter/add.ts +23 -0
- package/src/primitives/BloomFilter/combine.ts +21 -0
- package/src/primitives/BloomFilter/contains.ts +26 -0
- package/src/primitives/BloomFilter/create.ts +35 -0
- package/src/primitives/BloomFilter/density.ts +22 -0
- package/src/primitives/BloomFilter/expectedFalsePositiveRate.ts +25 -0
- package/src/primitives/BloomFilter/fromHex.ts +37 -0
- package/src/primitives/BloomFilter/hash.ts +43 -0
- package/src/primitives/BloomFilter/index.ts +59 -37
- package/src/primitives/BloomFilter/isEmpty.ts +22 -0
- package/src/primitives/BloomFilter/merge.ts +24 -0
- package/src/primitives/BloomFilter/toHex.ts +22 -0
- package/src/primitives/Bytecode/analyze.ts +58 -0
- package/src/primitives/Bytecode/detectFusions.ts +10 -0
- package/src/primitives/Bytecode/equals.ts +10 -0
- package/src/primitives/Bytecode/extractRuntime.ts +12 -0
- package/src/primitives/Bytecode/format.ts +16 -0
- package/src/primitives/Bytecode/from.ts +16 -0
- package/src/primitives/Bytecode/fromHex.ts +14 -0
- package/src/primitives/Bytecode/getBlock.ts +12 -0
- package/src/primitives/Bytecode/getNextPc.ts +12 -0
- package/src/primitives/Bytecode/getPushSize.ts +8 -0
- package/src/primitives/Bytecode/hasMetadata.ts +10 -0
- package/src/primitives/Bytecode/hash.ts +9 -0
- package/src/primitives/Bytecode/index.ts +103 -13
- package/src/primitives/Bytecode/isPush.ts +8 -0
- package/src/primitives/Bytecode/isTerminator.ts +8 -0
- package/src/primitives/Bytecode/isValidJumpDest.ts +12 -0
- package/src/primitives/Bytecode/parseInstructions.ts +10 -0
- package/src/primitives/Bytecode/prettyPrint.ts +12 -0
- package/src/primitives/Bytecode/scan.ts +20 -0
- package/src/primitives/Bytecode/size.ts +9 -0
- package/src/primitives/Bytecode/stripMetadata.ts +10 -0
- package/src/primitives/Bytecode/toAbi.ts +10 -0
- package/src/primitives/Bytecode/toHex.ts +10 -0
- package/src/primitives/Bytecode/types.ts +23 -0
- package/src/primitives/Bytecode/validate.ts +9 -0
- package/src/primitives/ContractSignature/ContractSignature.test.ts +1 -13
- package/src/primitives/ContractSignature/verifySignature.ts +88 -62
- package/src/primitives/Ens/Ens.test.ts +71 -0
- package/src/primitives/Ens/convert.ts +13 -0
- package/src/primitives/Ens/from.ts +32 -0
- package/src/primitives/Ens/hash.ts +46 -0
- package/src/primitives/Ens/index.ts +86 -4
- package/src/primitives/Ens/normalize.ts +45 -0
- package/src/primitives/Ens/validation.ts +38 -0
- package/src/primitives/EventLog/accessors.ts +32 -0
- package/src/primitives/EventLog/clone.ts +17 -0
- package/src/primitives/EventLog/create.ts +46 -0
- package/src/primitives/EventLog/filtering.ts +48 -0
- package/src/primitives/EventLog/index.ts +96 -6
- package/src/primitives/EventLog/status.ts +17 -0
- package/src/primitives/EventLog/toRpc.ts +49 -0
- package/src/primitives/Hardfork/HardforkSchema.ts +3 -3
- package/src/primitives/Hardfork/allIds.ts +13 -0
- package/src/primitives/Hardfork/allNames.ts +13 -0
- package/src/primitives/Hardfork/compare.ts +17 -0
- package/src/primitives/Hardfork/comparisons.ts +45 -0
- package/src/primitives/Hardfork/equals.ts +17 -0
- package/src/primitives/Hardfork/features.ts +61 -0
- package/src/primitives/Hardfork/fromString.ts +16 -0
- package/src/primitives/Hardfork/index.ts +128 -18
- package/src/primitives/Hardfork/isValidName.ts +14 -0
- package/src/primitives/Hardfork/minMax.ts +23 -0
- package/src/primitives/Hardfork/range.ts +19 -0
- package/src/primitives/Hardfork/toString.ts +16 -0
- package/src/primitives/Hash/Hash.test.ts +104 -0
- package/src/primitives/Hash/from.ts +47 -0
- package/src/primitives/Hash/fromBytes.ts +46 -0
- package/src/primitives/Hash/fromHex.ts +44 -0
- package/src/primitives/Hash/index.ts +45 -8
- package/src/primitives/Hash/isHash.ts +31 -0
- package/src/primitives/Hash/toHex.ts +29 -0
- package/src/primitives/Hex/Hex.test.ts +327 -153
- package/src/primitives/Hex/assertSize.ts +41 -0
- package/src/primitives/Hex/concat.ts +37 -0
- package/src/primitives/Hex/from.ts +38 -0
- package/src/primitives/Hex/fromBigInt.ts +40 -0
- package/src/primitives/Hex/fromBoolean.ts +29 -0
- package/src/primitives/Hex/fromNumber.ts +41 -0
- package/src/primitives/Hex/fromString.ts +28 -0
- package/src/primitives/Hex/index.ts +68 -37
- package/src/primitives/Hex/pad.ts +40 -0
- package/src/primitives/Hex/padRight.ts +39 -0
- package/src/primitives/Hex/size.ts +29 -0
- package/src/primitives/Hex/slice.ts +42 -0
- package/src/primitives/Hex/toBigInt.ts +27 -0
- package/src/primitives/Hex/toBoolean.ts +38 -0
- package/src/primitives/Hex/toNumber.ts +37 -0
- package/src/primitives/Hex/toStringHex.ts +39 -0
- package/src/primitives/Hex/trim.ts +27 -0
- package/src/primitives/Hex/validate.ts +37 -0
- package/src/primitives/Hex/xor.ts +39 -0
- package/src/primitives/Opcode/OpcodeSchema.ts +1 -1
- package/src/primitives/Opcode/disassemble.ts +15 -0
- package/src/primitives/Opcode/dupPosition.ts +15 -0
- package/src/primitives/Opcode/format.ts +15 -0
- package/src/primitives/Opcode/getters.ts +54 -0
- package/src/primitives/Opcode/index.ts +301 -11
- package/src/primitives/Opcode/info.ts +18 -0
- package/src/primitives/Opcode/jumpDests.ts +15 -0
- package/src/primitives/Opcode/logTopics.ts +15 -0
- package/src/primitives/Opcode/name.ts +15 -0
- package/src/primitives/Opcode/parse.ts +15 -0
- package/src/primitives/Opcode/predicates.ts +72 -0
- package/src/primitives/Opcode/pushBytes.ts +15 -0
- package/src/primitives/Opcode/pushOpcode.ts +15 -0
- package/src/primitives/Opcode/swapPosition.ts +15 -0
- package/src/primitives/Rlp/decodeBatch.ts +46 -0
- package/src/primitives/Rlp/decodeObject.ts +46 -0
- package/src/primitives/Rlp/decodeValue.ts +51 -0
- package/src/primitives/Rlp/encodeBatch.ts +50 -0
- package/src/primitives/Rlp/encodeObject.ts +48 -0
- package/src/primitives/Rlp/encodeVariadic.ts +49 -0
- package/src/primitives/Rlp/equals.ts +22 -0
- package/src/primitives/Rlp/from.ts +44 -0
- package/src/primitives/Rlp/fromJSON.ts +45 -0
- package/src/primitives/Rlp/getEncodedLength.ts +47 -0
- package/src/primitives/Rlp/getLength.ts +44 -0
- package/src/primitives/Rlp/index.ts +67 -14
- package/src/primitives/Rlp/isBytesData.ts +21 -0
- package/src/primitives/Rlp/isCanonical.ts +32 -0
- package/src/primitives/Rlp/isData.ts +21 -0
- package/src/primitives/Rlp/isList.ts +46 -0
- package/src/primitives/Rlp/isListData.ts +21 -0
- package/src/primitives/Rlp/isString.ts +46 -0
- package/src/primitives/Rlp/toJSON.ts +20 -0
- package/src/primitives/Rlp/toRaw.ts +31 -0
- package/src/primitives/Signature/Signature.test.ts +217 -0
- package/src/primitives/Signature/from.ts +38 -0
- package/src/primitives/Signature/fromBytes.ts +31 -0
- package/src/primitives/Signature/fromCompact.ts +33 -0
- package/src/primitives/Signature/fromDER.ts +35 -0
- package/src/primitives/Signature/fromEd25519.ts +24 -0
- package/src/primitives/Signature/fromHex.ts +29 -0
- package/src/primitives/Signature/fromP256.ts +25 -0
- package/src/primitives/Signature/fromRpc.ts +38 -0
- package/src/primitives/Signature/fromSecp256k1.ts +29 -0
- package/src/primitives/Signature/fromTuple.ts +33 -0
- package/src/primitives/Signature/getR.ts +24 -0
- package/src/primitives/Signature/getS.ts +24 -0
- package/src/primitives/Signature/getV.ts +24 -0
- package/src/primitives/Signature/index.ts +61 -11
- package/src/primitives/Signature/toDER.ts +24 -0
- package/src/primitives/Signature/toHex.ts +24 -0
- package/src/primitives/Signature/toRpc.ts +35 -0
- package/src/primitives/Signature/toTuple.ts +29 -0
- package/src/primitives/Signature/verify.ts +31 -0
- package/src/primitives/Siwe/create.ts +56 -0
- package/src/primitives/Siwe/hash.ts +27 -0
- package/src/primitives/Siwe/index.ts +57 -21
- package/src/primitives/Siwe/parse.ts +24 -0
- package/src/primitives/Siwe/verify.ts +47 -0
- package/src/primitives/Transaction/Transaction.test.ts +309 -0
- package/src/primitives/Transaction/index.ts +467 -2
- package/src/primitives/Uint/Uint.test.ts +200 -0
- package/src/primitives/Uint/dividedBy.ts +34 -0
- package/src/primitives/Uint/from.ts +35 -0
- package/src/primitives/Uint/fromAbiEncoded.ts +29 -0
- package/src/primitives/Uint/fromBigInt.ts +30 -0
- package/src/primitives/Uint/fromBytes.ts +32 -0
- package/src/primitives/Uint/fromHex.ts +32 -0
- package/src/primitives/Uint/fromNumber.ts +30 -0
- package/src/primitives/Uint/index.ts +90 -45
- package/src/primitives/Uint/isUint256.ts +25 -0
- package/src/primitives/Uint/isValid.ts +25 -0
- package/src/primitives/Uint/modulo.ts +34 -0
- package/src/primitives/Uint/toHex.ts +31 -0
- package/src/primitives/Uint/tryFrom.ts +30 -0
- package/src/services/Contract/Contract.test.ts +46 -41
- package/src/services/Contract/Contract.ts +25 -29
- package/src/services/Contract/ContractTypes.ts +6 -3
- package/src/services/Contract/estimateGas.test.ts +21 -9
- package/src/services/Contract/estimateGas.ts +21 -23
- package/src/services/Debug/Debug.ts +1 -1
- package/src/services/Debug/DebugService.ts +1 -1
- package/src/services/FeeEstimator/DefaultFeeEstimator.ts +10 -6
- package/src/services/FeeEstimator/FeeEstimator.test.ts +68 -62
- package/src/services/Multicall/BalanceResolver.ts +1 -1
- package/src/services/Multicall/GetBalance.ts +1 -1
- package/src/services/Multicall/Multicall.ts +1 -1
- package/src/services/NonceManager/DefaultNonceManager.ts +4 -7
- package/src/services/NonceManager/NonceManager.test.ts +20 -33
- package/src/services/Provider/Provider.test.ts +155 -349
- package/src/services/Provider/Provider.ts +14 -1180
- package/src/services/Provider/ProviderService.ts +14 -1199
- package/src/services/Provider/actions/multicall.test.ts +29 -39
- package/src/services/Provider/actions/multicall.ts +2 -2
- package/src/services/Provider/actions/readContract.test.ts +45 -50
- package/src/services/Provider/actions/readContract.ts +2 -6
- package/src/services/Provider/actions/simulateContract.test.ts +55 -232
- package/src/services/Provider/actions/simulateContract.ts +2 -3
- package/src/services/Provider/ens/getEnsAddress.ts +11 -14
- package/src/services/Provider/ens/getEnsName.ts +15 -18
- package/src/services/Provider/ens/getEnsResolver.ts +11 -14
- package/src/services/Provider/ens/getEnsText.ts +15 -18
- package/src/services/Provider/functions/backfillBlocks.ts +97 -0
- package/src/services/Provider/functions/call.ts +45 -0
- package/src/services/Provider/functions/createAccessList.ts +61 -0
- package/src/services/Provider/functions/createBlockFilter.ts +41 -0
- package/src/services/Provider/functions/createEventFilter.ts +43 -0
- package/src/services/Provider/functions/createPendingTransactionFilter.ts +41 -0
- package/src/services/Provider/functions/estimateGas.ts +52 -0
- package/src/services/Provider/functions/getAccounts.ts +40 -0
- package/src/services/Provider/functions/getBalance.ts +50 -0
- package/src/services/Provider/functions/getBlobBaseFee.ts +46 -0
- package/src/services/Provider/functions/getBlock.ts +95 -0
- package/src/services/Provider/functions/getBlockNumber.ts +51 -0
- package/src/services/Provider/functions/getBlockReceipts.ts +78 -0
- package/src/services/Provider/functions/getBlockTransactionCount.ts +86 -0
- package/src/services/Provider/functions/getChainId.ts +46 -0
- package/src/services/Provider/functions/getCode.ts +43 -0
- package/src/services/Provider/functions/getCoinbase.ts +40 -0
- package/src/services/Provider/functions/getFeeHistory.ts +85 -0
- package/src/services/Provider/functions/getFilterChanges.ts +42 -0
- package/src/services/Provider/functions/getFilterLogs.ts +44 -0
- package/src/services/Provider/functions/getGasPrice.ts +46 -0
- package/src/services/Provider/functions/getHashrate.ts +46 -0
- package/src/services/Provider/functions/getLogs.ts +45 -0
- package/src/services/Provider/functions/getMaxPriorityFeePerGas.ts +46 -0
- package/src/services/Provider/functions/getMining.ts +40 -0
- package/src/services/Provider/functions/getProof.ts +52 -0
- package/src/services/Provider/functions/getProtocolVersion.ts +40 -0
- package/src/services/Provider/functions/getStorageAt.ts +52 -0
- package/src/services/Provider/functions/getSyncing.ts +56 -0
- package/src/services/Provider/functions/getTransaction.ts +57 -0
- package/src/services/Provider/functions/getTransactionByBlockHashAndIndex.ts +73 -0
- package/src/services/Provider/functions/getTransactionByBlockNumberAndIndex.ts +86 -0
- package/src/services/Provider/functions/getTransactionConfirmations.ts +70 -0
- package/src/services/Provider/functions/getTransactionCount.ts +50 -0
- package/src/services/Provider/functions/getTransactionReceipt.ts +57 -0
- package/src/services/Provider/functions/getUncle.ts +97 -0
- package/src/services/Provider/functions/getUncleCount.ts +86 -0
- package/src/services/Provider/functions/index.ts +73 -0
- package/src/services/Provider/functions/netVersion.ts +40 -0
- package/src/services/Provider/functions/sendRawTransaction.ts +40 -0
- package/src/services/Provider/functions/sendTransaction.ts +48 -0
- package/src/services/Provider/functions/sign.ts +50 -0
- package/src/services/Provider/functions/signTransaction.ts +52 -0
- package/src/services/Provider/functions/simulateV1.ts +95 -0
- package/src/services/Provider/functions/simulateV2.ts +51 -0
- package/src/services/Provider/functions/subscribe.ts +49 -0
- package/src/services/Provider/functions/uninstallFilter.ts +40 -0
- package/src/services/Provider/functions/unsubscribe.ts +41 -0
- package/src/services/Provider/functions/waitForTransactionReceipt.ts +168 -0
- package/src/services/Provider/functions/watchBlocks.ts +98 -0
- package/src/services/Provider/index.ts +29 -178
- package/src/services/Provider/types.ts +780 -0
- package/src/services/Provider/utils.ts +204 -0
- package/src/services/RawProvider/ForkProviderTransport.ts +2 -3
- package/src/services/RawProvider/HttpProviderTransport.ts +3 -3
- package/src/services/RawProvider/InMemoryProviderTransport.ts +3 -3
- package/src/services/RawProvider/WebSocketProviderTransport.ts +3 -3
- package/src/services/Signer/Signer.test.ts +211 -187
- package/src/services/Signer/Signer.ts +26 -16
- package/src/services/Signer/actions/deployContract.test.ts +125 -105
- package/src/services/Signer/actions/deployContract.ts +3 -2
- package/src/services/Signer/actions/prepareAuthorization.test.ts +47 -48
- package/src/services/Signer/actions/prepareAuthorization.ts +3 -3
- package/src/services/Signer/actions/signAuthorization.test.ts +39 -45
- package/src/services/Signer/actions/signAuthorization.ts +3 -3
- package/src/services/Signer/actions/writeContract.test.ts +41 -57
- package/src/services/Transport/FallbackTransport.ts +3 -3
- package/src/services/Transport/HttpTransport.ts +3 -3
- package/src/services/Transport/config.ts +7 -7
- package/src/services/Transport/index.ts +3 -4
- package/src/services/errors.test.ts +3 -8
- package/src/services/index.ts +8 -90
- package/src/services/presets/index.ts +9 -10
- package/src/services/presets/presets.test.ts +14 -29
- package/src/standards/ERC165.test.ts +19 -20
- package/src/standards/ERC165.ts +9 -11
- package/src/type-exports.test.ts +37 -0
- package/dist/AccountService-BetXokad.d.ts +0 -1717
- package/dist/RpcResolver-BpvqybjD.d.ts +0 -6439
- package/src/services/Provider/Account.ts +0 -33
- package/src/services/Provider/AccountService.ts +0 -84
- package/src/services/Provider/Blocks.ts +0 -32
- package/src/services/Provider/BlocksService.ts +0 -73
- package/src/services/Provider/Events.ts +0 -33
- package/src/services/Provider/EventsService.ts +0 -71
- package/src/services/Provider/Network.ts +0 -41
- package/src/services/Provider/NetworkService.ts +0 -114
- package/src/services/Provider/Simulation.ts +0 -34
- package/src/services/Provider/SimulationService.ts +0 -161
- package/src/services/Provider/Streaming.ts +0 -30
- package/src/services/Provider/StreamingService.ts +0 -58
- package/src/services/Provider/Transaction.ts +0 -39
- package/src/services/Provider/TransactionService.ts +0 -83
- package/src/services/Provider/filters.ts +0 -91
- package/src/services/Provider/getBlobBaseFee.ts +0 -170
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get the transaction count in a block.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getBlockTransactionCount
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import {
|
|
11
|
+
type BlockTag,
|
|
12
|
+
type GetBlockTransactionCountArgs,
|
|
13
|
+
ProviderResponseError,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Gets the number of transactions in a block.
|
|
19
|
+
*
|
|
20
|
+
* @param args - Block identifier (blockTag or blockHash)
|
|
21
|
+
* @returns Effect yielding the transaction count as bigint
|
|
22
|
+
*
|
|
23
|
+
* @since 0.4.0
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { Effect } from 'effect'
|
|
28
|
+
* import { getBlockTransactionCount, Provider, HttpTransport } from 'voltaire-effect'
|
|
29
|
+
*
|
|
30
|
+
* const program = Effect.gen(function* () {
|
|
31
|
+
* // Get transaction count for latest block
|
|
32
|
+
* const count = yield* getBlockTransactionCount({})
|
|
33
|
+
*
|
|
34
|
+
* // Get by block hash
|
|
35
|
+
* const countByHash = yield* getBlockTransactionCount({
|
|
36
|
+
* blockHash: '0x...'
|
|
37
|
+
* })
|
|
38
|
+
* }).pipe(
|
|
39
|
+
* Effect.provide(Provider),
|
|
40
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
41
|
+
* )
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export const getBlockTransactionCount = (
|
|
45
|
+
args: GetBlockTransactionCountArgs = {},
|
|
46
|
+
): Effect.Effect<bigint, TransportError | ProviderResponseError, ProviderService> =>
|
|
47
|
+
Effect.flatMap(ProviderService, (svc) => {
|
|
48
|
+
if ("blockHash" in args && args.blockHash !== undefined) {
|
|
49
|
+
const hash =
|
|
50
|
+
typeof args.blockHash === "string"
|
|
51
|
+
? args.blockHash
|
|
52
|
+
: `0x${Buffer.from(args.blockHash).toString("hex")}`;
|
|
53
|
+
return svc
|
|
54
|
+
.request<string>("eth_getBlockTransactionCountByHash", [hash])
|
|
55
|
+
.pipe(
|
|
56
|
+
Effect.flatMap((hex) =>
|
|
57
|
+
Effect.try({
|
|
58
|
+
try: () => BigInt(hex),
|
|
59
|
+
catch: (error) =>
|
|
60
|
+
new ProviderResponseError(
|
|
61
|
+
hex,
|
|
62
|
+
"Invalid hex from eth_getBlockTransactionCountByHash",
|
|
63
|
+
{ cause: error },
|
|
64
|
+
),
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const blockTag: BlockTag = args.blockTag ?? "latest";
|
|
71
|
+
return svc
|
|
72
|
+
.request<string>("eth_getBlockTransactionCountByNumber", [blockTag])
|
|
73
|
+
.pipe(
|
|
74
|
+
Effect.flatMap((hex) =>
|
|
75
|
+
Effect.try({
|
|
76
|
+
try: () => BigInt(hex),
|
|
77
|
+
catch: (error) =>
|
|
78
|
+
new ProviderResponseError(
|
|
79
|
+
hex,
|
|
80
|
+
"Invalid hex from eth_getBlockTransactionCountByNumber",
|
|
81
|
+
{ cause: error },
|
|
82
|
+
),
|
|
83
|
+
}),
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get the chain ID.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getChainId
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import { parseHexToBigInt } from "../utils.js";
|
|
11
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
12
|
+
import type { ProviderResponseError } from "../types.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the chain ID of the connected Ethereum network.
|
|
16
|
+
*
|
|
17
|
+
* @returns Effect yielding the chain ID as bigint
|
|
18
|
+
*
|
|
19
|
+
* @since 0.4.0
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { Effect } from 'effect'
|
|
24
|
+
* import { getChainId, Provider, HttpTransport } from 'voltaire-effect'
|
|
25
|
+
*
|
|
26
|
+
* const program = Effect.gen(function* () {
|
|
27
|
+
* const chainId = yield* getChainId()
|
|
28
|
+
* console.log('Chain ID:', chainId)
|
|
29
|
+
* }).pipe(
|
|
30
|
+
* Effect.provide(Provider),
|
|
31
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const getChainId = (): Effect.Effect<
|
|
36
|
+
bigint,
|
|
37
|
+
TransportError | ProviderResponseError,
|
|
38
|
+
ProviderService
|
|
39
|
+
> =>
|
|
40
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
41
|
+
svc.request<string>("eth_chainId").pipe(
|
|
42
|
+
Effect.flatMap((response) =>
|
|
43
|
+
parseHexToBigInt({ method: "eth_chainId", response }),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get contract bytecode.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getCode
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { AddressInput, BlockTag } from "../types.js";
|
|
11
|
+
import { toAddressHex } from "../utils.js";
|
|
12
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the bytecode at an address.
|
|
16
|
+
*
|
|
17
|
+
* @param address - The address to get code from
|
|
18
|
+
* @param blockTag - Block to query at (default: "latest")
|
|
19
|
+
* @returns Effect yielding the bytecode as hex string
|
|
20
|
+
*
|
|
21
|
+
* @since 0.4.0
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { Effect } from 'effect'
|
|
26
|
+
* import { getCode, Provider, HttpTransport } from 'voltaire-effect'
|
|
27
|
+
*
|
|
28
|
+
* const program = Effect.gen(function* () {
|
|
29
|
+
* const code = yield* getCode('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48')
|
|
30
|
+
* console.log(`Code length: ${(code.length - 2) / 2} bytes`)
|
|
31
|
+
* }).pipe(
|
|
32
|
+
* Effect.provide(Provider),
|
|
33
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const getCode = (
|
|
38
|
+
address: AddressInput,
|
|
39
|
+
blockTag: BlockTag = "latest",
|
|
40
|
+
): Effect.Effect<`0x${string}`, TransportError, ProviderService> =>
|
|
41
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
42
|
+
svc.request<`0x${string}`>("eth_getCode", [toAddressHex(address), blockTag]),
|
|
43
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get the coinbase address.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getCoinbase
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Gets the coinbase address of the node.
|
|
14
|
+
*
|
|
15
|
+
* @returns Effect yielding the coinbase address
|
|
16
|
+
*
|
|
17
|
+
* @since 0.4.0
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { Effect } from 'effect'
|
|
22
|
+
* import { getCoinbase, Provider, HttpTransport } from 'voltaire-effect'
|
|
23
|
+
*
|
|
24
|
+
* const program = Effect.gen(function* () {
|
|
25
|
+
* const coinbase = yield* getCoinbase()
|
|
26
|
+
* console.log('Coinbase:', coinbase)
|
|
27
|
+
* }).pipe(
|
|
28
|
+
* Effect.provide(Provider),
|
|
29
|
+
* Effect.provide(HttpTransport('http://localhost:8545'))
|
|
30
|
+
* )
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const getCoinbase = (): Effect.Effect<
|
|
34
|
+
`0x${string}`,
|
|
35
|
+
TransportError,
|
|
36
|
+
ProviderService
|
|
37
|
+
> =>
|
|
38
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
39
|
+
svc.request<`0x${string}`>("eth_coinbase"),
|
|
40
|
+
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get fee history.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getFeeHistory
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { BlockTag, FeeHistoryType } from "../types.js";
|
|
11
|
+
import { ProviderValidationError } from "../types.js";
|
|
12
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
13
|
+
import type { ProviderResponseError } from "../types.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the fee history for a range of blocks.
|
|
17
|
+
*
|
|
18
|
+
* @param blockCount - Number of blocks to return (must be > 0)
|
|
19
|
+
* @param newestBlock - Newest block to include
|
|
20
|
+
* @param rewardPercentiles - Percentiles to sample for priority fees (0-100, ascending)
|
|
21
|
+
* @returns Effect yielding the fee history
|
|
22
|
+
*
|
|
23
|
+
* @since 0.4.0
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { Effect } from 'effect'
|
|
28
|
+
* import { getFeeHistory, Provider, HttpTransport } from 'voltaire-effect'
|
|
29
|
+
*
|
|
30
|
+
* const program = Effect.gen(function* () {
|
|
31
|
+
* const history = yield* getFeeHistory(10, 'latest', [25, 50, 75])
|
|
32
|
+
* console.log('Oldest block:', history.oldestBlock)
|
|
33
|
+
* console.log('Base fees:', history.baseFeePerGas)
|
|
34
|
+
* }).pipe(
|
|
35
|
+
* Effect.provide(Provider),
|
|
36
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
37
|
+
* )
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const getFeeHistory = (
|
|
41
|
+
blockCount: number,
|
|
42
|
+
newestBlock: BlockTag,
|
|
43
|
+
rewardPercentiles: number[],
|
|
44
|
+
): Effect.Effect<
|
|
45
|
+
FeeHistoryType,
|
|
46
|
+
TransportError | ProviderResponseError | ProviderValidationError,
|
|
47
|
+
ProviderService
|
|
48
|
+
> =>
|
|
49
|
+
Effect.gen(function* () {
|
|
50
|
+
if (blockCount <= 0) {
|
|
51
|
+
return yield* Effect.fail(
|
|
52
|
+
new ProviderValidationError(
|
|
53
|
+
{ blockCount, newestBlock, rewardPercentiles },
|
|
54
|
+
"blockCount must be greater than 0",
|
|
55
|
+
),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < rewardPercentiles.length; i++) {
|
|
60
|
+
const p = rewardPercentiles[i];
|
|
61
|
+
if (p < 0 || p > 100) {
|
|
62
|
+
return yield* Effect.fail(
|
|
63
|
+
new ProviderValidationError(
|
|
64
|
+
{ blockCount, newestBlock, rewardPercentiles },
|
|
65
|
+
`Percentile ${p} must be between 0 and 100`,
|
|
66
|
+
),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (i > 0 && p < rewardPercentiles[i - 1]) {
|
|
70
|
+
return yield* Effect.fail(
|
|
71
|
+
new ProviderValidationError(
|
|
72
|
+
{ blockCount, newestBlock, rewardPercentiles },
|
|
73
|
+
"Percentiles must be in ascending order",
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const svc = yield* ProviderService;
|
|
80
|
+
return yield* svc.request<FeeHistoryType>("eth_feeHistory", [
|
|
81
|
+
`0x${blockCount.toString(16)}`,
|
|
82
|
+
newestBlock,
|
|
83
|
+
rewardPercentiles,
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get filter changes.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getFilterChanges
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { FilterId, FilterChanges } from "../types.js";
|
|
11
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Gets changes since last poll for the given filter.
|
|
15
|
+
*
|
|
16
|
+
* Returns logs for event filters, or hashes for block/pending transaction filters.
|
|
17
|
+
*
|
|
18
|
+
* @param filterId - Filter ID from createEventFilter/createBlockFilter/createPendingTransactionFilter
|
|
19
|
+
* @returns Effect yielding logs or hashes depending on filter type
|
|
20
|
+
*
|
|
21
|
+
* @since 0.4.0
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { Effect } from 'effect'
|
|
26
|
+
* import { createBlockFilter, getFilterChanges, Provider, HttpTransport } from 'voltaire-effect'
|
|
27
|
+
*
|
|
28
|
+
* const program = Effect.gen(function* () {
|
|
29
|
+
* const filterId = yield* createBlockFilter()
|
|
30
|
+
* const changes = yield* getFilterChanges(filterId)
|
|
31
|
+
* }).pipe(
|
|
32
|
+
* Effect.provide(Provider),
|
|
33
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
34
|
+
* )
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const getFilterChanges = (
|
|
38
|
+
filterId: FilterId,
|
|
39
|
+
): Effect.Effect<FilterChanges, TransportError, ProviderService> =>
|
|
40
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
41
|
+
svc.request<FilterChanges>("eth_getFilterChanges", [filterId]),
|
|
42
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get all logs for an event filter.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getFilterLogs
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { FilterId, LogType } from "../types.js";
|
|
11
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Gets all logs matching the filter since it was created.
|
|
15
|
+
*
|
|
16
|
+
* Only works for event filters created with createEventFilter.
|
|
17
|
+
*
|
|
18
|
+
* @param filterId - Filter ID from createEventFilter
|
|
19
|
+
* @returns Effect yielding array of logs
|
|
20
|
+
*
|
|
21
|
+
* @since 0.4.0
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { Effect } from 'effect'
|
|
26
|
+
* import { createEventFilter, getFilterLogs, Provider, HttpTransport } from 'voltaire-effect'
|
|
27
|
+
*
|
|
28
|
+
* const program = Effect.gen(function* () {
|
|
29
|
+
* const filterId = yield* createEventFilter({
|
|
30
|
+
* address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
|
|
31
|
+
* })
|
|
32
|
+
* const logs = yield* getFilterLogs(filterId)
|
|
33
|
+
* }).pipe(
|
|
34
|
+
* Effect.provide(Provider),
|
|
35
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
36
|
+
* )
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const getFilterLogs = (
|
|
40
|
+
filterId: FilterId,
|
|
41
|
+
): Effect.Effect<LogType[], TransportError, ProviderService> =>
|
|
42
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
43
|
+
svc.request<LogType[]>("eth_getFilterLogs", [filterId]),
|
|
44
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get the current gas price.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getGasPrice
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import { parseHexToBigInt } from "../utils.js";
|
|
11
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
12
|
+
import type { ProviderResponseError } from "../types.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current gas price in wei.
|
|
16
|
+
*
|
|
17
|
+
* @returns Effect yielding the gas price as bigint
|
|
18
|
+
*
|
|
19
|
+
* @since 0.4.0
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { Effect } from 'effect'
|
|
24
|
+
* import { getGasPrice, Provider, HttpTransport } from 'voltaire-effect'
|
|
25
|
+
*
|
|
26
|
+
* const program = Effect.gen(function* () {
|
|
27
|
+
* const gasPrice = yield* getGasPrice()
|
|
28
|
+
* console.log('Gas price:', gasPrice, 'wei')
|
|
29
|
+
* }).pipe(
|
|
30
|
+
* Effect.provide(Provider),
|
|
31
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const getGasPrice = (): Effect.Effect<
|
|
36
|
+
bigint,
|
|
37
|
+
TransportError | ProviderResponseError,
|
|
38
|
+
ProviderService
|
|
39
|
+
> =>
|
|
40
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
41
|
+
svc.request<string>("eth_gasPrice").pipe(
|
|
42
|
+
Effect.flatMap((response) =>
|
|
43
|
+
parseHexToBigInt({ method: "eth_gasPrice", response }),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get the hashrate.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getHashrate
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import { parseHexToBigInt } from "../utils.js";
|
|
11
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
12
|
+
import type { ProviderResponseError } from "../types.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current hashrate of the node.
|
|
16
|
+
*
|
|
17
|
+
* @returns Effect yielding the hashrate as bigint
|
|
18
|
+
*
|
|
19
|
+
* @since 0.4.0
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { Effect } from 'effect'
|
|
24
|
+
* import { getHashrate, Provider, HttpTransport } from 'voltaire-effect'
|
|
25
|
+
*
|
|
26
|
+
* const program = Effect.gen(function* () {
|
|
27
|
+
* const hashrate = yield* getHashrate()
|
|
28
|
+
* console.log('Hashrate:', hashrate)
|
|
29
|
+
* }).pipe(
|
|
30
|
+
* Effect.provide(Provider),
|
|
31
|
+
* Effect.provide(HttpTransport('http://localhost:8545'))
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const getHashrate = (): Effect.Effect<
|
|
36
|
+
bigint,
|
|
37
|
+
TransportError | ProviderResponseError,
|
|
38
|
+
ProviderService
|
|
39
|
+
> =>
|
|
40
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
41
|
+
svc.request<string>("eth_hashrate").pipe(
|
|
42
|
+
Effect.flatMap((response) =>
|
|
43
|
+
parseHexToBigInt({ method: "eth_hashrate", response }),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get logs matching a filter.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getLogs
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { LogFilter, LogType } from "../types.js";
|
|
11
|
+
import { formatLogFilterParams } from "../utils.js";
|
|
12
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets logs matching the given filter.
|
|
16
|
+
*
|
|
17
|
+
* @param filter - Log filter (blockHash XOR fromBlock/toBlock, plus optional address/topics)
|
|
18
|
+
* @returns Effect yielding array of matching logs
|
|
19
|
+
*
|
|
20
|
+
* @since 0.4.0
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { Effect } from 'effect'
|
|
25
|
+
* import { getLogs, Provider, HttpTransport } from 'voltaire-effect'
|
|
26
|
+
*
|
|
27
|
+
* const program = Effect.gen(function* () {
|
|
28
|
+
* const logs = yield* getLogs({
|
|
29
|
+
* fromBlock: '0x100000',
|
|
30
|
+
* toBlock: '0x100100',
|
|
31
|
+
* address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
|
|
32
|
+
* })
|
|
33
|
+
* console.log(`Found ${logs.length} logs`)
|
|
34
|
+
* }).pipe(
|
|
35
|
+
* Effect.provide(Provider),
|
|
36
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
37
|
+
* )
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const getLogs = (
|
|
41
|
+
filter: LogFilter,
|
|
42
|
+
): Effect.Effect<LogType[], TransportError, ProviderService> =>
|
|
43
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
44
|
+
svc.request<LogType[]>("eth_getLogs", [formatLogFilterParams(filter)]),
|
|
45
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get the max priority fee per gas.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getMaxPriorityFeePerGas
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import { parseHexToBigInt } from "../utils.js";
|
|
11
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
12
|
+
import type { ProviderResponseError } from "../types.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the suggested max priority fee per gas for EIP-1559 transactions.
|
|
16
|
+
*
|
|
17
|
+
* @returns Effect yielding the max priority fee as bigint
|
|
18
|
+
*
|
|
19
|
+
* @since 0.4.0
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { Effect } from 'effect'
|
|
24
|
+
* import { getMaxPriorityFeePerGas, Provider, HttpTransport } from 'voltaire-effect'
|
|
25
|
+
*
|
|
26
|
+
* const program = Effect.gen(function* () {
|
|
27
|
+
* const priorityFee = yield* getMaxPriorityFeePerGas()
|
|
28
|
+
* console.log('Priority fee:', priorityFee, 'wei')
|
|
29
|
+
* }).pipe(
|
|
30
|
+
* Effect.provide(Provider),
|
|
31
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
32
|
+
* )
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export const getMaxPriorityFeePerGas = (): Effect.Effect<
|
|
36
|
+
bigint,
|
|
37
|
+
TransportError | ProviderResponseError,
|
|
38
|
+
ProviderService
|
|
39
|
+
> =>
|
|
40
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
41
|
+
svc.request<string>("eth_maxPriorityFeePerGas").pipe(
|
|
42
|
+
Effect.flatMap((response) =>
|
|
43
|
+
parseHexToBigInt({ method: "eth_maxPriorityFeePerGas", response }),
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to check mining status.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getMining
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks if the node is currently mining.
|
|
14
|
+
*
|
|
15
|
+
* @returns Effect yielding true if mining, false otherwise
|
|
16
|
+
*
|
|
17
|
+
* @since 0.4.0
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { Effect } from 'effect'
|
|
22
|
+
* import { getMining, Provider, HttpTransport } from 'voltaire-effect'
|
|
23
|
+
*
|
|
24
|
+
* const program = Effect.gen(function* () {
|
|
25
|
+
* const isMining = yield* getMining()
|
|
26
|
+
* console.log('Mining:', isMining)
|
|
27
|
+
* }).pipe(
|
|
28
|
+
* Effect.provide(Provider),
|
|
29
|
+
* Effect.provide(HttpTransport('http://localhost:8545'))
|
|
30
|
+
* )
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const getMining = (): Effect.Effect<
|
|
34
|
+
boolean,
|
|
35
|
+
TransportError,
|
|
36
|
+
ProviderService
|
|
37
|
+
> =>
|
|
38
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
39
|
+
svc.request<boolean>("eth_mining"),
|
|
40
|
+
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Free function to get Merkle-Patricia proof for an account.
|
|
3
|
+
*
|
|
4
|
+
* @module Provider/functions/getProof
|
|
5
|
+
* @since 0.4.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { ProviderService } from "../ProviderService.js";
|
|
10
|
+
import type { AddressInput, BlockTag, HashInput, ProofType } from "../types.js";
|
|
11
|
+
import { toAddressHex, toHashHex } from "../utils.js";
|
|
12
|
+
import type { TransportError } from "../../Transport/TransportError.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets a Merkle-Patricia proof for an account and storage slots.
|
|
16
|
+
*
|
|
17
|
+
* @param address - The address to get proof for
|
|
18
|
+
* @param storageKeys - Array of storage slots to include in proof
|
|
19
|
+
* @param blockTag - Block to query at (default: "latest")
|
|
20
|
+
* @returns Effect yielding the proof
|
|
21
|
+
*
|
|
22
|
+
* @since 0.4.0
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { Effect } from 'effect'
|
|
27
|
+
* import { getProof, Provider, HttpTransport } from 'voltaire-effect'
|
|
28
|
+
*
|
|
29
|
+
* const program = Effect.gen(function* () {
|
|
30
|
+
* const proof = yield* getProof(
|
|
31
|
+
* '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
32
|
+
* ['0x0000000000000000000000000000000000000000000000000000000000000000']
|
|
33
|
+
* )
|
|
34
|
+
* console.log(`Account proof nodes: ${proof.accountProof.length}`)
|
|
35
|
+
* }).pipe(
|
|
36
|
+
* Effect.provide(Provider),
|
|
37
|
+
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
38
|
+
* )
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export const getProof = (
|
|
42
|
+
address: AddressInput,
|
|
43
|
+
storageKeys: HashInput[],
|
|
44
|
+
blockTag: BlockTag = "latest",
|
|
45
|
+
): Effect.Effect<ProofType, TransportError, ProviderService> =>
|
|
46
|
+
Effect.flatMap(ProviderService, (svc) =>
|
|
47
|
+
svc.request<ProofType>("eth_getProof", [
|
|
48
|
+
toAddressHex(address),
|
|
49
|
+
storageKeys.map(toHashHex),
|
|
50
|
+
blockTag,
|
|
51
|
+
]),
|
|
52
|
+
);
|