Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing error when calling overloaded functions in Hardhat-Ignition module. #762

Closed
SyedAsadKazmi opened this issue May 20, 2024 · 4 comments · Fixed by #774
Closed

Throwing error when calling overloaded functions in Hardhat-Ignition module. #762

SyedAsadKazmi opened this issue May 20, 2024 · 4 comments · Fixed by #774
Assignees
Labels
status:ready This issue is ready to be worked on

Comments

@SyedAsadKazmi
Copy link

Here's the minimal example:

contracts/OverloadSum.sol

contract OverloadSum {
    function sum(uint256 a, uint256 b) external pure returns (uint256) {
        return a + b;
    }

    function sum(uint256[] memory _array) external pure returns (uint256) {
        return _array[0] + _array[1];
    }
}

ignition/modules/OverloadSum.js

module.exports = buildModule("OverloadSum", (m) => {

  const overloadSum = m.contract("OverloadSum");
  
   m.call(overloadSum, "sum(uint256,uint256)", [1, 2], { id: "MyUniqueId1" })
  m.call(overloadSum, "sum(uint256[])", [[1, 2]], { id: "MyUniqueId2" })

  return { overloadSum };
});

When I'm executing this command:

npx hardhat ignition deploy ignition/modules/OverloadSum.js

Getting this error:

IgnitionError: IGN702: Module validation failed with reason: The function name "sum(uint256[])" is invalid, make sure you use a valid identifier.
@SyedAsadKazmi SyedAsadKazmi changed the title Throwing error when calling **overloaded** functions in Hardhat-Ignition module. Throwing error when calling overloaded functions in Hardhat-Ignition module. May 20, 2024
@SyedAsadKazmi
Copy link
Author

It's not working in case of array arguments though, like in my example:

m.call(overloadSum, "sum(uint256[])", [[1, 2]], { id: "MyUniqueId2" });

@kanej kanej added status:ready This issue is ready to be worked on and removed status:triaging labels May 22, 2024
@kanej
Copy link
Member

kanej commented May 22, 2024

Fixing the validation of [] should be straightforward. We need to consider how we approach the writing out of [] in to files in the deployment folder, as by default the id is generated from the function name.

@SyedAsadKazmi
Copy link
Author

Fixing the validation of [] should be straightforward. We need to consider how we approach the writing out of [] in to files in the deployment folder, as by default the id is generated from the function name.

Thanks for responding, @kanej.
So, is this something that we can achieve on our end or it requires some fixes/updates in ignition ?

@kanej
Copy link
Member

kanej commented May 28, 2024

Fixing the validation of [] should be straightforward. We need to consider how we approach the writing out of [] in to files in the deployment folder, as by default the id is generated from the function name.

Thanks for responding, @kanej. So, is this something that we can achieve on our end or it requires some fixes/updates in ignition ?

Other than using one of the other overloads for the function, I think this is something we have to fix on our end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants