@graphprotocol/toolshed
Version:
A collection of tools and utilities for the Graph Protocol Typescript components
21 lines (17 loc) • 469 B
text/typescript
import type { TransactionResponse } from 'ethers'
import { ethers } from 'ethers'
export async function getEventData(tx: TransactionResponse, eventAbi: string) {
const receipt = await tx.wait()
const abi = [eventAbi]
const iface = new ethers.Interface(abi)
if (receipt?.logs === undefined) {
return []
}
for (const log of receipt.logs) {
const event = iface.parseLog(log)
if (event !== null) {
return event.args
}
}
return []
}