Skip to content

Commit e47922d

Browse files
authored
build: update to Solidity 6.4 (#165)
1 parent 848a96a commit e47922d

23 files changed

+1913
-1097
lines changed

contracts/DisputeManager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.5.2;
1+
pragma solidity ^0.6.4;
22

33
/*
44
* @title Dispute management

contracts/GNS.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
pragma solidity ^0.5.2;
1+
pragma solidity ^0.6.4;
22

33
import "./Governed.sol";
44

5-
65
contract GNS is Governed {
76
/*
87
* @title Graph Name Service (GNS) contract

contracts/Governed.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pragma solidity ^0.5.2;
2-
1+
pragma solidity ^0.6.4;
32

43
contract Governed {
54
/*

contracts/GraphToken.sol

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,35 @@
1-
pragma solidity ^0.5.2;
1+
pragma solidity ^0.6.4;
2+
23
/*
34
* @title GraphToken contract
45
*
5-
* @author Bryant Eisenbach
6-
* @author Reuven Etzion
7-
*
8-
* Requirements
9-
* @req 01 The Graph Token shall implement the ERC20 Token Standard
10-
* @req 02 The Graph Token shall allow tokens staked in the protocol to be burned
11-
* @req 03 The Graph Token shall allow tokens to be minted to reward protocol participants
12-
* @req 04 The Graph Token shall only allow designated accounts the authority to mint
13-
* Note: for example, the Payment Channel Hub and Rewards Manager contracts
14-
* @req 05 The Graph Token shall allow the protocol Governance to modify the accounts that have
15-
* minting authority
16-
* @req 06 The Graph Token shall allow the protocol Governance to mint new tokens
17-
* @req 07 The Graph Token shall mint an inital distribution of tokens
18-
* @req 08 The Graph Token shall allow a token holder to stake in the protocol for indexing or
19-
* curation markets for a particular Subgraph
20-
*
216
*/
227

238
import "./Governed.sol";
24-
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol";
25-
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol";
26-
import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol";
27-
9+
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
10+
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";
2811

2912
// @imp 08 target _to of transfer(_to, _amount, _data) in Token must implement this interface
3013
// NOTE: This is based off of ERC777TokensRecipient interface, but does not fully implement it
31-
contract TokenReceiver {
14+
interface TokenReceiver {
3215
function tokensReceived(
3316
address _from,
3417
uint256 _amount,
3518
bytes calldata _data
3619
) external returns (bool);
3720
}
3821

22+
contract GraphToken is Governed, ERC20Detailed, ERC20Burnable {
23+
mapping(address => bool) private _minters;
24+
25+
// -- Events --
26+
event MinterAdded(address indexed account);
27+
event MinterRemoved(address indexed account);
3928

40-
contract GraphToken is
41-
Governed,
42-
ERC20Detailed, // @imp 01
43-
ERC20Burnable, // @imp 01, 02
44-
ERC20Mintable // @imp 01, 03, 04
45-
{
46-
// @imp 05, 06 Override so Governor can set Minters or mint tokens
4729
modifier onlyMinter() {
4830
require(
4931
isMinter(msg.sender) || msg.sender == governor,
50-
"Only minter can call."
32+
"Only minter can call"
5133
);
5234
_;
5335
}
@@ -62,22 +44,38 @@ contract GraphToken is
6244
ERC20Detailed("Graph Token", "GRT", 18)
6345
Governed(_governor)
6446
{
65-
// @imp 06 Governor is initially the sole treasurer
47+
// Governor is initially the sole treasurer
6648
_addMinter(_governor);
67-
_removeMinter(msg.sender); // Zep automagically does this, so remove...
6849

69-
// @imp 07 The Governer has the initial supply of tokens
70-
_mint(_governor, _initialSupply); // Deployment address holds all tokens
50+
// The Governor has the initial supply of tokens
51+
_mint(_governor, _initialSupply);
7152
}
7253

73-
/**
74-
* @dev Method to expose `removeToken` while using the `onlyGovernor` modifier
75-
* @param _account <address> Address of account to remove from `_minters`
76-
*/
77-
function removeMinter(address _account) public onlyGovernance {
54+
function addMinter(address _account) external onlyGovernance {
55+
_addMinter(_account);
56+
}
57+
58+
function removeMinter(address _account) external onlyGovernance {
7859
_removeMinter(_account);
7960
}
8061

62+
function isMinter(address _account) public view returns (bool) {
63+
return _minters[_account];
64+
}
65+
66+
function renounceMinter() external {
67+
_removeMinter(msg.sender);
68+
}
69+
70+
function mint(address _account, uint256 _amount)
71+
external
72+
onlyMinter
73+
returns (bool)
74+
{
75+
_mint(_account, _amount);
76+
return true;
77+
}
78+
8179
/*
8280
* @dev Transfer Graph tokens to the Staking interface
8381
* @notice Interacts with Staking contract
@@ -93,4 +91,14 @@ contract GraphToken is
9391
assert(TokenReceiver(_to).tokensReceived(msg.sender, _amount, _data));
9492
success = true;
9593
}
94+
95+
function _addMinter(address _account) internal {
96+
_minters[_account] = true;
97+
emit MinterAdded(_account);
98+
}
99+
100+
function _removeMinter(address _account) internal {
101+
_minters[_account] = false;
102+
emit MinterRemoved(_account);
103+
}
96104
}

contracts/Migrations.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pragma solidity ^0.5.2;
2-
1+
pragma solidity ^0.6.4;
32

43
contract Migrations {
54
address public owner;

contracts/MultiSigWallet.sol

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
pragma solidity ^0.5.2;
2-
1+
pragma solidity ^0.6.4;
32

43
// upgraded from solidity ^0.4.15 (Gnosis MultiSigWallet v1.3.7)
54

@@ -95,7 +94,7 @@ contract MultiSigWallet {
9594
}
9695

9796
/// @dev Fallback function allows to deposit ether.
98-
function() external payable {
97+
fallback() external payable {
9998
if (msg.value > 0) emit Deposit(msg.sender, msg.value);
10099
}
101100

@@ -143,7 +142,7 @@ contract MultiSigWallet {
143142
owners[i] = owners[owners.length - 1];
144143
break;
145144
}
146-
owners.length -= 1;
145+
owners.pop();
147146
if (required > owners.length) changeRequirement(owners.length);
148147
emit OwnerRemoval(owner);
149148
}
@@ -183,7 +182,7 @@ contract MultiSigWallet {
183182
/// @param destination Transaction target address.
184183
/// @param value Transaction ether value.
185184
/// @param data Transaction data payload.
186-
/// @return Returns transaction ID.
185+
/// @return transactionId Returns transaction ID.
187186
function submitTransaction(
188187
address destination,
189188
uint256 value,
@@ -257,7 +256,7 @@ contract MultiSigWallet {
257256
let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
258257
let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
259258
result := call(
260-
sub(gas, 34710), // 34710 is the value that solidity is currently emitting
259+
sub(gas(), 34710), // 34710 is the value that solidity is currently emitting
261260
// It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +
262261
// callNewAccountGas (25000, in case the destination address does not exist and needs creating)
263262
destination,
@@ -289,7 +288,7 @@ contract MultiSigWallet {
289288
/// @param destination Transaction target address.
290289
/// @param value Transaction ether value.
291290
/// @param data Transaction data payload.
292-
/// @return Returns transaction ID.
291+
/// @return transactionId Returns transaction ID.
293292
function addTransaction(
294293
address destination,
295294
uint256 value,
@@ -311,7 +310,7 @@ contract MultiSigWallet {
311310
*/
312311
/// @dev Returns number of confirmations of a transaction.
313312
/// @param transactionId Transaction ID.
314-
/// @return Number of confirmations.
313+
/// @return count Number of confirmations.
315314
function getConfirmationCount(uint256 transactionId)
316315
public
317316
view
@@ -324,7 +323,7 @@ contract MultiSigWallet {
324323
/// @dev Returns total number of transactions after filers are applied.
325324
/// @param pending Include pending transactions.
326325
/// @param executed Include executed transactions.
327-
/// @return Total number of transactions after filters are applied.
326+
/// @return count Total number of transactions after filters are applied.
328327
function getTransactionCount(bool pending, bool executed)
329328
public
330329
view
@@ -345,7 +344,7 @@ contract MultiSigWallet {
345344

346345
/// @dev Returns array with owner addresses, which confirmed transaction.
347346
/// @param transactionId Transaction ID.
348-
/// @return Returns array of owner addresses.
347+
/// @return _confirmations Returns array of owner addresses.
349348
function getConfirmations(uint256 transactionId)
350349
public
351350
view
@@ -368,7 +367,7 @@ contract MultiSigWallet {
368367
/// @param to Index end position of transaction array.
369368
/// @param pending Include pending transactions.
370369
/// @param executed Include executed transactions.
371-
/// @return Returns array of transaction IDs.
370+
/// @return _transactionIds Returns array of transaction IDs.
372371
function getTransactionIds(
373372
uint256 from,
374373
uint256 to,

contracts/RewardsManager.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
pragma solidity ^0.5.2;
1+
pragma solidity ^0.6.4;
22

33
import "./Governed.sol";
44

5-
65
contract RewardsManager is Governed {
76
/*
87
* @title Graph Protocol Reward Manager contract

contracts/ServiceRegistry.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
pragma solidity ^0.5.2;
1+
pragma solidity ^0.6.4;
22

33
import "./Governed.sol";
44

5-
65
contract ServiceRegistry is Governed {
76
/*
87
* @title Graph Protocol Service Registry contract

contracts/Staking.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.5.2;
1+
pragma solidity ^0.6.4;
22

33
/*
44
* @title Staking contract

0 commit comments

Comments
 (0)