Replies: 3 comments 15 replies
-
This isn’t something that is possible given the current ABI format. There is no way to know what value a given enum has, so it cannot be substituted in. I plan to add something to help with this to the human-readable ABI, but last I talked to Solidity about this, there was no plans to export that data. So for enums you must pass the number of value. :s |
Beta Was this translation helpful? Give feedback.
-
I've exactly the same problem as op. Can't pass enums as parameters to a library method, neither invoke a library method that returns an enum. In the first case it returns INVALID_ARGUMENT when passing a uint8 value (hardhat + chai). In the second case it throws 'call revert exception' at Interface.decodeFunctionResult (node_modules@ethersproject\abi\src.ts\interface.ts:425:23). |
Beta Was this translation helpful? Give feedback.
-
Truffle+web3 are able to provide, e.g. contract Withdraw {
...
enum WithdrawMode { Basic, Redeem, Settle }
} const Withdraw = artifacts.require("Withdraw");
console.log(Withdraw.WithdrawMode.Basic); // 0 How are they doing it? Enums become significantly more brittle if you have to maintain a redundant |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
When attempting to pass an enum to a function accepting an enum type parameter the following error is thrown:
Error: invalid type (argument="type", value="Test.fruit", code=INVALID_ARGUMENT, version=abi/5.5.0
Function being called: https://github.com/bgits/hardhat-enums/blob/main/contracts/Test.sol#L9
Failure point: https://github.com/bgits/hardhat-enums/blob/main/test/Test.ts#L9
Reproduction steps
A mock repo can be found here: https://github.com/bgits/hardhat-enums
test case can be run:
npx hardhat test
Environment:
This is run as part of a hardhat development environment. Full project dependencies and configuration can be found in the example repo.
Search Terms
code=INVALID_ARGUMENT
invalid type
Beta Was this translation helpful? Give feedback.
All reactions