Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions contracts/lib/ERC20.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

contract ERC20Basic {
uint256 public totalSupply;
function balanceOf(address who) public constant returns (uint256);
function balanceOf(address who) public pure returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
Expand All @@ -11,7 +11,7 @@ contract ERC20 is ERC20Basic {
string public name;
string public symbol;
uint256 public decimals;
function allowance(address owner, address spender) public constant returns (uint256);
function allowance(address owner, address spender) public pure returns (uint256);
function transferFrom(address from, address to, uint256 value) public returns (bool);
function approve(address spender, uint256 value) public returns (bool);
event Approval(address indexed owner, address indexed spender, uint256 value);
Expand Down
9 changes: 7 additions & 2 deletions contracts/lib/lifecycle/Destructible.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "../ownership/Ownable.sol";


//was not compiling with selfdestruct(owner) added a require and changed parameter from owner to msg.sender


contract Destructible is Ownable {
function selfDestruct() public onlyOwner {
selfdestruct(owner);
require(owner == msg.sender);
selfdestruct(msg.sender);
Copy link
Author

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

}
}
2 changes: 1 addition & 1 deletion contracts/lib/ownership/Ownable.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

contract Ownable {
address public owner;
Expand Down
2 changes: 1 addition & 1 deletion contracts/lib/ownership/Upgradable.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./ZapCoordinatorInterface.sol";

Expand Down
10 changes: 5 additions & 5 deletions contracts/lib/ownership/ZapCoordinator.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./Upgradable.sol";
import "./ZapCoordinatorInterface.sol";
Expand All @@ -17,7 +17,7 @@ contract ZapCoordinator is ZapCoordinatorInterface {
DatabaseInterface public db;

// used for adding contracts like Database and ZapToken
function addImmutableContract(string contractName, address newAddress) external onlyOwner {
function addImmutableContract(string calldata contractName, address newAddress) external onlyOwner {
assert(contracts[contractName] == address(0));
contracts[contractName] = newAddress;

Expand All @@ -27,7 +27,7 @@ contract ZapCoordinator is ZapCoordinatorInterface {
}

// used for modifying an existing contract or adding a new contract to the system
function updateContract(string contractName, address newAddress) external onlyOwner {
function updateContract(string calldata contractName, address newAddress) external onlyOwner {
address prev = contracts[contractName];
if (prev == address(0) ) {
// First time adding this contract
Expand All @@ -43,11 +43,11 @@ contract ZapCoordinator is ZapCoordinatorInterface {
contracts[contractName] = newAddress;
}

function getContractName(uint index) public view returns (string) {
function getContractName(uint index) public view returns (string memory) {
return loadedContracts[index];
}

function getContract(string contractName) public view returns (address) {
function getContract(string memory contractName) public view returns (address) {
return contracts[contractName];
}

Expand Down
10 changes: 5 additions & 5 deletions contracts/lib/ownership/ZapCoordinatorInterface.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "./Ownable.sol";

contract ZapCoordinatorInterface is Ownable {
function addImmutableContract(string contractName, address newAddress) external;
function updateContract(string contractName, address newAddress) external;
function getContractName(uint index) public view returns (string);
function getContract(string contractName) public view returns (address);
function addImmutableContract(string calldata contractName, address newAddress) external;
function updateContract(string calldata contractName, address newAddress) external;
function getContractName(uint index) public view returns (string memory);
function getContract(string memory contractName) public view returns (address);
function updateAllDependencies() external;
}
76 changes: 0 additions & 76 deletions contracts/lib/platform/BTCcontest.sol

This file was deleted.

14 changes: 7 additions & 7 deletions contracts/lib/platform/Client.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

contract Client1 {
/// @dev callback that provider will call after Dispatch.query() call
/// @param id request id
/// @param response1 first provider-specified param
function callback(uint256 id, string response1) external;
function callback(uint256 id, string calldata response1) external;
}
contract Client2 {
/// @dev callback that provider will call after Dispatch.query() call
/// @param id request id
/// @param response1 first provider-specified param
/// @param response2 second provider-specified param
function callback(uint256 id, string response1, string response2) external;
function callback(uint256 id, string calldata response1, string calldata response2) external;
}
contract Client3 {
/// @dev callback that provider will call after Dispatch.query() call
/// @param id request id
/// @param response1 first provider-specified param
/// @param response2 second provider-specified param
/// @param response3 third provider-specified param
function callback(uint256 id, string response1, string response2, string response3) external;
function callback(uint256 id, string calldata response1, string calldata response2, string calldata response3) external;
}
contract Client4 {
/// @dev callback that provider will call after Dispatch.query() call
Expand All @@ -28,19 +28,19 @@ contract Client4 {
/// @param response2 second provider-specified param
/// @param response3 third provider-specified param
/// @param response4 fourth provider-specified param
function callback(uint256 id, string response1, string response2, string response3, string response4) external;
function callback(uint256 id, string calldata response1, string calldata response2, string calldata response3, string calldata response4) external;
}

contract ClientBytes32Array {
/// @dev callback that provider will call after Dispatch.query() call
/// @param id request id
/// @param response bytes32 array
function callback(uint256 id, bytes32[] response) external;
function callback(uint256 id, bytes32[] calldata response) external;
}

contract ClientIntArray{
/// @dev callback that provider will call after Dispatch.query() call
/// @param id request id
/// @param response int array
function callback(uint256 id, int[] response) external;
function callback(uint256 id, int[] calldata response) external;
}
18 changes: 9 additions & 9 deletions contracts/lib/platform/ERCDotFactory.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "../token/TokenFactoryInterface.sol";
import "../token/FactoryTokenInterface.sol";
Expand All @@ -18,7 +18,7 @@ contract ERCDotFactory is Ownable {

event DotTokenCreated(address tokenAddress);

constructor(address coordinator, address factory){
constructor(address coordinator, address factory) public {
coord = ZapCoordinatorInterface(coordinator);
reserveToken = FactoryTokenInterface(coord.getContract("ZAP_TOKEN"));
reserveToken.approve(coord.getContract("BONDAGE"), ~uint256(0));
Expand All @@ -30,9 +30,9 @@ contract ERCDotFactory is Ownable {
bytes32 providerTitle,
bytes32 specifier,
bytes32 symbol,
int256[] curve
) returns(address) {
require(curves[specifier] == 0, "Curve specifier already exists");
int256[] memory curve
) public returns(address) {
require(curves[specifier] == address(0) , "Curve specifier already exists");
Copy link
Author

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)


RegistryInterface registry = RegistryInterface(coord.getContract("REGISTRY"));
if (!registry.isProviderInitiated(address(this))) {
Expand All @@ -42,7 +42,7 @@ contract ERCDotFactory is Ownable {
registry.initiateProviderCurve(specifier, curve, address(this));
curves[specifier] = newToken(bytes32ToString(specifier), bytes32ToString(symbol));

DotTokenCreated(curves[specifier]);
emit DotTokenCreated(curves[specifier]);
return curves[specifier];
}

Expand All @@ -62,8 +62,8 @@ contract ERCDotFactory is Ownable {
}

function newToken(
string name,
string symbol
string memory name,
string memory symbol
)
public
returns (address tokenAddress)
Expand All @@ -74,7 +74,7 @@ contract ERCDotFactory is Ownable {
}

//https://ethereum.stackexchange.com/questions/2519/how-to-convert-a-bytes32-to-string
function bytes32ToString(bytes32 x) constant returns (string) {
function bytes32ToString(bytes32 x) pure public returns (string memory) {
bytes memory bytesString = new bytes(32);

bytesString = abi.encodePacked(x);
Expand Down
16 changes: 8 additions & 8 deletions contracts/lib/platform/EthAdapter.sol
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.24;
pragma solidity ^0.5.0;

import "../../platform/bondage/currentCost/CurrentCostInterface.sol";
import "./ERCDotFactory.sol";
Expand All @@ -13,7 +13,7 @@ contract EthAdapter is ERCDotFactory {

event MsgSender(address _sender);

constructor(address coordinator, address tokenFactory, uint256 rate)
constructor(address coordinator, address tokenFactory, uint256 rate) public
ERCDotFactory(coordinator, tokenFactory) {
adapterRate = rate;
}
Expand All @@ -23,12 +23,12 @@ contract EthAdapter is ERCDotFactory {
adapterRate = rate;
}

function ownerBond(address wallet, bytes32 specifier, uint numDots) payable onlyOwner {
function ownerBond(address wallet, bytes32 specifier, uint numDots) public payable onlyOwner {
emit MsgSender(msg.sender);
bond(wallet, specifier, numDots);
}

function ownerUnbond(address wallet, bytes32 specifier, uint quantity) onlyOwner {
function ownerUnbond(address wallet, bytes32 specifier, uint quantity) public onlyOwner {
unbond(wallet, specifier, quantity);
}

Expand All @@ -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 {
Copy link
Author

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

bondage = BondageInterface(coord.getContract("BONDAGE"));
uint issued = bondage.getDotsIssued(address(this), specifier);

Expand All @@ -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);
Copy link
Author

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

}

function getAdapterPrice(bytes32 specifier, uint quantity) view returns(uint){
function getAdapterPrice(bytes32 specifier, uint quantity) public payable returns(uint){
bondage = BondageInterface(coord.getContract("BONDAGE"));
uint reserveAmount = bondage.calcZapForDots(address(this), specifier, quantity);
return reserveAmount * adapterRate;
Expand Down
Loading