I have an extended ERC20 contract with ERC827 functions, which are overrides of ERC20 with an extra callback parameter.
I have these two pairs of base/override functions:
Base:
function approve(address _spender, uint _value) public returns (bool success) { allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); return true; }
Override:
function approve(address _spender, uint _value, bytes _data) public returns (bool) { require(_spender != address(this)); super.approve(_spender, _value); require(_spender.call(_data)); return true; }
Base:
function increaseApproval(address _spender, uint _addedValue) public returns (bool) { allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); Approval(msg.sender, _spender, allowed[msg.sender][_spender]); return true; }
Override:
function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) { require(_spender != address(this)); super.increaseApproval(_spender, _addedValue); require(_spender.call(_data)); return true; }
When in unint test I make a call to approve with two arguments, it works fine, but when I make a call to increaseApproval with two arguments, it throws the following error:
Error: Invalid number of arguments to Solidity function at Object.InvalidNumberOfSolidityArgs (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:25:1) at SolidityFunction.validateArgs (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:74:1) at SolidityFunction.toPayload (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:90:1) at SolidityFunction.sendTransaction (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:163:1) at SolidityFunction.execute (/Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/function.js:256:1) at /Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:202:1 at /Users/user/.local/share/npm/lib/node_modules/truffle/build/webpack:/~/truffle-contract/contract.js:155:1 at process._tickCallback (internal/process/next_tick.js:109:7)
But if I call it with three arguments (as in its override) it works fine.
Any ideas why approve can be called as the base function (with 2 arguments) but increaseApproval fails with two arguments and wants three (as in the override)