Socket
Socket
Sign inDemoInstall

@ethereumjs/tx

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/tx - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

7

dist/baseTransaction.js

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

const types_1 = require("./types");
const util_2 = require("./util");
/**

@@ -63,2 +64,8 @@ * This base class will likely be subject to further

this._validateCannotExceedMaxInteger({ nonce: this.nonce }, 64, true);
const createContract = this.to === undefined || this.to === null;
const allowUnlimitedInitCodeSize = opts.allowUnlimitedInitCodeSize ?? false;
const common = opts.common ?? this._getCommon();
if (createContract && common.isActivatedEIP(3860) && allowUnlimitedInitCodeSize === false) {
(0, util_2.checkMaxInitCodeSize)(common, this.data.length);
}
}

@@ -65,0 +72,0 @@ /**

3

dist/eip1559Transaction.js

@@ -64,5 +64,2 @@ "use strict";

this._validateHighS();
if (this.common.isActivatedEIP(3860)) {
(0, util_2.checkMaxInitCodeSize)(this.common, this.data.length);
}
const freeze = opts?.freeze ?? true;

@@ -69,0 +66,0 @@ if (freeze) {

@@ -59,5 +59,2 @@ "use strict";

this._validateHighS();
if (this.common.isActivatedEIP(3860)) {
(0, util_2.checkMaxInitCodeSize)(this.common, this.data.length);
}
const freeze = opts?.freeze ?? true;

@@ -64,0 +61,0 @@ if (freeze) {

@@ -83,5 +83,2 @@ "use strict";

this._validateHighS();
if (this.common.isActivatedEIP(3860)) {
(0, util_2.checkMaxInitCodeSize)(this.common, this.data.length);
}
for (const hash of this.versionedHashes) {

@@ -88,0 +85,0 @@ if (hash.length !== 32) {

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

: null;
txParams.v = (0, util_1.toType)(txParams.v, util_1.TypeOutput.BigInt);
// Normalize the v/r/s values. If RPC returns '0x0', ensure v/r/s are set to `undefined` in the tx.
// If this is not done, then the transaction creation will throw, because `v` is `0`.
// Note: this still means that `isSigned` will return `false`.
// v/r/s values are `0x0` on networks like Optimism, where the tx is a system tx.
// For instance: https://optimistic.etherscan.io/tx/0xf4304cb09b3f58a8e5d20fec5f393c96ccffe0269aaf632cb2be7a8a0f0c91cc
txParams.v = txParams.v === '0x0' ? '0x' : txParams.v;
txParams.r = txParams.r === '0x0' ? '0x' : txParams.r;
txParams.s = txParams.s === '0x0' ? '0x' : txParams.s;
if (txParams.v !== '0x') {
txParams.v = (0, util_1.toType)(txParams.v, util_1.TypeOutput.BigInt);
}
return txParams;

@@ -20,0 +30,0 @@ };

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

const types_1 = require("./types");
const util_2 = require("./util");
const TRANSACTION_TYPE = 0;

@@ -54,5 +53,2 @@ function meetsEIP155(_v, chainId) {

}
if (this.common.isActivatedEIP(3860)) {
(0, util_2.checkMaxInitCodeSize)(this.common, this.data.length);
}
const freeze = opts?.freeze ?? true;

@@ -59,0 +55,0 @@ if (freeze) {

/// <reference types="node" />
import { JsonRpcProvider } from '@ethersproject/providers';
import type { AccessListEIP2930TxData, BlobEIP4844TxData, FeeMarketEIP1559TxData, TxData, TxOptions, TypedTransaction } from './types';

@@ -37,4 +36,12 @@ export declare class TransactionFactory {

*/
static fromEthersProvider(provider: string | JsonRpcProvider, txHash: string, txOptions?: TxOptions): Promise<TypedTransaction>;
static fromEthersProvider(provider: string | any, txHash: string, txOptions?: TxOptions): Promise<TypedTransaction>;
/**
* Method to decode data retrieved from RPC, such as `eth_getTransactionByHash`
* Note that this normalizes some of the parameters
* @param txData The RPC-encoded data
* @param txOptions The transaction options
* @returns
*/
static fromRPCTx(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData | BlobEIP4844TxData, txOptions?: TxOptions): Promise<TypedTransaction>;
}
//# sourceMappingURL=transactionFactory.d.ts.map

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

