Socket
Socket
Sign inDemoInstall

ethers

Package Overview
Dependencies
Maintainers
1
Versions
319
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethers - npm Package Compare versions

Comparing version 6.11.1 to 6.12.0-beta.1

output.txt

5

CHANGELOG.md

@@ -6,2 +6,7 @@ Change Log

ethers/v6.12.0-beta.1 (2024-03-27 14:40)
----------------------------------------
- Fix ignored throttle parameters ([#4663](https://github.com/ethers-io/ethers.js/issues/4663); [12772e9](https://github.com/ethers-io/ethers.js/commit/12772e9498b70f8538838f30e16f3792ea90e173)).
ethers/v6.11.1 (2024-02-14 13:13)

@@ -8,0 +13,0 @@ ---------------------------------

2

lib.commonjs/_version.js

@@ -8,3 +8,3 @@ "use strict";

*/
exports.version = "6.11.1";
exports.version = "6.12.0-beta.1";
//# sourceMappingURL=_version.js.map

@@ -19,5 +19,5 @@ export { version } from "./_version.js";

export type { Provider, Signer, AbstractProviderOptions, FallbackProviderOptions, AbstractProviderPlugin, BlockParams, BlockTag, ContractRunner, DebugEventBrowserProvider, Eip1193Provider, EventFilter, Filter, FilterByBlockHash, GasCostParameters, JsonRpcApiProviderOptions, JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcTransactionRequest, LogParams, MinedBlock, MinedTransactionResponse, Networkish, OrphanFilter, PerformActionFilter, PerformActionRequest, PerformActionTransaction, PreparedTransactionRequest, ProviderEvent, Subscriber, Subscription, TopicFilter, TransactionReceiptParams, TransactionRequest, TransactionResponseParams, WebSocketCreator, WebSocketLike } from "./providers/index.js";
export type { AccessList, AccessListish, AccessListEntry, TransactionLike } from "./transaction/index.js";
export type { AccessList, AccessListish, AccessListEntry, Blob, BlobLike, KzgLibrary, TransactionLike } from "./transaction/index.js";
export type { BytesLike, BigNumberish, Numeric, ErrorCode, FixedFormat, Utf8ErrorFunc, UnicodeNormalizationForm, Utf8ErrorReason, RlpStructuredData, RlpStructuredDataish, GetUrlResponse, FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc, FetchGatewayFunc, FetchGetUrlFunc, EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError, ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError, NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError, CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError, ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError, ActionRejectedError, CodedEthersError, CallExceptionAction, CallExceptionTransaction, EventEmitterable, Listener } from "./utils/index.js";
export type { CrowdsaleAccount, KeystoreAccount, EncryptOptions } from "./wallet/index.js";
//# sourceMappingURL=ethers.d.ts.map

@@ -155,4 +155,4 @@ "use strict";

}
else if (pop.type === 2) {
// Explicitly using EIP-1559
else if (pop.type === 2 || pop.type === 3) {
// Explicitly using EIP-1559 or EIP-4844
// Populate missing fee data

@@ -159,0 +159,0 @@ if (pop.maxFeePerGas == null) {

import type { AddressLike, NameResolver } from "../address/index.js";
import type { BigNumberish, EventEmitterable } from "../utils/index.js";
import type { Signature } from "../crypto/index.js";
import type { AccessList, AccessListish, TransactionLike } from "../transaction/index.js";
import type { AccessList, AccessListish, BlobLike, KzgLibrary, TransactionLike } from "../transaction/index.js";
import type { ContractRunner } from "./contracts.js";

@@ -147,2 +147,22 @@ import type { Network } from "./network.js";

enableCcipRead?: boolean;
/**
* The blob versioned hashes (see [[link-eip-4844]]).
*/
blobVersionedHashes?: null | Array<string>;
/**
* The maximum fee per blob gas (see [[link-eip-4844]]).
*/
maxFeePerBlobGas?: null | BigNumberish;
/**
* Any blobs to include in the transaction (see [[link-eip-4844]]).
*/
blobs?: null | Array<BlobLike>;
/**
* An external library for computing the KZG commitments and
* proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
*
* This is generally ``null``, unless you are creating BLOb
* transactions.
*/
kzg?: null | KzgLibrary;
}

@@ -149,0 +169,0 @@ /**

@@ -96,3 +96,3 @@ "use strict";

}
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
for (const key of bigIntKeys) {

@@ -123,2 +123,16 @@ if (!(key in req) || req[key] == null) {

}
if ("blobVersionedHashes" in req && req.blobVersionedHashes) {
result.blobVersionedHashes = req.blobVersionedHashes.slice();
}
if ("kzg" in req) {
result.kzg = req.kzg;
}
if ("blobs" in req && req.blobs) {
result.blobs = req.blobs.map((b) => {
if ((0, index_js_1.isBytesLike)(b)) {
return (0, index_js_1.hexlify)(b);
}
return Object.assign({}, b);
});
}
return result;

@@ -125,0 +139,0 @@ }

@@ -24,3 +24,3 @@ /**

export { Transaction } from "./transaction.js";
export type { TransactionLike } from "./transaction.js";
export type { Blob, BlobLike, KzgLibrary, TransactionLike } from "./transaction.js";
//# sourceMappingURL=index.d.ts.map

@@ -75,4 +75,47 @@ import { Signature } from "../crypto/index.js";

blobVersionedHashes?: null | Array<string>;
/**
* The blobs (if any) attached to this transaction (see [[link-eip-4844]]).
*/
blobs?: null | Array<BlobLike>;
/**
* An external library for computing the KZG commitments and
* proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
*
* This is generally ``null``, unless you are creating BLOb
* transactions.
*/
kzg?: null | KzgLibrary;
}
/**
* A full-valid BLOb object for [[link-eip-4844]] transactions.
*
* The commitment and proof should have been computed using a
* KZG library.
*/
export interface Blob {
data: string;
proof: string;
commitment: string;
}
/**
* A BLOb object that can be passed for [[link-eip-4844]]
* transactions.
*
* It may have had its commitment and proof already provided
* or rely on an attached [[KzgLibrary]] to compute them.
*/
export type BlobLike = BytesLike | {
data: BytesLike;
proof: BytesLike;
commitment: BytesLike;
};
/**
* A KZG Library with the necessary functions to compute
* BLOb commitments and proofs.
*/
export interface KzgLibrary {
blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
}
/**
* A **Transaction** describes an operation to be executed on

@@ -175,3 +218,3 @@ * Ethereum by an Externally Owned Account (EOA). It includes

/**
* The BLOB versioned hashes for Cancun transactions.
* The BLOb versioned hashes for Cancun transactions.
*/

@@ -181,2 +224,29 @@ get blobVersionedHashes(): null | Array<string>;

/**
* The BLObs for the Transaction, if any.
*
* If ``blobs`` is non-``null``, then the [[seriailized]]
* will return the network formatted sidecar, otherwise it
* will return the standard [[link-eip-2718]] payload. The
* [[unsignedSerialized]] is unaffected regardless.
*
* When setting ``blobs``, either fully valid [[Blob]] objects
* may be specified (i.e. correctly padded, with correct
* committments and proofs) or a raw [[BytesLike]] may
* be provided.
*
* If raw [[BytesLike]] are provided, the [[kzg]] property **must**
* be already set. The blob will be correctly padded and the
* [[KzgLibrary]] will be used to compute the committment and
* proof for the blob.
*
* Setting this automatically populates [[blobVersionedHashes]],
* overwriting any existing values. Setting this to ``null``
* does **not** remove the [[blobVersionedHashes]], leaving them
* present.
*/
get blobs(): null | Array<Blob>;
set blobs(_blobs: null | Array<BlobLike>);
get kzg(): null | KzgLibrary;
set kzg(kzg: null | KzgLibrary);
/**
* Creates a new Transaction with default values.

@@ -183,0 +253,0 @@ */

@@ -16,2 +16,11 @@ "use strict";

const BN_MAX_UINT = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
const BLOB_SIZE = 4096 * 32;
function getVersionedHash(version, hash) {
let versioned = version.toString(16);
while (versioned.length < 2) {
versioned = "0" + versioned;
}
versioned += (0, index_js_2.sha256)(hash).substring(4);
return "0x" + versioned;
}
function handleAddress(value) {

@@ -99,3 +108,3 @@ if (value === "0x") {

});
tx.hash = (0, index_js_2.keccak256)(data);
//tx.hash = keccak256(data);
}

@@ -191,3 +200,3 @@ return tx;

}
tx.hash = (0, index_js_2.keccak256)(data);
//tx.hash = keccak256(data);
_parseEipSignature(tx, fields.slice(9));

