Question: Warnings raised when there are Events with the same name but different inputs?
See original GitHub issueOn ethers
5.0.2
Given the following ABI with two Transfer
events with different inputs:
{
"abi": [
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
},
{
"indexed": false,
"name": "data",
"type": "bytes"
}
],
"name": "Transfer",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"name": "from",
"type": "address"
},
{
"indexed": true,
"name": "to",
"type": "address"
},
{
"indexed": false,
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
]
}
In contract form this would look like:
contract Test {
event Transfer(address indexed from, address indexed to, uint256 value);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
When calling the above contract, ethers@5.02
logs the following warning:
Duplicate definition of Transfer
(Transfer(address,address,uint256,bytes),
Transfer(address,address,uint256))
Why do we warn users for having Events with duplicate names? I would expect that the intention is to check for duplicate Event signatures, for example:
- [
Transfer(address,address,uint256,bytes)
,Transfer(address,address,uint256)
] is OK 👍 since they have different event signatures. - [
Transfer(address,address,uint256,bytes)
,Transfer(address,address,uint256,bytes)
] is NOT OK 👎 because they have duplicate event signatures.
Is this because of the events API expecting an event name?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Events: change, input, cut, copy, paste
Let's cover various events that accompany data updates. Event: change. The change event triggers when the element has finished changing.
Read more >Warnings in Python - GeeksforGeeks
Usually, a warning occurs when there is some obsolete of certain programming elements, such as keyword, function or class, etc. A warning in...
Read more >Advanced Callbacks | Dash for Python Documentation | Plotly
Useful when multiple inputs can trigger the callback at the same time, or multiple properties of the same component can trigger the callback....
Read more >In Python, how does one catch warnings as if they were ...
To handle warnings as errors simply use this: import warnings warnings.filterwarnings("error"). After this you will be able to catch warnings same as errors ......
Read more >Event handling (overview) - Event reference - MDN Web Docs
Programmers can create event handler code that will run when an event ... Warning: A third approach for setting event handlers using HTML ......
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
The main reason is because of how you would access them. If you have a single
Transfer
event, then you could usecontract.events.Transfer
to get the Transfer fragment. But if there are multiple, you need to usecontract.events["Transfer(address, address,uint256"]
for example.Many of these issues go away in v6 which will use a Proxy, but for now this is something there isn’t a great way around. You can always lower the Logger logLevel to
error
if the console logs are too much an issue. 😃Well could you please at least create a setting for disabling this warning on ES3? The user should be able to decide whether they care about it or not. I have hundreds of lines of this warning in my test output, and that obscures legitimate test output.