@ethereumjs/tx
Advanced tools
Comparing version 3.5.1 to 3.5.2
@@ -5,3 +5,3 @@ /// <reference types="bn.js" /> | ||
import { Address, BN, BNLike } from 'ethereumjs-util'; | ||
import { TxData, JsonTx, AccessListEIP2930ValuesArray, AccessListEIP2930TxData, FeeMarketEIP1559ValuesArray, FeeMarketEIP1559TxData, TxValuesArray, Capability } from './types'; | ||
import { TxData, JsonTx, AccessListEIP2930ValuesArray, AccessListEIP2930TxData, FeeMarketEIP1559ValuesArray, FeeMarketEIP1559TxData, TxValuesArray, Capability, TxOptions } from './types'; | ||
interface TransactionCache { | ||
@@ -33,2 +33,3 @@ hash: Buffer | undefined; | ||
protected cache: TransactionCache; | ||
protected readonly txOptions: TxOptions; | ||
/** | ||
@@ -56,3 +57,3 @@ * List of tx type defining EIPs, | ||
protected DEFAULT_HARDFORK: string | Hardfork; | ||
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData); | ||
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData, opts: TxOptions); | ||
/** | ||
@@ -59,0 +60,0 @@ * Alias for {@link BaseTransaction.type} |
@@ -65,3 +65,3 @@ "use strict"; | ||
var BaseTransaction = /** @class */ (function () { | ||
function BaseTransaction(txData) { | ||
function BaseTransaction(txData, opts) { | ||
this.cache = { | ||
@@ -95,2 +95,3 @@ hash: undefined, | ||
this._type = new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(type)).toNumber(); | ||
this.txOptions = opts; | ||
var toB = (0, ethereumjs_util_1.toBuffer)(to === '' ? '0x' : to); | ||
@@ -97,0 +98,0 @@ var vB = (0, ethereumjs_util_1.toBuffer)(v === '' ? '0x' : v); |
@@ -70,3 +70,3 @@ "use strict"; | ||
var _a, _b; | ||
_this = _super.call(this, __assign(__assign({}, txData), { type: TRANSACTION_TYPE })) || this; | ||
_this = _super.call(this, __assign(__assign({}, txData), { type: TRANSACTION_TYPE }), opts) || this; | ||
/** | ||
@@ -379,5 +379,3 @@ * The default HF if the tx type is active on that HF | ||
FeeMarketEIP1559Transaction.prototype._processSignature = function (v, r, s) { | ||
var opts = { | ||
common: this.common, | ||
}; | ||
var opts = __assign(__assign({}, this.txOptions), { common: this.common }); | ||
return FeeMarketEIP1559Transaction.fromTxData({ | ||
@@ -384,0 +382,0 @@ chainId: this.chainId, |
@@ -70,3 +70,3 @@ "use strict"; | ||
var _a, _b; | ||
_this = _super.call(this, __assign(__assign({}, txData), { type: TRANSACTION_TYPE })) || this; | ||
_this = _super.call(this, __assign(__assign({}, txData), { type: TRANSACTION_TYPE }), opts) || this; | ||
/** | ||
@@ -369,5 +369,3 @@ * The default HF if the tx type is active on that HF | ||
AccessListEIP2930Transaction.prototype._processSignature = function (v, r, s) { | ||
var opts = { | ||
common: this.common, | ||
}; | ||
var opts = __assign(__assign({}, this.txOptions), { common: this.common }); | ||
return AccessListEIP2930Transaction.fromTxData({ | ||
@@ -374,0 +372,0 @@ chainId: this.chainId, |
@@ -66,3 +66,3 @@ "use strict"; | ||
var _a; | ||
_this = _super.call(this, __assign(__assign({}, txData), { type: TRANSACTION_TYPE })) || this; | ||
_this = _super.call(this, __assign(__assign({}, txData), { type: TRANSACTION_TYPE }), opts) || this; | ||
_this.common = _this._validateTxV(_this.v, opts.common); | ||
@@ -318,5 +318,3 @@ _this.gasPrice = new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(txData.gasPrice === '' ? '0x' : txData.gasPrice)); | ||
} | ||
var opts = { | ||
common: this.common, | ||
}; | ||
var opts = __assign(__assign({}, this.txOptions), { common: this.common }); | ||
return Transaction.fromTxData({ | ||
@@ -354,6 +352,13 @@ nonce: this.nonce, | ||
Transaction.prototype._validateTxV = function (v, common) { | ||
// Check for valid v values in the scope of a signed legacy tx | ||
if (v !== undefined) { | ||
// v is 1. not matching the EIP-155 chainId included case and... | ||
// v is 2. not matching the classic v=27 or v=28 case | ||
if (v.ltn(37) && !v.eqn(27) && !v.eqn(28)) { | ||
throw new Error("Legacy txs need either v = 27/28 or v >= 37 (EIP-155 replay protection), got v = ".concat(v)); | ||
} | ||
} | ||
var chainIdBN; | ||
// No unsigned tx and EIP-155 activated and chain ID included | ||
if (v !== undefined && | ||
!v.eqn(0) && | ||
(!common || common.gteHardfork('spuriousDragon')) && | ||
@@ -360,0 +365,0 @@ !v.eqn(27) && |
@@ -55,3 +55,3 @@ /// <reference types="node" /> | ||
* If you need to deactivate the tx freeze - e.g. because you want to subclass tx and | ||
* add aditional properties - it is strongly encouraged that you do the freeze yourself | ||
* add additional properties - it is strongly encouraged that you do the freeze yourself | ||
* within your code instead. | ||
@@ -58,0 +58,0 @@ * |
@@ -5,3 +5,3 @@ /// <reference types="bn.js" /> | ||
import { Address, BN, BNLike } from 'ethereumjs-util'; | ||
import { TxData, JsonTx, AccessListEIP2930ValuesArray, AccessListEIP2930TxData, FeeMarketEIP1559ValuesArray, FeeMarketEIP1559TxData, TxValuesArray, Capability } from './types'; | ||
import { TxData, JsonTx, AccessListEIP2930ValuesArray, AccessListEIP2930TxData, FeeMarketEIP1559ValuesArray, FeeMarketEIP1559TxData, TxValuesArray, Capability, TxOptions } from './types'; | ||
interface TransactionCache { | ||
@@ -33,2 +33,3 @@ hash: Buffer | undefined; | ||
protected cache: TransactionCache; | ||
protected readonly txOptions: TxOptions; | ||
/** | ||
@@ -56,3 +57,3 @@ * List of tx type defining EIPs, | ||
protected DEFAULT_HARDFORK: string | Hardfork; | ||
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData); | ||
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData, opts: TxOptions); | ||
/** | ||
@@ -59,0 +60,0 @@ * Alias for {@link BaseTransaction.type} |
@@ -38,3 +38,3 @@ "use strict"; | ||
class BaseTransaction { | ||
constructor(txData) { | ||
constructor(txData, opts) { | ||
this.cache = { | ||
@@ -68,2 +68,3 @@ hash: undefined, | ||
this._type = new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(type)).toNumber(); | ||
this.txOptions = opts; | ||
const toB = (0, ethereumjs_util_1.toBuffer)(to === '' ? '0x' : to); | ||
@@ -70,0 +71,0 @@ const vB = (0, ethereumjs_util_1.toBuffer)(v === '' ? '0x' : v); |
@@ -25,3 +25,3 @@ "use strict"; | ||
var _a, _b; | ||
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE })); | ||
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts); | ||
/** | ||
@@ -315,5 +315,3 @@ * The default HF if the tx type is active on that HF | ||
_processSignature(v, r, s) { | ||
const opts = { | ||
common: this.common, | ||
}; | ||
const opts = Object.assign(Object.assign({}, this.txOptions), { common: this.common }); | ||
return FeeMarketEIP1559Transaction.fromTxData({ | ||
@@ -320,0 +318,0 @@ chainId: this.chainId, |
@@ -25,3 +25,3 @@ "use strict"; | ||
var _a, _b; | ||
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE })); | ||
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts); | ||
/** | ||
@@ -306,5 +306,3 @@ * The default HF if the tx type is active on that HF | ||
_processSignature(v, r, s) { | ||
const opts = { | ||
common: this.common, | ||
}; | ||
const opts = Object.assign(Object.assign({}, this.txOptions), { common: this.common }); | ||
return AccessListEIP2930Transaction.fromTxData({ | ||
@@ -311,0 +309,0 @@ chainId: this.chainId, |
@@ -21,3 +21,3 @@ "use strict"; | ||
var _a; | ||
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE })); | ||
super(Object.assign(Object.assign({}, txData), { type: TRANSACTION_TYPE }), opts); | ||
this.common = this._validateTxV(this.v, opts.common); | ||
@@ -267,5 +267,3 @@ this.gasPrice = new ethereumjs_util_1.BN((0, ethereumjs_util_1.toBuffer)(txData.gasPrice === '' ? '0x' : txData.gasPrice)); | ||
} | ||
const opts = { | ||
common: this.common, | ||
}; | ||
const opts = Object.assign(Object.assign({}, this.txOptions), { common: this.common }); | ||
return Transaction.fromTxData({ | ||
@@ -303,6 +301,13 @@ nonce: this.nonce, | ||
_validateTxV(v, common) { | ||
// Check for valid v values in the scope of a signed legacy tx | ||
if (v !== undefined) { | ||
// v is 1. not matching the EIP-155 chainId included case and... | ||
// v is 2. not matching the classic v=27 or v=28 case | ||
if (v.ltn(37) && !v.eqn(27) && !v.eqn(28)) { | ||
throw new Error(`Legacy txs need either v = 27/28 or v >= 37 (EIP-155 replay protection), got v = ${v}`); | ||
} | ||
} | ||
let chainIdBN; | ||
// No unsigned tx and EIP-155 activated and chain ID included | ||
if (v !== undefined && | ||
!v.eqn(0) && | ||
(!common || common.gteHardfork('spuriousDragon')) && | ||
@@ -309,0 +314,0 @@ !v.eqn(27) && |
@@ -55,3 +55,3 @@ /// <reference types="node" /> | ||
* If you need to deactivate the tx freeze - e.g. because you want to subclass tx and | ||
* add aditional properties - it is strongly encouraged that you do the freeze yourself | ||
* add additional properties - it is strongly encouraged that you do the freeze yourself | ||
* within your code instead. | ||
@@ -58,0 +58,0 @@ * |
{ | ||
"name": "@ethereumjs/tx", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "A simple module for creating, manipulating and signing Ethereum transactions", | ||
@@ -37,4 +37,4 @@ "license": "MPL-2.0", | ||
"dependencies": { | ||
"@ethereumjs/common": "^2.6.3", | ||
"ethereumjs-util": "^7.1.4" | ||
"@ethereumjs/common": "^2.6.4", | ||
"ethereumjs-util": "^7.1.5" | ||
}, | ||
@@ -41,0 +41,0 @@ "devDependencies": { |
@@ -23,2 +23,3 @@ import Common, { Chain, Hardfork } from '@ethereumjs/common' | ||
Capability, | ||
TxOptions, | ||
} from './types' | ||
@@ -61,2 +62,4 @@ | ||
protected readonly txOptions: TxOptions | ||
/** | ||
@@ -87,6 +90,8 @@ * List of tx type defining EIPs, | ||
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData) { | ||
constructor(txData: TxData | AccessListEIP2930TxData | FeeMarketEIP1559TxData, opts: TxOptions) { | ||
const { nonce, gasLimit, to, value, data, v, r, s, type } = txData | ||
this._type = new BN(toBuffer(type)).toNumber() | ||
this.txOptions = opts | ||
const toB = toBuffer(to === '' ? '0x' : to) | ||
@@ -93,0 +98,0 @@ const vB = toBuffer(v === '' ? '0x' : v) |
@@ -186,3 +186,3 @@ import { | ||
public constructor(txData: FeeMarketEIP1559TxData, opts: TxOptions = {}) { | ||
super({ ...txData, type: TRANSACTION_TYPE }) | ||
super({ ...txData, type: TRANSACTION_TYPE }, opts) | ||
const { chainId, accessList, maxFeePerGas, maxPriorityFeePerGas } = txData | ||
@@ -412,5 +412,3 @@ | ||
_processSignature(v: number, r: Buffer, s: Buffer) { | ||
const opts = { | ||
common: this.common, | ||
} | ||
const opts = { ...this.txOptions, common: this.common } | ||
@@ -417,0 +415,0 @@ return FeeMarketEIP1559Transaction.fromTxData( |
@@ -174,3 +174,3 @@ import { | ||
public constructor(txData: AccessListEIP2930TxData, opts: TxOptions = {}) { | ||
super({ ...txData, type: TRANSACTION_TYPE }) | ||
super({ ...txData, type: TRANSACTION_TYPE }, opts) | ||
const { chainId, accessList, gasPrice } = txData | ||
@@ -384,5 +384,3 @@ | ||
_processSignature(v: number, r: Buffer, s: Buffer) { | ||
const opts = { | ||
common: this.common, | ||
} | ||
const opts = { ...this.txOptions, common: this.common } | ||
@@ -389,0 +387,0 @@ return AccessListEIP2930Transaction.fromTxData( |
@@ -108,3 +108,3 @@ import { | ||
public constructor(txData: TxData, opts: TxOptions = {}) { | ||
super({ ...txData, type: TRANSACTION_TYPE }) | ||
super({ ...txData, type: TRANSACTION_TYPE }, opts) | ||
@@ -343,5 +343,3 @@ this.common = this._validateTxV(this.v, opts.common) | ||
const opts = { | ||
common: this.common, | ||
} | ||
const opts = { ...this.txOptions, common: this.common } | ||
@@ -385,2 +383,13 @@ return Transaction.fromTxData( | ||
private _validateTxV(v?: BN, common?: Common): Common { | ||
// Check for valid v values in the scope of a signed legacy tx | ||
if (v !== undefined) { | ||
// v is 1. not matching the EIP-155 chainId included case and... | ||
// v is 2. not matching the classic v=27 or v=28 case | ||
if (v.ltn(37) && !v.eqn(27) && !v.eqn(28)) { | ||
throw new Error( | ||
`Legacy txs need either v = 27/28 or v >= 37 (EIP-155 replay protection), got v = ${v}` | ||
) | ||
} | ||
} | ||
let chainIdBN | ||
@@ -390,3 +399,2 @@ // No unsigned tx and EIP-155 activated and chain ID included | ||
v !== undefined && | ||
!v.eqn(0) && | ||
(!common || common.gteHardfork('spuriousDragon')) && | ||
@@ -393,0 +401,0 @@ !v.eqn(27) && |
@@ -58,3 +58,3 @@ import { BN, AddressLike, BNLike, BufferLike, PrefixedHexString } from 'ethereumjs-util' | ||
* If you need to deactivate the tx freeze - e.g. because you want to subclass tx and | ||
* add aditional properties - it is strongly encouraged that you do the freeze yourself | ||
* add additional properties - it is strongly encouraged that you do the freeze yourself | ||
* within your code instead. | ||
@@ -61,0 +61,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
430683
7771
Updated@ethereumjs/common@^2.6.4
Updatedethereumjs-util@^7.1.5