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
|
@@ -90,7 +90,7 @@ const makeRetrySchedule = (retryCount: number, retryDelay: number) => {
|
|
|
90
90
|
* @example Basic fallback between multiple HTTP transports
|
|
91
91
|
* ```typescript
|
|
92
92
|
* import { Effect } from 'effect'
|
|
93
|
-
* import { FallbackTransport, HttpTransport,
|
|
93
|
+
* import { FallbackTransport, HttpTransport, Provider, getBlockNumber } from 'voltaire-effect'
|
|
94
94
|
*
|
|
95
95
|
* const transport = FallbackTransport([
|
|
96
96
|
* HttpTransport('https://eth.llamarpc.com'),
|
|
@@ -99,8 +99,8 @@ const makeRetrySchedule = (retryCount: number, retryDelay: number) => {
|
|
|
99
99
|
* ])
|
|
100
100
|
*
|
|
101
101
|
* const program = Effect.gen(function* () {
|
|
102
|
-
* const
|
|
103
|
-
* return
|
|
102
|
+
* const blockNumber = yield* getBlockNumber()
|
|
103
|
+
* return blockNumber
|
|
104
104
|
* }).pipe(
|
|
105
105
|
* Effect.provide(Provider),
|
|
106
106
|
* Effect.provide(transport)
|
|
@@ -170,7 +170,7 @@ interface JsonRpcResponse<T> {
|
|
|
170
170
|
* ```typescript
|
|
171
171
|
* import { Effect, Schedule } from 'effect'
|
|
172
172
|
* import { FetchHttpClient } from '@effect/platform'
|
|
173
|
-
* import { HttpTransport, Provider,
|
|
173
|
+
* import { HttpTransport, Provider, getBlockNumber } from 'voltaire-effect'
|
|
174
174
|
*
|
|
175
175
|
* const transport = HttpTransport({
|
|
176
176
|
* url: 'https://mainnet.infura.io/v3/YOUR_KEY',
|
|
@@ -186,8 +186,8 @@ interface JsonRpcResponse<T> {
|
|
|
186
186
|
* })
|
|
187
187
|
*
|
|
188
188
|
* const program = Effect.gen(function* () {
|
|
189
|
-
* const
|
|
190
|
-
* return
|
|
189
|
+
* const blockNumber = yield* getBlockNumber()
|
|
190
|
+
* return blockNumber
|
|
191
191
|
* }).pipe(
|
|
192
192
|
* Effect.provide(Provider),
|
|
193
193
|
* Effect.provide(transport),
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
* @example
|
|
17
17
|
* ```typescript
|
|
18
18
|
* import { Effect, Schedule } from "effect"
|
|
19
|
-
* import { withTimeout, withRetrySchedule } from "voltaire-effect"
|
|
19
|
+
* import { getBalance, withTimeout, withRetrySchedule } from "voltaire-effect"
|
|
20
20
|
*
|
|
21
21
|
* // Default timeout is 30s with exponential backoff retries
|
|
22
|
-
* const balance = yield*
|
|
22
|
+
* const balance = yield* getBalance(addr)
|
|
23
23
|
*
|
|
24
24
|
* // This call uses a 5s timeout and custom retry schedule
|
|
25
|
-
* const fastBalance = yield*
|
|
25
|
+
* const fastBalance = yield* getBalance(addr).pipe(
|
|
26
26
|
* withTimeout("5 seconds"),
|
|
27
27
|
* withRetrySchedule(Schedule.recurs(1))
|
|
28
28
|
* )
|
|
@@ -91,8 +91,8 @@ export const tracingRef: FiberRef.FiberRef<boolean> =
|
|
|
91
91
|
*
|
|
92
92
|
* @example
|
|
93
93
|
* ```typescript
|
|
94
|
-
*
|
|
95
|
-
*
|
|
94
|
+
* getBalance(addr).pipe(withTimeout("5 seconds"))
|
|
95
|
+
* getBalance(addr).pipe(withTimeout(Duration.seconds(5)))
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
98
|
export const withTimeout =
|
|
@@ -108,14 +108,14 @@ export const withTimeout =
|
|
|
108
108
|
*
|
|
109
109
|
* @example Simple retry count
|
|
110
110
|
* ```typescript
|
|
111
|
-
*
|
|
111
|
+
* getBalance(addr).pipe(
|
|
112
112
|
* withRetrySchedule(Schedule.recurs(1))
|
|
113
113
|
* )
|
|
114
114
|
* ```
|
|
115
115
|
*
|
|
116
116
|
* @example Exponential backoff with jitter
|
|
117
117
|
* ```typescript
|
|
118
|
-
*
|
|
118
|
+
* getBalance(addr).pipe(
|
|
119
119
|
* withRetrySchedule(
|
|
120
120
|
* Schedule.exponential("500 millis").pipe(
|
|
121
121
|
* Schedule.jittered,
|
|
@@ -20,15 +20,14 @@
|
|
|
20
20
|
* ```typescript
|
|
21
21
|
* import { Effect } from 'effect'
|
|
22
22
|
* import {
|
|
23
|
-
* TransportService,
|
|
24
23
|
* HttpTransport,
|
|
25
24
|
* Provider,
|
|
26
|
-
*
|
|
25
|
+
* getBlockNumber
|
|
27
26
|
* } from 'voltaire-effect'
|
|
28
27
|
*
|
|
29
28
|
* const program = Effect.gen(function* () {
|
|
30
|
-
* const
|
|
31
|
-
* return
|
|
29
|
+
* const blockNumber = yield* getBlockNumber()
|
|
30
|
+
* return blockNumber
|
|
32
31
|
* }).pipe(
|
|
33
32
|
* Effect.provide(Provider),
|
|
34
33
|
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
@@ -26,10 +26,8 @@ import {
|
|
|
26
26
|
} from "./Contract/ContractTypes.js";
|
|
27
27
|
import { KzgError } from "./Kzg/KzgService.js";
|
|
28
28
|
import { Provider } from "./Provider/Provider.js";
|
|
29
|
-
import {
|
|
30
|
-
|
|
31
|
-
ProviderService,
|
|
32
|
-
} from "./Provider/ProviderService.js";
|
|
29
|
+
import { getBlockNumber } from "./Provider/functions/index.js";
|
|
30
|
+
import { ProviderResponseError } from "./Provider/ProviderService.js";
|
|
33
31
|
import { SignerError } from "./Signer/SignerService.js";
|
|
34
32
|
import {
|
|
35
33
|
DeserializeError,
|
|
@@ -261,10 +259,7 @@ describe("Error constructor standardization", () => {
|
|
|
261
259
|
const layer = Provider.pipe(Layer.provide(transport));
|
|
262
260
|
|
|
263
261
|
const exit = await Effect.runPromiseExit(
|
|
264
|
-
Effect.
|
|
265
|
-
const provider = yield* ProviderService;
|
|
266
|
-
return yield* provider.getBlockNumber();
|
|
267
|
-
}).pipe(Effect.provide(layer)),
|
|
262
|
+
getBlockNumber().pipe(Effect.provide(layer)),
|
|
268
263
|
);
|
|
269
264
|
|
|
270
265
|
expect(Exit.isFailure(exit)).toBe(true);
|
package/src/services/index.ts
CHANGED
|
@@ -45,18 +45,20 @@
|
|
|
45
45
|
* Type-safe smart contract interactions.
|
|
46
46
|
* - {@link Contract} - Factory to create contract instances
|
|
47
47
|
*
|
|
48
|
-
* @example Typical usage pattern
|
|
48
|
+
* @example Typical usage pattern (using free functions - idiomatic Effect.ts)
|
|
49
49
|
* ```typescript
|
|
50
50
|
* import { Effect } from 'effect'
|
|
51
51
|
* import {
|
|
52
|
-
*
|
|
52
|
+
* getBlockNumber,
|
|
53
|
+
* getBalance,
|
|
53
54
|
* Provider,
|
|
54
55
|
* HttpTransport
|
|
55
56
|
* } from 'voltaire-effect'
|
|
56
57
|
*
|
|
57
58
|
* const program = Effect.gen(function* () {
|
|
58
|
-
* const
|
|
59
|
-
*
|
|
59
|
+
* const blockNumber = yield* getBlockNumber()
|
|
60
|
+
* const balance = yield* getBalance('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045')
|
|
61
|
+
* return { blockNumber, balance }
|
|
60
62
|
* }).pipe(
|
|
61
63
|
* Effect.provide(Provider),
|
|
62
64
|
* Effect.provide(HttpTransport('https://mainnet.infura.io/v3/YOUR_KEY'))
|
|
@@ -255,92 +257,8 @@ export {
|
|
|
255
257
|
NonceManagerService,
|
|
256
258
|
type NonceManagerShape,
|
|
257
259
|
} from "./NonceManager/index.js";
|
|
258
|
-
// Provider exports
|
|
259
|
-
export
|
|
260
|
-
type AccessListType,
|
|
261
|
-
Account as ProviderAccount,
|
|
262
|
-
AccountService as ProviderAccountService,
|
|
263
|
-
type AccountShape as ProviderAccountShape,
|
|
264
|
-
type BackfillBlocksError,
|
|
265
|
-
Blocks,
|
|
266
|
-
BlocksService,
|
|
267
|
-
type BlocksShape,
|
|
268
|
-
type BlockTag as ProviderBlockTag,
|
|
269
|
-
type BlockType,
|
|
270
|
-
type CallError,
|
|
271
|
-
type CallRequest,
|
|
272
|
-
type CreateAccessListError,
|
|
273
|
-
type CreateBlockFilterError,
|
|
274
|
-
type CreateEventFilterError,
|
|
275
|
-
type CreatePendingTransactionFilterError,
|
|
276
|
-
type EstimateGasError,
|
|
277
|
-
type EventFilter as ProviderEventFilter,
|
|
278
|
-
Events,
|
|
279
|
-
EventsService,
|
|
280
|
-
type EventsShape,
|
|
281
|
-
type FeeHistoryType,
|
|
282
|
-
type FilterChanges as ProviderFilterChanges,
|
|
283
|
-
type FilterId as ProviderFilterId,
|
|
284
|
-
type GetBalanceError,
|
|
285
|
-
type GetBlobBaseFeeError,
|
|
286
|
-
type GetBlockError,
|
|
287
|
-
type GetBlockNumberError,
|
|
288
|
-
type GetBlockTransactionCountError,
|
|
289
|
-
type GetChainIdError,
|
|
290
|
-
type GetCodeError,
|
|
291
|
-
type GetFeeHistoryError,
|
|
292
|
-
type GetFilterChangesError,
|
|
293
|
-
type GetFilterLogsError,
|
|
294
|
-
type GetGasPriceError,
|
|
295
|
-
type GetLogsError,
|
|
296
|
-
type GetMaxPriorityFeePerGasError,
|
|
297
|
-
type GetProofError,
|
|
298
|
-
type GetStorageAtError,
|
|
299
|
-
type GetTransactionConfirmationsError,
|
|
300
|
-
type GetTransactionCountError,
|
|
301
|
-
type GetTransactionError,
|
|
302
|
-
type GetTransactionReceiptError,
|
|
303
|
-
type GetUncleError,
|
|
304
|
-
type LogFilter as ProviderLogFilter,
|
|
305
|
-
type LogType,
|
|
306
|
-
Network,
|
|
307
|
-
NetworkService,
|
|
308
|
-
type NetworkShape,
|
|
309
|
-
Provider,
|
|
310
|
-
ProviderConfirmationsPendingError,
|
|
311
|
-
type ProviderError,
|
|
312
|
-
ProviderNotFoundError,
|
|
313
|
-
ProviderReceiptPendingError,
|
|
314
|
-
ProviderResponseError,
|
|
315
|
-
ProviderService,
|
|
316
|
-
type ProviderShape,
|
|
317
|
-
ProviderStreamError,
|
|
318
|
-
ProviderTimeoutError,
|
|
319
|
-
ProviderValidationError,
|
|
320
|
-
type ReceiptType,
|
|
321
|
-
type SendRawTransactionError,
|
|
322
|
-
type SimulateV1BlockResult,
|
|
323
|
-
type SimulateV1CallResult,
|
|
324
|
-
type SimulateV1Payload,
|
|
325
|
-
type SimulateV1Result,
|
|
326
|
-
type SimulateV2Payload,
|
|
327
|
-
type SimulateV2Result,
|
|
328
|
-
Simulation,
|
|
329
|
-
SimulationService,
|
|
330
|
-
type SimulationShape,
|
|
331
|
-
Streaming,
|
|
332
|
-
StreamingService,
|
|
333
|
-
type StreamingShape,
|
|
334
|
-
type SyncingStatus,
|
|
335
|
-
Transaction,
|
|
336
|
-
TransactionService,
|
|
337
|
-
type TransactionShape,
|
|
338
|
-
type TransactionType,
|
|
339
|
-
type UninstallFilterError,
|
|
340
|
-
type WaitForTransactionReceiptError,
|
|
341
|
-
type WatchBlocksError,
|
|
342
|
-
type WorkResult,
|
|
343
|
-
} from "./Provider/index.js";
|
|
260
|
+
// Provider exports - re-export everything from the Provider module
|
|
261
|
+
export * from "./Provider/index.js";
|
|
344
262
|
// Preset exports (layer composition helpers)
|
|
345
263
|
export {
|
|
346
264
|
ArbitrumProvider,
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
* @example Using MainnetProvider
|
|
12
12
|
* ```typescript
|
|
13
13
|
* import { Effect } from 'effect'
|
|
14
|
-
* import {
|
|
14
|
+
* import { getChainId, MainnetProvider } from 'voltaire-effect'
|
|
15
15
|
*
|
|
16
16
|
* const program = Effect.gen(function* () {
|
|
17
|
-
* const
|
|
18
|
-
* return
|
|
17
|
+
* const chainId = yield* getChainId()
|
|
18
|
+
* return chainId
|
|
19
19
|
* }).pipe(Effect.provide(MainnetProvider('https://mainnet.infura.io/v3/YOUR_KEY')))
|
|
20
20
|
*
|
|
21
21
|
* await Effect.runPromise(program)
|
|
@@ -67,12 +67,11 @@ import { HttpTransport } from "../Transport/index.js";
|
|
|
67
67
|
* @example
|
|
68
68
|
* ```typescript
|
|
69
69
|
* import { Effect } from 'effect'
|
|
70
|
-
* import {
|
|
70
|
+
* import { getBlockNumber, getChainId, MainnetProvider } from 'voltaire-effect'
|
|
71
71
|
*
|
|
72
72
|
* const program = Effect.gen(function* () {
|
|
73
|
-
* const
|
|
74
|
-
* const
|
|
75
|
-
* const chainId = yield* provider.getChainId()
|
|
73
|
+
* const blockNumber = yield* getBlockNumber()
|
|
74
|
+
* const chainId = yield* getChainId()
|
|
76
75
|
* return { blockNumber, chainId }
|
|
77
76
|
* }).pipe(Effect.provide(MainnetProvider('https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY')))
|
|
78
77
|
*
|
|
@@ -100,15 +99,15 @@ export const MainnetProvider = (url: string): Layer.Layer<ProviderService> =>
|
|
|
100
99
|
* @example
|
|
101
100
|
* ```typescript
|
|
102
101
|
* import { Effect } from 'effect'
|
|
103
|
-
* import {
|
|
102
|
+
* import { getChainId, createProvider } from 'voltaire-effect'
|
|
104
103
|
*
|
|
105
104
|
* // Works with any network
|
|
106
105
|
* const arbitrumProvider = createProvider('https://arb1.arbitrum.io/rpc')
|
|
107
106
|
* const optimismProvider = createProvider('https://mainnet.optimism.io')
|
|
108
107
|
*
|
|
109
108
|
* const program = Effect.gen(function* () {
|
|
110
|
-
* const
|
|
111
|
-
* return
|
|
109
|
+
* const chainId = yield* getChainId()
|
|
110
|
+
* return chainId
|
|
112
111
|
* }).pipe(Effect.provide(arbitrumProvider))
|
|
113
112
|
* ```
|
|
114
113
|
*/
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { describe, expect, it } from "@effect/vitest";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Provider,
|
|
6
|
+
getBalance,
|
|
7
|
+
getBlockNumber,
|
|
8
|
+
getChainId,
|
|
9
|
+
} from "../Provider/index.js";
|
|
5
10
|
import { TestTransport } from "../Transport/index.js";
|
|
6
11
|
import { createProvider, MainnetProvider } from "./index.js";
|
|
7
12
|
|
|
@@ -13,13 +18,8 @@ describe("presets", () => {
|
|
|
13
18
|
Layer.provide(TestTransport({ eth_chainId: "0x1" })),
|
|
14
19
|
);
|
|
15
20
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
return yield* provider.getChainId();
|
|
19
|
-
}).pipe(Effect.provide(testLayer));
|
|
20
|
-
|
|
21
|
-
const result = yield* program;
|
|
22
|
-
expect(result).toBe(1);
|
|
21
|
+
const result = yield* getChainId().pipe(Effect.provide(testLayer));
|
|
22
|
+
expect(result).toBe(1n);
|
|
23
23
|
}),
|
|
24
24
|
);
|
|
25
25
|
|
|
@@ -29,12 +29,7 @@ describe("presets", () => {
|
|
|
29
29
|
Layer.provide(TestTransport({ eth_blockNumber: "0x1234" })),
|
|
30
30
|
);
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
const provider = yield* ProviderService;
|
|
34
|
-
return yield* provider.getBlockNumber();
|
|
35
|
-
}).pipe(Effect.provide(testLayer));
|
|
36
|
-
|
|
37
|
-
const result = yield* program;
|
|
32
|
+
const result = yield* getBlockNumber().pipe(Effect.provide(testLayer));
|
|
38
33
|
expect(result).toBe(0x1234n);
|
|
39
34
|
}),
|
|
40
35
|
);
|
|
@@ -52,13 +47,8 @@ describe("presets", () => {
|
|
|
52
47
|
Layer.provide(TestTransport({ eth_chainId: "0xa4b1" })),
|
|
53
48
|
);
|
|
54
49
|
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
return yield* provider.getChainId();
|
|
58
|
-
}).pipe(Effect.provide(testLayer));
|
|
59
|
-
|
|
60
|
-
const result = yield* program;
|
|
61
|
-
expect(result).toBe(42161);
|
|
50
|
+
const result = yield* getChainId().pipe(Effect.provide(testLayer));
|
|
51
|
+
expect(result).toBe(42161n);
|
|
62
52
|
}),
|
|
63
53
|
);
|
|
64
54
|
|
|
@@ -68,14 +58,9 @@ describe("presets", () => {
|
|
|
68
58
|
Layer.provide(TestTransport({ eth_getBalance: "0xde0b6b3a7640000" })),
|
|
69
59
|
);
|
|
70
60
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"0x1234567890123456789012345678901234567890",
|
|
75
|
-
);
|
|
76
|
-
}).pipe(Effect.provide(testLayer));
|
|
77
|
-
|
|
78
|
-
const result = yield* program;
|
|
61
|
+
const result = yield* getBalance(
|
|
62
|
+
"0x1234567890123456789012345678901234567890",
|
|
63
|
+
).pipe(Effect.provide(testLayer));
|
|
79
64
|
expect(result).toBe(1000000000000000000n);
|
|
80
65
|
}),
|
|
81
66
|
);
|
|
@@ -5,20 +5,19 @@ import * as Layer from "effect/Layer";
|
|
|
5
5
|
import { ProviderService } from "../services/Provider/index.js";
|
|
6
6
|
import * as ERC165 from "./ERC165.js";
|
|
7
7
|
|
|
8
|
+
const mockCallFn = vi.fn();
|
|
9
|
+
|
|
8
10
|
const mockProvider = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
estimateGas: vi.fn(),
|
|
20
|
-
getChainId: vi.fn(),
|
|
21
|
-
getGasPrice: vi.fn(),
|
|
11
|
+
request: <T>(method: string, params?: unknown[]) => {
|
|
12
|
+
switch (method) {
|
|
13
|
+
case "eth_call":
|
|
14
|
+
return mockCallFn(params?.[0]) as Effect.Effect<T, never>;
|
|
15
|
+
case "eth_chainId":
|
|
16
|
+
return Effect.succeed("0x1" as T);
|
|
17
|
+
default:
|
|
18
|
+
return Effect.succeed(null as T);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
const MockProviderLayer = Layer.succeed(
|
|
@@ -96,7 +95,7 @@ describe("ERC165", () => {
|
|
|
96
95
|
|
|
97
96
|
describe("supportsInterface", () => {
|
|
98
97
|
it("returns true when contract supports interface", async () => {
|
|
99
|
-
|
|
98
|
+
mockCallFn.mockReturnValue(
|
|
100
99
|
Effect.succeed(
|
|
101
100
|
"0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
102
101
|
),
|
|
@@ -110,11 +109,11 @@ describe("ERC165", () => {
|
|
|
110
109
|
);
|
|
111
110
|
|
|
112
111
|
expect(result).toBe(true);
|
|
113
|
-
expect(
|
|
112
|
+
expect(mockCallFn).toHaveBeenCalled();
|
|
114
113
|
});
|
|
115
114
|
|
|
116
115
|
it("returns false when contract does not support interface", async () => {
|
|
117
|
-
|
|
116
|
+
mockCallFn.mockReturnValue(
|
|
118
117
|
Effect.succeed(
|
|
119
118
|
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
120
119
|
),
|
|
@@ -131,7 +130,7 @@ describe("ERC165", () => {
|
|
|
131
130
|
});
|
|
132
131
|
|
|
133
132
|
it("returns false on empty response", async () => {
|
|
134
|
-
|
|
133
|
+
mockCallFn.mockReturnValue(Effect.succeed("0x"));
|
|
135
134
|
|
|
136
135
|
const result = await Effect.runPromise(
|
|
137
136
|
ERC165.supportsInterface(
|
|
@@ -144,7 +143,7 @@ describe("ERC165", () => {
|
|
|
144
143
|
});
|
|
145
144
|
|
|
146
145
|
it("returns false on call failure", async () => {
|
|
147
|
-
|
|
146
|
+
mockCallFn.mockReturnValue(
|
|
148
147
|
Effect.fail(new Error("execution reverted")),
|
|
149
148
|
);
|
|
150
149
|
|
|
@@ -161,7 +160,7 @@ describe("ERC165", () => {
|
|
|
161
160
|
|
|
162
161
|
describe("detectInterfaces", () => {
|
|
163
162
|
it("returns empty array when contract does not support ERC165", async () => {
|
|
164
|
-
|
|
163
|
+
mockCallFn.mockReturnValue(
|
|
165
164
|
Effect.succeed(
|
|
166
165
|
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
167
166
|
),
|
|
@@ -177,7 +176,7 @@ describe("ERC165", () => {
|
|
|
177
176
|
});
|
|
178
177
|
|
|
179
178
|
it("returns detected interfaces when contract supports ERC165", async () => {
|
|
180
|
-
|
|
179
|
+
mockCallFn.mockImplementation(({ data }: { data: string }) => {
|
|
181
180
|
const encodedERC165 = "01ffc9a7";
|
|
182
181
|
const encodedERC721 = "80ac58cd";
|
|
183
182
|
const encodedERC721Metadata = "5b5e139f";
|
package/src/standards/ERC165.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ERC165 as ERC165Impl } from "@tevm/voltaire";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import {
|
|
3
|
+
import { call } from "../services/Provider/functions/index.js";
|
|
4
|
+
import type { ProviderService } from "../services/Provider/index.js";
|
|
4
5
|
import { StandardsError } from "./errors.js";
|
|
5
6
|
|
|
6
7
|
export const SELECTOR = ERC165Impl.SELECTOR;
|
|
@@ -37,18 +38,15 @@ export const supportsInterface = (
|
|
|
37
38
|
interfaceId: string,
|
|
38
39
|
): Effect.Effect<boolean, StandardsError, ProviderService> =>
|
|
39
40
|
Effect.gen(function* () {
|
|
40
|
-
const provider = yield* ProviderService;
|
|
41
41
|
const data = yield* encodeSupportsInterface(interfaceId);
|
|
42
42
|
|
|
43
|
-
const result = yield*
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Effect.catchAll(() => Effect.succeed(false)),
|
|
51
|
-
);
|
|
43
|
+
const result = yield* call({ to: contract as `0x${string}`, data: data as `0x${string}` }).pipe(
|
|
44
|
+
Effect.map((res) => {
|
|
45
|
+
if (!res || res === "0x") return false;
|
|
46
|
+
return ERC165Impl.decodeSupportsInterface(res);
|
|
47
|
+
}),
|
|
48
|
+
Effect.catchAll(() => Effect.succeed(false)),
|
|
49
|
+
);
|
|
52
50
|
|
|
53
51
|
return result;
|
|
54
52
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tests verifying type exports are accessible from root module
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expectTypeOf } from "vitest";
|
|
5
|
+
import type { AddressType, HexType, HashType, BrandedAddress, HexBrand, Sized } from "./index.js";
|
|
6
|
+
|
|
7
|
+
describe("root type exports", () => {
|
|
8
|
+
it("AddressType is exported and usable", () => {
|
|
9
|
+
const addr: AddressType = new Uint8Array(20) as AddressType;
|
|
10
|
+
expectTypeOf(addr).toMatchTypeOf<Uint8Array>();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("HexType is exported and usable", () => {
|
|
14
|
+
const hex: HexType = "0xdeadbeef" as HexType;
|
|
15
|
+
expectTypeOf(hex).toMatchTypeOf<string>();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("HashType is exported and usable", () => {
|
|
19
|
+
const hash: HashType = new Uint8Array(32) as HashType;
|
|
20
|
+
expectTypeOf(hash).toMatchTypeOf<Uint8Array>();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("BrandedAddress is exported", () => {
|
|
24
|
+
type Test = BrandedAddress;
|
|
25
|
+
expectTypeOf<Test>().not.toBeNever();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("HexBrand is exported", () => {
|
|
29
|
+
type Test = HexBrand;
|
|
30
|
+
expectTypeOf<Test>().not.toBeNever();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("Sized is exported", () => {
|
|
34
|
+
type Test = Sized<32>;
|
|
35
|
+
expectTypeOf<Test>().toMatchTypeOf<string>();
|
|
36
|
+
});
|
|
37
|
+
});
|