Skip to content

Commit 89117cf

Browse files
ScottyPoiholgerd77
andauthored
TX: tx factory renaming (#3667)
* TX: rename to createTx * TX: rename createTxFromRLP * fix lint errors * Fix t8ntool createTxFromTxData -> createTx --------- Co-authored-by: Holger Drewes <[email protected]>
1 parent b763c47 commit 89117cf

38 files changed

+119
-119
lines changed

packages/block/examples/1559.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createBlock } from '@ethereumjs/block'
22
import { Common, Hardfork, Mainnet } from '@ethereumjs/common'
3-
import { createTxFromTxData } from '@ethereumjs/tx'
3+
import { createTx } from '@ethereumjs/tx'
44
const common = new Common({ chain: Mainnet, hardfork: Hardfork.London })
55

66
const block = createBlock(
@@ -37,7 +37,7 @@ console.log(Number(blockWithMatchingBaseFee.header.baseFeePerGas)) // 11
3737
await blockWithMatchingBaseFee.validateData()
3838

3939
// failed validation throws error
40-
const tx = createTxFromTxData(
40+
const tx = createTx(
4141
{ type: 2, maxFeePerGas: BigInt(20) },
4242
{ common: new Common({ chain: Mainnet, hardfork: Hardfork.London }) },
4343
)

packages/block/src/block/constructors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { RLP } from '@ethereumjs/rlp'
22
import { Trie } from '@ethereumjs/trie'
33
import {
44
type TxOptions,
5+
createTx,
56
createTxFromBlockBodyData,
6-
createTxFromSerializedData,
7-
createTxFromTxData,
7+
createTxFromRLP,
88
normalizeTxParams,
99
} from '@ethereumjs/tx'
1010
import {
@@ -77,7 +77,7 @@ export function createBlock(blockData: BlockData = {}, opts?: BlockOptions) {
7777
// parse transactions
7878
const transactions = []
7979
for (const txData of txsData ?? []) {
80-
const tx = createTxFromTxData(txData, {
80+
const tx = createTx(txData, {
8181
...opts,
8282
// Use header common in case of setHardfork being activated
8383
common: header.common,
@@ -288,7 +288,7 @@ export function createBlockFromRPC(
288288
const opts = { common: header.common }
289289
for (const _txParams of blockParams.transactions ?? []) {
290290
const txParams = normalizeTxParams(_txParams)
291-
const tx = createTxFromTxData(txParams, opts)
291+
const tx = createTx(txParams, opts)
292292
transactions.push(tx)
293293
}
294294

@@ -391,7 +391,7 @@ export async function createBlockFromExecutionPayload(
391391
const txs = []
392392
for (const [index, serializedTx] of transactions.entries()) {
393393
try {
394-
const tx = createTxFromSerializedData(hexToBytes(serializedTx as PrefixedHexString), {
394+
const tx = createTxFromRLP(hexToBytes(serializedTx as PrefixedHexString), {
395395
common: opts?.common,
396396
})
397397
txs.push(tx)

packages/client/devnets/4844-interop/tools/txGenerator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Adapted from - https://github.com/Inphi/eip4844-interop/blob/master/blob_tx_generator/blob.js
22
import { createCommonFromGethGenesis, Hardfork } from '@ethereumjs/common'
3-
import { createTxFromTxData, TransactionType, TxData } from '@ethereumjs/tx'
3+
import { createTx, TransactionType, TxData } from '@ethereumjs/tx'
44
import {
55
blobsToCommitments,
66
commitmentsToVersionedHashes,
@@ -62,7 +62,7 @@ async function run(data: any) {
6262
txData.gasLimit = BigInt(28000000)
6363
const nonce = await getNonce(client, sender.toString())
6464
txData.nonce = BigInt(nonce)
65-
const blobTx = createTxFromTxData<TransactionType.BlobEIP4844>(txData, { common }).sign(pkey)
65+
const blobTx = createTx<TransactionType.BlobEIP4844>(txData, { common }).sign(pkey)
6666

6767
const serializedWrapper = blobTx.serializeNetworkWrapper()
6868

packages/client/src/net/protocol/ethprotocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Blob4844Tx,
55
createBlob4844TxFromSerializedNetworkWrapper,
66
createTxFromBlockBodyData,
7-
createTxFromSerializedData,
7+
createTxFromRLP,
88
isAccessList2930Tx,
99
isBlob4844Tx,
1010
isEOACode7702Tx,
@@ -133,7 +133,7 @@ export class EthProtocol extends Protocol {
133133
BIGINT_0, // Use chainstart,
134134
timestamp: this.chain.headers.latest?.timestamp ?? Math.floor(Date.now() / 1000),
135135
})
136-
return txs.map((txData) => createTxFromSerializedData(txData, { common }))
136+
return txs.map((txData) => createTxFromRLP(txData, { common }))
137137
},
138138
},
139139
{

packages/client/src/rpc/modules/eth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Hardfork } from '@ethereumjs/common'
33
import {
44
Capability,
55
createBlob4844TxFromSerializedNetworkWrapper,
6-
createTxFromSerializedData,
7-
createTxFromTxData,
6+
createTx,
7+
createTxFromRLP,
88
} from '@ethereumjs/tx'
99
import {
1010
BIGINT_0,
@@ -608,7 +608,7 @@ export class Eth {
608608
blockNumber: blockToRunOn.header.number,
609609
})
610610

611-
const tx = createTxFromTxData(txData, { common: vm.common, freeze: false })
611+
const tx = createTx(txData, { common: vm.common, freeze: false })
612612

613613
// set from address
614614
const from =
@@ -1181,7 +1181,7 @@ export class Eth {
11811181
)
11821182
}
11831183
} else {
1184-
tx = createTxFromSerializedData(txBuf, { common })
1184+
tx = createTxFromRLP(txBuf, { common })
11851185
}
11861186
} catch (e: any) {
11871187
throw {

packages/client/test/net/protocol/ethprotocol.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createBlock } from '@ethereumjs/block'
22
import { Common, Hardfork, Holesky } from '@ethereumjs/common'
3-
import { TransactionType, createFeeMarket1559Tx, createTxFromTxData } from '@ethereumjs/tx'
3+
import { TransactionType, createFeeMarket1559Tx, createTx } from '@ethereumjs/tx'
44
import {
55
bigIntToBytes,
66
bytesToBigInt,
@@ -226,10 +226,10 @@ describe('[EthProtocol]', () => {
226226
const chain = await Chain.create({ config })
227227
const p = new EthProtocol({ config, chain })
228228

229-
const legacyTx = createTxFromTxData({ type: 0 }, { common: config.chainCommon })
230-
const eip2929Tx = createTxFromTxData({ type: 1 }, { common: config.chainCommon })
231-
const eip1559Tx = createTxFromTxData({ type: 2 }, { common: config.chainCommon })
232-
const blobTx = createTxFromTxData(
229+
const legacyTx = createTx({ type: 0 }, { common: config.chainCommon })
230+
const eip2929Tx = createTx({ type: 1 }, { common: config.chainCommon })
231+
const eip1559Tx = createTx({ type: 2 }, { common: config.chainCommon })
232+
const blobTx = createTx(
233233
{
234234
type: 3,
235235
to: createZeroAddress(),
@@ -265,7 +265,7 @@ describe('[EthProtocol]', () => {
265265
})
266266
const chain = await Chain.create({ config })
267267
const p = new EthProtocol({ config, chain })
268-
const fakeTx = createTxFromTxData({}).sign(randomBytes(32))
268+
const fakeTx = createTx({}).sign(randomBytes(32))
269269
const fakeHash = fakeTx.hash()
270270
const encoded = p.encode(
271271
p.messages.filter((message) => message.name === 'NewPooledTransactionHashes')[0],

packages/client/test/rpc/debug/storageRangeAt.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createTxFromTxData } from '@ethereumjs/tx'
1+
import { createTx } from '@ethereumjs/tx'
22
import { bigIntToHex, bytesToBigInt, bytesToHex, hexToBytes, setLengthLeft } from '@ethereumjs/util'
33
import { buildBlock } from '@ethereumjs/vm'
44
import { keccak256 } from 'ethereum-cryptography/keccak.js'
@@ -89,7 +89,7 @@ describe(method, () => {
8989
txLookupLimit: 0,
9090
})
9191
const rpc = getRPCClient(server)
92-
const firstTx = createTxFromTxData(
92+
const firstTx = createTx(
9393
{
9494
type: 0x2,
9595
gasLimit: 10000000,
@@ -116,7 +116,7 @@ describe(method, () => {
116116

117117
const result = await blockBuilder.addTransaction(firstTx, { skipHardForkValidation: true })
118118

119-
const secondTx = createTxFromTxData(
119+
const secondTx = createTx(
120120
{
121121
to: result.createdAddress,
122122
type: 0x2,
@@ -132,7 +132,7 @@ describe(method, () => {
132132

133133
await blockBuilder.addTransaction(secondTx, { skipHardForkValidation: true })
134134

135-
const thirdTx = createTxFromTxData(
135+
const thirdTx = createTx(
136136
{
137137
type: 0x2,
138138
gasLimit: 10000000,

packages/client/test/rpc/debug/traceCall.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createBlock } from '@ethereumjs/block'
2-
import { createTxFromTxData } from '@ethereumjs/tx'
2+
import { createTx } from '@ethereumjs/tx'
33
import { bytesToHex } from '@ethereumjs/util'
44
import { assert, describe, expect, expectTypeOf, it } from 'vitest'
55

@@ -51,7 +51,7 @@ describe('trace a call', async () => {
5151
})
5252
const rpc = getRPCClient(server)
5353
// construct block with tx
54-
const tx = createTxFromTxData(
54+
const tx = createTx(
5555
{
5656
type: 0x2,
5757
gasLimit: 0xfffff,

packages/client/test/rpc/debug/traceTransaction.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createBlock } from '@ethereumjs/block'
2-
import { createTxFromTxData } from '@ethereumjs/tx'
2+
import { createTx } from '@ethereumjs/tx'
33
import { bytesToHex } from '@ethereumjs/util'
44
import { assert, describe, it } from 'vitest'
55

@@ -50,7 +50,7 @@ describe(method, () => {
5050
})
5151
const rpc = getRPCClient(server)
5252
// construct block with tx
53-
const tx = createTxFromTxData(
53+
const tx = createTx(
5454
{
5555
type: 0x2,
5656
gasLimit: 0xfffff,
@@ -79,7 +79,7 @@ describe(method, () => {
7979
})
8080
const rpc = getRPCClient(server)
8181
// construct block with tx
82-
const tx = createTxFromTxData(
82+
const tx = createTx(
8383
{
8484
type: 0x2,
8585
gasLimit: 0xfffff,
@@ -108,7 +108,7 @@ describe(method, () => {
108108
})
109109
const rpc = getRPCClient(server)
110110
// construct block with tx
111-
const tx = createTxFromTxData(
111+
const tx = createTx(
112112
{
113113
type: 0x2,
114114
gasLimit: 0xfffff,
@@ -141,7 +141,7 @@ describe(method, () => {
141141
})
142142
const rpc = getRPCClient(server)
143143
// construct block with tx
144-
const tx = createTxFromTxData(
144+
const tx = createTx(
145145
{
146146
type: 0x2,
147147
gasLimit: 0xfffff,

packages/client/test/rpc/engine/getPayloadBodiesByHashV1.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createBlock, createBlockHeader } from '@ethereumjs/block'
22
import { Hardfork } from '@ethereumjs/common'
33
import { MerkleStateManager } from '@ethereumjs/statemanager'
4-
import { createTxFromTxData } from '@ethereumjs/tx'
4+
import { createTx } from '@ethereumjs/tx'
55
import {
66
Account,
77
bytesToHex,
@@ -51,7 +51,7 @@ describe(method, () => {
5151

5252
account!.balance = 0xfffffffffffffffn
5353
await service.execution.vm.stateManager.putAccount(address, account!)
54-
const tx = createTxFromTxData(
54+
const tx = createTx(
5555
{
5656
type: 0x01,
5757
maxFeePerBlobGas: 1n,
@@ -61,7 +61,7 @@ describe(method, () => {
6161
},
6262
{ common },
6363
).sign(pkey)
64-
const tx2 = createTxFromTxData(
64+
const tx2 = createTx(
6565
{
6666
type: 0x01,
6767
maxFeePerBlobGas: 1n,
@@ -133,7 +133,7 @@ describe(method, () => {
133133

134134
account!.balance = 0xfffffffffffffffn
135135
await service.execution.vm.stateManager.putAccount(address, account!)
136-
const tx = createTxFromTxData(
136+
const tx = createTx(
137137
{
138138
type: 0x01,
139139
maxFeePerBlobGas: 1n,
@@ -143,7 +143,7 @@ describe(method, () => {
143143
},
144144
{ common },
145145
).sign(pkey)
146-
const tx2 = createTxFromTxData(
146+
const tx2 = createTx(
147147
{
148148
type: 0x01,
149149
maxFeePerBlobGas: 1n,

0 commit comments

Comments
 (0)