Socket
Socket
Sign inDemoInstall

@ethereumjs/tx

Package Overview
Dependencies
Maintainers
3
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.0.0 to 4.0.1

dist/fromRpc.d.ts

3

dist/baseTransaction.d.ts

@@ -174,2 +174,5 @@ /// <reference types="node" />

}, bits?: number, cannotEqual?: boolean): void;
protected static _validateNotArray(values: {
[key: string]: any;
}): void;
/**

@@ -176,0 +179,0 @@ * Return a compact error string representation of the object

@@ -309,2 +309,26 @@ "use strict";

}
static _validateNotArray(values) {
const txDataKeys = [
'nonce',
'gasPrice',
'gasLimit',
'to',
'value',
'data',
'v',
'r',
's',
'type',
'baseFee',
'maxFeePerGas',
'chainId',
];
for (const [key, value] of Object.entries(values)) {
if (txDataKeys.includes(key)) {
if (Array.isArray(value)) {
throw new Error(`${key} cannot be an array`);
}
}
}
}
/**

@@ -311,0 +335,0 @@ * Returns the shared error postfix part for _error() method

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

});
baseTransaction_1.BaseTransaction._validateNotArray(txData);
if (this.gasLimit * this.maxFeePerGas > util_1.MAX_INTEGER) {

@@ -114,2 +115,3 @@ const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)');

const [chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, v, r, s,] = values;
this._validateNotArray({ chainId, v });
(0, util_1.validateNoLeadingZeroes)({ nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, value, v, r, s });

@@ -116,0 +118,0 @@ return new FeeMarketEIP1559Transaction({

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

});
baseTransaction_1.BaseTransaction._validateNotArray(txData);
if (this.gasPrice * this.gasLimit > util_1.MAX_INTEGER) {

@@ -109,2 +110,3 @@ const msg = this._errorMsg('gasLimit * gasPrice cannot exceed MAX_INTEGER');

const [chainId, nonce, gasPrice, gasLimit, to, value, data, accessList, v, r, s] = values;
this._validateNotArray({ chainId, v });
(0, util_1.validateNoLeadingZeroes)({ nonce, gasPrice, gasLimit, value, v, r, s });

@@ -111,0 +113,0 @@ const emptyAccessList = [];

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

this._validateCannotExceedMaxInteger({ gasPrice: this.gasPrice });
baseTransaction_1.BaseTransaction._validateNotArray(txData);
if (this.common.gteHardfork('spuriousDragon')) {

@@ -38,0 +39,0 @@ if (!this.isSigned()) {

/// <reference types="node" />
import { ethers } from 'ethers';
import type { AccessListEIP2930TxData, FeeMarketEIP1559TxData, TxData, TxOptions, TypedTransaction } from './types';

@@ -29,3 +30,11 @@ export declare class TransactionFactory {

static fromBlockBodyData(data: Buffer | Buffer[], txOptions?: TxOptions): TypedTransaction;
/**
* Method to retrieve a transaction from the provider
* @param provider - An Ethers JsonRPCProvider
* @param txHash - Transaction hash
* @param txOptions - The transaction options
* @returns the transaction specified by `txHash`
*/
static fromEthersProvider(provider: string | ethers.providers.JsonRpcProvider, txHash: string, txOptions?: TxOptions): Promise<TypedTransaction>;
}
//# sourceMappingURL=transactionFactory.d.ts.map

@@ -5,4 +5,6 @@ "use strict";

const util_1 = require("@ethereumjs/util");
const ethers_1 = require("ethers");
const eip1559Transaction_1 = require("./eip1559Transaction");
const eip2930Transaction_1 = require("./eip2930Transaction");
const fromRpc_1 = require("./fromRpc");
const legacyTransaction_1 = require("./legacyTransaction");

@@ -92,4 +94,17 @@ class TransactionFactory {

}
/**
* Method to retrieve a transaction from the provider
* @param provider - An Ethers JsonRPCProvider
* @param txHash - Transaction hash
* @param txOptions - The transaction options
* @returns the transaction specified by `txHash`
*/
static async fromEthersProvider(provider, txHash, txOptions) {
const prov = typeof provider === 'string' ? new ethers_1.ethers.providers.JsonRpcProvider(provider) : provider;
const txData = await prov.send('eth_getTransactionByHash', [txHash]);
const normedTx = (0, fromRpc_1.normalizeTxParams)(txData);
return TransactionFactory.fromTxData(normedTx, txOptions);
}
}
exports.TransactionFactory = TransactionFactory;
//# sourceMappingURL=transactionFactory.js.map

