solidstate-network/solidstate-solidity

Event parsing function

ItsNickBarry opened this issue · 2 comments

Draft provided by @Lumyo

import { ContractReceipt } from 'ethers';
import { Interface } from 'ethers/lib/utils';
import { LogDescription } from '@ethersproject/abi';

function getEvents(
  contractInterface: Interface,
  receipt: ContractReceipt,
) {
  const events: LogDescription[] = [];

  for (const log of receipt.logs) {
    try {
      events.push(contractInterface.parseLog(log));
    } catch (e) {}
  }

  return events;
}

This would probably go well inside the lib package or it could be hardhat-plugin 🤔 . Was there anything that stopped this from being implemented?

It should go in lib. It's blocked by the fact that lib is disorganized and lowest priority.