@@ -7,22 +7,31 @@ import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
77import "../helpers/Ownable.sol " ;
88
99/**
10- * @title AkropolisBaseToken
11- * @notice A basic ERC20 token with modular data storage
12- */
10+ * @title AkropolisBaseToken
11+ * @notice A basic ERC20 token with modular data storage
12+ */
1313contract AkropolisBaseToken is ERC20 , TokenStorage , Ownable {
1414 using SafeMath for uint256 ;
1515
1616 /** Events */
1717 event Mint (address indexed to , uint256 value );
1818 event MintFinished ();
19+ event MintStarted ();
1920 event Burn (address indexed burner , uint256 value );
2021 event Transfer (address indexed from , address indexed to , uint256 value );
21- event Approval (address indexed owner , address indexed spender , uint256 value );
22-
23-
24- constructor (address _balances , address _allowances , string _name , uint8 _decimals , string _symbol ) public
25- TokenStorage (_balances, _allowances, _name, _decimals, _symbol) {}
22+ event Approval (
23+ address indexed owner ,
24+ address indexed spender ,
25+ uint256 value
26+ );
27+
28+ constructor (
29+ address _balances ,
30+ address _allowances ,
31+ string _name ,
32+ uint8 _decimals ,
33+ string _symbol
34+ ) public TokenStorage (_balances, _allowances, _name, _decimals, _symbol) {}
2635
2736 /** Modifiers **/
2837
@@ -41,7 +50,6 @@ contract AkropolisBaseToken is ERC20, TokenStorage, Ownable {
4150 _burn (msg .sender , _amount);
4251 }
4352
44-
4553 function isMintingFinished () public view returns (bool ) {
4654 bytes32 slot = keccak256 (abi.encode ("Minting " , "mint " ));
4755 uint256 v;
@@ -51,7 +59,6 @@ contract AkropolisBaseToken is ERC20, TokenStorage, Ownable {
5159 return v != 0 ;
5260 }
5361
54-
5562 function setMintingFinished (bool value ) internal {
5663 bytes32 slot = keccak256 (abi.encode ("Minting " , "mint " ));
5764 uint256 v = value ? 1 : 0 ;
@@ -65,30 +72,42 @@ contract AkropolisBaseToken is ERC20, TokenStorage, Ownable {
6572 emit MintFinished ();
6673 }
6774
75+ function mintStarted () public onlyOwner {
76+ setMintingFinished (false );
77+ emit MintStarted ();
78+ }
6879
69- function approve (address _spender , uint256 _value )
70- public returns (bool ) {
80+ function approve (address _spender , uint256 _value ) public returns (bool ) {
7181 allowances.setAllowance (msg .sender , _spender, _value);
7282 emit Approval (msg .sender , _spender, _value);
7383 return true ;
7484 }
7585
7686 function transfer (address _to , uint256 _amount ) public returns (bool ) {
77- require (_to != address (0 ),"to address cannot be 0x0 " );
78- require (_amount <= balanceOf (msg .sender ),"not enough balance to transfer " );
87+ require (_to != address (0 ), "to address cannot be 0x0 " );
88+ require (
89+ _amount <= balanceOf (msg .sender ),
90+ "not enough balance to transfer "
91+ );
7992
8093 balances.subBalance (msg .sender , _amount);
8194 balances.addBalance (_to, _amount);
8295 emit Transfer (msg .sender , _to, _amount);
8396 return true ;
8497 }
8598
86- function transferFrom (address _from , address _to , uint256 _amount )
87- public returns (bool ) {
88- require (_amount <= allowance (_from, msg .sender ),"not enough allowance to transfer " );
89- require (_to != address (0 ),"to address cannot be 0x0 " );
90- require (_amount <= balanceOf (_from),"not enough balance to transfer " );
91-
99+ function transferFrom (
100+ address _from ,
101+ address _to ,
102+ uint256 _amount
103+ ) public returns (bool ) {
104+ require (
105+ _amount <= allowance (_from, msg .sender ),
106+ "not enough allowance to transfer "
107+ );
108+ require (_to != address (0 ), "to address cannot be 0x0 " );
109+ require (_amount <= balanceOf (_from), "not enough balance to transfer " );
110+
92111 allowances.subAllowance (_from, msg .sender , _amount);
93112 balances.addBalance (_to, _amount);
94113 balances.subBalance (_from, _amount);
@@ -97,31 +116,34 @@ contract AkropolisBaseToken is ERC20, TokenStorage, Ownable {
97116 }
98117
99118 /**
100- * @notice Implements balanceOf() as specified in the ERC20 standard.
101- */
119+ * @notice Implements balanceOf() as specified in the ERC20 standard.
120+ */
102121 function balanceOf (address who ) public view returns (uint256 ) {
103122 return balances.balanceOf (who);
104123 }
105124
106125 /**
107- * @notice Implements allowance() as specified in the ERC20 standard.
108- */
109- function allowance (address owner , address spender ) public view returns (uint256 ) {
126+ * @notice Implements allowance() as specified in the ERC20 standard.
127+ */
128+ function allowance (address owner , address spender )
129+ public
130+ view
131+ returns (uint256 )
132+ {
110133 return allowances.allowanceOf (owner, spender);
111134 }
112135
113136 /**
114- * @notice Implements totalSupply() as specified in the ERC20 standard.
115- */
137+ * @notice Implements totalSupply() as specified in the ERC20 standard.
138+ */
116139 function totalSupply () public view returns (uint256 ) {
117140 return balances.totalSupply ();
118141 }
119142
120-
121143 /** Internal functions **/
122144
123145 function _burn (address _tokensOf , uint256 _amount ) internal {
124- require (_amount <= balanceOf (_tokensOf),"not enough balance to burn " );
146+ require (_amount <= balanceOf (_tokensOf), "not enough balance to burn " );
125147 // no need to require value <= totalSupply, since that would imply the
126148 // sender's balance is greater than the totalSupply, which *should* be an assertion failure
127149 balances.subBalance (_tokensOf, _amount);
@@ -136,5 +158,4 @@ contract AkropolisBaseToken is ERC20, TokenStorage, Ownable {
136158 emit Mint (_to, _amount);
137159 emit Transfer (address (0 ), _to, _amount);
138160 }
139-
140- }
161+ }
0 commit comments