const util_1 = require("@ethereumjs/util");
const providers_1 = require("@ethersproject/providers");
const eip1559Transaction_1 = require("./eip1559Transaction");

@@ -98,9 +97,24 @@ const eip2930Transaction_1 = require("./eip2930Transaction");

static async fromEthersProvider(provider, txHash, txOptions) {
const prov = typeof provider === 'string' ? new providers_1.JsonRpcProvider(provider) : provider;
const txData = await prov.send('eth_getTransactionByHash', [txHash]);
const normedTx = (0, fromRpc_1.normalizeTxParams)(txData);
return TransactionFactory.fromTxData(normedTx, txOptions);
const prov = (0, util_1.getProvider)(provider);
const txData = await (0, util_1.fetchFromProvider)(prov, {
method: 'eth_getTransactionByHash',
params: [txHash],
});
if (txData === null) {
throw new Error('No data returned from provider');
}
return TransactionFactory.fromRPCTx(txData, txOptions);
}
/**
* Method to decode data retrieved from RPC, such as `eth_getTransactionByHash`
* Note that this normalizes some of the parameters
* @param txData The RPC-encoded data
* @param txOptions The transaction options
* @returns
*/
static async fromRPCTx(txData, txOptions = {}) {
return TransactionFactory.fromTxData((0, fromRpc_1.normalizeTxParams)(txData), txOptions);
}
}
exports.TransactionFactory = TransactionFactory;
//# sourceMappingURL=transactionFactory.js.map

@@ -62,2 +62,7 @@ /// <reference types="node" />

freeze?: boolean;
/**
* Allows unlimited contract code-size init while debugging. This (partially) disables EIP-3860.
* Gas cost for initcode size analysis will still be charged. Use with caution.
*/
allowUnlimitedInitCodeSize?: boolean;
}

