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

Commit ca59b6d

Browse files
authored
4693/transaction receipt effective gas price 4.x (#4866)
* add effective gas price to transactionreceipt * Add effectiveGasPrice in convertibleProperties * Add effectiveGasPrice in mocks. Changed the value, previous could be only bigInt
1 parent 76427c9 commit ca59b6d

File tree

7 files changed

+27
-0
lines changed

7 files changed

+27
-0
lines changed

packages/web3-common/src/eth_execution_api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export interface ReceiptInfo {
158158
readonly logsBloom: HexString256Bytes;
159159
readonly root: HexString32Bytes;
160160
readonly status: '0x1' | '0x0';
161+
readonly effectiveGasPrice: Uint;
161162
}
162163

163164
// https://github.com/ethereum/execution-apis/blob/main/src/schemas/client.json#L2

packages/web3-common/src/formatters.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ export const outputTransactionReceiptFormatter = (receipt: ReceiptInput): Receip
358358
modifiedReceipt.logs = receipt.logs.map(outputLogFormatter);
359359
}
360360

361+
if (receipt.effectiveGasPrice) {
362+
modifiedReceipt.effectiveGasPrice = hexToNumber(receipt.effectiveGasPrice);
363+
}
364+
361365
if (receipt.contractAddress) {
362366
modifiedReceipt.contractAddress = toChecksumAddress(receipt.contractAddress);
363367
}

packages/web3-common/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ export interface ReceiptInput {
174174
readonly logs?: LogsInput[];
175175
readonly contractAddress?: HexString;
176176
readonly status?: string;
177+
readonly effectiveGasPrice?: HexString;
177178
}
178179

179180
export interface ReceiptOutput {
@@ -184,6 +185,7 @@ export interface ReceiptOutput {
184185
readonly logs?: LogsOutput[];
185186
readonly contractAddress?: HexString;
186187
readonly status: boolean;
188+
readonly effectiveGasPrice?: bigint | number;
187189
}
188190

189191
export interface PostInput {

packages/web3-common/test/unit/formatters.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,20 @@ describe('formatters', () => {
391391

392392
expect(result.status).toBeFalsy();
393393
});
394+
395+
it('should convert "effectiveGasPrice" from hex to number', () => {
396+
const effectiveGasPrice = '0x80d9594d23495b';
397+
398+
const result = outputTransactionReceiptFormatter({
399+
...validReceipt,
400+
effectiveGasPrice,
401+
});
402+
403+
expect(utils.hexToNumber).toHaveBeenCalledWith(effectiveGasPrice);
404+
expect(result).toEqual(
405+
expect.objectContaining({ effectiveGasPrice: hexToNumberResult }),
406+
);
407+
});
394408
});
395409

396410
describe('outputBlockFormatter', () => {

packages/web3-eth/src/convertible_properties.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const convertibleReceiptInfoProperties: (keyof ReceiptInfo)[] = [
3535
'cumulativeGasUsed',
3636
'gasUsed',
3737
'status',
38+
'effectiveGasPrice',
3839
];
3940

4041
export const convertibleFeeHistoryResultProperties: (keyof FeeHistoryResult)[] = [

packages/web3-eth/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export interface ReceiptInfoFormatted<
205205
readonly logsBloom: HexString256Bytes;
206206
readonly root: HexString32Bytes;
207207
readonly status: ReturnType;
208+
readonly effectiveGasPrice: ReturnType;
208209
}
209210

210211
export interface BlockFormatted<

packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,6 +1339,7 @@ const receiptInfo: ReceiptInfo = {
13391339
logsBloom: '0xe21194c9509beb01be7e90c2bcefff2804cd85836ae12134f22ad4acda0fc547',
13401340
root: '0xe21194c9509beb01be7e90c2bcefff2804cd85836ae12134f22ad4acda0fc547',
13411341
status: '0x1',
1342+
effectiveGasPrice: '0x4dc4', // 19908
13421343
};
13431344
const receiptInfoNumberString: ReceiptInfoFormatted<ValidTypes.NumberString> = {
13441345
...receiptInfo,
@@ -1347,6 +1348,7 @@ const receiptInfoNumberString: ReceiptInfoFormatted<ValidTypes.NumberString> = {
13471348
cumulativeGasUsed: '13244',
13481349
gasUsed: '1244',
13491350
status: '1',
1351+
effectiveGasPrice: '19908',
13501352
};
13511353
const receiptInfoNumber: ReceiptInfoFormatted<ValidTypes.Number> = {
13521354
...receiptInfo,
@@ -1355,6 +1357,7 @@ const receiptInfoNumber: ReceiptInfoFormatted<ValidTypes.Number> = {
13551357
cumulativeGasUsed: 13244,
13561358
gasUsed: 1244,
13571359
status: 1,
1360+
effectiveGasPrice: 19908,
13581361
};
13591362
const receiptInfoBigInt: ReceiptInfoFormatted<ValidTypes.BigInt> = {
13601363
...receiptInfo,
@@ -1363,6 +1366,7 @@ const receiptInfoBigInt: ReceiptInfoFormatted<ValidTypes.BigInt> = {
13631366
cumulativeGasUsed: BigInt('13244'),
13641367
gasUsed: BigInt('1244'),
13651368
status: BigInt('1'),
1369+
effectiveGasPrice: BigInt('19908'),
13661370
};
13671371
/**
13681372
* Array consists of:

0 commit comments

Comments
 (0)