Skip to content

Commit d5f5969

Browse files
committed
tx, vm: renamed LegacyTransaction -> Transaction
1 parent df5ee72 commit d5f5969

File tree

17 files changed

+105
-111
lines changed

17 files changed

+105
-111
lines changed

packages/tx/src/baseTransaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export abstract class BaseTransaction<TransactionObject> {
161161
}
162162

163163
/**
164-
* Returns the raw `Buffer[]` (LegacyTransaction) or `Buffer` (typed transaction).
164+
* Returns the raw `Buffer[]` (Transaction) or `Buffer` (typed transaction).
165165
* This is the data which is found in the transactions of the block body.
166166
*/
167167
abstract raw(): Buffer[] | Buffer

packages/tx/src/eip2930Transaction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ export default class AccessListEIP2930Transaction extends BaseTransaction<Access
273273

274274
/**
275275
* Returns the encoding of the transaction. For typed transaction, this is the raw Buffer.
276-
* In LegacyTransaction, this is a Buffer array.
276+
* In Transaction, this is a Buffer array.
277277
*/
278278
serialize(): Buffer {
279279
return <Buffer>this.raw()

packages/tx/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { default as LegacyTransaction } from './legacyTransaction'
1+
export { default as Transaction } from './legacyTransaction'
22
export { default as AccessListEIP2930Transaction } from './eip2930Transaction'
33
export { default as TransactionFactory } from './transactionFactory'
44
export * from './types'

packages/tx/src/legacyTransaction.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const N_DIV_2 = new BN('7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46
2121
/**
2222
* An Ethereum transaction.
2323
*/
24-
export default class LegacyTransaction extends BaseTransaction<LegacyTransaction> {
24+
export default class Transaction extends BaseTransaction<Transaction> {
2525
public readonly v?: BN
2626
public readonly r?: BN
2727
public readonly s?: BN
@@ -31,7 +31,7 @@ export default class LegacyTransaction extends BaseTransaction<LegacyTransaction
3131
}
3232

3333
public static fromTxData(txData: TxData, opts: TxOptions = {}) {
34-
return new LegacyTransaction(txData, opts)
34+
return new Transaction(txData, opts)
3535
}
3636

3737
public static fromRlpSerializedTx(serialized: Buffer, opts: TxOptions = {}) {
@@ -46,7 +46,7 @@ export default class LegacyTransaction extends BaseTransaction<LegacyTransaction
4646

4747
// alias of fromRlpSerializedTx
4848
public static fromSerializedTx(serialized: Buffer, opts: TxOptions = {}) {
49-
return LegacyTransaction.fromRlpSerializedTx(serialized, opts)
49+
return Transaction.fromRlpSerializedTx(serialized, opts)
5050
}
5151

5252
public static fromValuesArray(values: Buffer[], opts: TxOptions = {}) {
@@ -63,7 +63,7 @@ export default class LegacyTransaction extends BaseTransaction<LegacyTransaction
6363

6464
const emptyBuffer = Buffer.from([])
6565

66-
return new LegacyTransaction(
66+
return new Transaction(
6767
{
6868
nonce: new BN(nonce),
6969
gasPrice: new BN(gasPrice),
@@ -209,7 +209,7 @@ export default class LegacyTransaction extends BaseTransaction<LegacyTransaction
209209
common: this.common,
210210
}
211211

212-
return LegacyTransaction.fromTxData(
212+
return Transaction.fromTxData(
213213
{
214214
nonce: this.nonce,
215215
gasPrice: this.gasPrice,

packages/tx/src/transactionFactory.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Common from '@ethereumjs/common'
2-
import { default as LegacyTransaction } from './legacyTransaction'
2+
import { default as Transaction } from './legacyTransaction'
33
import { default as AccessListEIP2930Transaction } from './eip2930Transaction'
44
import { TxOptions, Transaction, TxData } from './types'
55
import { BN } from 'ethereumjs-util'
@@ -12,14 +12,14 @@ export default class TransactionFactory {
1212

1313
/**
1414
* Create a transaction from a `txData` object
15-
* @param txData - The transaction data. The `type` field will determine which transaction type is returned (if undefined, create a LegacyTransaction)
15+
* @param txData - The transaction data. The `type` field will determine which transaction type is returned (if undefined, create a Transaction)
1616
* @param txOptions - Options to pass on to the constructor of the transaction
1717
*/
1818
public static fromTxData(txData: TxData, txOptions: TxOptions = {}): Transaction {
1919
const common = txOptions.common ?? DEFAULT_COMMON
2020
if (txData.type === undefined) {
21-
// Assume LegacyTransaction
22-
return LegacyTransaction.fromTxData(txData, txOptions)
21+
// Assume Transaction
22+
return Transaction.fromTxData(txData, txOptions)
2323
} else {
2424
const txType = new BN(txData.type).toNumber()
2525
return TransactionFactory.getTransactionClass(txType, common).fromTxData(txData, txOptions)
@@ -57,14 +57,14 @@ export default class TransactionFactory {
5757

5858
return AccessListEIP2930Transaction.fromRlpSerializedTx(rawData, txOptions)
5959
} else {
60-
return LegacyTransaction.fromRlpSerializedTx(rawData, txOptions)
60+
return Transaction.fromRlpSerializedTx(rawData, txOptions)
6161
}
6262
}
6363

6464
/**
6565
* When decoding a BlockBody, in the transactions field, a field is either:
6666
* A Buffer (a TypedTransaction - encoded as TransactionType || rlp(TransactionPayload))
67-
* A Buffer[] (LegacyTransaction)
67+
* A Buffer[] (Transaction)
6868
* This method returns the right transaction.
6969
* @param rawData - Either a Buffer or a Buffer[]
7070
* @param txOptions - The transaction options
@@ -73,16 +73,16 @@ export default class TransactionFactory {
7373
if (Buffer.isBuffer(rawData)) {
7474
return this.fromRawData(rawData, txOptions)
7575
} else if (Array.isArray(rawData)) {
76-
// It is a LegacyTransaction
77-
return LegacyTransaction.fromValuesArray(rawData, txOptions)
76+
// It is a Transaction
77+
return Transaction.fromValuesArray(rawData, txOptions)
7878
} else {
7979
throw new Error('Cannot decode transaction: unknown type input')
8080
}
8181
}
8282

8383
/**
8484
* This helper method allows one to retrieve the class which matches the transactionID
85-
* If transactionID is undefined, return the LegacyTransaction class.
85+
* If transactionID is undefined, return the Transaction class.
8686
* @param transactionID
8787
* @param common
8888
*/
@@ -97,7 +97,7 @@ export default class TransactionFactory {
9797
const legacyTxn = transactionID == 0 || (transactionID >= 0x80 && transactionID <= 0xff)
9898

9999
if (legacyTxn) {
100-
return LegacyTransaction
100+
return Transaction
101101
}
102102

103103
switch (transactionID) {

packages/tx/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AddressLike, BNLike, BufferLike } from 'ethereumjs-util'
22
import Common from '@ethereumjs/common'
3-
import { default as LegacyTransaction } from './legacyTransaction'
3+
import { default as Transaction } from './legacyTransaction'
44
import { default as AccessListEIP2930Transaction } from './eip2930Transaction'
55

66
/**
@@ -131,7 +131,7 @@ export interface TxData {
131131
type?: BNLike
132132
}
133133

134-
export type Transaction = LegacyTransaction | AccessListEIP2930Transaction
134+
export type Transaction = Transaction | AccessListEIP2930Transaction
135135

136136
export type BaseTransactionData = {
137137
/**

packages/tx/test/base.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import tape from 'tape'
22
import Common from '@ethereumjs/common'
3-
import { LegacyTransaction, AccessListEIP2930Transaction } from '../src'
3+
import { Transaction, AccessListEIP2930Transaction } from '../src'
44
import { TxsJsonEntry } from './types'
55
import { BaseTransaction } from '../src/baseTransaction'
66
import { privateToPublic } from 'ethereumjs-util'
77

88
tape('[BaseTransaction]', function (t) {
99
const legacyFixtures: TxsJsonEntry[] = require('./json/txs.json')
10-
const legacyTxs: BaseTransaction<LegacyTransaction>[] = []
10+
const legacyTxs: BaseTransaction<Transaction>[] = []
1111
legacyFixtures.slice(0, 4).forEach(function (tx: any) {
12-
legacyTxs.push(LegacyTransaction.fromTxData(tx.data))
12+
legacyTxs.push(Transaction.fromTxData(tx.data))
1313
})
1414

1515
const eip2930Fixtures = require('./json/eip2930txs.json')
@@ -21,8 +21,8 @@ tape('[BaseTransaction]', function (t) {
2121
const zero = Buffer.alloc(0)
2222
const txTypes = [
2323
{
24-
class: LegacyTransaction,
25-
name: 'LegacyTransaction',
24+
class: Transaction,
25+
name: 'Transaction',
2626
values: Array(6).fill(zero),
2727
txs: legacyTxs,
2828
fixtures: legacyFixtures,

0 commit comments

Comments
 (0)