Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-eth-accounts

Package Overview
Dependencies
Maintainers
4
Versions
510
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-eth-accounts - npm Package Compare versions

Comparing version 4.3.1-dev.9aab5cd.0 to 4.3.1-dev.acdb0c7.0

lib/commonjs/tsconfig.cjs.tsbuildinfo

55

lib/commonjs/common/common.js

@@ -43,22 +43,2 @@ "use strict";

class Common extends web3_utils_1.EventEmitter {
constructor(opts) {
var _a, _b;
super();
this._eips = [];
this._customChains = (_a = opts.customChains) !== null && _a !== void 0 ? _a : [];
this._chainParams = this.setChain(opts.chain);
this.DEFAULT_HARDFORK = (_b = this._chainParams.defaultHardfork) !== null && _b !== void 0 ? _b : enums_js_1.Hardfork.Merge;
// Assign hardfork changes in the sequence of the applied hardforks
this.HARDFORK_CHANGES = this.hardforks().map(hf => [
hf.name,
index_js_2.hardforks[hf.name],
]);
this._hardfork = this.DEFAULT_HARDFORK;
if (opts.hardfork !== undefined) {
this.setHardfork(opts.hardfork);
}
if (opts.eips) {
this.setEIPs(opts.eips);
}
}
/**

@@ -154,3 +134,5 @@ * Creates a {@link Common} object for a custom chain, based on a standard one.

*/
static fromGethGenesis(genesisJson, { chain, eips, genesisHash, hardfork, mergeForkIdPostMerge }) {
static fromGethGenesis(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
genesisJson, { chain, eips, genesisHash, hardfork, mergeForkIdPostMerge }) {
var _a;

@@ -194,2 +176,22 @@ const genesisParams = (0, utils_js_1.parseGethGenesis)(genesisJson, chain, mergeForkIdPostMerge);

}
constructor(opts) {
var _a, _b;
super();
this._eips = [];
this._customChains = (_a = opts.customChains) !== null && _a !== void 0 ? _a : [];
this._chainParams = this.setChain(opts.chain);
this.DEFAULT_HARDFORK = (_b = this._chainParams.defaultHardfork) !== null && _b !== void 0 ? _b : enums_js_1.Hardfork.Merge;
// Assign hardfork changes in the sequence of the applied hardforks
this.HARDFORK_CHANGES = this.hardforks().map(hf => [
hf.name,
index_js_2.hardforks[hf.name],
]);
this._hardfork = this.DEFAULT_HARDFORK;
if (opts.hardfork !== undefined) {
this.setHardfork(opts.hardfork);
}
if (opts.eips) {
this.setEIPs(opts.eips);
}
}
/**

@@ -690,4 +692,4 @@ * Sets the chain

nextHardforkBlockOrTimestamp(_hardfork) {
var _a, _b;
const hardfork = _hardfork !== null && _hardfork !== void 0 ? _hardfork : this._hardfork;
var _a, _b, _c;
const hardfork = (_a = _hardfork) !== null && _a !== void 0 ? _a : this._hardfork;
const hfs = this.hardforks();

@@ -705,3 +707,3 @@ let hfIndex = hfs.findIndex(hf => hf.name === hardfork);

}
let currHfTimeOrBlock = (_a = hfs[hfIndex].timestamp) !== null && _a !== void 0 ? _a : hfs[hfIndex].block;
let currHfTimeOrBlock = (_b = hfs[hfIndex].timestamp) !== null && _b !== void 0 ? _b : hfs[hfIndex].block;
currHfTimeOrBlock =

@@ -733,3 +735,3 @@ // eslint-disable-next-line no-null/no-null

}
const nextHfBlock = (_b = nextHf.timestamp) !== null && _b !== void 0 ? _b : nextHf.block;
const nextHfBlock = (_c = nextHf.timestamp) !== null && _c !== void 0 ? _c : nextHf.block;
// eslint-disable-next-line no-null/no-null

@@ -750,3 +752,4 @@ if (nextHfBlock === null || nextHfBlock === undefined) {

nextHardforkBlock(_hardfork) {
const hardfork = _hardfork !== null && _hardfork !== void 0 ? _hardfork : this._hardfork;
var _a;
const hardfork = (_a = _hardfork) !== null && _a !== void 0 ? _a : this._hardfork;
let hfBlock = this.hardforkBlock(hardfork);

@@ -753,0 +756,0 @@ // If this is a merge hardfork with block not set, then we fallback to previous hardfork

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

Chain[Chain["Sepolia"] = 11155111] = "Sepolia";
})(Chain = exports.Chain || (exports.Chain = {}));
})(Chain || (exports.Chain = Chain = {}));
var Hardfork;

@@ -47,3 +47,3 @@ (function (Hardfork) {

Hardfork["ShardingForkDev"] = "shardingFork";
})(Hardfork = exports.Hardfork || (exports.Hardfork = {}));
})(Hardfork || (exports.Hardfork = Hardfork = {}));
var ConsensusType;

@@ -54,3 +54,3 @@ (function (ConsensusType) {

ConsensusType["ProofOfAuthority"] = "poa";
})(ConsensusType = exports.ConsensusType || (exports.ConsensusType = {}));
})(ConsensusType || (exports.ConsensusType = ConsensusType = {}));
var ConsensusAlgorithm;

@@ -61,3 +61,3 @@ (function (ConsensusAlgorithm) {

ConsensusAlgorithm["Casper"] = "casper";
})(ConsensusAlgorithm = exports.ConsensusAlgorithm || (exports.ConsensusAlgorithm = {}));
})(ConsensusAlgorithm || (exports.ConsensusAlgorithm = ConsensusAlgorithm = {}));
var CustomChain;

@@ -107,3 +107,3 @@ (function (CustomChain) {

CustomChain["OptimisticEthereum"] = "optimistic-ethereum";
})(CustomChain = exports.CustomChain || (exports.CustomChain = {}));
})(CustomChain || (exports.CustomChain = CustomChain = {}));
//# sourceMappingURL=enums.js.map

@@ -5,8 +5,8 @@ import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js';

}
export declare type CliqueConfig = {
export type CliqueConfig = {
period: number;
epoch: number;
};
export declare type EthashConfig = Record<string, unknown>;
export declare type CasperConfig = Record<string, unknown>;
export type EthashConfig = Record<string, unknown>;
export type CasperConfig = Record<string, unknown>;
export interface GenesisBlockConfig {

@@ -113,9 +113,9 @@ timestamp?: string;

}
export declare type PrefixedHexString = string;
export declare type Uint8ArrayLike = Uint8Array | number[] | number | bigint | PrefixedHexString;
export declare type BigIntLike = bigint | PrefixedHexString | number | Uint8Array;
export type PrefixedHexString = string;
export type Uint8ArrayLike = Uint8Array | number[] | number | bigint | PrefixedHexString;
export type BigIntLike = bigint | PrefixedHexString | number | Uint8Array;
export interface TransformableToArray {
toArray(): Uint8Array;
}
export declare type NestedUint8Array = Array<Uint8Array | NestedUint8Array>;
export type NestedUint8Array = Array<Uint8Array | NestedUint8Array>;
/**

@@ -130,3 +130,3 @@ * Type output options

}
export declare type TypeOutputReturnType = {
export type TypeOutputReturnType = {
[TypeOutput.Number]: number;

@@ -137,3 +137,3 @@ [TypeOutput.BigInt]: bigint;

};
export declare type ToBytesInputTypes = PrefixedHexString | number | bigint | Uint8Array | number[] | TransformableToArray | null | undefined;
export type ToBytesInputTypes = PrefixedHexString | number | bigint | Uint8Array | number[] | TransformableToArray | null | undefined;
export {};

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

TypeOutput[TypeOutput["PrefixedHexString"] = 3] = "PrefixedHexString";
})(TypeOutput = exports.TypeOutput || (exports.TypeOutput = {}));
})(TypeOutput || (exports.TypeOutput = TypeOutput = {}));
//# sourceMappingURL=types.js.map
import { ToBytesInputTypes, TypeOutput, TypeOutputReturnType } from './types.js';
declare type ConfigHardfork = {
type ConfigHardfork = {
name: string;

@@ -4,0 +4,0 @@ block: null;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toType = exports.ecrecover = exports.bigIntToUnpaddedUint8Array = exports.bigIntToHex = exports.unpadUint8Array = exports.stripZeros = exports.setLengthLeft = exports.assertIsUint8Array = exports.zeros = exports.bigIntToUint8Array = exports.uint8ArrayToBigInt = exports.toUint8Array = exports.intToUint8Array = exports.padToEven = exports.parseGethGenesis = exports.stripHexPrefix = void 0;
exports.ecrecover = exports.bigIntToHex = exports.unpadUint8Array = exports.setLengthLeft = exports.zeros = exports.toUint8Array = exports.intToUint8Array = exports.stripHexPrefix = void 0;
exports.parseGethGenesis = parseGethGenesis;
exports.padToEven = padToEven;
exports.uint8ArrayToBigInt = uint8ArrayToBigInt;
exports.bigIntToUint8Array = bigIntToUint8Array;
exports.assertIsUint8Array = assertIsUint8Array;
exports.stripZeros = stripZeros;
exports.bigIntToUnpaddedUint8Array = bigIntToUnpaddedUint8Array;
exports.toType = toType;
/*

@@ -69,2 +77,3 @@ This file is part of web3.js.

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseGethParams(json, mergeForkIdPostMerge = true) {

@@ -105,3 +114,3 @@ var _a, _b;

// eslint-disable-next-line radix
gasLimit: parseInt(gasLimit),
gasLimit: parseInt(gasLimit), // geth gasLimit and difficulty are hex strings while ours are `number`s
// eslint-disable-next-line radix

@@ -170,3 +179,3 @@ difficulty: parseInt(difficulty),

const configHardforkNames = Object.keys(config).filter(
// eslint-disable-next-line no-null/no-null, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line no-null/no-null, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/prefer-optional-chain
key => forkMapRev[key] !== undefined && config[key] !== undefined && config[key] !== null);

@@ -217,3 +226,3 @@ params.hardforks = configHardforkNames

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(hf) => { var _a; return ((_a = forkMap[hf.name]) === null || _a === void 0 ? void 0 : _a.postMerge) === true; });
hf => { var _a; return ((_a = forkMap[hf.name]) === null || _a === void 0 ? void 0 : _a.postMerge) === true; });
if (postMergeIndex !== -1) {

@@ -237,2 +246,3 @@ params.hardforks.splice(postMergeIndex, 0, mergeConfig);

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseGethGenesis(json, name, mergeForkIdPostMerge) {

@@ -254,3 +264,2 @@ try {

}
exports.parseGethGenesis = parseGethGenesis;
/**

@@ -270,3 +279,2 @@ * Pads a `String` to have an even length

}
exports.padToEven = padToEven;
/**

@@ -338,3 +346,2 @@ * Converts an `Number` to a `Uint8Array`

}
exports.uint8ArrayToBigInt = uint8ArrayToBigInt;
/**

@@ -346,3 +353,2 @@ * Converts a {@link bigint} to a {@link Uint8Array}

}
exports.bigIntToUint8Array = bigIntToUint8Array;
/**

@@ -390,3 +396,2 @@ * Returns a Uint8Array filled with 0s.

}
exports.assertIsUint8Array = assertIsUint8Array;
/**

@@ -422,3 +427,2 @@ * Left Pads a `Uint8Array` with leading zeros till it has `length` bytes.

}
exports.stripZeros = stripZeros;
/**

@@ -447,3 +451,2 @@ * Trims leading zeros from a `Uint8Array`.

}
exports.bigIntToUnpaddedUint8Array = bigIntToUnpaddedUint8Array;
function calculateSigRecovery(v, chainId) {

@@ -511,3 +514,2 @@ if (v === BigInt(0) || v === BigInt(1))

}
exports.toType = toType;
//# sourceMappingURL=utils.js.map

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

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static _validateNotArray(values) {

@@ -431,2 +432,3 @@ const txDataKeys = [

// @ts-expect-error unused variable
// eslint-disable-next-line @typescript-eslint/no-explicit-any
txData,

@@ -433,0 +435,0 @@ // @ts-expect-error unused variable

@@ -39,54 +39,2 @@ "use strict";

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'london';
const { chainId, accessList, maxFeePerGas, maxPriorityFeePerGas } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
if (!this.common.isActivatedEIP(1559)) {
throw new Error('EIP-1559 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([1559, 2718, 2930]);
// Populate the access list fields
const accessListData = (0, utils_js_1.getAccessListData)(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
(0, utils_js_1.verifyAccessList)(this.accessList);
this.maxFeePerGas = (0, utils_js_2.uint8ArrayToBigInt)((0, utils_js_2.toUint8Array)(maxFeePerGas === '' ? '0x' : maxFeePerGas));
this.maxPriorityFeePerGas = (0, utils_js_2.uint8ArrayToBigInt)((0, utils_js_2.toUint8Array)(maxPriorityFeePerGas === '' ? '0x' : maxPriorityFeePerGas));
this._validateCannotExceedMaxInteger({
maxFeePerGas: this.maxFeePerGas,
maxPriorityFeePerGas: this.maxPriorityFeePerGas,
});
baseTransaction_js_1.BaseTransaction._validateNotArray(txData);
if (this.gasLimit * this.maxFeePerGas > constants_js_1.MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
if (this.maxFeePerGas < this.maxPriorityFeePerGas) {
const msg = this._errorMsg('maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Instantiate a transaction from a data dictionary.

@@ -153,3 +101,3 @@ *

accessList: accessList !== null && accessList !== void 0 ? accessList : [],
v: v !== undefined ? (0, utils_js_2.uint8ArrayToBigInt)(v) : undefined,
v: v !== undefined ? (0, utils_js_2.uint8ArrayToBigInt)(v) : undefined, // EIP2930 supports v's with value 0 (empty Uint8Array)
r,

@@ -160,2 +108,54 @@ s,

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'london';
const { chainId, accessList, maxFeePerGas, maxPriorityFeePerGas } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
if (!this.common.isActivatedEIP(1559)) {
throw new Error('EIP-1559 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([1559, 2718, 2930]);
// Populate the access list fields
const accessListData = (0, utils_js_1.getAccessListData)(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
(0, utils_js_1.verifyAccessList)(this.accessList);
this.maxFeePerGas = (0, utils_js_2.uint8ArrayToBigInt)((0, utils_js_2.toUint8Array)(maxFeePerGas === '' ? '0x' : maxFeePerGas));
this.maxPriorityFeePerGas = (0, utils_js_2.uint8ArrayToBigInt)((0, utils_js_2.toUint8Array)(maxPriorityFeePerGas === '' ? '0x' : maxPriorityFeePerGas));
this._validateCannotExceedMaxInteger({
maxFeePerGas: this.maxFeePerGas,
maxPriorityFeePerGas: this.maxPriorityFeePerGas,
});
baseTransaction_js_1.BaseTransaction._validateNotArray(txData);
if (this.gasLimit * this.maxFeePerGas > constants_js_1.MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
if (this.maxFeePerGas < this.maxPriorityFeePerGas) {
const msg = this._errorMsg('maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* The amount of gas paid for the data in this tx

@@ -309,3 +309,3 @@ */

accessList: this.accessList,
v: v - BigInt(27),
v: v - BigInt(27), // This looks extremely hacky: /util actually adds 27 to the value, the recovery bit is either 0 or 1.
r: (0, utils_js_2.uint8ArrayToBigInt)(r),

@@ -312,0 +312,0 @@ s: (0, utils_js_2.uint8ArrayToBigInt)(s),

@@ -39,49 +39,2 @@ "use strict";

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'berlin';
const { chainId, accessList, gasPrice } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
// EIP-2718 check is done in Common
if (!this.common.isActivatedEIP(2930)) {
throw new Error('EIP-2930 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([2718, 2930]);
// Populate the access list fields
const accessListData = (0, utils_js_1.getAccessListData)(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
(0, utils_js_1.verifyAccessList)(this.accessList);
this.gasPrice = (0, utils_js_2.uint8ArrayToBigInt)((0, utils_js_2.toUint8Array)(gasPrice === '' ? '0x' : gasPrice));
this._validateCannotExceedMaxInteger({
gasPrice: this.gasPrice,
});
baseTransaction_js_1.BaseTransaction._validateNotArray(txData);
if (this.gasPrice * this.gasLimit > constants_js_1.MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * gasPrice cannot exceed MAX_INTEGER');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Instantiate a transaction from a data dictionary.

@@ -139,3 +92,3 @@ *

accessList: accessList !== null && accessList !== void 0 ? accessList : emptyAccessList,
v: v !== undefined ? (0, utils_js_2.uint8ArrayToBigInt)(v) : undefined,
v: v !== undefined ? (0, utils_js_2.uint8ArrayToBigInt)(v) : undefined, // EIP2930 supports v's with value 0 (empty Uint8Array)
r,

@@ -146,2 +99,49 @@ s,

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'berlin';
const { chainId, accessList, gasPrice } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
// EIP-2718 check is done in Common
if (!this.common.isActivatedEIP(2930)) {
throw new Error('EIP-2930 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([2718, 2930]);
// Populate the access list fields
const accessListData = (0, utils_js_1.getAccessListData)(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
(0, utils_js_1.verifyAccessList)(this.accessList);
this.gasPrice = (0, utils_js_2.uint8ArrayToBigInt)((0, utils_js_2.toUint8Array)(gasPrice === '' ? '0x' : gasPrice));
this._validateCannotExceedMaxInteger({
gasPrice: this.gasPrice,
});
baseTransaction_js_1.BaseTransaction._validateNotArray(txData);
if (this.gasPrice * this.gasLimit > constants_js_1.MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * gasPrice cannot exceed MAX_INTEGER');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* The amount of gas paid for the data in this tx

@@ -288,3 +288,3 @@ */

accessList: this.accessList,
v: v - BigInt(27),
v: v - BigInt(27), // This looks extremely hacky: /util actually adds 27 to the value, the recovery bit is either 0 or 1.
r: (0, utils_js_2.uint8ArrayToBigInt)(r),

@@ -291,0 +291,0 @@ s: (0, utils_js_2.uint8ArrayToBigInt)(s),

@@ -40,42 +40,2 @@ "use strict";

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
this.common = this._validateTxV(this.v, opts.common);
this.gasPrice = (0, utils_js_1.uint8ArrayToBigInt)((0, utils_js_1.toUint8Array)(txData.gasPrice === '' ? '0x' : txData.gasPrice));
if (this.gasPrice * this.gasLimit > constants_js_1.MAX_INTEGER) {
const msg = this._errorMsg('gas limit * gasPrice cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
this._validateCannotExceedMaxInteger({ gasPrice: this.gasPrice });
baseTransaction_js_1.BaseTransaction._validateNotArray(txData);
if (this.common.gteHardfork('spuriousDragon')) {
if (!this.isSigned()) {
this.activeCapabilities.push(types_js_1.Capability.EIP155ReplayProtection);
}
else {
// EIP155 spec:
// If block.number >= 2,675,000 and v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36
// then when computing the hash of a transaction for purposes of signing or recovering
// instead of hashing only the first six elements (i.e. nonce, gasprice, startgas, to, value, data)
// hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0.
// v and chain ID meet EIP-155 conditions
// eslint-disable-next-line no-lonely-if
if (meetsEIP155(this.v, this.common.chainId())) {
this.activeCapabilities.push(types_js_1.Capability.EIP155ReplayProtection);
}
}
}
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Instantiate a transaction from a data dictionary.

@@ -129,2 +89,42 @@ *

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
this.common = this._validateTxV(this.v, opts.common);
this.gasPrice = (0, utils_js_1.uint8ArrayToBigInt)((0, utils_js_1.toUint8Array)(txData.gasPrice === '' ? '0x' : txData.gasPrice));
if (this.gasPrice * this.gasLimit > constants_js_1.MAX_INTEGER) {
const msg = this._errorMsg('gas limit * gasPrice cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
this._validateCannotExceedMaxInteger({ gasPrice: this.gasPrice });
baseTransaction_js_1.BaseTransaction._validateNotArray(txData);
if (this.common.gteHardfork('spuriousDragon')) {
if (!this.isSigned()) {
this.activeCapabilities.push(types_js_1.Capability.EIP155ReplayProtection);
}
else {
// EIP155 spec:
// If block.number >= 2,675,000 and v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36
// then when computing the hash of a transaction for purposes of signing or recovering
// instead of hashing only the first six elements (i.e. nonce, gasprice, startgas, to, value, data)
// hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0.
// v and chain ID meet EIP-155 conditions
// eslint-disable-next-line no-lonely-if
if (meetsEIP155(this.v, this.common.chainId())) {
this.activeCapabilities.push(types_js_1.Capability.EIP155ReplayProtection);
}
}
}
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Returns a Uint8Array Array of the raw Uint8Arrays of the legacy transaction, in order.

@@ -131,0 +131,0 @@ *

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

// It is not possible to instantiate a TransactionFactory object.
// eslint-disable-next-line @typescript-eslint/no-empty-function, no-useless-constructor
// eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
constructor() { }

@@ -32,0 +32,0 @@ static typeToInt(txType) {

@@ -64,9 +64,9 @@ import type { HexString, Numbers } from 'web3-types';

}
export declare type AccessListItem = {
export type AccessListItem = {
address: PrefixedHexString;
storageKeys: PrefixedHexString[];
};
export declare type AccessListUint8ArrayItem = [Uint8Array, Uint8Array[]];
export declare type AccessListUint8Array = AccessListUint8ArrayItem[];
export declare type AccessList = AccessListItem[];
export type AccessListUint8ArrayItem = [Uint8Array, Uint8Array[]];
export type AccessListUint8Array = AccessListUint8ArrayItem[];
export type AccessList = AccessListItem[];
export declare function isAccessListUint8Array(input: AccessListUint8Array | AccessList): input is AccessListUint8Array;

@@ -82,3 +82,3 @@ export declare function isAccessList(input: AccessListUint8Array | AccessList): input is AccessList;

*/
export declare type TxData = {
export type TxData = {
/**

@@ -159,7 +159,7 @@ * The transaction's nonce.

*/
export declare type TxValuesArray = Uint8Array[];
export type TxValuesArray = Uint8Array[];
/**
* Uint8Array values array for an {@link AccessListEIP2930Transaction}
*/
export declare type AccessListEIP2930ValuesArray = [
export type AccessListEIP2930ValuesArray = [
Uint8Array,

@@ -180,3 +180,3 @@ Uint8Array,

*/
export declare type FeeMarketEIP1559ValuesArray = [
export type FeeMarketEIP1559ValuesArray = [
Uint8Array,

@@ -195,3 +195,3 @@ Uint8Array,

];
declare type JsonAccessListItem = {
type JsonAccessListItem = {
address: string;

@@ -198,0 +198,0 @@ storageKeys: string[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAccessList = exports.isAccessListUint8Array = exports.Capability = void 0;
exports.Capability = void 0;
exports.isAccessListUint8Array = isAccessListUint8Array;
exports.isAccessList = isAccessList;
/**

@@ -30,3 +32,3 @@ * Can be used in conjunction with {@link Transaction.supports}

Capability[Capability["EIP2930AccessLists"] = 2930] = "EIP2930AccessLists";
})(Capability = exports.Capability || (exports.Capability = {}));
})(Capability || (exports.Capability = Capability = {}));
function isAccessListUint8Array(input) {

@@ -42,7 +44,5 @@ if (input.length === 0) {

}
exports.isAccessListUint8Array = isAccessListUint8Array;
function isAccessList(input) {
return !isAccessListUint8Array(input); // This is exactly the same method, except the output is negated.
}
exports.isAccessList = isAccessList;
//# sourceMappingURL=types.js.map

@@ -88,7 +88,6 @@ "use strict";

const JSONItem = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/consistent-type-assertions
address: (0, web3_utils_1.bytesToHex)((0, utils_js_1.setLengthLeft)(item[0], 20)),
storageKeys: [],
};
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/prefer-optional-chain
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
const storageSlots = item && item[1];

@@ -95,0 +94,0 @@ // eslint-disable-next-line @typescript-eslint/prefer-for-of

@@ -38,2 +38,2 @@ import { HexString, SignatureObject, SignResult, SignTransactionResult, Web3BaseWalletAccount } from 'web3-types';

}
export declare type TypedTransaction = Transaction | AccessListEIP2930Transaction | FeeMarketEIP1559Transaction;
export type TypedTransaction = Transaction | AccessListEIP2930Transaction | FeeMarketEIP1559Transaction;

@@ -37,22 +37,2 @@ /*

export class Common extends EventEmitter {
constructor(opts) {
var _a, _b;
super();
this._eips = [];
this._customChains = (_a = opts.customChains) !== null && _a !== void 0 ? _a : [];
this._chainParams = this.setChain(opts.chain);
this.DEFAULT_HARDFORK = (_b = this._chainParams.defaultHardfork) !== null && _b !== void 0 ? _b : Hardfork.Merge;
// Assign hardfork changes in the sequence of the applied hardforks
this.HARDFORK_CHANGES = this.hardforks().map(hf => [
hf.name,
HARDFORK_SPECS[hf.name],
]);
this._hardfork = this.DEFAULT_HARDFORK;
if (opts.hardfork !== undefined) {
this.setHardfork(opts.hardfork);
}
if (opts.eips) {
this.setEIPs(opts.eips);
}
}
/**

@@ -148,3 +128,5 @@ * Creates a {@link Common} object for a custom chain, based on a standard one.

*/
static fromGethGenesis(genesisJson, { chain, eips, genesisHash, hardfork, mergeForkIdPostMerge }) {
static fromGethGenesis(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
genesisJson, { chain, eips, genesisHash, hardfork, mergeForkIdPostMerge }) {
var _a;

@@ -188,2 +170,22 @@ const genesisParams = parseGethGenesis(genesisJson, chain, mergeForkIdPostMerge);

}
constructor(opts) {
var _a, _b;
super();
this._eips = [];
this._customChains = (_a = opts.customChains) !== null && _a !== void 0 ? _a : [];
this._chainParams = this.setChain(opts.chain);
this.DEFAULT_HARDFORK = (_b = this._chainParams.defaultHardfork) !== null && _b !== void 0 ? _b : Hardfork.Merge;
// Assign hardfork changes in the sequence of the applied hardforks
this.HARDFORK_CHANGES = this.hardforks().map(hf => [
hf.name,
HARDFORK_SPECS[hf.name],
]);
this._hardfork = this.DEFAULT_HARDFORK;
if (opts.hardfork !== undefined) {
this.setHardfork(opts.hardfork);
}
if (opts.eips) {
this.setEIPs(opts.eips);
}
}
/**

@@ -684,4 +686,4 @@ * Sets the chain

nextHardforkBlockOrTimestamp(_hardfork) {
var _a, _b;
const hardfork = _hardfork !== null && _hardfork !== void 0 ? _hardfork : this._hardfork;
var _a, _b, _c;
const hardfork = (_a = _hardfork) !== null && _a !== void 0 ? _a : this._hardfork;
const hfs = this.hardforks();

@@ -699,3 +701,3 @@ let hfIndex = hfs.findIndex(hf => hf.name === hardfork);

}
let currHfTimeOrBlock = (_a = hfs[hfIndex].timestamp) !== null && _a !== void 0 ? _a : hfs[hfIndex].block;
let currHfTimeOrBlock = (_b = hfs[hfIndex].timestamp) !== null && _b !== void 0 ? _b : hfs[hfIndex].block;
currHfTimeOrBlock =

@@ -727,3 +729,3 @@ // eslint-disable-next-line no-null/no-null

}
const nextHfBlock = (_b = nextHf.timestamp) !== null && _b !== void 0 ? _b : nextHf.block;
const nextHfBlock = (_c = nextHf.timestamp) !== null && _c !== void 0 ? _c : nextHf.block;
// eslint-disable-next-line no-null/no-null

@@ -744,3 +746,4 @@ if (nextHfBlock === null || nextHfBlock === undefined) {

nextHardforkBlock(_hardfork) {
const hardfork = _hardfork !== null && _hardfork !== void 0 ? _hardfork : this._hardfork;
var _a;
const hardfork = (_a = _hardfork) !== null && _a !== void 0 ? _a : this._hardfork;
let hfBlock = this.hardforkBlock(hardfork);

@@ -747,0 +750,0 @@ // If this is a merge hardfork with block not set, then we fallback to previous hardfork

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

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseGethParams(json, mergeForkIdPostMerge = true) {

@@ -101,3 +102,3 @@ var _a, _b;

// eslint-disable-next-line radix
gasLimit: parseInt(gasLimit),
gasLimit: parseInt(gasLimit), // geth gasLimit and difficulty are hex strings while ours are `number`s
// eslint-disable-next-line radix

@@ -166,3 +167,3 @@ difficulty: parseInt(difficulty),

const configHardforkNames = Object.keys(config).filter(
// eslint-disable-next-line no-null/no-null, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line no-null/no-null, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/prefer-optional-chain
key => forkMapRev[key] !== undefined && config[key] !== undefined && config[key] !== null);

@@ -213,3 +214,3 @@ params.hardforks = configHardforkNames

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(hf) => { var _a; return ((_a = forkMap[hf.name]) === null || _a === void 0 ? void 0 : _a.postMerge) === true; });
hf => { var _a; return ((_a = forkMap[hf.name]) === null || _a === void 0 ? void 0 : _a.postMerge) === true; });
if (postMergeIndex !== -1) {

@@ -233,2 +234,3 @@ params.hardforks.splice(postMergeIndex, 0, mergeConfig);

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function parseGethGenesis(json, name, mergeForkIdPostMerge) {

@@ -235,0 +237,0 @@ try {

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

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static _validateNotArray(values) {

@@ -428,2 +429,3 @@ const txDataKeys = [

// @ts-expect-error unused variable
// eslint-disable-next-line @typescript-eslint/no-explicit-any
txData,

@@ -430,0 +432,0 @@ // @ts-expect-error unused variable

@@ -36,54 +36,2 @@ /*

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'london';
const { chainId, accessList, maxFeePerGas, maxPriorityFeePerGas } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
if (!this.common.isActivatedEIP(1559)) {
throw new Error('EIP-1559 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([1559, 2718, 2930]);
// Populate the access list fields
const accessListData = getAccessListData(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
verifyAccessList(this.accessList);
this.maxFeePerGas = uint8ArrayToBigInt(toUint8Array(maxFeePerGas === '' ? '0x' : maxFeePerGas));
this.maxPriorityFeePerGas = uint8ArrayToBigInt(toUint8Array(maxPriorityFeePerGas === '' ? '0x' : maxPriorityFeePerGas));
this._validateCannotExceedMaxInteger({
maxFeePerGas: this.maxFeePerGas,
maxPriorityFeePerGas: this.maxPriorityFeePerGas,
});
BaseTransaction._validateNotArray(txData);
if (this.gasLimit * this.maxFeePerGas > MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
if (this.maxFeePerGas < this.maxPriorityFeePerGas) {
const msg = this._errorMsg('maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Instantiate a transaction from a data dictionary.

@@ -150,3 +98,3 @@ *

accessList: accessList !== null && accessList !== void 0 ? accessList : [],
v: v !== undefined ? uint8ArrayToBigInt(v) : undefined,
v: v !== undefined ? uint8ArrayToBigInt(v) : undefined, // EIP2930 supports v's with value 0 (empty Uint8Array)
r,

@@ -157,2 +105,54 @@ s,

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'london';
const { chainId, accessList, maxFeePerGas, maxPriorityFeePerGas } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
if (!this.common.isActivatedEIP(1559)) {
throw new Error('EIP-1559 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([1559, 2718, 2930]);
// Populate the access list fields
const accessListData = getAccessListData(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
verifyAccessList(this.accessList);
this.maxFeePerGas = uint8ArrayToBigInt(toUint8Array(maxFeePerGas === '' ? '0x' : maxFeePerGas));
this.maxPriorityFeePerGas = uint8ArrayToBigInt(toUint8Array(maxPriorityFeePerGas === '' ? '0x' : maxPriorityFeePerGas));
this._validateCannotExceedMaxInteger({
maxFeePerGas: this.maxFeePerGas,
maxPriorityFeePerGas: this.maxPriorityFeePerGas,
});
BaseTransaction._validateNotArray(txData);
if (this.gasLimit * this.maxFeePerGas > MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
if (this.maxFeePerGas < this.maxPriorityFeePerGas) {
const msg = this._errorMsg('maxFeePerGas cannot be less than maxPriorityFeePerGas (The total must be the larger of the two)');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* The amount of gas paid for the data in this tx

@@ -306,3 +306,3 @@ */

accessList: this.accessList,
v: v - BigInt(27),
v: v - BigInt(27), // This looks extremely hacky: /util actually adds 27 to the value, the recovery bit is either 0 or 1.
r: uint8ArrayToBigInt(r),

@@ -309,0 +309,0 @@ s: uint8ArrayToBigInt(s),

@@ -36,49 +36,2 @@ /*

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'berlin';
const { chainId, accessList, gasPrice } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
// EIP-2718 check is done in Common
if (!this.common.isActivatedEIP(2930)) {
throw new Error('EIP-2930 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([2718, 2930]);
// Populate the access list fields
const accessListData = getAccessListData(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
verifyAccessList(this.accessList);
this.gasPrice = uint8ArrayToBigInt(toUint8Array(gasPrice === '' ? '0x' : gasPrice));
this._validateCannotExceedMaxInteger({
gasPrice: this.gasPrice,
});
BaseTransaction._validateNotArray(txData);
if (this.gasPrice * this.gasLimit > MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * gasPrice cannot exceed MAX_INTEGER');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Instantiate a transaction from a data dictionary.

@@ -136,3 +89,3 @@ *

accessList: accessList !== null && accessList !== void 0 ? accessList : emptyAccessList,
v: v !== undefined ? uint8ArrayToBigInt(v) : undefined,
v: v !== undefined ? uint8ArrayToBigInt(v) : undefined, // EIP2930 supports v's with value 0 (empty Uint8Array)
r,

@@ -143,2 +96,49 @@ s,

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
/**
* The default HF if the tx type is active on that HF
* or the first greater HF where the tx is active.
*
* @hidden
*/
this.DEFAULT_HARDFORK = 'berlin';
const { chainId, accessList, gasPrice } = txData;
this.common = this._getCommon(opts.common, chainId);
this.chainId = this.common.chainId();
// EIP-2718 check is done in Common
if (!this.common.isActivatedEIP(2930)) {
throw new Error('EIP-2930 not enabled on Common');
}
this.activeCapabilities = this.activeCapabilities.concat([2718, 2930]);
// Populate the access list fields
const accessListData = getAccessListData(accessList !== null && accessList !== void 0 ? accessList : []);
this.accessList = accessListData.accessList;
this.AccessListJSON = accessListData.AccessListJSON;
// Verify the access list format.
verifyAccessList(this.accessList);
this.gasPrice = uint8ArrayToBigInt(toUint8Array(gasPrice === '' ? '0x' : gasPrice));
this._validateCannotExceedMaxInteger({
gasPrice: this.gasPrice,
});
BaseTransaction._validateNotArray(txData);
if (this.gasPrice * this.gasLimit > MAX_INTEGER) {
const msg = this._errorMsg('gasLimit * gasPrice cannot exceed MAX_INTEGER');
throw new Error(msg);
}
this._validateYParity();
this._validateHighS();
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* The amount of gas paid for the data in this tx

@@ -285,3 +285,3 @@ */

accessList: this.accessList,
v: v - BigInt(27),
v: v - BigInt(27), // This looks extremely hacky: /util actually adds 27 to the value, the recovery bit is either 0 or 1.
r: uint8ArrayToBigInt(r),

@@ -288,0 +288,0 @@ s: uint8ArrayToBigInt(s),

@@ -37,42 +37,2 @@ /*

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
this.common = this._validateTxV(this.v, opts.common);
this.gasPrice = uint8ArrayToBigInt(toUint8Array(txData.gasPrice === '' ? '0x' : txData.gasPrice));
if (this.gasPrice * this.gasLimit > MAX_INTEGER) {
const msg = this._errorMsg('gas limit * gasPrice cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
this._validateCannotExceedMaxInteger({ gasPrice: this.gasPrice });
BaseTransaction._validateNotArray(txData);
if (this.common.gteHardfork('spuriousDragon')) {
if (!this.isSigned()) {
this.activeCapabilities.push(Capability.EIP155ReplayProtection);
}
else {
// EIP155 spec:
// If block.number >= 2,675,000 and v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36
// then when computing the hash of a transaction for purposes of signing or recovering
// instead of hashing only the first six elements (i.e. nonce, gasprice, startgas, to, value, data)
// hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0.
// v and chain ID meet EIP-155 conditions
// eslint-disable-next-line no-lonely-if
if (meetsEIP155(this.v, this.common.chainId())) {
this.activeCapabilities.push(Capability.EIP155ReplayProtection);
}
}
}
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Instantiate a transaction from a data dictionary.

@@ -126,2 +86,42 @@ *

/**
* This constructor takes the values, validates them, assigns them and freezes the object.
*
* It is not recommended to use this constructor directly. Instead use
* the static factory methods to assist in creating a Transaction object from
* varying data types.
*/
constructor(txData, opts = {}) {
var _a;
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts);
this.common = this._validateTxV(this.v, opts.common);
this.gasPrice = uint8ArrayToBigInt(toUint8Array(txData.gasPrice === '' ? '0x' : txData.gasPrice));
if (this.gasPrice * this.gasLimit > MAX_INTEGER) {
const msg = this._errorMsg('gas limit * gasPrice cannot exceed MAX_INTEGER (2^256-1)');
throw new Error(msg);
}
this._validateCannotExceedMaxInteger({ gasPrice: this.gasPrice });
BaseTransaction._validateNotArray(txData);
if (this.common.gteHardfork('spuriousDragon')) {
if (!this.isSigned()) {
this.activeCapabilities.push(Capability.EIP155ReplayProtection);
}
else {
// EIP155 spec:
// If block.number >= 2,675,000 and v = CHAIN_ID * 2 + 35 or v = CHAIN_ID * 2 + 36
// then when computing the hash of a transaction for purposes of signing or recovering
// instead of hashing only the first six elements (i.e. nonce, gasprice, startgas, to, value, data)
// hash nine elements, with v replaced by CHAIN_ID, r = 0 and s = 0.
// v and chain ID meet EIP-155 conditions
// eslint-disable-next-line no-lonely-if
if (meetsEIP155(this.v, this.common.chainId())) {
this.activeCapabilities.push(Capability.EIP155ReplayProtection);
}
}
}
const freeze = (_a = opts === null || opts === void 0 ? void 0 : opts.freeze) !== null && _a !== void 0 ? _a : true;
if (freeze) {
Object.freeze(this);
}
}
/**
* Returns a Uint8Array Array of the raw Uint8Arrays of the legacy transaction, in order.

@@ -128,0 +128,0 @@ *

@@ -26,3 +26,3 @@ /*

// It is not possible to instantiate a TransactionFactory object.
// eslint-disable-next-line @typescript-eslint/no-empty-function, no-useless-constructor
// eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
constructor() { }

@@ -29,0 +29,0 @@ static typeToInt(txType) {

@@ -82,7 +82,6 @@ import { bytesToHex } from 'web3-utils';

const JSONItem = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/consistent-type-assertions
address: bytesToHex(setLengthLeft(item[0], 20)),
storageKeys: [],
};
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/prefer-optional-chain
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
const storageSlots = item && item[1];

@@ -89,0 +88,0 @@ // eslint-disable-next-line @typescript-eslint/prefer-for-of

@@ -5,8 +5,8 @@ import type { Chain, ConsensusAlgorithm, ConsensusType, Hardfork } from './enums.js';

}
export declare type CliqueConfig = {
export type CliqueConfig = {
period: number;
epoch: number;
};
export declare type EthashConfig = Record<string, unknown>;
export declare type CasperConfig = Record<string, unknown>;
export type EthashConfig = Record<string, unknown>;
export type CasperConfig = Record<string, unknown>;
export interface GenesisBlockConfig {

@@ -113,9 +113,9 @@ timestamp?: string;

}
export declare type PrefixedHexString = string;
export declare type Uint8ArrayLike = Uint8Array | number[] | number | bigint | PrefixedHexString;
export declare type BigIntLike = bigint | PrefixedHexString | number | Uint8Array;
export type PrefixedHexString = string;
export type Uint8ArrayLike = Uint8Array | number[] | number | bigint | PrefixedHexString;
export type BigIntLike = bigint | PrefixedHexString | number | Uint8Array;
export interface TransformableToArray {
toArray(): Uint8Array;
}
export declare type NestedUint8Array = Array<Uint8Array | NestedUint8Array>;
export type NestedUint8Array = Array<Uint8Array | NestedUint8Array>;
/**

@@ -130,3 +130,3 @@ * Type output options

}
export declare type TypeOutputReturnType = {
export type TypeOutputReturnType = {
[TypeOutput.Number]: number;

@@ -137,4 +137,4 @@ [TypeOutput.BigInt]: bigint;

};
export declare type ToBytesInputTypes = PrefixedHexString | number | bigint | Uint8Array | number[] | TransformableToArray | null | undefined;
export type ToBytesInputTypes = PrefixedHexString | number | bigint | Uint8Array | number[] | TransformableToArray | null | undefined;
export {};
//# sourceMappingURL=types.d.ts.map
import { ToBytesInputTypes, TypeOutput, TypeOutputReturnType } from './types.js';
declare type ConfigHardfork = {
type ConfigHardfork = {
name: string;

@@ -4,0 +4,0 @@ block: null;

@@ -64,9 +64,9 @@ import type { HexString, Numbers } from 'web3-types';

}
export declare type AccessListItem = {
export type AccessListItem = {
address: PrefixedHexString;
storageKeys: PrefixedHexString[];
};
export declare type AccessListUint8ArrayItem = [Uint8Array, Uint8Array[]];
export declare type AccessListUint8Array = AccessListUint8ArrayItem[];
export declare type AccessList = AccessListItem[];
export type AccessListUint8ArrayItem = [Uint8Array, Uint8Array[]];
export type AccessListUint8Array = AccessListUint8ArrayItem[];
export type AccessList = AccessListItem[];
export declare function isAccessListUint8Array(input: AccessListUint8Array | AccessList): input is AccessListUint8Array;

@@ -82,3 +82,3 @@ export declare function isAccessList(input: AccessListUint8Array | AccessList): input is AccessList;

*/
export declare type TxData = {
export type TxData = {
/**

@@ -159,7 +159,7 @@ * The transaction's nonce.

*/
export declare type TxValuesArray = Uint8Array[];
export type TxValuesArray = Uint8Array[];
/**
* Uint8Array values array for an {@link AccessListEIP2930Transaction}
*/
export declare type AccessListEIP2930ValuesArray = [
export type AccessListEIP2930ValuesArray = [
Uint8Array,

@@ -180,3 +180,3 @@ Uint8Array,

*/
export declare type FeeMarketEIP1559ValuesArray = [
export type FeeMarketEIP1559ValuesArray = [
Uint8Array,

@@ -195,3 +195,3 @@ Uint8Array,

];
declare type JsonAccessListItem = {
type JsonAccessListItem = {
address: string;

@@ -198,0 +198,0 @@ storageKeys: string[];

@@ -38,3 +38,3 @@ import { HexString, SignatureObject, SignResult, SignTransactionResult, Web3BaseWalletAccount } from 'web3-types';

}
export declare type TypedTransaction = Transaction | AccessListEIP2930Transaction | FeeMarketEIP1559Transaction;
export type TypedTransaction = Transaction | AccessListEIP2930Transaction | FeeMarketEIP1559Transaction;
//# sourceMappingURL=types.d.ts.map
{
"name": "web3-eth-accounts",
"version": "4.3.1-dev.9aab5cd.0+9aab5cd",
"version": "4.3.1-dev.acdb0c7.0+acdb0c7",
"description": "Package for managing Ethereum accounts and signing",

@@ -57,4 +57,4 @@ "main": "./lib/commonjs/index.js",

"ts-jest": "^29.1.1",
"typescript": "^4.7.4",
"web3-providers-ipc": "4.0.8-dev.9aab5cd.0+9aab5cd"
"typescript": "^5.5.4",
"web3-providers-ipc": "4.0.8-dev.acdb0c7.0+acdb0c7"
},

@@ -65,8 +65,8 @@ "dependencies": {

"ethereum-cryptography": "^2.0.0",
"web3-errors": "1.3.1-dev.9aab5cd.0+9aab5cd",
"web3-types": "1.9.1-dev.9aab5cd.0+9aab5cd",
"web3-utils": "4.3.3-dev.9aab5cd.0+9aab5cd",
"web3-validator": "2.0.7-dev.9aab5cd.0+9aab5cd"
"web3-errors": "1.3.1-dev.acdb0c7.0+acdb0c7",
"web3-types": "1.9.1-dev.acdb0c7.0+acdb0c7",
"web3-utils": "4.3.3-dev.acdb0c7.0+acdb0c7",
"web3-validator": "2.0.7-dev.acdb0c7.0+acdb0c7"
},
"gitHead": "9aab5cd38cd3b3ccb2cacd4d3e9cfe2bab1c5cec"
"gitHead": "acdb0c775b885e0411e177a64f0cbd350b90315f"
}

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

public static fromGethGenesis(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
genesisJson: any,

@@ -815,5 +816,5 @@ { chain, eips, genesisHash, hardfork, mergeForkIdPostMerge }: GethConfigOpts,

public nextHardforkBlockOrTimestamp(_hardfork?: string | Hardfork): bigint | null {
const hardfork = _hardfork ?? this._hardfork;
const hardfork = (_hardfork as Hardfork) ?? this._hardfork;
const hfs = this.hardforks();
let hfIndex = hfs.findIndex(hf => hf.name === hardfork);
let hfIndex = hfs.findIndex(hf => (hf.name as Hardfork) === hardfork);
// If the current hardfork is merge, go one behind as merge hf is not part of these

@@ -847,3 +848,3 @@ // calcs even if the merge hf block is set

return (
hf.name !== Hardfork.Merge &&
(hf.name as Hardfork) !== Hardfork.Merge &&
// eslint-disable-next-line no-null/no-null

@@ -879,3 +880,3 @@ hfTimeOrBlock !== null &&

public nextHardforkBlock(_hardfork?: string | Hardfork): bigint | null {
const hardfork = _hardfork ?? this._hardfork;
const hardfork = (_hardfork as Hardfork) ?? this._hardfork;
let hfBlock = this.hardforkBlock(hardfork);

@@ -912,3 +913,3 @@ // If this is a merge hardfork with block not set, then we fallback to previous hardfork

// eslint-disable-next-line no-null/no-null
return block > hfBlock! && acc === null ? block : acc;
return block > hfBlock && acc === null ? block : acc;
// eslint-disable-next-line no-null/no-null

@@ -959,3 +960,3 @@ }, null);

blockOrTime !== prevBlockOrTime &&
name !== Hardfork.Merge
(name as Hardfork) !== Hardfork.Merge
) {

@@ -962,0 +963,0 @@ const hfBlockUint8Array = hexToBytes(blockOrTime.toString(16).padStart(16, '0'));

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

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function parseGethParams(json: any, mergeForkIdPostMerge = true) {

@@ -87,2 +88,3 @@ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment

name: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
config: any;

@@ -199,3 +201,3 @@ difficulty: string;

const configHardforkNames = Object.keys(config).filter(
// eslint-disable-next-line no-null/no-null, @typescript-eslint/no-unsafe-member-access
// eslint-disable-next-line no-null/no-null, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/prefer-optional-chain
key => forkMapRev[key] !== undefined && config[key] !== undefined && config[key] !== null,

@@ -256,3 +258,3 @@ );

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(hf: any) => forkMap[hf.name]?.postMerge === true,
hf => forkMap[hf.name]?.postMerge === true,
);

@@ -279,2 +281,3 @@ if (postMergeIndex !== -1) {

*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function parseGethGenesis(json: any, name?: string, mergeForkIdPostMerge?: boolean) {

@@ -290,5 +293,5 @@ try {

return parseGethParams(json, mergeForkIdPostMerge);
} catch (e: any) {
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
throw new Error(`Error parsing parameters file: ${e.message}`);
throw new Error(`Error parsing parameters file: ${(e as { message: string }).message}`);
}

@@ -295,0 +298,0 @@ }

@@ -310,3 +310,3 @@ /*

return unpadUint8Array(publicKey).length !== 0;
} catch (e: any) {
} catch (e) {
return false;

@@ -514,2 +514,3 @@ }

// eslint-disable-next-line @typescript-eslint/no-explicit-any
protected static _validateNotArray(values: { [key: string]: any }) {

@@ -561,3 +562,3 @@ const txDataKeys = [

hash = this.isSigned() ? bytesToHex(this.hash()) : 'not available (unsigned)';
} catch (e: any) {
} catch (e) {
hash = 'error';

@@ -568,3 +569,3 @@ }

isSigned = this.isSigned().toString();
} catch (e: any) {
} catch (e) {
hash = 'error';

@@ -575,3 +576,3 @@ }

hf = this.common.hardfork();
} catch (e: any) {
} catch (e) {
hf = 'error';

@@ -611,3 +612,3 @@ }

opts: TxOptions = {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
): any {}

@@ -618,7 +619,8 @@

// @ts-expect-error unused variable
// eslint-disable-next-line @typescript-eslint/no-explicit-any
txData: any,
// @ts-expect-error unused variable
opts: TxOptions = {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any
): any {}
}

@@ -107,3 +107,6 @@ /*

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return FeeMarketEIP1559Transaction.fromValuesArray(values as any, opts);
return FeeMarketEIP1559Transaction.fromValuesArray(
values as FeeMarketEIP1559ValuesArray,
opts,
);
}

@@ -383,3 +386,3 @@

);
} catch (e: any) {
} catch (e) {
const msg = this._errorMsg('Invalid Signature');

@@ -386,0 +389,0 @@ throw new Error(msg);

@@ -106,3 +106,6 @@ /*

// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return AccessListEIP2930Transaction.fromValuesArray(values as any, opts);
return AccessListEIP2930Transaction.fromValuesArray(
values as AccessListEIP2930ValuesArray,
opts,
);
}

@@ -341,3 +344,3 @@

);
} catch (e: any) {
} catch (e) {
const msg = this._errorMsg('Invalid Signature');

@@ -344,0 +347,0 @@ throw new Error(msg);

@@ -325,3 +325,3 @@ /*

);
} catch (e: any) {
} catch (e) {
const msg = this._errorMsg('Invalid Signature');

@@ -328,0 +328,0 @@ throw new Error(msg);

@@ -39,3 +39,3 @@ /*

// It is not possible to instantiate a TransactionFactory object.
// eslint-disable-next-line @typescript-eslint/no-empty-function, no-useless-constructor
// eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
private constructor() {}

@@ -42,0 +42,0 @@

@@ -209,3 +209,3 @@ /*

*/
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-redundant-type-constituents
gasPrice?: never | null;

@@ -212,0 +212,0 @@ /**

@@ -90,3 +90,3 @@ /*

// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/consistent-type-assertions
if ((<any>accessListItem)[2] !== undefined) {
if ((<Array<unknown>>accessListItem)[2] !== undefined) {
throw new Error(

@@ -119,9 +119,8 @@ 'Access list item cannot have 3 elements. It can only have an address, and an array of storage slots.',

for (let index = 0; index < accessList.length; index += 1) {
const item: any = accessList[index];
const item = accessList[index];
const JSONItem: { address: HexString; storageKeys: HexString[] } = {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/consistent-type-assertions
address: bytesToHex(setLengthLeft(<Uint8Array>item[0], 20)),
address: bytesToHex(setLengthLeft(item[0], 20)),
storageKeys: [],
};
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/prefer-optional-chain
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
const storageSlots: Uint8Array[] = item && item[1];

@@ -128,0 +127,0 @@ // eslint-disable-next-line @typescript-eslint/prefer-for-of

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 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

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