@@ -233,3 +242,3 @@ return tx;

}
tx.hash = (0, index_js_2.keccak256)(data);
//tx.hash = keccak256(data);
_parseEipSignature(tx, fields.slice(8));

@@ -257,4 +266,25 @@ return tx;

function _parseEip4844(data) {
const fields = (0, index_js_3.decodeRlp)((0, index_js_3.getBytes)(data).slice(1));
(0, index_js_3.assertArgument)(Array.isArray(fields) && (fields.length === 11 || fields.length === 14), "invalid field count for transaction type: 3", "data", (0, index_js_3.hexlify)(data));
let fields = (0, index_js_3.decodeRlp)((0, index_js_3.getBytes)(data).slice(1));
let typeName = "3";
let blobs = null;
// Parse the network format
if (fields.length === 4 && Array.isArray(fields[0])) {
typeName = "3 (network format)";
const fBlobs = fields[1], fCommits = fields[2], fProofs = fields[3];
(0, index_js_3.assertArgument)(Array.isArray(fBlobs), "invalid network format: blobs not an array", "fields[1]", fBlobs);
(0, index_js_3.assertArgument)(Array.isArray(fCommits), "invalid network format: commitments not an array", "fields[2]", fCommits);
(0, index_js_3.assertArgument)(Array.isArray(fProofs), "invalid network format: proofs not an array", "fields[3]", fProofs);
(0, index_js_3.assertArgument)(fBlobs.length === fCommits.length, "invalid network format: blobs/commitments length mismatch", "fields", fields);
(0, index_js_3.assertArgument)(fBlobs.length === fProofs.length, "invalid network format: blobs/proofs length mismatch", "fields", fields);
blobs = [];
for (let i = 0; i < fields[1].length; i++) {
blobs.push({
data: fBlobs[i],
commitment: fCommits[i],
proof: fProofs[i],
});
}
fields = fields[0];
}
(0, index_js_3.assertArgument)(Array.isArray(fields) && (fields.length === 11 || fields.length === 14), `invalid field count for transaction type: ${typeName}`, "data", (0, index_js_3.hexlify)(data));
const tx = {

@@ -275,3 +305,6 @@ type: 3,

};
(0, index_js_3.assertArgument)(tx.to != null, "invalid address for transaction type: 3", "data", data);
if (blobs) {
tx.blobs = blobs;
}
(0, index_js_3.assertArgument)(tx.to != null, `invalid address for transaction type: ${typeName}`, "data", data);
(0, index_js_3.assertArgument)(Array.isArray(tx.blobVersionedHashes), "invalid blobVersionedHashes: must be an array", "data", data);

@@ -285,7 +318,9 @@ for (let i = 0; i < tx.blobVersionedHashes.length; i++) {

}
tx.hash = (0, index_js_2.keccak256)(data);
// @TODO: Do we need to do this? This is only called internally
// and used to verify hashes; it might save time to not do this
//tx.hash = keccak256(concat([ "0x03", encodeRlp(fields) ]));
_parseEipSignature(tx, fields.slice(11));
return tx;
}
function _serializeEip4844(tx, sig) {
function _serializeEip4844(tx, sig, blobs) {
const fields = [

@@ -308,2 +343,14 @@ formatNumber(tx.chainId, "chainId"),

fields.push((0, index_js_3.toBeArray)(sig.s));
// We have blobs; return the network wrapped format
if (blobs) {
return (0, index_js_3.concat)([
"0x03",
(0, index_js_3.encodeRlp)([
fields,
blobs.map((b) => b.data),
blobs.map((b) => b.commitment),
blobs.map((b) => b.proof),
])
]);
}
}

@@ -340,2 +387,4 @@ return (0, index_js_3.concat)(["0x03", (0, index_js_3.encodeRlp)(fields)]);

#blobVersionedHashes;
#kzg;
#blobs;
/**

@@ -522,3 +571,3 @@ * The transaction type.

/**
* The BLOB versioned hashes for Cancun transactions.
* The BLOb versioned hashes for Cancun transactions.
*/

@@ -545,2 +594,78 @@ get blobVersionedHashes() {

/**
* The BLObs for the Transaction, if any.
*
* If ``blobs`` is non-``null``, then the [[seriailized]]
* will return the network formatted sidecar, otherwise it
* will return the standard [[link-eip-2718]] payload. The
* [[unsignedSerialized]] is unaffected regardless.
*
* When setting ``blobs``, either fully valid [[Blob]] objects
* may be specified (i.e. correctly padded, with correct
* committments and proofs) or a raw [[BytesLike]] may
* be provided.
*
* If raw [[BytesLike]] are provided, the [[kzg]] property **must**
* be already set. The blob will be correctly padded and the
* [[KzgLibrary]] will be used to compute the committment and
* proof for the blob.
*
* Setting this automatically populates [[blobVersionedHashes]],
* overwriting any existing values. Setting this to ``null``
* does **not** remove the [[blobVersionedHashes]], leaving them
* present.
*/
get blobs() {
if (this.#blobs == null) {
return null;
}
return this.#blobs.map((b) => Object.assign({}, b));
}
set blobs(_blobs) {
if (_blobs == null) {
this.#blobs = null;
return;
}
const blobs = [];
const versionedHashes = [];
for (let i = 0; i < _blobs.length; i++) {
const blob = _blobs[i];
if ((0, index_js_3.isBytesLike)(blob)) {
(0, index_js_3.assert)(this.#kzg, "adding a raw blob requires a KZG library", "UNSUPPORTED_OPERATION", {
operation: "set blobs()"
});
let data = (0, index_js_3.getBytes)(blob);
(0, index_js_3.assertArgument)(data.length <= BLOB_SIZE, "blob is too large", `blobs[${i}]`, blob);
// Pad blob if necessary
if (data.length !== BLOB_SIZE) {
const padded = new Uint8Array(BLOB_SIZE);
padded.set(data);
data = padded;
}
const commit = this.#kzg.blobToKzgCommitment(data);
const proof = (0, index_js_3.hexlify)(this.#kzg.computeBlobKzgProof(data, commit));
blobs.push({
data: (0, index_js_3.hexlify)(data),
commitment: (0, index_js_3.hexlify)(commit),
proof
});
versionedHashes.push(getVersionedHash(1, commit));
}
else {
const commit = (0, index_js_3.hexlify)(blob.commitment);
blobs.push({
data: (0, index_js_3.hexlify)(blob.data),
commitment: commit,
proof: (0, index_js_3.hexlify)(blob.proof)
});
versionedHashes.push(getVersionedHash(1, commit));
}
}
this.#blobs = blobs;
this.#blobVersionedHashes = versionedHashes;
}
get kzg() { return this.#kzg; }
set kzg(kzg) {
this.#kzg = kzg;
}
/**
* Creates a new Transaction with default values.

@@ -563,2 +688,4 @@ */

this.#blobVersionedHashes = null;
this.#blobs = null;
this.#kzg = null;
}

@@ -572,3 +699,3 @@ /**

}
return (0, index_js_2.keccak256)(this.serialized);
return (0, index_js_2.keccak256)(this.#getSerialized(true, false));
}

@@ -611,19 +738,14 @@ /**

}
/**
* The serialized transaction.
*
* This throws if the transaction is unsigned. For the pre-image,
* use [[unsignedSerialized]].
*/
get serialized() {
(0, index_js_3.assert)(this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
#getSerialized(signed, sidecar) {
(0, index_js_3.assert)(!signed || this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
const sig = signed ? this.signature : null;
switch (this.inferType()) {
case 0:
return _serializeLegacy(this, this.signature);
return _serializeLegacy(this, sig);
case 1:
return _serializeEip2930(this, this.signature);
return _serializeEip2930(this, sig);
case 2:
return _serializeEip1559(this, this.signature);
return _serializeEip1559(this, sig);
case 3:
return _serializeEip4844(this, this.signature);
return _serializeEip4844(this, sig, sidecar ? this.blobs : null);
}

@@ -633,2 +755,11 @@ (0, index_js_3.assert)(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".serialized" });

/**
* The serialized transaction.
*
* This throws if the transaction is unsigned. For the pre-image,
* use [[unsignedSerialized]].
*/
get serialized() {
return this.#getSerialized(true, true);
}
/**
* The transaction pre-image.

@@ -640,13 +771,3 @@ *

get unsignedSerialized() {
switch (this.inferType()) {
case 0:
return _serializeLegacy(this);
case 1:
return _serializeEip2930(this);
case 2:
return _serializeEip1559(this);
case 3:
return _serializeEip4844(this);
}
(0, index_js_3.assert)(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".unsignedSerialized" });
return this.#getSerialized(false, false);
}

@@ -851,5 +972,14 @@ /**

}
// This will get overwritten by blobs, if present
if (tx.blobVersionedHashes != null) {
result.blobVersionedHashes = tx.blobVersionedHashes;
}
// Make sure we assign the kzg before assigning blobs, which
// require the library in the event raw blob data is provided.
if (tx.kzg != null) {
result.kzg = tx.kzg;
}
if (tx.blobs != null) {
result.blobs = tx.blobs;
}
if (tx.hash != null) {

@@ -856,0 +986,0 @@ (0, index_js_3.assertArgument)(result.isSigned(), "unsigned transaction cannot define hash", "tx", tx);

@@ -583,2 +583,3 @@ "use strict";

clone.#retry = this.#retry;
clone.#throttle = Object.assign({}, this.#throttle);
clone.#getUrlFunc = this.#getUrlFunc;

@@ -585,0 +586,0 @@ return clone;

@@ -5,3 +5,3 @@ /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */

*/
export const version = "6.11.1";
export const version = "6.12.0-beta.1";
//# sourceMappingURL=_version.js.map

@@ -19,5 +19,5 @@ export { version } from "./_version.js";

export type { Provider, Signer, AbstractProviderOptions, FallbackProviderOptions, AbstractProviderPlugin, BlockParams, BlockTag, ContractRunner, DebugEventBrowserProvider, Eip1193Provider, EventFilter, Filter, FilterByBlockHash, GasCostParameters, JsonRpcApiProviderOptions, JsonRpcError, JsonRpcPayload, JsonRpcResult, JsonRpcTransactionRequest, LogParams, MinedBlock, MinedTransactionResponse, Networkish, OrphanFilter, PerformActionFilter, PerformActionRequest, PerformActionTransaction, PreparedTransactionRequest, ProviderEvent, Subscriber, Subscription, TopicFilter, TransactionReceiptParams, TransactionRequest, TransactionResponseParams, WebSocketCreator, WebSocketLike } from "./providers/index.js";
export type { AccessList, AccessListish, AccessListEntry, TransactionLike } from "./transaction/index.js";
export type { AccessList, AccessListish, AccessListEntry, Blob, BlobLike, KzgLibrary, TransactionLike } from "./transaction/index.js";
export type { BytesLike, BigNumberish, Numeric, ErrorCode, FixedFormat, Utf8ErrorFunc, UnicodeNormalizationForm, Utf8ErrorReason, RlpStructuredData, RlpStructuredDataish, GetUrlResponse, FetchPreflightFunc, FetchProcessFunc, FetchRetryFunc, FetchGatewayFunc, FetchGetUrlFunc, EthersError, UnknownError, NotImplementedError, UnsupportedOperationError, NetworkError, ServerError, TimeoutError, BadDataError, CancelledError, BufferOverrunError, NumericFaultError, InvalidArgumentError, MissingArgumentError, UnexpectedArgumentError, CallExceptionError, InsufficientFundsError, NonceExpiredError, OffchainFaultError, ReplacementUnderpricedError, TransactionReplacedError, UnconfiguredNameError, ActionRejectedError, CodedEthersError, CallExceptionAction, CallExceptionTransaction, EventEmitterable, Listener } from "./utils/index.js";
export type { CrowdsaleAccount, KeystoreAccount, EncryptOptions } from "./wallet/index.js";
//# sourceMappingURL=ethers.d.ts.map

@@ -152,4 +152,4 @@ /**

}
else if (pop.type === 2) {
// Explicitly using EIP-1559
else if (pop.type === 2 || pop.type === 3) {
// Explicitly using EIP-1559 or EIP-4844
// Populate missing fee data

@@ -156,0 +156,0 @@ if (pop.maxFeePerGas == null) {

import type { AddressLike, NameResolver } from "../address/index.js";
import type { BigNumberish, EventEmitterable } from "../utils/index.js";
import type { Signature } from "../crypto/index.js";
import type { AccessList, AccessListish, TransactionLike } from "../transaction/index.js";
import type { AccessList, AccessListish, BlobLike, KzgLibrary, TransactionLike } from "../transaction/index.js";
import type { ContractRunner } from "./contracts.js";

@@ -147,2 +147,22 @@ import type { Network } from "./network.js";

enableCcipRead?: boolean;
/**
* The blob versioned hashes (see [[link-eip-4844]]).
*/
blobVersionedHashes?: null | Array<string>;
/**
* The maximum fee per blob gas (see [[link-eip-4844]]).
*/
maxFeePerBlobGas?: null | BigNumberish;
/**
* Any blobs to include in the transaction (see [[link-eip-4844]]).
*/
blobs?: null | Array<BlobLike>;
/**
* An external library for computing the KZG commitments and
* proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
*
* This is generally ``null``, unless you are creating BLOb
* transactions.
*/
kzg?: null | KzgLibrary;
}

@@ -149,0 +169,0 @@ /**

//import { resolveAddress } from "@ethersproject/address";
import { defineProperties, getBigInt, getNumber, hexlify, resolveProperties, assert, assertArgument, isError, makeError } from "../utils/index.js";
import { defineProperties, getBigInt, getNumber, hexlify, isBytesLike, resolveProperties, assert, assertArgument, isError, makeError } from "../utils/index.js";
import { accessListify } from "../transaction/index.js";

@@ -92,3 +92,3 @@ const BN_0 = BigInt(0);

}
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
const bigIntKeys = "chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);
for (const key of bigIntKeys) {

@@ -119,2 +119,16 @@ if (!(key in req) || req[key] == null) {

}
if ("blobVersionedHashes" in req && req.blobVersionedHashes) {
result.blobVersionedHashes = req.blobVersionedHashes.slice();
}
if ("kzg" in req) {
result.kzg = req.kzg;
}
if ("blobs" in req && req.blobs) {
result.blobs = req.blobs.map((b) => {
if (isBytesLike(b)) {
return hexlify(b);
}
return Object.assign({}, b);
});
}
return result;

@@ -121,0 +135,0 @@ }

@@ -24,3 +24,3 @@ /**

export { Transaction } from "./transaction.js";
export type { TransactionLike } from "./transaction.js";
export type { Blob, BlobLike, KzgLibrary, TransactionLike } from "./transaction.js";
//# sourceMappingURL=index.d.ts.map

@@ -75,4 +75,47 @@ import { Signature } from "../crypto/index.js";

blobVersionedHashes?: null | Array<string>;
/**
* The blobs (if any) attached to this transaction (see [[link-eip-4844]]).
*/
blobs?: null | Array<BlobLike>;
/**
* An external library for computing the KZG commitments and
* proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
*
* This is generally ``null``, unless you are creating BLOb
* transactions.
*/
kzg?: null | KzgLibrary;
}
/**
* A full-valid BLOb object for [[link-eip-4844]] transactions.
*
* The commitment and proof should have been computed using a
* KZG library.
*/
export interface Blob {
data: string;
proof: string;
commitment: string;
}
/**
* A BLOb object that can be passed for [[link-eip-4844]]
* transactions.
*
* It may have had its commitment and proof already provided
* or rely on an attached [[KzgLibrary]] to compute them.
*/
export type BlobLike = BytesLike | {
data: BytesLike;
proof: BytesLike;
commitment: BytesLike;
};
/**
* A KZG Library with the necessary functions to compute
* BLOb commitments and proofs.
*/
export interface KzgLibrary {
blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
}
/**
* A **Transaction** describes an operation to be executed on

@@ -175,3 +218,3 @@ * Ethereum by an Externally Owned Account (EOA). It includes

/**
* The BLOB versioned hashes for Cancun transactions.
* The BLOb versioned hashes for Cancun transactions.
*/

@@ -181,2 +224,29 @@ get blobVersionedHashes(): null | Array<string>;

/**
* The BLObs for the Transaction, if any.
*
* If ``blobs`` is non-``null``, then the [[seriailized]]
* will return the network formatted sidecar, otherwise it
* will return the standard [[link-eip-2718]] payload. The
* [[unsignedSerialized]] is unaffected regardless.
*
* When setting ``blobs``, either fully valid [[Blob]] objects
* may be specified (i.e. correctly padded, with correct
* committments and proofs) or a raw [[BytesLike]] may
* be provided.
*
* If raw [[BytesLike]] are provided, the [[kzg]] property **must**
* be already set. The blob will be correctly padded and the
* [[KzgLibrary]] will be used to compute the committment and
* proof for the blob.
*
* Setting this automatically populates [[blobVersionedHashes]],
* overwriting any existing values. Setting this to ``null``
* does **not** remove the [[blobVersionedHashes]], leaving them
* present.
*/
get blobs(): null | Array<Blob>;
set blobs(_blobs: null | Array<BlobLike>);
get kzg(): null | KzgLibrary;
set kzg(kzg: null | KzgLibrary);
/**
* Creates a new Transaction with default values.

@@ -183,0 +253,0 @@ */

import { getAddress } from "../address/index.js";
import { ZeroAddress } from "../constants/addresses.js";
import { keccak256, Signature, SigningKey } from "../crypto/index.js";
import { concat, decodeRlp, encodeRlp, getBytes, getBigInt, getNumber, hexlify, assert, assertArgument, isHexString, toBeArray, zeroPadValue } from "../utils/index.js";
import { keccak256, sha256, Signature, SigningKey } from "../crypto/index.js";
import { concat, decodeRlp, encodeRlp, getBytes, getBigInt, getNumber, hexlify, assert, assertArgument, isBytesLike, isHexString, toBeArray, zeroPadValue } from "../utils/index.js";
import { accessListify } from "./accesslist.js";

@@ -13,2 +13,11 @@ import { recoverAddress } from "./address.js";

const BN_MAX_UINT = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
const BLOB_SIZE = 4096 * 32;
function getVersionedHash(version, hash) {
let versioned = version.toString(16);
while (versioned.length < 2) {
versioned = "0" + versioned;
}
versioned += sha256(hash).substring(4);
return "0x" + versioned;
}
function handleAddress(value) {

@@ -96,3 +105,3 @@ if (value === "0x") {

});
tx.hash = keccak256(data);
//tx.hash = keccak256(data);
}

@@ -188,3 +197,3 @@ return tx;

}
tx.hash = keccak256(data);
//tx.hash = keccak256(data);
_parseEipSignature(tx, fields.slice(9));

@@ -230,3 +239,3 @@ return tx;

}
tx.hash = keccak256(data);
//tx.hash = keccak256(data);
_parseEipSignature(tx, fields.slice(8));

