NomicFoundation / hardhat-ignition

Hardhat Ignition is a declarative deployment system that enables you to deploy your smart contracts without navigating the mechanics of the deployment process.
https://hardhat.org/ignition
MIT License
108 stars 26 forks source link

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

Closed SyedAsadKazmi closed 5 months ago

SyedAsadKazmi commented 6 months ago

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 commented 6 months ago

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

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

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 commented 6 months ago

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 commented 5 months ago

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.