Skip to content

Commit 7ddecf3

Browse files
authored
support solc 6 (#766)
* support solc 6 * CommonToken * lint * bunmp version * fix compilion * add websocket * NFTManager * use infra 0.1.1-rc.20 * coverage 0.7.8 * lint * license warning
1 parent 598b81c commit 7ddecf3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2949
-3215
lines changed

.solhint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"no-simple-event-func-name": "off",
88
"two-lines-top-level-separator": "off",
99
"mark-callable-contracts": "off",
10-
"reason-string": "off"
10+
"reason-string": "off",
11+
"compiler-version": ["error","^0.6.10"]
1112
}
1213
}

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dist: trusty
33
language: node_js
44

55
node_js:
6-
- "12.16.1"
6+
- "12.18.1"
77

88
before_install:
99

@@ -31,4 +31,3 @@ jobs:
3131
name: "Solidity Test Coverage"
3232
if: branch = arc-factory
3333
script: npm run coveralls
34-

buidler.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ module.exports = {
124124
}
125125
},
126126
solc: {
127-
version: "0.5.17", // Fetch exact version from solc-bin (default: truffle's version)
127+
version: "0.6.10", // Fetch exact version from solc-bin (default: truffle's version)
128128
optimizer: {
129129
enabled: true,
130130
runs: 200

contracts/controller/Avatar.sol

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

34
import "@daostack/infra-experimental/contracts/Reputation.sol";
45
import "./DAOToken.sol";
56
import "./Vault.sol";
67
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
78
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol";
8-
import "@openzeppelin/upgrades/contracts/Initializable.sol";
99

1010

1111
/**
1212
* @title An Avatar holds tokens, reputation and ether for a controller
1313
*/
14-
contract Avatar is Initializable, Ownable {
14+
contract Avatar is Initializable, OwnableUpgradeSafe {
1515
using SafeERC20 for IERC20;
1616

1717
string public orgName;
@@ -29,10 +29,11 @@ contract Avatar is Initializable, Ownable {
2929
/**
3030
* @dev enables an avatar to receive ethers
3131
*/
32-
function() external payable {
33-
if (msg.sender != address(vault)) {
32+
/* solhint-disable */
33+
receive() external payable {
34+
if (msg.sender != address(vault)) {
3435
// solhint-disable-next-line avoid-call-value
35-
(bool success, ) = address(vault).call.value(msg.value)("");
36+
(bool success, ) = address(vault).call{value:msg.value}("");
3637
require(success, "sendEther failed.");
3738
}
3839
}
@@ -50,7 +51,8 @@ contract Avatar is Initializable, Ownable {
5051
orgName = _orgName;
5152
nativeToken = _nativeToken;
5253
nativeReputation = _nativeReputation;
53-
Ownable.initialize(_owner);
54+
__Ownable_init_unchained();
55+
transferOwnership(_owner);
5456
vault = new Vault();
5557
vault.initialize(address(this));
5658
}
@@ -60,8 +62,8 @@ contract Avatar is Initializable, Ownable {
6062
* @param _contract the contract's address to call
6163
* @param _data ABI-encoded contract call to call `_contract` address.
6264
* @param _value value (ETH) to transfer with the transaction
63-
* @return bool success or fail
64-
* bytes - the return bytes of the called contract's function.
65+
* @return success success or fail
66+
* returnValue - the return bytes of the called contract's function.
6567
*/
6668
function genericCall(address _contract, bytes calldata _data, uint256 _value)
6769
external
@@ -71,7 +73,7 @@ contract Avatar is Initializable, Ownable {
7173
vault.sendEther(_value, address(this));
7274
}
7375
// solhint-disable-next-line avoid-call-value
74-
(success, returnValue) = _contract.call.value(_value)(_data);
76+
(success, returnValue) = _contract.call{value:_value}(_data);
7577
emit GenericCall(_contract, _data, _value, success);
7678
}
7779

contracts/controller/Controller.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

34
import "./Avatar.sol";
45
import "../globalConstraints/GlobalConstraintInterface.sol";
5-
import "@openzeppelin/upgrades/contracts/Initializable.sol";
66

77

88
/**
@@ -289,7 +289,7 @@ contract Controller is Initializable {
289289
globalConstraintsPre[globalConstraintRegister.index] = globalConstraint;
290290
globalConstraintsRegisterPre[globalConstraint].index = globalConstraintRegister.index;
291291
}
292-
globalConstraintsPre.length--;
292+
globalConstraintsPre.pop();
293293
delete globalConstraintsRegisterPre[_globalConstraint];
294294
retVal = true;
295295
}
@@ -303,7 +303,7 @@ contract Controller is Initializable {
303303
globalConstraintsPost[globalConstraintRegister.index] = globalConstraint;
304304
globalConstraintsRegisterPost[globalConstraint].index = globalConstraintRegister.index;
305305
}
306-
globalConstraintsPost.length--;
306+
globalConstraintsPost.pop();
307307
delete globalConstraintsRegisterPost[_globalConstraint];
308308
retVal = true;
309309
}

contracts/controller/DAOToken.sol

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

34
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Burnable.sol";
45
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
5-
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
6-
import "@openzeppelin/upgrades/contracts/Initializable.sol";
6+
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
77

88

99
/**
1010
* @title DAOToken, base on zeppelin contract.
1111
* @dev ERC20 compatible token. It is a mintable, burnable token.
1212
*/
13-
contract DAOToken is Initializable, Ownable, ERC20, ERC20Burnable {
13+
contract DAOToken is ERC20BurnableUpgradeSafe, OwnableUpgradeSafe {
1414

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

2117
/**
@@ -27,10 +23,10 @@ contract DAOToken is Initializable, Ownable, ERC20, ERC20Burnable {
2723
function initialize(string calldata _name, string calldata _symbol, uint256 _cap, address _owner)
2824
external
2925
initializer {
30-
name = _name;
31-
symbol = _symbol;
3226
cap = _cap;
33-
Ownable.initialize(_owner);
27+
__ERC20_init_unchained(_name, _symbol);
28+
__Ownable_init_unchained();
29+
transferOwnership(_owner);
3430
}
3531

3632
/**

contracts/controller/Vault.sol

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,37 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

3-
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
4+
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
45

56

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

13+
/**
14+
* @dev initialize
15+
* @param _owner vault owner
16+
*/
17+
function initialize(address _owner)
18+
external
19+
initializer {
20+
__Ownable_init_unchained();
21+
transferOwnership(_owner);
22+
}
23+
1224
/**
1325
* @dev enables this contract to receive ethers
1426
*/
15-
function() external payable {
27+
/* solhint-disable */
28+
receive() external payable {
1629
emit ReceiveEther(msg.sender, msg.value);
1730
}
1831

1932
function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
2033
// solhint-disable-next-line avoid-call-value
21-
(bool success, ) = _to.call.value(_amountInWei)("");
34+
(bool success, ) = _to.call{value:_amountInWei}("");
2235
require(success, "sendEther failed.");
2336
emit SendEther(_to, _amountInWei);
2437
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

3-
4-
contract GlobalConstraintInterface {
4+
// solhint-disable-next-line indent
5+
abstract contract GlobalConstraintInterface {
56

67
enum CallPhase { Pre, Post, PreAndPost }
78

8-
function pre( address _scheme, bytes32 _method ) public returns(bool);
9-
function post( address _scheme, bytes32 _method ) public returns(bool);
9+
function pre( address _scheme, bytes32 _method ) public virtual returns(bool);
10+
function post( address _scheme, bytes32 _method ) public virtual returns(bool);
1011
/**
1112
* @dev when return if this globalConstraints is pre, post or both.
1213
* @return CallPhase enum indication Pre, Post or PreAndPost.
1314
*/
14-
function when() public returns(CallPhase);
15+
function when() public virtual returns(CallPhase);
1516
}

contracts/globalConstraints/TokenCapGC.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

34
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
45
import "./GlobalConstraintInterface.sol";
5-
import "@openzeppelin/upgrades/contracts/Initializable.sol";
6+
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";
7+
68

79
/**
810
* @title Token Cap Global Constraint

contracts/libs/Bytes32ToStr.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
pragma solidity ^0.5.17;
1+
pragma solidity ^0.6.10;
2+
// SPDX-License-Identifier: GPL-3.0
23

34
library Bytes32ToStr {
45
function toStr(bytes32 x) internal pure returns (string memory) {

0 commit comments

Comments
 (0)