voltaire-effect 0.2.23
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/README.md +42 -0
- package/dist/AccountService-BetXokad.d.ts +1717 -0
- package/dist/RpcResolver-BpvqybjD.d.ts +6439 -0
- package/dist/Secp256k1Service-OxQ6hJFp.d.ts +250 -0
- package/dist/X25519Test-DGsk1V9o.d.ts +5352 -0
- package/dist/crypto/index.d.ts +289 -0
- package/dist/crypto/index.js +1254 -0
- package/dist/index-IgkEHjBe.d.ts +20058 -0
- package/dist/index.d.ts +11961 -0
- package/dist/index.js +20715 -0
- package/dist/native/index.d.ts +193 -0
- package/dist/native/index.js +20931 -0
- package/dist/primitives/index.d.ts +273 -0
- package/dist/primitives/index.js +8688 -0
- package/dist/services/index.d.ts +42 -0
- package/dist/services/index.js +6176 -0
- package/package.json +108 -0
- package/src/auth/index.ts +20 -0
- package/src/auth/siwe.test.ts +156 -0
- package/src/auth/siwe.ts +319 -0
- package/src/block/BlockError.test.ts +120 -0
- package/src/block/BlockError.ts +52 -0
- package/src/block/block.test.ts +579 -0
- package/src/block/fetchBlock.ts +100 -0
- package/src/block/fetchBlockByHash.ts +97 -0
- package/src/block/fetchBlockReceipts.ts +129 -0
- package/src/block/index.ts +52 -0
- package/src/block/toLightBlock.ts +43 -0
- package/src/blockchain/Blockchain.test.ts +468 -0
- package/src/blockchain/Blockchain.ts +441 -0
- package/src/blockchain/BlockchainService.ts +203 -0
- package/src/blockchain/index.ts +46 -0
- package/src/contract/EventStream.test.ts +802 -0
- package/src/contract/EventStream.ts +138 -0
- package/src/contract/EventStreamError.test.ts +92 -0
- package/src/contract/EventStreamError.ts +33 -0
- package/src/contract/EventStreamService.ts +124 -0
- package/src/contract/index.ts +39 -0
- package/src/crypto/AesGcm/AesGcm.test.ts +185 -0
- package/src/crypto/AesGcm/AesGcmService.ts +86 -0
- package/src/crypto/AesGcm/errors.ts +38 -0
- package/src/crypto/AesGcm/index.ts +101 -0
- package/src/crypto/AesGcm/operations.ts +191 -0
- package/src/crypto/Bip39/Bip39.test.ts +183 -0
- package/src/crypto/Bip39/Bip39Service.ts +160 -0
- package/src/crypto/Bip39/index.ts +52 -0
- package/src/crypto/Bip39/operations.ts +168 -0
- package/src/crypto/Bip39/types.ts +16 -0
- package/src/crypto/Bip39/utils.ts +42 -0
- package/src/crypto/Blake2/Blake2.test.ts +317 -0
- package/src/crypto/Blake2/Blake2Service.ts +121 -0
- package/src/crypto/Blake2/hash.ts +59 -0
- package/src/crypto/Blake2/index.ts +30 -0
- package/src/crypto/Bls12381/Bls12381.test.ts +464 -0
- package/src/crypto/Bls12381/Bls12381Live.ts +43 -0
- package/src/crypto/Bls12381/Bls12381Service.ts +131 -0
- package/src/crypto/Bls12381/aggregate.ts +66 -0
- package/src/crypto/Bls12381/index.ts +43 -0
- package/src/crypto/Bls12381/sign.ts +65 -0
- package/src/crypto/Bls12381/verify.ts +71 -0
- package/src/crypto/Bn254/Bn254.test.ts +131 -0
- package/src/crypto/Bn254/Bn254Service.ts +369 -0
- package/src/crypto/Bn254/index.ts +56 -0
- package/src/crypto/Bn254/operations.ts +259 -0
- package/src/crypto/Bn254/types.ts +15 -0
- package/src/crypto/ChaCha20Poly1305/ChaCha20Poly1305.test.ts +199 -0
- package/src/crypto/ChaCha20Poly1305/ChaCha20Poly1305Service.ts +177 -0
- package/src/crypto/ChaCha20Poly1305/errors.ts +38 -0
- package/src/crypto/ChaCha20Poly1305/index.ts +46 -0
- package/src/crypto/ChaCha20Poly1305/operations.ts +161 -0
- package/src/crypto/CryptoLive.test.ts +42 -0
- package/src/crypto/CryptoLive.ts +52 -0
- package/src/crypto/CryptoTest.ts +49 -0
- package/src/crypto/EIP712/EIP712.test.ts +197 -0
- package/src/crypto/EIP712/EIP712Service.ts +184 -0
- package/src/crypto/EIP712/index.ts +50 -0
- package/src/crypto/EIP712/operations.ts +220 -0
- package/src/crypto/ERC6492/ERC6492.test.ts +115 -0
- package/src/crypto/ERC6492/index.ts +9 -0
- package/src/crypto/ERC6492/unwrapSignature.ts +72 -0
- package/src/crypto/ERC6492/verifySignature.ts +139 -0
- package/src/crypto/ERC6492/wrapSignature.ts +55 -0
- package/src/crypto/Ed25519/Ed25519.test.ts +472 -0
- package/src/crypto/Ed25519/Ed25519Live.ts +44 -0
- package/src/crypto/Ed25519/Ed25519Service.ts +134 -0
- package/src/crypto/Ed25519/Ed25519Test.ts +59 -0
- package/src/crypto/Ed25519/getPublicKey.ts +60 -0
- package/src/crypto/Ed25519/index.ts +42 -0
- package/src/crypto/Ed25519/sign.ts +66 -0
- package/src/crypto/Ed25519/verify.ts +75 -0
- package/src/crypto/HDWallet/HDWallet.cleanup.test.ts +128 -0
- package/src/crypto/HDWallet/HDWallet.test.ts +383 -0
- package/src/crypto/HDWallet/HDWalletLive.ts +201 -0
- package/src/crypto/HDWallet/HDWalletService.ts +186 -0
- package/src/crypto/HDWallet/derive.ts +348 -0
- package/src/crypto/HDWallet/errors.ts +121 -0
- package/src/crypto/HDWallet/index.ts +65 -0
- package/src/crypto/HMAC/HMAC.test.ts +380 -0
- package/src/crypto/HMAC/HMACService.ts +174 -0
- package/src/crypto/HMAC/index.ts +39 -0
- package/src/crypto/HMAC/operations.ts +112 -0
- package/src/crypto/Hash/index.ts +51 -0
- package/src/crypto/KZG/KZG.test.ts +94 -0
- package/src/crypto/KZG/KZGService.ts +241 -0
- package/src/crypto/KZG/commit.ts +76 -0
- package/src/crypto/KZG/index.ts +42 -0
- package/src/crypto/KZG/verify.ts +52 -0
- package/src/crypto/Keccak256/Keccak256.test.ts +265 -0
- package/src/crypto/Keccak256/KeccakService.ts +177 -0
- package/src/crypto/Keccak256/hash.ts +76 -0
- package/src/crypto/Keccak256/index.ts +49 -0
- package/src/crypto/Keystore/Keystore.cleanup.test.ts +93 -0
- package/src/crypto/Keystore/Keystore.test.ts +511 -0
- package/src/crypto/Keystore/KeystoreLive.ts +35 -0
- package/src/crypto/Keystore/KeystoreService.ts +115 -0
- package/src/crypto/Keystore/KeystoreTest.ts +65 -0
- package/src/crypto/Keystore/decrypt.ts +105 -0
- package/src/crypto/Keystore/encrypt.ts +71 -0
- package/src/crypto/Keystore/index.ts +41 -0
- package/src/crypto/ModExp/ModExp.test.ts +177 -0
- package/src/crypto/ModExp/ModExpService.ts +139 -0
- package/src/crypto/ModExp/index.ts +39 -0
- package/src/crypto/ModExp/operations.ts +122 -0
- package/src/crypto/P256/P256.test.ts +414 -0
- package/src/crypto/P256/P256Live.ts +41 -0
- package/src/crypto/P256/P256Service.ts +115 -0
- package/src/crypto/P256/index.ts +37 -0
- package/src/crypto/P256/sign.ts +66 -0
- package/src/crypto/P256/verify.ts +75 -0
- package/src/crypto/Ripemd160/Ripemd160.test.ts +61 -0
- package/src/crypto/Ripemd160/Ripemd160Service.ts +119 -0
- package/src/crypto/Ripemd160/hash.ts +58 -0
- package/src/crypto/Ripemd160/index.ts +35 -0
- package/src/crypto/SHA256/SHA256.test.ts +284 -0
- package/src/crypto/SHA256/SHA256Service.ts +179 -0
- package/src/crypto/SHA256/hash.ts +93 -0
- package/src/crypto/SHA256/index.ts +48 -0
- package/src/crypto/Secp256k1/Secp256k1.test.ts +469 -0
- package/src/crypto/Secp256k1/Secp256k1Live.ts +83 -0
- package/src/crypto/Secp256k1/Secp256k1Service.ts +194 -0
- package/src/crypto/Secp256k1/Secp256k1Test.ts +101 -0
- package/src/crypto/Secp256k1/errors.ts +224 -0
- package/src/crypto/Secp256k1/index.ts +65 -0
- package/src/crypto/Secp256k1/recover.ts +106 -0
- package/src/crypto/Secp256k1/sign.ts +96 -0
- package/src/crypto/Secp256k1/verify.ts +111 -0
- package/src/crypto/Signature/Signature.test.ts +323 -0
- package/src/crypto/Signature/constantTimeEqual.ts +54 -0
- package/src/crypto/Signature/errors.ts +93 -0
- package/src/crypto/Signature/hashMessage.ts +83 -0
- package/src/crypto/Signature/index.ts +69 -0
- package/src/crypto/Signature/recoverAddress.ts +163 -0
- package/src/crypto/Signature/recoverMessageAddress.ts +70 -0
- package/src/crypto/Signature/verifyHash.ts +72 -0
- package/src/crypto/Signature/verifyMessage.ts +71 -0
- package/src/crypto/Signature/verifyTypedData.ts +88 -0
- package/src/crypto/Signers/Signers.test.ts +149 -0
- package/src/crypto/Signers/SignersLive.ts +40 -0
- package/src/crypto/Signers/SignersService.ts +73 -0
- package/src/crypto/Signers/SignersTest.ts +49 -0
- package/src/crypto/Signers/index.ts +44 -0
- package/src/crypto/Signers/operations.ts +123 -0
- package/src/crypto/Verify/errors.ts +97 -0
- package/src/crypto/Verify/hashMessage.ts +68 -0
- package/src/crypto/Verify/recoverAddress.ts +163 -0
- package/src/crypto/X25519/X25519.test.ts +168 -0
- package/src/crypto/X25519/X25519Live.ts +37 -0
- package/src/crypto/X25519/X25519Service.ts +81 -0
- package/src/crypto/X25519/X25519Test.ts +38 -0
- package/src/crypto/X25519/computeSecret.ts +61 -0
- package/src/crypto/X25519/generateKeyPair.ts +37 -0
- package/src/crypto/X25519/getPublicKey.ts +40 -0
- package/src/crypto/X25519/index.ts +41 -0
- package/src/crypto/index.ts +239 -0
- package/src/crypto/utils/constantTimeEqual.test.ts +40 -0
- package/src/crypto/utils/constantTimeEqual.ts +36 -0
- package/src/crypto/utils/index.ts +7 -0
- package/src/index.ts +224 -0
- package/src/jsonrpc/Anvil.ts +87 -0
- package/src/jsonrpc/BatchRequest.ts +23 -0
- package/src/jsonrpc/BatchResponse.ts +55 -0
- package/src/jsonrpc/Error.ts +107 -0
- package/src/jsonrpc/Eth.ts +224 -0
- package/src/jsonrpc/Hardhat.ts +69 -0
- package/src/jsonrpc/IdCounter.ts +7 -0
- package/src/jsonrpc/JsonRpc.test.ts +751 -0
- package/src/jsonrpc/Net.ts +24 -0
- package/src/jsonrpc/Request.ts +44 -0
- package/src/jsonrpc/Response.ts +98 -0
- package/src/jsonrpc/Txpool.ts +24 -0
- package/src/jsonrpc/Wallet.ts +52 -0
- package/src/jsonrpc/Web3.ts +22 -0
- package/src/jsonrpc/errors.test.ts +355 -0
- package/src/jsonrpc/errors.ts +680 -0
- package/src/jsonrpc/index.ts +112 -0
- package/src/jsonrpc/schemas/anvil/dropTransaction.ts +53 -0
- package/src/jsonrpc/schemas/anvil/impersonateAccount.ts +53 -0
- package/src/jsonrpc/schemas/anvil/index.ts +73 -0
- package/src/jsonrpc/schemas/anvil/mine.ts +52 -0
- package/src/jsonrpc/schemas/anvil/reset.ts +57 -0
- package/src/jsonrpc/schemas/anvil/revert.ts +49 -0
- package/src/jsonrpc/schemas/anvil/setAutomine.ts +45 -0
- package/src/jsonrpc/schemas/anvil/setBalance.ts +50 -0
- package/src/jsonrpc/schemas/anvil/setBlockTimestampInterval.ts +49 -0
- package/src/jsonrpc/schemas/anvil/setCode.ts +50 -0
- package/src/jsonrpc/schemas/anvil/setNextBlockTimestamp.ts +53 -0
- package/src/jsonrpc/schemas/anvil/setNonce.ts +50 -0
- package/src/jsonrpc/schemas/anvil/setStorageAt.ts +56 -0
- package/src/jsonrpc/schemas/anvil/snapshot.ts +49 -0
- package/src/jsonrpc/schemas/anvil/stopImpersonatingAccount.ts +53 -0
- package/src/jsonrpc/schemas/common.ts +450 -0
- package/src/jsonrpc/schemas/eth/accounts.ts +49 -0
- package/src/jsonrpc/schemas/eth/blobBaseFee.ts +49 -0
- package/src/jsonrpc/schemas/eth/blockNumber.ts +49 -0
- package/src/jsonrpc/schemas/eth/call.ts +69 -0
- package/src/jsonrpc/schemas/eth/chainId.ts +49 -0
- package/src/jsonrpc/schemas/eth/coinbase.ts +49 -0
- package/src/jsonrpc/schemas/eth/createAccessList.ts +57 -0
- package/src/jsonrpc/schemas/eth/estimateGas.ts +59 -0
- package/src/jsonrpc/schemas/eth/feeHistory.ts +54 -0
- package/src/jsonrpc/schemas/eth/gasPrice.ts +49 -0
- package/src/jsonrpc/schemas/eth/getBalance.ts +51 -0
- package/src/jsonrpc/schemas/eth/getBlockByHash.ts +54 -0
- package/src/jsonrpc/schemas/eth/getBlockByNumber.ts +54 -0
- package/src/jsonrpc/schemas/eth/getBlockReceipts.ts +54 -0
- package/src/jsonrpc/schemas/eth/getBlockTransactionCountByHash.ts +54 -0
- package/src/jsonrpc/schemas/eth/getBlockTransactionCountByNumber.ts +55 -0
- package/src/jsonrpc/schemas/eth/getCode.ts +51 -0
- package/src/jsonrpc/schemas/eth/getFilterChanges.ts +58 -0
- package/src/jsonrpc/schemas/eth/getFilterLogs.ts +54 -0
- package/src/jsonrpc/schemas/eth/getLogs.ts +50 -0
- package/src/jsonrpc/schemas/eth/getProof.ts +56 -0
- package/src/jsonrpc/schemas/eth/getStorageAt.ts +57 -0
- package/src/jsonrpc/schemas/eth/getTransactionByBlockHashAndIndex.ts +59 -0
- package/src/jsonrpc/schemas/eth/getTransactionByBlockNumberAndIndex.ts +59 -0
- package/src/jsonrpc/schemas/eth/getTransactionByHash.ts +54 -0
- package/src/jsonrpc/schemas/eth/getTransactionCount.ts +58 -0
- package/src/jsonrpc/schemas/eth/getTransactionReceipt.ts +54 -0
- package/src/jsonrpc/schemas/eth/getUncleByBlockHashAndIndex.ts +58 -0
- package/src/jsonrpc/schemas/eth/getUncleByBlockNumberAndIndex.ts +58 -0
- package/src/jsonrpc/schemas/eth/getUncleCountByBlockHash.ts +54 -0
- package/src/jsonrpc/schemas/eth/getUncleCountByBlockNumber.ts +54 -0
- package/src/jsonrpc/schemas/eth/getWork.ts +53 -0
- package/src/jsonrpc/schemas/eth/hashrate.ts +49 -0
- package/src/jsonrpc/schemas/eth/index.ts +178 -0
- package/src/jsonrpc/schemas/eth/maxPriorityFeePerGas.ts +53 -0
- package/src/jsonrpc/schemas/eth/mining.ts +45 -0
- package/src/jsonrpc/schemas/eth/newBlockFilter.ts +53 -0
- package/src/jsonrpc/schemas/eth/newFilter.ts +50 -0
- package/src/jsonrpc/schemas/eth/newPendingTransactionFilter.ts +53 -0
- package/src/jsonrpc/schemas/eth/protocolVersion.ts +49 -0
- package/src/jsonrpc/schemas/eth/sendRawTransaction.ts +54 -0
- package/src/jsonrpc/schemas/eth/sendTransaction.ts +54 -0
- package/src/jsonrpc/schemas/eth/sign.ts +50 -0
- package/src/jsonrpc/schemas/eth/signTransaction.ts +54 -0
- package/src/jsonrpc/schemas/eth/submitHashrate.ts +57 -0
- package/src/jsonrpc/schemas/eth/submitWork.ts +54 -0
- package/src/jsonrpc/schemas/eth/subscribe.ts +86 -0
- package/src/jsonrpc/schemas/eth/syncing.ts +49 -0
- package/src/jsonrpc/schemas/eth/uninstallFilter.ts +53 -0
- package/src/jsonrpc/schemas/eth/unsubscribe.ts +49 -0
- package/src/jsonrpc/schemas/hardhat/dropTransaction.ts +53 -0
- package/src/jsonrpc/schemas/hardhat/impersonateAccount.ts +53 -0
- package/src/jsonrpc/schemas/hardhat/index.ts +60 -0
- package/src/jsonrpc/schemas/hardhat/mine.ts +52 -0
- package/src/jsonrpc/schemas/hardhat/reset.ts +53 -0
- package/src/jsonrpc/schemas/hardhat/setBalance.ts +50 -0
- package/src/jsonrpc/schemas/hardhat/setCode.ts +50 -0
- package/src/jsonrpc/schemas/hardhat/setNonce.ts +50 -0
- package/src/jsonrpc/schemas/hardhat/setStorageAt.ts +56 -0
- package/src/jsonrpc/schemas/hardhat/stopImpersonatingAccount.ts +53 -0
- package/src/jsonrpc/schemas/index.ts +271 -0
- package/src/jsonrpc/schemas/net/index.ts +40 -0
- package/src/jsonrpc/schemas/net/listening.ts +45 -0
- package/src/jsonrpc/schemas/net/peerCount.ts +49 -0
- package/src/jsonrpc/schemas/net/version.ts +45 -0
- package/src/jsonrpc/schemas/schemas.test.ts +563 -0
- package/src/jsonrpc/schemas/txpool/content.ts +70 -0
- package/src/jsonrpc/schemas/txpool/index.ts +40 -0
- package/src/jsonrpc/schemas/txpool/inspect.ts +67 -0
- package/src/jsonrpc/schemas/txpool/status.ts +52 -0
- package/src/jsonrpc/schemas/wallet/addEthereumChain.ts +81 -0
- package/src/jsonrpc/schemas/wallet/getCallsStatus.ts +87 -0
- package/src/jsonrpc/schemas/wallet/getCapabilities.ts +87 -0
- package/src/jsonrpc/schemas/wallet/getPermissions.ts +51 -0
- package/src/jsonrpc/schemas/wallet/index.ts +64 -0
- package/src/jsonrpc/schemas/wallet/registerOnboarding.ts +50 -0
- package/src/jsonrpc/schemas/wallet/requestPermissions.ts +88 -0
- package/src/jsonrpc/schemas/wallet/revokePermissions.ts +62 -0
- package/src/jsonrpc/schemas/wallet/sendCalls.ts +79 -0
- package/src/jsonrpc/schemas/wallet/showCallsStatus.ts +50 -0
- package/src/jsonrpc/schemas/wallet/switchEthereumChain.ts +66 -0
- package/src/jsonrpc/schemas/wallet/watchAsset.ts +75 -0
- package/src/jsonrpc/schemas/web3/clientVersion.ts +49 -0
- package/src/jsonrpc/schemas/web3/index.ts +34 -0
- package/src/jsonrpc/schemas/web3/sha3.ts +50 -0
- package/src/native/CryptoLiveNative.ts +8 -0
- package/src/native/index.ts +14 -0
- package/src/primitives/Abi/Abi.test.ts +967 -0
- package/src/primitives/Abi/AbiSchema.test.ts +382 -0
- package/src/primitives/Abi/AbiSchema.ts +489 -0
- package/src/primitives/Abi/Item/index.ts +17 -0
- package/src/primitives/Abi/constructor/index.ts +5 -0
- package/src/primitives/Abi/decodeError.test.ts +117 -0
- package/src/primitives/Abi/decodeError.ts +103 -0
- package/src/primitives/Abi/decodeEventLog.test.ts +128 -0
- package/src/primitives/Abi/decodeEventLog.ts +164 -0
- package/src/primitives/Abi/decodeFunction.test.ts +91 -0
- package/src/primitives/Abi/decodeFunction.ts +87 -0
- package/src/primitives/Abi/decodeFunctionData.test.ts +158 -0
- package/src/primitives/Abi/decodeFunctionData.ts +116 -0
- package/src/primitives/Abi/decodeFunctionResult.test.ts +197 -0
- package/src/primitives/Abi/decodeFunctionResult.ts +160 -0
- package/src/primitives/Abi/encodeError.test.ts +106 -0
- package/src/primitives/Abi/encodeError.ts +96 -0
- package/src/primitives/Abi/encodeEventLog.test.ts +91 -0
- package/src/primitives/Abi/encodeEventLog.ts +86 -0
- package/src/primitives/Abi/encodeFunction.test.ts +65 -0
- package/src/primitives/Abi/encodeFunction.ts +65 -0
- package/src/primitives/Abi/encodeFunctionData.test.ts +149 -0
- package/src/primitives/Abi/encodeFunctionData.ts +124 -0
- package/src/primitives/Abi/encodeFunctionResult.test.ts +114 -0
- package/src/primitives/Abi/encodeFunctionResult.ts +96 -0
- package/src/primitives/Abi/error/index.ts +11 -0
- package/src/primitives/Abi/error/standards/index.ts +23 -0
- package/src/primitives/Abi/error/wrapped/index.ts +7 -0
- package/src/primitives/Abi/event/index.ts +15 -0
- package/src/primitives/Abi/findError.test.ts +97 -0
- package/src/primitives/Abi/findError.ts +55 -0
- package/src/primitives/Abi/findEvent.test.ts +100 -0
- package/src/primitives/Abi/findEvent.ts +51 -0
- package/src/primitives/Abi/findFunction.test.ts +86 -0
- package/src/primitives/Abi/findFunction.ts +58 -0
- package/src/primitives/Abi/format.test.ts +112 -0
- package/src/primitives/Abi/format.ts +39 -0
- package/src/primitives/Abi/formatWithArgs.test.ts +105 -0
- package/src/primitives/Abi/formatWithArgs.ts +43 -0
- package/src/primitives/Abi/function/errors.ts +69 -0
- package/src/primitives/Abi/function/index.ts +24 -0
- package/src/primitives/Abi/getErrorSignature.test.ts +78 -0
- package/src/primitives/Abi/getErrorSignature.ts +40 -0
- package/src/primitives/Abi/getEvent.test.ts +98 -0
- package/src/primitives/Abi/getEvent.ts +131 -0
- package/src/primitives/Abi/getEventSignature.test.ts +79 -0
- package/src/primitives/Abi/getEventSignature.ts +40 -0
- package/src/primitives/Abi/getFunction.test.ts +116 -0
- package/src/primitives/Abi/getFunction.ts +121 -0
- package/src/primitives/Abi/getFunctionSignature.test.ts +88 -0
- package/src/primitives/Abi/getFunctionSignature.ts +40 -0
- package/src/primitives/Abi/getSelector.test.ts +149 -0
- package/src/primitives/Abi/getSelector.ts +59 -0
- package/src/primitives/Abi/index.ts +53 -0
- package/src/primitives/Abi/interface/index.ts +11 -0
- package/src/primitives/Abi/parameter/index.ts +5 -0
- package/src/primitives/Abi/parse.test.ts +97 -0
- package/src/primitives/Abi/parse.ts +61 -0
- package/src/primitives/Abi/parseItem.test.ts +144 -0
- package/src/primitives/Abi/parseItem.ts +76 -0
- package/src/primitives/Abi/wasm/index.ts +67 -0
- package/src/primitives/AccessList/Rpc.ts +128 -0
- package/src/primitives/AccessList/index.ts +32 -0
- package/src/primitives/AccountState/Struct.ts +214 -0
- package/src/primitives/AccountState/index.ts +60 -0
- package/src/primitives/Address/Address.test.ts +366 -0
- package/src/primitives/Address/AddressSchema.ts +21 -0
- package/src/primitives/Address/Bytes.ts +55 -0
- package/src/primitives/Address/Checksummed.ts +93 -0
- package/src/primitives/Address/Hex.ts +56 -0
- package/src/primitives/Address/clone.ts +26 -0
- package/src/primitives/Address/compare.ts +29 -0
- package/src/primitives/Address/equals.ts +29 -0
- package/src/primitives/Address/greaterThan.ts +29 -0
- package/src/primitives/Address/index.ts +89 -0
- package/src/primitives/Address/isValid.ts +26 -0
- package/src/primitives/Address/isValidChecksum.ts +26 -0
- package/src/primitives/Address/isZero.ts +26 -0
- package/src/primitives/Address/lessThan.ts +29 -0
- package/src/primitives/Address/toAbiEncoded.ts +28 -0
- package/src/primitives/Address/toBytes.ts +26 -0
- package/src/primitives/Address/toLowercase.ts +28 -0
- package/src/primitives/Address/toShortHex.ts +27 -0
- package/src/primitives/Address/toU256.ts +28 -0
- package/src/primitives/Address/toUppercase.ts +28 -0
- package/src/primitives/Authorization/Rpc.ts +148 -0
- package/src/primitives/Authorization/index.ts +38 -0
- package/src/primitives/Balance/BigInt.ts +48 -0
- package/src/primitives/Balance/Number.ts +46 -0
- package/src/primitives/Balance/String.ts +47 -0
- package/src/primitives/Balance/index.ts +44 -0
- package/src/primitives/Base64/Base64Schema.ts +90 -0
- package/src/primitives/Base64/extensions/index.ts +10 -0
- package/src/primitives/Base64/index.ts +28 -0
- package/src/primitives/BaseFeePerGas/BigInt.ts +49 -0
- package/src/primitives/BaseFeePerGas/Gwei.ts +63 -0
- package/src/primitives/BaseFeePerGas/index.ts +47 -0
- package/src/primitives/BaseFeePerGas/toGwei.ts +28 -0
- package/src/primitives/BeaconBlockRoot/Hex.ts +76 -0
- package/src/primitives/BeaconBlockRoot/index.ts +47 -0
- package/src/primitives/BinaryTree/BinaryTreeSchema.ts +34 -0
- package/src/primitives/BinaryTree/get.ts +28 -0
- package/src/primitives/BinaryTree/index.ts +27 -0
- package/src/primitives/BinaryTree/init.ts +23 -0
- package/src/primitives/BinaryTree/rootHash.ts +22 -0
- package/src/primitives/Blob/BlobSchema.ts +87 -0
- package/src/primitives/Blob/index.ts +54 -0
- package/src/primitives/Blob/isValid.ts +22 -0
- package/src/primitives/Blob/toData.ts +23 -0
- package/src/primitives/Block/Block.test.ts +377 -0
- package/src/primitives/Block/BlockSchema.ts +201 -0
- package/src/primitives/Block/Rpc.ts +189 -0
- package/src/primitives/Block/index.ts +55 -0
- package/src/primitives/BlockBody/BlockBody.test.ts +228 -0
- package/src/primitives/BlockBody/BlockBodySchema.ts +85 -0
- package/src/primitives/BlockBody/Rpc.ts +100 -0
- package/src/primitives/BlockBody/index.ts +52 -0
- package/src/primitives/BlockFilter/BlockFilterSchema.ts +39 -0
- package/src/primitives/BlockFilter/index.ts +20 -0
- package/src/primitives/BlockHash/BlockHashTypeSchema.ts +21 -0
- package/src/primitives/BlockHash/Bytes.ts +53 -0
- package/src/primitives/BlockHash/Hex.ts +56 -0
- package/src/primitives/BlockHash/index.ts +55 -0
- package/src/primitives/BlockHeader/BlockHeaderSchema.ts +84 -0
- package/src/primitives/BlockHeader/Rpc.ts +95 -0
- package/src/primitives/BlockHeader/calculateHash.ts +24 -0
- package/src/primitives/BlockHeader/index.ts +61 -0
- package/src/primitives/BlockNumber/BigInt.ts +51 -0
- package/src/primitives/BlockNumber/BlockNumber.test.ts +122 -0
- package/src/primitives/BlockNumber/BlockNumberTypeSchema.ts +21 -0
- package/src/primitives/BlockNumber/Hex.ts +56 -0
- package/src/primitives/BlockNumber/Number.ts +66 -0
- package/src/primitives/BlockNumber/index.ts +60 -0
- package/src/primitives/BloomFilter/BloomFilterSchema.ts +96 -0
- package/src/primitives/BloomFilter/extensions/index.ts +12 -0
- package/src/primitives/BloomFilter/index.ts +64 -0
- package/src/primitives/Brand/Brand.test.ts +192 -0
- package/src/primitives/Brand/index.ts +292 -0
- package/src/primitives/BuilderBid/BuilderBidSchema.ts +116 -0
- package/src/primitives/BuilderBid/index.ts +38 -0
- package/src/primitives/Bundle/BundleSchema.ts +176 -0
- package/src/primitives/Bundle/index.ts +43 -0
- package/src/primitives/BundleHash/Hex.ts +68 -0
- package/src/primitives/BundleHash/index.ts +30 -0
- package/src/primitives/Bundler/BundlerSchema.ts +77 -0
- package/src/primitives/Bundler/index.ts +35 -0
- package/src/primitives/Bytecode/Bytecode.test.ts +49 -0
- package/src/primitives/Bytecode/BytecodeSchema.ts +48 -0
- package/src/primitives/Bytecode/Bytes.ts +60 -0
- package/src/primitives/Bytecode/Hex.ts +61 -0
- package/src/primitives/Bytecode/index.ts +45 -0
- package/src/primitives/Bytes/Bytes.test.ts +402 -0
- package/src/primitives/Bytes/Bytes1/index.ts +18 -0
- package/src/primitives/Bytes/Bytes16/index.ts +23 -0
- package/src/primitives/Bytes/Bytes2/index.ts +17 -0
- package/src/primitives/Bytes/Bytes3/index.ts +17 -0
- package/src/primitives/Bytes/Bytes32/index.ts +28 -0
- package/src/primitives/Bytes/Bytes4/index.ts +17 -0
- package/src/primitives/Bytes/Bytes5/index.ts +17 -0
- package/src/primitives/Bytes/Bytes6/index.ts +17 -0
- package/src/primitives/Bytes/Bytes64/index.ts +23 -0
- package/src/primitives/Bytes/Bytes7/index.ts +17 -0
- package/src/primitives/Bytes/Bytes8/index.ts +17 -0
- package/src/primitives/Bytes/Hex.ts +59 -0
- package/src/primitives/Bytes/concat.ts +23 -0
- package/src/primitives/Bytes/equals.ts +26 -0
- package/src/primitives/Bytes/extensions/index.ts +6 -0
- package/src/primitives/Bytes/index.ts +79 -0
- package/src/primitives/Bytes/isBytes.ts +23 -0
- package/src/primitives/Bytes/random.ts +22 -0
- package/src/primitives/Bytes/size.ts +22 -0
- package/src/primitives/Bytes/toString.ts +24 -0
- package/src/primitives/Bytes32/Bytes.ts +57 -0
- package/src/primitives/Bytes32/Bytes32.test.ts +62 -0
- package/src/primitives/Bytes32/Hex.ts +57 -0
- package/src/primitives/Bytes32/index.ts +80 -0
- package/src/primitives/CallData/CallData.test.ts +35 -0
- package/src/primitives/CallData/Hex.ts +74 -0
- package/src/primitives/CallData/empty.ts +24 -0
- package/src/primitives/CallData/index.ts +50 -0
- package/src/primitives/CallTrace/CallTraceSchema.ts +38 -0
- package/src/primitives/CallTrace/flatten.ts +21 -0
- package/src/primitives/CallTrace/getCalls.ts +20 -0
- package/src/primitives/CallTrace/hasError.ts +22 -0
- package/src/primitives/CallTrace/index.ts +13 -0
- package/src/primitives/Chain/ChainSchema.ts +231 -0
- package/src/primitives/Chain/index.ts +57 -0
- package/src/primitives/ChainHead/ChainHeadSchema.ts +130 -0
- package/src/primitives/ChainHead/index.ts +53 -0
- package/src/primitives/ChainId/BigInt.ts +79 -0
- package/src/primitives/ChainId/Hex.ts +83 -0
- package/src/primitives/ChainId/Number.ts +78 -0
- package/src/primitives/ChainId/index.ts +56 -0
- package/src/primitives/CompilerVersion/CompilerVersionSchema.ts +42 -0
- package/src/primitives/CompilerVersion/index.ts +10 -0
- package/src/primitives/ContractCode/Bytes.ts +63 -0
- package/src/primitives/ContractCode/ContractCode.test.ts +45 -0
- package/src/primitives/ContractCode/Hex.ts +65 -0
- package/src/primitives/ContractCode/index.ts +51 -0
- package/src/primitives/ContractResult/ContractResultSchema.ts +98 -0
- package/src/primitives/ContractResult/index.ts +13 -0
- package/src/primitives/ContractSignature/ContractSignature.test.ts +111 -0
- package/src/primitives/ContractSignature/Struct.ts +67 -0
- package/src/primitives/ContractSignature/index.ts +68 -0
- package/src/primitives/ContractSignature/verifySignature.ts +254 -0
- package/src/primitives/DecodedData/DecodedDataSchema.ts +72 -0
- package/src/primitives/DecodedData/index.ts +11 -0
- package/src/primitives/Denomination/EtherSchema.ts +87 -0
- package/src/primitives/Denomination/GweiSchema.ts +86 -0
- package/src/primitives/Denomination/WeiSchema.ts +87 -0
- package/src/primitives/Denomination/index.ts +49 -0
- package/src/primitives/Domain/Domain.test.ts +80 -0
- package/src/primitives/Domain/Struct.ts +165 -0
- package/src/primitives/Domain/index.ts +62 -0
- package/src/primitives/DomainSeparator/DomainSeparator.test.ts +67 -0
- package/src/primitives/DomainSeparator/Hex.ts +105 -0
- package/src/primitives/DomainSeparator/index.ts +50 -0
- package/src/primitives/EffectiveGasPrice/BigInt.ts +47 -0
- package/src/primitives/EffectiveGasPrice/Gwei.ts +54 -0
- package/src/primitives/EffectiveGasPrice/calculate.ts +39 -0
- package/src/primitives/EffectiveGasPrice/compare.ts +31 -0
- package/src/primitives/EffectiveGasPrice/equals.ts +31 -0
- package/src/primitives/EffectiveGasPrice/index.ts +59 -0
- package/src/primitives/EffectiveGasPrice/toGwei.ts +28 -0
- package/src/primitives/EncodedData/EncodedDataSchema.ts +66 -0
- package/src/primitives/EncodedData/index.ts +11 -0
- package/src/primitives/Ens/String.ts +45 -0
- package/src/primitives/Ens/index.ts +18 -0
- package/src/primitives/EntryPoint/EntryPointSchema.ts +113 -0
- package/src/primitives/EntryPoint/index.ts +47 -0
- package/src/primitives/Epoch/BigInt.ts +46 -0
- package/src/primitives/Epoch/index.ts +18 -0
- package/src/primitives/ErrorSignature/ErrorSignature.test.ts +43 -0
- package/src/primitives/ErrorSignature/String.ts +102 -0
- package/src/primitives/ErrorSignature/index.ts +55 -0
- package/src/primitives/EventLog/EventLog.test.ts +77 -0
- package/src/primitives/EventLog/Rpc.ts +159 -0
- package/src/primitives/EventLog/extensions/index.ts +17 -0
- package/src/primitives/EventLog/extensions/utils.ts +18 -0
- package/src/primitives/EventLog/index.ts +23 -0
- package/src/primitives/EventSignature/EventSignature.test.ts +54 -0
- package/src/primitives/EventSignature/String.ts +102 -0
- package/src/primitives/EventSignature/index.ts +53 -0
- package/src/primitives/FeeMarket/FeeMarketSchema.ts +160 -0
- package/src/primitives/FeeMarket/index.ts +36 -0
- package/src/primitives/FeeOracle/Struct.ts +152 -0
- package/src/primitives/FeeOracle/index.ts +29 -0
- package/src/primitives/FilterId/Hex.ts +97 -0
- package/src/primitives/FilterId/index.ts +57 -0
- package/src/primitives/ForkId/ForkIdSchema.ts +66 -0
- package/src/primitives/ForkId/index.ts +34 -0
- package/src/primitives/ForwardRequest/ForwardRequestSchema.ts +109 -0
- package/src/primitives/ForwardRequest/index.ts +26 -0
- package/src/primitives/FunctionSignature/FunctionSignature.test.ts +34 -0
- package/src/primitives/FunctionSignature/String.ts +77 -0
- package/src/primitives/FunctionSignature/index.ts +41 -0
- package/src/primitives/Gas/BigInt.ts +66 -0
- package/src/primitives/Gas/Hex.ts +66 -0
- package/src/primitives/Gas/Number.ts +74 -0
- package/src/primitives/Gas/index.ts +51 -0
- package/src/primitives/GasConstants/GasConstantsSchema.ts +139 -0
- package/src/primitives/GasConstants/index.ts +33 -0
- package/src/primitives/GasCosts/GasCostsSchema.ts +113 -0
- package/src/primitives/GasCosts/index.ts +24 -0
- package/src/primitives/GasEstimate/BigInt.ts +47 -0
- package/src/primitives/GasEstimate/Number.ts +47 -0
- package/src/primitives/GasEstimate/index.ts +50 -0
- package/src/primitives/GasEstimate/toGasLimit.ts +34 -0
- package/src/primitives/GasEstimate/withBuffer.ts +38 -0
- package/src/primitives/GasPrice/BigInt.ts +67 -0
- package/src/primitives/GasPrice/Gwei.ts +70 -0
- package/src/primitives/GasPrice/Hex.ts +67 -0
- package/src/primitives/GasPrice/Number.ts +71 -0
- package/src/primitives/GasPrice/index.ts +57 -0
- package/src/primitives/GasRefund/BigInt.ts +47 -0
- package/src/primitives/GasRefund/Number.ts +46 -0
- package/src/primitives/GasRefund/cappedRefund.ts +38 -0
- package/src/primitives/GasRefund/index.ts +49 -0
- package/src/primitives/GasUsed/BigInt.ts +47 -0
- package/src/primitives/GasUsed/Number.ts +46 -0
- package/src/primitives/GasUsed/calculateCost.ts +33 -0
- package/src/primitives/GasUsed/index.ts +48 -0
- package/src/primitives/Hardfork/HardforkSchema.ts +47 -0
- package/src/primitives/Hardfork/index.ts +39 -0
- package/src/primitives/Hash/Bytes.ts +71 -0
- package/src/primitives/Hash/Hash.test.ts +630 -0
- package/src/primitives/Hash/Hex.ts +72 -0
- package/src/primitives/Hash/assert.ts +46 -0
- package/src/primitives/Hash/clone.ts +32 -0
- package/src/primitives/Hash/concat.ts +32 -0
- package/src/primitives/Hash/equals.ts +35 -0
- package/src/primitives/Hash/extensions/index.ts +21 -0
- package/src/primitives/Hash/format.ts +38 -0
- package/src/primitives/Hash/index.ts +65 -0
- package/src/primitives/Hash/isValidHex.ts +30 -0
- package/src/primitives/Hash/isZero.ts +32 -0
- package/src/primitives/Hash/keccak256.ts +54 -0
- package/src/primitives/Hash/merkleRoot.ts +32 -0
- package/src/primitives/Hash/random.ts +36 -0
- package/src/primitives/Hash/slice.ts +38 -0
- package/src/primitives/Hash/toBytes.ts +43 -0
- package/src/primitives/Hash/toString.ts +32 -0
- package/src/primitives/Hex/Bytes.ts +67 -0
- package/src/primitives/Hex/Hex.test.ts +478 -0
- package/src/primitives/Hex/String.ts +64 -0
- package/src/primitives/Hex/clone.ts +31 -0
- package/src/primitives/Hex/equals.ts +32 -0
- package/src/primitives/Hex/index.ts +82 -0
- package/src/primitives/Hex/isHex.ts +32 -0
- package/src/primitives/Hex/isSized.ts +34 -0
- package/src/primitives/Hex/random.ts +31 -0
- package/src/primitives/Hex/zero.ts +30 -0
- package/src/primitives/InitCode/Bytes.ts +62 -0
- package/src/primitives/InitCode/Hex.ts +64 -0
- package/src/primitives/InitCode/InitCode.test.ts +46 -0
- package/src/primitives/InitCode/index.ts +50 -0
- package/src/primitives/Int128/BigInt.ts +52 -0
- package/src/primitives/Int128/Int128.test.ts +374 -0
- package/src/primitives/Int128/Int128Schema.ts +13 -0
- package/src/primitives/Int128/Number.ts +53 -0
- package/src/primitives/Int128/String.ts +52 -0
- package/src/primitives/Int128/abs.ts +10 -0
- package/src/primitives/Int128/add.ts +11 -0
- package/src/primitives/Int128/compare.ts +13 -0
- package/src/primitives/Int128/constants.ts +13 -0
- package/src/primitives/Int128/div.ts +11 -0
- package/src/primitives/Int128/equals.ts +11 -0
- package/src/primitives/Int128/index.ts +83 -0
- package/src/primitives/Int128/isNegative.ts +11 -0
- package/src/primitives/Int128/isZero.ts +11 -0
- package/src/primitives/Int128/mul.ts +11 -0
- package/src/primitives/Int128/negate.ts +11 -0
- package/src/primitives/Int128/sub.ts +11 -0
- package/src/primitives/Int16/BigInt.ts +54 -0
- package/src/primitives/Int16/Int16.test.ts +285 -0
- package/src/primitives/Int16/Int16Schema.ts +13 -0
- package/src/primitives/Int16/Number.ts +52 -0
- package/src/primitives/Int16/String.ts +52 -0
- package/src/primitives/Int16/abs.ts +10 -0
- package/src/primitives/Int16/add.ts +11 -0
- package/src/primitives/Int16/compare.ts +13 -0
- package/src/primitives/Int16/constants.ts +10 -0
- package/src/primitives/Int16/div.ts +11 -0
- package/src/primitives/Int16/equals.ts +11 -0
- package/src/primitives/Int16/index.ts +80 -0
- package/src/primitives/Int16/isNegative.ts +11 -0
- package/src/primitives/Int16/isZero.ts +10 -0
- package/src/primitives/Int16/mul.ts +11 -0
- package/src/primitives/Int16/negate.ts +11 -0
- package/src/primitives/Int16/sub.ts +11 -0
- package/src/primitives/Int256/BigInt.ts +53 -0
- package/src/primitives/Int256/Int256.test.ts +499 -0
- package/src/primitives/Int256/Int256Schema.ts +14 -0
- package/src/primitives/Int256/Number.ts +53 -0
- package/src/primitives/Int256/String.ts +53 -0
- package/src/primitives/Int256/abs.ts +10 -0
- package/src/primitives/Int256/add.ts +11 -0
- package/src/primitives/Int256/compare.ts +13 -0
- package/src/primitives/Int256/constants.ts +13 -0
- package/src/primitives/Int256/div.ts +11 -0
- package/src/primitives/Int256/equals.ts +11 -0
- package/src/primitives/Int256/index.ts +87 -0
- package/src/primitives/Int256/isNegative.ts +11 -0
- package/src/primitives/Int256/isZero.ts +11 -0
- package/src/primitives/Int256/mul.ts +11 -0
- package/src/primitives/Int256/negate.ts +11 -0
- package/src/primitives/Int256/sub.ts +11 -0
- package/src/primitives/Int32/BigInt.ts +52 -0
- package/src/primitives/Int32/Int32.test.ts +267 -0
- package/src/primitives/Int32/Int32Schema.ts +13 -0
- package/src/primitives/Int32/Number.ts +52 -0
- package/src/primitives/Int32/String.ts +52 -0
- package/src/primitives/Int32/abs.ts +10 -0
- package/src/primitives/Int32/add.ts +11 -0
- package/src/primitives/Int32/compare.ts +13 -0
- package/src/primitives/Int32/constants.ts +10 -0
- package/src/primitives/Int32/div.ts +11 -0
- package/src/primitives/Int32/equals.ts +11 -0
- package/src/primitives/Int32/index.ts +80 -0
- package/src/primitives/Int32/isNegative.ts +11 -0
- package/src/primitives/Int32/isZero.ts +10 -0
- package/src/primitives/Int32/mul.ts +11 -0
- package/src/primitives/Int32/negate.ts +11 -0
- package/src/primitives/Int32/sub.ts +11 -0
- package/src/primitives/Int64/BigInt.ts +52 -0
- package/src/primitives/Int64/Int64.test.ts +306 -0
- package/src/primitives/Int64/Int64Schema.ts +13 -0
- package/src/primitives/Int64/Number.ts +53 -0
- package/src/primitives/Int64/String.ts +52 -0
- package/src/primitives/Int64/abs.ts +10 -0
- package/src/primitives/Int64/add.ts +11 -0
- package/src/primitives/Int64/compare.ts +13 -0
- package/src/primitives/Int64/constants.ts +10 -0
- package/src/primitives/Int64/div.ts +11 -0
- package/src/primitives/Int64/equals.ts +11 -0
- package/src/primitives/Int64/index.ts +80 -0
- package/src/primitives/Int64/isNegative.ts +11 -0
- package/src/primitives/Int64/isZero.ts +10 -0
- package/src/primitives/Int64/mul.ts +11 -0
- package/src/primitives/Int64/negate.ts +11 -0
- package/src/primitives/Int64/sub.ts +11 -0
- package/src/primitives/Int8/BigInt.ts +60 -0
- package/src/primitives/Int8/Int8.test.ts +477 -0
- package/src/primitives/Int8/Int8Schema.ts +13 -0
- package/src/primitives/Int8/Number.ts +58 -0
- package/src/primitives/Int8/String.ts +58 -0
- package/src/primitives/Int8/abs.ts +10 -0
- package/src/primitives/Int8/add.ts +11 -0
- package/src/primitives/Int8/compare.ts +13 -0
- package/src/primitives/Int8/constants.ts +10 -0
- package/src/primitives/Int8/div.ts +11 -0
- package/src/primitives/Int8/equals.ts +11 -0
- package/src/primitives/Int8/index.ts +80 -0
- package/src/primitives/Int8/isNegative.ts +11 -0
- package/src/primitives/Int8/isZero.ts +10 -0
- package/src/primitives/Int8/mul.ts +11 -0
- package/src/primitives/Int8/negate.ts +10 -0
- package/src/primitives/Int8/sub.ts +11 -0
- package/src/primitives/License/String.ts +57 -0
- package/src/primitives/License/index.ts +22 -0
- package/src/primitives/LogFilter/LogFilter.test.ts +81 -0
- package/src/primitives/LogFilter/Rpc.ts +209 -0
- package/src/primitives/LogFilter/index.ts +36 -0
- package/src/primitives/LogIndex/Number.ts +93 -0
- package/src/primitives/LogIndex/index.ts +38 -0
- package/src/primitives/MaxFeePerGas/BigInt.ts +49 -0
- package/src/primitives/MaxFeePerGas/Gwei.ts +63 -0
- package/src/primitives/MaxFeePerGas/index.ts +47 -0
- package/src/primitives/MaxFeePerGas/toGwei.ts +28 -0
- package/src/primitives/MaxPriorityFeePerGas/BigInt.ts +48 -0
- package/src/primitives/MaxPriorityFeePerGas/Gwei.ts +63 -0
- package/src/primitives/MaxPriorityFeePerGas/index.ts +51 -0
- package/src/primitives/MaxPriorityFeePerGas/toGwei.ts +28 -0
- package/src/primitives/MemoryDump/MemoryDumpSchema.ts +70 -0
- package/src/primitives/MemoryDump/index.ts +22 -0
- package/src/primitives/MerkleTree/MerkleTreeSchema.ts +52 -0
- package/src/primitives/MerkleTree/index.ts +39 -0
- package/src/primitives/Metadata/MetadataSchema.ts +57 -0
- package/src/primitives/Metadata/index.ts +24 -0
- package/src/primitives/MultiTokenId/MultiTokenIdSchema.ts +48 -0
- package/src/primitives/MultiTokenId/index.ts +23 -0
- package/src/primitives/NetworkId/BigInt.ts +79 -0
- package/src/primitives/NetworkId/Hex.ts +86 -0
- package/src/primitives/NetworkId/Number.ts +104 -0
- package/src/primitives/NetworkId/index.ts +60 -0
- package/src/primitives/NodeInfo/NodeInfoSchema.ts +70 -0
- package/src/primitives/NodeInfo/index.ts +39 -0
- package/src/primitives/Nonce/BigInt.ts +66 -0
- package/src/primitives/Nonce/Hex.ts +66 -0
- package/src/primitives/Nonce/Number.ts +74 -0
- package/src/primitives/Nonce/index.ts +56 -0
- package/src/primitives/OpStep/OpStepSchema.ts +118 -0
- package/src/primitives/OpStep/index.ts +29 -0
- package/src/primitives/Opcode/OpcodeSchema.ts +55 -0
- package/src/primitives/Opcode/index.ts +24 -0
- package/src/primitives/PackedUserOperation/PackedUserOperationSchema.ts +203 -0
- package/src/primitives/PackedUserOperation/hash.test.ts +103 -0
- package/src/primitives/PackedUserOperation/hash.ts +128 -0
- package/src/primitives/PackedUserOperation/index.ts +80 -0
- package/src/primitives/PackedUserOperation/unpack.ts +101 -0
- package/src/primitives/Paymaster/PaymasterSchema.ts +194 -0
- package/src/primitives/Paymaster/index.ts +21 -0
- package/src/primitives/PeerId/PeerIdSchema.ts +47 -0
- package/src/primitives/PeerId/index.ts +31 -0
- package/src/primitives/PeerInfo/PeerInfoSchema.ts +61 -0
- package/src/primitives/PeerInfo/index.ts +39 -0
- package/src/primitives/PendingTransactionFilter/Struct.ts +56 -0
- package/src/primitives/PendingTransactionFilter/index.ts +25 -0
- package/src/primitives/Permit/Permit.test.ts +32 -0
- package/src/primitives/Permit/Struct.ts +77 -0
- package/src/primitives/Permit/index.ts +58 -0
- package/src/primitives/PrivateKey/Bytes.ts +59 -0
- package/src/primitives/PrivateKey/Hex.ts +64 -0
- package/src/primitives/PrivateKey/PrivateKey.test.ts +410 -0
- package/src/primitives/PrivateKey/index.ts +62 -0
- package/src/primitives/PrivateKey/isValid.ts +35 -0
- package/src/primitives/PrivateKey/random.ts +27 -0
- package/src/primitives/Proof/Struct.ts +32 -0
- package/src/primitives/Proof/equals.ts +10 -0
- package/src/primitives/Proof/index.ts +37 -0
- package/src/primitives/Proof/verify.ts +11 -0
- package/src/primitives/ProtocolVersion/ProtocolVersionSchema.ts +55 -0
- package/src/primitives/ProtocolVersion/index.ts +32 -0
- package/src/primitives/Proxy/Struct.ts +49 -0
- package/src/primitives/Proxy/index.ts +11 -0
- package/src/primitives/PublicKey/Bytes.ts +68 -0
- package/src/primitives/PublicKey/Compressed.ts +71 -0
- package/src/primitives/PublicKey/Hex.ts +57 -0
- package/src/primitives/PublicKey/PublicKey.test.ts +443 -0
- package/src/primitives/PublicKey/equals.ts +30 -0
- package/src/primitives/PublicKey/index.ts +70 -0
- package/src/primitives/PublicKey/isCompressed.ts +27 -0
- package/src/primitives/PublicKey/isValid.ts +31 -0
- package/src/primitives/PublicKey/toAddress.ts +29 -0
- package/src/primitives/PublicKey/toBytes.ts +27 -0
- package/src/primitives/PublicKey/verify.ts +36 -0
- package/src/primitives/Receipt/ReceiptSchema.test.ts +94 -0
- package/src/primitives/Receipt/ReceiptSchema.ts +492 -0
- package/src/primitives/Receipt/index.ts +65 -0
- package/src/primitives/RelayData/RelayDataSchema.ts +106 -0
- package/src/primitives/RelayData/index.ts +10 -0
- package/src/primitives/ReturnData/Bytes.ts +60 -0
- package/src/primitives/ReturnData/Hex.ts +61 -0
- package/src/primitives/ReturnData/ReturnData.test.ts +43 -0
- package/src/primitives/ReturnData/ReturnDataSchema.ts +50 -0
- package/src/primitives/ReturnData/index.ts +45 -0
- package/src/primitives/RevertReason/Bytes.ts +81 -0
- package/src/primitives/RevertReason/Hex.ts +85 -0
- package/src/primitives/RevertReason/RevertReason.test.ts +42 -0
- package/src/primitives/RevertReason/RevertReasonSchema.ts +108 -0
- package/src/primitives/RevertReason/index.ts +67 -0
- package/src/primitives/RevertReason/toString.ts +28 -0
- package/src/primitives/Rlp/Rlp.test.ts +991 -0
- package/src/primitives/Rlp/RlpSchema.ts +50 -0
- package/src/primitives/Rlp/decode.ts +57 -0
- package/src/primitives/Rlp/decodeArray.ts +48 -0
- package/src/primitives/Rlp/encode.ts +58 -0
- package/src/primitives/Rlp/encodeArray.ts +32 -0
- package/src/primitives/Rlp/encodeBytes.ts +27 -0
- package/src/primitives/Rlp/encodeList.ts +32 -0
- package/src/primitives/Rlp/flatten.ts +38 -0
- package/src/primitives/Rlp/index.ts +74 -0
- package/src/primitives/Rlp/validate.ts +25 -0
- package/src/primitives/RuntimeCode/Bytes.ts +60 -0
- package/src/primitives/RuntimeCode/Hex.ts +61 -0
- package/src/primitives/RuntimeCode/RuntimeCode.test.ts +43 -0
- package/src/primitives/RuntimeCode/RuntimeCodeSchema.ts +49 -0
- package/src/primitives/RuntimeCode/index.ts +46 -0
- package/src/primitives/Selector/Bytes.ts +64 -0
- package/src/primitives/Selector/Hex.ts +69 -0
- package/src/primitives/Selector/Selector.test.ts +258 -0
- package/src/primitives/Selector/SelectorSchema.ts +95 -0
- package/src/primitives/Selector/Signature.ts +65 -0
- package/src/primitives/Selector/equals.ts +33 -0
- package/src/primitives/Selector/index.ts +55 -0
- package/src/primitives/Signature/Bytes.ts +57 -0
- package/src/primitives/Signature/Compact.ts +59 -0
- package/src/primitives/Signature/DER.ts +65 -0
- package/src/primitives/Signature/Hex.ts +56 -0
- package/src/primitives/Signature/Rpc.ts +77 -0
- package/src/primitives/Signature/Signature.test.ts +496 -0
- package/src/primitives/Signature/SignatureSchema.ts +30 -0
- package/src/primitives/Signature/Tuple.ts +75 -0
- package/src/primitives/Signature/equals.ts +25 -0
- package/src/primitives/Signature/getAlgorithm.ts +29 -0
- package/src/primitives/Signature/index.ts +93 -0
- package/src/primitives/Signature/is.ts +26 -0
- package/src/primitives/Signature/isCanonical.ts +28 -0
- package/src/primitives/Signature/isSignature.ts +26 -0
- package/src/primitives/Signature/normalize.ts +24 -0
- package/src/primitives/Signature/toBytes.ts +24 -0
- package/src/primitives/Signature/toCompact.ts +26 -0
- package/src/primitives/SignedData/SignedDataSchema.ts +61 -0
- package/src/primitives/SignedData/index.ts +26 -0
- package/src/primitives/Siwe/Siwe.test.ts +42 -0
- package/src/primitives/Siwe/String.ts +136 -0
- package/src/primitives/Siwe/index.ts +55 -0
- package/src/primitives/Slot/SlotSchema.ts +51 -0
- package/src/primitives/Slot/index.ts +20 -0
- package/src/primitives/SourceMap/Struct.ts +94 -0
- package/src/primitives/SourceMap/index.ts +12 -0
- package/src/primitives/Ssz/SszSchema.ts +49 -0
- package/src/primitives/Ssz/index.ts +29 -0
- package/src/primitives/State/StateSchema.ts +112 -0
- package/src/primitives/State/index.ts +22 -0
- package/src/primitives/StateDiff/StateDiffSchema.ts +251 -0
- package/src/primitives/StateDiff/index.ts +28 -0
- package/src/primitives/StateProof/StateProofSchema.ts +109 -0
- package/src/primitives/StateProof/index.ts +66 -0
- package/src/primitives/StateRoot/StateRootSchema.ts +109 -0
- package/src/primitives/StateRoot/index.ts +78 -0
- package/src/primitives/StealthAddress/Struct.ts +48 -0
- package/src/primitives/StealthAddress/index.ts +6 -0
- package/src/primitives/Storage/StorageSchema.ts +100 -0
- package/src/primitives/Storage/index.ts +53 -0
- package/src/primitives/StorageDiff/StorageDiffSchema.ts +111 -0
- package/src/primitives/StorageDiff/index.ts +59 -0
- package/src/primitives/StorageProof/Struct.ts +93 -0
- package/src/primitives/StorageProof/equals.ts +72 -0
- package/src/primitives/StorageProof/index.ts +67 -0
- package/src/primitives/StorageValue/Hex.ts +109 -0
- package/src/primitives/StorageValue/index.ts +92 -0
- package/src/primitives/StructLog/Struct.ts +101 -0
- package/src/primitives/StructLog/index.ts +28 -0
- package/src/primitives/SyncStatus/SyncStatusSchema.ts +87 -0
- package/src/primitives/SyncStatus/index.ts +36 -0
- package/src/primitives/TokenBalance/Struct.ts +48 -0
- package/src/primitives/TokenBalance/index.ts +23 -0
- package/src/primitives/TokenId/BigInt.ts +50 -0
- package/src/primitives/TokenId/index.ts +36 -0
- package/src/primitives/TopicFilter/Rpc.ts +142 -0
- package/src/primitives/TopicFilter/TopicFilter.test.ts +22 -0
- package/src/primitives/TopicFilter/index.ts +29 -0
- package/src/primitives/TraceConfig/TraceConfigSchema.ts +104 -0
- package/src/primitives/TraceConfig/index.ts +22 -0
- package/src/primitives/TraceResult/TraceResultSchema.ts +96 -0
- package/src/primitives/TraceResult/index.ts +23 -0
- package/src/primitives/Transaction/Authorization/index.ts +5 -0
- package/src/primitives/Transaction/EIP1559/index.ts +17 -0
- package/src/primitives/Transaction/EIP2930/index.ts +16 -0
- package/src/primitives/Transaction/EIP4844/index.ts +18 -0
- package/src/primitives/Transaction/EIP7702/index.ts +17 -0
- package/src/primitives/Transaction/Legacy/index.ts +17 -0
- package/src/primitives/Transaction/Rpc.ts +176 -0
- package/src/primitives/Transaction/Serialized.ts +98 -0
- package/src/primitives/Transaction/Transaction.test.ts +1562 -0
- package/src/primitives/Transaction/TransactionSchema.ts +515 -0
- package/src/primitives/Transaction/index.ts +289 -0
- package/src/primitives/TransactionHash/Bytes.ts +56 -0
- package/src/primitives/TransactionHash/Hex.ts +62 -0
- package/src/primitives/TransactionHash/index.ts +58 -0
- package/src/primitives/TransactionIndex/Number.ts +59 -0
- package/src/primitives/TransactionIndex/index.ts +53 -0
- package/src/primitives/TransactionStatus/TransactionStatusSchema.ts +57 -0
- package/src/primitives/TransactionStatus/index.ts +9 -0
- package/src/primitives/TransactionUrl/TransactionUrlSchema.ts +54 -0
- package/src/primitives/TransactionUrl/index.ts +21 -0
- package/src/primitives/TypedData/Struct.ts +194 -0
- package/src/primitives/TypedData/TypedData.test.ts +63 -0
- package/src/primitives/TypedData/index.ts +54 -0
- package/src/primitives/U256/index.ts +71 -0
- package/src/primitives/Uint/BigInt.ts +60 -0
- package/src/primitives/Uint/Bytes.ts +62 -0
- package/src/primitives/Uint/Hex.ts +61 -0
- package/src/primitives/Uint/Number.ts +61 -0
- package/src/primitives/Uint/String.ts +57 -0
- package/src/primitives/Uint/Uint.test.ts +838 -0
- package/src/primitives/Uint/bitLength.ts +22 -0
- package/src/primitives/Uint/bitwiseAnd.ts +24 -0
- package/src/primitives/Uint/bitwiseNot.ts +23 -0
- package/src/primitives/Uint/bitwiseOr.ts +24 -0
- package/src/primitives/Uint/bitwiseXor.ts +24 -0
- package/src/primitives/Uint/clone.ts +22 -0
- package/src/primitives/Uint/equals.ts +24 -0
- package/src/primitives/Uint/gcd.ts +24 -0
- package/src/primitives/Uint/greaterThan.ts +24 -0
- package/src/primitives/Uint/greaterThanOrEqual.ts +24 -0
- package/src/primitives/Uint/index.ts +85 -0
- package/src/primitives/Uint/isPowerOf2.ts +23 -0
- package/src/primitives/Uint/isZero.ts +22 -0
- package/src/primitives/Uint/lcm.ts +24 -0
- package/src/primitives/Uint/leadingZeros.ts +24 -0
- package/src/primitives/Uint/lessThan.ts +24 -0
- package/src/primitives/Uint/lessThanOrEqual.ts +24 -0
- package/src/primitives/Uint/max.ts +24 -0
- package/src/primitives/Uint/maximum.ts +27 -0
- package/src/primitives/Uint/min.ts +24 -0
- package/src/primitives/Uint/minimum.ts +27 -0
- package/src/primitives/Uint/minus.ts +27 -0
- package/src/primitives/Uint/notEquals.ts +24 -0
- package/src/primitives/Uint/plus.ts +27 -0
- package/src/primitives/Uint/popCount.ts +24 -0
- package/src/primitives/Uint/product.ts +24 -0
- package/src/primitives/Uint/shiftLeft.ts +24 -0
- package/src/primitives/Uint/shiftRight.ts +24 -0
- package/src/primitives/Uint/sum.ts +24 -0
- package/src/primitives/Uint/times.ts +27 -0
- package/src/primitives/Uint/toAbiEncoded.ts +24 -0
- package/src/primitives/Uint/toBigInt.ts +25 -0
- package/src/primitives/Uint/toBytes.ts +25 -0
- package/src/primitives/Uint/toNumber.ts +28 -0
- package/src/primitives/Uint/toPower.ts +29 -0
- package/src/primitives/Uint/toString.ts +31 -0
- package/src/primitives/Uint128/BigInt.ts +54 -0
- package/src/primitives/Uint128/Bytes.ts +56 -0
- package/src/primitives/Uint128/Hex.ts +55 -0
- package/src/primitives/Uint128/Number.ts +59 -0
- package/src/primitives/Uint128/String.ts +55 -0
- package/src/primitives/Uint128/Uint128Schema.ts +119 -0
- package/src/primitives/Uint128/index.ts +71 -0
- package/src/primitives/Uint16/BigInt.ts +57 -0
- package/src/primitives/Uint16/Bytes.ts +55 -0
- package/src/primitives/Uint16/Hex.ts +55 -0
- package/src/primitives/Uint16/Number.ts +55 -0
- package/src/primitives/Uint16/String.ts +55 -0
- package/src/primitives/Uint16/Uint16.test.ts +313 -0
- package/src/primitives/Uint16/Uint16Schema.ts +117 -0
- package/src/primitives/Uint16/index.ts +70 -0
- package/src/primitives/Uint32/BigInt.ts +55 -0
- package/src/primitives/Uint32/Bytes.ts +55 -0
- package/src/primitives/Uint32/Hex.ts +55 -0
- package/src/primitives/Uint32/Number.ts +55 -0
- package/src/primitives/Uint32/String.ts +55 -0
- package/src/primitives/Uint32/Uint32Schema.ts +122 -0
- package/src/primitives/Uint32/index.ts +70 -0
- package/src/primitives/Uint64/BigInt.ts +55 -0
- package/src/primitives/Uint64/Bytes.ts +56 -0
- package/src/primitives/Uint64/Hex.ts +55 -0
- package/src/primitives/Uint64/Number.ts +59 -0
- package/src/primitives/Uint64/String.ts +55 -0
- package/src/primitives/Uint64/Uint64Schema.ts +122 -0
- package/src/primitives/Uint64/index.ts +71 -0
- package/src/primitives/Uint8/BigInt.ts +57 -0
- package/src/primitives/Uint8/Bytes.ts +55 -0
- package/src/primitives/Uint8/Hex.ts +55 -0
- package/src/primitives/Uint8/Number.ts +55 -0
- package/src/primitives/Uint8/String.ts +55 -0
- package/src/primitives/Uint8/Uint8.test.ts +324 -0
- package/src/primitives/Uint8/Uint8Schema.ts +117 -0
- package/src/primitives/Uint8/index.ts +70 -0
- package/src/primitives/Uncle/Rpc.ts +49 -0
- package/src/primitives/Uncle/index.ts +11 -0
- package/src/primitives/UserOperation/UserOperationSchema.ts +213 -0
- package/src/primitives/UserOperation/index.ts +81 -0
- package/src/primitives/ValidatorIndex/ValidatorIndexSchema.ts +44 -0
- package/src/primitives/ValidatorIndex/index.ts +20 -0
- package/src/primitives/Withdrawal/WithdrawalSchema.ts +47 -0
- package/src/primitives/Withdrawal/index.ts +20 -0
- package/src/primitives/WithdrawalIndex/WithdrawalIndexSchema.ts +47 -0
- package/src/primitives/WithdrawalIndex/index.ts +20 -0
- package/src/primitives/errors/index.ts +1 -0
- package/src/primitives/index.ts +143 -0
- package/src/primitives/validation/assertCommon.ts +40 -0
- package/src/primitives/validation/assertInRange.ts +60 -0
- package/src/primitives/validation/assertInt.ts +121 -0
- package/src/primitives/validation/assertSize.ts +68 -0
- package/src/primitives/validation/assertUint.ts +114 -0
- package/src/primitives/validation/index.ts +23 -0
- package/src/services/AbiEncoder/AbiEncoder.test.ts +190 -0
- package/src/services/AbiEncoder/AbiEncoderService.ts +141 -0
- package/src/services/AbiEncoder/DefaultAbiEncoder.ts +186 -0
- package/src/services/AbiEncoder/index.ts +14 -0
- package/src/services/Account/Account.test.ts +756 -0
- package/src/services/Account/AccountService.ts +453 -0
- package/src/services/Account/JsonRpcAccount.ts +347 -0
- package/src/services/Account/LocalAccount.ts +967 -0
- package/src/services/Account/fromMnemonic.test.ts +67 -0
- package/src/services/Account/fromMnemonic.ts +221 -0
- package/src/services/Account/index.ts +65 -0
- package/src/services/Account/toAccount.test.ts +139 -0
- package/src/services/Account/toAccount.ts +185 -0
- package/src/services/BlockStream/BlockStream.test.ts +1246 -0
- package/src/services/BlockStream/BlockStream.ts +125 -0
- package/src/services/BlockStream/BlockStreamError.ts +33 -0
- package/src/services/BlockStream/BlockStreamService.ts +105 -0
- package/src/services/BlockStream/index.ts +32 -0
- package/src/services/Cache/CacheService.ts +102 -0
- package/src/services/Cache/LookupCacheService.test.ts +305 -0
- package/src/services/Cache/LookupCacheService.ts +209 -0
- package/src/services/Cache/MemoryCache.test.ts +154 -0
- package/src/services/Cache/MemoryCache.ts +175 -0
- package/src/services/Cache/NoopCache.test.ts +159 -0
- package/src/services/Cache/NoopCache.ts +81 -0
- package/src/services/Cache/index.ts +176 -0
- package/src/services/Ccip/Ccip.test.ts +569 -0
- package/src/services/Ccip/CcipService.ts +106 -0
- package/src/services/Ccip/DefaultCcip.ts +189 -0
- package/src/services/Ccip/NoopCcip.ts +52 -0
- package/src/services/Ccip/index.ts +20 -0
- package/src/services/Chain/BlockExplorerService.ts +39 -0
- package/src/services/Chain/Chain.test.ts +296 -0
- package/src/services/Chain/ChainService.ts +97 -0
- package/src/services/Chain/ContractsService.ts +46 -0
- package/src/services/Chain/chains/arbitrum.ts +73 -0
- package/src/services/Chain/chains/base.ts +73 -0
- package/src/services/Chain/chains/index.ts +48 -0
- package/src/services/Chain/chains/mainnet.ts +77 -0
- package/src/services/Chain/chains/optimism.ts +73 -0
- package/src/services/Chain/chains/polygon.ts +73 -0
- package/src/services/Chain/chains/sepolia.ts +78 -0
- package/src/services/Chain/index.ts +77 -0
- package/src/services/Chain/rpcUrls.ts +31 -0
- package/src/services/Contract/Contract.test.ts +988 -0
- package/src/services/Contract/Contract.ts +432 -0
- package/src/services/Contract/ContractTypes.ts +412 -0
- package/src/services/Contract/estimateGas.test.ts +124 -0
- package/src/services/Contract/estimateGas.ts +163 -0
- package/src/services/Contract/index.ts +67 -0
- package/src/services/Debug/Debug.ts +121 -0
- package/src/services/Debug/DebugService.ts +89 -0
- package/src/services/Debug/index.ts +13 -0
- package/src/services/EngineApi/EngineApi.ts +95 -0
- package/src/services/EngineApi/EngineApiService.ts +99 -0
- package/src/services/EngineApi/index.ts +9 -0
- package/src/services/Ens/DefaultEns.ts +60 -0
- package/src/services/Ens/EnsService.ts +66 -0
- package/src/services/Ens/index.ts +61 -0
- package/src/services/FeeEstimator/DefaultFeeEstimator.ts +277 -0
- package/src/services/FeeEstimator/FeeEstimator.test.ts +810 -0
- package/src/services/FeeEstimator/FeeEstimatorService.ts +168 -0
- package/src/services/FeeEstimator/index.ts +57 -0
- package/src/services/Formatter/DefaultFormatter.ts +74 -0
- package/src/services/Formatter/Formatter.test.ts +92 -0
- package/src/services/Formatter/FormatterService.ts +137 -0
- package/src/services/Formatter/chains/arbitrum.ts +35 -0
- package/src/services/Formatter/chains/chains.test.ts +102 -0
- package/src/services/Formatter/chains/index.ts +13 -0
- package/src/services/Formatter/chains/optimism.ts +36 -0
- package/src/services/Formatter/chains/zksync.ts +35 -0
- package/src/services/Formatter/index.ts +22 -0
- package/src/services/Kzg/DefaultKzg.ts +111 -0
- package/src/services/Kzg/Kzg.test.ts +320 -0
- package/src/services/Kzg/KzgService.ts +123 -0
- package/src/services/Kzg/NoopKzg.ts +75 -0
- package/src/services/Kzg/index.ts +15 -0
- package/src/services/Multicall/BalanceResolver.ts +182 -0
- package/src/services/Multicall/GetBalance.ts +27 -0
- package/src/services/Multicall/Multicall.test.ts +384 -0
- package/src/services/Multicall/Multicall.ts +241 -0
- package/src/services/Multicall/index.ts +20 -0
- package/src/services/NonceManager/DefaultNonceManager.ts +154 -0
- package/src/services/NonceManager/NonceManager.test.ts +468 -0
- package/src/services/NonceManager/NonceManagerService.ts +191 -0
- package/src/services/NonceManager/index.ts +46 -0
- package/src/services/Provider/Account.ts +33 -0
- package/src/services/Provider/AccountService.ts +84 -0
- package/src/services/Provider/Blocks.ts +32 -0
- package/src/services/Provider/BlocksService.ts +73 -0
- package/src/services/Provider/Events.ts +33 -0
- package/src/services/Provider/EventsService.ts +71 -0
- package/src/services/Provider/Network.ts +41 -0
- package/src/services/Provider/NetworkService.ts +114 -0
- package/src/services/Provider/Provider.test.ts +1723 -0
- package/src/services/Provider/Provider.ts +1193 -0
- package/src/services/Provider/ProviderService.ts +1218 -0
- package/src/services/Provider/REFACTOR_PLAN.md +203 -0
- package/src/services/Provider/Simulation.ts +34 -0
- package/src/services/Provider/SimulationService.ts +161 -0
- package/src/services/Provider/Streaming.ts +30 -0
- package/src/services/Provider/StreamingService.ts +58 -0
- package/src/services/Provider/Transaction.ts +39 -0
- package/src/services/Provider/TransactionService.ts +83 -0
- package/src/services/Provider/actions/index.ts +26 -0
- package/src/services/Provider/actions/multicall.test.ts +716 -0
- package/src/services/Provider/actions/multicall.ts +304 -0
- package/src/services/Provider/actions/readContract.test.ts +808 -0
- package/src/services/Provider/actions/readContract.ts +311 -0
- package/src/services/Provider/actions/simulateContract.test.ts +454 -0
- package/src/services/Provider/actions/simulateContract.ts +189 -0
- package/src/services/Provider/ens/EnsError.ts +38 -0
- package/src/services/Provider/ens/constants.ts +81 -0
- package/src/services/Provider/ens/ens.test.ts +322 -0
- package/src/services/Provider/ens/getEnsAddress.ts +126 -0
- package/src/services/Provider/ens/getEnsAvatar.ts +51 -0
- package/src/services/Provider/ens/getEnsName.ts +124 -0
- package/src/services/Provider/ens/getEnsResolver.ts +82 -0
- package/src/services/Provider/ens/getEnsText.ts +158 -0
- package/src/services/Provider/ens/index.ts +49 -0
- package/src/services/Provider/ens/utils.ts +165 -0
- package/src/services/Provider/filters.ts +91 -0
- package/src/services/Provider/getBlobBaseFee.ts +170 -0
- package/src/services/Provider/index.ts +213 -0
- package/src/services/Provider/simulateCalls.test.ts +127 -0
- package/src/services/Provider/simulateCalls.ts +281 -0
- package/src/services/RateLimiter/DefaultRateLimiter.ts +226 -0
- package/src/services/RateLimiter/RateLimiter.test.ts +181 -0
- package/src/services/RateLimiter/RateLimiterService.ts +208 -0
- package/src/services/RateLimiter/index.ts +54 -0
- package/src/services/RawProvider/ForkProviderTransport.ts +100 -0
- package/src/services/RawProvider/HttpProviderTransport.test.ts +310 -0
- package/src/services/RawProvider/HttpProviderTransport.ts +76 -0
- package/src/services/RawProvider/InMemoryProviderTransport.test.ts +246 -0
- package/src/services/RawProvider/InMemoryProviderTransport.ts +81 -0
- package/src/services/RawProvider/RawProvider.test.ts +454 -0
- package/src/services/RawProvider/RawProviderService.ts +61 -0
- package/src/services/RawProvider/RawProviderTransport.ts +64 -0
- package/src/services/RawProvider/WebSocketProviderTransport.ts +106 -0
- package/src/services/RawProvider/index.ts +31 -0
- package/src/services/RpcBatch/RpcBatch.test.ts +628 -0
- package/src/services/RpcBatch/RpcRequest.ts +227 -0
- package/src/services/RpcBatch/RpcResolver.test.ts +315 -0
- package/src/services/RpcBatch/RpcResolver.ts +362 -0
- package/src/services/RpcBatch/index.ts +88 -0
- package/src/services/Signer/Signer.test.ts +1629 -0
- package/src/services/Signer/Signer.ts +812 -0
- package/src/services/Signer/SignerService.ts +518 -0
- package/src/services/Signer/actions/addChain.test.ts +178 -0
- package/src/services/Signer/actions/addChain.ts +80 -0
- package/src/services/Signer/actions/deployContract.test.ts +523 -0
- package/src/services/Signer/actions/deployContract.ts +165 -0
- package/src/services/Signer/actions/getAddresses.test.ts +118 -0
- package/src/services/Signer/actions/getAddresses.ts +60 -0
- package/src/services/Signer/actions/getPermissions.test.ts +122 -0
- package/src/services/Signer/actions/getPermissions.ts +54 -0
- package/src/services/Signer/actions/index.ts +49 -0
- package/src/services/Signer/actions/prepareAuthorization.test.ts +206 -0
- package/src/services/Signer/actions/prepareAuthorization.ts +92 -0
- package/src/services/Signer/actions/requestPermissions.test.ts +164 -0
- package/src/services/Signer/actions/requestPermissions.ts +66 -0
- package/src/services/Signer/actions/signAuthorization.test.ts +279 -0
- package/src/services/Signer/actions/signAuthorization.ts +127 -0
- package/src/services/Signer/actions/switchChain.test.ts +129 -0
- package/src/services/Signer/actions/switchChain.ts +56 -0
- package/src/services/Signer/actions/watchAsset.test.ts +175 -0
- package/src/services/Signer/actions/watchAsset.ts +110 -0
- package/src/services/Signer/actions/writeContract.test.ts +281 -0
- package/src/services/Signer/actions/writeContract.ts +109 -0
- package/src/services/Signer/index.ts +108 -0
- package/src/services/TransactionSerializer/DefaultTransactionSerializer.ts +110 -0
- package/src/services/TransactionSerializer/TransactionSerializer.test.ts +200 -0
- package/src/services/TransactionSerializer/TransactionSerializerService.ts +114 -0
- package/src/services/TransactionSerializer/index.ts +38 -0
- package/src/services/Transport/BatchScheduler.test.ts +209 -0
- package/src/services/Transport/BatchScheduler.ts +298 -0
- package/src/services/Transport/BrowserTransport.test.ts +354 -0
- package/src/services/Transport/BrowserTransport.ts +209 -0
- package/src/services/Transport/CustomTransport.test.ts +331 -0
- package/src/services/Transport/CustomTransport.ts +355 -0
- package/src/services/Transport/FallbackTransport.test.ts +492 -0
- package/src/services/Transport/FallbackTransport.ts +240 -0
- package/src/services/Transport/HttpTransport.ts +685 -0
- package/src/services/Transport/HttpTransportConfig.test.ts +153 -0
- package/src/services/Transport/HttpTransportConfig.ts +270 -0
- package/src/services/Transport/HttpTransportHooks.test.ts +176 -0
- package/src/services/Transport/IdGenerator.test.ts +117 -0
- package/src/services/Transport/IdGenerator.ts +82 -0
- package/src/services/Transport/IpcTransport.test.ts +222 -0
- package/src/services/Transport/IpcTransport.ts +732 -0
- package/src/services/Transport/RateLimitedTransport.test.ts +118 -0
- package/src/services/Transport/RateLimitedTransport.ts +124 -0
- package/src/services/Transport/RpcRequest.test.ts +266 -0
- package/src/services/Transport/RpcRequest.ts +312 -0
- package/src/services/Transport/RpcResolver.test.ts +280 -0
- package/src/services/Transport/RpcResolver.ts +184 -0
- package/src/services/Transport/TestTransport.ts +175 -0
- package/src/services/Transport/Transport.test.ts +1755 -0
- package/src/services/Transport/TransportConfig.test.ts +224 -0
- package/src/services/Transport/TransportConfig.ts +285 -0
- package/src/services/Transport/TransportError.test.ts +166 -0
- package/src/services/Transport/TransportError.ts +134 -0
- package/src/services/Transport/TransportFiberRef.test.ts +164 -0
- package/src/services/Transport/TransportInterceptor.test.ts +341 -0
- package/src/services/Transport/TransportInterceptor.ts +531 -0
- package/src/services/Transport/TransportService.ts +124 -0
- package/src/services/Transport/WebSocketTransport.test.ts +588 -0
- package/src/services/Transport/WebSocketTransport.ts +765 -0
- package/src/services/Transport/WebSocketTransportConfig.test.ts +185 -0
- package/src/services/Transport/WebSocketTransportConfig.ts +247 -0
- package/src/services/Transport/__testUtils__/mockIpcSocket.ts +106 -0
- package/src/services/Transport/__testUtils__/mockWebSocket.ts +138 -0
- package/src/services/Transport/config.ts +150 -0
- package/src/services/Transport/index.ts +161 -0
- package/src/services/errors.test.ts +570 -0
- package/src/services/index.ts +439 -0
- package/src/services/presets/index.ts +283 -0
- package/src/services/presets/presets.test.ts +88 -0
- package/src/standards/ERC1155.test.ts +324 -0
- package/src/standards/ERC1155.ts +328 -0
- package/src/standards/ERC165.test.ts +216 -0
- package/src/standards/ERC165.ts +87 -0
- package/src/standards/ERC20.test.ts +310 -0
- package/src/standards/ERC20.ts +275 -0
- package/src/standards/ERC721.test.ts +343 -0
- package/src/standards/ERC721.ts +319 -0
- package/src/standards/errors.test.ts +54 -0
- package/src/standards/errors.ts +7 -0
- package/src/standards/index.ts +5 -0
- package/src/stream/index.test.ts +216 -0
- package/src/stream/index.ts +37 -0
- package/src/transaction/TransactionStream.test.ts +887 -0
- package/src/transaction/TransactionStream.ts +142 -0
- package/src/transaction/TransactionStreamError.test.ts +133 -0
- package/src/transaction/TransactionStreamError.ts +35 -0
- package/src/transaction/TransactionStreamService.ts +121 -0
- package/src/transaction/index.ts +35 -0
- package/src/utils/Unit/Unit.test.ts +337 -0
- package/src/utils/Unit/errors.ts +16 -0
- package/src/utils/Unit/formatEther.ts +24 -0
- package/src/utils/Unit/formatGwei.ts +24 -0
- package/src/utils/Unit/formatUnits.ts +55 -0
- package/src/utils/Unit/index.ts +49 -0
- package/src/utils/Unit/parseEther.ts +24 -0
- package/src/utils/Unit/parseGwei.ts +24 -0
- package/src/utils/Unit/parseUnits.ts +68 -0
|
@@ -0,0 +1,1755 @@
|
|
|
1
|
+
import * as HttpClient from "@effect/platform/HttpClient";
|
|
2
|
+
import type * as HttpClientRequest from "@effect/platform/HttpClientRequest";
|
|
3
|
+
import type * as HttpClientResponse from "@effect/platform/HttpClientResponse";
|
|
4
|
+
import {
|
|
5
|
+
afterEach,
|
|
6
|
+
beforeEach,
|
|
7
|
+
describe,
|
|
8
|
+
expect,
|
|
9
|
+
it,
|
|
10
|
+
vi,
|
|
11
|
+
} from "@effect/vitest";
|
|
12
|
+
import * as Duration from "effect/Duration";
|
|
13
|
+
import * as Effect from "effect/Effect";
|
|
14
|
+
import * as Fiber from "effect/Fiber";
|
|
15
|
+
import * as Layer from "effect/Layer";
|
|
16
|
+
import * as Schedule from "effect/Schedule";
|
|
17
|
+
import * as TestClock from "effect/TestClock";
|
|
18
|
+
import { makeMockWebSocket } from "./__testUtils__/mockWebSocket.js";
|
|
19
|
+
import {
|
|
20
|
+
BrowserTransport,
|
|
21
|
+
FallbackTransport,
|
|
22
|
+
HttpTransport,
|
|
23
|
+
TestTransport,
|
|
24
|
+
TransportError,
|
|
25
|
+
TransportService,
|
|
26
|
+
WebSocketConstructorGlobal,
|
|
27
|
+
WebSocketTransport,
|
|
28
|
+
} from "./index.js";
|
|
29
|
+
|
|
30
|
+
const createMockHttpClientLayer = (
|
|
31
|
+
fetchMock: ReturnType<typeof vi.fn>,
|
|
32
|
+
): Layer.Layer<HttpClient.HttpClient> =>
|
|
33
|
+
Layer.succeed(
|
|
34
|
+
HttpClient.HttpClient,
|
|
35
|
+
HttpClient.make((request: HttpClientRequest.HttpClientRequest) => {
|
|
36
|
+
return Effect.gen(function* () {
|
|
37
|
+
const result = fetchMock(request);
|
|
38
|
+
const resolved =
|
|
39
|
+
result instanceof Promise
|
|
40
|
+
? yield* Effect.promise(() => result)
|
|
41
|
+
: result;
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
status: resolved.ok ? 200 : (resolved.status ?? 500),
|
|
45
|
+
headers: {},
|
|
46
|
+
cookies: {} as HttpClientResponse.HttpClientResponse["cookies"],
|
|
47
|
+
formData: Effect.succeed(new FormData()),
|
|
48
|
+
json: Effect.promise(() => resolved.json()),
|
|
49
|
+
text: Effect.succeed(""),
|
|
50
|
+
urlParamsBody: Effect.succeed({} as never),
|
|
51
|
+
arrayBuffer: Effect.succeed(new ArrayBuffer(0)),
|
|
52
|
+
stream: null as never,
|
|
53
|
+
request,
|
|
54
|
+
remoteAddress: { _tag: "None" } as never,
|
|
55
|
+
[Symbol.for("effect/Inspectable")]: {},
|
|
56
|
+
toJSON: () => ({}),
|
|
57
|
+
toString: () => "",
|
|
58
|
+
} as unknown as HttpClientResponse.HttpClientResponse;
|
|
59
|
+
});
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
import type { HttpTransportConfig } from "./HttpTransport.js";
|
|
64
|
+
|
|
65
|
+
const createMockHttpTransport = (
|
|
66
|
+
fetchMock: ReturnType<typeof vi.fn>,
|
|
67
|
+
options: HttpTransportConfig | string,
|
|
68
|
+
): Layer.Layer<TransportService> =>
|
|
69
|
+
Layer.provide(HttpTransport(options), createMockHttpClientLayer(fetchMock));
|
|
70
|
+
|
|
71
|
+
const parseJsonBody = (
|
|
72
|
+
request: HttpClientRequest.HttpClientRequest,
|
|
73
|
+
): unknown => {
|
|
74
|
+
const body = request.body as { _tag: string; body: Uint8Array };
|
|
75
|
+
return JSON.parse(new TextDecoder().decode(body.body));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const parseBatchRequests = (
|
|
79
|
+
request: HttpClientRequest.HttpClientRequest,
|
|
80
|
+
): Array<{ id: number; method: string; params?: unknown[] }> => {
|
|
81
|
+
const parsed = parseJsonBody(request) as
|
|
82
|
+
| { id: number; method: string; params?: unknown[] }
|
|
83
|
+
| Array<{ id: number; method: string; params?: unknown[] }>;
|
|
84
|
+
return Array.isArray(parsed) ? parsed : [parsed];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
describe("TransportService", () => {
|
|
88
|
+
describe("TestTransport", () => {
|
|
89
|
+
it("returns mocked responses", async () => {
|
|
90
|
+
const program = Effect.gen(function* () {
|
|
91
|
+
const transport = yield* TransportService;
|
|
92
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
93
|
+
}).pipe(Effect.provide(TestTransport({ eth_blockNumber: "0x1234" })));
|
|
94
|
+
|
|
95
|
+
const result = await Effect.runPromise(program);
|
|
96
|
+
expect(result).toBe("0x1234");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("returns mocked responses from Map", async () => {
|
|
100
|
+
const responses = new Map([["eth_chainId", "0x1"]]);
|
|
101
|
+
const program = Effect.gen(function* () {
|
|
102
|
+
const transport = yield* TransportService;
|
|
103
|
+
return yield* transport.request<string>("eth_chainId", []);
|
|
104
|
+
}).pipe(Effect.provide(TestTransport(responses)));
|
|
105
|
+
|
|
106
|
+
const result = await Effect.runPromise(program);
|
|
107
|
+
expect(result).toBe("0x1");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("fails for unknown methods", async () => {
|
|
111
|
+
const program = Effect.gen(function* () {
|
|
112
|
+
const transport = yield* TransportService;
|
|
113
|
+
return yield* transport.request<string>("eth_unknown", []);
|
|
114
|
+
}).pipe(Effect.provide(TestTransport({})));
|
|
115
|
+
|
|
116
|
+
const exit = await Effect.runPromiseExit(program);
|
|
117
|
+
expect(exit._tag).toBe("Failure");
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("can mock errors", async () => {
|
|
121
|
+
const responses = new Map([
|
|
122
|
+
[
|
|
123
|
+
"eth_call",
|
|
124
|
+
new TransportError({ code: -32000, message: "execution reverted" }),
|
|
125
|
+
],
|
|
126
|
+
]);
|
|
127
|
+
const program = Effect.gen(function* () {
|
|
128
|
+
const transport = yield* TransportService;
|
|
129
|
+
return yield* transport.request<string>("eth_call", []);
|
|
130
|
+
}).pipe(Effect.provide(TestTransport(responses)));
|
|
131
|
+
|
|
132
|
+
const exit = await Effect.runPromiseExit(program);
|
|
133
|
+
expect(exit._tag).toBe("Failure");
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it("returns complex object responses", async () => {
|
|
137
|
+
const mockBlock = {
|
|
138
|
+
number: "0x10",
|
|
139
|
+
hash: "0xabc",
|
|
140
|
+
transactions: ["0x1", "0x2"],
|
|
141
|
+
};
|
|
142
|
+
const program = Effect.gen(function* () {
|
|
143
|
+
const transport = yield* TransportService;
|
|
144
|
+
return yield* transport.request<typeof mockBlock>(
|
|
145
|
+
"eth_getBlockByNumber",
|
|
146
|
+
[],
|
|
147
|
+
);
|
|
148
|
+
}).pipe(
|
|
149
|
+
Effect.provide(TestTransport({ eth_getBlockByNumber: mockBlock })),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const result = await Effect.runPromise(program);
|
|
153
|
+
expect(result.number).toBe("0x10");
|
|
154
|
+
expect(result.transactions).toHaveLength(2);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it("handles null responses", async () => {
|
|
158
|
+
const program = Effect.gen(function* () {
|
|
159
|
+
const transport = yield* TransportService;
|
|
160
|
+
return yield* transport.request<null>("eth_getTransactionReceipt", []);
|
|
161
|
+
}).pipe(
|
|
162
|
+
Effect.provide(TestTransport({ eth_getTransactionReceipt: null })),
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const result = await Effect.runPromise(program);
|
|
166
|
+
expect(result).toBeNull();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("handles array responses", async () => {
|
|
170
|
+
const accounts = ["0x1234", "0x5678"];
|
|
171
|
+
const program = Effect.gen(function* () {
|
|
172
|
+
const transport = yield* TransportService;
|
|
173
|
+
return yield* transport.request<string[]>("eth_accounts", []);
|
|
174
|
+
}).pipe(Effect.provide(TestTransport({ eth_accounts: accounts })));
|
|
175
|
+
|
|
176
|
+
const result = await Effect.runPromise(program);
|
|
177
|
+
expect(result).toEqual(accounts);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("preserves error code in TransportError", async () => {
|
|
181
|
+
const errorCode = -32602;
|
|
182
|
+
const program = Effect.gen(function* () {
|
|
183
|
+
const transport = yield* TransportService;
|
|
184
|
+
return yield* transport.request<string>("eth_call", []);
|
|
185
|
+
}).pipe(
|
|
186
|
+
Effect.provide(
|
|
187
|
+
TestTransport({
|
|
188
|
+
eth_call: new TransportError({
|
|
189
|
+
code: errorCode,
|
|
190
|
+
message: "Invalid params",
|
|
191
|
+
}),
|
|
192
|
+
}),
|
|
193
|
+
),
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
const exit = await Effect.runPromiseExit(program);
|
|
197
|
+
expect(exit._tag).toBe("Failure");
|
|
198
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
199
|
+
expect((exit.cause.error as TransportError).code).toBe(errorCode);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("preserves error data in TransportError", async () => {
|
|
204
|
+
const errorData = { revertReason: "0x08c379a0..." };
|
|
205
|
+
const program = Effect.gen(function* () {
|
|
206
|
+
const transport = yield* TransportService;
|
|
207
|
+
return yield* transport.request<string>("eth_call", []);
|
|
208
|
+
}).pipe(
|
|
209
|
+
Effect.provide(
|
|
210
|
+
TestTransport({
|
|
211
|
+
eth_call: new TransportError({
|
|
212
|
+
code: -32000,
|
|
213
|
+
message: "reverted",
|
|
214
|
+
data: errorData,
|
|
215
|
+
}),
|
|
216
|
+
}),
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const exit = await Effect.runPromiseExit(program);
|
|
221
|
+
expect(exit._tag).toBe("Failure");
|
|
222
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
223
|
+
expect((exit.cause.error as TransportError).data).toEqual(errorData);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("HttpTransport", () => {
|
|
229
|
+
let fetchMock: ReturnType<typeof vi.fn>;
|
|
230
|
+
|
|
231
|
+
beforeEach(() => {
|
|
232
|
+
fetchMock = vi.fn();
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it("makes JSON-RPC requests", async () => {
|
|
236
|
+
fetchMock.mockResolvedValueOnce({
|
|
237
|
+
ok: true,
|
|
238
|
+
json: async () => ({ jsonrpc: "2.0", id: 1, result: "0x5678" }),
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const program = Effect.gen(function* () {
|
|
242
|
+
const transport = yield* TransportService;
|
|
243
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
244
|
+
}).pipe(
|
|
245
|
+
Effect.provide(
|
|
246
|
+
createMockHttpTransport(fetchMock, {
|
|
247
|
+
url: "https://eth.example.com",
|
|
248
|
+
}),
|
|
249
|
+
),
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
const result = await Effect.runPromise(program);
|
|
253
|
+
expect(result).toBe("0x5678");
|
|
254
|
+
|
|
255
|
+
expect(fetchMock).toHaveBeenCalled();
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
it("accepts string URL shorthand", async () => {
|
|
259
|
+
fetchMock.mockResolvedValueOnce({
|
|
260
|
+
ok: true,
|
|
261
|
+
json: async () => ({ jsonrpc: "2.0", id: 1, result: "0x1" }),
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const program = Effect.gen(function* () {
|
|
265
|
+
const transport = yield* TransportService;
|
|
266
|
+
return yield* transport.request<string>("eth_chainId", []);
|
|
267
|
+
}).pipe(
|
|
268
|
+
Effect.provide(
|
|
269
|
+
createMockHttpTransport(fetchMock, "https://eth.example.com"),
|
|
270
|
+
),
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const result = await Effect.runPromise(program);
|
|
274
|
+
expect(result).toBe("0x1");
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("includes custom headers", async () => {
|
|
278
|
+
fetchMock.mockResolvedValueOnce({
|
|
279
|
+
ok: true,
|
|
280
|
+
json: async () => ({ jsonrpc: "2.0", id: 1, result: "0x1" }),
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
const program = Effect.gen(function* () {
|
|
284
|
+
const transport = yield* TransportService;
|
|
285
|
+
return yield* transport.request<string>("eth_chainId", []);
|
|
286
|
+
}).pipe(
|
|
287
|
+
Effect.provide(
|
|
288
|
+
createMockHttpTransport(fetchMock, {
|
|
289
|
+
url: "https://eth.example.com",
|
|
290
|
+
headers: { "X-Api-Key": "secret" },
|
|
291
|
+
}),
|
|
292
|
+
),
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
const result = await Effect.runPromise(program);
|
|
296
|
+
expect(result).toBe("0x1");
|
|
297
|
+
expect(fetchMock).toHaveBeenCalled();
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
it("handles JSON-RPC errors", async () => {
|
|
301
|
+
fetchMock.mockResolvedValueOnce({
|
|
302
|
+
ok: true,
|
|
303
|
+
json: async () => ({
|
|
304
|
+
jsonrpc: "2.0",
|
|
305
|
+
id: 1,
|
|
306
|
+
error: { code: -32000, message: "execution reverted" },
|
|
307
|
+
}),
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const program = Effect.gen(function* () {
|
|
311
|
+
const transport = yield* TransportService;
|
|
312
|
+
return yield* transport.request<string>("eth_call", []);
|
|
313
|
+
}).pipe(
|
|
314
|
+
Effect.provide(
|
|
315
|
+
createMockHttpTransport(fetchMock, {
|
|
316
|
+
url: "https://eth.example.com",
|
|
317
|
+
}),
|
|
318
|
+
),
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
const exit = await Effect.runPromiseExit(program);
|
|
322
|
+
expect(exit._tag).toBe("Failure");
|
|
323
|
+
if (exit._tag === "Failure") {
|
|
324
|
+
const error = exit.cause;
|
|
325
|
+
expect(error._tag).toBe("Fail");
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it("sends JSON-RPC batch body for __batch__ requests", async () => {
|
|
330
|
+
const batchRequests = [
|
|
331
|
+
{ jsonrpc: "2.0", id: 0, method: "eth_blockNumber", params: [] },
|
|
332
|
+
{ jsonrpc: "2.0", id: 1, method: "eth_chainId", params: [] },
|
|
333
|
+
];
|
|
334
|
+
|
|
335
|
+
fetchMock.mockImplementation(
|
|
336
|
+
(request: HttpClientRequest.HttpClientRequest) => {
|
|
337
|
+
const body = parseJsonBody(request);
|
|
338
|
+
expect(Array.isArray(body)).toBe(true);
|
|
339
|
+
if (Array.isArray(body)) {
|
|
340
|
+
expect(body[0]).toMatchObject({
|
|
341
|
+
method: "eth_blockNumber",
|
|
342
|
+
id: 0,
|
|
343
|
+
});
|
|
344
|
+
expect(body[1]).toMatchObject({
|
|
345
|
+
method: "eth_chainId",
|
|
346
|
+
id: 1,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return Promise.resolve({
|
|
350
|
+
ok: true,
|
|
351
|
+
json: async () => [
|
|
352
|
+
{ jsonrpc: "2.0", id: 0, result: "0x100" },
|
|
353
|
+
{ jsonrpc: "2.0", id: 1, result: "0x1" },
|
|
354
|
+
],
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
const program = Effect.gen(function* () {
|
|
360
|
+
const transport = yield* TransportService;
|
|
361
|
+
return yield* transport.request<
|
|
362
|
+
Array<{ jsonrpc: string; id: number; result?: unknown }>
|
|
363
|
+
>("__batch__", batchRequests as unknown[]);
|
|
364
|
+
}).pipe(
|
|
365
|
+
Effect.provide(
|
|
366
|
+
createMockHttpTransport(fetchMock, {
|
|
367
|
+
url: "https://eth.example.com",
|
|
368
|
+
}),
|
|
369
|
+
),
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
const result = await Effect.runPromise(program);
|
|
373
|
+
expect(result).toEqual([
|
|
374
|
+
{ jsonrpc: "2.0", id: 0, result: "0x100" },
|
|
375
|
+
{ jsonrpc: "2.0", id: 1, result: "0x1" },
|
|
376
|
+
]);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("handles HTTP errors", async () => {
|
|
380
|
+
fetchMock.mockResolvedValueOnce({
|
|
381
|
+
ok: false,
|
|
382
|
+
status: 429,
|
|
383
|
+
statusText: "Too Many Requests",
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
const program = Effect.gen(function* () {
|
|
387
|
+
const transport = yield* TransportService;
|
|
388
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
389
|
+
}).pipe(
|
|
390
|
+
Effect.provide(
|
|
391
|
+
createMockHttpTransport(fetchMock, {
|
|
392
|
+
url: "https://eth.example.com",
|
|
393
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
394
|
+
unknown,
|
|
395
|
+
TransportError
|
|
396
|
+
>,
|
|
397
|
+
}),
|
|
398
|
+
),
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
const exit = await Effect.runPromiseExit(program);
|
|
402
|
+
expect(exit._tag).toBe("Failure");
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
it("handles 500 Internal Server Error", async () => {
|
|
406
|
+
fetchMock.mockResolvedValueOnce({
|
|
407
|
+
ok: false,
|
|
408
|
+
status: 500,
|
|
409
|
+
statusText: "Internal Server Error",
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const program = Effect.gen(function* () {
|
|
413
|
+
const transport = yield* TransportService;
|
|
414
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
415
|
+
}).pipe(
|
|
416
|
+
Effect.provide(
|
|
417
|
+
createMockHttpTransport(fetchMock, {
|
|
418
|
+
url: "https://eth.example.com",
|
|
419
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
420
|
+
unknown,
|
|
421
|
+
TransportError
|
|
422
|
+
>,
|
|
423
|
+
}),
|
|
424
|
+
),
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
const exit = await Effect.runPromiseExit(program);
|
|
428
|
+
expect(exit._tag).toBe("Failure");
|
|
429
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
430
|
+
expect((exit.cause.error as TransportError).message).toContain("500");
|
|
431
|
+
}
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it("handles 503 Service Unavailable", async () => {
|
|
435
|
+
fetchMock.mockResolvedValueOnce({
|
|
436
|
+
ok: false,
|
|
437
|
+
status: 503,
|
|
438
|
+
statusText: "Service Unavailable",
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const program = Effect.gen(function* () {
|
|
442
|
+
const transport = yield* TransportService;
|
|
443
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
444
|
+
}).pipe(
|
|
445
|
+
Effect.provide(
|
|
446
|
+
createMockHttpTransport(fetchMock, {
|
|
447
|
+
url: "https://eth.example.com",
|
|
448
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
449
|
+
unknown,
|
|
450
|
+
TransportError
|
|
451
|
+
>,
|
|
452
|
+
}),
|
|
453
|
+
),
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const exit = await Effect.runPromiseExit(program);
|
|
457
|
+
expect(exit._tag).toBe("Failure");
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
it("handles network failure", async () => {
|
|
461
|
+
fetchMock.mockRejectedValueOnce(new Error("Network error"));
|
|
462
|
+
|
|
463
|
+
const program = Effect.gen(function* () {
|
|
464
|
+
const transport = yield* TransportService;
|
|
465
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
466
|
+
}).pipe(
|
|
467
|
+
Effect.provide(
|
|
468
|
+
createMockHttpTransport(fetchMock, {
|
|
469
|
+
url: "https://eth.example.com",
|
|
470
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
471
|
+
unknown,
|
|
472
|
+
TransportError
|
|
473
|
+
>,
|
|
474
|
+
}),
|
|
475
|
+
),
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
const exit = await Effect.runPromiseExit(program);
|
|
479
|
+
expect(exit._tag).toBe("Failure");
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
it("handles DNS resolution failure", async () => {
|
|
483
|
+
fetchMock.mockRejectedValueOnce(new Error("getaddrinfo ENOTFOUND"));
|
|
484
|
+
|
|
485
|
+
const program = Effect.gen(function* () {
|
|
486
|
+
const transport = yield* TransportService;
|
|
487
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
488
|
+
}).pipe(
|
|
489
|
+
Effect.provide(
|
|
490
|
+
createMockHttpTransport(fetchMock, {
|
|
491
|
+
url: "https://nonexistent.invalid",
|
|
492
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
493
|
+
unknown,
|
|
494
|
+
TransportError
|
|
495
|
+
>,
|
|
496
|
+
}),
|
|
497
|
+
),
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
const exit = await Effect.runPromiseExit(program);
|
|
501
|
+
expect(exit._tag).toBe("Failure");
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
it("handles connection refused", async () => {
|
|
505
|
+
fetchMock.mockRejectedValueOnce(new Error("ECONNREFUSED"));
|
|
506
|
+
|
|
507
|
+
const program = Effect.gen(function* () {
|
|
508
|
+
const transport = yield* TransportService;
|
|
509
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
510
|
+
}).pipe(
|
|
511
|
+
Effect.provide(
|
|
512
|
+
createMockHttpTransport(fetchMock, {
|
|
513
|
+
url: "https://eth.example.com",
|
|
514
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
515
|
+
unknown,
|
|
516
|
+
TransportError
|
|
517
|
+
>,
|
|
518
|
+
}),
|
|
519
|
+
),
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
const exit = await Effect.runPromiseExit(program);
|
|
523
|
+
expect(exit._tag).toBe("Failure");
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it("handles invalid JSON response", async () => {
|
|
527
|
+
fetchMock.mockResolvedValueOnce({
|
|
528
|
+
ok: true,
|
|
529
|
+
json: async () => {
|
|
530
|
+
throw new SyntaxError("Unexpected token");
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
const program = Effect.gen(function* () {
|
|
535
|
+
const transport = yield* TransportService;
|
|
536
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
537
|
+
}).pipe(
|
|
538
|
+
Effect.provide(
|
|
539
|
+
createMockHttpTransport(fetchMock, {
|
|
540
|
+
url: "https://eth.example.com",
|
|
541
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
542
|
+
unknown,
|
|
543
|
+
TransportError
|
|
544
|
+
>,
|
|
545
|
+
}),
|
|
546
|
+
),
|
|
547
|
+
);
|
|
548
|
+
|
|
549
|
+
const exit = await Effect.runPromiseExit(program);
|
|
550
|
+
expect(exit._tag).toBe("Failure");
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
it("handles request timeout", async () => {
|
|
554
|
+
fetchMock.mockImplementation(() => new Promise(() => {}));
|
|
555
|
+
|
|
556
|
+
const program = Effect.gen(function* () {
|
|
557
|
+
const transport = yield* TransportService;
|
|
558
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
559
|
+
}).pipe(
|
|
560
|
+
Effect.provide(
|
|
561
|
+
createMockHttpTransport(fetchMock, {
|
|
562
|
+
url: "https://eth.example.com",
|
|
563
|
+
timeout: 100,
|
|
564
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
565
|
+
unknown,
|
|
566
|
+
TransportError
|
|
567
|
+
>,
|
|
568
|
+
}),
|
|
569
|
+
),
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
const exit = await Effect.runPromiseExit(program);
|
|
573
|
+
expect(exit._tag).toBe("Failure");
|
|
574
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
575
|
+
expect(
|
|
576
|
+
(exit.cause.error as TransportError).message.toLowerCase(),
|
|
577
|
+
).toContain("timed out");
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
it("retries on failure before succeeding", async () => {
|
|
582
|
+
let callCount = 0;
|
|
583
|
+
fetchMock.mockImplementation(() => {
|
|
584
|
+
callCount++;
|
|
585
|
+
if (callCount < 2) {
|
|
586
|
+
return Promise.resolve({
|
|
587
|
+
ok: false,
|
|
588
|
+
status: 500,
|
|
589
|
+
statusText: "Internal Server Error",
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
return Promise.resolve({
|
|
593
|
+
ok: true,
|
|
594
|
+
json: async () => ({ jsonrpc: "2.0", id: 1, result: "0x1234" }),
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
const program = Effect.gen(function* () {
|
|
599
|
+
const transport = yield* TransportService;
|
|
600
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
601
|
+
}).pipe(
|
|
602
|
+
Effect.provide(
|
|
603
|
+
createMockHttpTransport(fetchMock, {
|
|
604
|
+
url: "https://eth.example.com",
|
|
605
|
+
retrySchedule: Schedule.spaced(Duration.millis(10)).pipe(
|
|
606
|
+
Schedule.intersect(Schedule.recurs(3)),
|
|
607
|
+
) as Schedule.Schedule<unknown, TransportError>,
|
|
608
|
+
}),
|
|
609
|
+
),
|
|
610
|
+
);
|
|
611
|
+
|
|
612
|
+
const result = await Effect.runPromise(program);
|
|
613
|
+
expect(result).toBe("0x1234");
|
|
614
|
+
expect(callCount).toBeGreaterThanOrEqual(2);
|
|
615
|
+
});
|
|
616
|
+
|
|
617
|
+
it("handles JSON-RPC method not found error", async () => {
|
|
618
|
+
fetchMock.mockResolvedValueOnce({
|
|
619
|
+
ok: true,
|
|
620
|
+
json: async () => ({
|
|
621
|
+
jsonrpc: "2.0",
|
|
622
|
+
id: 1,
|
|
623
|
+
error: { code: -32601, message: "Method not found" },
|
|
624
|
+
}),
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
const program = Effect.gen(function* () {
|
|
628
|
+
const transport = yield* TransportService;
|
|
629
|
+
return yield* transport.request<string>("eth_unknownMethod", []);
|
|
630
|
+
}).pipe(
|
|
631
|
+
Effect.provide(
|
|
632
|
+
createMockHttpTransport(fetchMock, {
|
|
633
|
+
url: "https://eth.example.com",
|
|
634
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
635
|
+
unknown,
|
|
636
|
+
TransportError
|
|
637
|
+
>,
|
|
638
|
+
}),
|
|
639
|
+
),
|
|
640
|
+
);
|
|
641
|
+
|
|
642
|
+
const exit = await Effect.runPromiseExit(program);
|
|
643
|
+
expect(exit._tag).toBe("Failure");
|
|
644
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
645
|
+
expect((exit.cause.error as TransportError).code).toBe(-32601);
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
it("handles JSON-RPC invalid params error", async () => {
|
|
650
|
+
fetchMock.mockResolvedValueOnce({
|
|
651
|
+
ok: true,
|
|
652
|
+
json: async () => ({
|
|
653
|
+
jsonrpc: "2.0",
|
|
654
|
+
id: 1,
|
|
655
|
+
error: { code: -32602, message: "Invalid params" },
|
|
656
|
+
}),
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
const program = Effect.gen(function* () {
|
|
660
|
+
const transport = yield* TransportService;
|
|
661
|
+
return yield* transport.request<string>("eth_getBalance", ["invalid"]);
|
|
662
|
+
}).pipe(
|
|
663
|
+
Effect.provide(
|
|
664
|
+
createMockHttpTransport(fetchMock, {
|
|
665
|
+
url: "https://eth.example.com",
|
|
666
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
667
|
+
unknown,
|
|
668
|
+
TransportError
|
|
669
|
+
>,
|
|
670
|
+
}),
|
|
671
|
+
),
|
|
672
|
+
);
|
|
673
|
+
|
|
674
|
+
const exit = await Effect.runPromiseExit(program);
|
|
675
|
+
expect(exit._tag).toBe("Failure");
|
|
676
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
677
|
+
expect((exit.cause.error as TransportError).code).toBe(-32602);
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
it("handles JSON-RPC parse error", async () => {
|
|
682
|
+
fetchMock.mockResolvedValueOnce({
|
|
683
|
+
ok: true,
|
|
684
|
+
json: async () => ({
|
|
685
|
+
jsonrpc: "2.0",
|
|
686
|
+
id: 1,
|
|
687
|
+
error: { code: -32700, message: "Parse error" },
|
|
688
|
+
}),
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
const program = Effect.gen(function* () {
|
|
692
|
+
const transport = yield* TransportService;
|
|
693
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
694
|
+
}).pipe(
|
|
695
|
+
Effect.provide(
|
|
696
|
+
createMockHttpTransport(fetchMock, {
|
|
697
|
+
url: "https://eth.example.com",
|
|
698
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
699
|
+
unknown,
|
|
700
|
+
TransportError
|
|
701
|
+
>,
|
|
702
|
+
}),
|
|
703
|
+
),
|
|
704
|
+
);
|
|
705
|
+
|
|
706
|
+
const exit = await Effect.runPromiseExit(program);
|
|
707
|
+
expect(exit._tag).toBe("Failure");
|
|
708
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
709
|
+
expect((exit.cause.error as TransportError).code).toBe(-32700);
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
|
|
713
|
+
it("handles JSON-RPC internal error with data", async () => {
|
|
714
|
+
const errorData = {
|
|
715
|
+
details: "execution reverted",
|
|
716
|
+
reason: "Ownable: caller is not the owner",
|
|
717
|
+
};
|
|
718
|
+
fetchMock.mockResolvedValueOnce({
|
|
719
|
+
ok: true,
|
|
720
|
+
json: async () => ({
|
|
721
|
+
jsonrpc: "2.0",
|
|
722
|
+
id: 1,
|
|
723
|
+
error: { code: -32603, message: "Internal error", data: errorData },
|
|
724
|
+
}),
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
const program = Effect.gen(function* () {
|
|
728
|
+
const transport = yield* TransportService;
|
|
729
|
+
return yield* transport.request<string>("eth_call", []);
|
|
730
|
+
}).pipe(
|
|
731
|
+
Effect.provide(
|
|
732
|
+
createMockHttpTransport(fetchMock, {
|
|
733
|
+
url: "https://eth.example.com",
|
|
734
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
735
|
+
unknown,
|
|
736
|
+
TransportError
|
|
737
|
+
>,
|
|
738
|
+
}),
|
|
739
|
+
),
|
|
740
|
+
);
|
|
741
|
+
|
|
742
|
+
const exit = await Effect.runPromiseExit(program);
|
|
743
|
+
expect(exit._tag).toBe("Failure");
|
|
744
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
745
|
+
const error = exit.cause.error as TransportError;
|
|
746
|
+
expect(error.code).toBe(-32603);
|
|
747
|
+
expect(error.data).toEqual(errorData);
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
describe("batching", () => {
|
|
752
|
+
it.effect("batches requests that arrive within wait window", () =>
|
|
753
|
+
Effect.gen(function* () {
|
|
754
|
+
fetchMock.mockImplementation(
|
|
755
|
+
(request: HttpClientRequest.HttpClientRequest) => {
|
|
756
|
+
const batch = parseBatchRequests(request);
|
|
757
|
+
const responses = batch.map((item) => ({
|
|
758
|
+
jsonrpc: "2.0",
|
|
759
|
+
id: item.id,
|
|
760
|
+
result: item.method === "eth_blockNumber" ? "0x100" : "0x1",
|
|
761
|
+
}));
|
|
762
|
+
return Promise.resolve({
|
|
763
|
+
ok: true,
|
|
764
|
+
json: async () => responses,
|
|
765
|
+
});
|
|
766
|
+
},
|
|
767
|
+
);
|
|
768
|
+
|
|
769
|
+
const program = Effect.gen(function* () {
|
|
770
|
+
const transport = yield* TransportService;
|
|
771
|
+
const fiber1 = yield* Effect.fork(
|
|
772
|
+
transport.request<string>("eth_blockNumber", []),
|
|
773
|
+
);
|
|
774
|
+
const fiber2 = yield* Effect.fork(
|
|
775
|
+
transport.request<string>("eth_chainId", []),
|
|
776
|
+
);
|
|
777
|
+
yield* Effect.yieldNow();
|
|
778
|
+
yield* Effect.yieldNow();
|
|
779
|
+
yield* TestClock.adjust(Duration.millis(50));
|
|
780
|
+
const r1 = yield* Fiber.join(fiber1);
|
|
781
|
+
const r2 = yield* Fiber.join(fiber2);
|
|
782
|
+
return [r1, r2] as const;
|
|
783
|
+
}).pipe(
|
|
784
|
+
Effect.scoped,
|
|
785
|
+
Effect.provide(
|
|
786
|
+
createMockHttpTransport(fetchMock, {
|
|
787
|
+
url: "https://eth.example.com",
|
|
788
|
+
batch: { batchSize: 100, wait: 50 },
|
|
789
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
790
|
+
unknown,
|
|
791
|
+
TransportError
|
|
792
|
+
>,
|
|
793
|
+
}),
|
|
794
|
+
),
|
|
795
|
+
);
|
|
796
|
+
|
|
797
|
+
const results = yield* program;
|
|
798
|
+
expect(results[0]).toBe("0x100");
|
|
799
|
+
expect(results[1]).toBe("0x1");
|
|
800
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
801
|
+
}),
|
|
802
|
+
);
|
|
803
|
+
|
|
804
|
+
it.effect("handles individual request errors in batch", () =>
|
|
805
|
+
Effect.gen(function* () {
|
|
806
|
+
fetchMock.mockImplementation(
|
|
807
|
+
(request: HttpClientRequest.HttpClientRequest) => {
|
|
808
|
+
const batch = parseBatchRequests(request);
|
|
809
|
+
const responses = batch.map((item) =>
|
|
810
|
+
item.method === "eth_call"
|
|
811
|
+
? {
|
|
812
|
+
jsonrpc: "2.0",
|
|
813
|
+
id: item.id,
|
|
814
|
+
error: { code: -32000, message: "execution reverted" },
|
|
815
|
+
}
|
|
816
|
+
: { jsonrpc: "2.0", id: item.id, result: "0x100" },
|
|
817
|
+
);
|
|
818
|
+
return Promise.resolve({
|
|
819
|
+
ok: true,
|
|
820
|
+
json: async () => responses,
|
|
821
|
+
});
|
|
822
|
+
},
|
|
823
|
+
);
|
|
824
|
+
|
|
825
|
+
const program = Effect.gen(function* () {
|
|
826
|
+
const transport = yield* TransportService;
|
|
827
|
+
const fiber = yield* Effect.fork(
|
|
828
|
+
Effect.all(
|
|
829
|
+
[
|
|
830
|
+
transport.request<string>("eth_blockNumber", []),
|
|
831
|
+
transport.request<string>("eth_call", []),
|
|
832
|
+
],
|
|
833
|
+
{ concurrency: "unbounded", mode: "either" },
|
|
834
|
+
),
|
|
835
|
+
);
|
|
836
|
+
yield* Effect.yieldNow();
|
|
837
|
+
yield* Effect.yieldNow();
|
|
838
|
+
yield* TestClock.adjust(Duration.millis(10));
|
|
839
|
+
return yield* Fiber.join(fiber);
|
|
840
|
+
}).pipe(
|
|
841
|
+
Effect.provide(
|
|
842
|
+
createMockHttpTransport(fetchMock, {
|
|
843
|
+
url: "https://eth.example.com",
|
|
844
|
+
batch: { batchSize: 100, wait: 10 },
|
|
845
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
846
|
+
unknown,
|
|
847
|
+
TransportError
|
|
848
|
+
>,
|
|
849
|
+
}),
|
|
850
|
+
),
|
|
851
|
+
Effect.scoped,
|
|
852
|
+
);
|
|
853
|
+
|
|
854
|
+
const results = yield* program;
|
|
855
|
+
expect(results[0]._tag).toBe("Right");
|
|
856
|
+
expect(results[1]._tag).toBe("Left");
|
|
857
|
+
}),
|
|
858
|
+
);
|
|
859
|
+
|
|
860
|
+
it.effect("flushes batch on size limit", () =>
|
|
861
|
+
Effect.gen(function* () {
|
|
862
|
+
let _callCount = 0;
|
|
863
|
+
fetchMock.mockImplementation(
|
|
864
|
+
(request: HttpClientRequest.HttpClientRequest) => {
|
|
865
|
+
_callCount++;
|
|
866
|
+
const batch = parseBatchRequests(request);
|
|
867
|
+
const responses = batch.map((item) => {
|
|
868
|
+
switch (item.method) {
|
|
869
|
+
case "eth_blockNumber":
|
|
870
|
+
return { jsonrpc: "2.0", id: item.id, result: "0x1" };
|
|
871
|
+
case "eth_chainId":
|
|
872
|
+
return { jsonrpc: "2.0", id: item.id, result: "0x2" };
|
|
873
|
+
case "eth_gasPrice":
|
|
874
|
+
return { jsonrpc: "2.0", id: item.id, result: "0x3" };
|
|
875
|
+
default:
|
|
876
|
+
return { jsonrpc: "2.0", id: item.id, result: "0x0" };
|
|
877
|
+
}
|
|
878
|
+
});
|
|
879
|
+
return Promise.resolve({
|
|
880
|
+
ok: true,
|
|
881
|
+
json: async () => responses,
|
|
882
|
+
});
|
|
883
|
+
},
|
|
884
|
+
);
|
|
885
|
+
|
|
886
|
+
const program = Effect.gen(function* () {
|
|
887
|
+
const transport = yield* TransportService;
|
|
888
|
+
return yield* Effect.all(
|
|
889
|
+
[
|
|
890
|
+
transport.request<string>("eth_blockNumber", []),
|
|
891
|
+
transport.request<string>("eth_chainId", []),
|
|
892
|
+
transport.request<string>("eth_gasPrice", []),
|
|
893
|
+
],
|
|
894
|
+
{ concurrency: "unbounded" },
|
|
895
|
+
);
|
|
896
|
+
}).pipe(
|
|
897
|
+
Effect.scoped,
|
|
898
|
+
Effect.provide(
|
|
899
|
+
createMockHttpTransport(fetchMock, {
|
|
900
|
+
url: "https://eth.example.com",
|
|
901
|
+
batch: { batchSize: 2, wait: 50 },
|
|
902
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
903
|
+
unknown,
|
|
904
|
+
TransportError
|
|
905
|
+
>,
|
|
906
|
+
}),
|
|
907
|
+
),
|
|
908
|
+
);
|
|
909
|
+
|
|
910
|
+
const results = yield* program;
|
|
911
|
+
expect(results).toEqual(["0x1", "0x2", "0x3"]);
|
|
912
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
913
|
+
}),
|
|
914
|
+
);
|
|
915
|
+
|
|
916
|
+
it.effect("fails all requests on HTTP error", () =>
|
|
917
|
+
Effect.gen(function* () {
|
|
918
|
+
fetchMock.mockImplementation(() =>
|
|
919
|
+
Promise.resolve({
|
|
920
|
+
ok: false,
|
|
921
|
+
status: 500,
|
|
922
|
+
statusText: "Internal Server Error",
|
|
923
|
+
}),
|
|
924
|
+
);
|
|
925
|
+
|
|
926
|
+
const program = Effect.gen(function* () {
|
|
927
|
+
const transport = yield* TransportService;
|
|
928
|
+
const fiber = yield* Effect.fork(
|
|
929
|
+
Effect.all(
|
|
930
|
+
[
|
|
931
|
+
transport.request<string>("eth_blockNumber", []),
|
|
932
|
+
transport.request<string>("eth_chainId", []),
|
|
933
|
+
],
|
|
934
|
+
{ concurrency: "unbounded", mode: "either" },
|
|
935
|
+
),
|
|
936
|
+
);
|
|
937
|
+
yield* Effect.yieldNow();
|
|
938
|
+
yield* Effect.yieldNow();
|
|
939
|
+
yield* TestClock.adjust(Duration.millis(10));
|
|
940
|
+
return yield* Fiber.join(fiber);
|
|
941
|
+
}).pipe(
|
|
942
|
+
Effect.provide(
|
|
943
|
+
createMockHttpTransport(fetchMock, {
|
|
944
|
+
url: "https://eth.example.com",
|
|
945
|
+
batch: { batchSize: 100, wait: 10 },
|
|
946
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
947
|
+
unknown,
|
|
948
|
+
TransportError
|
|
949
|
+
>,
|
|
950
|
+
}),
|
|
951
|
+
),
|
|
952
|
+
Effect.scoped,
|
|
953
|
+
);
|
|
954
|
+
|
|
955
|
+
const results = yield* program;
|
|
956
|
+
expect(results[0]._tag).toBe("Left");
|
|
957
|
+
expect(results[1]._tag).toBe("Left");
|
|
958
|
+
}),
|
|
959
|
+
);
|
|
960
|
+
|
|
961
|
+
it.effect("fails missing batch response with useful error", () =>
|
|
962
|
+
Effect.gen(function* () {
|
|
963
|
+
fetchMock.mockImplementation(
|
|
964
|
+
(request: HttpClientRequest.HttpClientRequest) => {
|
|
965
|
+
const batch = parseBatchRequests(request);
|
|
966
|
+
const first = batch[0];
|
|
967
|
+
return Promise.resolve({
|
|
968
|
+
ok: true,
|
|
969
|
+
json: async () =>
|
|
970
|
+
first
|
|
971
|
+
? [{ jsonrpc: "2.0", id: first.id, result: "0x100" }]
|
|
972
|
+
: [],
|
|
973
|
+
});
|
|
974
|
+
},
|
|
975
|
+
);
|
|
976
|
+
|
|
977
|
+
const program = Effect.gen(function* () {
|
|
978
|
+
const transport = yield* TransportService;
|
|
979
|
+
const fiber = yield* Effect.fork(
|
|
980
|
+
Effect.all(
|
|
981
|
+
[
|
|
982
|
+
transport.request<string>("eth_blockNumber", []),
|
|
983
|
+
transport.request<string>("eth_chainId", []),
|
|
984
|
+
],
|
|
985
|
+
{ concurrency: "unbounded", mode: "either" },
|
|
986
|
+
),
|
|
987
|
+
);
|
|
988
|
+
yield* Effect.yieldNow();
|
|
989
|
+
yield* Effect.yieldNow();
|
|
990
|
+
yield* TestClock.adjust(Duration.millis(10));
|
|
991
|
+
return yield* Fiber.join(fiber);
|
|
992
|
+
}).pipe(
|
|
993
|
+
Effect.provide(
|
|
994
|
+
createMockHttpTransport(fetchMock, {
|
|
995
|
+
url: "https://eth.example.com",
|
|
996
|
+
batch: { batchSize: 100, wait: 10 },
|
|
997
|
+
retrySchedule: Schedule.recurs(0) as Schedule.Schedule<
|
|
998
|
+
unknown,
|
|
999
|
+
TransportError
|
|
1000
|
+
>,
|
|
1001
|
+
}),
|
|
1002
|
+
),
|
|
1003
|
+
Effect.scoped,
|
|
1004
|
+
);
|
|
1005
|
+
|
|
1006
|
+
const results = yield* program;
|
|
1007
|
+
expect(results[0]._tag).toBe("Right");
|
|
1008
|
+
expect(results[1]._tag).toBe("Left");
|
|
1009
|
+
if (results[1]._tag === "Left") {
|
|
1010
|
+
expect(results[1].left.message).toContain(
|
|
1011
|
+
"Missing JSON-RPC response",
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
}),
|
|
1015
|
+
);
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
describe("BrowserTransport", () => {
|
|
1020
|
+
const originalWindow = globalThis.window;
|
|
1021
|
+
|
|
1022
|
+
afterEach(() => {
|
|
1023
|
+
(globalThis as unknown as { window: typeof window }).window =
|
|
1024
|
+
originalWindow;
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
it("fails when no browser wallet", async () => {
|
|
1028
|
+
(globalThis as unknown as { window: undefined }).window = undefined;
|
|
1029
|
+
|
|
1030
|
+
const program = Effect.gen(function* () {
|
|
1031
|
+
const transport = yield* TransportService;
|
|
1032
|
+
return yield* transport.request<string>("eth_accounts", []);
|
|
1033
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1034
|
+
|
|
1035
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1036
|
+
expect(exit._tag).toBe("Failure");
|
|
1037
|
+
});
|
|
1038
|
+
|
|
1039
|
+
it("calls window.ethereum.request", async () => {
|
|
1040
|
+
const mockRequest = vi
|
|
1041
|
+
.fn()
|
|
1042
|
+
.mockResolvedValue(["0x1234567890123456789012345678901234567890"]);
|
|
1043
|
+
(
|
|
1044
|
+
globalThis as unknown as {
|
|
1045
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1046
|
+
}
|
|
1047
|
+
).window = {
|
|
1048
|
+
ethereum: { request: mockRequest },
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
const program = Effect.gen(function* () {
|
|
1052
|
+
const transport = yield* TransportService;
|
|
1053
|
+
return yield* transport.request<string[]>("eth_accounts", []);
|
|
1054
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1055
|
+
|
|
1056
|
+
const result = await Effect.runPromise(program);
|
|
1057
|
+
expect(result).toEqual(["0x1234567890123456789012345678901234567890"]);
|
|
1058
|
+
expect(mockRequest).toHaveBeenCalledWith({
|
|
1059
|
+
method: "eth_accounts",
|
|
1060
|
+
params: [],
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
it("handles user rejection error (4001)", async () => {
|
|
1065
|
+
const mockRequest = vi.fn().mockRejectedValue({
|
|
1066
|
+
code: 4001,
|
|
1067
|
+
message: "User rejected the request.",
|
|
1068
|
+
});
|
|
1069
|
+
(
|
|
1070
|
+
globalThis as unknown as {
|
|
1071
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1072
|
+
}
|
|
1073
|
+
).window = {
|
|
1074
|
+
ethereum: { request: mockRequest },
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
const program = Effect.gen(function* () {
|
|
1078
|
+
const transport = yield* TransportService;
|
|
1079
|
+
return yield* transport.request<string[]>("eth_requestAccounts", []);
|
|
1080
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1081
|
+
|
|
1082
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1083
|
+
expect(exit._tag).toBe("Failure");
|
|
1084
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
1085
|
+
expect((exit.cause.error as TransportError).code).toBe(4001);
|
|
1086
|
+
}
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
it("handles unauthorized error (4100)", async () => {
|
|
1090
|
+
const mockRequest = vi.fn().mockRejectedValue({
|
|
1091
|
+
code: 4100,
|
|
1092
|
+
message: "The requested method and/or account has not been authorized.",
|
|
1093
|
+
});
|
|
1094
|
+
(
|
|
1095
|
+
globalThis as unknown as {
|
|
1096
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1097
|
+
}
|
|
1098
|
+
).window = {
|
|
1099
|
+
ethereum: { request: mockRequest },
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
const program = Effect.gen(function* () {
|
|
1103
|
+
const transport = yield* TransportService;
|
|
1104
|
+
return yield* transport.request<string>("eth_sendTransaction", []);
|
|
1105
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1106
|
+
|
|
1107
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1108
|
+
expect(exit._tag).toBe("Failure");
|
|
1109
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
1110
|
+
expect((exit.cause.error as TransportError).code).toBe(4100);
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
|
|
1114
|
+
it("handles unsupported method error (4200)", async () => {
|
|
1115
|
+
const mockRequest = vi.fn().mockRejectedValue({
|
|
1116
|
+
code: 4200,
|
|
1117
|
+
message: "The Provider does not support the requested method.",
|
|
1118
|
+
});
|
|
1119
|
+
(
|
|
1120
|
+
globalThis as unknown as {
|
|
1121
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1122
|
+
}
|
|
1123
|
+
).window = {
|
|
1124
|
+
ethereum: { request: mockRequest },
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
const program = Effect.gen(function* () {
|
|
1128
|
+
const transport = yield* TransportService;
|
|
1129
|
+
return yield* transport.request<string>("eth_unsupported", []);
|
|
1130
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1131
|
+
|
|
1132
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1133
|
+
expect(exit._tag).toBe("Failure");
|
|
1134
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
1135
|
+
expect((exit.cause.error as TransportError).code).toBe(4200);
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
|
|
1139
|
+
it("handles chain mismatch error (4901)", async () => {
|
|
1140
|
+
const mockRequest = vi.fn().mockRejectedValue({
|
|
1141
|
+
code: 4901,
|
|
1142
|
+
message: "The Provider is not connected to the requested chain.",
|
|
1143
|
+
});
|
|
1144
|
+
(
|
|
1145
|
+
globalThis as unknown as {
|
|
1146
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1147
|
+
}
|
|
1148
|
+
).window = {
|
|
1149
|
+
ethereum: { request: mockRequest },
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
const program = Effect.gen(function* () {
|
|
1153
|
+
const transport = yield* TransportService;
|
|
1154
|
+
return yield* transport.request<string>("eth_chainId", []);
|
|
1155
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1156
|
+
|
|
1157
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1158
|
+
expect(exit._tag).toBe("Failure");
|
|
1159
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
1160
|
+
expect((exit.cause.error as TransportError).code).toBe(4901);
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
|
|
1164
|
+
it("handles unknown errors gracefully", async () => {
|
|
1165
|
+
const mockRequest = vi.fn().mockRejectedValue(new Error("Unknown error"));
|
|
1166
|
+
(
|
|
1167
|
+
globalThis as unknown as {
|
|
1168
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1169
|
+
}
|
|
1170
|
+
).window = {
|
|
1171
|
+
ethereum: { request: mockRequest },
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
const program = Effect.gen(function* () {
|
|
1175
|
+
const transport = yield* TransportService;
|
|
1176
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1177
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1178
|
+
|
|
1179
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1180
|
+
expect(exit._tag).toBe("Failure");
|
|
1181
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
1182
|
+
expect((exit.cause.error as TransportError).message).toContain(
|
|
1183
|
+
"Unknown error",
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
|
|
1188
|
+
it("handles error with data field", async () => {
|
|
1189
|
+
const errorData = "0x08c379a0...";
|
|
1190
|
+
const mockRequest = vi.fn().mockRejectedValue({
|
|
1191
|
+
code: -32000,
|
|
1192
|
+
message: "execution reverted",
|
|
1193
|
+
data: errorData,
|
|
1194
|
+
});
|
|
1195
|
+
(
|
|
1196
|
+
globalThis as unknown as {
|
|
1197
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1198
|
+
}
|
|
1199
|
+
).window = {
|
|
1200
|
+
ethereum: { request: mockRequest },
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
const program = Effect.gen(function* () {
|
|
1204
|
+
const transport = yield* TransportService;
|
|
1205
|
+
return yield* transport.request<string>("eth_call", []);
|
|
1206
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1207
|
+
|
|
1208
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1209
|
+
expect(exit._tag).toBe("Failure");
|
|
1210
|
+
if (exit._tag === "Failure" && exit.cause._tag === "Fail") {
|
|
1211
|
+
const error = exit.cause.error as TransportError;
|
|
1212
|
+
expect(error.data).toBe(errorData);
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
it("passes method params correctly", async () => {
|
|
1217
|
+
const mockRequest = vi.fn().mockResolvedValue("0xde0b6b3a7640000");
|
|
1218
|
+
(
|
|
1219
|
+
globalThis as unknown as {
|
|
1220
|
+
window: { ethereum: { request: typeof mockRequest } };
|
|
1221
|
+
}
|
|
1222
|
+
).window = {
|
|
1223
|
+
ethereum: { request: mockRequest },
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
const program = Effect.gen(function* () {
|
|
1227
|
+
const transport = yield* TransportService;
|
|
1228
|
+
return yield* transport.request<string>("eth_getBalance", [
|
|
1229
|
+
"0x1234567890123456789012345678901234567890",
|
|
1230
|
+
"latest",
|
|
1231
|
+
]);
|
|
1232
|
+
}).pipe(Effect.provide(BrowserTransport));
|
|
1233
|
+
|
|
1234
|
+
await Effect.runPromise(program);
|
|
1235
|
+
expect(mockRequest).toHaveBeenCalledWith({
|
|
1236
|
+
method: "eth_getBalance",
|
|
1237
|
+
params: ["0x1234567890123456789012345678901234567890", "latest"],
|
|
1238
|
+
});
|
|
1239
|
+
});
|
|
1240
|
+
});
|
|
1241
|
+
|
|
1242
|
+
describe("FallbackTransport", () => {
|
|
1243
|
+
it("uses first transport when available", async () => {
|
|
1244
|
+
const program = Effect.gen(function* () {
|
|
1245
|
+
const transport = yield* TransportService;
|
|
1246
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1247
|
+
}).pipe(
|
|
1248
|
+
Effect.provide(
|
|
1249
|
+
FallbackTransport([
|
|
1250
|
+
TestTransport({ eth_blockNumber: "0x1" }),
|
|
1251
|
+
TestTransport({ eth_blockNumber: "0x2" }),
|
|
1252
|
+
]),
|
|
1253
|
+
),
|
|
1254
|
+
);
|
|
1255
|
+
|
|
1256
|
+
const result = await Effect.runPromise(program);
|
|
1257
|
+
expect(result).toBe("0x1");
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
it("fails over to next transport on error", async () => {
|
|
1261
|
+
const failingTransport = TestTransport(
|
|
1262
|
+
new Map([
|
|
1263
|
+
[
|
|
1264
|
+
"eth_blockNumber",
|
|
1265
|
+
new TransportError({ code: -32603, message: "Primary failed" }),
|
|
1266
|
+
],
|
|
1267
|
+
]),
|
|
1268
|
+
);
|
|
1269
|
+
|
|
1270
|
+
const program = Effect.gen(function* () {
|
|
1271
|
+
const transport = yield* TransportService;
|
|
1272
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1273
|
+
}).pipe(
|
|
1274
|
+
Effect.provide(
|
|
1275
|
+
FallbackTransport(
|
|
1276
|
+
[failingTransport, TestTransport({ eth_blockNumber: "0xBackup" })],
|
|
1277
|
+
{ retryCount: 1 },
|
|
1278
|
+
),
|
|
1279
|
+
),
|
|
1280
|
+
);
|
|
1281
|
+
|
|
1282
|
+
const result = await Effect.runPromise(program);
|
|
1283
|
+
expect(result).toBe("0xBackup");
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1286
|
+
it("fails when all transports fail", async () => {
|
|
1287
|
+
const error = new TransportError({ code: -32603, message: "Failed" });
|
|
1288
|
+
const program = Effect.gen(function* () {
|
|
1289
|
+
const transport = yield* TransportService;
|
|
1290
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1291
|
+
}).pipe(
|
|
1292
|
+
Effect.provide(
|
|
1293
|
+
FallbackTransport(
|
|
1294
|
+
[
|
|
1295
|
+
TestTransport(new Map([["eth_blockNumber", error]])),
|
|
1296
|
+
TestTransport(new Map([["eth_blockNumber", error]])),
|
|
1297
|
+
],
|
|
1298
|
+
{ retryCount: 1 },
|
|
1299
|
+
),
|
|
1300
|
+
),
|
|
1301
|
+
);
|
|
1302
|
+
|
|
1303
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1304
|
+
expect(exit._tag).toBe("Failure");
|
|
1305
|
+
});
|
|
1306
|
+
|
|
1307
|
+
it("recovers failed transports after reset", async () => {
|
|
1308
|
+
const error = new TransportError({
|
|
1309
|
+
code: -32603,
|
|
1310
|
+
message: "Primary failed",
|
|
1311
|
+
});
|
|
1312
|
+
const failingTransport = TestTransport(
|
|
1313
|
+
new Map([["eth_blockNumber", error]]),
|
|
1314
|
+
);
|
|
1315
|
+
const backupTransport = TestTransport({ eth_blockNumber: "0xBackup" });
|
|
1316
|
+
|
|
1317
|
+
const fallback = FallbackTransport([failingTransport, backupTransport], {
|
|
1318
|
+
retryCount: 1,
|
|
1319
|
+
});
|
|
1320
|
+
|
|
1321
|
+
const program = Effect.gen(function* () {
|
|
1322
|
+
const transport = yield* TransportService;
|
|
1323
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1324
|
+
}).pipe(Effect.provide(fallback));
|
|
1325
|
+
|
|
1326
|
+
const result = await Effect.runPromise(program);
|
|
1327
|
+
expect(result).toBe("0xBackup");
|
|
1328
|
+
});
|
|
1329
|
+
|
|
1330
|
+
it("supports latency-based ranking", async () => {
|
|
1331
|
+
const program = Effect.gen(function* () {
|
|
1332
|
+
const transport = yield* TransportService;
|
|
1333
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1334
|
+
}).pipe(
|
|
1335
|
+
Effect.provide(
|
|
1336
|
+
FallbackTransport(
|
|
1337
|
+
[
|
|
1338
|
+
TestTransport({ eth_blockNumber: "0x1" }),
|
|
1339
|
+
TestTransport({ eth_blockNumber: "0x2" }),
|
|
1340
|
+
],
|
|
1341
|
+
{ rank: true },
|
|
1342
|
+
),
|
|
1343
|
+
),
|
|
1344
|
+
);
|
|
1345
|
+
|
|
1346
|
+
const result = await Effect.runPromise(program);
|
|
1347
|
+
expect(result).toBe("0x1");
|
|
1348
|
+
});
|
|
1349
|
+
|
|
1350
|
+
it("fails when no transports provided", async () => {
|
|
1351
|
+
const program = Effect.gen(function* () {
|
|
1352
|
+
const transport = yield* TransportService;
|
|
1353
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1354
|
+
}).pipe(Effect.provide(FallbackTransport([])));
|
|
1355
|
+
|
|
1356
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1357
|
+
expect(exit._tag).toBe("Failure");
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
it("respects retryCount option", async () => {
|
|
1361
|
+
const _callCount = 0;
|
|
1362
|
+
const failingTransport = TestTransport(
|
|
1363
|
+
new Map([
|
|
1364
|
+
[
|
|
1365
|
+
"eth_blockNumber",
|
|
1366
|
+
new TransportError({ code: -32603, message: "Always fails" }),
|
|
1367
|
+
],
|
|
1368
|
+
]),
|
|
1369
|
+
);
|
|
1370
|
+
|
|
1371
|
+
const program = Effect.gen(function* () {
|
|
1372
|
+
const transport = yield* TransportService;
|
|
1373
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1374
|
+
}).pipe(
|
|
1375
|
+
Effect.provide(
|
|
1376
|
+
FallbackTransport(
|
|
1377
|
+
[failingTransport, TestTransport({ eth_blockNumber: "0xBackup" })],
|
|
1378
|
+
{ retryCount: 2, retryDelay: 10 },
|
|
1379
|
+
),
|
|
1380
|
+
),
|
|
1381
|
+
);
|
|
1382
|
+
|
|
1383
|
+
const result = await Effect.runPromise(program);
|
|
1384
|
+
expect(result).toBe("0xBackup");
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1387
|
+
it("handles mixed success and failure across transports", async () => {
|
|
1388
|
+
const error = new TransportError({ code: -32603, message: "Failed" });
|
|
1389
|
+
const program = Effect.gen(function* () {
|
|
1390
|
+
const transport = yield* TransportService;
|
|
1391
|
+
const blockNum = yield* transport.request<string>(
|
|
1392
|
+
"eth_blockNumber",
|
|
1393
|
+
[],
|
|
1394
|
+
);
|
|
1395
|
+
const chainId = yield* transport.request<string>("eth_chainId", []);
|
|
1396
|
+
return { blockNum, chainId };
|
|
1397
|
+
}).pipe(
|
|
1398
|
+
Effect.provide(
|
|
1399
|
+
FallbackTransport(
|
|
1400
|
+
[
|
|
1401
|
+
TestTransport(
|
|
1402
|
+
new Map<string, string | TransportError>([
|
|
1403
|
+
["eth_blockNumber", error],
|
|
1404
|
+
["eth_chainId", "0x1"],
|
|
1405
|
+
]),
|
|
1406
|
+
),
|
|
1407
|
+
TestTransport({ eth_blockNumber: "0x100", eth_chainId: "0x5" }),
|
|
1408
|
+
],
|
|
1409
|
+
{ retryCount: 1 },
|
|
1410
|
+
),
|
|
1411
|
+
),
|
|
1412
|
+
);
|
|
1413
|
+
|
|
1414
|
+
const result = await Effect.runPromise(program);
|
|
1415
|
+
expect(result.blockNum).toBe("0x100");
|
|
1416
|
+
expect(result.chainId).toBe("0x1");
|
|
1417
|
+
});
|
|
1418
|
+
|
|
1419
|
+
it("resets failures when all transports fail and retries", async () => {
|
|
1420
|
+
const error = new TransportError({
|
|
1421
|
+
code: -32603,
|
|
1422
|
+
message: "Temporary failure",
|
|
1423
|
+
});
|
|
1424
|
+
const _failCount = 0;
|
|
1425
|
+
|
|
1426
|
+
const fallback = FallbackTransport(
|
|
1427
|
+
[TestTransport(new Map([["eth_blockNumber", error]]))],
|
|
1428
|
+
{ retryCount: 1, retryDelay: 10 },
|
|
1429
|
+
);
|
|
1430
|
+
|
|
1431
|
+
const program = Effect.gen(function* () {
|
|
1432
|
+
const transport = yield* TransportService;
|
|
1433
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1434
|
+
}).pipe(Effect.provide(fallback));
|
|
1435
|
+
|
|
1436
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1437
|
+
expect(exit._tag).toBe("Failure");
|
|
1438
|
+
});
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
describe("WebSocketTransport", () => {
|
|
1442
|
+
const originalWebSocket = globalThis.WebSocket;
|
|
1443
|
+
|
|
1444
|
+
afterEach(() => {
|
|
1445
|
+
globalThis.WebSocket = originalWebSocket;
|
|
1446
|
+
});
|
|
1447
|
+
|
|
1448
|
+
it("handles concurrent requests correctly", async () => {
|
|
1449
|
+
const pendingMessages: Array<{
|
|
1450
|
+
id: number;
|
|
1451
|
+
resolve: (data: string) => void;
|
|
1452
|
+
}> = [];
|
|
1453
|
+
const { MockWebSocket } = makeMockWebSocket({
|
|
1454
|
+
onSend: (socket, data) => {
|
|
1455
|
+
const parsed = JSON.parse(String(data));
|
|
1456
|
+
pendingMessages.push({
|
|
1457
|
+
id: parsed.id,
|
|
1458
|
+
resolve: (result: string) => {
|
|
1459
|
+
socket.emitMessage(
|
|
1460
|
+
JSON.stringify({
|
|
1461
|
+
jsonrpc: "2.0",
|
|
1462
|
+
id: parsed.id,
|
|
1463
|
+
result,
|
|
1464
|
+
}),
|
|
1465
|
+
);
|
|
1466
|
+
},
|
|
1467
|
+
});
|
|
1468
|
+
},
|
|
1469
|
+
});
|
|
1470
|
+
globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
|
|
1471
|
+
|
|
1472
|
+
const program = Effect.gen(function* () {
|
|
1473
|
+
const transport = yield* TransportService;
|
|
1474
|
+
|
|
1475
|
+
const fibers = yield* Effect.all(
|
|
1476
|
+
Array.from({ length: 100 }, () =>
|
|
1477
|
+
Effect.fork(transport.request<string>("eth_blockNumber", [])),
|
|
1478
|
+
),
|
|
1479
|
+
);
|
|
1480
|
+
|
|
1481
|
+
yield* Effect.sleep(20);
|
|
1482
|
+
|
|
1483
|
+
for (const msg of pendingMessages) {
|
|
1484
|
+
msg.resolve(`0x${msg.id.toString(16)}`);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
const results = yield* Effect.all(fibers.map((f) => Fiber.join(f)));
|
|
1488
|
+
return results;
|
|
1489
|
+
}).pipe(
|
|
1490
|
+
Effect.provide(
|
|
1491
|
+
Layer.provide(
|
|
1492
|
+
WebSocketTransport("ws://localhost:8545"),
|
|
1493
|
+
WebSocketConstructorGlobal,
|
|
1494
|
+
),
|
|
1495
|
+
),
|
|
1496
|
+
Effect.scoped,
|
|
1497
|
+
);
|
|
1498
|
+
|
|
1499
|
+
const results = await Effect.runPromise(program);
|
|
1500
|
+
expect(results).toHaveLength(100);
|
|
1501
|
+
|
|
1502
|
+
const uniqueResults = new Set(results);
|
|
1503
|
+
expect(uniqueResults.size).toBe(100);
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
it("reconnects after disconnect", async () => {
|
|
1507
|
+
const { MockWebSocket, sockets } = makeMockWebSocket({
|
|
1508
|
+
onSend: (socket, data) => {
|
|
1509
|
+
const parsed = JSON.parse(String(data));
|
|
1510
|
+
if (parsed.method === "web3_clientVersion") return;
|
|
1511
|
+
queueMicrotask(() => {
|
|
1512
|
+
socket.emitMessage(
|
|
1513
|
+
JSON.stringify({
|
|
1514
|
+
jsonrpc: "2.0",
|
|
1515
|
+
id: parsed.id,
|
|
1516
|
+
result: `0x${socket.index + 1}`,
|
|
1517
|
+
}),
|
|
1518
|
+
);
|
|
1519
|
+
});
|
|
1520
|
+
},
|
|
1521
|
+
});
|
|
1522
|
+
globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
|
|
1523
|
+
|
|
1524
|
+
const program = Effect.gen(function* () {
|
|
1525
|
+
const transport = yield* TransportService;
|
|
1526
|
+
|
|
1527
|
+
const result1 = yield* transport.request<string>("eth_blockNumber", []);
|
|
1528
|
+
expect(result1).toBe("0x1");
|
|
1529
|
+
|
|
1530
|
+
sockets[0]?.close();
|
|
1531
|
+
|
|
1532
|
+
yield* Effect.sleep(50);
|
|
1533
|
+
|
|
1534
|
+
const result2 = yield* transport.request<string>("eth_blockNumber", []);
|
|
1535
|
+
expect(result2).toBe("0x2");
|
|
1536
|
+
|
|
1537
|
+
return { result1, result2, connectionCount: sockets.length };
|
|
1538
|
+
}).pipe(
|
|
1539
|
+
Effect.provide(
|
|
1540
|
+
Layer.provide(
|
|
1541
|
+
WebSocketTransport({
|
|
1542
|
+
url: "ws://localhost:8545",
|
|
1543
|
+
reconnect: { delay: 10, maxAttempts: 3 },
|
|
1544
|
+
}),
|
|
1545
|
+
WebSocketConstructorGlobal,
|
|
1546
|
+
),
|
|
1547
|
+
),
|
|
1548
|
+
Effect.scoped,
|
|
1549
|
+
);
|
|
1550
|
+
|
|
1551
|
+
const result = await Effect.runPromise(program);
|
|
1552
|
+
expect(result.connectionCount).toBe(2);
|
|
1553
|
+
});
|
|
1554
|
+
|
|
1555
|
+
it("uses exponential backoff for reconnection", async () => {
|
|
1556
|
+
const connectionTimes: number[] = [];
|
|
1557
|
+
const { MockWebSocket: BaseMockWebSocket, sockets } = makeMockWebSocket({
|
|
1558
|
+
onSend: (socket, data) => {
|
|
1559
|
+
const parsed = JSON.parse(String(data));
|
|
1560
|
+
if (parsed.method === "web3_clientVersion") return;
|
|
1561
|
+
queueMicrotask(() => {
|
|
1562
|
+
socket.emitMessage(
|
|
1563
|
+
JSON.stringify({
|
|
1564
|
+
jsonrpc: "2.0",
|
|
1565
|
+
id: parsed.id,
|
|
1566
|
+
result: "0x1",
|
|
1567
|
+
}),
|
|
1568
|
+
);
|
|
1569
|
+
});
|
|
1570
|
+
},
|
|
1571
|
+
});
|
|
1572
|
+
|
|
1573
|
+
class MockWebSocket extends BaseMockWebSocket {
|
|
1574
|
+
constructor(url: string, protocols?: string | string[]) {
|
|
1575
|
+
super(url, protocols);
|
|
1576
|
+
connectionTimes.push(Date.now());
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
|
|
1581
|
+
|
|
1582
|
+
const program = Effect.gen(function* () {
|
|
1583
|
+
const transport = yield* TransportService;
|
|
1584
|
+
|
|
1585
|
+
yield* transport.request<string>("eth_blockNumber", []);
|
|
1586
|
+
|
|
1587
|
+
sockets[0]?.close();
|
|
1588
|
+
yield* Effect.sleep(15);
|
|
1589
|
+
sockets[1]?.close();
|
|
1590
|
+
yield* Effect.sleep(30);
|
|
1591
|
+
sockets[2]?.close();
|
|
1592
|
+
yield* Effect.sleep(60);
|
|
1593
|
+
|
|
1594
|
+
return connectionTimes;
|
|
1595
|
+
}).pipe(
|
|
1596
|
+
Effect.provide(
|
|
1597
|
+
Layer.provide(
|
|
1598
|
+
WebSocketTransport({
|
|
1599
|
+
url: "ws://localhost:8545",
|
|
1600
|
+
reconnect: { delay: 10, multiplier: 2, maxAttempts: 10 },
|
|
1601
|
+
}),
|
|
1602
|
+
WebSocketConstructorGlobal,
|
|
1603
|
+
),
|
|
1604
|
+
),
|
|
1605
|
+
Effect.scoped,
|
|
1606
|
+
);
|
|
1607
|
+
|
|
1608
|
+
const times = await Effect.runPromise(program);
|
|
1609
|
+
|
|
1610
|
+
expect(times.length).toBeGreaterThanOrEqual(3);
|
|
1611
|
+
if (times.length >= 3) {
|
|
1612
|
+
const delay1 = times[1] - times[0];
|
|
1613
|
+
const delay2 = times[2] - times[1];
|
|
1614
|
+
expect(delay2).toBeGreaterThanOrEqual(delay1 * 0.8);
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
|
|
1618
|
+
it("fails after max reconnection attempts", async () => {
|
|
1619
|
+
const { MockWebSocket, sockets } = makeMockWebSocket({
|
|
1620
|
+
autoOpen: (index) => index === 0,
|
|
1621
|
+
getReadyState: (index) => (index === 0 ? 1 : 0),
|
|
1622
|
+
});
|
|
1623
|
+
globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
|
|
1624
|
+
|
|
1625
|
+
const program = Effect.gen(function* () {
|
|
1626
|
+
const transport = yield* TransportService;
|
|
1627
|
+
|
|
1628
|
+
yield* Effect.sleep(10);
|
|
1629
|
+
sockets[0]?.close();
|
|
1630
|
+
yield* Effect.sleep(20);
|
|
1631
|
+
sockets[1]?.emitError(new Error("Connection refused"));
|
|
1632
|
+
yield* Effect.sleep(20);
|
|
1633
|
+
sockets[2]?.emitError(new Error("Connection refused"));
|
|
1634
|
+
yield* Effect.sleep(20);
|
|
1635
|
+
sockets[3]?.emitError(new Error("Connection refused"));
|
|
1636
|
+
|
|
1637
|
+
yield* Effect.sleep(200);
|
|
1638
|
+
|
|
1639
|
+
return yield* transport.request<string>("eth_blockNumber", []);
|
|
1640
|
+
}).pipe(
|
|
1641
|
+
Effect.provide(
|
|
1642
|
+
Layer.provide(
|
|
1643
|
+
WebSocketTransport({
|
|
1644
|
+
url: "ws://localhost:8545",
|
|
1645
|
+
reconnect: { delay: 10, maxAttempts: 3 },
|
|
1646
|
+
timeout: 500,
|
|
1647
|
+
}),
|
|
1648
|
+
WebSocketConstructorGlobal,
|
|
1649
|
+
),
|
|
1650
|
+
),
|
|
1651
|
+
Effect.scoped,
|
|
1652
|
+
);
|
|
1653
|
+
|
|
1654
|
+
const exit = await Effect.runPromiseExit(program);
|
|
1655
|
+
expect(exit._tag).toBe("Failure");
|
|
1656
|
+
});
|
|
1657
|
+
|
|
1658
|
+
it("queues requests during reconnection", async () => {
|
|
1659
|
+
const { MockWebSocket, sockets } = makeMockWebSocket({
|
|
1660
|
+
autoOpen: (index) => index === 0,
|
|
1661
|
+
getReadyState: (index) => (index === 0 ? 1 : 0),
|
|
1662
|
+
onSend: (socket, data) => {
|
|
1663
|
+
const parsed = JSON.parse(String(data));
|
|
1664
|
+
if (parsed.method === "web3_clientVersion") return;
|
|
1665
|
+
queueMicrotask(() => {
|
|
1666
|
+
socket.emitMessage(
|
|
1667
|
+
JSON.stringify({
|
|
1668
|
+
jsonrpc: "2.0",
|
|
1669
|
+
id: parsed.id,
|
|
1670
|
+
result: `0x${parsed.id}`,
|
|
1671
|
+
}),
|
|
1672
|
+
);
|
|
1673
|
+
});
|
|
1674
|
+
},
|
|
1675
|
+
});
|
|
1676
|
+
globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
|
|
1677
|
+
|
|
1678
|
+
const program = Effect.gen(function* () {
|
|
1679
|
+
const transport = yield* TransportService;
|
|
1680
|
+
|
|
1681
|
+
const result1 = yield* transport.request<string>("eth_blockNumber", []);
|
|
1682
|
+
expect(result1).toBe("0x1");
|
|
1683
|
+
|
|
1684
|
+
sockets[0]?.close();
|
|
1685
|
+
yield* Effect.sleep(5);
|
|
1686
|
+
|
|
1687
|
+
const requestFiber = yield* Effect.fork(
|
|
1688
|
+
transport.request<string>("eth_chainId", []),
|
|
1689
|
+
);
|
|
1690
|
+
|
|
1691
|
+
yield* Effect.sleep(30);
|
|
1692
|
+
sockets[1]?.emitOpen();
|
|
1693
|
+
|
|
1694
|
+
yield* Effect.sleep(100);
|
|
1695
|
+
const result2 = yield* Fiber.join(requestFiber);
|
|
1696
|
+
expect(result2).toBe("0x2");
|
|
1697
|
+
|
|
1698
|
+
return { result1, result2 };
|
|
1699
|
+
}).pipe(
|
|
1700
|
+
Effect.provide(
|
|
1701
|
+
Layer.provide(
|
|
1702
|
+
WebSocketTransport({
|
|
1703
|
+
url: "ws://localhost:8545",
|
|
1704
|
+
reconnect: { delay: 10, maxAttempts: 3 },
|
|
1705
|
+
}),
|
|
1706
|
+
WebSocketConstructorGlobal,
|
|
1707
|
+
),
|
|
1708
|
+
),
|
|
1709
|
+
Effect.scoped,
|
|
1710
|
+
);
|
|
1711
|
+
|
|
1712
|
+
await Effect.runPromise(program);
|
|
1713
|
+
});
|
|
1714
|
+
|
|
1715
|
+
it("sends keep-alive pings", async () => {
|
|
1716
|
+
const sentMessages: string[] = [];
|
|
1717
|
+
|
|
1718
|
+
const { MockWebSocket } = makeMockWebSocket({
|
|
1719
|
+
onSend: (_socket, data) => {
|
|
1720
|
+
sentMessages.push(String(data));
|
|
1721
|
+
},
|
|
1722
|
+
});
|
|
1723
|
+
globalThis.WebSocket = MockWebSocket as unknown as typeof WebSocket;
|
|
1724
|
+
|
|
1725
|
+
const program = Effect.gen(function* () {
|
|
1726
|
+
yield* TransportService;
|
|
1727
|
+
|
|
1728
|
+
yield* Effect.sleep(150);
|
|
1729
|
+
|
|
1730
|
+
const keepAliveMessages = sentMessages.filter((msg) => {
|
|
1731
|
+
const parsed = JSON.parse(msg);
|
|
1732
|
+
return (
|
|
1733
|
+
parsed.method === "web3_clientVersion" && parsed.id === "keepalive"
|
|
1734
|
+
);
|
|
1735
|
+
});
|
|
1736
|
+
|
|
1737
|
+
return keepAliveMessages.length;
|
|
1738
|
+
}).pipe(
|
|
1739
|
+
Effect.provide(
|
|
1740
|
+
Layer.provide(
|
|
1741
|
+
WebSocketTransport({
|
|
1742
|
+
url: "ws://localhost:8545",
|
|
1743
|
+
keepAlive: 50,
|
|
1744
|
+
}),
|
|
1745
|
+
WebSocketConstructorGlobal,
|
|
1746
|
+
),
|
|
1747
|
+
),
|
|
1748
|
+
Effect.scoped,
|
|
1749
|
+
);
|
|
1750
|
+
|
|
1751
|
+
const keepAliveCount = await Effect.runPromise(program);
|
|
1752
|
+
expect(keepAliveCount).toBeGreaterThanOrEqual(2);
|
|
1753
|
+
});
|
|
1754
|
+
});
|
|
1755
|
+
});
|