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

@ethereumjs/tx

Package Overview
Dependencies
Maintainers
6
Versions
39
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 3.1.2 to 3.1.3

102

CHANGELOG.md

@@ -9,4 +9,18 @@ # Changelog

## 3.1.3 - 2021-04-09
This release fixes a critical EIP-2930 tx constructor bug which slipped through our tests and where a tx is not initialized correctly when a `v` value of `0` is passed (which is a common case for EIP-2930 txs). This makes the typed txs unusable on prior versions and an update from a version `v3.1.0` or higher is necessary for working typed tx support. Releases `v3.1.0`, `v3.1.1` and `v3.1.2` are marked as deprecated.
**Change Summary**
- Fixed `AccessListEIP2930Transaction` constructor bug with `v=0`, PR [#1190](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1190)
- Added alias `type` for `transactionType` so it can be interpreted correctly for an `AccessListEIP2930Transaction` instantiation when passed to `fromTxData()`, PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185)
- `TransactionFactory.fromTxData()`: fixed a bug where instantiation was breaking when `type` was passed in as a 0x-prefixed hex string, PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185)
- `AccessListEIP2930Transaction`: added a test that initializes correctly from its own data (adds coverage for `type` property alias), PR [#1185](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1185)
- EIP-2930 aliases for `senderS`, `senderR`, `yParity` are now marked as *deprecated*, use `v`, `r`, `s` instead
## 3.1.2 - 2021-03-31
**DEPRECATED**: Release is deprecated in favor of 3.1.3 which fixes a critical EIP-2930 tx constructor bug.
- Fixed default value for empty access lists in the `AccessListEIP2930Transaction.fromValuesArray()` static constructor method, PR [#1179](https://github.com/ethereumjs/ethereumjs-monorepo/pull/1179)

@@ -16,2 +30,4 @@

**DEPRECATED**: Release is deprecated in favor of 3.1.3 which fixes a critical EIP-2930 tx constructor bug.
This release fixes a bug in the `v3.1.0` Berlin HF `@ethereumjs/tx` release where the import path for `eip2930Transaction` was broken on operating systems with case sensitive filename resolution.

@@ -113,7 +129,7 @@

This release is a major refactoring of the transaction library to simplify and strengthen its code base. Refactoring work has been done along PR [#812](https://github.com/ethereumjs/ethereumjs-vm/pull/812) and PR [#887](https://github.com/ethereumjs/ethereumjs-vm/pull/887).
This release is a major refactoring of the transaction library to simplify and strengthen its code base. Refactoring work has been done along PR [#812](https://github.com/ethereumjs/ethereumjs-monorepo/pull/812) and PR [#887](https://github.com/ethereumjs/ethereumjs-monorepo/pull/887).
#### New Constructor Params
The constructor has been reworked and new static factory methods `fromTxData`, `fromRlpSerializedTx`, and `fromValuesArray` have been added for a more `TypeScript` friendly and less error-prone way to initialize a `Transaction` object. The direct usage of the main constructor (now just being an alias to `Tx.fromTxData()`, see PR [#944](https://github.com/ethereumjs/ethereumjs-vm/pull/944)) is now discouraged and the static factory methods should be used.
The constructor has been reworked and new static factory methods `fromTxData`, `fromRlpSerializedTx`, and `fromValuesArray` have been added for a more `TypeScript` friendly and less error-prone way to initialize a `Transaction` object. The direct usage of the main constructor (now just being an alias to `Tx.fromTxData()`, see PR [#944](https://github.com/ethereumjs/ethereumjs-monorepo/pull/944)) is now discouraged and the static factory methods should be used.

@@ -149,3 +165,3 @@ **Breaking:** Note that you **need** to adopt your `Transaction` initialization code since the constructor API has changed!

If you need `Transaction` mutability - e.g. because you want to subclass `Transaction` and modifiy its behavior - there is a `freeze` option to prevent the `Object.freeze()` call on initialization, see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941).
If you need `Transaction` mutability - e.g. because you want to subclass `Transaction` and modifiy its behavior - there is a `freeze` option to prevent the `Object.freeze()` call on initialization, see PR [#941](https://github.com/ethereumjs/ethereumjs-monorepo/pull/941).

@@ -166,11 +182,11 @@ #### from

**Breaking:** The default HF on the library has been updated from `petersburg` to `istanbul`, see PR [#906](https://github.com/ethereumjs/ethereumjs-vm/pull/906).
**Breaking:** The default HF on the library has been updated from `petersburg` to `istanbul`, see PR [#906](https://github.com/ethereumjs/ethereumjs-monorepo/pull/906).
The HF setting is now automatically taken from the HF set for `Common.DEAULT_HARDFORK`, see PR [#863](https://github.com/ethereumjs/ethereumjs-vm/pull/863).
The HF setting is now automatically taken from the HF set for `Common.DEAULT_HARDFORK`, see PR [#863](https://github.com/ethereumjs/ethereumjs-monorepo/pull/863).
### Dual ES5 and ES2017 Builds
We significantly updated our internal tool and CI setup along the work on PR [#913](https://github.com/ethereumjs/ethereumjs-vm/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup.
We significantly updated our internal tool and CI setup along the work on PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint` for code linting and formatting and the introduction of a new build setup.
Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce a separate `ES5` build distributed along using the `browser` directive as an entrypoint, see PR [#921](https://github.com/ethereumjs/ethereumjs-vm/pull/921). This will result in performance benefits for Node.js consumers, see [here](https://github.com/ethereumjs/merkle-patricia-tree/pull/117) for a releated discussion.
Packages now target `ES2017` for Node.js builds (the `main` entrypoint from `package.json`) and introduce a separate `ES5` build distributed along using the `browser` directive as an entrypoint, see PR [#921](https://github.com/ethereumjs/ethereumjs-monorepo/pull/921). This will result in performance benefits for Node.js consumers, see [here](https://github.com/ethereumjs/merkle-patricia-tree/pull/117) for a releated discussion.

@@ -181,18 +197,18 @@ ### Other Changes

- Updated `ethereumjs-util` to v7, PR [#748](https://github.com/ethereumjs/ethereumjs-vm/pull/748)
- Replaced `new Buffer()` (deprecated) statements with `Buffer.from()`, PR [#721](https://github.com/ethereumjs/ethereumjs-vm/pull/721)
- Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-vm/pull/953)
- Updated `ethereumjs-util` to v7, PR [#748](https://github.com/ethereumjs/ethereumjs-monorepo/pull/748)
- Replaced `new Buffer()` (deprecated) statements with `Buffer.from()`, PR [#721](https://github.com/ethereumjs/ethereumjs-monorepo/pull/721)
- Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-monorepo/pull/953)
## 3.0.0-rc.1 - 2020-11-19
This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version.
This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version.
- Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-vm/pull/953)
- Dropped `ethereumjs-testing` dev dependency, PR [#953](https://github.com/ethereumjs/ethereumjs-monorepo/pull/953)
## 3.0.0-beta.2 - 2020-11-12
This is the second beta release towards a final library release, see [beta.1 release notes](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.1) for an overview on the full changes since the last publicly released version.
This is the second beta release towards a final library release, see [beta.1 release notes](https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Ftx%403.0.0-beta.1) for an overview on the full changes since the last publicly released version.
- Added `freeze` option to allow for transaction freeze deactivation (e.g. to allow for subclassing tx and adding additional parameters), see PR [#941](https://github.com/ethereumjs/ethereumjs-vm/pull/941)
- **Breaking:** Reworked constructor to take in data as a `TxData` typed dictionary instead of single values, the `Tx.fromTxData()` factory method becomes an alias for the constructor with this change, see PR [#944](https://github.com/ethereumjs/ethereumjs-vm/pull/944)
- Added `freeze` option to allow for transaction freeze deactivation (e.g. to allow for subclassing tx and adding additional parameters), see PR [#941](https://github.com/ethereumjs/ethereumjs-monorepo/pull/941)
- **Breaking:** Reworked constructor to take in data as a `TxData` typed dictionary instead of single values, the `Tx.fromTxData()` factory method becomes an alias for the constructor with this change, see PR [#944](https://github.com/ethereumjs/ethereumjs-monorepo/pull/944)

@@ -215,3 +231,3 @@ ## 3.0.0-beta.1 - 2020-10-22

This release is a major refactoring of the transaction library to simplify and strengthen its code base. Refactoring work has been done along PR [#812](https://github.com/ethereumjs/ethereumjs-vm/pull/812) and PR [#887](https://github.com/ethereumjs/ethereumjs-vm/pull/887).
This release is a major refactoring of the transaction library to simplify and strengthen its code base. Refactoring work has been done along PR [#812](https://github.com/ethereumjs/ethereumjs-monorepo/pull/812) and PR [#887](https://github.com/ethereumjs/ethereumjs-monorepo/pull/887).

@@ -280,5 +296,5 @@ #### New Constructor Params

**Breaking:** The default HF on the library has been updated from `petersburg` to `istanbul`, see PR [#906](https://github.com/ethereumjs/ethereumjs-vm/pull/906).
**Breaking:** The default HF on the library has been updated from `petersburg` to `istanbul`, see PR [#906](https://github.com/ethereumjs/ethereumjs-monorepo/pull/906).
The HF setting is now automatically taken from the HF set for `Common.DEAULT_HARDFORK`,
see PR [#863](https://github.com/ethereumjs/ethereumjs-vm/pull/863).
see PR [#863](https://github.com/ethereumjs/ethereumjs-monorepo/pull/863).

@@ -288,3 +304,3 @@ ### Dual ES5 and ES2017 Builds

We significantly updated our internal tool and CI setup along the work on
PR [#913](https://github.com/ethereumjs/ethereumjs-vm/pull/913) with an update to `ESLint` from `TSLint`
PR [#913](https://github.com/ethereumjs/ethereumjs-monorepo/pull/913) with an update to `ESLint` from `TSLint`
for code linting and formatting and the introduction of a new build setup.

@@ -294,3 +310,3 @@

a separate `ES5` build distributed along using the `browser` directive as an entrypoint, see
PR [#921](https://github.com/ethereumjs/ethereumjs-vm/pull/921). This will result
PR [#921](https://github.com/ethereumjs/ethereumjs-monorepo/pull/921). This will result
in performance benefits for Node.js consumers, see [here](https://github.com/ethereumjs/merkle-patricia-tree/pull/117) for a releated discussion.

@@ -303,5 +319,5 @@

- Updated `ethereumjs-util` to v7,
PR [#748](https://github.com/ethereumjs/ethereumjs-vm/pull/748)
PR [#748](https://github.com/ethereumjs/ethereumjs-monorepo/pull/748)
- Replaced `new Buffer()` (deprecated) statements with `Buffer.from()`,
PR [#721](https://github.com/ethereumjs/ethereumjs-vm/pull/721)
PR [#721](https://github.com/ethereumjs/ethereumjs-monorepo/pull/721)

@@ -313,3 +329,3 @@ ## [2.1.2] - 2019-12-19

[2.1.2]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%402.1.1...%40ethereumjs%2Ftx%402.1.2
[2.1.2]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%402.1.1...%40ethereumjs%2Ftx%402.1.2

@@ -322,3 +338,3 @@ ## [2.1.1] - 2019-08-30

[2.1.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%402.1.0...%40ethereumjs%2Ftx%402.1.1
[2.1.1]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%402.1.0...%40ethereumjs%2Ftx%402.1.1

@@ -346,3 +362,3 @@ ## [2.1.0] - 2019-06-28

[2.1.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%402.0.0...%40ethereumjs%2Ftx%402.1.0
[2.1.0]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%402.0.0...%40ethereumjs%2Ftx%402.1.0

@@ -409,3 +425,3 @@ ## [2.0.0] - 2019-06-03

[2.0.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.7...%40ethereumjs%2Ftx%402.0.0
[2.0.0]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.7...%40ethereumjs%2Ftx%402.0.0

@@ -416,3 +432,3 @@ ## [1.3.7] - 2018-07-25

[1.3.7]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.6...%40ethereumjs%2Ftx%401.3.7
[1.3.7]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.6...%40ethereumjs%2Ftx%401.3.7

@@ -424,3 +440,3 @@ ## [1.3.6] - 2018-07-02

[1.3.6]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.5...%40ethereumjs%2Ftx%401.3.6
[1.3.6]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.5...%40ethereumjs%2Ftx%401.3.6

@@ -432,3 +448,3 @@ ## [1.3.5] - 2018-06-22

[1.3.5]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.4...%40ethereumjs%2Ftx%401.3.5
[1.3.5]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.4...%40ethereumjs%2Ftx%401.3.5

@@ -441,3 +457,3 @@ ## [1.3.4] - 2018-03-06

[1.3.4]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.3...%40ethereumjs%2Ftx%401.3.4
[1.3.4]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.3...%40ethereumjs%2Ftx%401.3.4

@@ -450,3 +466,3 @@ ## [1.3.3] - 2017-07-12

[1.3.3]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.1...%40ethereumjs%2Ftx%401.3.3
[1.3.3]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.1...%40ethereumjs%2Ftx%401.3.3

@@ -457,3 +473,3 @@ ## [1.3.1] - 2017-05-13

[1.3.1]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.3.0...%40ethereumjs%2Ftx%401.3.1
[1.3.1]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.3.0...%40ethereumjs%2Ftx%401.3.1

@@ -467,3 +483,3 @@ ## [1.3.0] - 2017-04-24

[1.3.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.2.3...%40ethereumjs%2Ftx%401.3.0
[1.3.0]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.2.3...%40ethereumjs%2Ftx%401.3.0

@@ -475,3 +491,3 @@ ## [1.2.3] - 2017-01-30

[1.2.3]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.2.2...%40ethereumjs%2Ftx%401.2.3
[1.2.3]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.2.2...%40ethereumjs%2Ftx%401.2.3

@@ -484,3 +500,3 @@ ## [1.2.2] - 2016-12-15

[1.2.2]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.2.0...%40ethereumjs%2Ftx%401.2.2
[1.2.2]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.2.0...%40ethereumjs%2Ftx%401.2.2

@@ -494,12 +510,12 @@ ## [1.2.0] - 2016-12-14

[1.2.0]: https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.1.4...%40ethereumjs%2Ftx%401.2.0
[1.2.0]: https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.1.4...%40ethereumjs%2Ftx%401.2.0
## Older releases:
- [1.1.4](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.1.3...%40ethereumjs%2Ftx%401.1.4) - 2016-11-17
- [1.1.3](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.1.2...%40ethereumjs%2Ftx%401.1.3) - 2016-11-10
- [1.1.2](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.1.1...%40ethereumjs%2Ftx%401.1.2) - 2016-07-17
- [1.1.1](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.1.0...%40ethereumjs%2Ftx%401.1.1) - 2016-03-05
- [1.1.0](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.0.1...%40ethereumjs%2Ftx%401.1.0) - 2016-03-03
- [1.0.1](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%401.0.0...%40ethereumjs%2Ftx%401.0.1) - 2016-03-03
- [1.0.0](https://github.com/ethereumjs/ethereumjs-vm/compare/%40ethereumjs%2Ftx%400.7.3...%40ethereumjs%2Ftx%401.0.0) - 2016-02-11
- [1.1.4](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.1.3...%40ethereumjs%2Ftx%401.1.4) - 2016-11-17
- [1.1.3](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.1.2...%40ethereumjs%2Ftx%401.1.3) - 2016-11-10
- [1.1.2](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.1.1...%40ethereumjs%2Ftx%401.1.2) - 2016-07-17
- [1.1.1](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.1.0...%40ethereumjs%2Ftx%401.1.1) - 2016-03-05
- [1.1.0](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.0.1...%40ethereumjs%2Ftx%401.1.0) - 2016-03-03
- [1.0.1](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%401.0.0...%40ethereumjs%2Ftx%401.0.1) - 2016-03-03
- [1.0.0](https://github.com/ethereumjs/ethereumjs-monorepo/compare/%40ethereumjs%2Ftx%400.7.3...%40ethereumjs%2Ftx%401.0.0) - 2016-02-11

@@ -5,3 +5,3 @@ /// <reference types="bn.js" />

import { Address, BN } from 'ethereumjs-util';
import { TxData, TxOptions, JsonTx, AccessListEIP2930ValuesArray } from './types';
import { TxData, TxOptions, JsonTx, AccessListEIP2930ValuesArray, AccessListEIP2930TxData } from './types';
/**

@@ -15,2 +15,3 @@ * This base class will likely be subject to further

export declare abstract class BaseTransaction<TransactionObject> {
private readonly _type;
readonly nonce: BN;

@@ -26,8 +27,12 @@ readonly gasLimit: BN;

readonly s?: BN;
constructor(txData: TxData, txOptions?: TxOptions);
constructor(txData: TxData | AccessListEIP2930TxData, txOptions?: TxOptions);
/**
* Checks if the transaction has the minimum amount of gas required
* (DataFee + TxFee + Creation Fee).
* Returns the transaction type
*/
get transactionType(): number;
/**
* Alias for `transactionType`
*/
get type(): number;
/**
* Checks if the transaction has the minimum amount of gas required

@@ -34,0 +39,0 @@ * (DataFee + TxFee + Creation Fee).

@@ -48,11 +48,22 @@ "use strict";

var nonce = txData.nonce, gasLimit = txData.gasLimit, gasPrice = txData.gasPrice, to = txData.to, value = txData.value, data = txData.data, v = txData.v, r = txData.r, s = txData.s;
this.nonce = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(nonce));
this.gasPrice = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasPrice));
this.gasLimit = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasLimit));
this.to = to ? new ethereumjs_util_1.Address(ethereumjs_util_1.toBuffer(to)) : undefined;
this.value = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(value));
this.data = ethereumjs_util_1.toBuffer(data);
this.v = v ? new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(v)) : undefined;
this.r = r ? new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(r)) : undefined;
this.s = s ? new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(s)) : undefined;
var type = txData.type;
if (type !== undefined) {
this._type = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(type)).toNumber();
}
else {
this._type = 0;
}
var toB = ethereumjs_util_1.toBuffer(to === '' ? '0x' : to);
var vB = ethereumjs_util_1.toBuffer(v === '' ? '0x' : v);
var rB = ethereumjs_util_1.toBuffer(r === '' ? '0x' : r);
var sB = ethereumjs_util_1.toBuffer(s === '' ? '0x' : s);
this.nonce = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(nonce === '' ? '0x' : nonce));
this.gasPrice = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasPrice === '' ? '0x' : gasPrice));
this.gasLimit = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasLimit === '' ? '0x' : gasLimit));
this.to = toB.length > 0 ? new ethereumjs_util_1.Address(toB) : undefined;
this.value = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(value === '' ? '0x' : value));
this.data = ethereumjs_util_1.toBuffer(data === '' ? '0x' : data);
this.v = vB.length > 0 ? new ethereumjs_util_1.BN(vB) : undefined;
this.r = rB.length > 0 ? new ethereumjs_util_1.BN(rB) : undefined;
this.s = sB.length > 0 ? new ethereumjs_util_1.BN(sB) : undefined;
this._validateCannotExceedMaxInteger({

@@ -66,2 +77,22 @@ nonce: this.nonce,

}
Object.defineProperty(BaseTransaction.prototype, "transactionType", {
/**
* Returns the transaction type
*/
get: function () {
return this._type;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseTransaction.prototype, "type", {
/**
* Alias for `transactionType`
*/
get: function () {
return this.transactionType;
},
enumerable: false,
configurable: true
});
BaseTransaction.prototype.validate = function (stringError) {

@@ -68,0 +99,0 @@ if (stringError === void 0) { stringError = false; }

@@ -16,5 +16,13 @@ /// <reference types="bn.js" />

readonly AccessListJSON: AccessList;
get transactionType(): number;
/**
* EIP-2930 alias for `r`
*/
get senderR(): BN | undefined;
/**
* EIP-2930 alias for `s`
*/
get senderS(): BN | undefined;
get senderR(): BN | undefined;
/**
* EIP-2930 alias for `v`
*/
get yParity(): BN | undefined;

@@ -21,0 +29,0 @@ /**

@@ -15,2 +15,13 @@ "use strict";

})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {

@@ -37,3 +48,2 @@ var m = typeof Symbol === "function" && o[Symbol.iterator];

var emptyAccessList = [];
var emptyBuffer = Buffer.from([]);
/**

@@ -59,3 +69,3 @@ * Typed transaction with optional access lists

var chainId = txData.chainId, accessList = txData.accessList;
_this = _super.call(this, txData, opts) || this;
_this = _super.call(this, __assign(__assign({}, txData), { type: 1 }), opts) || this;
// EIP-2718 check is done in Common

@@ -134,5 +144,8 @@ if (!_this.common.isActivatedEIP(2930)) {

}
Object.defineProperty(AccessListEIP2930Transaction.prototype, "transactionType", {
Object.defineProperty(AccessListEIP2930Transaction.prototype, "senderR", {
/**
* EIP-2930 alias for `r`
*/
get: function () {
return 1;
return this.r;
},

@@ -143,3 +156,5 @@ enumerable: false,

Object.defineProperty(AccessListEIP2930Transaction.prototype, "senderS", {
// EIP-2930 alias for `s`
/**
* EIP-2930 alias for `s`
*/
get: function () {

@@ -151,12 +166,6 @@ return this.s;

});
Object.defineProperty(AccessListEIP2930Transaction.prototype, "senderR", {
// EIP-2930 alias for `r`
get: function () {
return this.r;
},
enumerable: false,
configurable: true
});
Object.defineProperty(AccessListEIP2930Transaction.prototype, "yParity", {
// EIP-2930 alias for `v`
/**
* EIP-2930 alias for `v`
*/
get: function () {

@@ -218,12 +227,12 @@ return this.v;

chainId: new ethereumjs_util_1.BN(chainId),
nonce: new ethereumjs_util_1.BN(nonce),
gasPrice: new ethereumjs_util_1.BN(gasPrice),
gasLimit: new ethereumjs_util_1.BN(gasLimit),
to: to && to.length > 0 ? new ethereumjs_util_1.Address(to) : undefined,
value: new ethereumjs_util_1.BN(value),
data: data !== null && data !== void 0 ? data : emptyBuffer,
nonce: nonce,
gasPrice: gasPrice,
gasLimit: gasLimit,
to: to,
value: value,
data: data,
accessList: accessList !== null && accessList !== void 0 ? accessList : emptyAccessList,
v: v !== undefined ? new ethereumjs_util_1.BN(v) : undefined,
r: r !== undefined && !r.equals(emptyBuffer) ? new ethereumjs_util_1.BN(r) : undefined,
s: s !== undefined && !s.equals(emptyBuffer) ? new ethereumjs_util_1.BN(s) : undefined,
r: r,
s: s,
}, opts);

@@ -230,0 +239,0 @@ };

@@ -8,3 +8,2 @@ /// <reference types="node" />

export default class Transaction extends BaseTransaction<Transaction> {
get transactionType(): number;
/**

@@ -11,0 +10,0 @@ * Instantiate a transaction from a data dictionary

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

}
Object.defineProperty(Transaction.prototype, "transactionType", {
get: function () {
return 0;
},
enumerable: false,
configurable: true
});
/**

@@ -110,13 +103,12 @@ * Instantiate a transaction from a data dictionary

var _a = __read(values, 9), nonce = _a[0], gasPrice = _a[1], gasLimit = _a[2], to = _a[3], value = _a[4], data = _a[5], v = _a[6], r = _a[7], s = _a[8];
var emptyBuffer = Buffer.from([]);
return new Transaction({
nonce: new ethereumjs_util_1.BN(nonce),
gasPrice: new ethereumjs_util_1.BN(gasPrice),
gasLimit: new ethereumjs_util_1.BN(gasLimit),
to: to && to.length > 0 ? new ethereumjs_util_1.Address(to) : undefined,
value: new ethereumjs_util_1.BN(value),
data: data !== null && data !== void 0 ? data : emptyBuffer,
v: v !== undefined && !v.equals(emptyBuffer) ? new ethereumjs_util_1.BN(v) : undefined,
r: r !== undefined && !r.equals(emptyBuffer) ? new ethereumjs_util_1.BN(r) : undefined,
s: s !== undefined && !s.equals(emptyBuffer) ? new ethereumjs_util_1.BN(s) : undefined,
nonce: nonce,
gasPrice: gasPrice,
gasLimit: gasLimit,
to: to,
value: value,
data: data,
v: v,
r: r,
s: s,
}, opts);

@@ -123,0 +115,0 @@ };

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

else {
var txType = new ethereumjs_util_1.BN(txData.type).toNumber();
var txType = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(txData.type)).toNumber();
return TransactionFactory.getTransactionClass(txType, common).fromTxData(txData, txOptions);

@@ -33,0 +33,0 @@ }

@@ -5,3 +5,3 @@ /// <reference types="bn.js" />

import { Address, BN } from 'ethereumjs-util';
import { TxData, TxOptions, JsonTx, AccessListEIP2930ValuesArray } from './types';
import { TxData, TxOptions, JsonTx, AccessListEIP2930ValuesArray, AccessListEIP2930TxData } from './types';
/**

@@ -15,2 +15,3 @@ * This base class will likely be subject to further

export declare abstract class BaseTransaction<TransactionObject> {
private readonly _type;
readonly nonce: BN;

@@ -26,8 +27,12 @@ readonly gasLimit: BN;

readonly s?: BN;
constructor(txData: TxData, txOptions?: TxOptions);
constructor(txData: TxData | AccessListEIP2930TxData, txOptions?: TxOptions);
/**
* Checks if the transaction has the minimum amount of gas required
* (DataFee + TxFee + Creation Fee).
* Returns the transaction type
*/
get transactionType(): number;
/**
* Alias for `transactionType`
*/
get type(): number;
/**
* Checks if the transaction has the minimum amount of gas required

@@ -34,0 +39,0 @@ * (DataFee + TxFee + Creation Fee).

@@ -20,11 +20,22 @@ "use strict";

const { nonce, gasLimit, gasPrice, to, value, data, v, r, s } = txData;
this.nonce = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(nonce));
this.gasPrice = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasPrice));
this.gasLimit = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasLimit));
this.to = to ? new ethereumjs_util_1.Address(ethereumjs_util_1.toBuffer(to)) : undefined;
this.value = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(value));
this.data = ethereumjs_util_1.toBuffer(data);
this.v = v ? new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(v)) : undefined;
this.r = r ? new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(r)) : undefined;
this.s = s ? new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(s)) : undefined;
const type = txData.type;
if (type !== undefined) {
this._type = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(type)).toNumber();
}
else {
this._type = 0;
}
const toB = ethereumjs_util_1.toBuffer(to === '' ? '0x' : to);
const vB = ethereumjs_util_1.toBuffer(v === '' ? '0x' : v);
const rB = ethereumjs_util_1.toBuffer(r === '' ? '0x' : r);
const sB = ethereumjs_util_1.toBuffer(s === '' ? '0x' : s);
this.nonce = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(nonce === '' ? '0x' : nonce));
this.gasPrice = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasPrice === '' ? '0x' : gasPrice));
this.gasLimit = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(gasLimit === '' ? '0x' : gasLimit));
this.to = toB.length > 0 ? new ethereumjs_util_1.Address(toB) : undefined;
this.value = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(value === '' ? '0x' : value));
this.data = ethereumjs_util_1.toBuffer(data === '' ? '0x' : data);
this.v = vB.length > 0 ? new ethereumjs_util_1.BN(vB) : undefined;
this.r = rB.length > 0 ? new ethereumjs_util_1.BN(rB) : undefined;
this.s = sB.length > 0 ? new ethereumjs_util_1.BN(sB) : undefined;
this._validateCannotExceedMaxInteger({

@@ -38,2 +49,14 @@ nonce: this.nonce,

}
/**
* Returns the transaction type
*/
get transactionType() {
return this._type;
}
/**
* Alias for `transactionType`
*/
get type() {
return this.transactionType;
}
validate(stringError = false) {

@@ -40,0 +63,0 @@ const errors = [];

@@ -16,5 +16,13 @@ /// <reference types="bn.js" />

readonly AccessListJSON: AccessList;
get transactionType(): number;
/**
* EIP-2930 alias for `r`
*/
get senderR(): BN | undefined;
/**
* EIP-2930 alias for `s`
*/
get senderS(): BN | undefined;
get senderR(): BN | undefined;
/**
* EIP-2930 alias for `v`
*/
get yParity(): BN | undefined;

@@ -21,0 +29,0 @@ /**

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

const emptyAccessList = [];
const emptyBuffer = Buffer.from([]);
/**

@@ -26,3 +25,3 @@ * Typed transaction with optional access lists

const { chainId, accessList } = txData;
super(txData, opts);
super(Object.assign(Object.assign({}, txData), { type: 1 }), opts);
// EIP-2718 check is done in Common

@@ -100,14 +99,17 @@ if (!this.common.isActivatedEIP(2930)) {

}
get transactionType() {
return 1;
/**
* EIP-2930 alias for `r`
*/
get senderR() {
return this.r;
}
// EIP-2930 alias for `s`
/**
* EIP-2930 alias for `s`
*/
get senderS() {
return this.s;
}
// EIP-2930 alias for `r`
get senderR() {
return this.r;
}
// EIP-2930 alias for `v`
/**
* EIP-2930 alias for `v`
*/
get yParity() {

@@ -162,12 +164,12 @@ return this.v;

chainId: new ethereumjs_util_1.BN(chainId),
nonce: new ethereumjs_util_1.BN(nonce),
gasPrice: new ethereumjs_util_1.BN(gasPrice),
gasLimit: new ethereumjs_util_1.BN(gasLimit),
to: to && to.length > 0 ? new ethereumjs_util_1.Address(to) : undefined,
value: new ethereumjs_util_1.BN(value),
data: data !== null && data !== void 0 ? data : emptyBuffer,
nonce,
gasPrice,
gasLimit,
to,
value,
data,
accessList: accessList !== null && accessList !== void 0 ? accessList : emptyAccessList,
v: v !== undefined ? new ethereumjs_util_1.BN(v) : undefined,
r: r !== undefined && !r.equals(emptyBuffer) ? new ethereumjs_util_1.BN(r) : undefined,
s: s !== undefined && !s.equals(emptyBuffer) ? new ethereumjs_util_1.BN(s) : undefined,
r,
s,
}, opts);

@@ -174,0 +176,0 @@ }

@@ -8,3 +8,2 @@ /// <reference types="node" />

export default class Transaction extends BaseTransaction<Transaction> {
get transactionType(): number;
/**

@@ -11,0 +10,0 @@ * Instantiate a transaction from a data dictionary

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

class Transaction extends baseTransaction_1.BaseTransaction {
get transactionType() {
return 0;
}
/**

@@ -53,13 +50,12 @@ * Instantiate a transaction from a data dictionary

const [nonce, gasPrice, gasLimit, to, value, data, v, r, s] = values;
const emptyBuffer = Buffer.from([]);
return new Transaction({
nonce: new ethereumjs_util_1.BN(nonce),
gasPrice: new ethereumjs_util_1.BN(gasPrice),
gasLimit: new ethereumjs_util_1.BN(gasLimit),
to: to && to.length > 0 ? new ethereumjs_util_1.Address(to) : undefined,
value: new ethereumjs_util_1.BN(value),
data: data !== null && data !== void 0 ? data : emptyBuffer,
v: v !== undefined && !v.equals(emptyBuffer) ? new ethereumjs_util_1.BN(v) : undefined,
r: r !== undefined && !r.equals(emptyBuffer) ? new ethereumjs_util_1.BN(r) : undefined,
s: s !== undefined && !s.equals(emptyBuffer) ? new ethereumjs_util_1.BN(s) : undefined,
nonce,
gasPrice,
gasLimit,
to,
value,
data,
v,
r,
s,
}, opts);

@@ -66,0 +62,0 @@ }

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

else {
const txType = new ethereumjs_util_1.BN(txData.type).toNumber();
const txType = new ethereumjs_util_1.BN(ethereumjs_util_1.toBuffer(txData.type)).toNumber();
return TransactionFactory.getTransactionClass(txType, common).fromTxData(txData, txOptions);

@@ -31,0 +31,0 @@ }

{
"name": "@ethereumjs/tx",
"version": "3.1.2",
"version": "3.1.3",
"description": "A simple module for creating, manipulating and signing Ethereum transactions",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MPL-2.0",
"author": "mjbecze <mb@ethdev.com>",
"keywords": [
"ethereum",
"transactions"
],
"files": [

@@ -11,2 +15,4 @@ "dist",

],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"browser": "dist.browser/index.js",

@@ -29,8 +35,2 @@ "scripts": {

},
"keywords": [
"ethereum",
"transactions"
],
"author": "mjbecze <mb@ethdev.com>",
"license": "MPL-2.0",
"dependencies": {

@@ -53,6 +53,6 @@ "@ethereumjs/common": "^2.2.0",

"istanbul": "^0.4.1",
"karma": "^5.2.1",
"karma-browserify": "^7.0.0",
"karma": "^6.3.2",
"karma-browserify": "^8.0.0",
"karma-chrome-launcher": "^3.1.0",
"karma-firefox-launcher": "^1.3.0",
"karma-firefox-launcher": "^2.1.0",
"karma-tap": "^4.2.0",

@@ -66,15 +66,6 @@ "minimist": "^1.2.0",

"tslint": "^5.16.0",
"typedoc": "next",
"typedoc-plugin-markdown": "^2.2.17",
"typescript": "^3.9.3",
"typestrict": "^1.0.2"
"typedoc": "^0.20.34",
"typedoc-plugin-markdown": "^3.6.0",
"typescript": "^3.9.3"
},
"repository": {
"type": "git",
"url": "https://github.com/ethereumjs/ethereumjs-monorepo.git"
},
"bugs": {
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+tx%22"
},
"homepage": "https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#readme",
"contributors": [

@@ -90,3 +81,11 @@ {

}
]
],
"repository": {
"type": "git",
"url": "https://github.com/ethereumjs/ethereumjs-monorepo.git"
},
"homepage": "https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#readme",
"bugs": {
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+tx%22"
}
}

@@ -163,3 +163,3 @@ # @ethereumjs/tx

The `Transaction` constructor receives a parameter of an [`@ethereumjs/common`](https://github.com/ethereumjs/ethereumjs-vm/blob/master/packages/common) object that lets you specify the chain and hardfork to be used. The chain defaults to `mainnet`.
The `Transaction` constructor receives a parameter of an [`@ethereumjs/common`](https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/common) object that lets you specify the chain and hardfork to be used. The chain defaults to `mainnet`.

@@ -196,7 +196,7 @@

[tx-npm-link]: https://www.npmjs.com/package/@ethereumjs/tx
[tx-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-vm/package:%20tx?label=issues
[tx-issues-link]: https://github.com/ethereumjs/ethereumjs-vm/issues?q=is%3Aopen+is%3Aissue+label%3A"package%3A+tx"
[tx-actions-badge]: https://github.com/ethereumjs/ethereumjs-vm/workflows/Tx%20Test/badge.svg
[tx-actions-link]: https://github.com/ethereumjs/ethereumjs-vm/actions?query=workflow%3A%22Tx+Test%22
[tx-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20tx?label=issues
[tx-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A"package%3A+tx"
[tx-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/Tx%20Test/badge.svg
[tx-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22Tx+Test%22
[tx-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=tx
[tx-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx

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