Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An event signature in 'inTransaction' is incorrect if the event has a struct as an argument #178

Open
Vsevo1od opened this issue Dec 30, 2021 · 0 comments

Comments

@Vsevo1od
Copy link

Vsevo1od commented Dec 30, 2021

A quick solution is to replace this line

const eventSignature = `${eventName}(${eventABI.inputs.map(input => input.type).join(',')})`;

with

const eventSignature = `${eventName}(${eventABI.inputs.map(input => {
        if (input.type === 'tuple'){
          return `(${input.components.map(input => input.type).join()})`
        }
        return input.type;
      }
  ).join(',')})`;

At least it works in my case
An example contract that can be used to reproduce the issue

pragma solidity 0.8.7;

contract Issue {
    struct AStruct {
        uint256 someValue;
    }

    event AnEvent(AStruct aStruct);

    function doEmit() external {
        emit AnEvent(AStruct({someValue: 0}));
    }
}

A test

import {artifacts, ethers} from "hardhat";
import {expectEvent} from "@openzeppelin/test-helpers";
import {test} from "mocha";

test('is emitted', async () => {
    const [deployer] = await ethers.getSigners();
    const factory = await ethers.getContractFactory('Issue', deployer);
    const contract = await factory.deploy();

    const tx = await contract.doEmit();
    await expectEvent.inTransaction(tx.hash, artifacts.require('Issue'), 'AnEvent');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant