get value via event.args.EVENT_KEY in typescript does not work
See original GitHub issuealthough it is undocumented but event.args actually can get event property via string instead of array, for example:
// solidity
event ValueChanged(address indexed author, string oldValue, string newValue);
function setValue(string value) public {
emit ValueChanged(msg.sender, _value, value);
_value = value;
}
// javascript
const tx = await contractWithSigner.setValue("I like turtles.");
const receipt = await tx.wait();
console.log(receipt.events[0].args.newValue)
// print "I like turtles."
console.log(receipt.events[0].args[2])
// same "I like turtles."
it works in javascript but does not work in typescript since args
is defined as any[]:
export interface Event extends Log {
args?: Array<any>;
// ...
}
PR is on the way to fix it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Types of parameters 'event' and 'event' are incompatible
I have a set of buttons, and I call these buttons in another component, but when I write the code, I have this...
Read more >React events and TypeScript: a complete guide - Devtrium
Learn how to handle onClick, onChange, and many other events on React with TypeScript. It's a bit harder than you'd think but easy...
Read more >Typed event dispatcher and event handlers #5211 - GitHub
The parameter would restrict the handler to only handle one kind of event, where the detail field's type would be determined by the...
Read more >KeyboardEvent - Web APIs | MDN
Returns a boolean value that is true if the Alt ( Option or ⌥ on macOS) key was active when the key event...
Read more >Forms and Events - React TypeScript Cheatsheets
Event that occurs whenever a form or form element gets/loses focus, a form element value is changed or the form is submitted. InvalidEvent,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually just ran into this same issue yesterday and have it fixed on my local version. I’ll push the change tomorrow. 😃
Ok. I’ll close this issue too, but please re-open if you continue to have issues.
Thanks! 😃