Skip to content

Commit

Permalink
Add storage varibable #16
Browse files Browse the repository at this point in the history
  • Loading branch information
mazaletskiy committed Jan 6, 2019
1 parent 5611f5c commit 79565a3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 78 deletions.
28 changes: 23 additions & 5 deletions contracts/helpers/Whitelist.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ contract Whitelist is Ownable {

mapping(address => bool) whitelist;

bool public whitelisted = false;

/**
* @dev Modifier to make a function callable only when msg.sender is in whitelist.
*/
modifier onlyWhitelist() {
if (whitelisted == true) {
if (isWhitelisted() == true) {
require(whitelist[msg.sender] == true, "Address is not in whitelist");
}
_;
Expand All @@ -33,7 +31,7 @@ contract Whitelist is Ownable {
*/

function enableWhitelist() public onlyOwner {
whitelisted = true;
setWhitelisted(true);
emit EnableWhitelist();
}

Expand All @@ -42,7 +40,7 @@ contract Whitelist is Ownable {
* @dev called by the owner to disable whitelist
*/
function disableWhitelist() public onlyOwner {
whitelisted = false;
setWhitelisted(false);
emit DisableWhitelist();
}

Expand All @@ -61,4 +59,24 @@ contract Whitelist is Ownable {
whitelist[_address] = false;
emit RemoveFromWhitelist(_address);
}


// bool public whitelisted = false;

function setWhitelisted(bool value) internal {
bytes32 slot = keccak256(abi.encode("Whitelist", "whitelisted"));
uint256 v = value ? 1 : 0;
assembly {
sstore(slot, v)
}
}

function isWhitelisted() public view returns (bool) {
bytes32 slot = keccak256(abi.encode("Whitelist", "whitelisted"));
uint256 v;
assembly {
v := sload(slot)
}
return v != 0;
}
}
6 changes: 3 additions & 3 deletions contracts/token/AkropolisBaseToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "./dataStorage/TokenStorage.sol";
import "openzeppelin-solidity/contracts/math/SafeMath.sol";
import "openzeppelin-solidity/contracts/AddressUtils.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import '../helpers/Ownable.sol';
import "../helpers/Ownable.sol";

/**
* @title AkropolisBaseToken
Expand All @@ -20,8 +20,8 @@ contract AkropolisBaseToken is ERC20, TokenStorage, Ownable {
event Approval(address indexed owner, address indexed spender, uint256 value);


constructor (address _balances, address _allowances) public
TokenStorage(_balances, _allowances) {}
constructor (address _balances, address _allowances, string _name, uint8 _decimals, string _symbol) public
TokenStorage(_balances, _allowances, _name, _decimals, _symbol) {}

/** Modifiers **/

Expand Down
15 changes: 4 additions & 11 deletions contracts/token/TokenProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@ pragma solidity ^0.4.24;

import "./dataStorage/TokenStorage.sol";
import "zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol";
import '../helpers/Ownable.sol';
import "../helpers/Ownable.sol";
import "./dataStorage/StorageState.sol";

/**
* @title TokenProxy
* @notice A proxy contract that serves the latest implementation of TokenProxy.
*/
contract TokenProxy is UpgradeabilityProxy, TokenStorage, Ownable {

string public name; //name of Token
uint8 public decimals; //decimals of Token
string public symbol; //Symbol of Token

contract TokenProxy is UpgradeabilityProxy, TokenStorage, Ownable, StorageState {
constructor(address _implementation, address _balances, address _allowances, string _name, uint8 _decimals, string _symbol)
UpgradeabilityProxy(_implementation)
TokenStorage(_balances, _allowances) public {
name = _name;
decimals = _decimals;
symbol = _symbol;
TokenStorage(_balances, _allowances, _name, _decimals, _symbol) public {
}

/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/TokenProxyDelayed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import '../helpers/Ownable.sol';
* upgrades only after a set amount of time (denominated in blocks mined)
*/
contract TokenProxyDelayed is DelayedUpgradeabilityProxy, TokenStorage, Ownable {
constructor(address _implementation, address _balances, address _allowances)
constructor(address _implementation, address _balances, address _allowances, string _name, uint8 _decimals, string _symbol)
DelayedUpgradeabilityProxy(_implementation)
TokenStorage(_balances, _allowances) public {}
TokenStorage(_balances, _allowances, _name, _decimals, _symbol) public {}

/**
* @dev Upgrade the backing implementation of the proxy.
Expand Down
56 changes: 0 additions & 56 deletions contracts/token/dataStorage/KeyValueStorage.sol

This file was deleted.

11 changes: 10 additions & 1 deletion contracts/token/dataStorage/TokenStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ contract TokenStorage {
BalanceSheet public balances;
AllowanceSheet public allowances;


string public name; //name of Token
uint8 public decimals; //decimals of Token
string public symbol; //Symbol of Token

/**
* @dev a TokenStorage consumer can set its storages only once, on construction
*
**/
constructor (address _balances, address _allowances) public {
constructor (address _balances, address _allowances, string _name, uint8 _decimals, string _symbol) public {
balances = BalanceSheet(_balances);
allowances = AllowanceSheet(_allowances);

name = _name;
decimals = _decimals;
symbol = _symbol;
}

/**
Expand Down

0 comments on commit 79565a3

Please sign in to comment.