Add proper Token contract
This commit is contained in:
parent
68fb8b2bee
commit
f0211ff4c1
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
build
|
||||
node_modules
|
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
var Registry = artifacts.require('./Registry.sol');
|
||||
var Token = artifacts.require('./Token1.sol');
|
||||
var Token = artifacts.require('./Token.sol');
|
||||
|
||||
module.exports = function(deployer) {
|
||||
deployer.deploy(Token).then(function(token) {
|
@ -1,14 +0,0 @@
|
||||
var Token = artifacts.require('./Token2.sol');
|
||||
var Registry = artifacts.require('./upgradeable/Registry');
|
||||
var UpgradeabilityProxy = artifacts.require('./upgradeable/UpgradeabilityProxy');
|
||||
|
||||
module.exports = function(deployer) {
|
||||
deployer.deploy(Token).then(function(t) {
|
||||
return Token.deployed();
|
||||
}).then(function(token) {
|
||||
Registry.deployed().then(function(registry) {
|
||||
console.log('Token address: ', Token.address);
|
||||
registry.addVersion('Token', Token.address);
|
||||
});
|
||||
})
|
||||
};
|
64
package-lock.json
generated
Normal file
64
package-lock.json
generated
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "kredits-contracts",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"bn.js": {
|
||||
"version": "4.11.6",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
||||
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz",
|
||||
"integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0="
|
||||
},
|
||||
"ethjs-abi": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz",
|
||||
"integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=",
|
||||
"requires": {
|
||||
"bn.js": "4.11.6",
|
||||
"js-sha3": "0.5.5",
|
||||
"number-to-bn": "1.7.0"
|
||||
}
|
||||
},
|
||||
"is-hex-prefixed": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz",
|
||||
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ="
|
||||
},
|
||||
"js-sha3": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz",
|
||||
"integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko="
|
||||
},
|
||||
"number-to-bn": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz",
|
||||
"integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=",
|
||||
"requires": {
|
||||
"bn.js": "4.11.6",
|
||||
"strip-hex-prefix": "1.0.0"
|
||||
}
|
||||
},
|
||||
"strip-hex-prefix": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz",
|
||||
"integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=",
|
||||
"requires": {
|
||||
"is-hex-prefixed": "1.0.0"
|
||||
}
|
||||
},
|
||||
"zeppelin-solidity": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/zeppelin-solidity/-/zeppelin-solidity-1.7.0.tgz",
|
||||
"integrity": "sha512-tb2GsrdbWlPoZGwhd1uAN82L3BwkH+tjtbX9a4L+3SBcfKlkn3WzcMTeYVtiTA1S1LZEGQBGsEwqLQk5w/Y8cw==",
|
||||
"requires": {
|
||||
"dotenv": "4.0.0",
|
||||
"ethjs-abi": "0.2.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
package.json
Normal file
25
package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "kredits-contracts",
|
||||
"version": "1.0.0",
|
||||
"description": "Ethereum contracts and npm wrapper for Kredits",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/67P/truffle-kredits.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/67P/truffle-kredits/issues"
|
||||
},
|
||||
"homepage": "https://github.com/67P/truffle-kredits#readme",
|
||||
"dependencies": {
|
||||
"zeppelin-solidity": "^1.7.0"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user