Events seems to now be logs, however it is not the same API and there is no information in the migration guide for this.
I'm just learning Solidity through Alchemy Uni. They seem to use Ethers5 and part of my learning process is upgrading to Ethers6. This one has me baffled:
describe("after approval from the arbiter", () => {
let before;
let receipt;
beforeEach(async () => {
before = await ethers.provider.getBalance(accounts.beneficiary.address);
let tx = await contract.connect(accounts.arbiter.signer).approve();
receipt = await tx.wait();
});
it("should emit the event", async () => {
const event = receipt.events.find(x => x.event === "Approved");
assert(event, "Expect an Approved event to be emitted!");
const amount = event.args[0];
assert.equal(
amount.toString(), deposit.toString(),
"Expected the deposit amount to be emitted in the Approved event!"
);
});
...
I can use receipt.logs to get an array, however there no longer seems to be an event (eg. Approved) and all there is is the topics. I guess I can decode them but surely there exists an easier way?
Could the migration documentation be updated to include this.
Well... Op's issue is months old and I am here struggling with the same issue here. Almost the same "find" approach failing and there is no easy way to filter events by name (or is there?).
Suggestion
Events seems to now be logs, however it is not the same API and there is no information in the migration guide for this.
I'm just learning Solidity through Alchemy Uni. They seem to use Ethers5 and part of my learning process is upgrading to Ethers6. This one has me baffled:
I can use
receipt.logs
to get an array, however there no longer seems to be anevent
(eg.Approved
) and all there is is thetopics
. I guess I can decode them but surely there exists an easier way?Could the migration documentation be updated to include this.