I have a contract with the getOwnerAddress
function that emits a OwnerReturned
event:
...
function getOwnerAddress() external returns (address) {
emit OwnerReturned("Owner");
return owner;
}
event OwnerReturned(string message);
...
I'm trying to check whether a transaction emitted an OwnerReturned
event:
let ownerTransaction = await contract.getOwnerAddress({
nonce: await signer.getNonce()
});
let ownerResult = await ownerTransaction.wait();
let ownerEvents = ownerResult.events;
if (ownerEvents !== undefined) {
let ownerReturnedEvent = ownerEvents.find(e => e.event === 'Owner');
console.log(ownerReturnedEvent);
} else {
console.log("Undefined events!");
}
The transaction executes, however the ownerEvents
is undefined.
Am I doing something wrong? How do I check if the transaction had OwnerReturned
event emitted?