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
|
@@ -99,83 +99,116 @@ const mockAccount: AccountShape = {
|
|
|
99
99
|
clearKey: () => Effect.void,
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
totalDifficulty: "0x0",
|
|
118
|
-
extraData: "0x",
|
|
119
|
-
size: "0x0",
|
|
120
|
-
gasLimit: "0x0",
|
|
121
|
-
gasUsed: "0x0",
|
|
122
|
-
timestamp: "0x0",
|
|
123
|
-
transactions: [],
|
|
124
|
-
uncles: [],
|
|
125
|
-
baseFeePerGas: "0x3b9aca00",
|
|
126
|
-
}),
|
|
127
|
-
getBlockTransactionCount: () => Effect.succeed(0n),
|
|
128
|
-
getBalance: () => Effect.succeed(1000000000000000000n),
|
|
129
|
-
getTransactionCount: () => Effect.succeed(5n),
|
|
130
|
-
getCode: () => Effect.succeed("0x"),
|
|
131
|
-
getStorageAt: () => Effect.succeed("0x0"),
|
|
132
|
-
getTransaction: () => Effect.succeed({} as never),
|
|
133
|
-
getTransactionReceipt: () => Effect.succeed({} as never),
|
|
134
|
-
waitForTransactionReceipt: () =>
|
|
135
|
-
Effect.succeed({
|
|
136
|
-
transactionHash: mockTxHashHex,
|
|
137
|
-
blockNumber: "0x1",
|
|
138
|
-
blockHash: "0xabc",
|
|
139
|
-
transactionIndex: "0x0",
|
|
140
|
-
from: "0xabababababababababababababababababababab",
|
|
141
|
-
to: null,
|
|
142
|
-
contractAddress: mockContractAddress,
|
|
143
|
-
cumulativeGasUsed: "0x5208",
|
|
144
|
-
gasUsed: "0x5208",
|
|
145
|
-
logs: [],
|
|
146
|
-
logsBloom: "0x0",
|
|
147
|
-
status: "0x1",
|
|
148
|
-
effectiveGasPrice: "0x3b9aca00",
|
|
149
|
-
type: "0x2",
|
|
150
|
-
}),
|
|
151
|
-
call: () => Effect.succeed("0x"),
|
|
152
|
-
estimateGas: () => Effect.succeed(100000n),
|
|
153
|
-
createAccessList: () => Effect.succeed({ accessList: [], gasUsed: "0x0" }),
|
|
154
|
-
getLogs: () => Effect.succeed([]),
|
|
155
|
-
createEventFilter: () => Effect.succeed("0x1" as any),
|
|
156
|
-
createBlockFilter: () => Effect.succeed("0x1" as any),
|
|
157
|
-
createPendingTransactionFilter: () => Effect.succeed("0x1" as any),
|
|
158
|
-
getFilterChanges: () => Effect.succeed([]),
|
|
159
|
-
getFilterLogs: () => Effect.succeed([]),
|
|
160
|
-
uninstallFilter: () => Effect.succeed(true),
|
|
161
|
-
getChainId: () => Effect.succeed(1),
|
|
162
|
-
getGasPrice: () => Effect.succeed(20000000000n),
|
|
163
|
-
getMaxPriorityFeePerGas: () => Effect.succeed(1000000000n),
|
|
164
|
-
getFeeHistory: () =>
|
|
165
|
-
Effect.succeed({ oldestBlock: "0x0", baseFeePerGas: [], gasUsedRatio: [] }),
|
|
166
|
-
sendRawTransaction: () => Effect.succeed("0x" as `0x${string}`),
|
|
167
|
-
getUncle: () => Effect.succeed({} as any),
|
|
168
|
-
getProof: () => Effect.succeed({} as any),
|
|
169
|
-
getBlobBaseFee: () => Effect.succeed(0n),
|
|
170
|
-
getTransactionConfirmations: () => Effect.succeed(0n),
|
|
171
|
-
watchBlocks: () => {
|
|
172
|
-
throw new Error("Not implemented in mock");
|
|
173
|
-
},
|
|
174
|
-
backfillBlocks: () => {
|
|
175
|
-
throw new Error("Not implemented in mock");
|
|
176
|
-
},
|
|
102
|
+
type ReceiptOverride = {
|
|
103
|
+
transactionHash: string;
|
|
104
|
+
blockNumber: string;
|
|
105
|
+
blockHash: string;
|
|
106
|
+
transactionIndex: string;
|
|
107
|
+
from: string;
|
|
108
|
+
to: null;
|
|
109
|
+
contractAddress: string | null;
|
|
110
|
+
cumulativeGasUsed: string;
|
|
111
|
+
gasUsed: string;
|
|
112
|
+
logs: unknown[];
|
|
113
|
+
logsBloom: string;
|
|
114
|
+
status: string;
|
|
115
|
+
effectiveGasPrice: string;
|
|
116
|
+
type: string;
|
|
177
117
|
};
|
|
178
118
|
|
|
119
|
+
const createMockProviderWithReceipt = (
|
|
120
|
+
receiptOverride?: ReceiptOverride | "error",
|
|
121
|
+
): ProviderShape => ({
|
|
122
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
123
|
+
switch (method) {
|
|
124
|
+
case "eth_blockNumber":
|
|
125
|
+
return Effect.succeed("0x3039" as T); // 12345
|
|
126
|
+
case "eth_getBlockByNumber":
|
|
127
|
+
case "eth_getBlockByHash":
|
|
128
|
+
return Effect.succeed({
|
|
129
|
+
number: "0x1",
|
|
130
|
+
hash: "0xabc",
|
|
131
|
+
parentHash: "0x0",
|
|
132
|
+
nonce: "0x0",
|
|
133
|
+
sha3Uncles: "0x0",
|
|
134
|
+
logsBloom: "0x0",
|
|
135
|
+
transactionsRoot: "0x0",
|
|
136
|
+
stateRoot: "0x0",
|
|
137
|
+
receiptsRoot: "0x0",
|
|
138
|
+
miner: "0x0",
|
|
139
|
+
difficulty: "0x0",
|
|
140
|
+
totalDifficulty: "0x0",
|
|
141
|
+
extraData: "0x",
|
|
142
|
+
size: "0x0",
|
|
143
|
+
gasLimit: "0x0",
|
|
144
|
+
gasUsed: "0x0",
|
|
145
|
+
timestamp: "0x0",
|
|
146
|
+
transactions: [],
|
|
147
|
+
uncles: [],
|
|
148
|
+
baseFeePerGas: "0x3b9aca00",
|
|
149
|
+
} as T);
|
|
150
|
+
case "eth_getBalance":
|
|
151
|
+
return Effect.succeed("0xde0b6b3a7640000" as T); // 1 ETH
|
|
152
|
+
case "eth_getTransactionCount":
|
|
153
|
+
return Effect.succeed("0x5" as T);
|
|
154
|
+
case "eth_getCode":
|
|
155
|
+
return Effect.succeed("0x" as T);
|
|
156
|
+
case "eth_getStorageAt":
|
|
157
|
+
return Effect.succeed("0x0" as T);
|
|
158
|
+
case "eth_getTransactionReceipt":
|
|
159
|
+
if (receiptOverride === "error") {
|
|
160
|
+
return Effect.fail(
|
|
161
|
+
new TransportError({
|
|
162
|
+
code: -32000,
|
|
163
|
+
message: "Network connection lost",
|
|
164
|
+
}),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
if (receiptOverride) {
|
|
168
|
+
return Effect.succeed(receiptOverride as T);
|
|
169
|
+
}
|
|
170
|
+
return Effect.succeed({
|
|
171
|
+
transactionHash: mockTxHashHex,
|
|
172
|
+
blockNumber: "0x1",
|
|
173
|
+
blockHash: "0xabc",
|
|
174
|
+
transactionIndex: "0x0",
|
|
175
|
+
from: "0xabababababababababababababababababababab",
|
|
176
|
+
to: null,
|
|
177
|
+
contractAddress: mockContractAddress,
|
|
178
|
+
cumulativeGasUsed: "0x5208",
|
|
179
|
+
gasUsed: "0x5208",
|
|
180
|
+
logs: [],
|
|
181
|
+
logsBloom: "0x0",
|
|
182
|
+
status: "0x1",
|
|
183
|
+
effectiveGasPrice: "0x3b9aca00",
|
|
184
|
+
type: "0x2",
|
|
185
|
+
} as T);
|
|
186
|
+
case "eth_call":
|
|
187
|
+
return Effect.succeed("0x" as T);
|
|
188
|
+
case "eth_estimateGas":
|
|
189
|
+
return Effect.succeed("0x186a0" as T); // 100000
|
|
190
|
+
case "eth_chainId":
|
|
191
|
+
return Effect.succeed("0x1" as T);
|
|
192
|
+
case "eth_gasPrice":
|
|
193
|
+
return Effect.succeed("0x4a817c800" as T); // 20 gwei
|
|
194
|
+
case "eth_maxPriorityFeePerGas":
|
|
195
|
+
return Effect.succeed("0x3b9aca00" as T); // 1 gwei
|
|
196
|
+
case "eth_feeHistory":
|
|
197
|
+
return Effect.succeed({
|
|
198
|
+
oldestBlock: "0x0",
|
|
199
|
+
baseFeePerGas: [],
|
|
200
|
+
gasUsedRatio: [],
|
|
201
|
+
} as T);
|
|
202
|
+
case "eth_sendRawTransaction":
|
|
203
|
+
return Effect.succeed("0x" as T);
|
|
204
|
+
default:
|
|
205
|
+
return Effect.succeed(null as T);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const mockProvider: ProviderShape = createMockProviderWithReceipt();
|
|
211
|
+
|
|
179
212
|
const mockTransport: TransportShape = {
|
|
180
213
|
request: <T>(_method: string, _params?: unknown[]): Effect.Effect<T, never> =>
|
|
181
214
|
Effect.succeed(mockTxHashHex as T),
|
|
@@ -338,26 +371,22 @@ describe("deployContract", () => {
|
|
|
338
371
|
});
|
|
339
372
|
|
|
340
373
|
it("fails address effect when receipt has no contractAddress", async () => {
|
|
341
|
-
const providerWithNullAddress
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
effectiveGasPrice: "0x3b9aca00",
|
|
358
|
-
type: "0x2",
|
|
359
|
-
}),
|
|
360
|
-
};
|
|
374
|
+
const providerWithNullAddress = createMockProviderWithReceipt({
|
|
375
|
+
transactionHash: mockTxHashHex,
|
|
376
|
+
blockNumber: "0x1",
|
|
377
|
+
blockHash: "0xabc",
|
|
378
|
+
transactionIndex: "0x0",
|
|
379
|
+
from: "0xabababababababababababababababababababab",
|
|
380
|
+
to: null,
|
|
381
|
+
contractAddress: null,
|
|
382
|
+
cumulativeGasUsed: "0x5208",
|
|
383
|
+
gasUsed: "0x5208",
|
|
384
|
+
logs: [],
|
|
385
|
+
logsBloom: "0x0",
|
|
386
|
+
status: "0x1",
|
|
387
|
+
effectiveGasPrice: "0x3b9aca00",
|
|
388
|
+
type: "0x2",
|
|
389
|
+
});
|
|
361
390
|
const NullAddressProviderLayer = Layer.succeed(
|
|
362
391
|
ProviderService,
|
|
363
392
|
providerWithNullAddress,
|
|
@@ -397,16 +426,7 @@ describe("deployContract", () => {
|
|
|
397
426
|
});
|
|
398
427
|
|
|
399
428
|
it("fails address effect when waitForTransactionReceipt fails", async () => {
|
|
400
|
-
const providerWithReceiptError
|
|
401
|
-
...mockProvider,
|
|
402
|
-
waitForTransactionReceipt: () =>
|
|
403
|
-
Effect.fail(
|
|
404
|
-
new TransportError({
|
|
405
|
-
code: -32000,
|
|
406
|
-
message: "Network connection lost",
|
|
407
|
-
}),
|
|
408
|
-
),
|
|
409
|
-
};
|
|
429
|
+
const providerWithReceiptError = createMockProviderWithReceipt("error");
|
|
410
430
|
const ErrorProviderLayer = Layer.succeed(
|
|
411
431
|
ProviderService,
|
|
412
432
|
providerWithReceiptError,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ProviderService,
|
|
20
20
|
type WaitForTransactionReceiptError,
|
|
21
21
|
} from "../../Provider/index.js";
|
|
22
|
+
import { waitForTransactionReceipt } from "../../Provider/functions/index.js";
|
|
22
23
|
import { type SignerError, SignerService } from "../SignerService.js";
|
|
23
24
|
|
|
24
25
|
type AddressType = BrandedAddress.AddressType;
|
|
@@ -151,8 +152,8 @@ export const deployContract = <TAbi extends Abi>(
|
|
|
151
152
|
WaitForTransactionReceiptError,
|
|
152
153
|
ProviderService
|
|
153
154
|
> = Effect.gen(function* () {
|
|
154
|
-
const
|
|
155
|
-
const receipt = yield*
|
|
155
|
+
const hashHex = `0x${Buffer.from(hash).toString("hex")}` as `0x${string}`;
|
|
156
|
+
const receipt = yield* waitForTransactionReceipt(hashHex);
|
|
156
157
|
if (!receipt.contractAddress) {
|
|
157
158
|
return yield* Effect.fail(
|
|
158
159
|
new ProviderResponseError({ hash }, "No contract address in receipt"),
|
|
@@ -44,41 +44,17 @@ const mockAccount: AccountShape = {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const mockProvider: ProviderShape = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
estimateGas: () => Effect.succeed(21000n),
|
|
59
|
-
createAccessList: () => Effect.succeed({ accessList: [], gasUsed: "0x0" }),
|
|
60
|
-
getLogs: () => Effect.succeed([]),
|
|
61
|
-
createEventFilter: () => Effect.succeed("0x1" as any),
|
|
62
|
-
createBlockFilter: () => Effect.succeed("0x1" as any),
|
|
63
|
-
createPendingTransactionFilter: () => Effect.succeed("0x1" as any),
|
|
64
|
-
getFilterChanges: () => Effect.succeed([]),
|
|
65
|
-
getFilterLogs: () => Effect.succeed([]),
|
|
66
|
-
uninstallFilter: () => Effect.succeed(true),
|
|
67
|
-
getChainId: () => Effect.succeed(1),
|
|
68
|
-
getGasPrice: () => Effect.succeed(20000000000n),
|
|
69
|
-
getMaxPriorityFeePerGas: () => Effect.succeed(1000000000n),
|
|
70
|
-
getFeeHistory: () =>
|
|
71
|
-
Effect.succeed({ oldestBlock: "0x0", baseFeePerGas: [], gasUsedRatio: [] }),
|
|
72
|
-
sendRawTransaction: () => Effect.succeed("0x" as `0x${string}`),
|
|
73
|
-
getUncle: () => Effect.succeed({} as any),
|
|
74
|
-
getProof: () => Effect.succeed({} as any),
|
|
75
|
-
getBlobBaseFee: () => Effect.succeed(0n),
|
|
76
|
-
getTransactionConfirmations: () => Effect.succeed(0n),
|
|
77
|
-
watchBlocks: () => {
|
|
78
|
-
throw new Error("Not implemented in mock");
|
|
79
|
-
},
|
|
80
|
-
backfillBlocks: () => {
|
|
81
|
-
throw new Error("Not implemented in mock");
|
|
47
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
48
|
+
switch (method) {
|
|
49
|
+
case "eth_chainId":
|
|
50
|
+
return Effect.succeed("0x1" as T);
|
|
51
|
+
case "eth_getTransactionCount":
|
|
52
|
+
return Effect.succeed("0x5" as T);
|
|
53
|
+
default:
|
|
54
|
+
return Effect.fail(
|
|
55
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
82
58
|
},
|
|
83
59
|
};
|
|
84
60
|
|
|
@@ -114,10 +90,18 @@ describe("prepareAuthorization", () => {
|
|
|
114
90
|
let capturedBlockTag: string | undefined;
|
|
115
91
|
|
|
116
92
|
const providerWithCapture: ProviderShape = {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
93
|
+
request: <T>(method: string, params?: unknown[]) => {
|
|
94
|
+
switch (method) {
|
|
95
|
+
case "eth_chainId":
|
|
96
|
+
return Effect.succeed("0x1" as T);
|
|
97
|
+
case "eth_getTransactionCount":
|
|
98
|
+
capturedBlockTag = params?.[1] as string;
|
|
99
|
+
return Effect.succeed("0xa" as T); // 10 in hex
|
|
100
|
+
default:
|
|
101
|
+
return Effect.fail(
|
|
102
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
121
105
|
},
|
|
122
106
|
};
|
|
123
107
|
|
|
@@ -141,10 +125,18 @@ describe("prepareAuthorization", () => {
|
|
|
141
125
|
it("uses provided nonce without fetching", async () => {
|
|
142
126
|
let getNonceCalled = false;
|
|
143
127
|
const providerWithCapture: ProviderShape = {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
128
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
129
|
+
switch (method) {
|
|
130
|
+
case "eth_chainId":
|
|
131
|
+
return Effect.succeed("0x1" as T);
|
|
132
|
+
case "eth_getTransactionCount":
|
|
133
|
+
getNonceCalled = true;
|
|
134
|
+
return Effect.succeed("0xa" as T);
|
|
135
|
+
default:
|
|
136
|
+
return Effect.fail(
|
|
137
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
148
140
|
},
|
|
149
141
|
};
|
|
150
142
|
|
|
@@ -181,11 +173,18 @@ describe("prepareAuthorization", () => {
|
|
|
181
173
|
|
|
182
174
|
it("handles provider errors", async () => {
|
|
183
175
|
const providerWithError: ProviderShape = {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
177
|
+
switch (method) {
|
|
178
|
+
case "eth_chainId":
|
|
179
|
+
return Effect.fail(
|
|
180
|
+
new TransportError({ code: -32000, message: "Network error" }),
|
|
181
|
+
);
|
|
182
|
+
default:
|
|
183
|
+
return Effect.fail(
|
|
184
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
189
188
|
};
|
|
190
189
|
|
|
191
190
|
const customLayers = Layer.mergeAll(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type UnsignedAuthorization,
|
|
13
13
|
} from "../../Account/index.js";
|
|
14
14
|
import { ProviderService } from "../../Provider/index.js";
|
|
15
|
+
import { getChainId, getTransactionCount } from "../../Provider/functions/index.js";
|
|
15
16
|
import {
|
|
16
17
|
type PrepareAuthorizationParams,
|
|
17
18
|
SignerError,
|
|
@@ -59,15 +60,14 @@ export const prepareAuthorization = (
|
|
|
59
60
|
ProviderService | AccountService
|
|
60
61
|
> =>
|
|
61
62
|
Effect.gen(function* () {
|
|
62
|
-
const provider = yield* ProviderService;
|
|
63
63
|
const account = yield* AccountService;
|
|
64
64
|
|
|
65
|
-
const chainId = params.chainId ??
|
|
65
|
+
const chainId = params.chainId ?? (yield* getChainId());
|
|
66
66
|
|
|
67
67
|
const addressHex = Address.toHex(account.address as AddressType);
|
|
68
68
|
const nonce =
|
|
69
69
|
params.nonce ??
|
|
70
|
-
(yield*
|
|
70
|
+
(yield* getTransactionCount(addressHex, "pending"));
|
|
71
71
|
|
|
72
72
|
const contractAddressHex =
|
|
73
73
|
typeof params.contractAddress === "string"
|
|
@@ -63,41 +63,17 @@ const mockAccount: AccountShape = {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const mockProvider: ProviderShape = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
estimateGas: () => Effect.succeed(21000n),
|
|
78
|
-
createAccessList: () => Effect.succeed({ accessList: [], gasUsed: "0x0" }),
|
|
79
|
-
getLogs: () => Effect.succeed([]),
|
|
80
|
-
createEventFilter: () => Effect.succeed("0x1" as any),
|
|
81
|
-
createBlockFilter: () => Effect.succeed("0x1" as any),
|
|
82
|
-
createPendingTransactionFilter: () => Effect.succeed("0x1" as any),
|
|
83
|
-
getFilterChanges: () => Effect.succeed([]),
|
|
84
|
-
getFilterLogs: () => Effect.succeed([]),
|
|
85
|
-
uninstallFilter: () => Effect.succeed(true),
|
|
86
|
-
getChainId: () => Effect.succeed(1),
|
|
87
|
-
getGasPrice: () => Effect.succeed(20000000000n),
|
|
88
|
-
getMaxPriorityFeePerGas: () => Effect.succeed(1000000000n),
|
|
89
|
-
getFeeHistory: () =>
|
|
90
|
-
Effect.succeed({ oldestBlock: "0x0", baseFeePerGas: [], gasUsedRatio: [] }),
|
|
91
|
-
sendRawTransaction: () => Effect.succeed("0x" as `0x${string}`),
|
|
92
|
-
getUncle: () => Effect.succeed({} as any),
|
|
93
|
-
getProof: () => Effect.succeed({} as any),
|
|
94
|
-
getBlobBaseFee: () => Effect.succeed(0n),
|
|
95
|
-
getTransactionConfirmations: () => Effect.succeed(0n),
|
|
96
|
-
watchBlocks: () => {
|
|
97
|
-
throw new Error("Not implemented in mock");
|
|
98
|
-
},
|
|
99
|
-
backfillBlocks: () => {
|
|
100
|
-
throw new Error("Not implemented in mock");
|
|
66
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
67
|
+
switch (method) {
|
|
68
|
+
case "eth_chainId":
|
|
69
|
+
return Effect.succeed("0x1" as T);
|
|
70
|
+
case "eth_getTransactionCount":
|
|
71
|
+
return Effect.succeed("0x5" as T);
|
|
72
|
+
default:
|
|
73
|
+
return Effect.fail(
|
|
74
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
75
|
+
);
|
|
76
|
+
}
|
|
101
77
|
},
|
|
102
78
|
};
|
|
103
79
|
|
|
@@ -229,11 +205,20 @@ describe("signAuthorization", () => {
|
|
|
229
205
|
|
|
230
206
|
it("handles provider errors when fetching chain ID", async () => {
|
|
231
207
|
const providerWithError: ProviderShape = {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
208
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
209
|
+
switch (method) {
|
|
210
|
+
case "eth_chainId":
|
|
211
|
+
return Effect.fail(
|
|
212
|
+
new TransportError({ code: -32000, message: "Network error" }),
|
|
213
|
+
);
|
|
214
|
+
case "eth_getTransactionCount":
|
|
215
|
+
return Effect.succeed("0x5" as T);
|
|
216
|
+
default:
|
|
217
|
+
return Effect.fail(
|
|
218
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
},
|
|
237
222
|
};
|
|
238
223
|
|
|
239
224
|
const customLayers = Layer.mergeAll(
|
|
@@ -254,11 +239,20 @@ describe("signAuthorization", () => {
|
|
|
254
239
|
|
|
255
240
|
it("handles provider errors when fetching nonce", async () => {
|
|
256
241
|
const providerWithError: ProviderShape = {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
242
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
243
|
+
switch (method) {
|
|
244
|
+
case "eth_chainId":
|
|
245
|
+
return Effect.succeed("0x1" as T);
|
|
246
|
+
case "eth_getTransactionCount":
|
|
247
|
+
return Effect.fail(
|
|
248
|
+
new TransportError({ code: -32000, message: "RPC timeout" }),
|
|
249
|
+
);
|
|
250
|
+
default:
|
|
251
|
+
return Effect.fail(
|
|
252
|
+
new TransportError({ code: -32601, message: `Unknown method: ${method}` }),
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
},
|
|
262
256
|
};
|
|
263
257
|
|
|
264
258
|
const customLayers = Layer.mergeAll(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type SignedAuthorization,
|
|
13
13
|
type UnsignedAuthorization,
|
|
14
14
|
} from "../../Account/index.js";
|
|
15
|
+
import { getChainId, getTransactionCount } from "../../Provider/functions/index.js";
|
|
15
16
|
import { ProviderService } from "../../Provider/index.js";
|
|
16
17
|
import { SignerError } from "../SignerService.js";
|
|
17
18
|
|
|
@@ -77,14 +78,13 @@ export const signAuthorization = (
|
|
|
77
78
|
ProviderService | AccountService
|
|
78
79
|
> =>
|
|
79
80
|
Effect.gen(function* () {
|
|
80
|
-
const provider = yield* ProviderService;
|
|
81
81
|
const account = yield* AccountService;
|
|
82
82
|
|
|
83
|
-
const chainId = params.chainId ?? BigInt(yield*
|
|
83
|
+
const chainId = params.chainId ?? BigInt(yield* getChainId());
|
|
84
84
|
|
|
85
85
|
const nonce =
|
|
86
86
|
params.nonce ??
|
|
87
|
-
(yield*
|
|
87
|
+
(yield* getTransactionCount(
|
|
88
88
|
Address.toHex(account.address as AddressType),
|
|
89
89
|
"pending",
|
|
90
90
|
));
|
|
@@ -83,63 +83,47 @@ const mockAccount: AccountShape = {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
const mockProvider: ProviderShape = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
uninstallFilter: () => Effect.succeed(true),
|
|
128
|
-
getChainId: () => Effect.succeed(1),
|
|
129
|
-
getGasPrice: () => Effect.succeed(20000000000n),
|
|
130
|
-
getMaxPriorityFeePerGas: () => Effect.succeed(1000000000n),
|
|
131
|
-
getFeeHistory: () =>
|
|
132
|
-
Effect.succeed({ oldestBlock: "0x0", baseFeePerGas: [], gasUsedRatio: [] }),
|
|
133
|
-
sendRawTransaction: () => Effect.succeed("0x" as `0x${string}`),
|
|
134
|
-
getUncle: () => Effect.succeed({} as any),
|
|
135
|
-
getProof: () => Effect.succeed({} as any),
|
|
136
|
-
getBlobBaseFee: () => Effect.succeed(0n),
|
|
137
|
-
getTransactionConfirmations: () => Effect.succeed(0n),
|
|
138
|
-
watchBlocks: () => {
|
|
139
|
-
throw new Error("Not implemented in mock");
|
|
140
|
-
},
|
|
141
|
-
backfillBlocks: () => {
|
|
142
|
-
throw new Error("Not implemented in mock");
|
|
86
|
+
request: <T>(method: string, _params?: unknown[]) => {
|
|
87
|
+
switch (method) {
|
|
88
|
+
case "eth_blockNumber":
|
|
89
|
+
return Effect.succeed("0x3039" as T); // 12345
|
|
90
|
+
case "eth_getBlockByNumber":
|
|
91
|
+
case "eth_getBlockByHash":
|
|
92
|
+
return Effect.succeed({
|
|
93
|
+
number: "0x1",
|
|
94
|
+
hash: "0xabc",
|
|
95
|
+
parentHash: "0x0",
|
|
96
|
+
nonce: "0x0",
|
|
97
|
+
sha3Uncles: "0x0",
|
|
98
|
+
logsBloom: "0x0",
|
|
99
|
+
transactionsRoot: "0x0",
|
|
100
|
+
stateRoot: "0x0",
|
|
101
|
+
receiptsRoot: "0x0",
|
|
102
|
+
miner: "0x0",
|
|
103
|
+
difficulty: "0x0",
|
|
104
|
+
totalDifficulty: "0x0",
|
|
105
|
+
extraData: "0x",
|
|
106
|
+
size: "0x0",
|
|
107
|
+
gasLimit: "0x0",
|
|
108
|
+
gasUsed: "0x0",
|
|
109
|
+
timestamp: "0x0",
|
|
110
|
+
transactions: [],
|
|
111
|
+
uncles: [],
|
|
112
|
+
baseFeePerGas: "0x3b9aca00",
|
|
113
|
+
} as T);
|
|
114
|
+
case "eth_getTransactionCount":
|
|
115
|
+
return Effect.succeed("0x5" as T);
|
|
116
|
+
case "eth_estimateGas":
|
|
117
|
+
return Effect.succeed("0x5208" as T); // 21000
|
|
118
|
+
case "eth_chainId":
|
|
119
|
+
return Effect.succeed("0x1" as T);
|
|
120
|
+
case "eth_gasPrice":
|
|
121
|
+
return Effect.succeed("0x4a817c800" as T); // 20 gwei
|
|
122
|
+
case "eth_maxPriorityFeePerGas":
|
|
123
|
+
return Effect.succeed("0x3b9aca00" as T); // 1 gwei
|
|
124
|
+
default:
|
|
125
|
+
return Effect.succeed(null as T);
|
|
126
|
+
}
|
|
143
127
|
},
|
|
144
128
|
};
|
|
145
129
|
|