Hi
I am updating Ethernaut to Solidity 0.5 and I am getting this error when try to compile some levels factories (mostly the problem is when level use address payable
:
/Users/paulina/projects/ethernaut/contracts/levels/base/Level.sol:7:3: TypeError: Function overload clash during conversion to external types for arguments.
function validateInstance(address _instance, address _player) public returns (bool);
^----------------------------------------------------------------------------------^
I am looking the best way to solve this problem, any ideas?
Below I am adding sample contracts to reproduce the issue:
Fallback.sol
pragma solidity ^0.5.0;
import 'openzeppelin-solidity/contracts/math/SafeMath.sol';
contract Fallback {
using SafeMath for uint256;
mapping(address => uint) public contributions;
address payable public owner;
constructor() public {
owner = msg.sender;
contributions[msg.sender] = 1000 * (1 ether);
}
modifier onlyOwner {
require(
msg.sender == owner,
"caller is not the owner"
);
_;
}
function contribute() public payable {
require(msg.value < 0.001 ether);
contributions[msg.sender] += msg.value;
if(contributions[msg.sender] > contributions[owner]) {
owner = msg.sender;
}
}
function getContribution() public view returns (uint) {
return contributions[msg.sender];
}
function withdraw() public onlyOwner {
owner.transfer(address(this).balance);
}
function() payable external {
require(msg.value > 0 && contributions[msg.sender] > 0);
owner = msg.sender;
}
}
FallbackFactory.sol:
pragma solidity ^0.5.0;
import './base/Level.sol';
import './Fallback.sol';
contract FallbackFactory is Level {
function createInstance(address _player) public payable returns (address) {
_player;
Fallback instance = new Fallback();
return address(instance);
}
function validateInstance(address payable _instance, address _player) public returns (bool) {
Fallback instance = Fallback(_instance);
return instance.owner() == _player && address(instance).balance == 0;
}
}
Level.sol
pragma solidity ^0.5.0;
import 'openzeppelin-solidity/contracts/ownership/Ownable.sol';
contract Level is Ownable {
function createInstance(address _player) public payable returns (address);
function validateInstance(address _instance, address _player) public returns (bool);
}