From 32357fcf317c89c3e06b83893f358259ed8d0738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20P=C3=A9rez?= Date: Wed, 21 Feb 2024 12:53:33 +0100 Subject: [PATCH] Add OP L1 Gas fees (#145) --- src/data_sources/events/web3_updated.ts | 4 ++++ src/entities/transaction_receipt.ts | 3 +++ src/parsers/web3/parse_web3_objects.ts | 1 + 3 files changed, 8 insertions(+) diff --git a/src/data_sources/events/web3_updated.ts b/src/data_sources/events/web3_updated.ts index 88ddac81..fcae2f13 100644 --- a/src/data_sources/events/web3_updated.ts +++ b/src/data_sources/events/web3_updated.ts @@ -24,6 +24,7 @@ export interface BlockWithTransactionData extends BlockWithTransactionDataOld { export interface TransactionReceipt extends TransactionReceiptOld { effectiveGasPrice: BigNumber; + gasFeesL1: BigNumber | undefined; //OP Stack } export const outputTransactionReceiptFormatter = function (receipt: any): TransactionReceipt { @@ -38,6 +39,9 @@ export const outputTransactionReceiptFormatter = function (receipt: any): Transa if (receipt.effectiveGasPrice) { receipt.effectiveGasPrice = new BigNumber(receipt.effectiveGasPrice); } + if (receipt.l1Fee) { + receipt.gasFeesL1 = new BigNumber(receipt.l1Fee); + } if (Array.isArray(receipt.logs)) { receipt.logs = receipt.logs.map(formatter.outputLogFormatter); } diff --git a/src/entities/transaction_receipt.ts b/src/entities/transaction_receipt.ts index 73f99310..9a903a10 100644 --- a/src/entities/transaction_receipt.ts +++ b/src/entities/transaction_receipt.ts @@ -29,4 +29,7 @@ export class TransactionReceipt { // Amount of gas consumed by the tx @Column({ name: 'gas_used', type: 'numeric', transformer: bigNumberTransformer }) public gasUsed!: BigNumber; + // Amount of gas consumed by the tx in L1 (only filled when this amount is not included in the L2 gas, (like in OP stack chains) + @Column({ name: 'gas_fees_l1', type: 'numeric', transformer: bigNumberTransformer }) + public gasFeesL1!: BigNumber | null; } diff --git a/src/parsers/web3/parse_web3_objects.ts b/src/parsers/web3/parse_web3_objects.ts index 4711af3b..31a49d1e 100644 --- a/src/parsers/web3/parse_web3_objects.ts +++ b/src/parsers/web3/parse_web3_objects.ts @@ -69,6 +69,7 @@ export function parseTransactionReceipt(rawReceipt: RawReceipt): TransactionRece transactionReceipt.senderAddress = rawReceipt.from; transactionReceipt.toAddress = rawReceipt.to; transactionReceipt.gasUsed = new BigNumber(rawReceipt.gasUsed); + transactionReceipt.gasFeesL1 = rawReceipt.gasFeesL1 === undefined ? null : new BigNumber(rawReceipt.gasFeesL1); return transactionReceipt; }