-
Notifications
You must be signed in to change notification settings - Fork 22
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
changes to compile at 5.0 #100
base: master
Are you sure you want to change the base?
Conversation
require(curves[specifier] == 0, "Curve specifier already exists"); | ||
int256[] memory curve | ||
) public returns(address) { | ||
require(curves[specifier] == address(0) , "Curve specifier already exists"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require(curves[specifier] == 0) . could not compare and address to a uint, so casted address to zero with address(0)
contract Destructible is Ownable { | ||
function selfDestruct() public onlyOwner { | ||
selfdestruct(owner); | ||
require(owner == msg.sender); | ||
selfdestruct(msg.sender); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//was not compiling with selfdestruct(owner) added a require and changed parameter from owner to msg.sender
require(unbondAllow, "unbond not allowed"); | ||
super.unbond(msg.sender, gatewaySpecifier, quantity); | ||
super.unbond1(msg.sender, gatewaySpecifier, quantity); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspected namespacing issues so renamed function to unbond1 to prevent other bond function to be called correctly.
@@ -52,8 +52,8 @@ contract EthAdapter is ERCDotFactory { | |||
} | |||
|
|||
//Override | |||
function unbond(address wallet, bytes32 specifier, uint quantity) internal { | |||
|
|||
function unbond1(address payable wallet, bytes32 specifier, uint quantity) internal { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suspected namespacing issues so renamed function to unbond1 to prevent other bond function to be called correctly.
compiler kept throwing issue to unbond
@@ -66,10 +66,10 @@ contract EthAdapter is ERCDotFactory { | |||
//burn dot backed token | |||
tok.burnFrom(wallet, quantity); | |||
//send wallet eth | |||
wallet.transfer(reserveCost * adapterRate); | |||
address(wallet).transfer(reserveCost * adapterRate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler throwing issues to wallet.transfer
casted wallet to address(wallet) to avoid compiler error
@@ -44,23 +44,23 @@ contract EthGatedMarket is EthAdapter { | |||
gatewaySpecifier = specifier; | |||
setAdapterRate(adapterRate); | |||
bondAllow = true; | |||
return gatewayToken; | |||
return address(gatewayToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler throwing error casted to address(gatewayToken) to fix compiler error
result += to_inc; | ||
} | ||
return address(result); | ||
function bytesToAddr (bytes memory bys) public pure returns (address) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old bytesToAddr function threw error at line 140 uint c = uint(b[i]);
could not cast bytes to uint
my work around was to find another algorithm online to caste bytes to address
@@ -61,7 +61,7 @@ contract FactoryToken is FactoryTokenInterface { | |||
|
|||
string public name; | |||
string public symbol; | |||
uint8 public decimals = 3; | |||
uint8 public decimals = 18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recheck to see if this is the proper decimal?
@@ -202,7 +202,7 @@ contract Bondage is Destructible, BondageInterface, Upgradable { | |||
uint256 numZap = currentCost._costOfNDots(oracleAddress, endpoint, issued + 1, numDots - 1); | |||
|
|||
// User must have approved contract to transfer working ZAP | |||
require(token.transferFrom(msg.sender, this, numZap), "Error: User must have approved contract to transfer ZAP"); | |||
require(token.transferFrom(msg.sender, address(this), numZap), "Error: User must have approved contract to transfer ZAP"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
casted address(this) instead
function getEndpointBroker(address oracleAddress, bytes32 endpoint) public view returns (address) { | ||
return address(db.getBytes32(keccak256(abi.encodePacked('oracles', oracleAddress, endpoint, 'broker')))); | ||
function getEndpointBroker(address oracleAddress, bytes32 _endpoint) public payable returns (address) { | ||
db.setBytes32(keccak256(abi.encodePacked('oracles', oracleAddress, _endpoint, 'broker')), _endpoint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler was asking for 2 inputs when it only got 1.
changes i put was _endpoint for the second parameter and i let db.setbyte32 first before casting and returning. instead of returning in one time
db.setBytes32(keccak256(abi.encodePacked('oracles', msg.sender, endpoint, 'broker')), bytes32(broker)); | ||
|
||
|
||
db.setBytes32(keccak256(abi.encodePacked('oracles', msg.sender, endpoint, 'broker')), bytes32(uint256(broker) << 96)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler did not allow the casting of address to bytes32...
work around i found online was to cast the address to uint256 then to bytes32
|
||
emit NewCurve(msg.sender, endpoint, curve, broker); | ||
|
||
return true; | ||
} | ||
|
||
function toBytes(address a) public pure returns (bytes memory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be removed.
originally was going to add this function to convert address to bytes1 but it was not necessary.
return db.getBytesArray(keccak256(abi.encodePacked('oracles', provider, 'endpointParams', endpoint))); | ||
} | ||
|
||
/// @dev get broker address for endpoint | ||
function getEndpointBroker(address oracleAddress, bytes32 endpoint) public view returns (address) { | ||
return address(db.getBytes32(keccak256(abi.encodePacked('oracles', oracleAddress, endpoint, 'broker')))); | ||
db.getBytes32(keccak256(abi.encodePacked('oracles', oracleAddress, endpoint, 'broker'))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason the original return with casting of db.getBytes32 on the return statement did not work.
had first let db.getBytes32 process then cast the return. by returning address(db)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these changes were to fill in the new syntax and semantics for compiling in solidity 5.0 which I had done successfully on my Terminal. Other major changes I made comments on for the reviewers to determine if it were the correct fix in comparison to the master branch.
my attempt to make the zap-ethereum-api compile in solidity 5.0