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

Commit d9bb9f7

Browse files
Merge branch '4.x' into 6599-implement-providergetfeedata
2 parents bb035dd + e774646 commit d9bb9f7

File tree

3 files changed

+73
-53
lines changed

3 files changed

+73
-53
lines changed

packages/web3-eth/src/web3_eth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,15 @@ export class Web3Eth extends Web3Context<Web3EthExecutionAPI, RegisteredSubscrip
270270
* @returns The current fee data.
271271
*
272272
* ```ts
273-
* web3.eth.getFeeData().then(console.log);
273+
* web3.eth.calculateFeeData().then(console.log);
274274
* > {
275275
* gasPrice: 20000000000n,
276276
* maxFeePerGas: 20000000000n,
277277
* maxPriorityFeePerGas: 20000000000n,
278278
* baseFeePerGas: 20000000000n
279279
* }
280280
*
281-
* web3.eth.getFeeData(ethUnitMap.Gwei, 2n).then(console.log);
281+
* web3.eth.calculateFeeData(ethUnitMap.Gwei, 2n).then(console.log);
282282
* > {
283283
* gasPrice: 20000000000n,
284284
* maxFeePerGas: 40000000000n,

packages/web3-eth/test/integration/web3_eth/send_transaction.test.ts

Lines changed: 66 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ import {
3737
createTempAccount,
3838
getSystemTestBackend,
3939
getSystemTestProvider,
40+
isGeth,
4041
itIf,
41-
BACKEND
42+
BACKEND,
4243
} from '../../fixtures/system_test_utils';
4344
import { SimpleRevertAbi, SimpleRevertDeploymentData } from '../../fixtures/simple_revert';
4445

@@ -89,9 +90,7 @@ describe('Web3Eth.sendTransaction', () => {
8990
expect(response.status).toBe(BigInt(1));
9091
expect(response.events).toBeUndefined();
9192

92-
const minedTransactionData = await web3EthWithWallet.getTransaction(
93-
response.transactionHash,
94-
);
93+
const minedTransactionData = await web3EthWithWallet.getTransaction(response.transactionHash);
9594

9695
expect(minedTransactionData).toMatchObject({
9796
from: tempAcc.address,
@@ -120,9 +119,7 @@ describe('Web3Eth.sendTransaction', () => {
120119
expect(response.status).toBe(BigInt(1));
121120
expect(response.events).toBeUndefined();
122121

123-
const minedTransactionData = await web3EthWithWallet.getTransaction(
124-
response.transactionHash,
125-
);
122+
const minedTransactionData = await web3EthWithWallet.getTransaction(response.transactionHash);
126123

127124
expect(minedTransactionData).toMatchObject({
128125
from: tempAcc.address,
@@ -155,9 +152,7 @@ describe('Web3Eth.sendTransaction', () => {
155152
expect(response.status).toBe(BigInt(1));
156153
expect(response.events).toBeUndefined();
157154

158-
const minedTransactionData = await web3EthWithWallet.getTransaction(
159-
response.transactionHash,
160-
);
155+
const minedTransactionData = await web3EthWithWallet.getTransaction(response.transactionHash);
161156

162157
expect(minedTransactionData).toMatchObject({
163158
from: tempAcc.address,
@@ -411,6 +406,29 @@ describe('Web3Eth.sendTransaction', () => {
411406
expect(minedTransactionData).toMatchObject(transaction);
412407
});
413408

409+
itIf(isGeth)(
410+
'should send type 0x2 transaction with maxPriorityFeePerGas got from await web3Eth.getMaxPriorityFeePerGas()',
411+
async () => {
412+
const transaction: Transaction = {
413+
from: tempAcc.address,
414+
to: '0x0000000000000000000000000000000000000000',
415+
value: BigInt(1),
416+
maxPriorityFeePerGas: await web3Eth.getMaxPriorityFeePerGas(),
417+
};
418+
const response = await web3Eth.sendTransaction(transaction);
419+
420+
// eslint-disable-next-line jest/no-standalone-expect
421+
expect(response.events).toBeUndefined();
422+
// eslint-disable-next-line jest/no-standalone-expect
423+
expect(response.type).toBe(BigInt(2));
424+
// eslint-disable-next-line jest/no-standalone-expect
425+
expect(response.status).toBe(BigInt(1));
426+
const minedTransactionData = await web3Eth.getTransaction(response.transactionHash);
427+
// eslint-disable-next-line jest/no-standalone-expect
428+
expect(minedTransactionData).toMatchObject(transaction);
429+
},
430+
);
431+
414432
describe('Transaction PromiEvents', () => {
415433
let transaction: Transaction;
416434

@@ -516,12 +534,9 @@ describe('Web3Eth.sendTransaction', () => {
516534
from: tempAcc.address,
517535
data: SimpleRevertDeploymentData,
518536
};
519-
simpleRevertDeployTransaction.gas = await web3Eth.estimateGas(
520-
simpleRevertDeployTransaction,
521-
);
522-
simpleRevertContractAddress = (
523-
await web3Eth.sendTransaction(simpleRevertDeployTransaction)
524-
).contractAddress as Address;
537+
simpleRevertDeployTransaction.gas = await web3Eth.estimateGas(simpleRevertDeployTransaction);
538+
simpleRevertContractAddress = (await web3Eth.sendTransaction(simpleRevertDeployTransaction))
539+
.contractAddress as Address;
525540
});
526541

527542
it('Should throw TransactionRevertInstructionError because gas too low', async () => {
@@ -540,51 +555,51 @@ describe('Web3Eth.sendTransaction', () => {
540555
? 'err: intrinsic gas too low: have 1, want 21000 (supplied gas 1)'
541556
: 'base fee exceeds gas limit',
542557
};
543-
544-
if(getSystemTestBackend() !== BACKEND.HARDHAT){
558+
559+
if (getSystemTestBackend() !== BACKEND.HARDHAT) {
545560
await expect(
546561
web3Eth
547562
.sendTransaction(transaction)
548563
.on('error', error => expect(error).toMatchObject(expectedThrownError)),
549564
).rejects.toMatchObject(expectedThrownError);
550565
} else {
551-
552566
try {
553567
await web3Eth.sendTransaction(transaction);
554-
} catch (error) {
568+
} catch (error) {
555569
expect((error as any).name).toEqual(expectedThrownError.name);
556570
expect((error as any).code).toEqual(expectedThrownError.code);
557571
expect((error as any).reason).toContain(expectedThrownError.reason);
558-
}
572+
}
559573
}
560574
});
561-
itIf(getSystemTestBackend() !== BACKEND.HARDHAT)('Should throw TransactionRevertInstructionError because insufficient funds', async () => {
562-
const transaction: Transaction = {
563-
from: tempAcc.address,
564-
to: '0x0000000000000000000000000000000000000000',
565-
value: BigInt('99999999999999999999999999999999999999999999999999999999999999999'),
566-
};
567-
568-
const expectedThrownError = {
569-
name: 'TransactionRevertInstructionError',
570-
message: 'Transaction has been reverted by the EVM',
571-
code: 402,
572-
reason:
573-
getSystemTestBackend() === BACKEND.GETH
574-
? expect.stringContaining(
575-
'err: insufficient funds for gas * price + value: address',
576-
)
577-
: 'VM Exception while processing transaction: insufficient balance',
578-
};
579-
580-
// eslint-disable-next-line jest/no-standalone-expect
581-
await expect(
582-
web3Eth
583-
.sendTransaction(transaction)
584-
// eslint-disable-next-line jest/no-standalone-expect
585-
.on('error', error => expect(error).toMatchObject(expectedThrownError)),
586-
).rejects.toMatchObject(expectedThrownError);
587-
});
575+
itIf(getSystemTestBackend() !== BACKEND.HARDHAT)(
576+
'Should throw TransactionRevertInstructionError because insufficient funds',
577+
async () => {
578+
const transaction: Transaction = {
579+
from: tempAcc.address,
580+
to: '0x0000000000000000000000000000000000000000',
581+
value: BigInt('99999999999999999999999999999999999999999999999999999999999999999'),
582+
};
583+
584+
const expectedThrownError = {
585+
name: 'TransactionRevertInstructionError',
586+
message: 'Transaction has been reverted by the EVM',
587+
code: 402,
588+
reason:
589+
getSystemTestBackend() === BACKEND.GETH
590+
? expect.stringContaining('err: insufficient funds for gas * price + value: address')
591+
: 'VM Exception while processing transaction: insufficient balance',
592+
};
593+
594+
// eslint-disable-next-line jest/no-standalone-expect
595+
await expect(
596+
web3Eth
597+
.sendTransaction(transaction)
598+
// eslint-disable-next-line jest/no-standalone-expect
599+
.on('error', error => expect(error).toMatchObject(expectedThrownError)),
600+
).rejects.toMatchObject(expectedThrownError);
601+
},
602+
);
588603

589604
it('Should throw TransactionRevertInstructionError because of contract revert and return revert reason', async () => {
590605
const transaction: Transaction = {
@@ -629,7 +644,7 @@ describe('Web3Eth.sendTransaction', () => {
629644
reason:
630645
getSystemTestBackend() === BACKEND.GETH
631646
? 'execution reverted'
632-
: "Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x72090e4d)",
647+
: 'Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0x72090e4d)',
633648
signature: '0x72090e4d',
634649
customErrorName: 'ErrorWithNoParams',
635650
customErrorDecodedSignature: 'ErrorWithNoParams()',
@@ -659,7 +674,7 @@ describe('Web3Eth.sendTransaction', () => {
659674
reason:
660675
getSystemTestBackend() === BACKEND.GETH
661676
? 'execution reverted'
662-
: "Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000)",
677+
: 'Error: VM Exception while processing transaction: reverted with an unrecognized custom error (return data: 0xc85bda60000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000)',
663678
signature: '0xc85bda60',
664679
data: '000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000001c5468697320697320616e206572726f72207769746820706172616d7300000000',
665680
customErrorName: 'ErrorWithParams',
@@ -697,7 +712,7 @@ describe('Web3Eth.sendTransaction', () => {
697712
signature: '0x08c379a0',
698713
data: '000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000155468697320697320612073656e64207265766572740000000000000000000000',
699714
};
700-
715+
701716
await expect(
702717
web3Eth
703718
.sendTransaction(transaction)

packages/web3-eth/test/unit/web3_eth_methods_no_parameters.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,10 @@ describe('web3_eth_methods_no_parameters', () => {
7676
await web3Eth.getNodeInfo();
7777
expect(ethRpcMethods.getNodeInfo).toHaveBeenCalledWith(web3Eth.requestManager);
7878
});
79+
80+
it('getMaxPriorityFeePerGas', async () => {
81+
await web3Eth.getMaxPriorityFeePerGas();
82+
expect(ethRpcMethods.getMaxPriorityFeePerGas).toHaveBeenCalledWith(web3Eth.requestManager);
83+
});
7984
});
8085
});

0 commit comments

Comments
 (0)