Add proper Token contract
This commit is contained in:
33
contracts/Token.sol
Normal file
33
contracts/Token.sol
Normal file
@@ -0,0 +1,33 @@
|
||||
pragma solidity ^0.4.18;
|
||||
|
||||
import 'zeppelin-solidity/contracts/token/ERC20/BasicToken.sol';
|
||||
import './upgradeable/Upgradeable.sol';
|
||||
|
||||
contract Token is Upgradeable, BasicToken {
|
||||
string public name;
|
||||
string public symbol;
|
||||
uint8 public decimals;
|
||||
|
||||
event LogMint(address indexed recipient, uint256 amount, string reference);
|
||||
|
||||
modifier requireRegistry() {
|
||||
require(address(registry) != 0x0);
|
||||
_;
|
||||
}
|
||||
|
||||
function initialize(address sender) public payable {
|
||||
require(msg.sender == address(registry));
|
||||
name = 'Kredits';
|
||||
symbol = 'K';
|
||||
decimals = 18;
|
||||
}
|
||||
|
||||
function mintFor(address _recipient, uint256 _amount, string _reference) requireRegistry returns (bool success) {
|
||||
totalSupply_ = totalSupply_.add(_amount);
|
||||
balances[_recipient] = balances[_recipient].add(_amount);
|
||||
|
||||
LogMint(_recipient, _amount, _reference);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
pragma solidity ^0.4.4;
|
||||
|
||||
import './upgradeable/Upgradeable.sol';
|
||||
|
||||
contract Token1 is Upgradeable {
|
||||
|
||||
uint public value = 0;
|
||||
|
||||
function mint() public {
|
||||
value += 10;
|
||||
}
|
||||
|
||||
function initialize(address sender) public payable {
|
||||
value = 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
pragma solidity ^0.4.4;
|
||||
|
||||
import './Token1.sol';
|
||||
|
||||
contract Token2 is Token1 {
|
||||
|
||||
function mint() public {
|
||||
value += 20;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,6 +52,11 @@ contract Registry is IRegistry {
|
||||
ProxyImplementationUpgraded(name, version);
|
||||
}
|
||||
|
||||
function upgradeToLatest(bytes32 name) public {
|
||||
uint current = currentVersions[name];
|
||||
upgrade(name, current);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Creates an upgradeable proxy
|
||||
* @param name of the contract
|
||||
|
||||
@@ -25,12 +25,4 @@ contract UpgradeabilityProxy is Proxy, UpgradeabilityStorage {
|
||||
_implementation = registry.getVersion(_proxiedContractName, _version);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Upgrades the implementation to the latest version
|
||||
*/
|
||||
function upgradeToLatest() public {
|
||||
require(msg.sender == address(registry));
|
||||
_implementation = registry.getLatestVersion(_proxiedContractName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user