Skip to content

Commit 1972eab

Browse files
committed
ERC20 totalSupply changed from public property to a function
Fixes #434
1 parent 9469772 commit 1972eab

11 files changed

+26
-9
lines changed

contracts/examples/SimpleToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ contract SimpleToken is StandardToken {
2222
* @dev Constructor that gives msg.sender all of existing tokens.
2323
*/
2424
function SimpleToken() public {
25-
totalSupply = INITIAL_SUPPLY;
25+
totalSupply_ = INITIAL_SUPPLY;
2626
balances[msg.sender] = INITIAL_SUPPLY;
2727
Transfer(0x0, msg.sender, INITIAL_SUPPLY);
2828
}

contracts/mocks/BasicTokenMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ contract BasicTokenMock is BasicToken {
99

1010
function BasicTokenMock(address initialAccount, uint256 initialBalance) public {
1111
balances[initialAccount] = initialBalance;
12-
totalSupply = initialBalance;
12+
totalSupply_ = initialBalance;
1313
}
1414

1515
}

contracts/mocks/BurnableTokenMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ contract BurnableTokenMock is BurnableToken {
66

77
function BurnableTokenMock(address initialAccount, uint initialBalance) public {
88
balances[initialAccount] = initialBalance;
9-
totalSupply = initialBalance;
9+
totalSupply_ = initialBalance;
1010
}
1111

1212
}

contracts/mocks/ERC23TokenMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ contract ERC23TokenMock is BasicToken {
1212

1313
function ERC23TokenMock(address initialAccount, uint256 initialBalance) public {
1414
balances[initialAccount] = initialBalance;
15-
totalSupply = initialBalance;
15+
totalSupply_ = initialBalance;
1616
}
1717

1818
// ERC23 compatible transfer function (except the name)

contracts/mocks/SafeERC20Helper.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ import '../token/ERC20.sol';
44
import '../token/SafeERC20.sol';
55

66
contract ERC20FailingMock is ERC20 {
7+
function totalSupply() public view returns (uint256) {
8+
return 0;
9+
}
10+
711
function transfer(address, uint256) public returns (bool) {
812
return false;
913
}
@@ -26,6 +30,10 @@ contract ERC20FailingMock is ERC20 {
2630
}
2731

2832
contract ERC20SucceedingMock is ERC20 {
33+
function totalSupply() public view returns (uint256) {
34+
return 0;
35+
}
36+
2937
function transfer(address, uint256) public returns (bool) {
3038
return true;
3139
}

contracts/mocks/StandardTokenMock.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ contract StandardTokenMock is StandardToken {
99

1010
function StandardTokenMock(address initialAccount, uint256 initialBalance) public {
1111
balances[initialAccount] = initialBalance;
12-
totalSupply = initialBalance;
12+
totalSupply_ = initialBalance;
1313
}
1414

1515
}

contracts/token/BasicToken.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ contract BasicToken is ERC20Basic {
1414

1515
mapping(address => uint256) balances;
1616

17+
uint256 totalSupply_;
18+
19+
/**
20+
* @dev total number of tokens in existence
21+
*/
22+
function totalSupply() public view returns (uint256) {
23+
return totalSupply_;
24+
}
25+
1726
/**
1827
* @dev transfer token for a specified address
1928
* @param _to The address to transfer to.

contracts/token/BurnableToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ contract BurnableToken is BasicToken {
2121

2222
address burner = msg.sender;
2323
balances[burner] = balances[burner].sub(_value);
24-
totalSupply = totalSupply.sub(_value);
24+
totalSupply_ = totalSupply_.sub(_value);
2525
Burn(burner, _value);
2626
}
2727
}

contracts/token/CappedToken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract CappedToken is MintableToken {
2323
* @return A boolean that indicates if the operation was successful.
2424
*/
2525
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
26-
require(totalSupply.add(_amount) <= cap);
26+
require(totalSupply_.add(_amount) <= cap);
2727

2828
return super.mint(_to, _amount);
2929
}

contracts/token/ERC20Basic.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pragma solidity ^0.4.18;
77
* @dev see https://github.com/ethereum/EIPs/issues/179
88
*/
99
contract ERC20Basic {
10-
uint256 public totalSupply;
10+
function totalSupply() public view returns (uint256);
1111
function balanceOf(address who) public view returns (uint256);
1212
function transfer(address to, uint256 value) public returns (bool);
1313
event Transfer(address indexed from, address indexed to, uint256 value);

0 commit comments

Comments
 (0)