@@ -64,0 +69,0 @@ export declare type AccessListItem = {

{
"name": "@ethereumjs/tx",
"version": "4.1.1",
"version": "4.1.2",
"description": "A simple module for creating, manipulating and signing Ethereum transactions",

@@ -54,8 +54,7 @@ "keywords": [

"dependencies": {
"@chainsafe/ssz": "0.9.4",
"@ethereumjs/common": "^3.1.1",
"@chainsafe/ssz": "^0.11.1",
"@ethereumjs/common": "^3.1.2",
"@ethereumjs/rlp": "^4.0.1",
"@ethereumjs/util": "^8.0.5",
"ethereum-cryptography": "^1.1.2",
"@ethersproject/providers": "^5.7.2"
"@ethereumjs/util": "^8.0.6",
"ethereum-cryptography": "^2.0.0"
},

@@ -74,3 +73,4 @@ "peerDependencies": {

"minimist": "^1.2.0",
"node-dir": "^0.1.16"
"node-dir": "^0.1.16",
"testdouble": "^3.17.2"
},

@@ -77,0 +77,0 @@ "engines": {

@@ -16,2 +16,3 @@ import { Chain, Common, Hardfork } from '@ethereumjs/common'

import { Capability } from './types'
import { checkMaxInitCodeSize } from './util'

@@ -120,2 +121,9 @@ import type {

this._validateCannotExceedMaxInteger({ nonce: this.nonce }, 64, true)
const createContract = this.to === undefined || this.to === null
const allowUnlimitedInitCodeSize = opts.allowUnlimitedInitCodeSize ?? false
const common = opts.common ?? this._getCommon()
if (createContract && common.isActivatedEIP(3860) && allowUnlimitedInitCodeSize === false) {
checkMaxInitCodeSize(common, this.data.length)
}
}

@@ -122,0 +130,0 @@

@@ -16,3 +16,3 @@ import { RLP } from '@ethereumjs/rlp'

import { BaseTransaction } from './baseTransaction'
import { AccessLists, checkMaxInitCodeSize } from './util'
import { AccessLists } from './util'

@@ -196,6 +196,2 @@ import type {

if (this.common.isActivatedEIP(3860)) {
checkMaxInitCodeSize(this.common, this.data.length)
}
const freeze = opts?.freeze ?? true

@@ -202,0 +198,0 @@ if (freeze) {

@@ -16,3 +16,3 @@ import { RLP } from '@ethereumjs/rlp'

import { BaseTransaction } from './baseTransaction'
import { AccessLists, checkMaxInitCodeSize } from './util'
import { AccessLists } from './util'

@@ -173,5 +173,2 @@ import type {

if (this.common.isActivatedEIP(3860)) {
checkMaxInitCodeSize(this.common, this.data.length)
}
const freeze = opts?.freeze ?? true

@@ -178,0 +175,0 @@ if (freeze) {

@@ -22,3 +22,3 @@ import { byteArrayEquals } from '@chainsafe/ssz'

} from './types'
import { AccessLists, blobTxToNetworkWrapperDataFormat, checkMaxInitCodeSize } from './util'
import { AccessLists, blobTxToNetworkWrapperDataFormat } from './util'
import { computeVersionedHash } from './utils/blobHelpers'

@@ -147,6 +147,2 @@

if (this.common.isActivatedEIP(3860)) {
checkMaxInitCodeSize(this.common, this.data.length)
}
for (const hash of this.versionedHashes) {

@@ -153,0 +149,0 @@ if (hash.length !== 32) {

@@ -21,5 +21,17 @@ import { TypeOutput, setLengthLeft, toBuffer, toType } from '@ethereumjs/util'

txParams.v = toType(txParams.v, TypeOutput.BigInt)
// Normalize the v/r/s values. If RPC returns '0x0', ensure v/r/s are set to `undefined` in the tx.
// If this is not done, then the transaction creation will throw, because `v` is `0`.
// Note: this still means that `isSigned` will return `false`.
// v/r/s values are `0x0` on networks like Optimism, where the tx is a system tx.
// For instance: https://optimistic.etherscan.io/tx/0xf4304cb09b3f58a8e5d20fec5f393c96ccffe0269aaf632cb2be7a8a0f0c91cc
txParams.v = txParams.v === '0x0' ? '0x' : txParams.v
txParams.r = txParams.r === '0x0' ? '0x' : txParams.r
txParams.s = txParams.s === '0x0' ? '0x' : txParams.s
if (txParams.v !== '0x') {
txParams.v = toType(txParams.v, TypeOutput.BigInt)
}
return txParams
}

@@ -18,3 +18,2 @@ import { RLP } from '@ethereumjs/rlp'

import { Capability } from './types'
import { checkMaxInitCodeSize } from './util'

@@ -138,6 +137,2 @@ import type { JsonTx, TxData, TxOptions, TxValuesArray } from './types'

if (this.common.isActivatedEIP(3860)) {
checkMaxInitCodeSize(this.common, this.data.length)
}
const freeze = opts?.freeze ?? true

@@ -144,0 +139,0 @@ if (freeze) {

@@ -1,3 +0,2 @@

import { bufferToBigInt, toBuffer } from '@ethereumjs/util'
import { JsonRpcProvider } from '@ethersproject/providers'
import { bufferToBigInt, fetchFromProvider, getProvider, toBuffer } from '@ethereumjs/util'

@@ -104,11 +103,30 @@ import { FeeMarketEIP1559Transaction } from './eip1559Transaction'

public static async fromEthersProvider(
provider: string | JsonRpcProvider,
provider: string | any,
txHash: string,
txOptions?: TxOptions
) {
const prov = typeof provider === 'string' ? new JsonRpcProvider(provider) : provider
const txData = await prov.send('eth_getTransactionByHash', [txHash])
const normedTx = normalizeTxParams(txData)
return TransactionFactory.fromTxData(normedTx, txOptions)
const prov = getProvider(provider)
const txData = await fetchFromProvider(prov, {
method: 'eth_getTransactionByHash',
params: [txHash],
})
if (txData === null) {
throw new Error('No data returned from provider')
}
return TransactionFactory.fromRPCTx(txData, txOptions)
}
/**
* Method to decode data retrieved from RPC, such as `eth_getTransactionByHash`
* Note that this normalizes some of the parameters
* @param txData The RPC-encoded data
* @param txOptions The transaction options
* @returns
*/
public static async fromRPCTx(
txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData | BlobEIP4844TxData,
txOptions: TxOptions = {}
) {
return TransactionFactory.fromTxData(normalizeTxParams(txData), txOptions)
}
}

@@ -93,2 +93,8 @@ import {

freeze?: boolean
/**
* Allows unlimited contract code-size init while debugging. This (partially) disables EIP-3860.
* Gas cost for initcode size analysis will still be charged. Use with caution.
*/
allowUnlimitedInitCodeSize?: boolean
}

@@ -95,0 +101,0 @@

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