Skip to content

Commit f660cb2

Browse files
authored
bump Solc versions to 0.5.13 (#73)
* solc 0.5.13 * Lint Reputation.sol
1 parent 33860d0 commit f660cb2

20 files changed

+261
-236
lines changed

contracts/Migrations.sol

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

33

44
contract Migrations {

contracts/Reputation.sol

Lines changed: 47 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.5.11;
1+
pragma solidity 0.5.13;
22

33
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
44

@@ -11,7 +11,6 @@ import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
1111
* The Reputation contract maintain a map of address to reputation value.
1212
* It provides an onlyOwner functions to mint and burn reputation _to (or _from) a specific address.
1313
*/
14-
1514
contract Reputation is Ownable {
1615

1716
uint8 public decimals = 18; //Number of decimals of the smallest unit
@@ -35,60 +34,10 @@ contract Reputation is Ownable {
3534
// `balances` is the map that tracks the balance of each address, in this
3635
// contract when the balance changes the block number that the change
3736
// occurred is also included in the map
38-
mapping (address => Checkpoint[]) balances;
37+
mapping (address => Checkpoint[]) private balances;
3938

4039
// Tracks the history of the `totalSupply` of the reputation
41-
Checkpoint[] totalSupplyHistory;
42-
43-
/// @notice Constructor to create a Reputation
44-
constructor(
45-
) public
46-
{
47-
}
48-
49-
/// @dev This function makes it easy to get the total number of reputation
50-
/// @return The total number of reputation
51-
function totalSupply() public view returns (uint256) {
52-
return totalSupplyAt(block.number);
53-
}
54-
55-
////////////////
56-
// Query balance and totalSupply in History
57-
////////////////
58-
/**
59-
* @dev return the reputation amount of a given owner
60-
* @param _owner an address of the owner which we want to get his reputation
61-
*/
62-
function balanceOf(address _owner) public view returns (uint256 balance) {
63-
return balanceOfAt(_owner, block.number);
64-
}
65-
66-
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
67-
/// @param _owner The address from which the balance will be retrieved
68-
/// @param _blockNumber The block number when the balance is queried
69-
/// @return The balance at `_blockNumber`
70-
function balanceOfAt(address _owner, uint256 _blockNumber)
71-
public view returns (uint256)
72-
{
73-
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
74-
return 0;
75-
// This will return the expected balance during normal situations
76-
} else {
77-
return getValueAt(balances[_owner], _blockNumber);
78-
}
79-
}
80-
81-
/// @notice Total amount of reputation at a specific `_blockNumber`.
82-
/// @param _blockNumber The block number when the totalSupply is queried
83-
/// @return The total amount of reputation at `_blockNumber`
84-
function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {
85-
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
86-
return 0;
87-
// This will return the expected totalSupply during normal situations
88-
} else {
89-
return getValueAt(totalSupplyHistory, _blockNumber);
90-
}
91-
}
40+
Checkpoint[] private totalSupplyHistory;
9241

9342
/// @notice Generates `_amount` reputation that are assigned to `_owner`
9443
/// @param _user The address that will be assigned the new reputation
@@ -122,6 +71,49 @@ contract Reputation is Ownable {
12271
return true;
12372
}
12473

74+
/// @dev This function makes it easy to get the total number of reputation
75+
/// @return The total number of reputation
76+
function totalSupply() public view returns (uint256) {
77+
return totalSupplyAt(block.number);
78+
}
79+
80+
////////////////
81+
// Query balance and totalSupply in History
82+
////////////////
83+
/**
84+
* @dev return the reputation amount of a given owner
85+
* @param _owner an address of the owner which we want to get his reputation
86+
*/
87+
function balanceOf(address _owner) public view returns (uint256 balance) {
88+
return balanceOfAt(_owner, block.number);
89+
}
90+
91+
/// @notice Total amount of reputation at a specific `_blockNumber`.
92+
/// @param _blockNumber The block number when the totalSupply is queried
93+
/// @return The total amount of reputation at `_blockNumber`
94+
function totalSupplyAt(uint256 _blockNumber) public view returns(uint256) {
95+
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
96+
return 0;
97+
// This will return the expected totalSupply during normal situations
98+
} else {
99+
return getValueAt(totalSupplyHistory, _blockNumber);
100+
}
101+
}
102+
103+
/// @dev Queries the balance of `_owner` at a specific `_blockNumber`
104+
/// @param _owner The address from which the balance will be retrieved
105+
/// @param _blockNumber The block number when the balance is queried
106+
/// @return The balance at `_blockNumber`
107+
function balanceOfAt(address _owner, uint256 _blockNumber)
108+
public view returns (uint256)
109+
{
110+
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
111+
return 0;
112+
// This will return the expected balance during normal situations
113+
} else {
114+
return getValueAt(balances[_owner], _blockNumber);
115+
}
116+
}
125117
////////////////
126118
// Internal helper functions to query and set a value in a snapshot array
127119
////////////////
@@ -148,7 +140,7 @@ contract Reputation is Ownable {
148140
uint256 max = checkpoints.length-1;
149141
while (max > min) {
150142
uint256 mid = (max + min + 1) / 2;
151-
if (checkpoints[mid].fromBlock<=_block) {
143+
if (checkpoints[mid].fromBlock <= _block) {
152144
min = mid;
153145
} else {
154146
max = mid-1;

contracts/libs/RealMath.sol

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

33
/**
44
* RealMath: fixed-point math library, based on fractional and integer parts.

contracts/test/AbsoluteVoteExecuteMock.sol

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

33
import "../votingMachines/ProposalExecuteInterface.sol";
44
import "../votingMachines/VotingMachineCallbacksInterface.sol";

contracts/test/Debug.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.5.11;
1+
pragma solidity 0.5.13;
22
/*
33
A contract you can inherit from that has some useful Events to print statements.
44
*/

contracts/test/ERC827TokenMock.sol

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

33
import "../token/ERC827/ERC827Token.sol";// mock class using ERC827 Token
44

contracts/test/GenesisProtocolCallbacksMock.sol

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

33
import "../votingMachines/VotingMachineCallbacksInterface.sol";
44
import "../votingMachines/ProposalExecuteInterface.sol";

contracts/test/RealMathTester.sol

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

33
import "../libs/RealMath.sol";
44

contracts/token/ERC827/ERC827.sol

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

33
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
44

contracts/token/ERC827/ERC827Token.sol

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

33
import "./ERC827.sol";
44
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";

0 commit comments

Comments
 (0)