Misleading Handling of Multiple Entries of Function Names in a JSON ABI file #4180
Replies: 1 comment
-
This was an intentional decision. Regarding v5: Keep in mind that both are available using their fully qualified names (e.g. For v5, I generally recommended users either trim the ABI down to just the fragments they care about (also reduces the size of the app) or use the fully qualified names. But changing thing behaviour is not safe for v5. But v5 is being phased out in favour of v6... ...which, in v6, this was a big feature, where it can now use the Ethers in general has a strong stance against "guessing", especially when catastrophic things can occur from guessing. :) Does that make sense? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Ethers Version
5.6.1
Search Terms
abi json
Describe the Problem
Some of the biggest tools in web3 like hardhat and OpenZeppelin will product ABI files with multiple function outputs in the abi array, especially for when there are multiple parameter lengths. What most libraries do when they are faced with multiple entries that must be transformed into one is they either use the first or the last. Ethers uses neither which is very misleading. Using an official ABI that is output by a major source and seeing 2 ABI entries would lead someone to believe that only 1 will be used or that there is some smarter handling where the number of parameters dictates which will be used.
Instead of picking one of the functions Ethers cancels both out which gives the impression that the wrong ABI file is being ingested. This also leads to default failure when using many common ABI files.
Instead I propose that one of the functions is used, probably the first one OR just error the whole thing when there are multiple functions with the same name. That's a lot easier to debug than every other function in an ABI working except one with no reason why.
Code Snippet
No response
Contract ABI
Errors
Environment
No response
Environment (Other)
No response
Beta Was this translation helpful? Give feedback.
All reactions