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

support solc 6 #766

Merged
merged 11 commits into from
Jun 28, 2020
Merged
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
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"no-simple-event-func-name": "off",
"two-lines-top-level-separator": "off",
"mark-callable-contracts": "off",
"reason-string": "off"
"reason-string": "off",
"compiler-version": ["error","^0.6.10"]
}
}
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dist: trusty
language: node_js

node_js:
- "12.16.1"
- "12.18.1"

before_install:

Expand Down Expand Up @@ -31,4 +31,3 @@ jobs:
name: "Solidity Test Coverage"
if: branch = arc-factory
script: npm run coveralls

2 changes: 1 addition & 1 deletion buidler.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = {
}
},
solc: {
version: "0.5.17", // Fetch exact version from solc-bin (default: truffle's version)
version: "0.6.10", // Fetch exact version from solc-bin (default: truffle's version)
optimizer: {
enabled: true,
runs: 200
Expand Down
22 changes: 12 additions & 10 deletions contracts/controller/Avatar.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0

import "@daostack/infra-experimental/contracts/Reputation.sol";
import "./DAOToken.sol";
import "./Vault.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";


/**
* @title An Avatar holds tokens, reputation and ether for a controller
*/
contract Avatar is Initializable, Ownable {
contract Avatar is Initializable, OwnableUpgradeSafe {
using SafeERC20 for IERC20;

string public orgName;
Expand All @@ -29,10 +29,11 @@ contract Avatar is Initializable, Ownable {
/**
* @dev enables an avatar to receive ethers
*/
function() external payable {
if (msg.sender != address(vault)) {
/* solhint-disable */
receive() external payable {
if (msg.sender != address(vault)) {
// solhint-disable-next-line avoid-call-value
(bool success, ) = address(vault).call.value(msg.value)("");
(bool success, ) = address(vault).call{value:msg.value}("");
require(success, "sendEther failed.");
}
}
Expand All @@ -50,7 +51,8 @@ contract Avatar is Initializable, Ownable {
orgName = _orgName;
nativeToken = _nativeToken;
nativeReputation = _nativeReputation;
Ownable.initialize(_owner);
__Ownable_init_unchained();
transferOwnership(_owner);
vault = new Vault();
vault.initialize(address(this));
}
Expand All @@ -60,8 +62,8 @@ contract Avatar is Initializable, Ownable {
* @param _contract the contract's address to call
* @param _data ABI-encoded contract call to call `_contract` address.
* @param _value value (ETH) to transfer with the transaction
* @return bool success or fail
* bytes - the return bytes of the called contract's function.
* @return success success or fail
* returnValue - the return bytes of the called contract's function.
*/
function genericCall(address _contract, bytes calldata _data, uint256 _value)
external
Expand All @@ -71,7 +73,7 @@ contract Avatar is Initializable, Ownable {
vault.sendEther(_value, address(this));
}
// solhint-disable-next-line avoid-call-value
(success, returnValue) = _contract.call.value(_value)(_data);
(success, returnValue) = _contract.call{value:_value}(_data);
emit GenericCall(_contract, _data, _value, success);
}

Expand Down
8 changes: 4 additions & 4 deletions contracts/controller/Controller.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0

import "./Avatar.sol";
import "../globalConstraints/GlobalConstraintInterface.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";


/**
Expand Down Expand Up @@ -289,7 +289,7 @@ contract Controller is Initializable {
globalConstraintsPre[globalConstraintRegister.index] = globalConstraint;
globalConstraintsRegisterPre[globalConstraint].index = globalConstraintRegister.index;
}
globalConstraintsPre.length--;
globalConstraintsPre.pop();
delete globalConstraintsRegisterPre[_globalConstraint];
retVal = true;
}
Expand All @@ -303,7 +303,7 @@ contract Controller is Initializable {
globalConstraintsPost[globalConstraintRegister.index] = globalConstraint;
globalConstraintsRegisterPost[globalConstraint].index = globalConstraintRegister.index;
}
globalConstraintsPost.length--;
globalConstraintsPost.pop();
delete globalConstraintsRegisterPost[_globalConstraint];
retVal = true;
}
Expand Down
18 changes: 7 additions & 11 deletions contracts/controller/DAOToken.sol
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";


/**
* @title DAOToken, base on zeppelin contract.
* @dev ERC20 compatible token. It is a mintable, burnable token.
*/
contract DAOToken is Initializable, Ownable, ERC20, ERC20Burnable {
contract DAOToken is ERC20BurnableUpgradeSafe, OwnableUpgradeSafe {

string public name;
string public symbol;
// solhint-disable-next-line const-name-snakecase
uint8 public constant decimals = 18;
uint256 public cap;

/**
Expand All @@ -27,10 +23,10 @@ contract DAOToken is Initializable, Ownable, ERC20, ERC20Burnable {
function initialize(string calldata _name, string calldata _symbol, uint256 _cap, address _owner)
external
initializer {
name = _name;
symbol = _symbol;
cap = _cap;
Ownable.initialize(_owner);
__ERC20_init_unchained(_name, _symbol);
__Ownable_init_unchained();
transferOwnership(_owner);
}

/**
Expand Down
23 changes: 18 additions & 5 deletions contracts/controller/Vault.sol
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0

import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";


//Proxy contracts cannot recive eth via fallback function.
//For now , we will use this vault to overcome that
contract Vault is Ownable {
contract Vault is OwnableUpgradeSafe {
event ReceiveEther(address indexed _sender, uint256 _value);
event SendEther(address indexed _to, uint256 _value);

/**
* @dev initialize
* @param _owner vault owner
*/
function initialize(address _owner)
external
initializer {
__Ownable_init_unchained();
transferOwnership(_owner);
}

/**
* @dev enables this contract to receive ethers
*/
function() external payable {
/* solhint-disable */
receive() external payable {
emit ReceiveEther(msg.sender, msg.value);
}

function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
// solhint-disable-next-line avoid-call-value
(bool success, ) = _to.call.value(_amountInWei)("");
(bool success, ) = _to.call{value:_amountInWei}("");
require(success, "sendEther failed.");
emit SendEther(_to, _amountInWei);
}
Expand Down
13 changes: 7 additions & 6 deletions contracts/globalConstraints/GlobalConstraintInterface.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0


contract GlobalConstraintInterface {
// solhint-disable-next-line indent
abstract contract GlobalConstraintInterface {

enum CallPhase { Pre, Post, PreAndPost }

function pre( address _scheme, bytes32 _method ) public returns(bool);
function post( address _scheme, bytes32 _method ) public returns(bool);
function pre( address _scheme, bytes32 _method ) public virtual returns(bool);
function post( address _scheme, bytes32 _method ) public virtual returns(bool);
/**
* @dev when return if this globalConstraints is pre, post or both.
* @return CallPhase enum indication Pre, Post or PreAndPost.
*/
function when() public returns(CallPhase);
function when() public virtual returns(CallPhase);
}
6 changes: 4 additions & 2 deletions contracts/globalConstraints/TokenCapGC.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "./GlobalConstraintInterface.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";


/**
* @title Token Cap Global Constraint
Expand Down
3 changes: 2 additions & 1 deletion contracts/libs/Bytes32ToStr.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pragma solidity ^0.5.17;
pragma solidity ^0.6.10;
// SPDX-License-Identifier: GPL-3.0

library Bytes32ToStr {
function toStr(bytes32 x) internal pure returns (string memory) {
Expand Down
Loading