TypeError: Cannot read properties of ')undefined (reading '0)
Maximesol opened this issue · 2 comments
Maximesol commented
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 commented
same issue
milosdjurica commented
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));