viem 2.7.22 → 2.8.0
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/CHANGELOG.md +10 -0
- package/_cjs/accounts/utils/sign.js +1 -0
- package/_cjs/accounts/utils/sign.js.map +1 -1
- package/_cjs/accounts/utils/signTransaction.js +11 -2
- package/_cjs/accounts/utils/signTransaction.js.map +1 -1
- package/_cjs/actions/index.js +4 -2
- package/_cjs/actions/index.js.map +1 -1
- package/_cjs/actions/public/call.js +3 -1
- package/_cjs/actions/public/call.js.map +1 -1
- package/_cjs/actions/public/estimateGas.js +3 -1
- package/_cjs/actions/public/estimateGas.js.map +1 -1
- package/_cjs/actions/public/getBlobBaseFee.js +11 -0
- package/_cjs/actions/public/getBlobBaseFee.js.map +1 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js +11 -2
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendRawTransaction.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +7 -8
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/signTransaction.js +7 -6
- package/_cjs/actions/wallet/signTransaction.js.map +1 -1
- package/_cjs/chains/celo/serializers.js +10 -15
- package/_cjs/chains/celo/serializers.js.map +1 -1
- package/_cjs/chains/definitions/plumeTestnet.js +30 -0
- package/_cjs/chains/definitions/plumeTestnet.js.map +1 -0
- package/_cjs/chains/index.js +5 -3
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/chains/opStack/actions/estimateL1Fee.js +1 -10
- package/_cjs/chains/opStack/actions/estimateL1Fee.js.map +1 -1
- package/_cjs/chains/opStack/actions/estimateL1Gas.js +1 -10
- package/_cjs/chains/opStack/actions/estimateL1Gas.js.map +1 -1
- package/_cjs/chains/opStack/actions/finalizeWithdrawal.js +1 -1
- package/_cjs/chains/opStack/actions/finalizeWithdrawal.js.map +1 -1
- package/_cjs/chains/opStack/actions/proveWithdrawal.js +1 -1
- package/_cjs/chains/opStack/actions/proveWithdrawal.js.map +1 -1
- package/_cjs/chains/opStack/serializers.js +3 -3
- package/_cjs/chains/opStack/serializers.js.map +1 -1
- package/_cjs/chains/zksync/actions/sendTransaction.js.map +1 -1
- package/_cjs/chains/zksync/actions/signEip712Transaction.js.map +1 -1
- package/_cjs/chains/zksync/serializers.js +6 -6
- package/_cjs/chains/zksync/serializers.js.map +1 -1
- package/_cjs/clients/decorators/public.js.map +1 -1
- package/_cjs/clients/decorators/wallet.js.map +1 -1
- package/_cjs/constants/blob.js +11 -0
- package/_cjs/constants/blob.js.map +1 -0
- package/_cjs/constants/kzg.js +7 -0
- package/_cjs/constants/kzg.js.map +1 -0
- package/_cjs/errors/blob.js +63 -0
- package/_cjs/errors/blob.js.map +1 -0
- package/_cjs/errors/transaction.js +1 -0
- package/_cjs/errors/transaction.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/index.js +22 -2
- package/_cjs/index.js.map +1 -1
- package/_cjs/node/index.js +3 -1
- package/_cjs/node/index.js.map +1 -1
- package/_cjs/node/trustedSetups.js +7 -0
- package/_cjs/node/trustedSetups.js.map +1 -0
- package/_cjs/types/eip4844.js +3 -0
- package/_cjs/types/eip4844.js.map +1 -0
- package/_cjs/types/kzg.js +3 -0
- package/_cjs/types/kzg.js.map +1 -0
- package/_cjs/utils/blob/blobsToCommitments.js +20 -0
- package/_cjs/utils/blob/blobsToCommitments.js.map +1 -0
- package/_cjs/utils/blob/blobsToProofs.js +26 -0
- package/_cjs/utils/blob/blobsToProofs.js.map +1 -0
- package/_cjs/utils/blob/commitmentToVersionedHash.js +14 -0
- package/_cjs/utils/blob/commitmentToVersionedHash.js.map +1 -0
- package/_cjs/utils/blob/commitmentsToVersionedHashes.js +19 -0
- package/_cjs/utils/blob/commitmentsToVersionedHashes.js.map +1 -0
- package/_cjs/utils/blob/fromBlobs.js +36 -0
- package/_cjs/utils/blob/fromBlobs.js.map +1 -0
- package/_cjs/utils/blob/sidecarsToVersionedHashes.js +19 -0
- package/_cjs/utils/blob/sidecarsToVersionedHashes.js.map +1 -0
- package/_cjs/utils/blob/toBlobSidecars.js +22 -0
- package/_cjs/utils/blob/toBlobSidecars.js.map +1 -0
- package/_cjs/utils/blob/toBlobs.js +48 -0
- package/_cjs/utils/blob/toBlobs.js.map +1 -0
- package/_cjs/utils/encoding/toRlp.js.map +1 -1
- package/_cjs/utils/formatters/transaction.js.map +1 -1
- package/_cjs/utils/formatters/transactionRequest.js +22 -25
- package/_cjs/utils/formatters/transactionRequest.js.map +1 -1
- package/_cjs/utils/kzg/defineKzg.js +11 -0
- package/_cjs/utils/kzg/defineKzg.js.map +1 -0
- package/_cjs/utils/kzg/setupKzg.js +17 -0
- package/_cjs/utils/kzg/setupKzg.js.map +1 -0
- package/_cjs/utils/signature/compactSignatureToSignature.js +3 -3
- package/_cjs/utils/signature/compactSignatureToSignature.js.map +1 -1
- package/_cjs/utils/signature/hexToSignature.js +6 -1
- package/_cjs/utils/signature/hexToSignature.js.map +1 -1
- package/_cjs/utils/signature/signatureToCompactSignature.js +3 -3
- package/_cjs/utils/signature/signatureToCompactSignature.js.map +1 -1
- package/_cjs/utils/signature/signatureToHex.js +9 -3
- package/_cjs/utils/signature/signatureToHex.js.map +1 -1
- package/_cjs/utils/transaction/assertTransaction.js +26 -1
- package/_cjs/utils/transaction/assertTransaction.js.map +1 -1
- package/_cjs/utils/transaction/getSerializedTransactionType.js +2 -0
- package/_cjs/utils/transaction/getSerializedTransactionType.js.map +1 -1
- package/_cjs/utils/transaction/getTransactionType.js +7 -1
- package/_cjs/utils/transaction/getTransactionType.js.map +1 -1
- package/_cjs/utils/transaction/parseTransaction.js +73 -0
- package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
- package/_cjs/utils/transaction/serializeAccessList.js.map +1 -1
- package/_cjs/utils/transaction/serializeTransaction.js +84 -21
- package/_cjs/utils/transaction/serializeTransaction.js.map +1 -1
- package/_esm/accounts/utils/sign.js +1 -0
- package/_esm/accounts/utils/sign.js.map +1 -1
- package/_esm/accounts/utils/signTransaction.js +13 -2
- package/_esm/accounts/utils/signTransaction.js.map +1 -1
- package/_esm/actions/index.js +1 -0
- package/_esm/actions/index.js.map +1 -1
- package/_esm/actions/public/call.js +3 -1
- package/_esm/actions/public/call.js.map +1 -1
- package/_esm/actions/public/estimateGas.js +3 -1
- package/_esm/actions/public/estimateGas.js.map +1 -1
- package/_esm/actions/public/getBlobBaseFee.js +27 -0
- package/_esm/actions/public/getBlobBaseFee.js.map +1 -0
- package/_esm/actions/wallet/prepareTransactionRequest.js +12 -2
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendRawTransaction.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +7 -8
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/signTransaction.js +6 -5
- package/_esm/actions/wallet/signTransaction.js.map +1 -1
- package/_esm/chains/celo/serializers.js +10 -17
- package/_esm/chains/celo/serializers.js.map +1 -1
- package/_esm/chains/definitions/plumeTestnet.js +27 -0
- package/_esm/chains/definitions/plumeTestnet.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/chains/opStack/actions/estimateL1Fee.js +1 -10
- package/_esm/chains/opStack/actions/estimateL1Fee.js.map +1 -1
- package/_esm/chains/opStack/actions/estimateL1Gas.js +1 -10
- package/_esm/chains/opStack/actions/estimateL1Gas.js.map +1 -1
- package/_esm/chains/opStack/actions/finalizeWithdrawal.js +1 -1
- package/_esm/chains/opStack/actions/finalizeWithdrawal.js.map +1 -1
- package/_esm/chains/opStack/actions/proveWithdrawal.js +1 -1
- package/_esm/chains/opStack/actions/proveWithdrawal.js.map +1 -1
- package/_esm/chains/opStack/serializers.js +2 -2
- package/_esm/chains/opStack/serializers.js.map +1 -1
- package/_esm/chains/zksync/actions/sendTransaction.js.map +1 -1
- package/_esm/chains/zksync/actions/signEip712Transaction.js.map +1 -1
- package/_esm/chains/zksync/serializers.js +6 -6
- package/_esm/chains/zksync/serializers.js.map +1 -1
- package/_esm/clients/decorators/public.js.map +1 -1
- package/_esm/clients/decorators/wallet.js.map +1 -1
- package/_esm/constants/blob.js +16 -0
- package/_esm/constants/blob.js.map +1 -0
- package/_esm/constants/kzg.js +7 -0
- package/_esm/constants/kzg.js.map +1 -0
- package/_esm/errors/blob.js +56 -0
- package/_esm/errors/blob.js.map +1 -0
- package/_esm/errors/transaction.js +1 -0
- package/_esm/errors/transaction.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/index.js +10 -0
- package/_esm/index.js.map +1 -1
- package/_esm/node/index.js +1 -0
- package/_esm/node/index.js.map +1 -1
- package/_esm/node/trustedSetups.js +4 -0
- package/_esm/node/trustedSetups.js.map +1 -0
- package/_esm/types/eip4844.js +2 -0
- package/_esm/types/eip4844.js.map +1 -0
- package/_esm/types/kzg.js +2 -0
- package/_esm/types/kzg.js.map +1 -0
- package/_esm/utils/blob/blobsToCommitments.js +28 -0
- package/_esm/utils/blob/blobsToCommitments.js.map +1 -0
- package/_esm/utils/blob/blobsToProofs.js +38 -0
- package/_esm/utils/blob/blobsToProofs.js.map +1 -0
- package/_esm/utils/blob/commitmentToVersionedHash.js +27 -0
- package/_esm/utils/blob/commitmentToVersionedHash.js.map +1 -0
- package/_esm/utils/blob/commitmentsToVersionedHashes.js +32 -0
- package/_esm/utils/blob/commitmentsToVersionedHashes.js.map +1 -0
- package/_esm/utils/blob/fromBlobs.js +33 -0
- package/_esm/utils/blob/fromBlobs.js.map +1 -0
- package/_esm/utils/blob/sidecarsToVersionedHashes.js +26 -0
- package/_esm/utils/blob/sidecarsToVersionedHashes.js.map +1 -0
- package/_esm/utils/blob/toBlobSidecars.js +45 -0
- package/_esm/utils/blob/toBlobSidecars.js.map +1 -0
- package/_esm/utils/blob/toBlobs.js +58 -0
- package/_esm/utils/blob/toBlobs.js.map +1 -0
- package/_esm/utils/encoding/toRlp.js.map +1 -1
- package/_esm/utils/formatters/transaction.js.map +1 -1
- package/_esm/utils/formatters/transactionRequest.js +23 -26
- package/_esm/utils/formatters/transactionRequest.js.map +1 -1
- package/_esm/utils/kzg/defineKzg.js +21 -0
- package/_esm/utils/kzg/defineKzg.js.map +1 -0
- package/_esm/utils/kzg/setupKzg.js +25 -0
- package/_esm/utils/kzg/setupKzg.js.map +1 -0
- package/_esm/utils/signature/compactSignatureToSignature.js +3 -3
- package/_esm/utils/signature/compactSignatureToSignature.js.map +1 -1
- package/_esm/utils/signature/hexToSignature.js +6 -1
- package/_esm/utils/signature/hexToSignature.js.map +1 -1
- package/_esm/utils/signature/signatureToCompactSignature.js +4 -4
- package/_esm/utils/signature/signatureToCompactSignature.js.map +1 -1
- package/_esm/utils/signature/signatureToHex.js +11 -4
- package/_esm/utils/signature/signatureToHex.js.map +1 -1
- package/_esm/utils/transaction/assertTransaction.js +24 -0
- package/_esm/utils/transaction/assertTransaction.js.map +1 -1
- package/_esm/utils/transaction/getSerializedTransactionType.js +2 -0
- package/_esm/utils/transaction/getSerializedTransactionType.js.map +1 -1
- package/_esm/utils/transaction/getTransactionType.js +7 -1
- package/_esm/utils/transaction/getTransactionType.js.map +1 -1
- package/_esm/utils/transaction/parseTransaction.js +74 -1
- package/_esm/utils/transaction/parseTransaction.js.map +1 -1
- package/_esm/utils/transaction/serializeAccessList.js.map +1 -1
- package/_esm/utils/transaction/serializeTransaction.js +85 -22
- package/_esm/utils/transaction/serializeTransaction.js.map +1 -1
- package/_types/accounts/types.d.ts +3 -3
- package/_types/accounts/types.d.ts.map +1 -1
- package/_types/accounts/utils/sign.d.ts.map +1 -1
- package/_types/accounts/utils/signTransaction.d.ts +5 -5
- package/_types/accounts/utils/signTransaction.d.ts.map +1 -1
- package/_types/actions/index.d.ts +1 -0
- package/_types/actions/index.d.ts.map +1 -1
- package/_types/actions/public/call.d.ts.map +1 -1
- package/_types/actions/public/estimateGas.d.ts.map +1 -1
- package/_types/actions/public/getBlobBaseFee.d.ts +30 -0
- package/_types/actions/public/getBlobBaseFee.d.ts.map +1 -0
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +27 -8
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendRawTransaction.d.ts +3 -5
- package/_types/actions/wallet/sendRawTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +4 -2
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/signTransaction.d.ts +5 -2
- package/_types/actions/wallet/signTransaction.d.ts.map +1 -1
- package/_types/chains/celo/chainConfig.d.ts +1282 -376
- package/_types/chains/celo/chainConfig.d.ts.map +1 -1
- package/_types/chains/celo/formatters.d.ts +1282 -376
- package/_types/chains/celo/formatters.d.ts.map +1 -1
- package/_types/chains/celo/serializers.d.ts +3 -4
- package/_types/chains/celo/serializers.d.ts.map +1 -1
- package/_types/chains/celo/types.d.ts +3 -8
- package/_types/chains/celo/types.d.ts.map +1 -1
- package/_types/chains/definitions/ancient8.d.ts +452 -188
- package/_types/chains/definitions/ancient8.d.ts.map +1 -1
- package/_types/chains/definitions/ancient8Sepolia.d.ts +452 -188
- package/_types/chains/definitions/ancient8Sepolia.d.ts.map +1 -1
- package/_types/chains/definitions/base.d.ts +452 -188
- package/_types/chains/definitions/base.d.ts.map +1 -1
- package/_types/chains/definitions/baseGoerli.d.ts +452 -188
- package/_types/chains/definitions/baseGoerli.d.ts.map +1 -1
- package/_types/chains/definitions/baseSepolia.d.ts +452 -188
- package/_types/chains/definitions/baseSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/celo.d.ts +1282 -376
- package/_types/chains/definitions/celo.d.ts.map +1 -1
- package/_types/chains/definitions/celoAlfajores.d.ts +1282 -376
- package/_types/chains/definitions/celoAlfajores.d.ts.map +1 -1
- package/_types/chains/definitions/fraxtal.d.ts +452 -188
- package/_types/chains/definitions/fraxtal.d.ts.map +1 -1
- package/_types/chains/definitions/fraxtalTestnet.d.ts +452 -188
- package/_types/chains/definitions/fraxtalTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/liskSepolia.d.ts +452 -188
- package/_types/chains/definitions/liskSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/optimism.d.ts +452 -188
- package/_types/chains/definitions/optimism.d.ts.map +1 -1
- package/_types/chains/definitions/optimismGoerli.d.ts +452 -188
- package/_types/chains/definitions/optimismGoerli.d.ts.map +1 -1
- package/_types/chains/definitions/optimismSepolia.d.ts +452 -188
- package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/pgn.d.ts +451 -187
- package/_types/chains/definitions/pgn.d.ts.map +1 -1
- package/_types/chains/definitions/pgnTestnet.d.ts +451 -187
- package/_types/chains/definitions/pgnTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/plumeTestnet.d.ts +37 -0
- package/_types/chains/definitions/plumeTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/zkSync.d.ts +692 -32
- package/_types/chains/definitions/zkSync.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +692 -32
- package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zkSyncTestnet.d.ts +692 -32
- package/_types/chains/definitions/zkSyncTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/zora.d.ts +452 -188
- package/_types/chains/definitions/zora.d.ts.map +1 -1
- package/_types/chains/definitions/zoraSepolia.d.ts +452 -188
- package/_types/chains/definitions/zoraSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/zoraTestnet.d.ts +452 -188
- package/_types/chains/definitions/zoraTestnet.d.ts.map +1 -1
- package/_types/chains/index.d.ts +2 -1
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/chains/opStack/actions/estimateL1Fee.d.ts.map +1 -1
- package/_types/chains/opStack/actions/estimateL1Gas.d.ts.map +1 -1
- package/_types/chains/opStack/actions/finalizeWithdrawal.d.ts.map +1 -1
- package/_types/chains/opStack/actions/proveWithdrawal.d.ts.map +1 -1
- package/_types/chains/opStack/chainConfig.d.ts +452 -188
- package/_types/chains/opStack/chainConfig.d.ts.map +1 -1
- package/_types/chains/opStack/formatters.d.ts +451 -187
- package/_types/chains/opStack/formatters.d.ts.map +1 -1
- package/_types/chains/opStack/serializers.d.ts +4 -3
- package/_types/chains/opStack/serializers.d.ts.map +1 -1
- package/_types/chains/opStack/types/transaction.d.ts +4 -8
- package/_types/chains/opStack/types/transaction.d.ts.map +1 -1
- package/_types/chains/zksync/actions/sendTransaction.d.ts.map +1 -1
- package/_types/chains/zksync/chainConfig.d.ts +692 -32
- package/_types/chains/zksync/chainConfig.d.ts.map +1 -1
- package/_types/chains/zksync/formatters.d.ts +692 -32
- package/_types/chains/zksync/formatters.d.ts.map +1 -1
- package/_types/chains/zksync/serializers.d.ts +3 -3
- package/_types/chains/zksync/serializers.d.ts.map +1 -1
- package/_types/chains/zksync/types/chain.d.ts +2 -2
- package/_types/chains/zksync/types/chain.d.ts.map +1 -1
- package/_types/chains/zksync/types/eip712.d.ts +2 -2
- package/_types/chains/zksync/types/eip712.d.ts.map +1 -1
- package/_types/clients/decorators/public.d.ts +2 -2
- package/_types/clients/decorators/public.d.ts.map +1 -1
- package/_types/clients/decorators/wallet.d.ts +4 -4
- package/_types/clients/decorators/wallet.d.ts.map +1 -1
- package/_types/constants/blob.d.ts +11 -0
- package/_types/constants/blob.d.ts.map +1 -0
- package/_types/constants/kzg.d.ts +6 -0
- package/_types/constants/kzg.d.ts.map +1 -0
- package/_types/errors/blob.d.ts +40 -0
- package/_types/errors/blob.d.ts.map +1 -0
- package/_types/errors/transaction.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/index.d.ts +11 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/node/index.d.ts +1 -0
- package/_types/node/index.d.ts.map +1 -1
- package/_types/node/trustedSetups.d.ts +3 -0
- package/_types/node/trustedSetups.d.ts.map +1 -0
- package/_types/types/account.d.ts +3 -3
- package/_types/types/account.d.ts.map +1 -1
- package/_types/types/chain.d.ts +2 -2
- package/_types/types/chain.d.ts.map +1 -1
- package/_types/types/eip1193.d.ts +3 -3
- package/_types/types/eip1193.d.ts.map +1 -1
- package/_types/types/eip4844.d.ts +11 -0
- package/_types/types/eip4844.d.ts.map +1 -0
- package/_types/types/fee.d.ts +2 -2
- package/_types/types/fee.d.ts.map +1 -1
- package/_types/types/kzg.d.ts +24 -0
- package/_types/types/kzg.d.ts.map +1 -0
- package/_types/types/misc.d.ts +15 -1
- package/_types/types/misc.d.ts.map +1 -1
- package/_types/types/rpc.d.ts +4 -4
- package/_types/types/rpc.d.ts.map +1 -1
- package/_types/types/transaction.d.ts +44 -9
- package/_types/types/transaction.d.ts.map +1 -1
- package/_types/types/utils.d.ts +38 -2
- package/_types/types/utils.d.ts.map +1 -1
- package/_types/utils/blob/blobsToCommitments.d.ts +31 -0
- package/_types/utils/blob/blobsToCommitments.d.ts.map +1 -0
- package/_types/utils/blob/blobsToProofs.d.ts +37 -0
- package/_types/utils/blob/blobsToProofs.d.ts.map +1 -0
- package/_types/utils/blob/commitmentToVersionedHash.d.ts +35 -0
- package/_types/utils/blob/commitmentToVersionedHash.d.ts.map +1 -0
- package/_types/utils/blob/commitmentsToVersionedHashes.d.ts +34 -0
- package/_types/utils/blob/commitmentsToVersionedHashes.d.ts.map +1 -0
- package/_types/utils/blob/fromBlobs.d.ts +16 -0
- package/_types/utils/blob/fromBlobs.d.ts.map +1 -0
- package/_types/utils/blob/sidecarsToVersionedHashes.d.ts +29 -0
- package/_types/utils/blob/sidecarsToVersionedHashes.d.ts.map +1 -0
- package/_types/utils/blob/toBlobSidecars.d.ts +57 -0
- package/_types/utils/blob/toBlobSidecars.d.ts.map +1 -0
- package/_types/utils/blob/toBlobs.d.ts +28 -0
- package/_types/utils/blob/toBlobs.d.ts.map +1 -0
- package/_types/utils/encoding/toRlp.d.ts +1 -1
- package/_types/utils/encoding/toRlp.d.ts.map +1 -1
- package/_types/utils/formatters/transaction.d.ts +25 -25
- package/_types/utils/formatters/transaction.d.ts.map +1 -1
- package/_types/utils/formatters/transactionRequest.d.ts +227 -3
- package/_types/utils/formatters/transactionRequest.d.ts.map +1 -1
- package/_types/utils/kzg/defineKzg.d.ts +21 -0
- package/_types/utils/kzg/defineKzg.d.ts.map +1 -0
- package/_types/utils/kzg/setupKzg.d.ts +21 -0
- package/_types/utils/kzg/setupKzg.d.ts.map +1 -0
- package/_types/utils/signature/hexToSignature.d.ts.map +1 -1
- package/_types/utils/signature/signatureToCompactSignature.d.ts +1 -1
- package/_types/utils/signature/signatureToHex.d.ts +2 -2
- package/_types/utils/signature/signatureToHex.d.ts.map +1 -1
- package/_types/utils/transaction/assertTransaction.d.ts +4 -1
- package/_types/utils/transaction/assertTransaction.d.ts.map +1 -1
- package/_types/utils/transaction/getSerializedTransactionType.d.ts +5 -3
- package/_types/utils/transaction/getSerializedTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/getTransactionType.d.ts +34 -3
- package/_types/utils/transaction/getTransactionType.d.ts.map +1 -1
- package/_types/utils/transaction/parseTransaction.d.ts +7 -5
- package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
- package/_types/utils/transaction/serializeTransaction.d.ts +13 -6
- package/_types/utils/transaction/serializeTransaction.d.ts.map +1 -1
- package/accounts/types.ts +9 -5
- package/accounts/utils/sign.ts +1 -0
- package/accounts/utils/signTransaction.ts +37 -22
- package/actions/index.ts +5 -0
- package/actions/public/call.ts +4 -0
- package/actions/public/estimateGas.ts +4 -0
- package/actions/public/getBlobBaseFee.ts +42 -0
- package/actions/wallet/prepareTransactionRequest.ts +134 -61
- package/actions/wallet/sendRawTransaction.ts +3 -5
- package/actions/wallet/sendTransaction.ts +32 -21
- package/actions/wallet/signTransaction.ts +34 -18
- package/chains/celo/serializers.ts +12 -25
- package/chains/celo/types.ts +5 -10
- package/chains/definitions/plumeTestnet.ts +28 -0
- package/chains/index.ts +1 -1
- package/chains/opStack/actions/estimateL1Fee.ts +12 -16
- package/chains/opStack/actions/estimateL1Gas.ts +12 -16
- package/chains/opStack/actions/finalizeWithdrawal.ts +3 -2
- package/chains/opStack/actions/proveWithdrawal.ts +3 -2
- package/chains/opStack/serializers.ts +5 -5
- package/chains/opStack/types/transaction.ts +9 -11
- package/chains/zksync/actions/sendTransaction.ts +2 -1
- package/chains/zksync/actions/signEip712Transaction.ts +2 -2
- package/chains/zksync/serializers.ts +14 -10
- package/chains/zksync/types/chain.ts +4 -7
- package/chains/zksync/types/eip712.ts +2 -2
- package/clients/decorators/public.ts +8 -4
- package/clients/decorators/wallet.ts +14 -6
- package/constants/blob.ts +21 -0
- package/constants/kzg.ts +9 -0
- package/errors/blob.ts +67 -0
- package/errors/transaction.ts +1 -0
- package/errors/version.ts +1 -1
- package/index.ts +64 -0
- package/node/index.ts +2 -0
- package/node/trustedSetups.ts +11 -0
- package/package.json +1 -1
- package/trusted-setups/mainnet.json +8265 -0
- package/trusted-setups/minimal.json +8265 -0
- package/types/account.ts +3 -3
- package/types/chain.ts +3 -1
- package/types/eip1193.ts +3 -3
- package/types/eip4844.ts +12 -0
- package/types/fee.ts +3 -2
- package/types/kzg.ts +32 -0
- package/types/misc.ts +20 -1
- package/types/rpc.ts +11 -6
- package/types/transaction.ts +75 -17
- package/types/utils.ts +49 -1
- package/utils/blob/blobsToCommitments.ts +69 -0
- package/utils/blob/blobsToProofs.ts +93 -0
- package/utils/blob/commitmentToVersionedHash.ts +62 -0
- package/utils/blob/commitmentsToVersionedHashes.ts +71 -0
- package/utils/blob/fromBlobs.ts +73 -0
- package/utils/blob/sidecarsToVersionedHashes.ts +66 -0
- package/utils/blob/toBlobSidecars.ts +109 -0
- package/utils/blob/toBlobs.ts +113 -0
- package/utils/encoding/toRlp.ts +2 -2
- package/utils/formatters/transaction.ts +3 -2
- package/utils/formatters/transactionRequest.ts +28 -35
- package/utils/kzg/defineKzg.ts +30 -0
- package/utils/kzg/setupKzg.ts +38 -0
- package/utils/signature/compactSignatureToSignature.ts +3 -3
- package/utils/signature/hexToSignature.ts +6 -1
- package/utils/signature/signatureToCompactSignature.ts +4 -4
- package/utils/signature/signatureToHex.ts +9 -4
- package/utils/transaction/assertTransaction.ts +41 -0
- package/utils/transaction/getSerializedTransactionType.ts +34 -11
- package/utils/transaction/getTransactionType.ts +109 -26
- package/utils/transaction/parseTransaction.ts +128 -8
- package/utils/transaction/serializeAccessList.ts +1 -1
- package/utils/transaction/serializeTransaction.ts +172 -39
package/types/account.ts
CHANGED
@@ -15,9 +15,9 @@ export type GetAccountParameter<
|
|
15
15
|
TRequired extends boolean = true,
|
16
16
|
> = IsUndefined<TAccount> extends true
|
17
17
|
? TRequired extends true
|
18
|
-
? { account: TAccountOverride }
|
19
|
-
: { account?: TAccountOverride }
|
20
|
-
: { account?: TAccountOverride }
|
18
|
+
? { account: TAccountOverride | Account | Address }
|
19
|
+
: { account?: TAccountOverride | Account | Address | undefined }
|
20
|
+
: { account?: TAccountOverride | Account | Address | undefined }
|
21
21
|
|
22
22
|
export type ParseAccount<
|
23
23
|
TAccountOrAddress extends Account | Address | undefined =
|
package/types/chain.ts
CHANGED
@@ -9,6 +9,7 @@ import type { FeeValuesType } from '../types/fee.js'
|
|
9
9
|
import type {
|
10
10
|
TransactionSerializable,
|
11
11
|
TransactionSerializableGeneric,
|
12
|
+
TransactionSerializedGeneric,
|
12
13
|
} from '../types/transaction.js'
|
13
14
|
import type { IsNarrowable, IsUndefined, Prettify } from '../types/utils.js'
|
14
15
|
import type { FormattedBlock } from '../utils/formatters/block.js'
|
@@ -162,7 +163,8 @@ export type ChainSerializers<
|
|
162
163
|
? TransactionSerializableGeneric &
|
163
164
|
Parameters<formatters['transactionRequest']['format']>[0]
|
164
165
|
: TransactionSerializable
|
165
|
-
: TransactionSerializable
|
166
|
+
: TransactionSerializable,
|
167
|
+
TransactionSerializedGeneric
|
166
168
|
>
|
167
169
|
| undefined
|
168
170
|
}
|
package/types/eip1193.ts
CHANGED
@@ -195,14 +195,14 @@ export type PublicRpcSchema = [
|
|
195
195
|
ReturnType: Quantity
|
196
196
|
},
|
197
197
|
/**
|
198
|
-
* @description Returns the
|
198
|
+
* @description Returns the base fee per blob gas in wei.
|
199
199
|
*
|
200
200
|
* @example
|
201
|
-
* provider.request({ method: '
|
201
|
+
* provider.request({ method: 'eth_blobBaseFee' })
|
202
202
|
* // => '0x09184e72a000'
|
203
203
|
*/
|
204
204
|
{
|
205
|
-
Method: '
|
205
|
+
Method: 'eth_blobBaseFee'
|
206
206
|
Parameters?: undefined
|
207
207
|
ReturnType: Quantity
|
208
208
|
},
|
package/types/eip4844.ts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { ByteArray, Hex } from './misc.js'
|
2
|
+
|
3
|
+
export type BlobSidecar<type extends Hex | ByteArray = Hex | ByteArray> = {
|
4
|
+
/** The blob associated with the transaction. */
|
5
|
+
blob: type
|
6
|
+
/** The KZG commitment corresponding to this blob. */
|
7
|
+
commitment: type
|
8
|
+
/** The KZG proof corresponding to this blob and commitment. */
|
9
|
+
proof: type
|
10
|
+
}
|
11
|
+
export type BlobSidecars<type extends Hex | ByteArray = Hex | ByteArray> =
|
12
|
+
BlobSidecar<type>[]
|
package/types/fee.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Assign } from './utils.js'
|
1
|
+
import type { Assign, OneOf } from './utils.js'
|
2
2
|
|
3
3
|
export type FeeHistory<TQuantity = bigint> = {
|
4
4
|
/**
|
@@ -39,9 +39,10 @@ export type FeeValuesEIP4844<TQuantity = bigint> = Assign<
|
|
39
39
|
}
|
40
40
|
>
|
41
41
|
|
42
|
-
export type FeeValues<TQuantity = bigint> =
|
42
|
+
export type FeeValues<TQuantity = bigint> = OneOf<
|
43
43
|
| FeeValuesLegacy<TQuantity>
|
44
44
|
| FeeValuesEIP1559<TQuantity>
|
45
45
|
| FeeValuesEIP4844<TQuantity>
|
46
|
+
>
|
46
47
|
|
47
48
|
export type FeeValuesType = 'legacy' | 'eip1559' | 'eip4844'
|
package/types/kzg.ts
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import type { LocalAccount } from './account.js'
|
3
|
+
import type { ByteArray } from './misc.js'
|
4
|
+
import type { TransactionRequestEIP4844 } from './transaction.js'
|
5
|
+
import type { MaybeRequired } from './utils.js'
|
6
|
+
|
7
|
+
export type Kzg = {
|
8
|
+
/**
|
9
|
+
* Convert a blob to a KZG commitment.
|
10
|
+
*/
|
11
|
+
blobToKzgCommitment(blob: ByteArray): ByteArray
|
12
|
+
/**
|
13
|
+
* Given a blob, return the KZG proof that is used to verify it against the
|
14
|
+
* commitment.
|
15
|
+
*/
|
16
|
+
computeBlobKzgProof(blob: ByteArray, commitment: ByteArray): ByteArray
|
17
|
+
}
|
18
|
+
|
19
|
+
export type GetTransactionRequestKzgParameter<
|
20
|
+
request extends unknown | undefined = undefined,
|
21
|
+
> = MaybeRequired<
|
22
|
+
{
|
23
|
+
/** KZG implementation */
|
24
|
+
kzg?: Kzg
|
25
|
+
},
|
26
|
+
request extends {
|
27
|
+
account: LocalAccount<string, Address>
|
28
|
+
blobs: TransactionRequestEIP4844['blobs']
|
29
|
+
}
|
30
|
+
? true
|
31
|
+
: false
|
32
|
+
>
|
package/types/misc.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import type { OneOf } from './utils.js'
|
2
|
+
|
1
3
|
export type ByteArray = Uint8Array
|
2
4
|
export type Hex = `0x${string}`
|
3
5
|
export type Hash = `0x${string}`
|
@@ -8,11 +10,28 @@ export type SignableMessage =
|
|
8
10
|
/** Raw data representation of the message. */
|
9
11
|
raw: Hex | ByteArray
|
10
12
|
}
|
11
|
-
export type
|
13
|
+
export type SignatureLegacy = {
|
12
14
|
r: Hex
|
13
15
|
s: Hex
|
14
16
|
v: bigint
|
15
17
|
}
|
18
|
+
export type Signature = OneOf<
|
19
|
+
| SignatureLegacy
|
20
|
+
| {
|
21
|
+
r: Hex
|
22
|
+
s: Hex
|
23
|
+
/** @deprecated use `yParity`. */
|
24
|
+
v: bigint
|
25
|
+
yParity?: number
|
26
|
+
}
|
27
|
+
| {
|
28
|
+
r: Hex
|
29
|
+
s: Hex
|
30
|
+
/** @deprecated use `yParity`. */
|
31
|
+
v?: bigint
|
32
|
+
yParity: number
|
33
|
+
}
|
34
|
+
>
|
16
35
|
export type CompactSignature = {
|
17
36
|
r: Hex
|
18
37
|
yParityAndS: Hex
|
package/types/rpc.ts
CHANGED
@@ -18,9 +18,10 @@ import type {
|
|
18
18
|
TransactionReceipt,
|
19
19
|
TransactionRequestEIP1559,
|
20
20
|
TransactionRequestEIP2930,
|
21
|
+
TransactionRequestEIP4844,
|
21
22
|
TransactionRequestLegacy,
|
22
23
|
} from './transaction.js'
|
23
|
-
import type { UnionOmit, UnionPartialBy } from './utils.js'
|
24
|
+
import type { OneOf, UnionOmit, UnionPartialBy } from './utils.js'
|
24
25
|
|
25
26
|
export type Index = `0x${string}`
|
26
27
|
export type Quantity = `0x${string}`
|
@@ -45,16 +46,20 @@ export type RpcTransactionReceipt = TransactionReceipt<
|
|
45
46
|
Status,
|
46
47
|
TransactionType
|
47
48
|
>
|
48
|
-
export type RpcTransactionRequest =
|
49
|
+
export type RpcTransactionRequest = OneOf<
|
49
50
|
| TransactionRequestLegacy<Quantity, Index, '0x0'>
|
50
51
|
| TransactionRequestEIP2930<Quantity, Index, '0x1'>
|
51
52
|
| TransactionRequestEIP1559<Quantity, Index, '0x2'>
|
53
|
+
| TransactionRequestEIP4844<Quantity, Index, '0x3'>
|
54
|
+
>
|
52
55
|
export type RpcTransaction<TPending extends boolean = boolean> = UnionOmit<
|
53
56
|
UnionPartialBy<
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
57
|
+
OneOf<
|
58
|
+
| TransactionLegacy<Quantity, Index, TPending, '0x0'>
|
59
|
+
| TransactionEIP2930<Quantity, Index, TPending, '0x1'>
|
60
|
+
| TransactionEIP1559<Quantity, Index, TPending, '0x2'>
|
61
|
+
| TransactionEIP4844<Quantity, Index, TPending, '0x3'>
|
62
|
+
>,
|
58
63
|
// `yParity` is optional on the RPC type as some nodes do not return it
|
59
64
|
// for 1559 & 2930 transactions (they should!).
|
60
65
|
'yParity'
|
package/types/transaction.ts
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
+
import type { BlobSidecar } from './eip4844.js'
|
3
4
|
import type {
|
4
5
|
FeeValuesEIP1559,
|
5
6
|
FeeValuesEIP4844,
|
6
7
|
FeeValuesLegacy,
|
7
8
|
} from './fee.js'
|
9
|
+
import type { Kzg } from './kzg.js'
|
8
10
|
import type { Log } from './log.js'
|
9
|
-
import type { Hash, Hex, Signature } from './misc.js'
|
10
|
-
import type { OneOf } from './utils.js'
|
11
|
+
import type { ByteArray, Hash, Hex, Signature } from './misc.js'
|
12
|
+
import type { Branded, IsNever, OneOf, RequiredBy } from './utils.js'
|
11
13
|
|
12
14
|
export type AccessList = { address: Address; storageKeys: Hex[] }[]
|
13
15
|
|
@@ -186,6 +188,7 @@ export type TransactionRequestLegacy<
|
|
186
188
|
> = TransactionRequestBase<TQuantity, TIndex> &
|
187
189
|
Partial<FeeValuesLegacy<TQuantity>> & {
|
188
190
|
accessList?: never
|
191
|
+
blobs?: undefined
|
189
192
|
type?: TTransactionType
|
190
193
|
}
|
191
194
|
export type TransactionRequestEIP2930<
|
@@ -195,6 +198,7 @@ export type TransactionRequestEIP2930<
|
|
195
198
|
> = TransactionRequestBase<TQuantity, TIndex> &
|
196
199
|
Partial<FeeValuesLegacy<TQuantity>> & {
|
197
200
|
accessList?: AccessList
|
201
|
+
blobs?: undefined
|
198
202
|
type?: TTransactionType
|
199
203
|
}
|
200
204
|
export type TransactionRequestEIP1559<
|
@@ -204,73 +208,127 @@ export type TransactionRequestEIP1559<
|
|
204
208
|
> = TransactionRequestBase<TQuantity, TIndex> &
|
205
209
|
Partial<FeeValuesEIP1559<TQuantity>> & {
|
206
210
|
accessList?: AccessList
|
211
|
+
blobs?: undefined
|
207
212
|
type?: TTransactionType
|
208
213
|
}
|
209
|
-
export type
|
214
|
+
export type TransactionRequestEIP4844<
|
215
|
+
TQuantity = bigint,
|
216
|
+
TIndex = number,
|
217
|
+
TTransactionType = 'eip4844',
|
218
|
+
> = RequiredBy<TransactionRequestBase<TQuantity, TIndex>, 'to'> &
|
219
|
+
RequiredBy<Partial<FeeValuesEIP4844<TQuantity>>, 'maxFeePerBlobGas'> & {
|
220
|
+
accessList?: AccessList
|
221
|
+
/** The blobs associated with this transaction. */
|
222
|
+
blobs: readonly Hex[] | readonly ByteArray[]
|
223
|
+
type?: TTransactionType
|
224
|
+
}
|
225
|
+
export type TransactionRequest<TQuantity = bigint, TIndex = number> = OneOf<
|
210
226
|
| TransactionRequestLegacy<TQuantity, TIndex>
|
211
227
|
| TransactionRequestEIP2930<TQuantity, TIndex>
|
212
228
|
| TransactionRequestEIP1559<TQuantity, TIndex>
|
229
|
+
| TransactionRequestEIP4844<TQuantity, TIndex>
|
230
|
+
>
|
213
231
|
|
214
232
|
export type TransactionSerializedEIP1559 = `0x02${string}`
|
215
233
|
export type TransactionSerializedEIP2930 = `0x01${string}`
|
216
|
-
export type
|
217
|
-
export type
|
218
|
-
export type
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
234
|
+
export type TransactionSerializedEIP4844 = `0x03${string}`
|
235
|
+
export type TransactionSerializedLegacy = Branded<`0x${string}`, 'legacy'>
|
236
|
+
export type TransactionSerializedGeneric = `0x${string}`
|
237
|
+
export type TransactionSerialized<
|
238
|
+
TType extends TransactionType = TransactionType,
|
239
|
+
result =
|
240
|
+
| (TType extends 'eip1559' ? TransactionSerializedEIP1559 : never)
|
241
|
+
| (TType extends 'eip2930' ? TransactionSerializedEIP2930 : never)
|
242
|
+
| (TType extends 'eip4844' ? TransactionSerializedEIP4844 : never)
|
243
|
+
| (TType extends 'legacy' ? TransactionSerializedLegacy : never),
|
244
|
+
> = IsNever<result> extends true ? TransactionSerializedGeneric : result
|
226
245
|
|
227
246
|
export type TransactionSerializableBase<
|
228
247
|
TQuantity = bigint,
|
229
248
|
TIndex = number,
|
230
249
|
> = Omit<TransactionRequestBase<TQuantity, TIndex>, 'from'> & Partial<Signature>
|
250
|
+
|
231
251
|
export type TransactionSerializableLegacy<
|
232
252
|
TQuantity = bigint,
|
233
253
|
TIndex = number,
|
234
254
|
> = TransactionSerializableBase<TQuantity, TIndex> &
|
235
255
|
Partial<FeeValuesLegacy<TQuantity>> & {
|
236
|
-
accessList?:
|
256
|
+
accessList?: undefined
|
257
|
+
blobs?: undefined
|
258
|
+
blobVersionedHashes?: undefined
|
237
259
|
chainId?: number
|
238
260
|
type?: 'legacy'
|
239
261
|
}
|
262
|
+
|
240
263
|
export type TransactionSerializableEIP2930<
|
241
264
|
TQuantity = bigint,
|
242
265
|
TIndex = number,
|
243
266
|
> = TransactionSerializableBase<TQuantity, TIndex> &
|
244
267
|
Partial<FeeValuesLegacy<TQuantity>> & {
|
245
268
|
accessList?: AccessList
|
269
|
+
blobs?: undefined
|
270
|
+
blobVersionedHashes?: undefined
|
246
271
|
chainId: number
|
247
272
|
type?: 'eip2930'
|
248
273
|
yParity?: number
|
249
274
|
}
|
275
|
+
|
250
276
|
export type TransactionSerializableEIP1559<
|
251
277
|
TQuantity = bigint,
|
252
278
|
TIndex = number,
|
253
279
|
> = TransactionSerializableBase<TQuantity, TIndex> &
|
254
280
|
Partial<FeeValuesEIP1559<TQuantity>> & {
|
255
281
|
accessList?: AccessList
|
282
|
+
blobs?: undefined
|
283
|
+
blobVersionedHashes?: undefined
|
256
284
|
chainId: number
|
257
285
|
type?: 'eip1559'
|
258
286
|
yParity?: number
|
259
287
|
}
|
288
|
+
|
289
|
+
export type TransactionSerializableEIP4844<
|
290
|
+
TQuantity = bigint,
|
291
|
+
TIndex = number,
|
292
|
+
> = TransactionSerializableBase<TQuantity, TIndex> &
|
293
|
+
Partial<FeeValuesEIP4844<TQuantity>> & {
|
294
|
+
accessList?: AccessList
|
295
|
+
chainId: number
|
296
|
+
type?: 'eip4844'
|
297
|
+
yParity?: number
|
298
|
+
} & OneOf<
|
299
|
+
| {
|
300
|
+
blobVersionedHashes: readonly Hex[]
|
301
|
+
sidecars?: readonly BlobSidecar<Hex>[] | false
|
302
|
+
}
|
303
|
+
| {
|
304
|
+
blobs: readonly Hex[] | readonly ByteArray[]
|
305
|
+
kzg: Kzg
|
306
|
+
sidecars?: false
|
307
|
+
}
|
308
|
+
>
|
309
|
+
|
260
310
|
export type TransactionSerializableGeneric<
|
261
311
|
TQuantity = bigint,
|
262
312
|
TIndex = number,
|
263
313
|
> = TransactionSerializableBase<TQuantity, TIndex> & {
|
264
314
|
accessList?: AccessList
|
315
|
+
blobs?: readonly Hex[] | readonly ByteArray[]
|
316
|
+
blobVersionedHashes?: readonly Hex[]
|
265
317
|
chainId?: number
|
266
318
|
gasPrice?: TQuantity
|
319
|
+
maxFeePerBlobGas?: TQuantity
|
267
320
|
maxFeePerGas?: TQuantity
|
268
321
|
maxPriorityFeePerGas?: TQuantity
|
269
|
-
|
322
|
+
sidecars?: readonly BlobSidecar<Hex>[] | false
|
323
|
+
type?: string
|
270
324
|
}
|
271
325
|
|
272
|
-
export type TransactionSerializable<
|
326
|
+
export type TransactionSerializable<
|
327
|
+
TQuantity = bigint,
|
328
|
+
TIndex = number,
|
329
|
+
> = OneOf<
|
273
330
|
| TransactionSerializableLegacy<TQuantity, TIndex>
|
274
331
|
| TransactionSerializableEIP2930<TQuantity, TIndex>
|
275
332
|
| TransactionSerializableEIP1559<TQuantity, TIndex>
|
276
|
-
|
|
333
|
+
| TransactionSerializableEIP4844<TQuantity, TIndex>
|
334
|
+
>
|
package/types/utils.ts
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
declare const symbol: unique symbol
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Creates a branded type of {@link T} with the brand {@link U}.
|
5
|
+
*
|
6
|
+
* @param T - Type to brand
|
7
|
+
* @param U - Label
|
8
|
+
* @returns Branded type
|
9
|
+
*
|
10
|
+
* @example
|
11
|
+
* type Result = Branded<string, 'foo'>
|
12
|
+
* // ^? type Result = string & { [symbol]: 'foo' }
|
13
|
+
*/
|
14
|
+
export type Branded<T, U> = T & { [symbol]: U }
|
15
|
+
|
1
16
|
/**
|
2
17
|
* Filters out all members of {@link T} that are not {@link P}
|
3
18
|
*
|
@@ -42,6 +57,21 @@ export type IsNarrowable<T, U> = IsNever<
|
|
42
57
|
*/
|
43
58
|
export type IsNever<T> = [T] extends [never] ? true : false
|
44
59
|
|
60
|
+
/**
|
61
|
+
* @description Returns type {@link T} if it is an opaque type of {@link U}
|
62
|
+
* @param T - Type to check
|
63
|
+
* @param U - Type to against
|
64
|
+
*
|
65
|
+
* @example
|
66
|
+
* type Result = Opaque<string, 'foo'>
|
67
|
+
* // ^? never
|
68
|
+
*
|
69
|
+
* @example
|
70
|
+
* type Result = Opaque<string, string>
|
71
|
+
* // ^? string
|
72
|
+
*/
|
73
|
+
export type Opaque<T, U> = IsNarrowable<T, U> extends true ? T : never
|
74
|
+
|
45
75
|
/**
|
46
76
|
* @description Evaluates boolean "or" condition for {@link T} properties.
|
47
77
|
* @param T - Type to check
|
@@ -203,10 +233,18 @@ export type ExactPartial<type> = {
|
|
203
233
|
|
204
234
|
export type OneOf<
|
205
235
|
union extends object,
|
236
|
+
fallback extends object | undefined = undefined,
|
206
237
|
///
|
207
238
|
keys extends KeyofUnion<union> = KeyofUnion<union>,
|
208
239
|
> = union extends infer Item
|
209
|
-
? Prettify<
|
240
|
+
? Prettify<
|
241
|
+
Item & {
|
242
|
+
[_K in Exclude<keys, keyof Item>]?: fallback extends object
|
243
|
+
? // @ts-ignore
|
244
|
+
fallback[_K]
|
245
|
+
: undefined
|
246
|
+
}
|
247
|
+
>
|
210
248
|
: never
|
211
249
|
type KeyofUnion<type> = type extends type ? keyof type : never
|
212
250
|
|
@@ -238,6 +276,16 @@ export type UnionOmit<type, keys extends keyof type> = type extends any
|
|
238
276
|
? Omit<type, keys>
|
239
277
|
: never
|
240
278
|
|
279
|
+
/**
|
280
|
+
* @description Construct a type with the properties of union type T except for those in type K.
|
281
|
+
* @example
|
282
|
+
* type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
283
|
+
* => { b: number } | { b: undefined, c: number }
|
284
|
+
*/
|
285
|
+
export type UnionPick<type, keys extends keyof type> = type extends any
|
286
|
+
? Pick<type, keys>
|
287
|
+
: never
|
288
|
+
|
241
289
|
/**
|
242
290
|
* @description Creates a type that is a partial of T, but with the required keys K.
|
243
291
|
*
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import type { ErrorType } from '../../errors/utils.js'
|
2
|
+
import type { Kzg } from '../../types/kzg.js'
|
3
|
+
import type { ByteArray, Hex } from '../../types/misc.js'
|
4
|
+
import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
|
5
|
+
import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
6
|
+
|
7
|
+
type To = 'hex' | 'bytes'
|
8
|
+
|
9
|
+
export type BlobsToCommitmentsParameters<
|
10
|
+
blobs extends ByteArray[] | Hex[] = ByteArray[] | Hex[],
|
11
|
+
to extends To | undefined = undefined,
|
12
|
+
> = {
|
13
|
+
/** Blobs to transform into commitments. */
|
14
|
+
blobs: blobs | ByteArray[] | Hex[]
|
15
|
+
/** KZG implementation. */
|
16
|
+
kzg: Pick<Kzg, 'blobToKzgCommitment'>
|
17
|
+
/** Return type. */
|
18
|
+
to?: to | To | undefined
|
19
|
+
}
|
20
|
+
|
21
|
+
export type BlobsToCommitmentsReturnType<to extends To> =
|
22
|
+
| (to extends 'bytes' ? ByteArray[] : never)
|
23
|
+
| (to extends 'hex' ? Hex[] : never)
|
24
|
+
|
25
|
+
export type BlobsToCommitmentsErrorType =
|
26
|
+
| HexToBytesErrorType
|
27
|
+
| BytesToHexErrorType
|
28
|
+
| ErrorType
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Compute commitments from a list of blobs.
|
32
|
+
*
|
33
|
+
* @example
|
34
|
+
* ```ts
|
35
|
+
* import { blobsToCommitments, toBlobs } from 'viem'
|
36
|
+
* import { kzg } from './kzg'
|
37
|
+
*
|
38
|
+
* const blobs = toBlobs({ data: '0x1234' })
|
39
|
+
* const commitments = blobsToCommitments({ blobs, kzg })
|
40
|
+
* ```
|
41
|
+
*/
|
42
|
+
export function blobsToCommitments<
|
43
|
+
const blobs extends ByteArray[] | Hex[],
|
44
|
+
to extends To =
|
45
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
46
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
47
|
+
>(
|
48
|
+
parameters: BlobsToCommitmentsParameters<blobs, to>,
|
49
|
+
): BlobsToCommitmentsReturnType<to> {
|
50
|
+
const { kzg } = parameters
|
51
|
+
|
52
|
+
const to =
|
53
|
+
parameters.to ?? (typeof parameters.blobs[0] === 'string' ? 'hex' : 'bytes')
|
54
|
+
const blobs = (
|
55
|
+
typeof parameters.blobs[0] === 'string'
|
56
|
+
? parameters.blobs.map((x) => hexToBytes(x as any))
|
57
|
+
: parameters.blobs
|
58
|
+
) as ByteArray[]
|
59
|
+
|
60
|
+
const commitments: ByteArray[] = []
|
61
|
+
for (const blob of blobs)
|
62
|
+
commitments.push(Uint8Array.from(kzg.blobToKzgCommitment(blob)))
|
63
|
+
|
64
|
+
return (to === 'bytes'
|
65
|
+
? commitments
|
66
|
+
: commitments.map((x) =>
|
67
|
+
bytesToHex(x),
|
68
|
+
)) as {} as BlobsToCommitmentsReturnType<to>
|
69
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
import type { ErrorType } from '../../errors/utils.js'
|
2
|
+
import type { Kzg } from '../../types/kzg.js'
|
3
|
+
import type { ByteArray, Hex } from '../../types/misc.js'
|
4
|
+
import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
|
5
|
+
import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
6
|
+
|
7
|
+
type To = 'hex' | 'bytes'
|
8
|
+
|
9
|
+
export type blobsToProofsParameters<
|
10
|
+
blobs extends ByteArray[] | Hex[],
|
11
|
+
commitments extends ByteArray[] | Hex[],
|
12
|
+
to extends To =
|
13
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
14
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
15
|
+
///
|
16
|
+
_blobsType =
|
17
|
+
| (blobs extends Hex[] ? Hex[] : never)
|
18
|
+
| (blobs extends ByteArray[] ? ByteArray[] : never),
|
19
|
+
> = {
|
20
|
+
/** Blobs to transform into proofs. */
|
21
|
+
blobs: blobs
|
22
|
+
/** Commitments for the blobs. */
|
23
|
+
commitments: commitments &
|
24
|
+
(commitments extends _blobsType
|
25
|
+
? {}
|
26
|
+
: `commitments must be the same type as blobs`)
|
27
|
+
/** KZG implementation. */
|
28
|
+
kzg: Pick<Kzg, 'computeBlobKzgProof'>
|
29
|
+
/** Return type. */
|
30
|
+
to?: to | To | undefined
|
31
|
+
}
|
32
|
+
|
33
|
+
export type blobsToProofsReturnType<to extends To> =
|
34
|
+
| (to extends 'bytes' ? ByteArray[] : never)
|
35
|
+
| (to extends 'hex' ? Hex[] : never)
|
36
|
+
|
37
|
+
export type blobsToProofsErrorType =
|
38
|
+
| BytesToHexErrorType
|
39
|
+
| HexToBytesErrorType
|
40
|
+
| ErrorType
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Compute the proofs for a list of blobs and their commitments.
|
44
|
+
*
|
45
|
+
* @example
|
46
|
+
* ```ts
|
47
|
+
* import {
|
48
|
+
* blobsToCommitments,
|
49
|
+
* toBlobs
|
50
|
+
* } from 'viem'
|
51
|
+
* import { kzg } from './kzg'
|
52
|
+
*
|
53
|
+
* const blobs = toBlobs({ data: '0x1234' })
|
54
|
+
* const commitments = blobsToCommitments({ blobs, kzg })
|
55
|
+
* const proofs = blobsToProofs({ blobs, commitments, kzg })
|
56
|
+
* ```
|
57
|
+
*/
|
58
|
+
export function blobsToProofs<
|
59
|
+
const blobs extends ByteArray[] | Hex[],
|
60
|
+
const commitments extends ByteArray[] | Hex[],
|
61
|
+
to extends To =
|
62
|
+
| (blobs extends Hex[] ? 'hex' : never)
|
63
|
+
| (blobs extends ByteArray[] ? 'bytes' : never),
|
64
|
+
>(
|
65
|
+
parameters: blobsToProofsParameters<blobs, commitments, to>,
|
66
|
+
): blobsToProofsReturnType<to> {
|
67
|
+
const { kzg } = parameters
|
68
|
+
|
69
|
+
const to =
|
70
|
+
parameters.to ?? (typeof parameters.blobs[0] === 'string' ? 'hex' : 'bytes')
|
71
|
+
|
72
|
+
const blobs = (
|
73
|
+
typeof parameters.blobs[0] === 'string'
|
74
|
+
? parameters.blobs.map((x) => hexToBytes(x as any))
|
75
|
+
: parameters.blobs
|
76
|
+
) as ByteArray[]
|
77
|
+
const commitments = (
|
78
|
+
typeof parameters.commitments[0] === 'string'
|
79
|
+
? parameters.commitments.map((x) => hexToBytes(x as any))
|
80
|
+
: parameters.commitments
|
81
|
+
) as ByteArray[]
|
82
|
+
|
83
|
+
const proofs: ByteArray[] = []
|
84
|
+
for (let i = 0; i < blobs.length; i++) {
|
85
|
+
const blob = blobs[i]
|
86
|
+
const commitment = commitments[i]
|
87
|
+
proofs.push(Uint8Array.from(kzg.computeBlobKzgProof(blob, commitment)))
|
88
|
+
}
|
89
|
+
|
90
|
+
return (to === 'bytes'
|
91
|
+
? proofs
|
92
|
+
: proofs.map((x) => bytesToHex(x))) as {} as blobsToProofsReturnType<to>
|
93
|
+
}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import type { ErrorType } from '../../errors/utils.js'
|
2
|
+
import type { ByteArray, Hex } from '../../types/misc.js'
|
3
|
+
import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
|
4
|
+
import { type Sha256ErrorType, sha256 } from '../hash/sha256.js'
|
5
|
+
|
6
|
+
type To = 'hex' | 'bytes'
|
7
|
+
|
8
|
+
export type CommitmentToVersionedHashParameters<
|
9
|
+
commitment extends Uint8Array | Hex = Uint8Array | Hex,
|
10
|
+
to extends To | undefined = undefined,
|
11
|
+
> = {
|
12
|
+
/** Commitment from blob. */
|
13
|
+
commitment: commitment | Uint8Array | Hex
|
14
|
+
/** Return type. */
|
15
|
+
to?: to | To | undefined
|
16
|
+
/** Version to tag onto the hash. */
|
17
|
+
version?: number
|
18
|
+
}
|
19
|
+
|
20
|
+
export type CommitmentToVersionedHashReturnType<to extends To> =
|
21
|
+
| (to extends 'bytes' ? ByteArray : never)
|
22
|
+
| (to extends 'hex' ? Hex : never)
|
23
|
+
|
24
|
+
export type CommitmentToVersionedHashErrorType =
|
25
|
+
| Sha256ErrorType
|
26
|
+
| BytesToHexErrorType
|
27
|
+
| ErrorType
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Transform a commitment to it's versioned hash.
|
31
|
+
*
|
32
|
+
* @example
|
33
|
+
* ```ts
|
34
|
+
* import {
|
35
|
+
* blobsToCommitments,
|
36
|
+
* commitmentToVersionedHash,
|
37
|
+
* toBlobs
|
38
|
+
* } from 'viem'
|
39
|
+
* import { kzg } from './kzg'
|
40
|
+
*
|
41
|
+
* const blobs = toBlobs({ data: '0x1234' })
|
42
|
+
* const [commitment] = blobsToCommitments({ blobs, kzg })
|
43
|
+
* const versionedHash = commitmentToVersionedHash({ commitment })
|
44
|
+
* ```
|
45
|
+
*/
|
46
|
+
export function commitmentToVersionedHash<
|
47
|
+
const commitment extends Hex | ByteArray,
|
48
|
+
to extends To =
|
49
|
+
| (commitment extends Hex ? 'hex' : never)
|
50
|
+
| (commitment extends ByteArray ? 'bytes' : never),
|
51
|
+
>(
|
52
|
+
parameters: CommitmentToVersionedHashParameters<commitment, to>,
|
53
|
+
): CommitmentToVersionedHashReturnType<to> {
|
54
|
+
const { commitment, version = 1 } = parameters
|
55
|
+
const to = parameters.to ?? (typeof commitment === 'string' ? 'hex' : 'bytes')
|
56
|
+
|
57
|
+
const versionedHash = sha256(commitment, 'bytes')
|
58
|
+
versionedHash.set([version], 0)
|
59
|
+
return (
|
60
|
+
to === 'bytes' ? versionedHash : bytesToHex(versionedHash)
|
61
|
+
) as CommitmentToVersionedHashReturnType<to>
|
62
|
+
}
|