superstack-wallet-sdk 0.4.2
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 +114 -0
- package/dist/esm/_virtual/_commonjsHelpers.js +2 -0
- package/dist/esm/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/esm/_virtual/_polyfill-node.buffer.js +2 -0
- package/dist/esm/_virtual/_polyfill-node.buffer.js.map +1 -0
- package/dist/esm/_virtual/index.js +2 -0
- package/dist/esm/_virtual/index.js.map +1 -0
- package/dist/esm/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js +2 -0
- package/dist/esm/node_modules/@emotion/is-prop-valid/dist/emotion-is-prop-valid.esm.js.map +1 -0
- package/dist/esm/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js +2 -0
- package/dist/esm/node_modules/@emotion/memoize/dist/emotion-memoize.esm.js.map +1 -0
- package/dist/esm/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js +2 -0
- package/dist/esm/node_modules/@emotion/unitless/dist/emotion-unitless.esm.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/_md.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/_md.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/_u64.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/_u64.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/crypto.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/crypto.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/hmac.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/hmac.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/sha2.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/sha2.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/sha256.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/sha256.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/sha3.js +2 -0
- package/dist/esm/node_modules/@noble/hashes/esm/sha3.js.map +1 -0
- package/dist/esm/node_modules/@noble/hashes/esm/utils.js +4 -0
- package/dist/esm/node_modules/@noble/hashes/esm/utils.js.map +1 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/adapter.js +2 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/adapter.js.map +1 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/errors.js +2 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/errors.js.map +1 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/signer.js +2 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/signer.js.map +1 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/transaction.js +2 -0
- package/dist/esm/node_modules/@solana/wallet-adapter-base/lib/esm/transaction.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/errors.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/errors.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/abiItem.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/abiItem.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/signature.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/signature.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/struct.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/errors/struct.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/formatAbiItem.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/formatAbiItem.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/parseAbi.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/parseAbi.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/parseAbiItem.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/parseAbiItem.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/parseAbiParameters.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/parseAbiParameters.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/cache.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/cache.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/signatures.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/signatures.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/structs.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/structs.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/utils.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/human-readable/runtime/utils.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/regex.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/regex.js.map +1 -0
- package/dist/esm/node_modules/abitype/dist/esm/version.js +2 -0
- package/dist/esm/node_modules/abitype/dist/esm/version.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/_version.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/_version.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/data.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/data.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/errors.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/errors.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/fixednumber.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/fixednumber.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/maths.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/maths.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/properties.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/properties.js.map +1 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/units.js +2 -0
- package/dist/esm/node_modules/ethers/lib.esm/utils/units.js.map +1 -0
- package/dist/esm/node_modules/eventemitter3/index.js +2 -0
- package/dist/esm/node_modules/eventemitter3/index.js.map +1 -0
- package/dist/esm/node_modules/eventemitter3/index2.js +2 -0
- package/dist/esm/node_modules/eventemitter3/index2.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiConstructor.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiConstructor.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiFunction.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiFunction.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiItem.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiItem.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiParameters.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/AbiParameters.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Address.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Address.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Authorization.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Authorization.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/BlockOverrides.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/BlockOverrides.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Bytes.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Bytes.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Caches.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Caches.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Errors.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Errors.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Hash.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Hash.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Hex.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Hex.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Json.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Json.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Signature.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Signature.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Solidity.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Solidity.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/Withdrawal.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/Withdrawal.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/abiItem.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/abiItem.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/abiParameters.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/abiParameters.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/bytes.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/bytes.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/cursor.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/cursor.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/errors.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/errors.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/hex.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/hex.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/lru.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/internal/lru.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/core/version.js +2 -0
- package/dist/esm/node_modules/ox/_esm/core/version.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/erc6492/SignatureErc6492.js +2 -0
- package/dist/esm/node_modules/ox/_esm/erc6492/SignatureErc6492.js.map +1 -0
- package/dist/esm/node_modules/ox/_esm/erc8010/SignatureErc8010.js +2 -0
- package/dist/esm/node_modules/ox/_esm/erc8010/SignatureErc8010.js.map +1 -0
- package/dist/esm/node_modules/styled-components/dist/styled-components.browser.esm.js +2 -0
- package/dist/esm/node_modules/styled-components/dist/styled-components.browser.esm.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Enum.js +2 -0
- package/dist/esm/node_modules/stylis/src/Enum.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Middleware.js +2 -0
- package/dist/esm/node_modules/stylis/src/Middleware.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Parser.js +2 -0
- package/dist/esm/node_modules/stylis/src/Parser.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Prefixer.js +2 -0
- package/dist/esm/node_modules/stylis/src/Prefixer.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Serializer.js +2 -0
- package/dist/esm/node_modules/stylis/src/Serializer.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Tokenizer.js +2 -0
- package/dist/esm/node_modules/stylis/src/Tokenizer.js.map +1 -0
- package/dist/esm/node_modules/stylis/src/Utility.js +2 -0
- package/dist/esm/node_modules/stylis/src/Utility.js.map +1 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js +2 -0
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/accounts/utils/parseAccount.js +2 -0
- package/dist/esm/node_modules/viem/_esm/accounts/utils/parseAccount.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsAvatar.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsAvatar.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsName.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsName.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsResolver.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsResolver.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsText.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/ens/getEnsText.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/call.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/call.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createAccessList.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createAccessList.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createBlockFilter.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createBlockFilter.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createContractEventFilter.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createContractEventFilter.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createEventFilter.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createEventFilter.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createPendingTransactionFilter.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/createPendingTransactionFilter.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateContractGas.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateContractGas.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateFeesPerGas.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateFeesPerGas.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateGas.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateGas.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateMaxPriorityFeePerGas.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBalance.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBalance.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlobBaseFee.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlobBaseFee.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlock.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlock.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlockNumber.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlockNumber.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlockTransactionCount.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getBlockTransactionCount.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getChainId.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getChainId.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getCode.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getCode.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getContractEvents.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getContractEvents.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getEip712Domain.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getEip712Domain.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getFeeHistory.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getFeeHistory.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getFilterChanges.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getFilterChanges.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getFilterLogs.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getFilterLogs.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getGasPrice.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getGasPrice.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getLogs.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getLogs.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getProof.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getProof.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getStorageAt.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getStorageAt.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransaction.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransaction.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransactionConfirmations.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransactionConfirmations.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransactionCount.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransactionCount.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransactionReceipt.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/getTransactionReceipt.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/multicall.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/multicall.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/readContract.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/readContract.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/simulateBlocks.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/simulateBlocks.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/simulateCalls.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/simulateCalls.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/simulateContract.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/simulateContract.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/uninstallFilter.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/uninstallFilter.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/verifyHash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/verifyHash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/verifyMessage.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/verifyMessage.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/verifyTypedData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/verifyTypedData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/waitForTransactionReceipt.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/waitForTransactionReceipt.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchBlockNumber.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchBlockNumber.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchBlocks.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchBlocks.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchContractEvent.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchContractEvent.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchEvent.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchEvent.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchPendingTransactions.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/public/watchPendingTransactions.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/siwe/verifySiweMessage.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/siwe/verifySiweMessage.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/wallet/prepareTransactionRequest.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/actions/wallet/sendRawTransaction.js +2 -0
- package/dist/esm/node_modules/viem/_esm/actions/wallet/sendRawTransaction.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/clients/createClient.js +2 -0
- package/dist/esm/node_modules/viem/_esm/clients/createClient.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/clients/createPublicClient.js +2 -0
- package/dist/esm/node_modules/viem/_esm/clients/createPublicClient.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/clients/decorators/public.js +2 -0
- package/dist/esm/node_modules/viem/_esm/clients/decorators/public.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/clients/transports/createTransport.js +2 -0
- package/dist/esm/node_modules/viem/_esm/clients/transports/createTransport.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/clients/transports/http.js +2 -0
- package/dist/esm/node_modules/viem/_esm/clients/transports/http.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/abis.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/abis.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/address.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/address.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/blob.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/blob.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/contract.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/contract.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/contracts.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/contracts.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/number.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/number.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/solidity.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/solidity.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/strings.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/strings.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/constants/unit.js +2 -0
- package/dist/esm/node_modules/viem/_esm/constants/unit.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/abi.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/abi.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/address.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/address.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/base.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/base.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/blob.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/blob.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/block.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/block.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/ccip.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/ccip.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/chain.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/chain.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/contract.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/contract.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/cursor.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/cursor.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/data.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/data.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/eip712.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/eip712.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/encoding.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/encoding.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/ens.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/ens.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/estimateGas.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/estimateGas.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/fee.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/fee.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/log.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/log.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/node.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/node.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/request.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/request.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/rpc.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/rpc.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/stateOverride.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/stateOverride.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/transaction.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/transaction.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/transport.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/transport.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/typedData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/typedData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/utils.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/utils.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/errors/version.js +2 -0
- package/dist/esm/node_modules/viem/_esm/errors/version.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeAbiParameters.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeAbiParameters.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeErrorResult.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeErrorResult.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeEventLog.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeEventLog.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeFunctionData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeFunctionData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeFunctionResult.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/decodeFunctionResult.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeAbiParameters.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeAbiParameters.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeDeployData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeDeployData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeErrorResult.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeErrorResult.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeEventTopics.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeEventTopics.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeFunctionData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeFunctionData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeFunctionResult.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/encodeFunctionResult.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/formatAbiItem.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/formatAbiItem.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/formatAbiItemWithArgs.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/formatAbiItemWithArgs.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/getAbiItem.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/getAbiItem.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/parseEventLogs.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/parseEventLogs.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/prepareEncodeFunctionData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/abi/prepareEncodeFunctionData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/address/getAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/address/getAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/address/isAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/address/isAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/address/isAddressEqual.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/address/isAddressEqual.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/authorization/hashAuthorization.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/authorization/hashAuthorization.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/authorization/recoverAuthorizationAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/authorization/recoverAuthorizationAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/authorization/verifyAuthorization.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/authorization/verifyAuthorization.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/blobsToCommitments.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/blobsToCommitments.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/blobsToProofs.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/blobsToProofs.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/commitmentToVersionedHash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/commitmentToVersionedHash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/commitmentsToVersionedHashes.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/commitmentsToVersionedHashes.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/toBlobSidecars.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/toBlobSidecars.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/toBlobs.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/blob/toBlobs.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/buildRequest.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/buildRequest.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ccip.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ccip.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/chain/getChainContractAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/chain/getChainContractAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/cursor.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/cursor.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/concat.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/concat.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/isHex.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/isHex.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/pad.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/pad.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/size.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/size.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/slice.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/slice.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/trim.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/data/trim.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/fromBytes.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/fromBytes.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/fromHex.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/fromHex.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/toBytes.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/toBytes.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/toHex.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/toHex.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/toRlp.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/encoding/toRlp.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/avatar/parseAvatarRecord.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/avatar/utils.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/avatar/utils.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/encodeLabelhash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/encodeLabelhash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/encodedLabelToLabelhash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/encodedLabelToLabelhash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/errors.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/errors.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/labelhash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/labelhash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/localBatchGatewayRequest.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/namehash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/namehash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/packetToBytes.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/ens/packetToBytes.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getCallError.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getCallError.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getContractError.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getContractError.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getEstimateGasError.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getEstimateGasError.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getNodeError.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/errors/getNodeError.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/filters/createFilterRequestScope.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/filters/createFilterRequestScope.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/block.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/block.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/extract.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/extract.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/feeHistory.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/feeHistory.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/log.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/log.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/proof.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/proof.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/transaction.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/transaction.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/transactionReceipt.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/transactionReceipt.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/transactionRequest.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/formatters/transactionRequest.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/getAction.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/getAction.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/hashSignature.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/hashSignature.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/keccak256.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/keccak256.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/normalizeSignature.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/normalizeSignature.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/sha256.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/sha256.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toEventSelector.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toEventSelector.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toFunctionSelector.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toFunctionSelector.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toSignature.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toSignature.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toSignatureHash.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/hash/toSignatureHash.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/lru.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/lru.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/observe.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/observe.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/poll.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/poll.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/createBatchScheduler.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/createBatchScheduler.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withCache.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withCache.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withDedupe.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withDedupe.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withResolvers.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withResolvers.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withRetry.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withRetry.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withTimeout.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/promise/withTimeout.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/regex.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/regex.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/rpc/http.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/rpc/http.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/rpc/id.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/rpc/id.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/hashMessage.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/hashMessage.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/hashTypedData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/hashTypedData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/recoverAddress.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/recoverAddress.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/recoverPublicKey.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/recoverPublicKey.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/serializeSignature.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/serializeSignature.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/siwe/parseSiweMessage.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/siwe/parseSiweMessage.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/siwe/validateSiweMessage.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/siwe/validateSiweMessage.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/stateOverride.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/stateOverride.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/stringify.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/stringify.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/transaction/assertRequest.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/transaction/assertRequest.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/transaction/getTransactionType.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/transaction/getTransactionType.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/typedData.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/typedData.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/uid.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/uid.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/unit/formatEther.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/unit/formatEther.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/unit/formatGwei.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/unit/formatGwei.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/unit/formatUnits.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/unit/formatUnits.js.map +1 -0
- package/dist/esm/node_modules/viem/_esm/utils/wait.js +2 -0
- package/dist/esm/node_modules/viem/_esm/utils/wait.js.map +1 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js +3 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js.map +1 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js +3 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js.map +1 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js +4 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js.map +1 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js +3 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js.map +1 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js +4 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js.map +1 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js +3 -0
- package/dist/esm/node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js.map +1 -0
- package/dist/esm/src/LoginModal.js +2 -0
- package/dist/esm/src/LoginModal.js.map +1 -0
- package/dist/esm/src/LoginModal.styles.js +286 -0
- package/dist/esm/src/LoginModal.styles.js.map +1 -0
- package/dist/esm/src/adapters/phantom.js +2 -0
- package/dist/esm/src/adapters/phantom.js.map +1 -0
- package/dist/esm/src/client.js +2 -0
- package/dist/esm/src/client.js.map +1 -0
- package/dist/esm/src/coinbase.js +2 -0
- package/dist/esm/src/coinbase.js.map +1 -0
- package/dist/esm/src/context.js +2 -0
- package/dist/esm/src/context.js.map +1 -0
- package/dist/esm/src/hooks.js +2 -0
- package/dist/esm/src/hooks.js.map +1 -0
- package/dist/esm/src/index.js +2 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/modal.js +2 -0
- package/dist/esm/src/modal.js.map +1 -0
- package/dist/esm/src/polyfills.js +2 -0
- package/dist/esm/src/polyfills.js.map +1 -0
- package/dist/esm/src/storage.js +2 -0
- package/dist/esm/src/storage.js.map +1 -0
- package/dist/esm/src/styles/index.js +2 -0
- package/dist/esm/src/styles/index.js.map +1 -0
- package/dist/esm/src/styles/theme.js +2 -0
- package/dist/esm/src/styles/theme.js.map +1 -0
- package/dist/esm/src/types.js +2 -0
- package/dist/esm/src/types.js.map +1 -0
- package/dist/esm/src/utils/coinbaseUtils.js +2 -0
- package/dist/esm/src/utils/coinbaseUtils.js.map +1 -0
- package/dist/esm/src/utils/oauth.js +2 -0
- package/dist/esm/src/utils/oauth.js.map +1 -0
- package/dist/esm/types/LoginModal.d.ts +3 -0
- package/dist/esm/types/LoginModal.styles.d.ts +29 -0
- package/dist/esm/types/adapters/phantom.d.ts +30 -0
- package/dist/esm/types/client.d.ts +170 -0
- package/dist/esm/types/coinbase.d.ts +3 -0
- package/dist/esm/types/context.d.ts +28 -0
- package/dist/esm/types/hooks.d.ts +56 -0
- package/dist/esm/types/index.d.ts +8 -0
- package/dist/esm/types/modal.d.ts +20 -0
- package/dist/esm/types/polyfills.d.ts +1 -0
- package/dist/esm/types/storage.d.ts +9 -0
- package/dist/esm/types/styles/globalStyles.d.ts +2 -0
- package/dist/esm/types/styles/index.d.ts +2 -0
- package/dist/esm/types/styles/theme.d.ts +103 -0
- package/dist/esm/types/types.d.ts +132 -0
- package/dist/esm/types/utils/coinbaseUtils.d.ts +9 -0
- package/dist/esm/types/utils/oauth.d.ts +21 -0
- package/dist/esm/types/utils/twitter.d.ts +35 -0
- package/dist/index.cjs +296 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +530 -0
- package/package.json +97 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getDefaultExportFromCjs as e}from"../../_virtual/_commonjsHelpers.js";import{__module as t}from"../../_virtual/index.js";!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,i){if("function"!=typeof r)throw new TypeError("The listener must be a function");var c=new o(r,s||e,i),f=n?n+t:t;return e._events[f]?e._events[f].fn?e._events[f]=[e._events[f],c]:e._events[f].push(c):(e._events[f]=c,e._eventsCount++),e}function i(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function c(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),c.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,i=new Array(s);o<s;o++)i[o]=r[o].fn;return i},c.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,o,s,i){var c=n?n+e:e;if(!this._events[c])return!1;var f,a,u=this._events[c],l=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),l){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,s),!0;case 6:return u.fn.call(u.context,t,r,o,s,i),!0}for(a=1,f=new Array(l-1);a<l;a++)f[a-1]=arguments[a];u.fn.apply(u.context,f)}else{var v,p=u.length;for(a=0;a<p;a++)switch(u[a].once&&this.removeListener(e,u[a].fn,void 0,!0),l){case 1:u[a].fn.call(u[a].context);break;case 2:u[a].fn.call(u[a].context,t);break;case 3:u[a].fn.call(u[a].context,t,r);break;case 4:u[a].fn.call(u[a].context,t,r,o);break;default:if(!f)for(v=1,f=new Array(l-1);v<l;v++)f[v-1]=arguments[v];u[a].fn.apply(u[a].context,f)}}return!0},c.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return i(this,s),this;var c=this._events[s];if(c.fn)c.fn!==t||o&&!c.once||r&&c.context!==r||i(this,s);else{for(var f=0,a=[],u=c.length;f<u;f++)(c[f].fn!==t||o&&!c[f].once||r&&c[f].context!==r)&&a.push(c[f]);a.length?this._events[s]=1===a.length?a[0]:a:i(this,s)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&i(this,t)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c}(t);var n=e(t.exports);export{n as default};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../node_modules/eventemitter3/index.js"],"sourcesContent":["'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n"],"names":["has","Object","prototype","hasOwnProperty","prefix","Events","EE","fn","context","once","this","addListener","emitter","event","TypeError","listener","evt","_events","push","_eventsCount","clearEvent","EventEmitter","create","__proto__","eventNames","events","name","names","call","slice","getOwnPropertySymbols","concat","listeners","handlers","i","l","length","ee","Array","listenerCount","emit","a1","a2","a3","a4","a5","args","len","arguments","removeListener","undefined","apply","j","on","removeAllListeners","off","prefixed","module"],"mappings":"6IAEA,IAAIA,EAAMC,OAAOC,UAAUC,eACvBC,EAAS,IASb,SAASC,IAAS,CA4BlB,SAASC,EAAGC,EAAIC,EAASC,GACvBC,KAAKH,GAAKA,EACVG,KAAKF,QAAUA,EACfE,KAAKD,KAAOA,IAAQ,CACtB,CAaA,SAASE,EAAYC,EAASC,EAAON,EAAIC,EAASC,GAChD,GAAkB,mBAAPF,EACT,MAAM,IAAIO,UAAU,mCAGtB,IAAIC,EAAW,IAAIT,EAAGC,EAAIC,GAAWI,EAASH,GAC1CO,EAAMZ,EAASA,EAASS,EAAQA,EAMpC,OAJKD,EAAQK,QAAQD,GACXJ,EAAQK,QAAQD,GAAKT,GAC1BK,EAAQK,QAAQD,GAAO,CAACJ,EAAQK,QAAQD,GAAMD,GADhBH,EAAQK,QAAQD,GAAKE,KAAKH,IADlCH,EAAQK,QAAQD,GAAOD,EAAUH,EAAQO,gBAI7DP,CACT,CASA,SAASQ,EAAWR,EAASI,GACI,MAAzBJ,EAAQO,aAAoBP,EAAQK,QAAU,IAAIZ,SAC5CO,EAAQK,QAAQD,EAC9B,CASA,SAASK,IACPX,KAAKO,QAAU,IAAIZ,EACnBK,KAAKS,aAAe,CACtB,CAzEIlB,OAAOqB,SACTjB,EAAOH,UAAYD,OAAOqB,OAAO,OAM5B,IAAIjB,GAASkB,YAAWnB,GAAS,IA2ExCiB,EAAanB,UAAUsB,WAAa,WAClC,IACIC,EACAC,EAFAC,EAAQ,GAIZ,GAA0B,IAAtBjB,KAAKS,aAAoB,OAAOQ,EAEpC,IAAKD,KAASD,EAASf,KAAKO,QAC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ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index2.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{from as r,NotFoundError as t}from"./AbiItem.js";import{encode as n}from"./AbiParameters.js";import{concat as o}from"./Hex.js";function e(...r){const[t,e]=(()=>{if(Array.isArray(r[0])){const[t,n]=r;return[i(t),n]}return r})(),{bytecode:s,args:c}=e;return o(s,t.inputs?.length&&c?.length?n(t.inputs,c):"0x")}function s(t){return r(t)}function i(r){const n=r.find(r=>"constructor"===r.type);if(!n)throw new t({name:"constructor"});return n}export{e as encode,s as from,i as fromAbi};
|
|
2
|
+
//# sourceMappingURL=AbiConstructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbiConstructor.js","sources":["../../../../../../node_modules/ox/_esm/core/AbiConstructor.js"],"sourcesContent":["import * as abitype from 'abitype';\nimport * as AbiItem from './AbiItem.js';\nimport * as AbiParameters from './AbiParameters.js';\nimport * as Hex from './Hex.js';\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function decode(...parameters) {\n const [abiConstructor, options] = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, options] = parameters;\n return [fromAbi(abi), options];\n }\n return parameters;\n })();\n const { bytecode } = options;\n if (abiConstructor.inputs.length === 0)\n return undefined;\n const data = options.data.replace(bytecode, '0x');\n return AbiParameters.decode(abiConstructor.inputs, data);\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function encode(...parameters) {\n const [abiConstructor, options] = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, options] = parameters;\n return [fromAbi(abi), options];\n }\n return parameters;\n })();\n const { bytecode, args } = options;\n return Hex.concat(bytecode, abiConstructor.inputs?.length && args?.length\n ? AbiParameters.encode(abiConstructor.inputs, args)\n : '0x');\n}\n/** @internal */\nexport function format(abiConstructor) {\n return abitype.formatAbiItem(abiConstructor);\n}\n/** @internal */\nexport function from(abiConstructor) {\n return AbiItem.from(abiConstructor);\n}\n/** @internal */\nexport function fromAbi(abi) {\n const item = abi.find((item) => item.type === 'constructor');\n if (!item)\n throw new AbiItem.NotFoundError({ name: 'constructor' });\n return item;\n}\n//# sourceMappingURL=AbiConstructor.js.map"],"names":["encode","parameters","abiConstructor","options","Array","isArray","abi","fromAbi","bytecode","args","Hex.concat","inputs","length","AbiParameters.encode","from","AbiItem.from","item","find","type","AbiItem.NotFoundError","name"],"mappings":"qIAoBO,SAASA,KAAUC,GACtB,MAAOC,EAAgBC,GAAW,MAC9B,GAAIC,MAAMC,QAAQJ,EAAW,IAAK,CAC9B,MAAOK,EAAKH,GAAWF,EACvB,MAAO,CAACM,EAAQD,GAAMH,EAC1B,CACA,OAAOF,CACV,EANiC,IAO5BO,SAAEA,EAAQC,KAAEA,GAASN,EAC3B,OAAOO,EAAWF,EAAUN,EAAeS,QAAQC,QAAUH,GAAMG,OAC7DC,EAAqBX,EAAeS,OAAQF,GAC5C,KACV,CAMO,SAASK,EAAKZ,GACjB,OAAOa,EAAab,EACxB,CAEO,SAASK,EAAQD,GACpB,MAAMU,EAAOV,EAAIW,KAAMD,GAAuB,gBAAdA,EAAKE,MACrC,IAAKF,EACD,MAAM,IAAIG,EAAsB,CAAEC,KAAM,gBAC5C,OAAOJ,CACX","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{from as r,fromAbi as t,NotFoundError as n,getSelector as o}from"./AbiItem.js";import{encode as e}from"./AbiParameters.js";import{concat as i}from"./Hex.js";function s(...r){const[t,n=[]]=(()=>{if(Array.isArray(r[0])){const[t,n,o]=r;return[u(t,n,{args:o}),o]}const[t,n]=r;return[t,n]})(),{overloads:o}=t,s=o?u([t,...o],t.name,{args:n}):t,f=a(s),m=n.length>0?e(s.inputs,n):void 0;return m?i(f,m):f}function f(t,n={}){return r(t,n)}function u(r,o,e){const i=t(r,o,e);if("function"!==i.type)throw new n({name:o,type:"function"});return i}function a(r){return o(r)}export{s as encodeData,f as from,u as fromAbi,a as getSelector};
|
|
2
|
+
//# sourceMappingURL=AbiFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbiFunction.js","sources":["../../../../../../node_modules/ox/_esm/core/AbiFunction.js"],"sourcesContent":["import * as abitype from 'abitype';\nimport * as AbiItem from './AbiItem.js';\nimport * as AbiParameters from './AbiParameters.js';\nimport * as Hex from './Hex.js';\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function decodeData(...parameters) {\n const [abiFunction, data] = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name, data] = parameters;\n return [fromAbi(abi, name), data];\n }\n return parameters;\n })();\n const { overloads } = abiFunction;\n if (Hex.size(data) < 4)\n throw new AbiItem.InvalidSelectorSizeError({ data });\n if (abiFunction.inputs.length === 0)\n return undefined;\n const item = overloads\n ? fromAbi([abiFunction, ...overloads], data)\n : abiFunction;\n if (Hex.size(data) <= 4)\n return undefined;\n return AbiParameters.decode(item.inputs, Hex.slice(data, 4));\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function decodeResult(...parameters) {\n const [abiFunction, data, options = {}] = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name, data, options] = parameters;\n return [fromAbi(abi, name), data, options];\n }\n return parameters;\n })();\n const values = AbiParameters.decode(abiFunction.outputs, data, options);\n if (values && Object.keys(values).length === 0)\n return undefined;\n if (values && Object.keys(values).length === 1) {\n if (Array.isArray(values))\n return values[0];\n return Object.values(values)[0];\n }\n return values;\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function encodeData(...parameters) {\n const [abiFunction, args = []] = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name, args] = parameters;\n return [fromAbi(abi, name, { args }), args];\n }\n const [abiFunction, args] = parameters;\n return [abiFunction, args];\n })();\n const { overloads } = abiFunction;\n const item = overloads\n ? fromAbi([abiFunction, ...overloads], abiFunction.name, {\n args,\n })\n : abiFunction;\n const selector = getSelector(item);\n const data = args.length > 0 ? AbiParameters.encode(item.inputs, args) : undefined;\n return data ? Hex.concat(selector, data) : selector;\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function encodeResult(...parameters) {\n const [abiFunction, output, options = {}] = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name, output, options] = parameters;\n return [fromAbi(abi, name), output, options];\n }\n return parameters;\n })();\n const { as = 'Array' } = options;\n const values = (() => {\n if (abiFunction.outputs.length === 1)\n return [output];\n if (Array.isArray(output))\n return output;\n if (as === 'Object')\n return Object.values(output);\n return [output];\n })();\n return AbiParameters.encode(abiFunction.outputs, values);\n}\n/**\n * Formats an {@link ox#AbiFunction.AbiFunction} into a **Human Readable ABI Function**.\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const formatted = AbiFunction.format({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param abiFunction - The ABI Function to format.\n * @returns The formatted ABI Function.\n */\nexport function format(abiFunction) {\n return abitype.formatAbiItem(abiFunction);\n}\n/**\n * Parses an arbitrary **JSON ABI Function** or **Human Readable ABI Function** into a typed {@link ox#AbiFunction.AbiFunction}.\n *\n * @example\n * ### JSON ABIs\n *\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * approve\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable ABIs\n *\n * A Human Readable ABI can be parsed into a typed ABI object:\n *\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from(\n * 'function approve(address spender, uint256 amount) returns (bool)' // [!code hl]\n * )\n *\n * approve\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from([\n * 'struct Foo { address spender; uint256 amount; }', // [!code hl]\n * 'function approve(Foo foo) returns (bool)',\n * ])\n *\n * approve\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param abiFunction - The ABI Function to parse.\n * @returns Typed ABI Function.\n */\nexport function from(abiFunction, options = {}) {\n return AbiItem.from(abiFunction, options);\n}\n/**\n * Extracts an {@link ox#AbiFunction.AbiFunction} from an {@link ox#Abi.Abi} given a name and optional arguments.\n *\n * @example\n * ### Extracting by Name\n *\n * ABI Functions can be extracted by their name using the `name` option:\n *\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n *\n * const item = AbiFunction.fromAbi(abi, 'foo') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Extracting by Selector\n *\n * ABI Functions can be extract by their selector when {@link ox#Hex.Hex} is provided to `name`.\n *\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n * const item = AbiFunction.fromAbi(abi, '0x095ea7b3') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * :::note\n *\n * Extracting via a hex selector is useful when extracting an ABI Function from an `eth_call` RPC response or\n * from a Transaction `input`.\n *\n * :::\n *\n * @param abi - The ABI to extract from.\n * @param name - The name (or selector) of the ABI item to extract.\n * @param options - Extraction options.\n * @returns The ABI item.\n */\nexport function fromAbi(abi, name, options) {\n const item = AbiItem.fromAbi(abi, name, options);\n if (item.type !== 'function')\n throw new AbiItem.NotFoundError({ name, type: 'function' });\n return item;\n}\n/**\n * Computes the [4-byte selector](https://solidity-by-example.org/function-selector/) for an {@link ox#AbiFunction.AbiFunction}.\n *\n * Useful for computing function selectors for calldata.\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const selector = AbiFunction.getSelector('function ownerOf(uint256 tokenId)')\n * // @log: '0x6352211e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const selector = AbiFunction.getSelector({\n * inputs: [{ type: 'uint256' }],\n * name: 'ownerOf',\n * outputs: [],\n * stateMutability: 'view',\n * type: 'function'\n * })\n * // @log: '0x6352211e'\n * ```\n *\n * @param abiItem - The ABI item to compute the selector for.\n * @returns The first 4 bytes of the {@link ox#Hash.(keccak256:function)} hash of the function signature.\n */\nexport function getSelector(abiItem) {\n return AbiItem.getSelector(abiItem);\n}\n//# sourceMappingURL=AbiFunction.js.map"],"names":["encodeData","parameters","abiFunction","args","Array","isArray","abi","name","fromAbi","overloads","item","selector","getSelector","data","length","AbiParameters.encode","inputs","undefined","Hex.concat","from","options","AbiItem.from","AbiItem.fromAbi","type","AbiItem.NotFoundError","abiItem","AbiItem.getSelector"],"mappings":"mKA6CO,SAASA,KAAcC,GAC1B,MAAOC,EAAaC,EAAO,IAAM,MAC7B,GAAIC,MAAMC,QAAQJ,EAAW,IAAK,CAC9B,MAAOK,EAAKC,EAAMJ,GAAQF,EAC1B,MAAO,CAACO,EAAQF,EAAKC,EAAM,CAAEJ,SAASA,EAC1C,CACA,MAAOD,EAAaC,GAAQF,EAC5B,MAAO,CAACC,EAAaC,EACxB,EAPgC,IAQ3BM,UAAEA,GAAcP,EAChBQ,EAAOD,EACPD,EAAQ,CAACN,KAAgBO,GAAYP,EAAYK,KAAM,CACrDJ,SAEFD,EACAS,EAAWC,EAAYF,GACvBG,EAAOV,EAAKW,OAAS,EAAIC,EAAqBL,EAAKM,OAAQb,QAAQc,EACzE,OAAOJ,EAAOK,EAAWP,EAAUE,GAAQF,CAC/C,CAiKO,SAASQ,EAAKjB,EAAakB,EAAU,IACxC,OAAOC,EAAanB,EAAakB,EACrC,CAkEO,SAASZ,EAAQF,EAAKC,EAAMa,GAC/B,MAAMV,EAAOY,EAAgBhB,EAAKC,EAAMa,GACxC,GAAkB,aAAdV,EAAKa,KACL,MAAM,IAAIC,EAAsB,CAAEjB,OAAMgB,KAAM,aAClD,OAAOb,CACX,CA+BO,SAASE,EAAYa,GACxB,OAAOC,EAAoBD,EAC/B","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{BaseError as t}from"./Errors.js";import{keccak256 as e}from"./Hash.js";import{validate as n,slice as r,fromString as i}from"./Hex.js";import{isArgOfType as s,normalizeSignature as o,getAmbiguousTypes as a}from"./internal/abiItem.js";import{parseAbiItem as u}from"../../../abitype/dist/esm/human-readable/parseAbiItem.js";import{formatAbiItem as m}from"../../../abitype/dist/esm/human-readable/formatAbiItem.js";function f(t,e={}){const{prepare:n=!0}=e,r=Array.isArray(t)||"string"==typeof t?u(t):t;return{...r,...n?{hash:y(r)}:{}}}function p(t,e,i){const{args:o=[],prepare:u=!0}=i??{},m=n(e,{strict:!1}),f=t.filter(t=>m?"function"===t.type||"error"===t.type?c(t)===r(e,0,4):"event"===t.type&&y(t)===e:"name"in t&&t.name===e);if(0===f.length)throw new l({name:e});if(1===f.length)return{...f[0],...u?{hash:y(f[0])}:{}};let p;for(const t of f){if(!("inputs"in t))continue;if(!o||0===o.length){if(!t.inputs||0===t.inputs.length)return{...t,...u?{hash:y(t)}:{}};continue}if(!t.inputs)continue;if(0===t.inputs.length)continue;if(t.inputs.length!==o.length)continue;if(o.every((e,n)=>{const r="inputs"in t&&t.inputs[n];return!!r&&s(e,r)})){if(p&&"inputs"in p&&p.inputs){const e=a(t.inputs,p.inputs,o);if(e)throw new b({abiItem:t,type:e[0]},{abiItem:p,type:e[1]})}p=t}}const h=(()=>{if(p)return p;const[t,...e]=f;return{...t,overloads:e}})();if(!h)throw new l({name:e});return{...h,...u?{hash:y(h)}:{}}}function c(...t){const e=(()=>{if(Array.isArray(t[0])){const[e,n]=t;return p(e,n)}return t[0]})();return r(y(e),0,4)}function h(...t){const e=(()=>{if(Array.isArray(t[0])){const[e,n]=t;return p(e,n)}return t[0]})(),n="string"==typeof e?e:m(e);return o(n)}function y(...t){const n=(()=>{if(Array.isArray(t[0])){const[e,n]=t;return p(e,n)}return t[0]})();return"string"!=typeof n&&"hash"in n&&n.hash?n.hash:e(i(h(n)))}class b extends t{constructor(t,e){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${t.type}\` in \`${o(m(t.abiItem))}\`, and`,`\`${e.type}\` in \`${o(m(e.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class l extends t{constructor({name:t,data:e,type:n="item"}){super(`ABI ${n}${t?` with name "${t}"`:e?` with data "${e}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}export{b as AmbiguityError,l as NotFoundError,f as from,p as fromAbi,c as getSelector,h as getSignature,y as getSignatureHash};
|
|
2
|
+
//# sourceMappingURL=AbiItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbiItem.js","sources":["../../../../../../node_modules/ox/_esm/core/AbiItem.js"],"sourcesContent":["import * as abitype from 'abitype';\nimport * as Errors from './Errors.js';\nimport * as Hash from './Hash.js';\nimport * as Hex from './Hex.js';\nimport * as internal from './internal/abiItem.js';\n/**\n * Formats an {@link ox#AbiItem.AbiItem} into a **Human Readable ABI Item**.\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const formatted = AbiItem.format({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param abiItem - The ABI Item to format.\n * @returns The formatted ABI Item .\n */\nexport function format(abiItem) {\n return abitype.formatAbiItem(abiItem);\n}\n/**\n * Parses an arbitrary **JSON ABI Item** or **Human Readable ABI Item** into a typed {@link ox#AbiItem.AbiItem}.\n *\n * @example\n * ### JSON ABIs\n *\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const abiItem = AbiItem.from({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * abiItem\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable ABIs\n *\n * A Human Readable ABI can be parsed into a typed ABI object:\n *\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const abiItem = AbiItem.from(\n * 'function approve(address spender, uint256 amount) returns (bool)' // [!code hl]\n * )\n *\n * abiItem\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const abiItem = AbiItem.from([\n * 'struct Foo { address spender; uint256 amount; }', // [!code hl]\n * 'function approve(Foo foo) returns (bool)',\n * ])\n *\n * abiItem\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param abiItem - The ABI Item to parse.\n * @returns The typed ABI Item.\n */\nexport function from(abiItem, options = {}) {\n const { prepare = true } = options;\n const item = (() => {\n if (Array.isArray(abiItem))\n return abitype.parseAbiItem(abiItem);\n if (typeof abiItem === 'string')\n return abitype.parseAbiItem(abiItem);\n return abiItem;\n })();\n return {\n ...item,\n ...(prepare ? { hash: getSignatureHash(item) } : {}),\n };\n}\n/**\n * Extracts an {@link ox#AbiItem.AbiItem} from an {@link ox#Abi.Abi} given a name and optional arguments.\n *\n * @example\n * ABI Items can be extracted by their name using the `name` option:\n *\n * ```ts twoslash\n * import { Abi, AbiItem } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n *\n * const item = AbiItem.fromAbi(abi, 'Transfer') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Extracting by Selector\n *\n * ABI Items can be extract by their selector when {@link ox#Hex.Hex} is provided to `name`.\n *\n * ```ts twoslash\n * import { Abi, AbiItem } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n * const item = AbiItem.fromAbi(abi, '0x095ea7b3') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * :::note\n *\n * Extracting via a hex selector is useful when extracting an ABI Item from an `eth_call` RPC response,\n * a Transaction `input`, or from Event Log `topics`.\n *\n * :::\n *\n * @param abi - The ABI to extract from.\n * @param name - The name (or selector) of the ABI item to extract.\n * @param options - Extraction options.\n * @returns The ABI item.\n */\nexport function fromAbi(abi, name, options) {\n const { args = [], prepare = true } = (options ??\n {});\n const isSelector = Hex.validate(name, { strict: false });\n const abiItems = abi.filter((abiItem) => {\n if (isSelector) {\n if (abiItem.type === 'function' || abiItem.type === 'error')\n return getSelector(abiItem) === Hex.slice(name, 0, 4);\n if (abiItem.type === 'event')\n return getSignatureHash(abiItem) === name;\n return false;\n }\n return 'name' in abiItem && abiItem.name === name;\n });\n if (abiItems.length === 0)\n throw new NotFoundError({ name: name });\n if (abiItems.length === 1)\n return {\n ...abiItems[0],\n ...(prepare ? { hash: getSignatureHash(abiItems[0]) } : {}),\n };\n let matchedAbiItem;\n for (const abiItem of abiItems) {\n if (!('inputs' in abiItem))\n continue;\n if (!args || args.length === 0) {\n if (!abiItem.inputs || abiItem.inputs.length === 0)\n return {\n ...abiItem,\n ...(prepare ? { hash: getSignatureHash(abiItem) } : {}),\n };\n continue;\n }\n if (!abiItem.inputs)\n continue;\n if (abiItem.inputs.length === 0)\n continue;\n if (abiItem.inputs.length !== args.length)\n continue;\n const matched = args.every((arg, index) => {\n const abiParameter = 'inputs' in abiItem && abiItem.inputs[index];\n if (!abiParameter)\n return false;\n return internal.isArgOfType(arg, abiParameter);\n });\n if (matched) {\n // Check for ambiguity against already matched parameters (e.g. `address` vs `bytes20`).\n if (matchedAbiItem &&\n 'inputs' in matchedAbiItem &&\n matchedAbiItem.inputs) {\n const ambiguousTypes = internal.getAmbiguousTypes(abiItem.inputs, matchedAbiItem.inputs, args);\n if (ambiguousTypes)\n throw new AmbiguityError({\n abiItem,\n type: ambiguousTypes[0],\n }, {\n abiItem: matchedAbiItem,\n type: ambiguousTypes[1],\n });\n }\n matchedAbiItem = abiItem;\n }\n }\n const abiItem = (() => {\n if (matchedAbiItem)\n return matchedAbiItem;\n const [abiItem, ...overloads] = abiItems;\n return { ...abiItem, overloads };\n })();\n if (!abiItem)\n throw new NotFoundError({ name: name });\n return {\n ...abiItem,\n ...(prepare ? { hash: getSignatureHash(abiItem) } : {}),\n };\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function getSelector(...parameters) {\n const abiItem = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name] = parameters;\n return fromAbi(abi, name);\n }\n return parameters[0];\n })();\n return Hex.slice(getSignatureHash(abiItem), 0, 4);\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function getSignature(...parameters) {\n const abiItem = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name] = parameters;\n return fromAbi(abi, name);\n }\n return parameters[0];\n })();\n const signature = (() => {\n if (typeof abiItem === 'string')\n return abiItem;\n return abitype.formatAbiItem(abiItem);\n })();\n return internal.normalizeSignature(signature);\n}\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function getSignatureHash(...parameters) {\n const abiItem = (() => {\n if (Array.isArray(parameters[0])) {\n const [abi, name] = parameters;\n return fromAbi(abi, name);\n }\n return parameters[0];\n })();\n if (typeof abiItem !== 'string' && 'hash' in abiItem && abiItem.hash)\n return abiItem.hash;\n return Hash.keccak256(Hex.fromString(getSignature(abiItem)));\n}\n/**\n * Throws when ambiguous types are found on overloaded ABI items.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from(['function foo(address)', 'function foo(bytes20)'])\n * AbiFunction.fromAbi(foo, 'foo', {\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * })\n * // @error: AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.\n * // @error: `bytes20` in `foo(bytes20)`, and\n * // @error: `address` in `foo(address)`\n * // @error: These types encode differently and cannot be distinguished at runtime.\n * // @error: Remove one of the ambiguous items in the ABI.\n * ```\n *\n * ### Solution\n *\n * Remove one of the ambiguous types from the ABI.\n *\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function foo(bytes20)' // [!code --]\n * ])\n * AbiFunction.fromAbi(foo, 'foo', {\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * })\n * // @error: AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.\n * // @error: `bytes20` in `foo(bytes20)`, and\n * // @error: `address` in `foo(address)`\n * // @error: These types encode differently and cannot be distinguished at runtime.\n * // @error: Remove one of the ambiguous items in the ABI.\n * ```\n */\nexport class AmbiguityError extends Errors.BaseError {\n constructor(x, y) {\n super('Found ambiguous types in overloaded ABI Items.', {\n metaMessages: [\n // TODO: abitype to add support for signature-formatted ABI items.\n `\\`${x.type}\\` in \\`${internal.normalizeSignature(abitype.formatAbiItem(x.abiItem))}\\`, and`,\n `\\`${y.type}\\` in \\`${internal.normalizeSignature(abitype.formatAbiItem(y.abiItem))}\\``,\n '',\n 'These types encode differently and cannot be distinguished at runtime.',\n 'Remove one of the ambiguous items in the ABI.',\n ],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiItem.AmbiguityError'\n });\n }\n}\n/**\n * Throws when an ABI item is not found in the ABI.\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)'\n * ])\n * AbiFunction.fromAbi(foo, 'baz')\n * // @error: AbiItem.NotFoundError: ABI function with name \"baz\" not found.\n * ```\n *\n * ### Solution\n *\n * Ensure the ABI item exists on the ABI.\n *\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)',\n * 'function baz(bool)' // [!code ++]\n * ])\n * AbiFunction.fromAbi(foo, 'baz')\n * ```\n */\nexport class NotFoundError extends Errors.BaseError {\n constructor({ name, data, type = 'item', }) {\n const selector = (() => {\n if (name)\n return ` with name \"${name}\"`;\n if (data)\n return ` with data \"${data}\"`;\n return '';\n })();\n super(`ABI ${type}${selector} not found.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiItem.NotFoundError'\n });\n }\n}\n/**\n * Throws when the selector size is invalid.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)'\n * ])\n * AbiFunction.fromAbi(foo, '0xaaa')\n * // @error: AbiItem.InvalidSelectorSizeError: Selector size is invalid. Expected 4 bytes. Received 2 bytes (\"0xaaa\").\n * ```\n *\n * ### Solution\n *\n * Ensure the selector size is 4 bytes.\n *\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)'\n * ])\n * AbiFunction.fromAbi(foo, '0x7af82b1a')\n * ```\n */\nexport class InvalidSelectorSizeError extends Errors.BaseError {\n constructor({ data }) {\n super(`Selector size is invalid. Expected 4 bytes. Received ${Hex.size(data)} bytes (\"${data}\").`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiItem.InvalidSelectorSizeError'\n });\n }\n}\n//# sourceMappingURL=AbiItem.js.map"],"names":["from","abiItem","options","prepare","item","Array","isArray","abitype.parseAbiItem","hash","getSignatureHash","fromAbi","abi","name","args","isSelector","Hex.validate","strict","abiItems","filter","type","getSelector","Hex.slice","length","NotFoundError","matchedAbiItem","inputs","every","arg","index","abiParameter","internal.isArgOfType","ambiguousTypes","internal.getAmbiguousTypes","AmbiguityError","overloads","parameters","getSignature","signature","abitype.formatAbiItem","internal.normalizeSignature","Hash.keccak256","Hex.fromString","Errors.BaseError","constructor","x","y","super","metaMessages","Object","defineProperty","this","enumerable","configurable","writable","value","data"],"mappings":"kaAgJO,SAASA,EAAKC,EAASC,EAAU,IACpC,MAAMC,QAAEA,GAAU,GAASD,EACrBE,EACEC,MAAMC,QAAQL,IAEK,iBAAZA,EADAM,EAAqBN,GAGzBA,EAEX,MAAO,IACAG,KACCD,EAAU,CAAEK,KAAMC,EAAiBL,IAAU,GAEzD,CAoEO,SAASM,EAAQC,EAAKC,EAAMV,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eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVC,MAAO,0BAEf,EAkCG,MAAM/B,UAAsBmB,EAC/B,WAAAC,EAAY/B,KAAEA,EAAI2C,KAAEA,EAAIpC,KAAEA,EAAO,SAQ7B2B,MAAM,OAAO3B,IANLP,EACO,eAAeA,KACtB2C,EACO,eAAeA,KACnB,iBAGXP,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVC,MAAO,yBAEf","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{assert as e}from"./Address.js";import{fromHex as r,size as t}from"./Bytes.js";import{BaseError as s}from"./Errors.js";import{fromBytes as n,size as a,padLeft as o,fromString as i,fromBoolean as c,fromNumber as l,padRight as m,concat as u}from"./Hex.js";import{prepareParameters as h,encode as p,decodeParameter as d}from"./internal/abiParameters.js";import{create as f}from"./internal/cursor.js";import{integerRegex as b,bytesRegex as g,arrayRegex as y}from"./Solidity.js";import{parseAbiParameters as A}from"../../../abitype/dist/esm/human-readable/parseAbiParameters.js";import{formatAbiParameters as v}from"../../../abitype/dist/esm/human-readable/formatAbiParameters.js";function w(e,s,a={}){const{as:o="Array",checksumAddress:i=!1}=a,c="string"==typeof s?r(s):s,l=f(c);if(0===t(c)&&e.length>0)throw new z;if(t(c)&&t(c)<32)throw new $({data:"string"==typeof s?s:n(s),parameters:e,size:t(c)});let m=0;const u="Array"===o?[]:{};for(let r=0;r<e.length;++r){const t=e[r];l.setPosition(m);const[s,n]=d(l,t,{checksumAddress:i,staticPosition:0});m+=n,"Array"===o?u.push(s):u[t.name??r]=s}return u}function x(e,r,t){const{checksumAddress:s=!1}={};if(e.length!==r.length)throw new I({expectedLength:e.length,givenLength:r.length});const n=h({checksumAddress:s,parameters:e,values:r}),a=p(n);return 0===a.length?"0x":a}function P(e,r){if(e.length!==r.length)throw new I({expectedLength:e.length,givenLength:r.length});const t=[];for(let s=0;s<e.length;s++){const n=e[s],a=r[s];t.push(P.encode(n,a))}return u(...t)}function j(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?A(e):e}!function(r){r.encode=function r(t,s,n=!1){if("address"===t){const r=s;return e(r),o(r.toLowerCase(),n?32:0)}if("string"===t)return i(s);if("bytes"===t)return s;if("bool"===t)return o(c(s),n?32:1);const a=t.match(b);if(a){const[e,r,t="256"]=a,o=Number.parseInt(t,10)/8;return l(s,{size:n?32:o,signed:"int"===r})}const h=t.match(g);if(h){const[e,r]=h;if(Number.parseInt(r,10)!==(s.length-2)/2)throw new E({expectedSize:Number.parseInt(r,10),value:s});return m(s,n?32:0)}const p=t.match(y);if(p&&Array.isArray(s)){const[e,t]=p,n=[];for(let e=0;e<s.length;e++)n.push(r(t,s[e],!0));return 0===n.length?"0x":u(...n)}throw new S(t)}}(P||(P={}));class $ extends s{constructor({data:e,parameters:r,size:t}){super(`Data size of ${t} bytes is too small for given parameters.`,{metaMessages:[`Params: (${v(r)})`,`Data: ${e} (${t} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class z extends s{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class L extends s{constructor({expectedLength:e,givenLength:r,type:t}){super(`Array length mismatch for type \`${t}\`. Expected: \`${e}\`. Given: \`${r}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class E extends s{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${a(r)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class I extends s{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${r}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class O extends s{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class S extends s{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}export{L as ArrayLengthMismatchError,E as BytesSizeMismatchError,$ as DataSizeTooSmallError,O as InvalidArrayError,S as InvalidTypeError,I as LengthMismatchError,z as ZeroDataError,w as decode,x as encode,P as encodePacked,j as from};
|
|
2
|
+
//# sourceMappingURL=AbiParameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbiParameters.js","sources":["../../../../../../node_modules/ox/_esm/core/AbiParameters.js"],"sourcesContent":["import * as abitype from 'abitype';\nimport * as Address from './Address.js';\nimport * as Bytes from './Bytes.js';\nimport * as Errors from './Errors.js';\nimport * as Hex from './Hex.js';\nimport * as internal from './internal/abiParameters.js';\nimport * as Cursor from './internal/cursor.js';\nimport * as Solidity from './Solidity.js';\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function decode(parameters, data, options = {}) {\n const { as = 'Array', checksumAddress = false } = options;\n const bytes = typeof data === 'string' ? Bytes.fromHex(data) : data;\n const cursor = Cursor.create(bytes);\n if (Bytes.size(bytes) === 0 && parameters.length > 0)\n throw new ZeroDataError();\n if (Bytes.size(bytes) && Bytes.size(bytes) < 32)\n throw new DataSizeTooSmallError({\n data: typeof data === 'string' ? data : Hex.fromBytes(data),\n parameters: parameters,\n size: Bytes.size(bytes),\n });\n let consumed = 0;\n const values = as === 'Array' ? [] : {};\n for (let i = 0; i < parameters.length; ++i) {\n const param = parameters[i];\n cursor.setPosition(consumed);\n const [data, consumed_] = internal.decodeParameter(cursor, param, {\n checksumAddress,\n staticPosition: 0,\n });\n consumed += consumed_;\n if (as === 'Array')\n values.push(data);\n else\n values[param.name ?? i] = data;\n }\n return values;\n}\n/**\n * Encodes primitive values into ABI encoded data as per the [Application Binary Interface (ABI) Specification](https://docs.soliditylang.org/en/latest/abi-spec).\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const data = AbiParameters.encode(\n * AbiParameters.from(['string', 'uint', 'bool']),\n * ['wagmi', 420n, true],\n * )\n * ```\n *\n * @example\n * ### JSON Parameters\n *\n * Specify **JSON ABI** Parameters as schema:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const data = AbiParameters.encode(\n * [\n * { type: 'string', name: 'name' },\n * { type: 'uint', name: 'age' },\n * { type: 'bool', name: 'isOwner' },\n * ],\n * ['wagmi', 420n, true],\n * )\n * ```\n *\n * @param parameters - The set of ABI parameters to encode, in the shape of the `inputs` or `outputs` attribute of an ABI Item. These parameters must include valid [ABI types](https://docs.soliditylang.org/en/latest/types.html).\n * @param values - The set of primitive values that correspond to the ABI types defined in `parameters`.\n * @returns ABI encoded data.\n */\nexport function encode(parameters, values, options) {\n const { checksumAddress = false } = options ?? {};\n if (parameters.length !== values.length)\n throw new LengthMismatchError({\n expectedLength: parameters.length,\n givenLength: values.length,\n });\n // Prepare the parameters to determine dynamic types to encode.\n const preparedParameters = internal.prepareParameters({\n checksumAddress,\n parameters: parameters,\n values: values,\n });\n const data = internal.encode(preparedParameters);\n if (data.length === 0)\n return '0x';\n return data;\n}\n/**\n * Encodes an array of primitive values to a [packed ABI encoding](https://docs.soliditylang.org/en/latest/abi-spec.html#non-standard-packed-mode).\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const encoded = AbiParameters.encodePacked(\n * ['address', 'string'],\n * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 'hello world'],\n * )\n * // @log: '0xd8da6bf26964af9d7eed9e03e53415d37aa9604568656c6c6f20776f726c64'\n * ```\n *\n * @param types - Set of ABI types to pack encode.\n * @param values - The set of primitive values that correspond to the ABI types defined in `types`.\n * @returns The encoded packed data.\n */\nexport function encodePacked(types, values) {\n if (types.length !== values.length)\n throw new LengthMismatchError({\n expectedLength: types.length,\n givenLength: values.length,\n });\n const data = [];\n for (let i = 0; i < types.length; i++) {\n const type = types[i];\n const value = values[i];\n data.push(encodePacked.encode(type, value));\n }\n return Hex.concat(...data);\n}\n(function (encodePacked) {\n // eslint-disable-next-line jsdoc/require-jsdoc\n function encode(type, value, isArray = false) {\n if (type === 'address') {\n const address = value;\n Address.assert(address);\n return Hex.padLeft(address.toLowerCase(), isArray ? 32 : 0);\n }\n if (type === 'string')\n return Hex.fromString(value);\n if (type === 'bytes')\n return value;\n if (type === 'bool')\n return Hex.padLeft(Hex.fromBoolean(value), isArray ? 32 : 1);\n const intMatch = type.match(Solidity.integerRegex);\n if (intMatch) {\n const [_type, baseType, bits = '256'] = intMatch;\n const size = Number.parseInt(bits, 10) / 8;\n return Hex.fromNumber(value, {\n size: isArray ? 32 : size,\n signed: baseType === 'int',\n });\n }\n const bytesMatch = type.match(Solidity.bytesRegex);\n if (bytesMatch) {\n const [_type, size] = bytesMatch;\n if (Number.parseInt(size, 10) !== (value.length - 2) / 2)\n throw new BytesSizeMismatchError({\n expectedSize: Number.parseInt(size, 10),\n value: value,\n });\n return Hex.padRight(value, isArray ? 32 : 0);\n }\n const arrayMatch = type.match(Solidity.arrayRegex);\n if (arrayMatch && Array.isArray(value)) {\n const [_type, childType] = arrayMatch;\n const data = [];\n for (let i = 0; i < value.length; i++) {\n data.push(encode(childType, value[i], true));\n }\n if (data.length === 0)\n return '0x';\n return Hex.concat(...data);\n }\n throw new InvalidTypeError(type);\n }\n encodePacked.encode = encode;\n})(encodePacked || (encodePacked = {}));\n/**\n * Formats {@link ox#AbiParameters.AbiParameters} into **Human Readable ABI Parameters**.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const formatted = AbiParameters.format([\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ])\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param parameters - The ABI Parameters to format.\n * @returns The formatted ABI Parameters .\n */\nexport function format(parameters) {\n return abitype.formatAbiParameters(parameters);\n}\n/**\n * Parses arbitrary **JSON ABI Parameters** or **Human Readable ABI Parameters** into typed {@link ox#AbiParameters.AbiParameters}.\n *\n * @example\n * ### JSON Parameters\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const parameters = AbiParameters.from([\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ])\n *\n * parameters\n * //^?\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable Parameters\n *\n * Human Readable ABI Parameters can be parsed into a typed {@link ox#AbiParameters.AbiParameters}:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const parameters = AbiParameters.from('address spender, uint256 amount')\n *\n * parameters\n * //^?\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const parameters = AbiParameters.from([\n * 'struct Foo { address spender; uint256 amount; }', // [!code hl]\n * 'Foo foo, address bar',\n * ])\n *\n * parameters\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param parameters - The ABI Parameters to parse.\n * @returns The typed ABI Parameters.\n */\nexport function from(parameters) {\n if (Array.isArray(parameters) && typeof parameters[0] === 'string')\n return abitype.parseAbiParameters(parameters);\n if (typeof parameters === 'string')\n return abitype.parseAbiParameters(parameters);\n return parameters;\n}\n/**\n * Throws when the data size is too small for the given parameters.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x010f')\n * // ↑ ❌ 2 bytes\n * // @error: AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters.\n * // @error: Params: (uint256)\n * // @error: Data: 0x010f (2 bytes)\n * ```\n *\n * ### Solution\n *\n * Pass a valid data size.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x00000000000000000000000000000000000000000000000000000000000010f')\n * // ↑ ✅ 32 bytes\n * ```\n */\nexport class DataSizeTooSmallError extends Errors.BaseError {\n constructor({ data, parameters, size, }) {\n super(`Data size of ${size} bytes is too small for given parameters.`, {\n metaMessages: [\n `Params: (${abitype.formatAbiParameters(parameters)})`,\n `Data: ${data} (${size} bytes)`,\n ],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.DataSizeTooSmallError'\n });\n }\n}\n/**\n * Throws when zero data is provided, but data is expected.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x')\n * // ↑ ❌ zero data\n * // @error: AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters.\n * // @error: Params: (uint256)\n * // @error: Data: 0x010f (2 bytes)\n * ```\n *\n * ### Solution\n *\n * Pass valid data.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x00000000000000000000000000000000000000000000000000000000000010f')\n * // ↑ ✅ 32 bytes\n * ```\n */\nexport class ZeroDataError extends Errors.BaseError {\n constructor() {\n super('Cannot decode zero data (\"0x\") with ABI parameters.');\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.ZeroDataError'\n });\n }\n}\n/**\n * The length of the array value does not match the length specified in the corresponding ABI parameter.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from('uint256[3]'), [[69n, 420n]])\n * // ↑ expected: 3 ↑ ❌ length: 2\n * // @error: AbiParameters.ArrayLengthMismatchError: ABI encoding array length mismatch\n * // @error: for type `uint256[3]`. Expected: `3`. Given: `2`.\n * ```\n *\n * ### Solution\n *\n * Pass an array of the correct length.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['uint256[3]']), [[69n, 420n, 69n]])\n * // ↑ ✅ length: 3\n * ```\n */\nexport class ArrayLengthMismatchError extends Errors.BaseError {\n constructor({ expectedLength, givenLength, type, }) {\n super(`Array length mismatch for type \\`${type}\\`. Expected: \\`${expectedLength}\\`. Given: \\`${givenLength}\\`.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.ArrayLengthMismatchError'\n });\n }\n}\n/**\n * The size of the bytes value does not match the size specified in the corresponding ABI parameter.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from('bytes8'), [['0xdeadbeefdeadbeefdeadbeef']])\n * // ↑ expected: 8 bytes ↑ ❌ size: 12 bytes\n * // @error: BytesSizeMismatchError: Size of bytes \"0xdeadbeefdeadbeefdeadbeef\"\n * // @error: (bytes12) does not match expected size (bytes8).\n * ```\n *\n * ### Solution\n *\n * Pass a bytes value of the correct size.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['bytes8']), ['0xdeadbeefdeadbeef'])\n * // ↑ ✅ size: 8 bytes\n * ```\n */\nexport class BytesSizeMismatchError extends Errors.BaseError {\n constructor({ expectedSize, value, }) {\n super(`Size of bytes \"${value}\" (bytes${Hex.size(value)}) does not match expected size (bytes${expectedSize}).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.BytesSizeMismatchError'\n });\n }\n}\n/**\n * The length of the values to encode does not match the length of the ABI parameters.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['string', 'uint256']), ['hello'])\n * // @error: LengthMismatchError: ABI encoding params/values length mismatch.\n * // @error: Expected length (params): 2\n * // @error: Given length (values): 1\n * ```\n *\n * ### Solution\n *\n * Pass the correct number of values to encode.\n *\n * ### Solution\n *\n * Pass a [valid ABI type](https://docs.soliditylang.org/en/develop/abi-spec.html#types).\n */\nexport class LengthMismatchError extends Errors.BaseError {\n constructor({ expectedLength, givenLength, }) {\n super([\n 'ABI encoding parameters/values length mismatch.',\n `Expected length (parameters): ${expectedLength}`,\n `Given length (values): ${givenLength}`,\n ].join('\\n'));\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.LengthMismatchError'\n });\n }\n}\n/**\n * The value provided is not a valid array as specified in the corresponding ABI parameter.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['uint256[3]']), [69])\n * ```\n *\n * ### Solution\n *\n * Pass an array value.\n */\nexport class InvalidArrayError extends Errors.BaseError {\n constructor(value) {\n super(`Value \\`${value}\\` is not a valid array.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.InvalidArrayError'\n });\n }\n}\n/**\n * Throws when the ABI parameter type is invalid.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'lol' }], '0x00000000000000000000000000000000000000000000000000000000000010f')\n * // ↑ ❌ invalid type\n * // @error: AbiParameters.InvalidTypeError: Type `lol` is not a valid ABI Type.\n * ```\n */\nexport class InvalidTypeError extends Errors.BaseError {\n constructor(type) {\n super(`Type \\`${type}\\` is not a valid ABI Type.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'AbiParameters.InvalidTypeError'\n });\n }\n}\n//# sourceMappingURL=AbiParameters.js.map"],"names":["decode","parameters","data","options","as","checksumAddress","bytes","Bytes.fromHex","cursor","Cursor.create","Bytes.size","length","ZeroDataError","DataSizeTooSmallError","Hex.fromBytes","size","consumed","values","i","param","setPosition","consumed_","internal.decodeParameter","staticPosition","push","name","encode","LengthMismatchError","expectedLength","givenLength","preparedParameters","internal.prepareParameters","internal.encode","encodePacked","types","type","value","Hex.concat","from","Array","isArray","abitype.parseAbiParameters","address","Address.assert","Hex.padLeft","toLowerCase","Hex.fromString","Hex.fromBoolean","intMatch","match","Solidity.integerRegex","_type","baseType","bits","Number","parseInt","Hex.fromNumber","signed","bytesMatch","Solidity.bytesRegex","BytesSizeMismatchError","expectedSize","Hex.padRight","arrayMatch","Solidity.arrayRegex","childType","InvalidTypeError","Errors.BaseError","constructor","super","metaMessages","abitype.formatAbiParameters","Object","defineProperty","this","enumerable","configurable","writable","ArrayLengthMismatchError","Hex.size","join","InvalidArrayError"],"mappings":"0qBASO,SAASA,EAAOC,EAAYC,EAAMC,EAAU,CAAA,GAC/C,MAAMC,GAAEA,EAAK,QAAOC,gBAAEA,GAAkB,GAAUF,EAC5CG,EAAwB,iBAATJ,EAAoBK,EAAcL,GAAQA,EACzDM,EAASC,EAAcH,GAC7B,GAA0B,IAAtBI,EAAWJ,IAAgBL,EAAWU,OAAS,EAC/C,MAAM,IAAIC,EACd,GAAIF,EAAWJ,IAAUI,EAAWJ,GAAS,GACzC,MAAM,IAAIO,EAAsB,CAC5BX,KAAsB,iBAATA,EAAoBA,EAAOY,EAAcZ,GACtDD,WAAYA,EACZc,KAAML,EAAWJ,KAEzB,IAAIU,EAAW,EACf,MAAMC,EAAgB,UAAPb,EAAiB,GAAK,CAAA,EACrC,IAAK,IAAIc,EAAI,EAAGA,EAAIjB,EAAWU,SAAUO,EAAG,CACxC,MAAMC,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e}from"./Bytes.js";import{checksum as r}from"./Caches.js";import{BaseError as s}from"./Errors.js";import{keccak256 as t}from"./Hash.js";const a=/^0x[a-fA-F0-9]{40}$/;function n(e,r={}){const{strict:s=!0}=r;if(!a.test(e))throw new i({address:e,cause:new u});if(s){if(e.toLowerCase()===e)return;if(o(e)!==e)throw new i({address:e,cause:new d})}}function o(s){if(r.has(s))return r.get(s);n(s,{strict:!1});const a=s.substring(2).toLowerCase(),o=t(e(a),{as:"Bytes"}),c=a.split("");for(let e=0;e<40;e+=2)o[e>>1]>>4>=8&&c[e]&&(c[e]=c[e].toUpperCase()),(15&o[e>>1])>=8&&c[e+1]&&(c[e+1]=c[e+1].toUpperCase());const i=`0x${c.join("")}`;return r.set(s,i),i}function c(e,r={}){const{strict:s=!0}=r??{};try{return n(e,{strict:s}),!0}catch{return!1}}class i extends s{constructor({address:e,cause:r}){super(`Address "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class u extends s{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class d extends s{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}export{i as InvalidAddressError,d as InvalidChecksumError,u as InvalidInputError,n as assert,o as checksum,c as validate};
|
|
2
|
+
//# sourceMappingURL=Address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Address.js","sources":["../../../../../../node_modules/ox/_esm/core/Address.js"],"sourcesContent":["import * as Bytes from './Bytes.js';\nimport * as Caches from './Caches.js';\nimport * as Errors from './Errors.js';\nimport * as Hash from './Hash.js';\nimport * as PublicKey from './PublicKey.js';\nconst addressRegex = /^0x[a-fA-F0-9]{40}$/;\n/**\n * Asserts that the given value is a valid {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.assert('0xA0Cf798816D4b9b9866b5330EEa46a18382f251e')\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.assert('0xdeadbeef')\n * // @error: InvalidAddressError: Address \"0xdeadbeef\" is invalid.\n * ```\n *\n * @param value - Value to assert if it is a valid address.\n * @param options - Assertion options.\n */\nexport function assert(value, options = {}) {\n const { strict = true } = options;\n if (!addressRegex.test(value))\n throw new InvalidAddressError({\n address: value,\n cause: new InvalidInputError(),\n });\n if (strict) {\n if (value.toLowerCase() === value)\n return;\n if (checksum(value) !== value)\n throw new InvalidAddressError({\n address: value,\n cause: new InvalidChecksumError(),\n });\n }\n}\n/**\n * Computes the checksum address for the given {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.checksum('0xa0cf798816d4b9b9866b5330eea46a18382f251e')\n * // @log: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'\n * ```\n *\n * @param address - The address to compute the checksum for.\n * @returns The checksummed address.\n */\nexport function checksum(address) {\n if (Caches.checksum.has(address))\n return Caches.checksum.get(address);\n assert(address, { strict: false });\n const hexAddress = address.substring(2).toLowerCase();\n const hash = Hash.keccak256(Bytes.fromString(hexAddress), { as: 'Bytes' });\n const characters = hexAddress.split('');\n for (let i = 0; i < 40; i += 2) {\n if (hash[i >> 1] >> 4 >= 8 && characters[i]) {\n characters[i] = characters[i].toUpperCase();\n }\n if ((hash[i >> 1] & 0x0f) >= 8 && characters[i + 1]) {\n characters[i + 1] = characters[i + 1].toUpperCase();\n }\n }\n const result = `0x${characters.join('')}`;\n Caches.checksum.set(address, result);\n return result;\n}\n/**\n * Converts a stringified address to a typed (checksummed) {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('0xa0cf798816d4b9b9866b5330eea46a18382f251e')\n * // @log: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('0xa0cf798816d4b9b9866b5330eea46a18382f251e', {\n * checksum: false\n * })\n * // @log: '0xa0cf798816d4b9b9866b5330eea46a18382f251e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('hello')\n * // @error: InvalidAddressError: Address \"0xa\" is invalid.\n * ```\n *\n * @param address - An address string to convert to a typed Address.\n * @param options - Conversion options.\n * @returns The typed Address.\n */\nexport function from(address, options = {}) {\n const { checksum: checksumVal = false } = options;\n assert(address);\n if (checksumVal)\n return checksum(address);\n return address;\n}\n/**\n * Converts an ECDSA public key to an {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address, PublicKey } from 'ox'\n *\n * const publicKey = PublicKey.from(\n * '0x048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5',\n * )\n * const address = Address.fromPublicKey(publicKey)\n * // @log: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'\n * ```\n *\n * @param publicKey - The ECDSA public key to convert to an {@link ox#Address.Address}.\n * @param options - Conversion options.\n * @returns The {@link ox#Address.Address} corresponding to the public key.\n */\nexport function fromPublicKey(publicKey, options = {}) {\n const address = Hash.keccak256(`0x${PublicKey.toHex(publicKey).slice(4)}`).substring(26);\n return from(`0x${address}`, options);\n}\n/**\n * Checks if two {@link ox#Address.Address} are equal.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.isEqual(\n * '0xa0cf798816d4b9b9866b5330eea46a18382f251e',\n * '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'\n * )\n * // @log: true\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.isEqual(\n * '0xa0cf798816d4b9b9866b5330eea46a18382f251e',\n * '0xA0Cf798816D4b9b9866b5330EEa46a18382f251f'\n * )\n * // @log: false\n * ```\n *\n * @param addressA - The first address to compare.\n * @param addressB - The second address to compare.\n * @returns Whether the addresses are equal.\n */\nexport function isEqual(addressA, addressB) {\n assert(addressA, { strict: false });\n assert(addressB, { strict: false });\n return addressA.toLowerCase() === addressB.toLowerCase();\n}\n/**\n * Checks if the given address is a valid {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.validate('0xA0Cf798816D4b9b9866b5330EEa46a18382f251e')\n * // @log: true\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.validate('0xdeadbeef')\n * // @log: false\n * ```\n *\n * @param address - Value to check if it is a valid address.\n * @param options - Check options.\n * @returns Whether the address is a valid address.\n */\nexport function validate(address, options = {}) {\n const { strict = true } = options ?? {};\n try {\n assert(address, { strict });\n return true;\n }\n catch {\n return false;\n }\n}\n/**\n * Thrown when an address is invalid.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('0x123')\n * // @error: Address.InvalidAddressError: Address `0x123` is invalid.\n * ```\n */\nexport class InvalidAddressError extends Errors.BaseError {\n constructor({ address, cause }) {\n super(`Address \"${address}\" is invalid.`, {\n cause,\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Address.InvalidAddressError'\n });\n }\n}\n/** Thrown when an address is not a 20 byte (40 hexadecimal character) value. */\nexport class InvalidInputError extends Errors.BaseError {\n constructor() {\n super('Address is not a 20 byte (40 hexadecimal character) value.');\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Address.InvalidInputError'\n });\n }\n}\n/** Thrown when an address does not match its checksum counterpart. */\nexport class InvalidChecksumError extends Errors.BaseError {\n constructor() {\n super('Address does not match its checksum counterpart.');\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Address.InvalidChecksumError'\n });\n }\n}\n//# sourceMappingURL=Address.js.map"],"names":["addressRegex","assert","value","options","strict","test","InvalidAddressError","address","cause","InvalidInputError","toLowerCase","checksum","InvalidChecksumError","Caches.checksum","has","get","hexAddress","substring","hash","Hash.keccak256","Bytes.fromString","as","characters","split","i","toUpperCase","result","join","set","validate","Errors.BaseError","constructor","super","Object","defineProperty","this","enumerable","configurable","writable"],"mappings":"6JAKA,MAAMA,EAAe,sBAsBd,SAASC,EAAOC,EAAOC,EAAU,IACpC,MAAMC,OAAEA,GAAS,GAASD,EAC1B,IAAKH,EAAaK,KAAKH,GACnB,MAAM,IAAII,EAAoB,CAC1BC,QAASL,EACTM,MAAO,IAAIC,IAEnB,GAAIL,EAAQ,CACR,GAAIF,EAAMQ,gBAAkBR,EACxB,OACJ,GAAIS,EAAST,KAAWA,EACpB,MAAM,IAAII,EAAoB,CAC1BC,QAASL,EACTM,MAAO,IAAII,GAEvB,CACJ,CAeO,SAASD,EAASJ,GACrB,GAAIM,EAAgBC,IAAIP,GACpB,OAAOM,EAAgBE,IAAIR,GAC/BN,EAAOM,EAAS,CAAEH,QAAQ,IAC1B,MAAMY,EAAaT,EAAQU,UAAU,GAAGP,cAClCQ,EAAOC,EAAeC,EAAiBJ,GAAa,CAAEK,GAAI,UAC1DC,EAAaN,EAAWO,MAAM,IACpC,IAAK,IAAIC,EAAI,EAAGA,EAAI,GAAIA,GAAK,EACrBN,EAAKM,GAAK,IAAM,GAAK,GAAKF,EAAWE,KACrCF,EAAWE,GAAKF,EAAWE,GAAGC,gBAEd,GAAfP,EAAKM,GAAK,KAAc,GAAKF,EAAWE,EAAI,KAC7CF,EAAWE,EAAI,GAAKF,EAAWE,EAAI,GAAGC,eAG9C,MAAMC,EAAS,KAAKJ,EAAWK,KAAK,MAEpC,OADAd,EAAgBe,IAAIrB,EAASmB,GACtBA,CACX,CAwHO,SAASG,EAAStB,EAASJ,EAAU,IACxC,MAAMC,OAAEA,GAAS,GAASD,GAAW,CAAA,EACrC,IAEI,OADAF,EAAOM,EAAS,CAAEH,YACX,CACX,CACA,MACI,OAAO,CACX,CACJ,CAYO,MAAME,UAA4BwB,EACrC,WAAAC,EAAYxB,QAAEA,EAAOC,MAAEA,IACnBwB,MAAM,YAAYzB,iBAAwB,CACtCC,UAEJyB,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVpC,MAAO,+BAEf,EAGG,MAAMO,UAA0BqB,EACnC,WAAAC,GACIC,MAAM,8DACNC,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVpC,MAAO,6BAEf,EAGG,MAAMU,UAA6BkB,EACtC,WAAAC,GACIC,MAAM,oDACNC,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVpC,MAAO,gCAEf","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{extract as n}from"./Signature.js";function r(n,r={}){return"string"==typeof n.chainId?t(n):{...n,...r.signature}}function t(r){const{address:t,chainId:e,nonce:i}=r,o=n(r);return{address:t,chainId:Number(e),nonce:BigInt(i),...o}}export{r as from,t as fromRpc};
|
|
2
|
+
//# sourceMappingURL=Authorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authorization.js","sources":["../../../../../../node_modules/ox/_esm/core/Authorization.js"],"sourcesContent":["import * as Hash from './Hash.js';\nimport * as Hex from './Hex.js';\nimport * as Rlp from './Rlp.js';\nimport * as Signature from './Signature.js';\n/**\n * Converts an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization object into a typed {@link ox#Authorization.Authorization}.\n *\n * @example\n * An Authorization can be instantiated from an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple in object format.\n *\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.from({\n * address: '0x1234567890abcdef1234567890abcdef12345678',\n * chainId: 1,\n * nonce: 69n,\n * })\n * ```\n *\n * @example\n * ### Attaching Signatures\n *\n * A {@link ox#Signature.Signature} can be attached with the `signature` option. The example below demonstrates signing\n * an Authorization with {@link ox#Secp256k1.(sign:function)}.\n *\n * ```ts twoslash\n * import { Authorization, Secp256k1 } from 'ox'\n *\n * const authorization = Authorization.from({\n * address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * chainId: 1,\n * nonce: 40n,\n * })\n *\n * const signature = Secp256k1.sign({\n * payload: Authorization.getSignPayload(authorization),\n * privateKey: '0x...',\n * })\n *\n * const authorization_signed = Authorization.from(authorization, { signature }) // [!code focus]\n * ```\n *\n * @param authorization - An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple in object format.\n * @param options - Authorization options.\n * @returns The {@link ox#Authorization.Authorization}.\n */\nexport function from(authorization, options = {}) {\n if (typeof authorization.chainId === 'string')\n return fromRpc(authorization);\n return { ...authorization, ...options.signature };\n}\n/**\n * Converts an {@link ox#Authorization.Rpc} to an {@link ox#Authorization.Authorization}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.fromRpc({\n * address: '0x0000000000000000000000000000000000000000',\n * chainId: '0x1',\n * nonce: '0x1',\n * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',\n * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',\n * yParity: '0x0',\n * })\n * ```\n *\n * @param authorization - The RPC-formatted Authorization.\n * @returns A signed {@link ox#Authorization.Authorization}.\n */\nexport function fromRpc(authorization) {\n const { address, chainId, nonce } = authorization;\n const signature = Signature.extract(authorization);\n return {\n address,\n chainId: Number(chainId),\n nonce: BigInt(nonce),\n ...signature,\n };\n}\n/**\n * Converts an {@link ox#Authorization.ListRpc} to an {@link ox#Authorization.List}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorizationList = Authorization.fromRpcList([{\n * address: '0x0000000000000000000000000000000000000000',\n * chainId: '0x1',\n * nonce: '0x1',\n * r: '0x635dc2033e60185bb36709c29c75d64ea51dfbd91c32ef4be198e4ceb169fb4d',\n * s: '0x50c2667ac4c771072746acfdcf1f1483336dcca8bd2df47cd83175dbe60f0540',\n * yParity: '0x0',\n * }])\n * ```\n *\n * @param authorizationList - The RPC-formatted Authorization list.\n * @returns A signed {@link ox#Authorization.List}.\n */\nexport function fromRpcList(authorizationList) {\n return authorizationList.map(fromRpc);\n}\n/**\n * Converts an {@link ox#Authorization.Tuple} to an {@link ox#Authorization.Authorization}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.fromTuple([\n * '0x1',\n * '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * '0x3'\n * ])\n * // @log: {\n * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * // @log: chainId: 1,\n * // @log: nonce: 3n\n * // @log: }\n * ```\n *\n * @example\n * It is also possible to append a Signature tuple to the end of an Authorization tuple.\n *\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.fromTuple([\n * '0x1',\n * '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * '0x3',\n * '0x1',\n * '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90',\n * '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064',\n * ])\n * // @log: {\n * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * // @log: chainId: 1,\n * // @log: nonce: 3n\n * // @log: r: BigInt('0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90'),\n * // @log: s: BigInt('0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'),\n * // @log: yParity: 0,\n * // @log: }\n * ```\n *\n * @param tuple - The [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple.\n * @returns The {@link ox#Authorization.Authorization}.\n */\nexport function fromTuple(tuple) {\n const [chainId, address, nonce, yParity, r, s] = tuple;\n let args = {\n address,\n chainId: chainId === '0x' ? 0 : Number(chainId),\n nonce: nonce === '0x' ? 0n : BigInt(nonce),\n };\n if (yParity && r && s)\n args = { ...args, ...Signature.fromTuple([yParity, r, s]) };\n return from(args);\n}\n/**\n * Converts an {@link ox#Authorization.TupleList} to an {@link ox#Authorization.List}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorizationList = Authorization.fromTupleList([\n * ['0x1', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x3'],\n * ['0x3', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x14'],\n * ])\n * // @log: [\n * // @log: {\n * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * // @log: chainId: 1,\n * // @log: nonce: 3n,\n * // @log: },\n * // @log: {\n * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * // @log: chainId: 3,\n * // @log: nonce: 20n,\n * // @log: },\n * // @log: ]\n * ```\n *\n * @example\n * It is also possible to append a Signature tuple to the end of an Authorization tuple.\n *\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorizationList = Authorization.fromTupleList([\n * ['0x1', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x3', '0x1', '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90', '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'],\n * ['0x3', '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c', '0x14', '0x1', '0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90', '0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'],\n * ])\n * // @log: [\n * // @log: {\n * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * // @log: chainId: 1,\n * // @log: nonce: 3n,\n * // @log: r: BigInt('0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90'),\n * // @log: s: BigInt('0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'),\n * // @log: yParity: 0,\n * // @log: },\n * // @log: {\n * // @log: address: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',\n * // @log: chainId: 3,\n * // @log: nonce: 20n,\n * // @log: r: BigInt('0x68a020a209d3d56c46f38cc50a33f704f4a9a10a59377f8dd762ac66910e9b90'),\n * // @log: s: BigInt('0x7e865ad05c4035ab5792787d4a0297a43617ae897930a6fe4d822b8faea52064'),\n * // @log: yParity: 0,\n * // @log: },\n * // @log: ]\n * ```\n *\n * @param tupleList - The [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple list.\n * @returns An {@link ox#Authorization.List}.\n */\nexport function fromTupleList(tupleList) {\n const list = [];\n for (const tuple of tupleList)\n list.push(fromTuple(tuple));\n return list;\n}\n/**\n * Computes the sign payload for an {@link ox#Authorization.Authorization} in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.\n *\n * @example\n * The example below demonstrates computing the sign payload for an {@link ox#Authorization.Authorization}. This payload\n * can then be passed to signing functions like {@link ox#Secp256k1.(sign:function)}.\n *\n * ```ts twoslash\n * import { Authorization, Secp256k1 } from 'ox'\n *\n * const authorization = Authorization.from({\n * address: '0x1234567890abcdef1234567890abcdef12345678',\n * chainId: 1,\n * nonce: 69n,\n * })\n *\n * const payload = Authorization.getSignPayload(authorization) // [!code focus]\n *\n * const signature = Secp256k1.sign({\n * payload,\n * privateKey: '0x...',\n * })\n * ```\n *\n * @param authorization - The {@link ox#Authorization.Authorization}.\n * @returns The sign payload.\n */\nexport function getSignPayload(authorization) {\n return hash(authorization, { presign: true });\n}\n/**\n * Computes the hash for an {@link ox#Authorization.Authorization} in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.from({\n * address: '0x1234567890abcdef1234567890abcdef12345678',\n * chainId: 1,\n * nonce: 69n,\n * })\n *\n * const hash = Authorization.hash(authorization) // [!code focus]\n * ```\n *\n * @param authorization - The {@link ox#Authorization.Authorization}.\n * @returns The hash.\n */\nexport function hash(authorization, options = {}) {\n const { presign } = options;\n return Hash.keccak256(Hex.concat('0x05', Rlp.fromHex(toTuple(presign\n ? {\n address: authorization.address,\n chainId: authorization.chainId,\n nonce: authorization.nonce,\n }\n : authorization))));\n}\n/**\n * Converts an {@link ox#Authorization.Authorization} to an {@link ox#Authorization.Rpc}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.toRpc({\n * address: '0x0000000000000000000000000000000000000000',\n * chainId: 1,\n * nonce: 1n,\n * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,\n * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,\n * yParity: 0,\n * })\n * ```\n *\n * @param authorization - An Authorization.\n * @returns An RPC-formatted Authorization.\n */\nexport function toRpc(authorization) {\n const { address, chainId, nonce, ...signature } = authorization;\n return {\n address,\n chainId: Hex.fromNumber(chainId),\n nonce: Hex.fromNumber(nonce),\n ...Signature.toRpc(signature),\n };\n}\n/**\n * Converts an {@link ox#Authorization.List} to an {@link ox#Authorization.ListRpc}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.toRpcList([{\n * address: '0x0000000000000000000000000000000000000000',\n * chainId: 1,\n * nonce: 1n,\n * r: 44944627813007772897391531230081695102703289123332187696115181104739239197517n,\n * s: 36528503505192438307355164441104001310566505351980369085208178712678799181120n,\n * yParity: 0,\n * }])\n * ```\n *\n * @param authorizationList - An Authorization List.\n * @returns An RPC-formatted Authorization List.\n */\nexport function toRpcList(authorizationList) {\n return authorizationList.map(toRpc);\n}\n/**\n * Converts an {@link ox#Authorization.Authorization} to an {@link ox#Authorization.Tuple}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization = Authorization.from({\n * address: '0x1234567890abcdef1234567890abcdef12345678',\n * chainId: 1,\n * nonce: 69n,\n * })\n *\n * const tuple = Authorization.toTuple(authorization) // [!code focus]\n * // @log: [\n * // @log: address: '0x1234567890abcdef1234567890abcdef12345678',\n * // @log: chainId: 1,\n * // @log: nonce: 69n,\n * // @log: ]\n * ```\n *\n * @param authorization - The {@link ox#Authorization.Authorization}.\n * @returns An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple.\n */\nexport function toTuple(authorization) {\n const { address, chainId, nonce } = authorization;\n const signature = Signature.extract(authorization);\n return [\n chainId ? Hex.fromNumber(chainId) : '0x',\n address,\n nonce ? Hex.fromNumber(nonce) : '0x',\n ...(signature ? Signature.toTuple(signature) : []),\n ];\n}\n/**\n * Converts an {@link ox#Authorization.List} to an {@link ox#Authorization.TupleList}.\n *\n * @example\n * ```ts twoslash\n * import { Authorization } from 'ox'\n *\n * const authorization_1 = Authorization.from({\n * address: '0x1234567890abcdef1234567890abcdef12345678',\n * chainId: 1,\n * nonce: 69n,\n * })\n * const authorization_2 = Authorization.from({\n * address: '0x1234567890abcdef1234567890abcdef12345678',\n * chainId: 3,\n * nonce: 20n,\n * })\n *\n * const tuple = Authorization.toTupleList([authorization_1, authorization_2]) // [!code focus]\n * // @log: [\n * // @log: [\n * // @log: address: '0x1234567890abcdef1234567890abcdef12345678',\n * // @log: chainId: 1,\n * // @log: nonce: 69n,\n * // @log: ],\n * // @log: [\n * // @log: address: '0x1234567890abcdef1234567890abcdef12345678',\n * // @log: chainId: 3,\n * // @log: nonce: 20n,\n * // @log: ],\n * // @log: ]\n * ```\n *\n * @param list - An {@link ox#Authorization.List}.\n * @returns An [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Authorization tuple list.\n */\nexport function toTupleList(list) {\n if (!list || list.length === 0)\n return [];\n const tupleList = [];\n for (const authorization of list)\n tupleList.push(toTuple(authorization));\n return tupleList;\n}\n//# sourceMappingURL=Authorization.js.map"],"names":["from","authorization","options","chainId","fromRpc","signature","address","nonce","Signature.extract","Number","BigInt"],"mappings":"yCA+CO,SAASA,EAAKC,EAAeC,EAAU,IAC1C,MAAqC,iBAA1BD,EAAcE,QACdC,EAAQH,GACZ,IAAKA,KAAkBC,EAAQG,UAC1C,CAqBO,SAASD,EAAQH,GACpB,MAAMK,QAAEA,EAAOH,QAAEA,EAAOI,MAAEA,GAAUN,EAC9BI,EAAYG,EAAkBP,GACpC,MAAO,CACHK,UACAH,QAASM,OAAON,GAChBI,MAAOG,OAAOH,MACXF,EAEX","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{fromNumber as e}from"./Hex.js";import{toRpc as i}from"./Withdrawal.js";function t(t){return{..."bigint"==typeof t.baseFeePerGas&&{baseFeePerGas:e(t.baseFeePerGas)},..."bigint"==typeof t.blobBaseFee&&{blobBaseFee:e(t.blobBaseFee)},..."string"==typeof t.feeRecipient&&{feeRecipient:t.feeRecipient},..."bigint"==typeof t.gasLimit&&{gasLimit:e(t.gasLimit)},..."bigint"==typeof t.number&&{number:e(t.number)},..."bigint"==typeof t.prevRandao&&{prevRandao:e(t.prevRandao)},..."bigint"==typeof t.time&&{time:e(t.time)},...t.withdrawals&&{withdrawals:t.withdrawals.map(i)}}}export{t as toRpc};
|
|
2
|
+
//# sourceMappingURL=BlockOverrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockOverrides.js","sources":["../../../../../../node_modules/ox/_esm/core/BlockOverrides.js"],"sourcesContent":["import * as Hex from './Hex.js';\nimport * as Withdrawal from './Withdrawal.js';\n/**\n * Converts an {@link ox#BlockOverrides.Rpc} to an {@link ox#BlockOverrides.BlockOverrides}.\n *\n * @example\n * ```ts twoslash\n * import { BlockOverrides } from 'ox'\n *\n * const blockOverrides = BlockOverrides.fromRpc({\n * baseFeePerGas: '0x1',\n * blobBaseFee: '0x2',\n * feeRecipient: '0x0000000000000000000000000000000000000000',\n * gasLimit: '0x4',\n * number: '0x5',\n * prevRandao: '0x6',\n * time: '0x1234567890',\n * withdrawals: [\n * {\n * address: '0x0000000000000000000000000000000000000000',\n * amount: '0x1',\n * index: '0x0',\n * validatorIndex: '0x1',\n * },\n * ],\n * })\n * ```\n *\n * @param rpcBlockOverrides - The RPC block overrides to convert.\n * @returns An instantiated {@link ox#BlockOverrides.BlockOverrides}.\n */\nexport function fromRpc(rpcBlockOverrides) {\n return {\n ...(rpcBlockOverrides.baseFeePerGas && {\n baseFeePerGas: BigInt(rpcBlockOverrides.baseFeePerGas),\n }),\n ...(rpcBlockOverrides.blobBaseFee && {\n blobBaseFee: BigInt(rpcBlockOverrides.blobBaseFee),\n }),\n ...(rpcBlockOverrides.feeRecipient && {\n feeRecipient: rpcBlockOverrides.feeRecipient,\n }),\n ...(rpcBlockOverrides.gasLimit && {\n gasLimit: BigInt(rpcBlockOverrides.gasLimit),\n }),\n ...(rpcBlockOverrides.number && {\n number: BigInt(rpcBlockOverrides.number),\n }),\n ...(rpcBlockOverrides.prevRandao && {\n prevRandao: BigInt(rpcBlockOverrides.prevRandao),\n }),\n ...(rpcBlockOverrides.time && {\n time: BigInt(rpcBlockOverrides.time),\n }),\n ...(rpcBlockOverrides.withdrawals && {\n withdrawals: rpcBlockOverrides.withdrawals.map(Withdrawal.fromRpc),\n }),\n };\n}\n/**\n * Converts an {@link ox#BlockOverrides.BlockOverrides} to an {@link ox#BlockOverrides.Rpc}.\n *\n * @example\n * ```ts twoslash\n * import { BlockOverrides } from 'ox'\n *\n * const blockOverrides = BlockOverrides.toRpc({\n * baseFeePerGas: 1n,\n * blobBaseFee: 2n,\n * feeRecipient: '0x0000000000000000000000000000000000000000',\n * gasLimit: 4n,\n * number: 5n,\n * prevRandao: 6n,\n * time: 78187493520n,\n * withdrawals: [\n * {\n * address: '0x0000000000000000000000000000000000000000',\n * amount: 1n,\n * index: 0,\n * validatorIndex: 1,\n * },\n * ],\n * })\n * ```\n *\n * @param blockOverrides - The block overrides to convert.\n * @returns An instantiated {@link ox#BlockOverrides.Rpc}.\n */\nexport function toRpc(blockOverrides) {\n return {\n ...(typeof blockOverrides.baseFeePerGas === 'bigint' && {\n baseFeePerGas: Hex.fromNumber(blockOverrides.baseFeePerGas),\n }),\n ...(typeof blockOverrides.blobBaseFee === 'bigint' && {\n blobBaseFee: Hex.fromNumber(blockOverrides.blobBaseFee),\n }),\n ...(typeof blockOverrides.feeRecipient === 'string' && {\n feeRecipient: blockOverrides.feeRecipient,\n }),\n ...(typeof blockOverrides.gasLimit === 'bigint' && {\n gasLimit: Hex.fromNumber(blockOverrides.gasLimit),\n }),\n ...(typeof blockOverrides.number === 'bigint' && {\n number: Hex.fromNumber(blockOverrides.number),\n }),\n ...(typeof blockOverrides.prevRandao === 'bigint' && {\n prevRandao: Hex.fromNumber(blockOverrides.prevRandao),\n }),\n ...(typeof blockOverrides.time === 'bigint' && {\n time: Hex.fromNumber(blockOverrides.time),\n }),\n ...(blockOverrides.withdrawals && {\n withdrawals: blockOverrides.withdrawals.map(Withdrawal.toRpc),\n }),\n };\n}\n//# sourceMappingURL=BlockOverrides.js.map"],"names":["toRpc","blockOverrides","baseFeePerGas","Hex.fromNumber","blobBaseFee","feeRecipient","gasLimit","number","prevRandao","time","withdrawals","map","Withdrawal.toRpc"],"mappings":"8EAwFO,SAASA,EAAMC,GAClB,MAAO,IACyC,iBAAjCA,EAAeC,eAA8B,CACpDA,cAAeC,EAAeF,EAAeC,mBAEP,iBAA/BD,EAAeG,aAA4B,CAClDA,YAAaD,EAAeF,EAAeG,iBAEJ,iBAAhCH,EAAeI,cAA6B,CACnDA,aAAcJ,EAAeI,iBAEM,iBAA5BJ,EAAeK,UAAyB,CAC/CA,SAAUH,EAAeF,EAAeK,cAEP,iBAA1BL,EAAeM,QAAuB,CAC7CA,OAAQJ,EAAeF,EAAeM,YAED,iBAA9BN,EAAeO,YAA2B,CACjDA,WAAYL,EAAeF,EAAeO,gBAEX,iBAAxBP,EAAeQ,MAAqB,CAC3CA,KAAMN,EAAeF,EAAeQ,UAEpCR,EAAeS,aAAe,CAC9BA,YAAaT,EAAeS,YAAYC,IAAIC,IAGxD","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{BaseError as e}from"./Errors.js";import{padRight as t,fromBytes as n,toNumber as r,toBigInt as i}from"./Hex.js";import{charCodeToBase16 as o,assertSize as s,trim as c,pad as a}from"./internal/bytes.js";import{assertSize as u}from"./internal/hex.js";const l=new TextDecoder,d=new TextEncoder;function f(e){return e instanceof Uint8Array?e:"string"==typeof e?b(e):y(e)}function y(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function b(n,r={}){const{size:i}=r;let s=n;i&&(u(n,i),s=t(n,i));let c=s.slice(2);c.length%2&&(c=`0${c}`);const a=c.length/2,l=new Uint8Array(a);for(let t=0,n=0;t<a;t++){const r=o(c.charCodeAt(n++)),i=o(c.charCodeAt(n++));if(void 0===r||void 0===i)throw new e(`Invalid byte sequence ("${c[n-2]}${c[n-1]}" in "${c}").`);l[t]=16*r+i}return l}function m(e,t={}){const{size:n}=t,r=d.encode(e);return"number"==typeof n?(s(r,n),z(r,n)):r}function z(e,t){return a(e,{dir:"right",size:t})}function g(e){return e.length}function h(e,t,n,r={}){const{strict:i}=r;return e.slice(t,n)}function p(e,t={}){const{size:r}=t;void 0!==r&&s(e,r);const o=n(e,t);return i(o,t)}function v(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(s(r,n),r=$(r)),r.length>1||r[0]>1)throw new S(r);return Boolean(r[0])}function w(e,t={}){const{size:i}=t;void 0!==i&&s(e,i);const o=n(e,t);return r(o,t)}function x(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(s(r,n),r=B(r)),l.decode(r)}function $(e){return c(e,{dir:"left"})}function B(e){return c(e,{dir:"right"})}class S extends e{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class j extends e{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}}class A extends e{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}}export{S as InvalidBytesBooleanError,A as SizeExceedsPaddingSizeError,j as SizeOverflowError,f as from,y as fromArray,b as fromHex,m as fromString,z as padRight,g as size,h as slice,p as toBigInt,v as toBoolean,w as toNumber,x as toString,$ as trimLeft,B as trimRight};
|
|
2
|
+
//# sourceMappingURL=Bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Bytes.js","sources":["../../../../../../node_modules/ox/_esm/core/Bytes.js"],"sourcesContent":["import { equalBytes } from '@noble/curves/abstract/utils';\nimport * as Errors from './Errors.js';\nimport * as Hex from './Hex.js';\nimport * as internal from './internal/bytes.js';\nimport * as internal_hex from './internal/hex.js';\nimport * as Json from './Json.js';\nconst decoder = /*#__PURE__*/ new TextDecoder();\nconst encoder = /*#__PURE__*/ new TextEncoder();\n/**\n * Asserts if the given value is {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.assert('abc')\n * // @error: Bytes.InvalidBytesTypeError:\n * // @error: Value `\"abc\"` of type `string` is an invalid Bytes value.\n * // @error: Bytes values must be of type `Uint8Array`.\n * ```\n *\n * @param value - Value to assert.\n */\nexport function assert(value) {\n if (value instanceof Uint8Array)\n return;\n if (!value)\n throw new InvalidBytesTypeError(value);\n if (typeof value !== 'object')\n throw new InvalidBytesTypeError(value);\n if (!('BYTES_PER_ELEMENT' in value))\n throw new InvalidBytesTypeError(value);\n if (value.BYTES_PER_ELEMENT !== 1 || value.constructor.name !== 'Uint8Array')\n throw new InvalidBytesTypeError(value);\n}\n/**\n * Concatenates two or more {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const bytes = Bytes.concat(\n * Bytes.from([1]),\n * Bytes.from([69]),\n * Bytes.from([420, 69]),\n * )\n * // @log: Uint8Array [ 1, 69, 420, 69 ]\n * ```\n *\n * @param values - Values to concatenate.\n * @returns Concatenated {@link ox#Bytes.Bytes}.\n */\nexport function concat(...values) {\n let length = 0;\n for (const arr of values) {\n length += arr.length;\n }\n const result = new Uint8Array(length);\n for (let i = 0, index = 0; i < values.length; i++) {\n const arr = values[i];\n result.set(arr, index);\n index += arr.length;\n }\n return result;\n}\n/**\n * Instantiates a {@link ox#Bytes.Bytes} value from a `Uint8Array`, a hex string, or an array of unsigned 8-bit integers.\n *\n * :::tip\n *\n * To instantiate from a **Boolean**, **String**, or **Number**, use one of the following:\n *\n * - `Bytes.fromBoolean`\n *\n * - `Bytes.fromString`\n *\n * - `Bytes.fromNumber`\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.from([255, 124, 5, 4])\n * // @log: Uint8Array([255, 124, 5, 4])\n *\n * const data = Bytes.from('0xdeadbeef')\n * // @log: Uint8Array([222, 173, 190, 239])\n * ```\n *\n * @param value - Value to convert.\n * @returns A {@link ox#Bytes.Bytes} instance.\n */\nexport function from(value) {\n if (value instanceof Uint8Array)\n return value;\n if (typeof value === 'string')\n return fromHex(value);\n return fromArray(value);\n}\n/**\n * Converts an array of unsigned 8-bit integers into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromArray([255, 124, 5, 4])\n * // @log: Uint8Array([255, 124, 5, 4])\n * ```\n *\n * @param value - Value to convert.\n * @returns A {@link ox#Bytes.Bytes} instance.\n */\nexport function fromArray(value) {\n return value instanceof Uint8Array ? value : new Uint8Array(value);\n}\n/**\n * Encodes a boolean value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromBoolean(true)\n * // @log: Uint8Array([1])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromBoolean(true, { size: 32 })\n * // @log: Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])\n * ```\n *\n * @param value - Boolean value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromBoolean(value, options = {}) {\n const { size } = options;\n const bytes = new Uint8Array(1);\n bytes[0] = Number(value);\n if (typeof size === 'number') {\n internal.assertSize(bytes, size);\n return padLeft(bytes, size);\n }\n return bytes;\n}\n/**\n * Encodes a {@link ox#Hex.Hex} value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromHex('0x48656c6c6f20776f726c6421')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromHex('0x48656c6c6f20776f726c6421', { size: 32 })\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n * ```\n *\n * @param value - {@link ox#Hex.Hex} value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromHex(value, options = {}) {\n const { size } = options;\n let hex = value;\n if (size) {\n internal_hex.assertSize(value, size);\n hex = Hex.padRight(value, size);\n }\n let hexString = hex.slice(2);\n if (hexString.length % 2)\n hexString = `0${hexString}`;\n const length = hexString.length / 2;\n const bytes = new Uint8Array(length);\n for (let index = 0, j = 0; index < length; index++) {\n const nibbleLeft = internal.charCodeToBase16(hexString.charCodeAt(j++));\n const nibbleRight = internal.charCodeToBase16(hexString.charCodeAt(j++));\n if (nibbleLeft === undefined || nibbleRight === undefined) {\n throw new Errors.BaseError(`Invalid byte sequence (\"${hexString[j - 2]}${hexString[j - 1]}\" in \"${hexString}\").`);\n }\n bytes[index] = nibbleLeft * 16 + nibbleRight;\n }\n return bytes;\n}\n/**\n * Encodes a number value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromNumber(420)\n * // @log: Uint8Array([1, 164])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromNumber(420, { size: 4 })\n * // @log: Uint8Array([0, 0, 1, 164])\n * ```\n *\n * @param value - Number value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromNumber(value, options) {\n const hex = Hex.fromNumber(value, options);\n return fromHex(hex);\n}\n/**\n * Encodes a string into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromString('Hello world!')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromString('Hello world!', { size: 32 })\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n * ```\n *\n * @param value - String to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromString(value, options = {}) {\n const { size } = options;\n const bytes = encoder.encode(value);\n if (typeof size === 'number') {\n internal.assertSize(bytes, size);\n return padRight(bytes, size);\n }\n return bytes;\n}\n/**\n * Checks if two {@link ox#Bytes.Bytes} values are equal.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.isEqual(Bytes.from([1]), Bytes.from([1]))\n * // @log: true\n *\n * Bytes.isEqual(Bytes.from([1]), Bytes.from([2]))\n * // @log: false\n * ```\n *\n * @param bytesA - First {@link ox#Bytes.Bytes} value.\n * @param bytesB - Second {@link ox#Bytes.Bytes} value.\n * @returns `true` if the two values are equal, otherwise `false`.\n */\nexport function isEqual(bytesA, bytesB) {\n return equalBytes(bytesA, bytesB);\n}\n/**\n * Pads a {@link ox#Bytes.Bytes} value to the left with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padLeft(Bytes.from([1]), 4)\n * // @log: Uint8Array([0, 0, 0, 1])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value to pad.\n * @param size - Size to pad the {@link ox#Bytes.Bytes} value to.\n * @returns Padded {@link ox#Bytes.Bytes} value.\n */\nexport function padLeft(value, size) {\n return internal.pad(value, { dir: 'left', size });\n}\n/**\n * Pads a {@link ox#Bytes.Bytes} value to the right with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padRight(Bytes.from([1]), 4)\n * // @log: Uint8Array([1, 0, 0, 0])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value to pad.\n * @param size - Size to pad the {@link ox#Bytes.Bytes} value to.\n * @returns Padded {@link ox#Bytes.Bytes} value.\n */\nexport function padRight(value, size) {\n return internal.pad(value, { dir: 'right', size });\n}\n/**\n * Generates random {@link ox#Bytes.Bytes} of the specified length.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const bytes = Bytes.random(32)\n * // @log: Uint8Array([... x32])\n * ```\n *\n * @param length - Length of the random {@link ox#Bytes.Bytes} to generate.\n * @returns Random {@link ox#Bytes.Bytes} of the specified length.\n */\nexport function random(length) {\n return crypto.getRandomValues(new Uint8Array(length));\n}\n/**\n * Retrieves the size of a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.size(Bytes.from([1, 2, 3, 4]))\n * // @log: 4\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Size of the {@link ox#Bytes.Bytes} value.\n */\nexport function size(value) {\n return value.length;\n}\n/**\n * Returns a section of a {@link ox#Bytes.Bytes} value given a start/end bytes offset.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.slice(\n * Bytes.from([1, 2, 3, 4, 5, 6, 7, 8, 9]),\n * 1,\n * 4,\n * )\n * // @log: Uint8Array([2, 3, 4])\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value.\n * @param start - Start offset.\n * @param end - End offset.\n * @param options - Slice options.\n * @returns Sliced {@link ox#Bytes.Bytes} value.\n */\nexport function slice(value, start, end, options = {}) {\n const { strict } = options;\n internal.assertStartOffset(value, start);\n const value_ = value.slice(start, end);\n if (strict)\n internal.assertEndOffset(value_, start, end);\n return value_;\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a bigint.\n *\n * @example\n * ```ts\n * import { Bytes } from 'ox'\n *\n * Bytes.toBigInt(Bytes.from([1, 164]))\n * // @log: 420n\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Decoding options.\n * @returns Decoded bigint.\n */\nexport function toBigInt(bytes, options = {}) {\n const { size } = options;\n if (typeof size !== 'undefined')\n internal.assertSize(bytes, size);\n const hex = Hex.fromBytes(bytes, options);\n return Hex.toBigInt(hex, options);\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a boolean.\n *\n * @example\n * ```ts\n * import { Bytes } from 'ox'\n *\n * Bytes.toBoolean(Bytes.from([1]))\n * // @log: true\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Decoding options.\n * @returns Decoded boolean.\n */\nexport function toBoolean(bytes, options = {}) {\n const { size } = options;\n let bytes_ = bytes;\n if (typeof size !== 'undefined') {\n internal.assertSize(bytes_, size);\n bytes_ = trimLeft(bytes_);\n }\n if (bytes_.length > 1 || bytes_[0] > 1)\n throw new InvalidBytesBooleanError(bytes_);\n return Boolean(bytes_[0]);\n}\n/**\n * Encodes a {@link ox#Bytes.Bytes} value into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toHex(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Options.\n * @returns Decoded {@link ox#Hex.Hex} value.\n */\nexport function toHex(value, options = {}) {\n return Hex.fromBytes(value, options);\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a number.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toNumber(Bytes.from([1, 164]))\n * // @log: 420\n * ```\n */\nexport function toNumber(bytes, options = {}) {\n const { size } = options;\n if (typeof size !== 'undefined')\n internal.assertSize(bytes, size);\n const hex = Hex.fromBytes(bytes, options);\n return Hex.toNumber(hex, options);\n}\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a string.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.toString(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: 'Hello world'\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Options.\n * @returns Decoded string.\n */\nexport function toString(bytes, options = {}) {\n const { size } = options;\n let bytes_ = bytes;\n if (typeof size !== 'undefined') {\n internal.assertSize(bytes_, size);\n bytes_ = trimRight(bytes_);\n }\n return decoder.decode(bytes_);\n}\n/**\n * Trims leading zeros from a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.trimLeft(Bytes.from([0, 0, 0, 0, 1, 2, 3]))\n * // @log: Uint8Array([1, 2, 3])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Trimmed {@link ox#Bytes.Bytes} value.\n */\nexport function trimLeft(value) {\n return internal.trim(value, { dir: 'left' });\n}\n/**\n * Trims trailing zeros from a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.trimRight(Bytes.from([1, 2, 3, 0, 0, 0, 0]))\n * // @log: Uint8Array([1, 2, 3])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Trimmed {@link ox#Bytes.Bytes} value.\n */\nexport function trimRight(value) {\n return internal.trim(value, { dir: 'right' });\n}\n/**\n * Checks if the given value is {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.validate('0x')\n * // @log: false\n *\n * Bytes.validate(Bytes.from([1, 2, 3]))\n * // @log: true\n * ```\n *\n * @param value - Value to check.\n * @returns `true` if the value is {@link ox#Bytes.Bytes}, otherwise `false`.\n */\nexport function validate(value) {\n try {\n assert(value);\n return true;\n }\n catch {\n return false;\n }\n}\n/**\n * Thrown when the bytes value cannot be represented as a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toBoolean(Bytes.from([5]))\n * // @error: Bytes.InvalidBytesBooleanError: Bytes value `[5]` is not a valid boolean.\n * // @error: The bytes array must contain a single byte of either a `0` or `1` value.\n * ```\n */\nexport class InvalidBytesBooleanError extends Errors.BaseError {\n constructor(bytes) {\n super(`Bytes value \\`${bytes}\\` is not a valid boolean.`, {\n metaMessages: [\n 'The bytes array must contain a single byte of either a `0` or `1` value.',\n ],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.InvalidBytesBooleanError'\n });\n }\n}\n/**\n * Thrown when a value cannot be converted to bytes.\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Bytes } from 'ox'\n *\n * Bytes.from('foo')\n * // @error: Bytes.InvalidBytesTypeError: Value `foo` of type `string` is an invalid Bytes value.\n * ```\n */\nexport class InvalidBytesTypeError extends Errors.BaseError {\n constructor(value) {\n super(`Value \\`${typeof value === 'object' ? Json.stringify(value) : value}\\` of type \\`${typeof value}\\` is an invalid Bytes value.`, {\n metaMessages: ['Bytes values must be of type `Bytes`.'],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.InvalidBytesTypeError'\n });\n }\n}\n/**\n * Thrown when a size exceeds the maximum allowed size.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.fromString('Hello World!', { size: 8 })\n * // @error: Bytes.SizeOverflowError: Size cannot exceed `8` bytes. Given size: `12` bytes.\n * ```\n */\nexport class SizeOverflowError extends Errors.BaseError {\n constructor({ givenSize, maxSize }) {\n super(`Size cannot exceed \\`${maxSize}\\` bytes. Given size: \\`${givenSize}\\` bytes.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.SizeOverflowError'\n });\n }\n}\n/**\n * Thrown when a slice offset is out-of-bounds.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.slice(Bytes.from([1, 2, 3]), 4)\n * // @error: Bytes.SliceOffsetOutOfBoundsError: Slice starting at offset `4` is out-of-bounds (size: `3`).\n * ```\n */\nexport class SliceOffsetOutOfBoundsError extends Errors.BaseError {\n constructor({ offset, position, size, }) {\n super(`Slice ${position === 'start' ? 'starting' : 'ending'} at offset \\`${offset}\\` is out-of-bounds (size: \\`${size}\\`).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.SliceOffsetOutOfBoundsError'\n });\n }\n}\n/**\n * Thrown when a the padding size exceeds the maximum allowed size.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padLeft(Bytes.fromString('Hello World!'), 8)\n * // @error: [Bytes.SizeExceedsPaddingSizeError: Bytes size (`12`) exceeds padding size (`8`).\n * ```\n */\nexport class SizeExceedsPaddingSizeError extends Errors.BaseError {\n constructor({ size, targetSize, type, }) {\n super(`${type.charAt(0).toUpperCase()}${type\n .slice(1)\n .toLowerCase()} size (\\`${size}\\`) exceeds padding size (\\`${targetSize}\\`).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Bytes.SizeExceedsPaddingSizeError'\n });\n }\n}\n//# sourceMappingURL=Bytes.js.map"],"names":["decoder","TextDecoder","encoder","TextEncoder","from","value","Uint8Array","fromHex","fromArray","options","size","hex","internal_hex.assertSize","Hex.padRight","hexString","slice","length","bytes","index","j","nibbleLeft","internal.charCodeToBase16","charCodeAt","nibbleRight","undefined","Errors.BaseError","fromString","encode","internal.assertSize","padRight","internal.pad","dir","start","end","strict","toBigInt","Hex.fromBytes","Hex.toBigInt","toBoolean","bytes_","trimLeft","InvalidBytesBooleanError","Boolean","toNumber","Hex.toNumber","toString","trimRight","decode","internal.trim","constructor","super","metaMessages","Object","defineProperty","this","enumerable","configurable","writable","SizeOverflowError","givenSize","maxSize","SizeExceedsPaddingSizeError","targetSize","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,QAAEA,IACrBV,MAAM,wBAAwBU,4BAAkCD,cAChEP,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVpD,MAAO,2BAEf,EAmCG,MAAMwD,UAAoCpC,EAC7C,WAAAwB,EAAYvC,KAAEA,EAAIoD,WAAEA,EAAUC,KAAEA,IAC5Bb,MAAM,GAAGa,EAAKC,OAAO,GAAGC,gBAAgBF,EACnChD,MAAM,GACNmD,yBAAyBxD,gCAAmCoD,SACjEV,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVpD,MAAO,qCAEf","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Caches.js","sources":["../../../../../../node_modules/ox/_esm/core/Caches.js"],"sourcesContent":["import { LruMap } from './internal/lru.js';\nconst caches = {\n checksum: /*#__PURE__*/ new LruMap(8192),\n};\nexport const checksum = caches.checksum;\n/**\n * Clears all global caches.\n *\n * @example\n * ```ts\n * import { Caches } from 'ox'\n * Caches.clear()\n * ```\n */\nexport function clear() {\n for (const cache of Object.values(caches))\n cache.clear();\n}\n//# sourceMappingURL=Caches.js.map"],"names":["checksum","LruMap"],"mappings":"2CACA,MAGaA,EAHE,CACXA,SAAwB,IAAIC,EAAO,OAERD","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getVersion as e}from"./internal/errors.js";class s extends Error{constructor(a,t={}){const r=(()=>{if(t.cause instanceof s){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),i=t.cause instanceof s&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${i??""}`;super([a||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...r||i?["",r?`Details: ${r}`:void 0,i?`See: ${o}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${e()}`}),this.cause=t.cause,this.details=r,this.docs=o,this.docsPath=i,this.shortMessage=a}walk(e){return a(this,e)}}function a(e,s){return s?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?a(e.cause,s):s?null:e}export{s as BaseError};
|
|
2
|
+
//# sourceMappingURL=Errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Errors.js","sources":["../../../../../../node_modules/ox/_esm/core/Errors.js"],"sourcesContent":["import { getVersion } from './internal/errors.js';\n/**\n * Base error class inherited by all errors thrown by ox.\n *\n * @example\n * ```ts\n * import { Errors } from 'ox'\n * throw new Errors.BaseError('An error occurred')\n * ```\n */\nexport class BaseError extends Error {\n constructor(shortMessage, options = {}) {\n const details = (() => {\n if (options.cause instanceof BaseError) {\n if (options.cause.details)\n return options.cause.details;\n if (options.cause.shortMessage)\n return options.cause.shortMessage;\n }\n if (options.cause &&\n 'details' in options.cause &&\n typeof options.cause.details === 'string')\n return options.cause.details;\n if (options.cause?.message)\n return options.cause.message;\n return options.details;\n })();\n const docsPath = (() => {\n if (options.cause instanceof BaseError)\n return options.cause.docsPath || options.docsPath;\n return options.docsPath;\n })();\n const docsBaseUrl = 'https://oxlib.sh';\n const docs = `${docsBaseUrl}${docsPath ?? ''}`;\n const message = [\n shortMessage || 'An error occurred.',\n ...(options.metaMessages ? ['', ...options.metaMessages] : []),\n ...(details || docsPath\n ? [\n '',\n details ? `Details: ${details}` : undefined,\n docsPath ? `See: ${docs}` : undefined,\n ]\n : []),\n ]\n .filter((x) => typeof x === 'string')\n .join('\\n');\n super(message, options.cause ? { cause: options.cause } : undefined);\n Object.defineProperty(this, \"details\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"docs\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"docsPath\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"shortMessage\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"cause\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'BaseError'\n });\n Object.defineProperty(this, \"version\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: `ox@${getVersion()}`\n });\n this.cause = options.cause;\n this.details = details;\n this.docs = docs;\n this.docsPath = docsPath;\n this.shortMessage = shortMessage;\n }\n walk(fn) {\n return walk(this, fn);\n }\n}\n/** @internal */\nfunction walk(err, fn) {\n if (fn?.(err))\n return err;\n if (err && typeof err === 'object' && 'cause' in err && err.cause)\n return walk(err.cause, fn);\n return fn ? null : err;\n}\n//# sourceMappingURL=Errors.js.map"],"names":["BaseError","Error","constructor","shortMessage","options","details","cause","message","docsPath","docs","super","metaMessages","undefined","filter","x","join","Object","defineProperty","this","enumerable","configurable","writable","value","getVersion","walk","fn","err"],"mappings":"kDAUO,MAAMA,UAAkBC,MAC3B,WAAAC,CAAYC,EAAcC,EAAU,IAChC,MAAMC,EAAU,MACZ,GAAID,EAAQE,iBAAiBN,EAAW,CACpC,GAAII,EAAQE,MAAMD,QACd,OAAOD,EAAQE,MAAMD,QACzB,GAAID,EAAQE,MA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ChBU,KAAKf,aAAeA,CACxB,CACA,IAAAqB,CAAKC,GACD,OAAOD,EAAKN,KAAMO,EACtB,EAGJ,SAASD,EAAKE,EAAKD,GACf,OAAIA,IAAKC,GACEA,EACPA,GAAsB,iBAARA,GAAoB,UAAWA,GAAOA,EAAIpB,MACjDkB,EAAKE,EAAIpB,MAAOmB,GACpBA,EAAK,KAAOC,CACvB","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{keccak_256 as s}from"../../../@noble/hashes/esm/sha3.js";import{from as t}from"./Bytes.js";import{fromBytes as e}from"./Hex.js";function o(o,r={}){const{as:m=("string"==typeof o?"Hex":"Bytes")}=r,n=s(t(o));return"Bytes"===m?n:e(n)}export{o as keccak256};
|
|
2
|
+
//# sourceMappingURL=Hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hash.js","sources":["../../../../../../node_modules/ox/_esm/core/Hash.js"],"sourcesContent":["import { ripemd160 as noble_ripemd160 } from '@noble/hashes/ripemd160';\nimport { keccak_256 as noble_keccak256 } from '@noble/hashes/sha3';\nimport { sha256 as noble_sha256 } from '@noble/hashes/sha256';\nimport * as Bytes from './Bytes.js';\nimport * as Hex from './Hex.js';\n/**\n * Calculates the [Keccak256](https://en.wikipedia.org/wiki/SHA-3) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n *\n * This function is a re-export of `keccak_256` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.keccak256('0xdeadbeef')\n * // @log: '0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1'\n * ```\n *\n * @example\n * ### Calculate Hash of a String\n *\n * ```ts twoslash\n * import { Hash, Hex } from 'ox'\n *\n * Hash.keccak256(Hex.fromString('hello world'))\n * // @log: '0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0'\n * ```\n *\n * @example\n * ### Configure Return Type\n *\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.keccak256('0xdeadbeef', { as: 'Bytes' })\n * // @log: Uint8Array [...]\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n * @param options - Options.\n * @returns Keccak256 hash.\n */\nexport function keccak256(value, options = {}) {\n const { as = typeof value === 'string' ? 'Hex' : 'Bytes' } = options;\n const bytes = noble_keccak256(Bytes.from(value));\n if (as === 'Bytes')\n return bytes;\n return Hex.fromBytes(bytes);\n}\n/**\n * Calculates the [Ripemd160](https://en.wikipedia.org/wiki/RIPEMD) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n *\n * This function is a re-export of `ripemd160` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.ripemd160('0xdeadbeef')\n * // '0x226821c2f5423e11fe9af68bd285c249db2e4b5a'\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n * @param options - Options.\n * @returns Ripemd160 hash.\n */\nexport function ripemd160(value, options = {}) {\n const { as = typeof value === 'string' ? 'Hex' : 'Bytes' } = options;\n const bytes = noble_ripemd160(Bytes.from(value));\n if (as === 'Bytes')\n return bytes;\n return Hex.fromBytes(bytes);\n}\n/**\n * Calculates the [Sha256](https://en.wikipedia.org/wiki/SHA-256) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n *\n * This function is a re-export of `sha256` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.sha256('0xdeadbeef')\n * // '0x5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953'\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n * @param options - Options.\n * @returns Sha256 hash.\n */\nexport function sha256(value, options = {}) {\n const { as = typeof value === 'string' ? 'Hex' : 'Bytes' } = options;\n const bytes = noble_sha256(Bytes.from(value));\n if (as === 'Bytes')\n return bytes;\n return Hex.fromBytes(bytes);\n}\n/**\n * Checks if a string is a valid hash value.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.validate('0x')\n * // @log: false\n *\n * Hash.validate('0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0')\n * // @log: true\n * ```\n *\n * @param value - Value to check.\n * @returns Whether the value is a valid hash.\n */\nexport function validate(value) {\n return Hex.validate(value) && Hex.size(value) === 32;\n}\n//# sourceMappingURL=Hash.js.map"],"names":["keccak256","value","options","as","bytes","noble_keccak256","Bytes.from","Hex.fromBytes"],"mappings":"uIA0CO,SAASA,EAAUC,EAAOC,EAAU,IACvC,MAAMC,GAAEA,GAAsB,iBAAVF,EAAqB,MAAQ,UAAYC,EACvDE,EAAQC,EAAgBC,EAAWL,IACzC,MAAW,UAAPE,EACOC,EACJG,EAAcH,EACzB","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{BaseError as e}from"./Errors.js";import{assertStartOffset as t,assertEndOffset as n,pad as r,assertSize as i}from"./internal/hex.js";import{stringify as s}from"./Json.js";const o=new TextEncoder,a=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function c(e,t={}){const{strict:n=!1}=t;if(!e)throw new v(e);if("string"!=typeof e)throw new v(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new S(e);if(!e.startsWith("0x"))throw new S(e)}function u(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function f(e){return e instanceof Uint8Array?g(e):Array.isArray(e)?g(new Uint8Array(e)):e}function l(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(i(n,t.size),x(n,t.size)):n}function g(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=a[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(i(r,t.size),p(r,t.size)):r}function d(e,t={}){const{signed:n,size:r}=t,i=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o="bigint"==typeof s&&n?-s-1n:0;if(s&&i>s||i<o){const t="bigint"==typeof e?"n":"";throw new w({max:s?`${s}${t}`:void 0,min:`${o}${t}`,signed:n,size:r,value:`${e}${t}`})}const a=`0x${(n&&i<0?(1n<<BigInt(8*r))+BigInt(i):i).toString(16)}`;return r?x(a,r):a}function b(e,t={}){return g(o.encode(e),t)}function x(e,t){return r(e,{dir:"left",size:t})}function p(e,t){return r(e,{dir:"right",size:t})}function m(e,r,i,s={}){const{strict:o}=s;t(e,r);const a=`0x${e.replace("0x","").slice(2*(r??0),2*(i??e.length))}`;return o&&n(a,r,i),a}function $(e){return Math.ceil((e.length-2)/2)}function y(e,t={}){const{signed:n}=t;t.size&&i(e,t.size);const r=BigInt(e);if(!n)return r;const s=(e.length-2)/2,o=(1n<<8n*BigInt(s))-1n;return r<=o>>1n?r:r-o-1n}function h(e,t={}){const{signed:n,size:r}=t;return Number(n||r?y(e,t):e)}function z(e,t={}){const{strict:n=!1}=t;try{return c(e,{strict:n}),!0}catch{return!1}}class w extends e{constructor({max:e,min:t,signed:n,size:r,value:i}){super(`Number \`${i}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class v extends e{constructor(e){super(`Value \`${"object"==typeof e?s(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class S extends e{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class E extends e{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class I extends e{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class O extends e{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}export{w as IntegerOutOfRangeError,v as InvalidHexTypeError,S as InvalidHexValueError,O as SizeExceedsPaddingSizeError,E as SizeOverflowError,I as SliceOffsetOutOfBoundsError,c as assert,u as concat,f as from,l as fromBoolean,g as fromBytes,d as fromNumber,b as fromString,x as padLeft,p as padRight,$ as size,m as slice,y as toBigInt,h as toNumber,z as validate};
|
|
2
|
+
//# sourceMappingURL=Hex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hex.js","sources":["../../../../../../node_modules/ox/_esm/core/Hex.js"],"sourcesContent":["import { equalBytes } from '@noble/curves/abstract/utils';\nimport * as Bytes from './Bytes.js';\nimport * as Errors from './Errors.js';\nimport * as internal_bytes from './internal/bytes.js';\nimport * as internal from './internal/hex.js';\nimport * as Json from './Json.js';\nconst encoder = /*#__PURE__*/ new TextEncoder();\nconst hexes = /*#__PURE__*/ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, '0'));\n/**\n * Asserts if the given value is {@link ox#Hex.Hex}.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.assert('abc')\n * // @error: InvalidHexValueTypeError:\n * // @error: Value `\"abc\"` of type `string` is an invalid hex type.\n * // @error: Hex types must be represented as `\"0x\\${string}\"`.\n * ```\n *\n * @param value - The value to assert.\n * @param options - Options.\n */\nexport function assert(value, options = {}) {\n const { strict = false } = options;\n if (!value)\n throw new InvalidHexTypeError(value);\n if (typeof value !== 'string')\n throw new InvalidHexTypeError(value);\n if (strict) {\n if (!/^0x[0-9a-fA-F]*$/.test(value))\n throw new InvalidHexValueError(value);\n }\n if (!value.startsWith('0x'))\n throw new InvalidHexValueError(value);\n}\n/**\n * Concatenates two or more {@link ox#Hex.Hex}.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.concat('0x123', '0x456')\n * // @log: '0x123456'\n * ```\n *\n * @param values - The {@link ox#Hex.Hex} values to concatenate.\n * @returns The concatenated {@link ox#Hex.Hex} value.\n */\nexport function concat(...values) {\n return `0x${values.reduce((acc, x) => acc + x.replace('0x', ''), '')}`;\n}\n/**\n * Instantiates a {@link ox#Hex.Hex} value from a hex string or {@link ox#Bytes.Bytes} value.\n *\n * :::tip\n *\n * To instantiate from a **Boolean**, **String**, or **Number**, use one of the following:\n *\n * - `Hex.fromBoolean`\n *\n * - `Hex.fromString`\n *\n * - `Hex.fromNumber`\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * import { Bytes, Hex } from 'ox'\n *\n * Hex.from('0x48656c6c6f20576f726c6421')\n * // @log: '0x48656c6c6f20576f726c6421'\n *\n * Hex.from(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value to encode.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function from(value) {\n if (value instanceof Uint8Array)\n return fromBytes(value);\n if (Array.isArray(value))\n return fromBytes(new Uint8Array(value));\n return value;\n}\n/**\n * Encodes a boolean into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromBoolean(true)\n * // @log: '0x1'\n *\n * Hex.fromBoolean(false)\n * // @log: '0x0'\n *\n * Hex.fromBoolean(true, { size: 32 })\n * // @log: '0x0000000000000000000000000000000000000000000000000000000000000001'\n * ```\n *\n * @param value - The boolean value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromBoolean(value, options = {}) {\n const hex = `0x${Number(value)}`;\n if (typeof options.size === 'number') {\n internal.assertSize(hex, options.size);\n return padLeft(hex, options.size);\n }\n return hex;\n}\n/**\n * Encodes a {@link ox#Bytes.Bytes} value into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes, Hex } from 'ox'\n *\n * Hex.fromBytes(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromBytes(value, options = {}) {\n let string = '';\n for (let i = 0; i < value.length; i++)\n string += hexes[value[i]];\n const hex = `0x${string}`;\n if (typeof options.size === 'number') {\n internal.assertSize(hex, options.size);\n return padRight(hex, options.size);\n }\n return hex;\n}\n/**\n * Encodes a number or bigint into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromNumber(420)\n * // @log: '0x1a4'\n *\n * Hex.fromNumber(420, { size: 32 })\n * // @log: '0x00000000000000000000000000000000000000000000000000000000000001a4'\n * ```\n *\n * @param value - The number or bigint value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromNumber(value, options = {}) {\n const { signed, size } = options;\n const value_ = BigInt(value);\n let maxValue;\n if (size) {\n if (signed)\n maxValue = (1n << (BigInt(size) * 8n - 1n)) - 1n;\n else\n maxValue = 2n ** (BigInt(size) * 8n) - 1n;\n }\n else if (typeof value === 'number') {\n maxValue = BigInt(Number.MAX_SAFE_INTEGER);\n }\n const minValue = typeof maxValue === 'bigint' && signed ? -maxValue - 1n : 0;\n if ((maxValue && value_ > maxValue) || value_ < minValue) {\n const suffix = typeof value === 'bigint' ? 'n' : '';\n throw new IntegerOutOfRangeError({\n max: maxValue ? `${maxValue}${suffix}` : undefined,\n min: `${minValue}${suffix}`,\n signed,\n size,\n value: `${value}${suffix}`,\n });\n }\n const stringValue = (signed && value_ < 0 ? (1n << BigInt(size * 8)) + BigInt(value_) : value_).toString(16);\n const hex = `0x${stringValue}`;\n if (size)\n return padLeft(hex, size);\n return hex;\n}\n/**\n * Encodes a string into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n * Hex.fromString('Hello World!')\n * // '0x48656c6c6f20576f726c6421'\n *\n * Hex.fromString('Hello World!', { size: 32 })\n * // '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000'\n * ```\n *\n * @param value - The string value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromString(value, options = {}) {\n return fromBytes(encoder.encode(value), options);\n}\n/**\n * Checks if two {@link ox#Hex.Hex} values are equal.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.isEqual('0xdeadbeef', '0xdeadbeef')\n * // @log: true\n *\n * Hex.isEqual('0xda', '0xba')\n * // @log: false\n * ```\n *\n * @param hexA - The first {@link ox#Hex.Hex} value.\n * @param hexB - The second {@link ox#Hex.Hex} value.\n * @returns `true` if the two {@link ox#Hex.Hex} values are equal, `false` otherwise.\n */\nexport function isEqual(hexA, hexB) {\n return equalBytes(Bytes.fromHex(hexA), Bytes.fromHex(hexB));\n}\n/**\n * Pads a {@link ox#Hex.Hex} value to the left with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.padLeft('0x1234', 4)\n * // @log: '0x00001234'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to pad.\n * @param size - The size (in bytes) of the output hex value.\n * @returns The padded {@link ox#Hex.Hex} value.\n */\nexport function padLeft(value, size) {\n return internal.pad(value, { dir: 'left', size });\n}\n/**\n * Pads a {@link ox#Hex.Hex} value to the right with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts\n * import { Hex } from 'ox'\n *\n * Hex.padRight('0x1234', 4)\n * // @log: '0x12340000'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to pad.\n * @param size - The size (in bytes) of the output hex value.\n * @returns The padded {@link ox#Hex.Hex} value.\n */\nexport function padRight(value, size) {\n return internal.pad(value, { dir: 'right', size });\n}\n/**\n * Generates a random {@link ox#Hex.Hex} value of the specified length.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * const hex = Hex.random(32)\n * // @log: '0x...'\n * ```\n *\n * @returns Random {@link ox#Hex.Hex} value.\n */\nexport function random(length) {\n return fromBytes(Bytes.random(length));\n}\n/**\n * Returns a section of a {@link ox#Bytes.Bytes} value given a start/end bytes offset.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.slice('0x0123456789', 1, 4)\n * // @log: '0x234567'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to slice.\n * @param start - The start offset (in bytes).\n * @param end - The end offset (in bytes).\n * @param options - Options.\n * @returns The sliced {@link ox#Hex.Hex} value.\n */\nexport function slice(value, start, end, options = {}) {\n const { strict } = options;\n internal.assertStartOffset(value, start);\n const value_ = `0x${value\n .replace('0x', '')\n .slice((start ?? 0) * 2, (end ?? value.length) * 2)}`;\n if (strict)\n internal.assertEndOffset(value_, start, end);\n return value_;\n}\n/**\n * Retrieves the size of a {@link ox#Hex.Hex} value (in bytes).\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.size('0xdeadbeef')\n * // @log: 4\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to get the size of.\n * @returns The size of the {@link ox#Hex.Hex} value (in bytes).\n */\nexport function size(value) {\n return Math.ceil((value.length - 2) / 2);\n}\n/**\n * Trims leading zeros from a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.trimLeft('0x00000000deadbeef')\n * // @log: '0xdeadbeef'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to trim.\n * @returns The trimmed {@link ox#Hex.Hex} value.\n */\nexport function trimLeft(value) {\n return internal.trim(value, { dir: 'left' });\n}\n/**\n * Trims trailing zeros from a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.trimRight('0xdeadbeef00000000')\n * // @log: '0xdeadbeef'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to trim.\n * @returns The trimmed {@link ox#Hex.Hex} value.\n */\nexport function trimRight(value) {\n return internal.trim(value, { dir: 'right' });\n}\n/**\n * Decodes a {@link ox#Hex.Hex} value into a BigInt.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toBigInt('0x1a4')\n * // @log: 420n\n *\n * Hex.toBigInt('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })\n * // @log: 420n\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded BigInt.\n */\nexport function toBigInt(hex, options = {}) {\n const { signed } = options;\n if (options.size)\n internal.assertSize(hex, options.size);\n const value = BigInt(hex);\n if (!signed)\n return value;\n const size = (hex.length - 2) / 2;\n const max_unsigned = (1n << (BigInt(size) * 8n)) - 1n;\n const max_signed = max_unsigned >> 1n;\n if (value <= max_signed)\n return value;\n return value - max_unsigned - 1n;\n}\n/**\n * Decodes a {@link ox#Hex.Hex} value into a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toBoolean('0x01')\n * // @log: true\n *\n * Hex.toBoolean('0x0000000000000000000000000000000000000000000000000000000000000001', { size: 32 })\n * // @log: true\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded boolean.\n */\nexport function toBoolean(hex, options = {}) {\n if (options.size)\n internal.assertSize(hex, options.size);\n const hex_ = trimLeft(hex);\n if (hex_ === '0x')\n return false;\n if (hex_ === '0x1')\n return true;\n throw new InvalidHexBooleanError(hex);\n}\n/**\n * Decodes a {@link ox#Hex.Hex} value into a {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * const data = Hex.toBytes('0x48656c6c6f20776f726c6421')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded {@link ox#Bytes.Bytes}.\n */\nexport function toBytes(hex, options = {}) {\n return Bytes.fromHex(hex, options);\n}\n/**\n * Decodes a {@link ox#Hex.Hex} value into a number.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toNumber('0x1a4')\n * // @log: 420\n *\n * Hex.toNumber('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })\n * // @log: 420\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded number.\n */\nexport function toNumber(hex, options = {}) {\n const { signed, size } = options;\n if (!signed && !size)\n return Number(hex);\n return Number(toBigInt(hex, options));\n}\n/**\n * Decodes a {@link ox#Hex.Hex} value into a string.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toString('0x48656c6c6f20576f726c6421')\n * // @log: 'Hello world!'\n *\n * Hex.toString('0x48656c6c6f20576f726c64210000000000000000000000000000000000000000', {\n * size: 32,\n * })\n * // @log: 'Hello world'\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded string.\n */\nexport function toString(hex, options = {}) {\n const { size } = options;\n let bytes = Bytes.fromHex(hex);\n if (size) {\n internal_bytes.assertSize(bytes, size);\n bytes = Bytes.trimRight(bytes);\n }\n return new TextDecoder().decode(bytes);\n}\n/**\n * Checks if the given value is {@link ox#Hex.Hex}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes, Hex } from 'ox'\n *\n * Hex.validate('0xdeadbeef')\n * // @log: true\n *\n * Hex.validate(Bytes.from([1, 2, 3]))\n * // @log: false\n * ```\n *\n * @param value - The value to check.\n * @param options - Options.\n * @returns `true` if the value is a {@link ox#Hex.Hex}, `false` otherwise.\n */\nexport function validate(value, options = {}) {\n const { strict = false } = options;\n try {\n assert(value, { strict });\n return true;\n }\n catch {\n return false;\n }\n}\n/**\n * Thrown when the provided integer is out of range, and cannot be represented as a hex value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromNumber(420182738912731283712937129)\n * // @error: Hex.IntegerOutOfRangeError: Number \\`4.2018273891273126e+26\\` is not in safe unsigned integer range (`0` to `9007199254740991`)\n * ```\n */\nexport class IntegerOutOfRangeError extends Errors.BaseError {\n constructor({ max, min, signed, size, value, }) {\n super(`Number \\`${value}\\` is not in safe${size ? ` ${size * 8}-bit` : ''}${signed ? ' signed' : ' unsigned'} integer range ${max ? `(\\`${min}\\` to \\`${max}\\`)` : `(above \\`${min}\\`)`}`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.IntegerOutOfRangeError'\n });\n }\n}\n/**\n * Thrown when the provided hex value cannot be represented as a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toBoolean('0xa')\n * // @error: Hex.InvalidHexBooleanError: Hex value `\"0xa\"` is not a valid boolean.\n * // @error: The hex value must be `\"0x0\"` (false) or `\"0x1\"` (true).\n * ```\n */\nexport class InvalidHexBooleanError extends Errors.BaseError {\n constructor(hex) {\n super(`Hex value \\`\"${hex}\"\\` is not a valid boolean.`, {\n metaMessages: [\n 'The hex value must be `\"0x0\"` (false) or `\"0x1\"` (true).',\n ],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.InvalidHexBooleanError'\n });\n }\n}\n/**\n * Thrown when the provided value is not a valid hex type.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.assert(1)\n * // @error: Hex.InvalidHexTypeError: Value `1` of type `number` is an invalid hex type.\n * ```\n */\nexport class InvalidHexTypeError extends Errors.BaseError {\n constructor(value) {\n super(`Value \\`${typeof value === 'object' ? Json.stringify(value) : value}\\` of type \\`${typeof value}\\` is an invalid hex type.`, {\n metaMessages: ['Hex types must be represented as `\"0x${string}\"`.'],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.InvalidHexTypeError'\n });\n }\n}\n/**\n * Thrown when the provided hex value is invalid.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.assert('0x0123456789abcdefg')\n * // @error: Hex.InvalidHexValueError: Value `0x0123456789abcdefg` is an invalid hex value.\n * // @error: Hex values must start with `\"0x\"` and contain only hexadecimal characters (0-9, a-f, A-F).\n * ```\n */\nexport class InvalidHexValueError extends Errors.BaseError {\n constructor(value) {\n super(`Value \\`${value}\\` is an invalid hex value.`, {\n metaMessages: [\n 'Hex values must start with `\"0x\"` and contain only hexadecimal characters (0-9, a-f, A-F).',\n ],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.InvalidHexValueError'\n });\n }\n}\n/**\n * Thrown when the provided hex value is an odd length.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.fromHex('0xabcde')\n * // @error: Hex.InvalidLengthError: Hex value `\"0xabcde\"` is an odd length (5 nibbles).\n * ```\n */\nexport class InvalidLengthError extends Errors.BaseError {\n constructor(value) {\n super(`Hex value \\`\"${value}\"\\` is an odd length (${value.length - 2} nibbles).`, {\n metaMessages: ['It must be an even length.'],\n });\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.InvalidLengthError'\n });\n }\n}\n/**\n * Thrown when the size of the value exceeds the expected max size.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromString('Hello World!', { size: 8 })\n * // @error: Hex.SizeOverflowError: Size cannot exceed `8` bytes. Given size: `12` bytes.\n * ```\n */\nexport class SizeOverflowError extends Errors.BaseError {\n constructor({ givenSize, maxSize }) {\n super(`Size cannot exceed \\`${maxSize}\\` bytes. Given size: \\`${givenSize}\\` bytes.`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.SizeOverflowError'\n });\n }\n}\n/**\n * Thrown when the slice offset exceeds the bounds of the value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.slice('0x0123456789', 6)\n * // @error: Hex.SliceOffsetOutOfBoundsError: Slice starting at offset `6` is out-of-bounds (size: `5`).\n * ```\n */\nexport class SliceOffsetOutOfBoundsError extends Errors.BaseError {\n constructor({ offset, position, size, }) {\n super(`Slice ${position === 'start' ? 'starting' : 'ending'} at offset \\`${offset}\\` is out-of-bounds (size: \\`${size}\\`).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.SliceOffsetOutOfBoundsError'\n });\n }\n}\n/**\n * Thrown when the size of the value exceeds the pad size.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.padLeft('0x1a4e12a45a21323123aaa87a897a897a898a6567a578a867a98778a667a85a875a87a6a787a65a675a6a9', 32)\n * // @error: Hex.SizeExceedsPaddingSizeError: Hex size (`43`) exceeds padding size (`32`).\n * ```\n */\nexport class SizeExceedsPaddingSizeError extends Errors.BaseError {\n constructor({ size, targetSize, type, }) {\n super(`${type.charAt(0).toUpperCase()}${type\n .slice(1)\n .toLowerCase()} size (\\`${size}\\`) exceeds padding size (\\`${targetSize}\\`).`);\n Object.defineProperty(this, \"name\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: 'Hex.SizeExceedsPaddingSizeError'\n });\n }\n}\n//# sourceMappingURL=Hex.js.map"],"names":["encoder","TextEncoder","hexes","Array","from","length","_v","i","toString","padStart","assert","value","options","strict","InvalidHexTypeError","test","InvalidHexValueError","startsWith","concat","values","reduce","acc","x","replace","Uint8Array","fromBytes","isArray","fromBoolean","hex","Number","size","internal.assertSize","padLeft","string","padRight","fromNumber","signed","value_","BigInt","maxValue","MAX_SAFE_INTEGER","minValue","suffix","IntegerOutOfRangeError","max","undefined","min","fromString","encode","internal.pad","dir","slice","start","end","internal.assertStartOffset","internal.assertEndOffset","Math","ceil","toBigInt","max_unsigned","toNumber","validate","Errors.BaseError","constructor","super","Object","defineProperty","this","enumerable","configurable","writable","Json.stringify","metaMessages","SizeOverflowError","givenSize","maxSize","SliceOffsetOutOfBoundsError","offset","position","SizeExceedsPaddingSizeError","targetSize","type","charAt","toUpperCase","toLowerCase"],"mappings":"kLAMA,MAAMA,EAAwB,IAAIC,YAC5BC,EAAsBC,MAAMC,KAAK,CAAEC,OAAQ,KAAO,CAACC,EAAIC,IAAMA,EAAEC,SAAS,IAAIC,SAAS,EAAG,MAiBvF,SAASC,EAAOC,EAAOC,EAAU,IACpC,MAAMC,OAAEA,GAAS,GAAUD,EAC3B,IAAKD,EACD,MAAM,IAAIG,EAAoBH,GAClC,GAAqB,iBAAVA,EACP,MAAM,IAAIG,EAAoBH,G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AAMiE,UAAoCd,EAC7C,WAAAC,EAAYc,OAAEA,EAAMC,SAAEA,EAAQhD,KAAEA,IAC5BkC,MAAM,SAAsB,UAAbc,EAAuB,WAAa,wBAAwBD,iCAAsC/C,SACjHmC,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACV3D,MAAO,mCAEf,EAaG,MAAMoE,UAAoCjB,EAC7C,WAAAC,EAAYjC,KAAEA,EAAIkD,WAAEA,EAAUC,KAAEA,IAC5BjB,MAAM,GAAGiB,EAAKC,OAAO,GAAGC,gBAAgBF,EACnC9B,MAAM,GACNiC,yBAAyBtD,gCAAmCkD,SACjEf,OAAOC,eAAeC,KAAM,OAAQ,CAChCC,YAAY,EACZC,cAAc,EACdC,UAAU,EACV3D,MAAO,mCAEf","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Json.js","sources":["../../../../../../node_modules/ox/_esm/core/Json.js"],"sourcesContent":["const bigIntSuffix = '#__bigint';\n/**\n * Parses a JSON string, with support for `bigint`.\n *\n * @example\n * ```ts twoslash\n * import { Json } from 'ox'\n *\n * const json = Json.parse('{\"foo\":\"bar\",\"baz\":\"69420694206942069420694206942069420694206942069420#__bigint\"}')\n * // @log: {\n * // @log: foo: 'bar',\n * // @log: baz: 69420694206942069420694206942069420694206942069420n\n * // @log: }\n * ```\n *\n * @param string - The value to parse.\n * @param reviver - A function that transforms the results.\n * @returns The parsed value.\n */\nexport function parse(string, reviver) {\n return JSON.parse(string, (key, value_) => {\n const value = value_;\n if (typeof value === 'string' && value.endsWith(bigIntSuffix))\n return BigInt(value.slice(0, -bigIntSuffix.length));\n return typeof reviver === 'function' ? reviver(key, value) : value;\n });\n}\n/**\n * Stringifies a value to its JSON representation, with support for `bigint`.\n *\n * @example\n * ```ts twoslash\n * import { Json } from 'ox'\n *\n * const json = Json.stringify({\n * foo: 'bar',\n * baz: 69420694206942069420694206942069420694206942069420n,\n * })\n * // @log: '{\"foo\":\"bar\",\"baz\":\"69420694206942069420694206942069420694206942069420#__bigint\"}'\n * ```\n *\n * @param value - The value to stringify.\n * @param replacer - A function that transforms the results. It is passed the key and value of the property, and must return the value to be used in the JSON string. If this function returns `undefined`, the property is not included in the resulting JSON string.\n * @param space - A string or number that determines the indentation of the JSON string. If it is a number, it indicates the number of spaces to use as indentation; if it is a string (e.g. `'\\t'`), it uses the string as the indentation character.\n * @returns The JSON string.\n */\nexport function stringify(value, replacer, space) {\n return JSON.stringify(value, (key, value) => {\n if (typeof replacer === 'function')\n return replacer(key, value);\n if (typeof value === 'bigint')\n return value.toString() + bigIntSuffix;\n return value;\n }, space);\n}\n//# sourceMappingURL=Json.js.map"],"names":["stringify","value","replacer","space","JSON","key","toString"],"mappings":"AA8CO,SAASA,EAAUC,EAAOC,EAAUC,GACvC,OAAOC,KAAKJ,UAAUC,EAAO,CAACI,EAAKJ,IAGV,iBAAVA,EACAA,EAAMK,WAnDJ,YAoDNL,EACRE,EACP","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{BaseError as e}from"./Errors.js";import{slice as r,fromBytes as t,size as i,from as n}from"./Hex.js";import{stringify as a}from"./Json.js";import{maxUint256 as s}from"./Solidity.js";function u(e,r={}){const{recovered:t}=r;if(void 0===e.r)throw new m({signature:e});if(void 0===e.s)throw new m({signature:e});if(t&&void 0===e.yParity)throw new m({signature:e});if(e.r<0n||e.r>s)throw new g({value:e.r});if(e.s<0n||e.s>s)throw new p({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new w({value:e.yParity})}function o(e){return l(t(e))}function l(e){if(130!==e.length&&132!==e.length)throw new d({signature:e});const t=BigInt(r(e,0,32)),i=BigInt(r(e,32,64)),n=(()=>{const r=Number(`0x${e.slice(130)}`);if(!Number.isNaN(r))try{return b(r)}catch{throw new w({value:r})}})();return void 0===n?{r:t,s:i}:{r:t,s:i,yParity:n}}function y(e){if(void 0!==e.r&&void 0!==e.s)return c(e)}function c(e){const r="string"==typeof e?l(e):e instanceof Uint8Array?o(e):"string"==typeof e.r?f(e):e.v?v(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return u(r),r}function v(e){return{r:e.r,s:e.s,yParity:b(e.v)}}function f(e){const r=(()=>{const r=e.v?Number(e.v):void 0;let t=e.yParity?Number(e.yParity):void 0;if("number"==typeof r&&"number"!=typeof t&&(t=b(r)),"number"!=typeof t)throw new w({value:e.yParity});return t})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:r}}function b(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new P({value:e})}class d extends e{constructor({signature:e}){super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${i(n(e))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class m extends e{constructor({signature:e}){super(`Signature \`${a(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class g extends e{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class p extends e{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class w extends e{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class P extends e{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}export{g as InvalidRError,p as InvalidSError,d as InvalidSerializedSizeError,P as InvalidVError,w as InvalidYParityError,m as MissingPropertiesError,u as assert,y as extract,c as from,o as fromBytes,l as fromHex,v as fromLegacy,f as fromRpc,b as vToYParity};
|
|
2
|
+
//# sourceMappingURL=Signature.js.map
|