Skip to content

Commit

Permalink
sum gasUsed in receipt if multiple evm events
Browse files Browse the repository at this point in the history
  • Loading branch information
shunjizhan committed Oct 16, 2024
1 parent 6f00def commit 3a567ed
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/eth-providers/src/utils/receiptHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,18 @@ export const findEvmEvent = (events: EventRecord[]): EventRecord | undefined =>
.reduce((r, event) => {
// For the moment the case of multiple evm events in one transaction only support Executed
if (r.event.method === 'Executed' && r.event.method === event.event.method) {
const logs = event.event.data[2] as unknown as EvmLog[];
const newLogs = (r.event.data[2] as unknown as EvmLog[]).concat(logs);
const curLogs = r.event.data[2] as unknown as EvmLog[];
const nextLogs = event.event.data[2] as unknown as EvmLog[];

r.event.data[2] = newLogs as any;
const curGasUsed = r.event.data[3] as unknown as u64;
const nextGasUsed = event.event.data[3] as unknown as u64;

// concat logs and sum gas used
r.event.data[2] = curLogs.concat(nextLogs) as any;
r.event.data[3] = curGasUsed.add(nextGasUsed) as any;

return r;
}
return r;
});
};

Expand Down

0 comments on commit 3a567ed

Please sign in to comment.