Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 210455a

Browse files
authoredMay 25, 2023
transaction integration tests (#6071)
* transactions test data * transactions integration test * bug fix 6063 * changelog update * fillGasPrice option param and test fixes * tx tests fix * fixed acct tests * fixed gas estimation error before signing in tests * updated test for type * updated tx type in tests * additional test with flag * updated prepareTransactionForSigning , defaultTransactionBuilder and tests * changelog update * update change log
1 parent fe959a1 commit 210455a

10 files changed

+5486
-30
lines changed
 

‎packages/web3-core/src/web3_context.ts

+1
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ export type TransactionBuilder<API extends Web3APISpec = unknown> = <
374374
transaction: Transaction;
375375
web3Context: Web3Context<API>;
376376
privateKey?: HexString | Uint8Array;
377+
fillGasPrice?: boolean;
377378
}) => Promise<ReturnType>;
378379

379380
/**

‎packages/web3-eth/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
126126

127127
## [Unreleased]
128128

129+
### Fixed
130+
131+
- Fixed `ignoreGasPricing` bug with wallet in context (#6071)
132+
129133
### Changed
130134

131135
- `formatTransaction` no longer throws a `TransactionDataAndInputError` if it's passed a transaction object with both `data` and `input` properties set (as long as they are the same value) (#6064)
132136
- Refactored documentation for `rpc_method_wrappers` to point to the previously duplicated documentation found under the `Web3Eth` class documentation (#6054)
133137
- Replaced Buffer for Uint8Array (#6004)
134138
- Refactored `defaultTransactionTypeParser` to return correct EIP-2718 types, prior implementation was prioritizing `transaction.hardfork` and ignoring the use of `transaction.gasLimit`. `defaultTransactionTypeParser` will now throw `InvalidPropertiesForTransactionTypeError`s for properties are used that are incompatible with `transaction.type` (#6102)
139+
- `prepareTransactionForSigning` and `defaultTransactionBuilder` now accepts optional `fillGasPrice` flag and by default will not fill gas(#6071)

‎packages/web3-eth/src/utils/prepare_transaction_for_signing.ts

+2
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,13 @@ export const prepareTransactionForSigning = async (
124124
transaction: Transaction,
125125
web3Context: Web3Context<EthExecutionAPI>,
126126
privateKey?: HexString | Uint8Array,
127+
fillGasPrice = false,
127128
) => {
128129
const populatedTransaction = (await transactionBuilder({
129130
transaction,
130131
web3Context,
131132
privateKey,
133+
fillGasPrice,
132134
})) as unknown as PopulatedUnsignedTransaction;
133135

134136
const formattedTransaction = formatTransaction(

‎packages/web3-eth/src/utils/transaction_builder.ts

+20-15
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ import { NUMBER_DATA_FORMAT } from '../constants';
4949
// eslint-disable-next-line import/no-cycle
5050
import { getChainId, getTransactionCount } from '../rpc_method_wrappers';
5151
import { detectTransactionType } from './detect_transaction_type';
52-
// eslint-disable-next-line import/no-cycle
53-
import { getTransactionGasPricing } from './get_transaction_gas_pricing';
5452
import { transactionSchema } from '../schemas';
5553
import { InternalTransaction } from '../types';
54+
// eslint-disable-next-line import/no-cycle
55+
import { getTransactionGasPricing } from './get_transaction_gas_pricing';
5656

5757
export const getTransactionFromOrToAttr = (
5858
attr: 'from' | 'to',
@@ -128,6 +128,7 @@ export async function defaultTransactionBuilder<ReturnType = Transaction>(option
128128
transaction: Transaction;
129129
web3Context: Web3Context<EthExecutionAPI & Web3NetAPI>;
130130
privateKey?: HexString | Uint8Array;
131+
fillGasPrice?: boolean;
131132
}): Promise<ReturnType> {
132133
// let populatedTransaction = { ...options.transaction } as unknown as InternalTransaction;
133134
let populatedTransaction = format(
@@ -228,24 +229,28 @@ export async function defaultTransactionBuilder<ReturnType = Transaction>(option
228229
populatedTransaction.accessList = [];
229230
}
230231

231-
populatedTransaction = {
232-
...populatedTransaction,
233-
...(await getTransactionGasPricing(
234-
populatedTransaction,
235-
options.web3Context,
236-
ETH_DATA_FORMAT,
237-
)),
238-
};
232+
if (options.fillGasPrice)
233+
populatedTransaction = {
234+
...populatedTransaction,
235+
...(await getTransactionGasPricing(
236+
populatedTransaction,
237+
options.web3Context,
238+
ETH_DATA_FORMAT,
239+
)),
240+
};
239241

240242
return populatedTransaction as ReturnType;
241243
}
242244

243-
export const transactionBuilder = async <ReturnType = Transaction>(options: {
244-
transaction: Transaction;
245-
web3Context: Web3Context<EthExecutionAPI>;
246-
privateKey?: HexString | Uint8Array;
245+
export const transactionBuilder = async <ReturnType = Transaction>(
246+
options: {
247+
transaction: Transaction;
248+
web3Context: Web3Context<EthExecutionAPI>;
249+
privateKey?: HexString | Uint8Array;
250+
fillGasPrice?: boolean;
251+
},
247252
// eslint-disable-next-line @typescript-eslint/require-await
248-
}) =>
253+
) =>
249254
(options.web3Context.transactionBuilder ?? defaultTransactionBuilder)({
250255
...options,
251256
transaction: options.transaction,

‎packages/web3-eth/test/unit/default_transaction_builder.test.ts

+53-4
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ describe('defaultTransactionBuilder', () => {
134134
// VALID_ETH_BASE_TYPES.HexString,
135135
// '0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709',
136136
// overrideFunction,
137+
fillGasPrice: true,
137138
});
138139
expect(overrideFunction).toHaveBeenCalledWith(input);
139140
});
@@ -149,6 +150,7 @@ describe('defaultTransactionBuilder', () => {
149150
transaction: input,
150151
web3Context,
151152
privateKey: '0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709',
153+
fillGasPrice: true,
152154
});
153155
expect(result.from).toBe(expectedFrom);
154156
});
@@ -169,6 +171,7 @@ describe('defaultTransactionBuilder', () => {
169171
const result = await defaultTransactionBuilder({
170172
transaction: input,
171173
web3Context,
174+
fillGasPrice: true,
172175
});
173176
expect(result.from).toBe(expectedFrom);
174177
});
@@ -183,7 +186,7 @@ describe('defaultTransactionBuilder', () => {
183186
delete input.maxFeePerGas;
184187

185188
await expect(
186-
defaultTransactionBuilder({ transaction: input, web3Context }),
189+
defaultTransactionBuilder({ transaction: input, web3Context, fillGasPrice: true }),
187190
).rejects.toThrow(new UnableToPopulateNonceError());
188191
});
189192

@@ -196,6 +199,26 @@ describe('defaultTransactionBuilder', () => {
196199
const result = await defaultTransactionBuilder({
197200
transaction: input,
198201
web3Context,
202+
fillGasPrice: true,
203+
});
204+
expect(result.nonce).toBe(expectedNonce);
205+
expect(getTransactionCountSpy).toHaveBeenCalledWith(
206+
web3Context.requestManager,
207+
expectedFrom,
208+
web3Context.defaultBlock,
209+
);
210+
});
211+
212+
it('should use web3Eth.getTransactionCount to populate nonce without gas fill', async () => {
213+
const input = { ...transaction };
214+
delete input.nonce;
215+
delete input.maxPriorityFeePerGas;
216+
delete input.maxFeePerGas;
217+
218+
const result = await defaultTransactionBuilder({
219+
transaction: input,
220+
web3Context,
221+
fillGasPrice: false,
199222
});
200223
expect(result.nonce).toBe(expectedNonce);
201224
expect(getTransactionCountSpy).toHaveBeenCalledWith(
@@ -216,6 +239,7 @@ describe('defaultTransactionBuilder', () => {
216239
const result = await defaultTransactionBuilder({
217240
transaction: input,
218241
web3Context,
242+
fillGasPrice: true,
219243
});
220244
expect(result.value).toBe('0x');
221245
});
@@ -232,6 +256,7 @@ describe('defaultTransactionBuilder', () => {
232256
const result = await defaultTransactionBuilder({
233257
transaction: input,
234258
web3Context,
259+
fillGasPrice: true,
235260
});
236261
expect(result.input).toBe('0x');
237262
expect(result.data).toBe('0x');
@@ -247,6 +272,7 @@ describe('defaultTransactionBuilder', () => {
247272
const result = await defaultTransactionBuilder({
248273
transaction: input,
249274
web3Context,
275+
fillGasPrice: true,
250276
});
251277
expect(result.input).toBe('0x123');
252278
expect(result.data).toBe('0x123');
@@ -277,6 +303,7 @@ describe('defaultTransactionBuilder', () => {
277303
const result = await defaultTransactionBuilder({
278304
transaction: input,
279305
web3Context,
306+
fillGasPrice: true,
280307
});
281308
expect(result.chain).toBe('mainnet');
282309
});
@@ -293,6 +320,7 @@ describe('defaultTransactionBuilder', () => {
293320
const result = await defaultTransactionBuilder({
294321
transaction: input,
295322
web3Context,
323+
fillGasPrice: true,
296324
});
297325
expect(result.chain).toBe(web3Context.defaultChain);
298326
});
@@ -309,6 +337,7 @@ describe('defaultTransactionBuilder', () => {
309337
const result = await defaultTransactionBuilder({
310338
transaction: input,
311339
web3Context,
340+
fillGasPrice: true,
312341
});
313342
expect(result.hardfork).toBe('london');
314343
});
@@ -325,6 +354,7 @@ describe('defaultTransactionBuilder', () => {
325354
const result = await defaultTransactionBuilder({
326355
transaction: input,
327356
web3Context,
357+
fillGasPrice: true,
328358
});
329359
expect(result.hardfork).toBe(web3Context.defaultHardfork);
330360
});
@@ -357,6 +387,7 @@ describe('defaultTransactionBuilder', () => {
357387
const result = await defaultTransactionBuilder({
358388
transaction: input,
359389
web3Context,
390+
fillGasPrice: true,
360391
});
361392
expect(result.common).toStrictEqual(customCommon);
362393
});
@@ -373,6 +404,7 @@ describe('defaultTransactionBuilder', () => {
373404
const result = await defaultTransactionBuilder({
374405
transaction: input,
375406
web3Context,
407+
fillGasPrice: true,
376408
});
377409
expect(result.chainId).toBe(expectedChainId);
378410
});
@@ -388,6 +420,7 @@ describe('defaultTransactionBuilder', () => {
388420
const result = await defaultTransactionBuilder({
389421
transaction: input,
390422
web3Context,
423+
fillGasPrice: true,
391424
});
392425
expect(result.networkId).toBe(expectedNetworkId);
393426
});
@@ -403,6 +436,7 @@ describe('defaultTransactionBuilder', () => {
403436
const result = await defaultTransactionBuilder({
404437
transaction: input,
405438
web3Context,
439+
fillGasPrice: true,
406440
});
407441
expect(result.gasLimit).toBe(expectedGasLimit);
408442
});
@@ -414,7 +448,7 @@ describe('defaultTransactionBuilder', () => {
414448
input.type = '0x8'; // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2718.md#transactions
415449

416450
await expect(
417-
defaultTransactionBuilder({ transaction: input, web3Context }),
451+
defaultTransactionBuilder({ transaction: input, web3Context, fillGasPrice: true }),
418452
).rejects.toThrow(new UnsupportedTransactionTypeError(input.type));
419453
});
420454

@@ -441,6 +475,7 @@ describe('defaultTransactionBuilder', () => {
441475
const result = await defaultTransactionBuilder({
442476
transaction: input,
443477
web3Context,
478+
fillGasPrice: true,
444479
});
445480
expect(result.type).toBe(web3Context.defaultTransactionType);
446481
});
@@ -454,7 +489,11 @@ describe('defaultTransactionBuilder', () => {
454489
delete input.maxPriorityFeePerGas;
455490
input.type = '0x0';
456491

457-
const result = await defaultTransactionBuilder({ transaction: input, web3Context });
492+
const result = await defaultTransactionBuilder({
493+
transaction: input,
494+
web3Context,
495+
fillGasPrice: true,
496+
});
458497
expect(result.gasPrice).toBe(expectedGasPrice);
459498
});
460499

@@ -468,6 +507,7 @@ describe('defaultTransactionBuilder', () => {
468507
const result = await defaultTransactionBuilder({
469508
transaction: input,
470509
web3Context,
510+
fillGasPrice: true,
471511
});
472512
expect(result.gasPrice).toBe(expectedGasPrice);
473513
});
@@ -484,6 +524,7 @@ describe('defaultTransactionBuilder', () => {
484524
const result = await defaultTransactionBuilder<PopulatedUnsignedEip2930Transaction>({
485525
transaction: input,
486526
web3Context,
527+
fillGasPrice: true,
487528
});
488529
expect(result.accessList).toStrictEqual([]);
489530
});
@@ -497,6 +538,7 @@ describe('defaultTransactionBuilder', () => {
497538
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
498539
transaction: input,
499540
web3Context,
541+
fillGasPrice: true,
500542
});
501543
expect(result.accessList).toStrictEqual([]);
502544
});
@@ -516,7 +558,7 @@ describe('defaultTransactionBuilder', () => {
516558
input.type = '0x2';
517559

518560
await expect(
519-
defaultTransactionBuilder({ transaction: input, web3Context }),
561+
defaultTransactionBuilder({ transaction: input, web3Context, fillGasPrice: true }),
520562
).rejects.toThrow(new Eip1559NotSupportedError());
521563
});
522564

@@ -530,6 +572,7 @@ describe('defaultTransactionBuilder', () => {
530572
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
531573
transaction: input,
532574
web3Context,
575+
fillGasPrice: true,
533576
});
534577

535578
expect(result.maxPriorityFeePerGas).toBeDefined();
@@ -546,6 +589,7 @@ describe('defaultTransactionBuilder', () => {
546589
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
547590
transaction: input,
548591
web3Context,
592+
fillGasPrice: true,
549593
});
550594
expect(result.maxPriorityFeePerGas).toBe(expectedMaxPriorityFeePerGas); // 2.5 Gwei, hardcoded in defaultTransactionBuilder;
551595
expect(result.maxFeePerGas).toBe(expectedMaxFeePerGas);
@@ -560,6 +604,7 @@ describe('defaultTransactionBuilder', () => {
560604
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
561605
transaction: input,
562606
web3Context,
607+
fillGasPrice: true,
563608
});
564609
expect(result.maxPriorityFeePerGas).toBe(expectedMaxPriorityFeePerGas); // 2.5 Gwei, hardcoded in defaultTransactionBuilder;
565610
expect(result.maxFeePerGas).toBe(expectedMaxFeePerGas);
@@ -574,6 +619,7 @@ describe('defaultTransactionBuilder', () => {
574619
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
575620
transaction: input,
576621
web3Context,
622+
fillGasPrice: true,
577623
});
578624
expect(result.maxPriorityFeePerGas).toBe(expectedMaxPriorityFeePerGas); // 2.5 Gwei, hardcoded in defaultTransactionBuilder;
579625
expect(result.maxFeePerGas).toBe(expectedMaxFeePerGas);
@@ -596,6 +642,7 @@ describe('defaultTransactionBuilder', () => {
596642
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
597643
transaction: input,
598644
web3Context,
645+
fillGasPrice: true,
599646
});
600647
expect(result.maxPriorityFeePerGas).toBe(web3Context.defaultMaxPriorityFeePerGas); // 2.5 Gwei, hardcoded in defaultTransactionBuilder;
601648
expect(result.maxFeePerGas).toBe(expectedMaxFeePerGas);
@@ -617,6 +664,7 @@ describe('defaultTransactionBuilder', () => {
617664
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
618665
transaction: input,
619666
web3Context,
667+
fillGasPrice: true,
620668
});
621669
expect(result.maxPriorityFeePerGas).toBe(web3Context.defaultMaxPriorityFeePerGas); // 2.5 Gwei, hardcoded in defaultTransactionBuilder;
622670
expect(result.maxFeePerGas).toBe(expectedMaxFeePerGas);
@@ -638,6 +686,7 @@ describe('defaultTransactionBuilder', () => {
638686
const result = await defaultTransactionBuilder<PopulatedUnsignedEip1559Transaction>({
639687
transaction: input,
640688
web3Context,
689+
fillGasPrice: true,
641690
});
642691
expect(result.maxPriorityFeePerGas).toBe(web3Context.defaultMaxPriorityFeePerGas); // 2.5 Gwei, hardcoded in defaultTransactionBuilder;
643692
expect(result.maxFeePerGas).toBe(expectedMaxFeePerGas);

‎packages/web3-eth/test/unit/prepare_transaction_for_signing.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ describe('prepareTransactionForSigning', () => {
5959
expectedTransaction,
6060
web3Context,
6161
expectedPrivateKey,
62+
true,
6263
);
6364

6465
// should produce an web3-utils/tx instance

‎packages/web3/test/fixtures/transactions.json

+5,264
Large diffs are not rendered by default.

‎packages/web3/test/integration/web3.accounts.test.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ describe('web3.accounts', () => {
7777
}),
7878
).resolves.toBeDefined();
7979

80+
const txWithGas = {
81+
...tx,
82+
gasPrice: '0x271000',
83+
};
8084
// Sign the tx from that account
81-
const signedTx = await account.signTransaction(tx);
85+
const signedTx = await account.signTransaction(txWithGas);
8286

8387
expect(signedTx).toEqual(
8488
expect.objectContaining({
@@ -108,6 +112,7 @@ describe('web3.accounts', () => {
108112
value: web3.utils.toWei('0.1', 'ether'),
109113
gas: '0x1',
110114
data: '0x1',
115+
gasPrice: '0x38562',
111116
};
112117

113118
await expect(account.signTransaction(tx)).rejects.toThrow('gasLimit is too low.');
@@ -141,6 +146,7 @@ describe('web3.accounts', () => {
141146
value: web3.utils.toWei('0.1', 'ether'),
142147
gas: '0x5218',
143148
data: '0x1',
149+
gasPrice: '0x48523',
144150
};
145151

146152
// Fund this account with some ether
@@ -181,6 +187,7 @@ describe('web3.accounts', () => {
181187
value: web3.utils.toWei('0.1', 'ether'),
182188
gas: '0x1',
183189
data: '0x1',
190+
gasPrice: '0x1',
184191
};
185192

186193
await expect(web3.eth.accounts.signTransaction(tx, account.privateKey)).rejects.toThrow(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
This file is part of web3.js.
3+
4+
web3.js is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU Lesser General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
web3.js is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public License
15+
along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
import * as httpProvider from 'web3-providers-http';
19+
import { Web3Account } from 'web3-eth-accounts';
20+
import Web3, { DEFAULT_RETURN_FORMAT, Transaction } from '../../src';
21+
import testsData from '../fixtures/transactions.json';
22+
23+
jest.mock('web3-providers-http');
24+
25+
describe('signTransaction', () => {
26+
let blockNum = 1;
27+
28+
it.each(testsData)(
29+
'Integration test of transaction %s with Web3, Web3.Eth, Web3.Accounts and Provider should pass',
30+
async txObj => {
31+
const web3: Web3 = new Web3('http://127.0.0.1:8080');
32+
33+
const account: Web3Account = web3.eth.accounts.privateKeyToAccount(txObj.privateKey);
34+
35+
web3.eth.wallet?.add(txObj.privateKey);
36+
37+
const normalTx: Transaction = {
38+
...txObj.transaction,
39+
from: account.address,
40+
};
41+
42+
// either make it legacy or type 0x2 tx, instead of keeping both gasPrice and (maxPriorityFeePerGas maxFeePerGas)
43+
if (txObj.transaction?.maxPriorityFeePerGas) {
44+
delete normalTx['gasPrice'];
45+
} else {
46+
delete normalTx['maxPriorityFeePerGas'];
47+
delete normalTx['maxFeePerGas'];
48+
}
49+
50+
jest.spyOn(httpProvider.HttpProvider.prototype, 'request').mockImplementation(
51+
async (payload: any) => {
52+
const response = {
53+
jsonrpc: '2.0',
54+
id: payload.id,
55+
result: {},
56+
};
57+
58+
switch (payload.method) {
59+
case 'net_version':
60+
response.result = '1';
61+
break;
62+
63+
case 'eth_chainId':
64+
response.result = '0x1';
65+
break;
66+
67+
case 'eth_blockNumber':
68+
blockNum += 10;
69+
response.result = `0x${blockNum.toString(16)}`;
70+
break;
71+
72+
case 'eth_getTransactionReceipt':
73+
response.result = {
74+
blockHash:
75+
'0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3',
76+
blockNumber: `0x${blockNum.toString(16)}`,
77+
cumulativeGasUsed: '0xa12515',
78+
// "effectiveGasPrice": payload.effectiveGasPrice,
79+
from: payload.from,
80+
gasUsed: payload.gasLimit,
81+
// "logs": [{}],
82+
// "logsBloom": "0xa957d47df264a31badc3ae823e10ac1d444b098d9b73d204c40426e57f47e8c3", // 256 byte bloom filter
83+
status: '0x1',
84+
to: payload.to,
85+
transactionHash:
86+
'0x85d995eba9763907fdf35cd2034144dd9d53ce32cbec21349d4b12823c6860c5',
87+
transactionIndex: '0x66',
88+
// "type": payload.type
89+
};
90+
break;
91+
92+
case 'eth_sendRawTransaction':
93+
if (txObj.transaction.maxPriorityFeePerGas !== undefined) {
94+
// eslint-disable-next-line jest/no-conditional-expect
95+
expect(payload.params[0]).toBe(txObj.signedLondon); // validate transaction for London HF
96+
} else {
97+
// eslint-disable-next-line jest/no-conditional-expect
98+
expect(payload.params[0]).toBe(txObj.signedBerlin); // validate transaction for Berlin HF
99+
}
100+
response.result =
101+
'0x895ebb29d30e0afa891a5ca3a2687e073bd2c7ab544117ac386c8d8ff3ad583b';
102+
break;
103+
104+
default:
105+
throw new Error(`Unknown payload ${payload}`);
106+
}
107+
108+
return new Promise(resolve => {
109+
resolve(response as any);
110+
});
111+
},
112+
);
113+
114+
const res = await web3.eth.sendTransaction(normalTx, DEFAULT_RETURN_FORMAT, {
115+
ignoreGasPricing: true,
116+
checkRevertBeforeSending: false,
117+
});
118+
expect(res).toBeDefined();
119+
},
120+
);
121+
});

‎scripts/system_tests_utils.ts

+11-10
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,16 @@ export const signTxAndSendEIP1559 = async (
335335
) => {
336336
const web3 = new Web3(provider as Web3BaseProvider);
337337
const acc = web3.eth.accounts.privateKeyToAccount(privateKey);
338-
const signedTx = await acc.signTransaction({
338+
web3.eth.wallet?.add(privateKey);
339+
340+
const txObj = {
339341
...tx,
340342
type: '0x2',
341343
gas: tx.gas ?? '1000000',
342344
from: acc.address,
343-
});
344-
return web3.eth.sendSignedTransaction(signedTx.rawTransaction, undefined, {
345-
checkRevertBeforeSending: false,
346-
});
345+
};
346+
347+
return web3.eth.sendTransaction(txObj, undefined, { checkRevertBeforeSending: false });
347348
};
348349

349350
export const signTxAndSendEIP2930 = async (
@@ -353,15 +354,15 @@ export const signTxAndSendEIP2930 = async (
353354
) => {
354355
const web3 = new Web3(provider as Web3BaseProvider);
355356
const acc = web3.eth.accounts.privateKeyToAccount(privateKey);
356-
const signedTx = await acc.signTransaction({
357+
web3.eth.wallet?.add(privateKey);
358+
const txObj = {
357359
...tx,
358360
type: '0x1',
359361
gas: tx.gas ?? '1000000',
360362
from: acc.address,
361-
});
362-
return web3.eth.sendSignedTransaction(signedTx.rawTransaction, undefined, {
363-
checkRevertBeforeSending: false,
364-
});
363+
};
364+
365+
return web3.eth.sendTransaction(txObj, undefined, { checkRevertBeforeSending: false });
365366
};
366367

367368
export const signAndSendContractMethodEIP1559 = async (

0 commit comments

Comments
 (0)
This repository has been archived.