12

package.json
{
"name": "@ethereumjs/tx",
"version": "4.0.0",
"version": "4.0.1",
"description": "A simple module for creating, manipulating and signing Ethereum transactions",

@@ -47,12 +47,14 @@ "keywords": [

"tape": "tape -r ts-node/register",
"test": "npm run test:node && npm run test:browser",
"test": "npm run test:node && npm run test:browser && npm run test:txTests",
"test:browser": "karma start karma.conf.js",
"test:node": "tape -r ts-node/register ./test/index.ts",
"test:node": "tape -r ts-node/register -- 'test/**/*.spec.ts'",
"test:txTests": "tape -r ts-node/register ./test/transactionRunner.ts",
"tsc": "../../config/cli/ts-compile.sh"
},
"dependencies": {
"@ethereumjs/common": "^3.0.0",
"@ethereumjs/common": "^3.0.1",
"@ethereumjs/rlp": "^4.0.0",
"@ethereumjs/util": "^8.0.0",
"ethereum-cryptography": "^1.1.2"
"ethereum-cryptography": "^1.1.2",
"ethers": "^5.7.1"
},

@@ -59,0 +61,0 @@ "devDependencies": {

@@ -208,2 +208,3 @@ # @ethereumjs/tx

- `public static fromBlockBodyData(data: Buffer | Buffer[], txOptions: TxOptions = {})`
- `public static async fromEthersProvider(provider: string | ethers.providers.JsonRpcProvider, txHash: string, txOptions?: TxOptions)`

@@ -210,0 +211,0 @@ ### Sending a Transaction

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

protected static _validateNotArray(values: { [key: string]: any }) {
const txDataKeys = [
'nonce',
'gasPrice',
'gasLimit',
'to',
'value',
'data',
'v',
'r',
's',
'type',
'baseFee',
'maxFeePerGas',
'chainId',
]
for (const [key, value] of Object.entries(values)) {
if (txDataKeys.includes(key)) {
if (Array.isArray(value)) {
throw new Error(`${key} cannot be an array`)
}
}
}
}
/**

@@ -456,0 +481,0 @@ * Return a compact error string representation of the object

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

this._validateNotArray({ chainId, v })
validateNoLeadingZeroes({ nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, value, v, r, s })

@@ -178,2 +179,4 @@

BaseTransaction._validateNotArray(txData)
if (this.gasLimit * this.maxFeePerGas > MAX_INTEGER) {

@@ -180,0 +183,0 @@ const msg = this._errorMsg('gasLimit * maxFeePerGas cannot exceed MAX_INTEGER (2^256-1)')

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

this._validateNotArray({ chainId, v })
validateNoLeadingZeroes({ nonce, gasPrice, gasLimit, value, v, r, s })

@@ -162,2 +163,4 @@

BaseTransaction._validateNotArray(txData)
if (this.gasPrice * this.gasLimit > MAX_INTEGER) {

@@ -164,0 +167,0 @@ const msg = this._errorMsg('gasLimit * gasPrice cannot exceed MAX_INTEGER')

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

this._validateCannotExceedMaxInteger({ gasPrice: this.gasPrice })
BaseTransaction._validateNotArray(txData)

@@ -121,0 +122,0 @@ if (this.common.gteHardfork('spuriousDragon')) {

import { bufferToBigInt, toBuffer } from '@ethereumjs/util'
import { ethers } from 'ethers'
import { FeeMarketEIP1559Transaction } from './eip1559Transaction'
import { AccessListEIP2930Transaction } from './eip2930Transaction'
import { normalizeTxParams } from './fromRpc'
import { Transaction } from './legacyTransaction'

@@ -96,2 +98,21 @@

}
/**
* Method to retrieve a transaction from the provider
* @param provider - An Ethers JsonRPCProvider
* @param txHash - Transaction hash
* @param txOptions - The transaction options
* @returns the transaction specified by `txHash`
*/
public static async fromEthersProvider(
provider: string | ethers.providers.JsonRpcProvider,
txHash: string,
txOptions?: TxOptions
) {
const prov =
typeof provider === 'string' ? new ethers.providers.JsonRpcProvider(provider) : provider
const txData = await prov.send('eth_getTransactionByHash', [txHash])
const normedTx = normalizeTxParams(txData)
return TransactionFactory.fromTxData(normedTx, txOptions)
}
}

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