@@ -254,4 +263,25 @@ return tx;

function _parseEip4844(data) {
const fields = decodeRlp(getBytes(data).slice(1));
assertArgument(Array.isArray(fields) && (fields.length === 11 || fields.length === 14), "invalid field count for transaction type: 3", "data", hexlify(data));
let fields = decodeRlp(getBytes(data).slice(1));
let typeName = "3";
let blobs = null;
// Parse the network format
if (fields.length === 4 && Array.isArray(fields[0])) {
typeName = "3 (network format)";
const fBlobs = fields[1], fCommits = fields[2], fProofs = fields[3];
assertArgument(Array.isArray(fBlobs), "invalid network format: blobs not an array", "fields[1]", fBlobs);
assertArgument(Array.isArray(fCommits), "invalid network format: commitments not an array", "fields[2]", fCommits);
assertArgument(Array.isArray(fProofs), "invalid network format: proofs not an array", "fields[3]", fProofs);
assertArgument(fBlobs.length === fCommits.length, "invalid network format: blobs/commitments length mismatch", "fields", fields);
assertArgument(fBlobs.length === fProofs.length, "invalid network format: blobs/proofs length mismatch", "fields", fields);
blobs = [];
for (let i = 0; i < fields[1].length; i++) {
blobs.push({
data: fBlobs[i],
commitment: fCommits[i],
proof: fProofs[i],
});
}
fields = fields[0];
}
assertArgument(Array.isArray(fields) && (fields.length === 11 || fields.length === 14), `invalid field count for transaction type: ${typeName}`, "data", hexlify(data));
const tx = {

@@ -272,3 +302,6 @@ type: 3,

};
assertArgument(tx.to != null, "invalid address for transaction type: 3", "data", data);
if (blobs) {
tx.blobs = blobs;
}
assertArgument(tx.to != null, `invalid address for transaction type: ${typeName}`, "data", data);
assertArgument(Array.isArray(tx.blobVersionedHashes), "invalid blobVersionedHashes: must be an array", "data", data);

@@ -282,7 +315,9 @@ for (let i = 0; i < tx.blobVersionedHashes.length; i++) {

}
tx.hash = keccak256(data);
// @TODO: Do we need to do this? This is only called internally
// and used to verify hashes; it might save time to not do this
//tx.hash = keccak256(concat([ "0x03", encodeRlp(fields) ]));
_parseEipSignature(tx, fields.slice(11));
return tx;
}
function _serializeEip4844(tx, sig) {
function _serializeEip4844(tx, sig, blobs) {
const fields = [

@@ -305,2 +340,14 @@ formatNumber(tx.chainId, "chainId"),

fields.push(toBeArray(sig.s));
// We have blobs; return the network wrapped format
if (blobs) {
return concat([
"0x03",
encodeRlp([
fields,
blobs.map((b) => b.data),
blobs.map((b) => b.commitment),
blobs.map((b) => b.proof),
])
]);
}
}

@@ -337,2 +384,4 @@ return concat(["0x03", encodeRlp(fields)]);

#blobVersionedHashes;
#kzg;
#blobs;
/**

@@ -519,3 +568,3 @@ * The transaction type.

/**
* The BLOB versioned hashes for Cancun transactions.
* The BLOb versioned hashes for Cancun transactions.
*/

@@ -542,2 +591,78 @@ get blobVersionedHashes() {

/**
* The BLObs for the Transaction, if any.
*
* If ``blobs`` is non-``null``, then the [[seriailized]]
* will return the network formatted sidecar, otherwise it
* will return the standard [[link-eip-2718]] payload. The
* [[unsignedSerialized]] is unaffected regardless.
*
* When setting ``blobs``, either fully valid [[Blob]] objects
* may be specified (i.e. correctly padded, with correct
* committments and proofs) or a raw [[BytesLike]] may
* be provided.
*
* If raw [[BytesLike]] are provided, the [[kzg]] property **must**
* be already set. The blob will be correctly padded and the
* [[KzgLibrary]] will be used to compute the committment and
* proof for the blob.
*
* Setting this automatically populates [[blobVersionedHashes]],
* overwriting any existing values. Setting this to ``null``
* does **not** remove the [[blobVersionedHashes]], leaving them
* present.
*/
get blobs() {
if (this.#blobs == null) {
return null;
}
return this.#blobs.map((b) => Object.assign({}, b));
}
set blobs(_blobs) {
if (_blobs == null) {
this.#blobs = null;
return;
}
const blobs = [];
const versionedHashes = [];
for (let i = 0; i < _blobs.length; i++) {
const blob = _blobs[i];
if (isBytesLike(blob)) {
assert(this.#kzg, "adding a raw blob requires a KZG library", "UNSUPPORTED_OPERATION", {
operation: "set blobs()"
});
let data = getBytes(blob);
assertArgument(data.length <= BLOB_SIZE, "blob is too large", `blobs[${i}]`, blob);
// Pad blob if necessary
if (data.length !== BLOB_SIZE) {
const padded = new Uint8Array(BLOB_SIZE);
padded.set(data);
data = padded;
}
const commit = this.#kzg.blobToKzgCommitment(data);
const proof = hexlify(this.#kzg.computeBlobKzgProof(data, commit));
blobs.push({
data: hexlify(data),
commitment: hexlify(commit),
proof
});
versionedHashes.push(getVersionedHash(1, commit));
}
else {
const commit = hexlify(blob.commitment);
blobs.push({
data: hexlify(blob.data),
commitment: commit,
proof: hexlify(blob.proof)
});
versionedHashes.push(getVersionedHash(1, commit));
}
}
this.#blobs = blobs;
this.#blobVersionedHashes = versionedHashes;
}
get kzg() { return this.#kzg; }
set kzg(kzg) {
this.#kzg = kzg;
}
/**
* Creates a new Transaction with default values.

@@ -560,2 +685,4 @@ */

this.#blobVersionedHashes = null;
this.#blobs = null;
this.#kzg = null;
}

@@ -569,3 +696,3 @@ /**

}
return keccak256(this.serialized);
return keccak256(this.#getSerialized(true, false));
}

@@ -608,19 +735,14 @@ /**

}
/**
* The serialized transaction.
*
* This throws if the transaction is unsigned. For the pre-image,
* use [[unsignedSerialized]].
*/
get serialized() {
assert(this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
#getSerialized(signed, sidecar) {
assert(!signed || this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized" });
const sig = signed ? this.signature : null;
switch (this.inferType()) {
case 0:
return _serializeLegacy(this, this.signature);
return _serializeLegacy(this, sig);
case 1:
return _serializeEip2930(this, this.signature);
return _serializeEip2930(this, sig);
case 2:
return _serializeEip1559(this, this.signature);
return _serializeEip1559(this, sig);
case 3:
return _serializeEip4844(this, this.signature);
return _serializeEip4844(this, sig, sidecar ? this.blobs : null);
}

@@ -630,2 +752,11 @@ assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".serialized" });

/**
* The serialized transaction.
*
* This throws if the transaction is unsigned. For the pre-image,
* use [[unsignedSerialized]].
*/
get serialized() {
return this.#getSerialized(true, true);
}
/**
* The transaction pre-image.

@@ -637,13 +768,3 @@ *

get unsignedSerialized() {
switch (this.inferType()) {
case 0:
return _serializeLegacy(this);
case 1:
return _serializeEip2930(this);
case 2:
return _serializeEip1559(this);
case 3:
return _serializeEip4844(this);
}
assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".unsignedSerialized" });
return this.#getSerialized(false, false);
}

@@ -848,5 +969,14 @@ /**

}
// This will get overwritten by blobs, if present
if (tx.blobVersionedHashes != null) {
result.blobVersionedHashes = tx.blobVersionedHashes;
}
// Make sure we assign the kzg before assigning blobs, which
// require the library in the event raw blob data is provided.
if (tx.kzg != null) {
result.kzg = tx.kzg;
}
if (tx.blobs != null) {
result.blobs = tx.blobs;
}
if (tx.hash != null) {

@@ -853,0 +983,0 @@ assertArgument(result.isSigned(), "unsigned transaction cannot define hash", "tx", tx);

@@ -579,2 +579,3 @@ /**

clone.#retry = this.#retry;
clone.#throttle = Object.assign({}, this.#throttle);
clone.#getUrlFunc = this.#getUrlFunc;

@@ -581,0 +582,0 @@ return clone;

@@ -96,3 +96,3 @@ {

],
"gitHead": "556fdd91d9b6bf7db4041bb099e66b2080e1a985",
"gitHead": "12772e9498b70f8538838f30e16f3792ea90e173",
"homepage": "https://ethers.org",

@@ -110,3 +110,3 @@ "keywords": [

"access": "public",
"tag": "latest"
"tag": "next"
},

@@ -136,3 +136,3 @@ "repository": {

"sideEffects": false,
"version": "6.11.1"
"version": "6.12.0-beta.1"
}

@@ -6,2 +6,2 @@ /* Do NOT modify this file; see /src.ts/_admin/update-version.ts */

*/
export const version: string = "6.11.1";
export const version: string = "6.12.0-beta.1";

@@ -180,2 +180,3 @@

AccessList, AccessListish, AccessListEntry,
Blob, BlobLike, KzgLibrary,
TransactionLike

@@ -182,0 +183,0 @@ } from "./transaction/index.js";

@@ -197,4 +197,4 @@ /**

} else if (pop.type === 2) {
// Explicitly using EIP-1559
} else if (pop.type === 2 || pop.type === 3) {
// Explicitly using EIP-1559 or EIP-4844

@@ -201,0 +201,0 @@ // Populate missing fee data

@@ -31,2 +31,4 @@ /**

export type { TransactionLike } from "./transaction.js";
export type {
Blob, BlobLike, KzgLibrary, TransactionLike
} from "./transaction.js";
import { getAddress } from "../address/index.js";
import { ZeroAddress } from "../constants/addresses.js";
import { keccak256, Signature, SigningKey } from "../crypto/index.js";
import {
keccak256, sha256, Signature, SigningKey
} from "../crypto/index.js";
import {
concat, decodeRlp, encodeRlp, getBytes, getBigInt, getNumber, hexlify,
assert, assertArgument, isHexString, toBeArray, zeroPadValue
assert, assertArgument, isBytesLike, isHexString, toBeArray, zeroPadValue
} from "../utils/index.js";

@@ -26,2 +28,3 @@

const BLOB_SIZE = 4096 * 32;

@@ -113,4 +116,59 @@ /**

blobVersionedHashes?: null | Array<string>;
/**
* The blobs (if any) attached to this transaction (see [[link-eip-4844]]).
*/
blobs?: null | Array<BlobLike>
/**
* An external library for computing the KZG commitments and
* proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
*
* This is generally ``null``, unless you are creating BLOb
* transactions.
*/
kzg?: null | KzgLibrary;
}
/**
* A full-valid BLOb object for [[link-eip-4844]] transactions.
*
* The commitment and proof should have been computed using a
* KZG library.
*/
export interface Blob {
data: string;
proof: string;
commitment: string;
}
/**
* A BLOb object that can be passed for [[link-eip-4844]]
* transactions.
*
* It may have had its commitment and proof already provided
* or rely on an attached [[KzgLibrary]] to compute them.
*/
export type BlobLike = BytesLike | {
data: BytesLike;
proof: BytesLike;
commitment: BytesLike;
};
/**
* A KZG Library with the necessary functions to compute
* BLOb commitments and proofs.
*/
export interface KzgLibrary {
blobToKzgCommitment: (blob: Uint8Array) => Uint8Array;
computeBlobKzgProof: (blob: Uint8Array, commitment: Uint8Array) => Uint8Array;
}
function getVersionedHash(version: number, hash: BytesLike): string {
let versioned = version.toString(16);
while (versioned.length < 2) { versioned = "0" + versioned; }
versioned += sha256(hash).substring(4);
return "0x" + versioned;
}
function handleAddress(value: string): null | string {

@@ -204,3 +262,3 @@ if (value === "0x") { return null; }

tx.hash = keccak256(data);
//tx.hash = keccak256(data);
}

@@ -211,3 +269,3 @@

function _serializeLegacy(tx: Transaction, sig?: Signature): string {
function _serializeLegacy(tx: Transaction, sig: null | Signature): string {
const fields: Array<any> = [

@@ -309,3 +367,3 @@ formatNumber(tx.nonce, "nonce"),

tx.hash = keccak256(data);
//tx.hash = keccak256(data);

@@ -317,3 +375,3 @@ _parseEipSignature(tx, fields.slice(9));

function _serializeEip1559(tx: Transaction, sig?: Signature): string {
function _serializeEip1559(tx: Transaction, sig: null | Signature): string {
const fields: Array<any> = [

@@ -361,3 +419,3 @@ formatNumber(tx.chainId, "chainId"),

tx.hash = keccak256(data);
//tx.hash = keccak256(data);

@@ -369,3 +427,3 @@ _parseEipSignature(tx, fields.slice(8));

function _serializeEip2930(tx: Transaction, sig?: Signature): string {
function _serializeEip2930(tx: Transaction, sig: null | Signature): string {
const fields: any = [

@@ -392,6 +450,32 @@ formatNumber(tx.chainId, "chainId"),

function _parseEip4844(data: Uint8Array): TransactionLike {
const fields: any = decodeRlp(getBytes(data).slice(1));
let fields: any = decodeRlp(getBytes(data).slice(1));
let typeName = "3";
let blobs: null | Array<Blob> = null;
// Parse the network format
if (fields.length === 4 && Array.isArray(fields[0])) {
typeName = "3 (network format)";
const fBlobs = fields[1], fCommits = fields[2], fProofs = fields[3];
assertArgument(Array.isArray(fBlobs), "invalid network format: blobs not an array", "fields[1]", fBlobs);
assertArgument(Array.isArray(fCommits), "invalid network format: commitments not an array", "fields[2]", fCommits);
assertArgument(Array.isArray(fProofs), "invalid network format: proofs not an array", "fields[3]", fProofs);
assertArgument(fBlobs.length === fCommits.length, "invalid network format: blobs/commitments length mismatch", "fields", fields);
assertArgument(fBlobs.length === fProofs.length, "invalid network format: blobs/proofs length mismatch", "fields", fields);
blobs = [ ];
for (let i = 0; i < fields[1].length; i++) {
blobs.push({
data: fBlobs[i],
commitment: fCommits[i],
proof: fProofs[i],
});
}
fields = fields[0];
}
assertArgument(Array.isArray(fields) && (fields.length === 11 || fields.length === 14),
"invalid field count for transaction type: 3", "data", hexlify(data));
`invalid field count for transaction type: ${ typeName }`, "data", hexlify(data));

@@ -414,4 +498,6 @@ const tx: TransactionLike = {

assertArgument(tx.to != null, "invalid address for transaction type: 3", "data", data);
if (blobs) { tx.blobs = blobs; }
assertArgument(tx.to != null, `invalid address for transaction type: ${ typeName }`, "data", data);
assertArgument(Array.isArray(tx.blobVersionedHashes), "invalid blobVersionedHashes: must be an array", "data", data);

@@ -425,3 +511,5 @@ for (let i = 0; i < tx.blobVersionedHashes.length; i++) {

tx.hash = keccak256(data);
// @TODO: Do we need to do this? This is only called internally
// and used to verify hashes; it might save time to not do this
//tx.hash = keccak256(concat([ "0x03", encodeRlp(fields) ]));

@@ -433,3 +521,3 @@ _parseEipSignature(tx, fields.slice(11));

function _serializeEip4844(tx: Transaction, sig?: Signature): string {
function _serializeEip4844(tx: Transaction, sig: null | Signature, blobs: null | Array<Blob>): string {
const fields: Array<any> = [

@@ -453,2 +541,16 @@ formatNumber(tx.chainId, "chainId"),

fields.push(toBeArray(sig.s));
// We have blobs; return the network wrapped format
if (blobs) {
return concat([
"0x03",
encodeRlp([
fields,
blobs.map((b) => b.data),
blobs.map((b) => b.commitment),
blobs.map((b) => b.proof),
])
]);
}
}

@@ -487,2 +589,4 @@

#blobVersionedHashes: null | Array<string>;
#kzg: null | KzgLibrary;
#blobs: null | Array<Blob>;

@@ -668,3 +772,3 @@ /**

/**
* The BLOB versioned hashes for Cancun transactions.
* The BLOb versioned hashes for Cancun transactions.
*/

@@ -690,2 +794,85 @@ get blobVersionedHashes(): null | Array<string> {

/**
* The BLObs for the Transaction, if any.
*
* If ``blobs`` is non-``null``, then the [[seriailized]]
* will return the network formatted sidecar, otherwise it
* will return the standard [[link-eip-2718]] payload. The
* [[unsignedSerialized]] is unaffected regardless.
*
* When setting ``blobs``, either fully valid [[Blob]] objects
* may be specified (i.e. correctly padded, with correct
* committments and proofs) or a raw [[BytesLike]] may
* be provided.
*
* If raw [[BytesLike]] are provided, the [[kzg]] property **must**
* be already set. The blob will be correctly padded and the
* [[KzgLibrary]] will be used to compute the committment and
* proof for the blob.
*
* Setting this automatically populates [[blobVersionedHashes]],
* overwriting any existing values. Setting this to ``null``
* does **not** remove the [[blobVersionedHashes]], leaving them
* present.
*/
get blobs(): null | Array<Blob> {
if (this.#blobs == null) { return null; }
return this.#blobs.map((b) => Object.assign({ }, b));
}
set blobs(_blobs: null | Array<BlobLike>) {
if (_blobs == null) {
this.#blobs = null;
return;
}
const blobs: Array<Blob> = [ ];
const versionedHashes: Array<string> = [ ];
for (let i = 0; i < _blobs.length; i++) {
const blob = _blobs[i];
if (isBytesLike(blob)) {
assert(this.#kzg, "adding a raw blob requires a KZG library", "UNSUPPORTED_OPERATION", {
operation: "set blobs()"
});
let data = getBytes(blob);
assertArgument(data.length <= BLOB_SIZE, "blob is too large", `blobs[${ i }]`, blob);
// Pad blob if necessary
if (data.length !== BLOB_SIZE) {
const padded = new Uint8Array(BLOB_SIZE);
padded.set(data);
data = padded;
}
const commit = this.#kzg.blobToKzgCommitment(data);
const proof = hexlify(this.#kzg.computeBlobKzgProof(data, commit));
blobs.push({
data: hexlify(data),
commitment: hexlify(commit),
proof
});
versionedHashes.push(getVersionedHash(1, commit));
} else {
const commit = hexlify(blob.commitment);
blobs.push({
data: hexlify(blob.data),
commitment: commit,
proof: hexlify(blob.proof)
});
versionedHashes.push(getVersionedHash(1, commit));
}
}
this.#blobs = blobs;
this.#blobVersionedHashes = versionedHashes;
}
get kzg(): null | KzgLibrary { return this.#kzg; }
set kzg(kzg: null | KzgLibrary) {
this.#kzg = kzg;
}
/**
* Creates a new Transaction with default values.

@@ -708,2 +895,4 @@ */

this.#blobVersionedHashes = null;
this.#blobs = null;
this.#kzg = null;
}

@@ -716,3 +905,3 @@

if (this.signature == null) { return null; }
return keccak256(this.serialized);
return keccak256(this.#getSerialized(true, false));
}

@@ -756,20 +945,15 @@

/**
* The serialized transaction.
*
* This throws if the transaction is unsigned. For the pre-image,
* use [[unsignedSerialized]].
*/
get serialized(): string {
assert(this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized"});
#getSerialized(signed: boolean, sidecar: boolean): string {
assert(!signed || this.signature != null, "cannot serialize unsigned transaction; maybe you meant .unsignedSerialized", "UNSUPPORTED_OPERATION", { operation: ".serialized"});
const sig = signed ? this.signature: null;
switch (this.inferType()) {
case 0:
return _serializeLegacy(this, this.signature);
return _serializeLegacy(this, sig);
case 1:
return _serializeEip2930(this, this.signature);
return _serializeEip2930(this, sig);
case 2:
return _serializeEip1559(this, this.signature);
return _serializeEip1559(this, sig);
case 3:
return _serializeEip4844(this, this.signature);
return _serializeEip4844(this, sig, sidecar ? this.blobs: null);
}

@@ -781,2 +965,12 @@

/**
* The serialized transaction.
*
* This throws if the transaction is unsigned. For the pre-image,
* use [[unsignedSerialized]].
*/
get serialized(): string {
return this.#getSerialized(true, true);
}
/**
* The transaction pre-image.

@@ -788,14 +982,3 @@ *

get unsignedSerialized(): string {
switch (this.inferType()) {
case 0:
return _serializeLegacy(this);
case 1:
return _serializeEip2930(this);
case 2:
return _serializeEip1559(this);
case 3:
return _serializeEip4844(this);
}
assert(false, "unsupported transaction type", "UNSUPPORTED_OPERATION", { operation: ".unsignedSerialized" });
return this.#getSerialized(false, false);
}

@@ -987,4 +1170,11 @@

if (tx.accessList != null) { result.accessList = tx.accessList; }
// This will get overwritten by blobs, if present
if (tx.blobVersionedHashes != null) { result.blobVersionedHashes = tx.blobVersionedHashes; }
// Make sure we assign the kzg before assigning blobs, which
// require the library in the event raw blob data is provided.
if (tx.kzg != null) { result.kzg = tx.kzg; }
if (tx.blobs != null) { result.blobs = tx.blobs; }
if (tx.hash != null) {

@@ -991,0 +1181,0 @@ assertArgument(result.isSigned(), "unsigned transaction cannot define hash", "tx", tx);

@@ -670,2 +670,4 @@ /**

clone.#throttle = Object.assign({ }, this.#throttle);
clone.#getUrlFunc = this.#getUrlFunc;

@@ -672,0 +674,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc