Two identical functions inside a truffle migration #5910
-
The contract VestingWallet.sol from OpenZeppelin have two functions with the same name "vestedAmount", but different parameters to call a particular function. The first one: function vestedAmount(uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(address(this).balance + released(), timestamp);
} Second: function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256) {
return _vestingSchedule(IERC20(token).balanceOf(address(this)) + released(token), timestamp);
} I'm writing a truffle migration file to see how tokens vests after one month, for example. const timestamp_Start = Math.floor(Date.now() / 1000);
const oneMonthLaterTimestamp = timestamp_Start + 30 * 24 * 60 * 60;
console.log("Vested amount after 1 month:", await myToken.vestedAmount(myToken.address, oneMonthLaterTimestamp)); It always ends with a failure: Error: value out-of-bounds (argument="timestamp", value="0x00000000000000000000000018E1Def9870DFbDB0CF4E94440104E39393B53A2", code=INVALID_ARGUMENT, version=abi/5.6.4) And so on. I'm assuming that truffle calls the first one vestedAmount function and not seeing the second with different parameters, because if I locally change the name of the function to different - it gives the correct output. How do I implement this right if I want to call the second without changing the name of the function or without commenting selection of the first one function? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Need to refer to the overloaded function, by its key in contract.methods. In my case:
|
Beta Was this translation helpful? Give feedback.
Need to refer to the overloaded function, by its key in contract.methods. In my case:
console.log("Vested amount after 1 month:", BigInt(await VestingWallet.methods['vestedAmount(address,uint64)'](myToken.address, oneMonthLaterTimestamp)));