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

Problem: decodeLogs cannot find events containing structures #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/expectEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function decodeLogs (logs, emitter, eventName) {
eventABI = eventABI[0];

// The first topic will equal the hash of the event signature
const eventSignature = `${eventName}(${eventABI.inputs.map(input => input.type).join(',')})`;
const eventSignature = signature(eventName, eventABI.inputs);
const eventTopic = web3.utils.sha3(eventSignature);

// Only decode events of type 'EventName'
Expand All @@ -143,6 +143,12 @@ function decodeLogs (logs, emitter, eventName) {
.map(decoded => ({ event: eventName, args: decoded }));
}

function signature (name, inputs) {
return `${name}(${inputs.map(
input => input.type === 'tuple' ? signature('', input.components) : input.type,
).join(',')})`;
}

function contains (args, key, value) {
expect(key in args).to.equal(true, `Event argument '${key}' not found`);

Expand Down Expand Up @@ -191,11 +197,11 @@ expectEvent.notEmitted.inTransaction = notInTransaction;
expectEvent.not = {};
expectEvent.not.inConstruction = deprecate(
notInConstruction,
'expectEvent.not is deprecated. Use expectEvent.notEmitted instead.'
'expectEvent.not is deprecated. Use expectEvent.notEmitted instead.',
);
expectEvent.not.inTransaction = deprecate(
notInTransaction,
'expectEvent.not is deprecated. Use expectEvent.notEmitted instead.'
'expectEvent.not is deprecated. Use expectEvent.notEmitted instead.',
);

module.exports = expectEvent;