Skip to content

Commit

Permalink
Add OP L1 Gas fees
Browse files Browse the repository at this point in the history
  • Loading branch information
Ktl-XV committed Feb 20, 2024
1 parent 6f6b025 commit dc74c57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/data_sources/events/web3_updated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions src/entities/transaction_receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions src/parsers/web3/parse_web3_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit dc74c57

Please sign in to comment.