Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

TypeError: Cannot read properties of ')undefined (reading '0) #51

Open
Maximesol opened this issue Nov 25, 2023 · 2 comments
Open

TypeError: Cannot read properties of ')undefined (reading '0) #51

Maximesol opened this issue Nov 25, 2023 · 2 comments

Comments

@Maximesol
Copy link

Hi every body
I am currently encountering a problem in the part of the code where we try to find the id of a proposal with this line

 const proposalId = proposeReceipt.events[0].args.proposalId

So this gives an error : TypeError: Cannot read properties of ')undefined (reading '0),

I saw a closed issue on this repo which said to do instead:

const proposalId = governor.interface.parseLog(proposeReceipt.logs[0].args.proposeId);

But this also leads to an error which is:

TypeError: Cannot read properties of undefined (reading 'topics')
    at Interface.parseLog

I hate this ethers v6 update, anyone have a solution to this? thank you so much...

@SevgiSr
Copy link

SevgiSr commented Dec 15, 2023

same issue

@milosdjurica
Copy link

Your question is not really well formatted, so I am not sure if this will help you. But here is code that works for me

JavaScript code ->

const proposalId = await proposeReceipt!.logs[0].args.proposalId;

const proposals = JSON.parse(fs.readFileSync(proposalsFilePath, "utf8"));
proposals[network.config.chainId!.toString()].push(proposalId.toString());
fs.writeFileSync(proposalsFilePath, JSON.stringify(proposals));

TypeScript code ->

const proposalId = await (proposeReceipt!.logs[0] as EventLog).args.proposalId;

const proposals = JSON.parse(fs.readFileSync(proposalsFilePath, "utf8"));
proposals[network.config.chainId!.toString()].push(proposalId.toString());
fs.writeFileSync(proposalsFilePath, JSON.stringify(proposals));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants