diff --git a/packages/web3-common/src/eth_execution_api.ts b/packages/web3-common/src/eth_execution_api.ts index 97d37b40d8c..f6a21e1d1cc 100644 --- a/packages/web3-common/src/eth_execution_api.ts +++ b/packages/web3-common/src/eth_execution_api.ts @@ -158,6 +158,7 @@ export interface ReceiptInfo { readonly logsBloom: HexString256Bytes; readonly root: HexString32Bytes; readonly status: '0x1' | '0x0'; + readonly effectiveGasPrice: Uint; } // https://github.com/ethereum/execution-apis/blob/main/src/schemas/client.json#L2 diff --git a/packages/web3-common/src/formatters.ts b/packages/web3-common/src/formatters.ts index 7d2ef67f9e7..7c36bbcb21e 100644 --- a/packages/web3-common/src/formatters.ts +++ b/packages/web3-common/src/formatters.ts @@ -358,6 +358,10 @@ export const outputTransactionReceiptFormatter = (receipt: ReceiptInput): Receip modifiedReceipt.logs = receipt.logs.map(outputLogFormatter); } + if (receipt.effectiveGasPrice) { + modifiedReceipt.effectiveGasPrice = hexToNumber(receipt.effectiveGasPrice); + } + if (receipt.contractAddress) { modifiedReceipt.contractAddress = toChecksumAddress(receipt.contractAddress); } diff --git a/packages/web3-common/src/types.ts b/packages/web3-common/src/types.ts index ed173d6a521..912ed248939 100644 --- a/packages/web3-common/src/types.ts +++ b/packages/web3-common/src/types.ts @@ -174,6 +174,7 @@ export interface ReceiptInput { readonly logs?: LogsInput[]; readonly contractAddress?: HexString; readonly status?: string; + readonly effectiveGasPrice?: HexString; } export interface ReceiptOutput { @@ -184,6 +185,7 @@ export interface ReceiptOutput { readonly logs?: LogsOutput[]; readonly contractAddress?: HexString; readonly status: boolean; + readonly effectiveGasPrice?: bigint | number; } export interface PostInput { diff --git a/packages/web3-common/test/unit/formatters.test.ts b/packages/web3-common/test/unit/formatters.test.ts index 35158f4d55e..fa9737fe182 100644 --- a/packages/web3-common/test/unit/formatters.test.ts +++ b/packages/web3-common/test/unit/formatters.test.ts @@ -391,6 +391,20 @@ describe('formatters', () => { expect(result.status).toBeFalsy(); }); + + it('should convert "effectiveGasPrice" from hex to number', () => { + const effectiveGasPrice = '0x80d9594d23495b'; + + const result = outputTransactionReceiptFormatter({ + ...validReceipt, + effectiveGasPrice, + }); + + expect(utils.hexToNumber).toHaveBeenCalledWith(effectiveGasPrice); + expect(result).toEqual( + expect.objectContaining({ effectiveGasPrice: hexToNumberResult }), + ); + }); }); describe('outputBlockFormatter', () => { diff --git a/packages/web3-eth/src/convertible_properties.ts b/packages/web3-eth/src/convertible_properties.ts index cf6dc9775b2..f836f165716 100644 --- a/packages/web3-eth/src/convertible_properties.ts +++ b/packages/web3-eth/src/convertible_properties.ts @@ -35,6 +35,7 @@ export const convertibleReceiptInfoProperties: (keyof ReceiptInfo)[] = [ 'cumulativeGasUsed', 'gasUsed', 'status', + 'effectiveGasPrice', ]; export const convertibleFeeHistoryResultProperties: (keyof FeeHistoryResult)[] = [ diff --git a/packages/web3-eth/src/types.ts b/packages/web3-eth/src/types.ts index a7b41b1000c..af0aa6b146b 100644 --- a/packages/web3-eth/src/types.ts +++ b/packages/web3-eth/src/types.ts @@ -205,6 +205,7 @@ export interface ReceiptInfoFormatted< readonly logsBloom: HexString256Bytes; readonly root: HexString32Bytes; readonly status: ReturnType; + readonly effectiveGasPrice: ReturnType; } export interface BlockFormatted< diff --git a/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts b/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts index d400a3d84fd..204c31bc216 100644 --- a/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts +++ b/packages/web3-eth/test/fixtures/rpc_methods_wrappers.ts @@ -1339,6 +1339,7 @@ const receiptInfo: ReceiptInfo = { logsBloom: '0xe21194c9509beb01be7e90c2bcefff2804cd85836ae12134f22ad4acda0fc547', root: '0xe21194c9509beb01be7e90c2bcefff2804cd85836ae12134f22ad4acda0fc547', status: '0x1', + effectiveGasPrice: '0x4dc4', // 19908 }; const receiptInfoNumberString: ReceiptInfoFormatted = { ...receiptInfo, @@ -1347,6 +1348,7 @@ const receiptInfoNumberString: ReceiptInfoFormatted = { cumulativeGasUsed: '13244', gasUsed: '1244', status: '1', + effectiveGasPrice: '19908', }; const receiptInfoNumber: ReceiptInfoFormatted = { ...receiptInfo, @@ -1355,6 +1357,7 @@ const receiptInfoNumber: ReceiptInfoFormatted = { cumulativeGasUsed: 13244, gasUsed: 1244, status: 1, + effectiveGasPrice: 19908, }; const receiptInfoBigInt: ReceiptInfoFormatted = { ...receiptInfo, @@ -1363,6 +1366,7 @@ const receiptInfoBigInt: ReceiptInfoFormatted = { cumulativeGasUsed: BigInt('13244'), gasUsed: BigInt('1244'), status: BigInt('1'), + effectiveGasPrice: BigInt('19908'), }; /** * Array consists of: