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,991 @@
|
|
|
1
|
+
import { describe, expect, it } from "@effect/vitest";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as S from "effect/Schema";
|
|
4
|
+
import * as Rlp from "./index.js";
|
|
5
|
+
|
|
6
|
+
type Encodable = Uint8Array | Encodable[];
|
|
7
|
+
|
|
8
|
+
/** Convert hex string to Uint8Array */
|
|
9
|
+
const fromHex = (hex: string): Uint8Array => {
|
|
10
|
+
const h = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
11
|
+
const bytes = new Uint8Array(h.length / 2);
|
|
12
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
13
|
+
bytes[i] = Number.parseInt(h.slice(i * 2, i * 2 + 2), 16);
|
|
14
|
+
}
|
|
15
|
+
return bytes;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Convert string to Uint8Array */
|
|
19
|
+
const fromString = (s: string): Uint8Array => new TextEncoder().encode(s);
|
|
20
|
+
|
|
21
|
+
/** Convert integer to minimal big-endian Uint8Array (0 = empty array) */
|
|
22
|
+
const fromInt = (n: number): Uint8Array => {
|
|
23
|
+
if (n === 0) return new Uint8Array(0);
|
|
24
|
+
const hex = n.toString(16);
|
|
25
|
+
const padded = hex.length % 2 === 0 ? hex : `0${hex}`;
|
|
26
|
+
return fromHex(padded);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe("Rlp encode", () => {
|
|
30
|
+
describe("single byte encoding", () => {
|
|
31
|
+
it("encodes single byte 0x00 as itself", () => {
|
|
32
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x00])));
|
|
33
|
+
expect(encoded).toEqual(new Uint8Array([0x00]));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("encodes single byte < 0x80 as itself", () => {
|
|
37
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x7f])));
|
|
38
|
+
expect(encoded).toEqual(new Uint8Array([0x7f]));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("encodes single byte 0x80 with prefix", () => {
|
|
42
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x80])));
|
|
43
|
+
expect(encoded).toEqual(new Uint8Array([0x81, 0x80]));
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("short bytes (0-55 bytes)", () => {
|
|
48
|
+
it("encodes empty bytes as 0x80", () => {
|
|
49
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array(0)));
|
|
50
|
+
expect(encoded).toEqual(new Uint8Array([0x80]));
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("encodes 2 bytes with prefix 0x82", () => {
|
|
54
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x01, 0x02])));
|
|
55
|
+
expect(encoded).toEqual(new Uint8Array([0x82, 0x01, 0x02]));
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("encodes 55 bytes with prefix 0xb7", () => {
|
|
59
|
+
const data = new Uint8Array(55).fill(0xab);
|
|
60
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
61
|
+
expect(encoded[0]).toBe(0xb7);
|
|
62
|
+
expect(encoded.length).toBe(56);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe("long bytes (> 55 bytes)", () => {
|
|
67
|
+
it("encodes 56 bytes with length prefix", () => {
|
|
68
|
+
const data = new Uint8Array(56).fill(0xab);
|
|
69
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
70
|
+
expect(encoded[0]).toBe(0xb8);
|
|
71
|
+
expect(encoded[1]).toBe(56);
|
|
72
|
+
expect(encoded.length).toBe(58);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("encodes 256 bytes with 2-byte length prefix", () => {
|
|
76
|
+
const data = new Uint8Array(256).fill(0xab);
|
|
77
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
78
|
+
expect(encoded[0]).toBe(0xb9);
|
|
79
|
+
expect(encoded[1]).toBe(0x01);
|
|
80
|
+
expect(encoded[2]).toBe(0x00);
|
|
81
|
+
expect(encoded.length).toBe(259);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("encodes 1024 bytes correctly", () => {
|
|
85
|
+
const data = new Uint8Array(1024).fill(0xcd);
|
|
86
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
87
|
+
expect(encoded[0]).toBe(0xb9);
|
|
88
|
+
expect(encoded.length).toBe(1027);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe("short lists (0-55 bytes total)", () => {
|
|
93
|
+
it("encodes empty list as 0xc0", () => {
|
|
94
|
+
const encoded = Effect.runSync(Rlp.encode([]));
|
|
95
|
+
expect(encoded).toEqual(new Uint8Array([0xc0]));
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("encodes list with single byte item", () => {
|
|
99
|
+
const encoded = Effect.runSync(Rlp.encode([new Uint8Array([0x01])]));
|
|
100
|
+
expect(encoded).toEqual(new Uint8Array([0xc1, 0x01]));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("encodes list with multiple items", () => {
|
|
104
|
+
const encoded = Effect.runSync(
|
|
105
|
+
Rlp.encode([new Uint8Array([0x01]), new Uint8Array([0x02])]),
|
|
106
|
+
);
|
|
107
|
+
expect(encoded).toEqual(new Uint8Array([0xc2, 0x01, 0x02]));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe("long lists (> 55 bytes)", () => {
|
|
112
|
+
it("encodes list with total > 55 bytes", () => {
|
|
113
|
+
const items = Array.from({ length: 60 }, () => new Uint8Array([0xab]));
|
|
114
|
+
const encoded = Effect.runSync(Rlp.encode(items));
|
|
115
|
+
expect(encoded[0]).toBe(0xf8);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
describe("nested lists", () => {
|
|
120
|
+
it("encodes nested list", () => {
|
|
121
|
+
const nested: Encodable = [[new Uint8Array([0x01])]];
|
|
122
|
+
const encoded = Effect.runSync(Rlp.encode(nested));
|
|
123
|
+
expect(encoded).toEqual(new Uint8Array([0xc2, 0xc1, 0x01]));
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("encodes deeply nested empty lists", () => {
|
|
127
|
+
const nested: Encodable = [[[[]]]];
|
|
128
|
+
const encoded = Effect.runSync(Rlp.encode(nested));
|
|
129
|
+
expect(encoded).toEqual(new Uint8Array([0xc3, 0xc2, 0xc1, 0xc0]));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it("encodes mixed nested structure", () => {
|
|
133
|
+
const mixed: Encodable = [
|
|
134
|
+
new Uint8Array([0x01]),
|
|
135
|
+
[new Uint8Array([0x02]), new Uint8Array([0x03])],
|
|
136
|
+
];
|
|
137
|
+
const encoded = Effect.runSync(Rlp.encode(mixed));
|
|
138
|
+
expect(encoded).toEqual(new Uint8Array([0xc4, 0x01, 0xc2, 0x02, 0x03]));
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
describe("Rlp decode", () => {
|
|
144
|
+
describe("single byte decoding", () => {
|
|
145
|
+
it("decodes single byte < 0x80", () => {
|
|
146
|
+
const decoded = Effect.runSync(Rlp.decode(new Uint8Array([0x7f])));
|
|
147
|
+
expect(decoded.data).toEqual({
|
|
148
|
+
type: "bytes",
|
|
149
|
+
value: new Uint8Array([0x7f]),
|
|
150
|
+
});
|
|
151
|
+
expect(decoded.remainder.length).toBe(0);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("decodes single byte 0x00", () => {
|
|
155
|
+
const decoded = Effect.runSync(Rlp.decode(new Uint8Array([0x00])));
|
|
156
|
+
expect(decoded.data).toEqual({
|
|
157
|
+
type: "bytes",
|
|
158
|
+
value: new Uint8Array([0x00]),
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("bytes decoding", () => {
|
|
164
|
+
it("decodes empty bytes", () => {
|
|
165
|
+
const decoded = Effect.runSync(Rlp.decode(new Uint8Array([0x80])));
|
|
166
|
+
expect(decoded.data).toEqual({ type: "bytes", value: new Uint8Array(0) });
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("decodes short bytes", () => {
|
|
170
|
+
const decoded = Effect.runSync(
|
|
171
|
+
Rlp.decode(new Uint8Array([0x82, 0x01, 0x02])),
|
|
172
|
+
);
|
|
173
|
+
expect(decoded.data).toEqual({
|
|
174
|
+
type: "bytes",
|
|
175
|
+
value: new Uint8Array([0x01, 0x02]),
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("decodes long bytes with 1-byte length", () => {
|
|
180
|
+
const data = new Uint8Array(56).fill(0xab);
|
|
181
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
182
|
+
const decoded = Effect.runSync(Rlp.decode(encoded));
|
|
183
|
+
expect(decoded.data).toEqual({ type: "bytes", value: data });
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe("list decoding", () => {
|
|
188
|
+
it("decodes empty list", () => {
|
|
189
|
+
const decoded = Effect.runSync(Rlp.decode(new Uint8Array([0xc0])));
|
|
190
|
+
expect(decoded.data).toEqual({ type: "list", value: [] });
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
it("decodes list with items", () => {
|
|
194
|
+
const decoded = Effect.runSync(
|
|
195
|
+
Rlp.decode(new Uint8Array([0xc2, 0x01, 0x02])),
|
|
196
|
+
);
|
|
197
|
+
expect(decoded.data).toEqual({
|
|
198
|
+
type: "list",
|
|
199
|
+
value: [
|
|
200
|
+
{ type: "bytes", value: new Uint8Array([0x01]) },
|
|
201
|
+
{ type: "bytes", value: new Uint8Array([0x02]) },
|
|
202
|
+
],
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe("error handling", () => {
|
|
208
|
+
it("rejects oversized length prefixes", async () => {
|
|
209
|
+
const oversizedLength = new Uint8Array([
|
|
210
|
+
0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
211
|
+
]);
|
|
212
|
+
await expect(
|
|
213
|
+
Effect.runPromise(Rlp.decode(oversizedLength)),
|
|
214
|
+
).rejects.toThrow();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("rejects truncated input", async () => {
|
|
218
|
+
const truncated = new Uint8Array([0x82, 0x01]);
|
|
219
|
+
await expect(Effect.runPromise(Rlp.decode(truncated))).rejects.toThrow();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("rejects invalid length for long bytes", async () => {
|
|
223
|
+
const invalid = new Uint8Array([0xb8, 0x10]);
|
|
224
|
+
await expect(Effect.runPromise(Rlp.decode(invalid))).rejects.toThrow();
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
describe("Rlp round-trip", () => {
|
|
230
|
+
it("round-trips empty bytes", () => {
|
|
231
|
+
const original = new Uint8Array(0);
|
|
232
|
+
const encoded = Effect.runSync(Rlp.encode(original));
|
|
233
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
234
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
235
|
+
expect(reEncoded).toEqual(encoded);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("round-trips short bytes", () => {
|
|
239
|
+
const original = new Uint8Array([0x01, 0x02, 0x03, 0x04, 0x05]);
|
|
240
|
+
const encoded = Effect.runSync(Rlp.encode(original));
|
|
241
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
242
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
243
|
+
expect(reEncoded).toEqual(encoded);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it("round-trips long bytes", () => {
|
|
247
|
+
const original = new Uint8Array(200).fill(0xab);
|
|
248
|
+
const encoded = Effect.runSync(Rlp.encode(original));
|
|
249
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
250
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
251
|
+
expect(reEncoded).toEqual(encoded);
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it("round-trips empty list", () => {
|
|
255
|
+
const original: Encodable = [];
|
|
256
|
+
const encoded = Effect.runSync(Rlp.encode(original));
|
|
257
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
258
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
259
|
+
expect(reEncoded).toEqual(encoded);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("round-trips nested lists", () => {
|
|
263
|
+
const original: Encodable = [
|
|
264
|
+
new Uint8Array([0x01]),
|
|
265
|
+
[new Uint8Array([0x02]), [new Uint8Array([0x03])]],
|
|
266
|
+
[],
|
|
267
|
+
];
|
|
268
|
+
const encoded = Effect.runSync(Rlp.encode(original));
|
|
269
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
270
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
271
|
+
expect(reEncoded).toEqual(encoded);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it("round-trips deeply nested empty lists", () => {
|
|
275
|
+
const original: Encodable = [[[[]]]];
|
|
276
|
+
const encoded = Effect.runSync(Rlp.encode(original));
|
|
277
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
278
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
279
|
+
expect(reEncoded).toEqual(encoded);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it("handles concurrent encode/decode without shared state", async () => {
|
|
283
|
+
const inputs: Encodable[] = [
|
|
284
|
+
new Uint8Array([0x01, 0x02, 0x03]),
|
|
285
|
+
[new Uint8Array([0x04]), [new Uint8Array([0x05])]],
|
|
286
|
+
[],
|
|
287
|
+
[new Uint8Array(0), new Uint8Array([0x00])],
|
|
288
|
+
[[[new Uint8Array([0xaa])]]],
|
|
289
|
+
];
|
|
290
|
+
|
|
291
|
+
const encoded = await Promise.all(
|
|
292
|
+
inputs.map((input) => Effect.runPromise(Rlp.encode(input))),
|
|
293
|
+
);
|
|
294
|
+
const decoded = await Promise.all(
|
|
295
|
+
encoded.map((bytes) => Effect.runPromise(Rlp.decode(bytes))),
|
|
296
|
+
);
|
|
297
|
+
const reEncoded = await Promise.all(
|
|
298
|
+
decoded.map(({ data }) => Effect.runPromise(Rlp.encode(data))),
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
encoded.forEach((bytes, index) => {
|
|
302
|
+
expect(decoded[index]?.remainder.length).toBe(0);
|
|
303
|
+
expect(reEncoded[index]).toEqual(bytes);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
describe("Rlp edge cases", () => {
|
|
309
|
+
it("distinguishes empty list from empty bytes", () => {
|
|
310
|
+
const emptyBytesEncoded = Effect.runSync(Rlp.encode(new Uint8Array(0)));
|
|
311
|
+
const emptyListEncoded = Effect.runSync(Rlp.encode([]));
|
|
312
|
+
|
|
313
|
+
expect(emptyBytesEncoded).toEqual(new Uint8Array([0x80]));
|
|
314
|
+
expect(emptyListEncoded).toEqual(new Uint8Array([0xc0]));
|
|
315
|
+
|
|
316
|
+
const emptyBytesDecoded = Effect.runSync(Rlp.decode(emptyBytesEncoded));
|
|
317
|
+
const emptyListDecoded = Effect.runSync(Rlp.decode(emptyListEncoded));
|
|
318
|
+
|
|
319
|
+
expect(emptyBytesDecoded.data).toEqual({
|
|
320
|
+
type: "bytes",
|
|
321
|
+
value: new Uint8Array(0),
|
|
322
|
+
});
|
|
323
|
+
expect(emptyListDecoded.data).toEqual({ type: "list", value: [] });
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it("encodes all single-byte values correctly", () => {
|
|
327
|
+
for (let i = 0; i < 128; i++) {
|
|
328
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([i])));
|
|
329
|
+
expect(encoded).toEqual(new Uint8Array([i]));
|
|
330
|
+
}
|
|
331
|
+
for (let i = 128; i < 256; i++) {
|
|
332
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([i])));
|
|
333
|
+
expect(encoded).toEqual(new Uint8Array([0x81, i]));
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it("handles large nested structure", () => {
|
|
338
|
+
const buildNested = (depth: number): Encodable => {
|
|
339
|
+
if (depth === 0) return new Uint8Array([0x42]);
|
|
340
|
+
return [buildNested(depth - 1)];
|
|
341
|
+
};
|
|
342
|
+
const nested = buildNested(10);
|
|
343
|
+
const encoded = Effect.runSync(Rlp.encode(nested));
|
|
344
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
345
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
346
|
+
expect(reEncoded).toEqual(encoded);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
it("handles list with many items", () => {
|
|
350
|
+
const items = Array.from({ length: 100 }, (_, i) => new Uint8Array([i]));
|
|
351
|
+
const encoded = Effect.runSync(Rlp.encode(items));
|
|
352
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
353
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
354
|
+
expect(reEncoded).toEqual(encoded);
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
describe("Ethereum official RLP test vectors", () => {
|
|
359
|
+
// From https://github.com/ethereum/tests/blob/develop/RLPTests/rlptest.json
|
|
360
|
+
|
|
361
|
+
it("emptystring: '' → 0x80", () => {
|
|
362
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array(0)));
|
|
363
|
+
expect(encoded).toEqual(fromHex("80"));
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it("bytestring00: '\\x00' → 0x00", () => {
|
|
367
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x00])));
|
|
368
|
+
expect(encoded).toEqual(fromHex("00"));
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
it("bytestring01: '\\x01' → 0x01", () => {
|
|
372
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x01])));
|
|
373
|
+
expect(encoded).toEqual(fromHex("01"));
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("bytestring7F: '\\x7f' → 0x7f", () => {
|
|
377
|
+
const encoded = Effect.runSync(Rlp.encode(new Uint8Array([0x7f])));
|
|
378
|
+
expect(encoded).toEqual(fromHex("7f"));
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("shortstring: 'dog' → 0x83646f67", () => {
|
|
382
|
+
const encoded = Effect.runSync(Rlp.encode(fromString("dog")));
|
|
383
|
+
expect(encoded).toEqual(fromHex("83646f67"));
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it("shortstring2: 55-char string → prefix 0xb7", () => {
|
|
387
|
+
const input = fromString(
|
|
388
|
+
"Lorem ipsum dolor sit amet, consectetur adipisicing eli",
|
|
389
|
+
);
|
|
390
|
+
expect(input.length).toBe(55);
|
|
391
|
+
const encoded = Effect.runSync(Rlp.encode(input));
|
|
392
|
+
expect(encoded).toEqual(
|
|
393
|
+
fromHex(
|
|
394
|
+
"b74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69",
|
|
395
|
+
),
|
|
396
|
+
);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
it("longstring: 56-char string → prefix 0xb838", () => {
|
|
400
|
+
const input = fromString(
|
|
401
|
+
"Lorem ipsum dolor sit amet, consectetur adipisicing elit",
|
|
402
|
+
);
|
|
403
|
+
expect(input.length).toBe(56);
|
|
404
|
+
const encoded = Effect.runSync(Rlp.encode(input));
|
|
405
|
+
expect(encoded).toEqual(
|
|
406
|
+
fromHex(
|
|
407
|
+
"b8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974",
|
|
408
|
+
),
|
|
409
|
+
);
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
it("zero: integer 0 → 0x80 (empty bytes)", () => {
|
|
413
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(0)));
|
|
414
|
+
expect(encoded).toEqual(fromHex("80"));
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
it("smallint: 1 → 0x01", () => {
|
|
418
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(1)));
|
|
419
|
+
expect(encoded).toEqual(fromHex("01"));
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it("smallint2: 16 → 0x10", () => {
|
|
423
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(16)));
|
|
424
|
+
expect(encoded).toEqual(fromHex("10"));
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it("smallint3: 79 → 0x4f", () => {
|
|
428
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(79)));
|
|
429
|
+
expect(encoded).toEqual(fromHex("4f"));
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it("smallint4: 127 → 0x7f", () => {
|
|
433
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(127)));
|
|
434
|
+
expect(encoded).toEqual(fromHex("7f"));
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("mediumint1: 128 → 0x8180", () => {
|
|
438
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(128)));
|
|
439
|
+
expect(encoded).toEqual(fromHex("8180"));
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it("mediumint2: 1000 → 0x8203e8", () => {
|
|
443
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(1000)));
|
|
444
|
+
expect(encoded).toEqual(fromHex("8203e8"));
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it("mediumint3: 100000 → 0x830186a0", () => {
|
|
448
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(100000)));
|
|
449
|
+
expect(encoded).toEqual(fromHex("830186a0"));
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
it("emptylist: [] → 0xc0", () => {
|
|
453
|
+
const encoded = Effect.runSync(Rlp.encode([]));
|
|
454
|
+
expect(encoded).toEqual(fromHex("c0"));
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("stringlist: ['dog','god','cat'] → 0xcc83646f6783676f6483636174", () => {
|
|
458
|
+
const encoded = Effect.runSync(
|
|
459
|
+
Rlp.encode([fromString("dog"), fromString("god"), fromString("cat")]),
|
|
460
|
+
);
|
|
461
|
+
expect(encoded).toEqual(fromHex("cc83646f6783676f6483636174"));
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it("multilist: ['zw', [4], 1] → 0xc6827a77c10401", () => {
|
|
465
|
+
const encoded = Effect.runSync(
|
|
466
|
+
Rlp.encode([fromString("zw"), [fromInt(4)], fromInt(1)]),
|
|
467
|
+
);
|
|
468
|
+
expect(encoded).toEqual(fromHex("c6827a77c10401"));
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
it("listsoflists: [[[], []], []] → 0xc4c2c0c0c0", () => {
|
|
472
|
+
const encoded = Effect.runSync(Rlp.encode([[[], []], []]));
|
|
473
|
+
expect(encoded).toEqual(fromHex("c4c2c0c0c0"));
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
it("listsoflists2: [[], [[]], [[], [[]]]] → 0xc7c0c1c0c3c0c1c0", () => {
|
|
477
|
+
const encoded = Effect.runSync(Rlp.encode([[], [[]], [[], [[]]]]));
|
|
478
|
+
expect(encoded).toEqual(fromHex("c7c0c1c0c3c0c1c0"));
|
|
479
|
+
});
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
describe("Rlp.encodeBytes", () => {
|
|
483
|
+
it("encodes empty bytes", () => {
|
|
484
|
+
const encoded = Effect.runSync(Rlp.encodeBytes(new Uint8Array(0)));
|
|
485
|
+
expect(encoded).toEqual(new Uint8Array([0x80]));
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
it("encodes single byte < 0x80 as itself", () => {
|
|
489
|
+
const encoded = Effect.runSync(Rlp.encodeBytes(new Uint8Array([0x42])));
|
|
490
|
+
expect(encoded).toEqual(new Uint8Array([0x42]));
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it("encodes single byte >= 0x80 with prefix", () => {
|
|
494
|
+
const encoded = Effect.runSync(Rlp.encodeBytes(new Uint8Array([0xff])));
|
|
495
|
+
expect(encoded).toEqual(new Uint8Array([0x81, 0xff]));
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
it("encodes short bytes with prefix", () => {
|
|
499
|
+
const encoded = Effect.runSync(Rlp.encodeBytes(new Uint8Array([1, 2, 3])));
|
|
500
|
+
expect(encoded).toEqual(new Uint8Array([0x83, 1, 2, 3]));
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
describe("Rlp.encodeList", () => {
|
|
505
|
+
it("encodes empty list", () => {
|
|
506
|
+
const encoded = Effect.runSync(Rlp.encodeList([]));
|
|
507
|
+
expect(encoded).toEqual(new Uint8Array([0xc0]));
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
it("encodes list with items", () => {
|
|
511
|
+
const encoded = Effect.runSync(
|
|
512
|
+
Rlp.encodeList([new Uint8Array([1]), new Uint8Array([2])]),
|
|
513
|
+
);
|
|
514
|
+
expect(encoded).toEqual(new Uint8Array([0xc2, 0x01, 0x02]));
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it("encodes nested list", () => {
|
|
518
|
+
const encoded = Effect.runSync(Rlp.encodeList([[new Uint8Array([0x42])]]));
|
|
519
|
+
expect(encoded).toEqual(new Uint8Array([0xc2, 0xc1, 0x42]));
|
|
520
|
+
});
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
describe("Rlp.encodeArray", () => {
|
|
524
|
+
it("encodes array of bytes", () => {
|
|
525
|
+
const encoded = Effect.runSync(
|
|
526
|
+
Rlp.encodeArray([new Uint8Array([1, 2]), new Uint8Array([3, 4])]),
|
|
527
|
+
);
|
|
528
|
+
expect(encoded[0]).toBe(0xc6); // list prefix for 6 bytes
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
it("round-trips with decodeArray", () => {
|
|
532
|
+
const original = [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])];
|
|
533
|
+
const encoded = Effect.runSync(Rlp.encodeArray(original));
|
|
534
|
+
const decoded = Effect.runSync(Rlp.decodeArray(encoded));
|
|
535
|
+
expect(decoded).toHaveLength(2);
|
|
536
|
+
expect(decoded[0]).toEqual(original[0]);
|
|
537
|
+
expect(decoded[1]).toEqual(original[1]);
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
describe("Rlp.decodeArray", () => {
|
|
542
|
+
it("decodes list to array", () => {
|
|
543
|
+
const encoded = new Uint8Array([0xc2, 0x01, 0x02]);
|
|
544
|
+
const decoded = Effect.runSync(Rlp.decodeArray(encoded));
|
|
545
|
+
expect(decoded).toEqual([new Uint8Array([0x01]), new Uint8Array([0x02])]);
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it("decodes nested lists", () => {
|
|
549
|
+
const encoded = new Uint8Array([0xc3, 0xc2, 0x01, 0x02]);
|
|
550
|
+
const decoded = Effect.runSync(Rlp.decodeArray(encoded));
|
|
551
|
+
expect(decoded).toHaveLength(1);
|
|
552
|
+
expect(Array.isArray(decoded[0])).toBe(true);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
it("fails on invalid RLP", async () => {
|
|
556
|
+
const invalid = new Uint8Array([0x83, 0x01]); // claims 3 bytes, only 1
|
|
557
|
+
await expect(Effect.runPromise(Rlp.decodeArray(invalid))).rejects.toThrow();
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
describe("Rlp.flatten", () => {
|
|
562
|
+
it("flattens bytes to single-element array", () => {
|
|
563
|
+
const { data } = Effect.runSync(
|
|
564
|
+
Rlp.decode(new Uint8Array([0x83, 1, 2, 3])),
|
|
565
|
+
);
|
|
566
|
+
const flat = Effect.runSync(Rlp.flatten(data));
|
|
567
|
+
expect(flat).toHaveLength(1);
|
|
568
|
+
expect(flat[0]?.value).toEqual(new Uint8Array([1, 2, 3]));
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
it("flattens nested list depth-first", () => {
|
|
572
|
+
const encoded = Effect.runSync(
|
|
573
|
+
Rlp.encode([
|
|
574
|
+
new Uint8Array([1]),
|
|
575
|
+
[new Uint8Array([2]), new Uint8Array([3])],
|
|
576
|
+
]),
|
|
577
|
+
);
|
|
578
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
579
|
+
const flat = Effect.runSync(Rlp.flatten(data));
|
|
580
|
+
expect(flat).toHaveLength(3);
|
|
581
|
+
expect(flat[0]?.value).toEqual(new Uint8Array([1]));
|
|
582
|
+
expect(flat[1]?.value).toEqual(new Uint8Array([2]));
|
|
583
|
+
expect(flat[2]?.value).toEqual(new Uint8Array([3]));
|
|
584
|
+
});
|
|
585
|
+
|
|
586
|
+
it("returns empty array for empty list", () => {
|
|
587
|
+
const { data } = Effect.runSync(Rlp.decode(new Uint8Array([0xc0])));
|
|
588
|
+
const flat = Effect.runSync(Rlp.flatten(data));
|
|
589
|
+
expect(flat).toEqual([]);
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
describe("Rlp.validate", () => {
|
|
594
|
+
it("returns true for valid single byte", () => {
|
|
595
|
+
const valid = Effect.runSync(Rlp.validate(new Uint8Array([0x42])));
|
|
596
|
+
expect(valid).toBe(true);
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
it("returns true for valid short bytes", () => {
|
|
600
|
+
const valid = Effect.runSync(Rlp.validate(new Uint8Array([0x83, 1, 2, 3])));
|
|
601
|
+
expect(valid).toBe(true);
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
it("returns true for valid empty list", () => {
|
|
605
|
+
const valid = Effect.runSync(Rlp.validate(new Uint8Array([0xc0])));
|
|
606
|
+
expect(valid).toBe(true);
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
it("returns false for truncated short bytes", () => {
|
|
610
|
+
const valid = Effect.runSync(Rlp.validate(new Uint8Array([0x83, 1]))); // claims 3 bytes
|
|
611
|
+
expect(valid).toBe(false);
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
it("returns false for truncated list", () => {
|
|
615
|
+
const valid = Effect.runSync(Rlp.validate(new Uint8Array([0xc2, 0x01]))); // claims 2 bytes
|
|
616
|
+
expect(valid).toBe(false);
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
it("returns false for empty input", () => {
|
|
620
|
+
const valid = Effect.runSync(Rlp.validate(new Uint8Array(0)));
|
|
621
|
+
expect(valid).toBe(false);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
describe("Rlp.Schema", () => {
|
|
626
|
+
// NOTE: The Schema uses Rlp.from() which wraps input as BrandedRlp data structures,
|
|
627
|
+
// it does NOT decode RLP-encoded bytes. For decoding, use Rlp.decode().
|
|
628
|
+
|
|
629
|
+
it("wraps Uint8Array as bytes data", () => {
|
|
630
|
+
// Schema wraps Uint8Array as {type: 'bytes', value: input}
|
|
631
|
+
const input = new Uint8Array([1, 2, 3]);
|
|
632
|
+
const result = S.decodeUnknownSync(Rlp.Schema)(input);
|
|
633
|
+
expect(result.type).toBe("bytes");
|
|
634
|
+
if (result.type === "bytes") {
|
|
635
|
+
expect(result.value).toEqual(new Uint8Array([1, 2, 3]));
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
|
|
639
|
+
it("handles already-branded RLP data", () => {
|
|
640
|
+
// First decode some RLP to get branded data
|
|
641
|
+
const { data } = Effect.runSync(
|
|
642
|
+
Rlp.decode(new Uint8Array([0x83, 1, 2, 3])),
|
|
643
|
+
);
|
|
644
|
+
// Schema should accept already-branded data
|
|
645
|
+
const result = S.decodeUnknownSync(Rlp.Schema)(data);
|
|
646
|
+
expect(result.type).toBe("bytes");
|
|
647
|
+
if (result.type === "bytes") {
|
|
648
|
+
expect(result.value).toEqual(new Uint8Array([1, 2, 3]));
|
|
649
|
+
}
|
|
650
|
+
});
|
|
651
|
+
|
|
652
|
+
it("encodes back to branded representation", () => {
|
|
653
|
+
const input = new Uint8Array([1, 2, 3]);
|
|
654
|
+
const decoded = S.decodeUnknownSync(Rlp.Schema)(input);
|
|
655
|
+
const encoded = S.encodeSync(Rlp.Schema)(decoded);
|
|
656
|
+
// Schema encode returns the branded type as-is
|
|
657
|
+
expect(encoded).toBe(decoded);
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
describe("Rlp decode error cases", () => {
|
|
662
|
+
it("rejects leading zeros in length (non-canonical)", async () => {
|
|
663
|
+
// 0xb900XX would be non-canonical for length < 256
|
|
664
|
+
const nonCanonical = new Uint8Array([
|
|
665
|
+
0xb9,
|
|
666
|
+
0x00,
|
|
667
|
+
0x38,
|
|
668
|
+
...new Array(56).fill(0xab),
|
|
669
|
+
]);
|
|
670
|
+
await expect(Effect.runPromise(Rlp.decode(nonCanonical))).rejects.toThrow();
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
it("rejects incomplete long length prefix", async () => {
|
|
674
|
+
// 0xb9 claims 2 length bytes, only 1 provided
|
|
675
|
+
const incomplete = new Uint8Array([0xb9, 0x01]);
|
|
676
|
+
await expect(Effect.runPromise(Rlp.decode(incomplete))).rejects.toThrow();
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
it("rejects list length exceeding input", async () => {
|
|
680
|
+
// 0xf8 0x10 claims 16 bytes of list content but none provided
|
|
681
|
+
const oversized = new Uint8Array([0xf8, 0x10]);
|
|
682
|
+
await expect(Effect.runPromise(Rlp.decode(oversized))).rejects.toThrow();
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
it("rejects bytes with trailing data when not in stream mode", async () => {
|
|
686
|
+
const withTrailing = new Uint8Array([0x01, 0x99]);
|
|
687
|
+
// Default mode (non-stream) throws on trailing data
|
|
688
|
+
await expect(Effect.runPromise(Rlp.decode(withTrailing))).rejects.toThrow();
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
it("handles stream mode for multiple items", () => {
|
|
692
|
+
const twoItems = new Uint8Array([0x01, 0x02]);
|
|
693
|
+
const first = Effect.runSync(Rlp.decode(twoItems, true));
|
|
694
|
+
expect(first.data).toEqual({
|
|
695
|
+
type: "bytes",
|
|
696
|
+
value: new Uint8Array([0x01]),
|
|
697
|
+
});
|
|
698
|
+
expect(first.remainder).toEqual(new Uint8Array([0x02]));
|
|
699
|
+
const second = Effect.runSync(Rlp.decode(first.remainder, true));
|
|
700
|
+
expect(second.data).toEqual({
|
|
701
|
+
type: "bytes",
|
|
702
|
+
value: new Uint8Array([0x02]),
|
|
703
|
+
});
|
|
704
|
+
expect(second.remainder.length).toBe(0);
|
|
705
|
+
});
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
describe("Rlp large data", () => {
|
|
709
|
+
it("encodes very long bytes (> 65535 bytes)", () => {
|
|
710
|
+
const data = new Uint8Array(70000).fill(0xab);
|
|
711
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
712
|
+
// 0xba + 3-byte length (70000 = 0x011170)
|
|
713
|
+
expect(encoded[0]).toBe(0xba);
|
|
714
|
+
expect(encoded.length).toBe(70000 + 4);
|
|
715
|
+
const { data: decoded } = Effect.runSync(Rlp.decode(encoded));
|
|
716
|
+
if (decoded.type === "bytes") {
|
|
717
|
+
expect(decoded.value.length).toBe(70000);
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
|
|
721
|
+
it("encodes very long list (> 55 bytes payload)", () => {
|
|
722
|
+
const items = Array.from(
|
|
723
|
+
{ length: 256 },
|
|
724
|
+
(_, i) => new Uint8Array([i % 256]),
|
|
725
|
+
);
|
|
726
|
+
const encoded = Effect.runSync(Rlp.encode(items));
|
|
727
|
+
expect(encoded[0]).toBe(0xf9); // 0xf8 + 1 (2-byte length)
|
|
728
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
729
|
+
expect(data.type).toBe("list");
|
|
730
|
+
if (data.type === "list") {
|
|
731
|
+
expect(data.value.length).toBe(256);
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
describe("Rlp list boundary cases", () => {
|
|
737
|
+
it("encodes list with exactly 55 bytes total payload (boundary)", () => {
|
|
738
|
+
// Each item: 0x83 + 3 bytes = 4 bytes encoded. Need 55 bytes, so 13 items + 3 bytes leftover
|
|
739
|
+
// Actually simpler: 55 single-byte items (each encoded as itself) = 55 bytes payload
|
|
740
|
+
const items = Array.from(
|
|
741
|
+
{ length: 55 },
|
|
742
|
+
(_, i) => new Uint8Array([i % 128]),
|
|
743
|
+
);
|
|
744
|
+
const encoded = Effect.runSync(Rlp.encode(items));
|
|
745
|
+
// List prefix for 55 bytes: 0xc0 + 55 = 0xf7
|
|
746
|
+
expect(encoded[0]).toBe(0xf7);
|
|
747
|
+
expect(encoded.length).toBe(56); // 1 prefix + 55 payload
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
it("encodes list with exactly 56 bytes total payload (crosses boundary)", () => {
|
|
751
|
+
// 56 single-byte items = 56 bytes payload
|
|
752
|
+
const items = Array.from(
|
|
753
|
+
{ length: 56 },
|
|
754
|
+
(_, i) => new Uint8Array([i % 128]),
|
|
755
|
+
);
|
|
756
|
+
const encoded = Effect.runSync(Rlp.encode(items));
|
|
757
|
+
// Long list prefix: 0xf8 (1 length byte) + 0x38 (56)
|
|
758
|
+
expect(encoded[0]).toBe(0xf8);
|
|
759
|
+
expect(encoded[1]).toBe(56);
|
|
760
|
+
expect(encoded.length).toBe(58); // 2 prefix bytes + 56 payload
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
it("encodes list containing a list at the 55-byte boundary", () => {
|
|
764
|
+
// Nested list at boundary: [[53 bytes]] = 0xc1 + inner = 0xc1 + 0xb7 + 53 bytes
|
|
765
|
+
const innerData = new Uint8Array(53).fill(0x42);
|
|
766
|
+
const nested: Encodable = [[innerData]];
|
|
767
|
+
const encoded = Effect.runSync(Rlp.encode(nested));
|
|
768
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
769
|
+
expect(data.type).toBe("list");
|
|
770
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
771
|
+
expect(reEncoded).toEqual(encoded);
|
|
772
|
+
});
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
describe("Rlp canonical encoding additional tests", () => {
|
|
776
|
+
it("rejects single byte >= 0x80 encoded without prefix (non-canonical would be impossible to represent)", () => {
|
|
777
|
+
// This is a conceptual test - RLP spec requires single bytes >= 0x80 to have 0x81 prefix
|
|
778
|
+
// Encoding 0x80 directly would be interpreted as empty string
|
|
779
|
+
const decoded = Effect.runSync(Rlp.decode(new Uint8Array([0x80])));
|
|
780
|
+
expect(decoded.data).toEqual({ type: "bytes", value: new Uint8Array(0) });
|
|
781
|
+
});
|
|
782
|
+
|
|
783
|
+
it("handles maximum single-byte length prefix (55 bytes)", () => {
|
|
784
|
+
// 0xb7 is the max prefix for short strings (0x80 + 55 = 0xb7)
|
|
785
|
+
const data = new Uint8Array(55).fill(0xff);
|
|
786
|
+
const encoded = Effect.runSync(Rlp.encode(data));
|
|
787
|
+
expect(encoded[0]).toBe(0xb7);
|
|
788
|
+
const { data: decoded } = Effect.runSync(Rlp.decode(encoded));
|
|
789
|
+
if (decoded.type === "bytes") {
|
|
790
|
+
expect(decoded.value.length).toBe(55);
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
|
|
794
|
+
it("rejects 0xb8 0x00 (empty data claiming long format)", async () => {
|
|
795
|
+
// Non-canonical: using long string format for data that could fit in short format
|
|
796
|
+
const nonCanonical = new Uint8Array([0xb8, 0x00]);
|
|
797
|
+
await expect(Effect.runPromise(Rlp.decode(nonCanonical))).rejects.toThrow();
|
|
798
|
+
});
|
|
799
|
+
|
|
800
|
+
it("rejects 0xb8 0x37 (55 bytes claiming long format)", async () => {
|
|
801
|
+
// Non-canonical: 55 bytes should use 0xb7 prefix, not 0xb8 0x37
|
|
802
|
+
const nonCanonical = new Uint8Array([
|
|
803
|
+
0xb8,
|
|
804
|
+
0x37,
|
|
805
|
+
...new Array(55).fill(0xab),
|
|
806
|
+
]);
|
|
807
|
+
await expect(Effect.runPromise(Rlp.decode(nonCanonical))).rejects.toThrow();
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
it("rejects 0xf8 0x00 (empty list claiming long format)", async () => {
|
|
811
|
+
// Non-canonical: empty list should be 0xc0, not 0xf8 0x00
|
|
812
|
+
const nonCanonical = new Uint8Array([0xf8, 0x00]);
|
|
813
|
+
await expect(Effect.runPromise(Rlp.decode(nonCanonical))).rejects.toThrow();
|
|
814
|
+
});
|
|
815
|
+
});
|
|
816
|
+
|
|
817
|
+
describe("Rlp transaction-like structures", () => {
|
|
818
|
+
it("encodes/decodes legacy transaction structure", () => {
|
|
819
|
+
// Legacy tx: [nonce, gasPrice, gasLimit, to, value, data, v, r, s]
|
|
820
|
+
const tx: Encodable = [
|
|
821
|
+
fromInt(0), // nonce
|
|
822
|
+
fromInt(20000000000), // gasPrice (20 gwei)
|
|
823
|
+
fromInt(21000), // gasLimit
|
|
824
|
+
fromHex("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"), // to (vitalik.eth)
|
|
825
|
+
fromInt(1000000000000000000), // value (1 ETH)
|
|
826
|
+
new Uint8Array(0), // data
|
|
827
|
+
fromInt(27), // v
|
|
828
|
+
fromHex(`0x${"ab".repeat(32)}`), // r
|
|
829
|
+
fromHex(`0x${"cd".repeat(32)}`), // s
|
|
830
|
+
];
|
|
831
|
+
|
|
832
|
+
const encoded = Effect.runSync(Rlp.encode(tx));
|
|
833
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
834
|
+
expect(data.type).toBe("list");
|
|
835
|
+
if (data.type === "list") {
|
|
836
|
+
expect(data.value.length).toBe(9);
|
|
837
|
+
}
|
|
838
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
839
|
+
expect(reEncoded).toEqual(encoded);
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
it("encodes/decodes EIP-2930 access list structure", () => {
|
|
843
|
+
// Access list: [[address, [storageKeys...]]]
|
|
844
|
+
const accessList: Encodable = [
|
|
845
|
+
[
|
|
846
|
+
fromHex("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"),
|
|
847
|
+
[fromHex(`0x${"00".repeat(32)}`), fromHex(`0x${"01".repeat(32)}`)],
|
|
848
|
+
],
|
|
849
|
+
];
|
|
850
|
+
|
|
851
|
+
const encoded = Effect.runSync(Rlp.encode(accessList));
|
|
852
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
853
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
854
|
+
expect(reEncoded).toEqual(encoded);
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
it("encodes/decodes block header structure", () => {
|
|
858
|
+
// Simplified block header fields
|
|
859
|
+
const header: Encodable = [
|
|
860
|
+
fromHex(`0x${"ab".repeat(32)}`), // parentHash
|
|
861
|
+
fromHex(`0x${"00".repeat(32)}`), // ommersHash
|
|
862
|
+
fromHex("0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"), // beneficiary
|
|
863
|
+
fromHex(`0x${"cd".repeat(32)}`), // stateRoot
|
|
864
|
+
fromHex(`0x${"ef".repeat(32)}`), // transactionsRoot
|
|
865
|
+
fromHex(`0x${"12".repeat(32)}`), // receiptsRoot
|
|
866
|
+
new Uint8Array(256).fill(0), // logsBloom
|
|
867
|
+
fromInt(1), // difficulty
|
|
868
|
+
fromInt(12345678), // number
|
|
869
|
+
fromInt(30000000), // gasLimit
|
|
870
|
+
fromInt(21000), // gasUsed
|
|
871
|
+
fromInt(1640000000), // timestamp
|
|
872
|
+
new Uint8Array(0), // extraData
|
|
873
|
+
fromHex(`0x${"ff".repeat(32)}`), // mixHash
|
|
874
|
+
fromHex(`0x${"00".repeat(8)}`), // nonce
|
|
875
|
+
];
|
|
876
|
+
|
|
877
|
+
const encoded = Effect.runSync(Rlp.encode(header));
|
|
878
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
879
|
+
expect(data.type).toBe("list");
|
|
880
|
+
if (data.type === "list") {
|
|
881
|
+
expect(data.value.length).toBe(15);
|
|
882
|
+
}
|
|
883
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
884
|
+
expect(reEncoded).toEqual(encoded);
|
|
885
|
+
});
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
describe("Rlp integer encoding edge cases", () => {
|
|
889
|
+
it("encodes integer 0 as empty bytes (0x80)", () => {
|
|
890
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(0)));
|
|
891
|
+
expect(encoded).toEqual(new Uint8Array([0x80]));
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
it("encodes integers without leading zeros", () => {
|
|
895
|
+
// 256 = 0x0100 should be [0x01, 0x00], not [0x00, 0x01, 0x00]
|
|
896
|
+
const encoded = Effect.runSync(Rlp.encode(fromInt(256)));
|
|
897
|
+
expect(encoded).toEqual(new Uint8Array([0x82, 0x01, 0x00]));
|
|
898
|
+
});
|
|
899
|
+
|
|
900
|
+
it("encodes max uint64 correctly", () => {
|
|
901
|
+
// 2^64 - 1 = 0xffffffffffffffff
|
|
902
|
+
const maxUint64 = fromHex("0xffffffffffffffff");
|
|
903
|
+
const encoded = Effect.runSync(Rlp.encode(maxUint64));
|
|
904
|
+
expect(encoded[0]).toBe(0x88); // 8 bytes + 0x80
|
|
905
|
+
expect(encoded.length).toBe(9);
|
|
906
|
+
});
|
|
907
|
+
|
|
908
|
+
it("encodes max uint256 correctly", () => {
|
|
909
|
+
// 2^256 - 1 = 32 bytes of 0xff
|
|
910
|
+
const maxUint256 = new Uint8Array(32).fill(0xff);
|
|
911
|
+
const encoded = Effect.runSync(Rlp.encode(maxUint256));
|
|
912
|
+
expect(encoded[0]).toBe(0xa0); // 32 bytes + 0x80
|
|
913
|
+
expect(encoded.length).toBe(33);
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
it("round-trips large integer values", () => {
|
|
917
|
+
const values = [
|
|
918
|
+
fromInt(127), // max single byte
|
|
919
|
+
fromInt(128), // first 2-byte
|
|
920
|
+
fromInt(255), // max 1-byte value
|
|
921
|
+
fromInt(256), // first 2-byte big-endian
|
|
922
|
+
fromInt(65535), // max 2-byte
|
|
923
|
+
fromInt(65536), // first 3-byte
|
|
924
|
+
fromInt(16777215), // max 3-byte
|
|
925
|
+
fromInt(16777216), // first 4-byte
|
|
926
|
+
];
|
|
927
|
+
|
|
928
|
+
for (const value of values) {
|
|
929
|
+
const encoded = Effect.runSync(Rlp.encode(value));
|
|
930
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
931
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
932
|
+
expect(reEncoded).toEqual(encoded);
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
describe("Rlp mixed content lists", () => {
|
|
938
|
+
it("encodes list with empty and non-empty items", () => {
|
|
939
|
+
const mixed: Encodable = [
|
|
940
|
+
new Uint8Array(0), // empty
|
|
941
|
+
new Uint8Array([1]), // single byte
|
|
942
|
+
new Uint8Array([128]), // single byte >= 0x80
|
|
943
|
+
[], // empty list
|
|
944
|
+
[new Uint8Array(0)], // list with empty bytes
|
|
945
|
+
];
|
|
946
|
+
|
|
947
|
+
const encoded = Effect.runSync(Rlp.encode(mixed));
|
|
948
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
949
|
+
expect(data.type).toBe("list");
|
|
950
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
951
|
+
expect(reEncoded).toEqual(encoded);
|
|
952
|
+
});
|
|
953
|
+
|
|
954
|
+
it("encodes alternating bytes and lists", () => {
|
|
955
|
+
const alternating: Encodable = [
|
|
956
|
+
new Uint8Array([1]),
|
|
957
|
+
[new Uint8Array([2])],
|
|
958
|
+
new Uint8Array([3]),
|
|
959
|
+
[new Uint8Array([4])],
|
|
960
|
+
];
|
|
961
|
+
|
|
962
|
+
const encoded = Effect.runSync(Rlp.encode(alternating));
|
|
963
|
+
// Total content: 1 (single byte) + 2 ([2]) + 1 (single byte) + 2 ([4]) = 6 bytes
|
|
964
|
+
expect(encoded).toEqual(
|
|
965
|
+
new Uint8Array([
|
|
966
|
+
0xc6, // list of 6 bytes
|
|
967
|
+
0x01, // 1
|
|
968
|
+
0xc1,
|
|
969
|
+
0x02, // [2]
|
|
970
|
+
0x03, // 3
|
|
971
|
+
0xc1,
|
|
972
|
+
0x04, // [4]
|
|
973
|
+
]),
|
|
974
|
+
);
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
it("handles deeply nested mixed structure", () => {
|
|
978
|
+
const deep: Encodable = [
|
|
979
|
+
new Uint8Array([1]),
|
|
980
|
+
[
|
|
981
|
+
new Uint8Array([2]),
|
|
982
|
+
[new Uint8Array([3]), [new Uint8Array([4]), [new Uint8Array([5])]]],
|
|
983
|
+
],
|
|
984
|
+
];
|
|
985
|
+
|
|
986
|
+
const encoded = Effect.runSync(Rlp.encode(deep));
|
|
987
|
+
const { data } = Effect.runSync(Rlp.decode(encoded));
|
|
988
|
+
const reEncoded = Effect.runSync(Rlp.encode(data));
|
|
989
|
+
expect(reEncoded).toEqual(encoded);
|
|
990
|
+
});
|
|
991
|
+
});
|