mirror of
https://github.com/status-im/contracts.git
synced 2025-02-22 19:48:44 +00:00
update contracts, embark and add Status Network contracts
This commit is contained in:
parent
b3b4d54e49
commit
66d593c859
63
config/blockchain.js
Normal file
63
config/blockchain.js
Normal file
@ -0,0 +1,63 @@
|
||||
module.exports = {
|
||||
development: {
|
||||
enabled: true,
|
||||
networkType: "custom", // Can be: testnet, rinkeby, livenet or custom, in which case, it will use the specified networkId
|
||||
networkId: "1337", // Network id used when networkType is custom
|
||||
isDev: true, // Uses and ephemeral proof-of-authority network with a pre-funded developer account, mining enabled
|
||||
genesisBlock: "config/development/genesis.json", // Genesis block to initiate on first creation of a development node
|
||||
datadir: ".embark/development/datadir", // Data directory for the databases and keystore
|
||||
mineWhenNeeded: true, // Uses our custom script (if isDev is false) to mine only when needed
|
||||
nodiscover: true, // Disables the peer discovery mechanism (manual peer addition)
|
||||
maxpeers: 0, // Maximum number of network peers (network disabled if set to 0) (default: 25)
|
||||
rpcHost: "localhost", // HTTP-RPC server listening interface (default: "localhost")
|
||||
rpcPort: 8545, // HTTP-RPC server listening port (default: 8545)
|
||||
rpcCorsDomain: "*", // Comma separated list of domains from which to accept cross origin requests (browser enforced)
|
||||
// When set to "auto", Embark will automatically set the cors to the address of the webserver
|
||||
proxy: true, // Proxy is used to present meaningful information about transactions
|
||||
account: {
|
||||
// "address": "", // When specified, uses that address instead of the default one for the network
|
||||
password: "config/development/password" // Password to unlock the account
|
||||
},
|
||||
targetGasLimit: 8000000, // Target gas limit sets the artificial target gas floor for the blocks to mine
|
||||
wsRPC: true, // Enable the WS-RPC server
|
||||
wsOrigins: "*", // Origins from which to accept websockets requests
|
||||
// When set to "auto", Embark will automatically set the cors to the address of the webserver
|
||||
wsHost: "localhost", // WS-RPC server listening interface (default: "localhost")
|
||||
wsPort: 8546, // WS-RPC server listening port (default: 8546)
|
||||
simulatorMnemonic: "example exile argue silk regular smile grass bomb merge arm assist farm", // Mnemonic used by the simulator to generate a wallet
|
||||
simulatorBlocktime: 0 // Specify blockTime in seconds for automatic mining. Default is 0 and no auto-mining.
|
||||
},
|
||||
testnet: {
|
||||
enabled: true,
|
||||
networkType: "testnet",
|
||||
syncMode: "light",
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: "http://localhost:8000",
|
||||
account: {
|
||||
password: "config/testnet/.password"
|
||||
}
|
||||
},
|
||||
livenet: {
|
||||
enabled: false,
|
||||
networkType: "livenet",
|
||||
syncMode: "light",
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: "http://localhost:8000",
|
||||
account: {
|
||||
password: "config/livenet/.password"
|
||||
}
|
||||
},
|
||||
rinkeby: {
|
||||
enabled: true,
|
||||
networkType: "rinkeby",
|
||||
syncMode: "light",
|
||||
rpcHost: "localhost",
|
||||
rpcPort: 8545,
|
||||
rpcCorsDomain: "http://localhost:8000",
|
||||
account: {
|
||||
password: "config/rinkeby/.password"
|
||||
}
|
||||
}
|
||||
};
|
@ -1,56 +0,0 @@
|
||||
{
|
||||
"development": {
|
||||
"enabled": true,
|
||||
"networkType": "custom",
|
||||
"genesisBlock": "config/development/genesis.json",
|
||||
"datadir": ".embark/development/datadir",
|
||||
"mineWhenNeeded": true,
|
||||
"nodiscover": true,
|
||||
"maxpeers": 0,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"account": {
|
||||
"password": "config/development/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "http://localhost:8000",
|
||||
"wsRPC": true,
|
||||
"wsHost": "localhost",
|
||||
"wsPort": 8546,
|
||||
"simulatorMnemonic": "example exile argue silk regular smile grass bomb merge arm assist farm",
|
||||
"simulatorBlocktime": 0
|
||||
},
|
||||
"testnet": {
|
||||
"enabled": true,
|
||||
"networkType": "testnet",
|
||||
"light": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"account": {
|
||||
"password": "config/testnet/password"
|
||||
}
|
||||
},
|
||||
"livenet": {
|
||||
"enabled": true,
|
||||
"networkType": "livenet",
|
||||
"light": true,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"account": {
|
||||
"password": "config/livenet/password"
|
||||
}
|
||||
},
|
||||
"privatenet": {
|
||||
"enabled": true,
|
||||
"networkType": "custom",
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"datadir": "yourdatadir",
|
||||
"networkId": "123",
|
||||
"bootnodes": ""
|
||||
}
|
||||
}
|
13
config/communication.js
Normal file
13
config/communication.js
Normal file
@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
default: {
|
||||
enabled: true,
|
||||
provider: "whisper", // Communication provider. Currently, Embark only supports whisper
|
||||
available_providers: ["whisper"], // Array of available providers
|
||||
connection: {
|
||||
host: "localhost", // Host of the blockchain node
|
||||
port: 8546, // Port of the blockchain node
|
||||
type: "ws" // Type of connection (ws or rpc)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"default": {
|
||||
"enabled": true,
|
||||
"provider": "whisper",
|
||||
"available_providers": ["whisper", "orbit"],
|
||||
"connection": {
|
||||
"host": "localhost",
|
||||
"port": 8546,
|
||||
"type": "ws"
|
||||
}
|
||||
}
|
||||
}
|
95
config/contracts.js
Normal file
95
config/contracts.js
Normal file
@ -0,0 +1,95 @@
|
||||
module.exports = {
|
||||
// default applies to all environments
|
||||
default: {
|
||||
// Blockchain node to deploy the contracts
|
||||
deployment: {
|
||||
host: "localhost", // Host of the blockchain node
|
||||
port: 8545, // Port of the blockchain node
|
||||
type: "rpc" // Type of connection (ws or rpc),
|
||||
},
|
||||
// order of connections the dapp should connect to
|
||||
dappConnection: [
|
||||
"$WEB3", // uses pre existing web3 object if available (e.g in Mist)
|
||||
"ws://localhost:8546",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
gas: "auto",
|
||||
contracts: {
|
||||
"ERC20Receiver": {"deploy": false},
|
||||
"SafeMath": {"deploy": false},
|
||||
|
||||
"MiniMeTokenFactory": {},
|
||||
"MiniMeToken": {
|
||||
"args":["$MiniMeTokenFactory", "0x0", "0x0", "Status Test Token", 18, "STT", true],
|
||||
},
|
||||
|
||||
"StatusNetwork": {"deploy": false},
|
||||
"TestStatusNetwork": {"deploy": false},
|
||||
"StatusRoot": {
|
||||
"instanceOf": "TestStatusNetwork",
|
||||
"deploy": true,
|
||||
"args": ["0x0", "$MiniMeToken"],
|
||||
"onDeploy": [
|
||||
"await MiniMeToken.methods.changeController(StatusRoot.address).send()",
|
||||
"await StatusRoot.methods.setOpen(true).send()",
|
||||
]
|
||||
},
|
||||
|
||||
"VisibilityStake": {
|
||||
"args":["$MiniMeToken", "31104000"],
|
||||
},
|
||||
"GroupAccess": {
|
||||
"args":["$MiniMeToken"],
|
||||
},
|
||||
"MessageTribute": {
|
||||
"args":["10000000000000000000"],
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
development: {
|
||||
deployment: {
|
||||
accounts: [
|
||||
{
|
||||
privateKey: "b2ab40d549e67ba67f278781fec03b3a90515ad4d0c898a6326dd958de1e46fa",
|
||||
balance: "5 ether" // You can set the balance of the account in the dev environment
|
||||
// Balances are in Wei, but you can specify the unit with its name
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
testnet: {
|
||||
contracts: {
|
||||
"MiniMeTokenFactory": {
|
||||
"deploy": false,
|
||||
"address": "0x6bFa86A71A7DBc68566d5C741F416e3009804279"
|
||||
},
|
||||
"MiniMeToken": {
|
||||
"deploy": false,
|
||||
"address": "0xc55cF4B03948D7EBc8b9E8BAD92643703811d162"
|
||||
},
|
||||
"StatusRoot": {
|
||||
"instanceOf": "TestStatusNetwork",
|
||||
"deploy": false,
|
||||
"address": "0x34358C45FbA99ef9b78cB501584E8cBFa6f85Cef"
|
||||
}
|
||||
}
|
||||
},
|
||||
rinkeby: {
|
||||
contracts: {
|
||||
"MiniMeTokenFactory": {
|
||||
"deploy": false,
|
||||
"address": "0x5bA5C786845CaacD45f5952E1135F4bFB8855469"
|
||||
},
|
||||
"MiniMeToken": {
|
||||
"deploy": false,
|
||||
"address": "0x43d5adC3B49130A575ae6e4b00dFa4BC55C71621"
|
||||
},
|
||||
"StatusRoot": {
|
||||
"instanceOf": "TestStatusNetwork",
|
||||
"deploy": false,
|
||||
"address": "0xEdEB948dE35C6ac414359f97329fc0b4be70d3f1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
"default": {
|
||||
"versions": {
|
||||
"web3.js": "1.0.0-beta",
|
||||
"solc": "0.4.23"
|
||||
},
|
||||
"deployment": {
|
||||
"host": "localhost",
|
||||
"port": 8545,
|
||||
"type": "rpc"
|
||||
},
|
||||
"dappConnection": [
|
||||
"$WEB3",
|
||||
"http://localhost:8545"
|
||||
],
|
||||
"gas": "auto",
|
||||
"contracts": {
|
||||
"Controlled": {"deploy": false},
|
||||
"Owned": {"deploy": false},
|
||||
"SafeMath": {"deploy": false},
|
||||
"MessageTribute": {"deploy": false},
|
||||
"MiniMeTokenFactory": {"deploy": false},
|
||||
"MiniMeToken": {"deploy": false}
|
||||
}
|
||||
}
|
||||
}
|
6
config/namesystem.js
Normal file
6
config/namesystem.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
default: {
|
||||
available_providers: ["ens"],
|
||||
provider: "ens"
|
||||
}
|
||||
};
|
35
config/storage.js
Normal file
35
config/storage.js
Normal file
@ -0,0 +1,35 @@
|
||||
module.exports = {
|
||||
default: {
|
||||
enabled: true,
|
||||
ipfs_bin: "ipfs",
|
||||
provider: "ipfs",
|
||||
available_providers: ["ipfs"],
|
||||
upload: {
|
||||
host: "localhost",
|
||||
port: 5001
|
||||
},
|
||||
dappConnection: [
|
||||
{
|
||||
provider: "ipfs",
|
||||
host: "localhost",
|
||||
port: 5001,
|
||||
getUrl: "http://localhost:8080/ipfs/"
|
||||
}
|
||||
]
|
||||
// Configuration to start Swarm in the same terminal as `embark run`
|
||||
/*,account: {
|
||||
address: "YOUR_ACCOUNT_ADDRESS", // Address of account accessing Swarm
|
||||
password: "PATH/TO/PASSWORD/FILE" // File containing the password of the account
|
||||
},
|
||||
swarmPath: "PATH/TO/SWARM/EXECUTABLE" // Path to swarm executable (default: swarm)*/
|
||||
},
|
||||
development: {
|
||||
enabled: true,
|
||||
provider: "ipfs",
|
||||
upload: {
|
||||
host: "localhost",
|
||||
port: 5001,
|
||||
getUrl: "http://localhost:8080/ipfs/"
|
||||
}
|
||||
}
|
||||
};
|
@ -1,20 +0,0 @@
|
||||
{
|
||||
"default": {
|
||||
"versions": {
|
||||
"ipfs-api": "17.2.4"
|
||||
},
|
||||
"enabled": true,
|
||||
"ipfs_bin": "ipfs",
|
||||
"provider": "ipfs",
|
||||
"available_providers": ["ipfs"],
|
||||
"host": "localhost",
|
||||
"port": 5001
|
||||
},
|
||||
"development": {
|
||||
"enabled": true,
|
||||
"provider": "ipfs",
|
||||
"host": "localhost",
|
||||
"port": 5001,
|
||||
"getUrl": "http://localhost:8080/ipfs/"
|
||||
}
|
||||
}
|
5
config/webserver.js
Normal file
5
config/webserver.js
Normal file
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
enabled: true,
|
||||
host: "localhost",
|
||||
port: 8000
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
{
|
||||
"enabled": true,
|
||||
"host": "localhost",
|
||||
"port": 8000
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
contract Controlled {
|
||||
/// @notice The address of the controller is the only address that can call
|
||||
|
@ -1,13 +1,11 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
/**
|
||||
* @notice Uses ethereum signed messages
|
||||
*/
|
||||
contract MessageSigned {
|
||||
|
||||
constructor() internal {
|
||||
|
||||
}
|
||||
constructor() internal {}
|
||||
|
||||
/**
|
||||
* @notice recovers address who signed the message
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
/// @dev `Owned` is a base level contract that assigns an `owner` that can be
|
||||
/// later changed
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
/**
|
||||
* Math operations with safety checks
|
||||
|
90
contracts/status/SNTController.sol
Normal file
90
contracts/status/SNTController.sol
Normal file
@ -0,0 +1,90 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "../token/TokenController.sol";
|
||||
import "../common/Owned.sol";
|
||||
import "../token/ERC20Token.sol";
|
||||
import "../token/MiniMeToken.sol";
|
||||
/**
|
||||
* @title SNTController
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
* @notice enables economic abstraction for SNT
|
||||
*/
|
||||
contract SNTController is TokenController, Owned {
|
||||
|
||||
MiniMeToken public snt;
|
||||
|
||||
event ClaimedTokens(address indexed _token, address indexed _controller, uint256 _amount);
|
||||
event ControllerChanged(address indexed _newController);
|
||||
|
||||
/**
|
||||
* @notice Constructor
|
||||
* @param _owner Authority address
|
||||
* @param _snt SNT token
|
||||
*/
|
||||
constructor(address payable _owner, MiniMeToken _snt) internal {
|
||||
if(_owner != address(0)){
|
||||
owner = _owner;
|
||||
}
|
||||
snt = _snt;
|
||||
}
|
||||
/**
|
||||
* @notice The owner of this contract can change the controller of the SNT token
|
||||
* Please, be sure that the owner is a trusted agent or 0x0 address.
|
||||
* @param _newController The address of the new controller
|
||||
*/
|
||||
function changeController(address payable _newController) public onlyOwner {
|
||||
snt.changeController(_newController);
|
||||
emit ControllerChanged(_newController);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice This method can be used by the controller to extract mistakenly
|
||||
* sent tokens to this contract.
|
||||
* @param _token The address of the token contract that you want to recover
|
||||
* set to 0 in case you want to extract ether.
|
||||
*/
|
||||
function claimTokens(address _token) public onlyOwner {
|
||||
if (snt.controller() == address(this)) {
|
||||
snt.claimTokens(_token);
|
||||
}
|
||||
if (_token == address(0)) {
|
||||
address(owner).transfer(address(this).balance);
|
||||
return;
|
||||
}
|
||||
|
||||
ERC20Token token = ERC20Token(_token);
|
||||
uint256 balance = token.balanceOf(address(this));
|
||||
token.transfer(owner, balance);
|
||||
emit ClaimedTokens(_token, owner, balance);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice payment by address coming from controlled token
|
||||
* @dev In between the offering and the network. Default settings for allowing token transfers.
|
||||
*/
|
||||
function proxyPayment(address) external payable returns (bool) {
|
||||
//Uncomment above line when using parameters
|
||||
//require(msg.sender == address(snt), "Unauthorized");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice register and authorizes transfer from token
|
||||
* @dev called by snt when a transfer is made
|
||||
*/
|
||||
function onTransfer(address, address, uint256) external returns (bool) {
|
||||
//Uncomment above line when using parameters
|
||||
//require(msg.sender == address(snt), "Unauthorized");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notice register and authorizes approve from token
|
||||
* @dev called by snt when an approval is made
|
||||
*/
|
||||
function onApprove(address, address, uint256) external returns (bool) {
|
||||
//Uncomment above line when using parameters
|
||||
//require(msg.sender == address(snt), "Unauthorized");
|
||||
return true;
|
||||
}
|
||||
}
|
23
contracts/status/StatusNetwork.sol
Normal file
23
contracts/status/StatusNetwork.sol
Normal file
@ -0,0 +1,23 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "./SNTController.sol";
|
||||
|
||||
/**
|
||||
* @dev Status Network is implemented here
|
||||
*/
|
||||
contract StatusNetwork is SNTController {
|
||||
|
||||
/**
|
||||
* @notice Constructor
|
||||
* @param _owner Authority address
|
||||
* @param _snt SNT token
|
||||
*/
|
||||
constructor(
|
||||
address payable _owner,
|
||||
MiniMeToken _snt
|
||||
)
|
||||
public
|
||||
SNTController(_owner, _snt)
|
||||
{ }
|
||||
|
||||
}
|
55
contracts/status/TestStatusNetwork.sol
Normal file
55
contracts/status/TestStatusNetwork.sol
Normal file
@ -0,0 +1,55 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "./StatusNetwork.sol";
|
||||
/**
|
||||
* @title SNTController
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
* @notice Test net version of SNTController which allow public mint
|
||||
*/
|
||||
contract TestStatusNetwork is StatusNetwork {
|
||||
|
||||
bool public open = false;
|
||||
|
||||
/**
|
||||
* @notice Constructor
|
||||
* @param _owner Authority address
|
||||
* @param _snt SNT token
|
||||
*/
|
||||
constructor(address payable _owner, MiniMeToken _snt)
|
||||
public
|
||||
StatusNetwork(_owner, _snt)
|
||||
{ }
|
||||
|
||||
function () external {
|
||||
_generateTokens(msg.sender, 1000 * (10 ** uint(snt.decimals())));
|
||||
}
|
||||
|
||||
function mint(uint256 _amount) external {
|
||||
_generateTokens(msg.sender, _amount);
|
||||
}
|
||||
|
||||
function generateTokens(address _who, uint _amount) external {
|
||||
_generateTokens(_who, _amount);
|
||||
}
|
||||
|
||||
function destroyTokens(address _who, uint _amount) external onlyOwner {
|
||||
snt.destroyTokens(_who, _amount);
|
||||
}
|
||||
|
||||
function setOpen(bool _open) external onlyOwner {
|
||||
open = _open;
|
||||
}
|
||||
|
||||
function _generateTokens(address _who, uint _amount) private {
|
||||
require(msg.sender == owner || open, "Test Mint Disabled");
|
||||
address statusNetwork = snt.controller();
|
||||
if(statusNetwork == address(this)){
|
||||
snt.generateTokens(_who, _amount);
|
||||
} else {
|
||||
TestStatusNetwork(statusNetwork).generateTokens(_who, _amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
contract ApproveAndCallFallBack {
|
||||
function receiveApproval(address from, uint256 _amount, address _token, bytes memory _data) public;
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "./ERC20Token.sol";
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
// Abstract contract for the full ERC 20 Token standard
|
||||
// https://github.com/ethereum/EIPs/issues/20
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
/*
|
||||
Copyright 2016, Jordi Baylina
|
||||
@ -29,7 +29,6 @@ pragma solidity ^0.5.0;
|
||||
import "../common/Controlled.sol";
|
||||
import "./TokenController.sol";
|
||||
import "./ApproveAndCallFallBack.sol";
|
||||
import "./MiniMeTokenInterface.sol";
|
||||
import "./MiniMeTokenFactory.sol";
|
||||
|
||||
/**
|
||||
@ -37,7 +36,7 @@ import "./MiniMeTokenFactory.sol";
|
||||
* that deploys the contract, so usually this token will be deployed by a
|
||||
* token controller contract, which Giveth will call a "Campaign"
|
||||
*/
|
||||
contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
contract MiniMeToken is Controlled {
|
||||
|
||||
string public name; //The Token's name: e.g. DigixDAO Tokens
|
||||
uint8 public decimals; //Number of decimals of the smallest unit
|
||||
@ -138,7 +137,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
* @return Whether the transfer was successful or not
|
||||
*/
|
||||
function transfer(address _to, uint256 _amount) public returns (bool success) {
|
||||
require(transfersEnabled);
|
||||
require(transfersEnabled, "Transfers disabled");
|
||||
return doTransfer(msg.sender, _to, _amount);
|
||||
}
|
||||
|
||||
@ -164,7 +163,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
// controller of this contract, which in most situations should be
|
||||
// another open source smart contract or 0x0
|
||||
if (msg.sender != controller) {
|
||||
require(transfersEnabled);
|
||||
require(transfersEnabled, "Transfers disabled");
|
||||
|
||||
// The standard ERC 20 transferFrom functionality
|
||||
if (allowed[_from][msg.sender] < _amount) {
|
||||
@ -196,10 +195,10 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
return true;
|
||||
}
|
||||
|
||||
require(parentSnapShotBlock < block.number);
|
||||
require(parentSnapShotBlock < block.number, "Invalid block.number");
|
||||
|
||||
// Do not allow transfer to 0x0 or the token contract itself
|
||||
require((_to != address(0)) && (_to != address(this)));
|
||||
require((_to != address(0)) && (_to != address(this)), "Invalid _to");
|
||||
|
||||
// If the amount being transfered is more than the balance of the
|
||||
// account the transfer returns false
|
||||
@ -210,7 +209,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
|
||||
// Alerts the token controller of the transfer
|
||||
if (isContract(controller)) {
|
||||
require(TokenController(controller).onTransfer(_from, _to, _amount));
|
||||
require(TokenController(controller).onTransfer(_from, _to, _amount), "Unauthorized transfer");
|
||||
}
|
||||
|
||||
// First update the balance array with the new value for the address
|
||||
@ -220,7 +219,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
// Then update the balance array with the new value for the address
|
||||
// receiving the tokens
|
||||
uint256 previousBalanceTo = balanceOfAt(_to, block.number);
|
||||
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
|
||||
require(previousBalanceTo + _amount >= previousBalanceTo, "Balance overflow"); // Check for overflow
|
||||
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
|
||||
|
||||
// An event to make the transfer easy to find on the blockchain
|
||||
@ -237,17 +236,17 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
internal
|
||||
returns (bool)
|
||||
{
|
||||
require(transfersEnabled);
|
||||
require(transfersEnabled, "Transfers disabled");
|
||||
|
||||
// To change the approve amount you first have to reduce the addresses`
|
||||
// allowance to zero by calling `approve(_spender,0)` if it is not
|
||||
// already 0 to mitigate the race condition described here:
|
||||
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
||||
require((_amount == 0) || (allowed[_from][_spender] == 0));
|
||||
require((_amount == 0) || (allowed[_from][_spender] == 0), "Reset allowance first");
|
||||
|
||||
// Alerts the token controller of the approve function call
|
||||
if (isContract(controller)) {
|
||||
require(TokenController(controller).onApprove(_from, _spender, _amount));
|
||||
require(TokenController(controller).onApprove(_from, _spender, _amount), "Unauthorized approve");
|
||||
}
|
||||
|
||||
allowed[_from][_spender] = _amount;
|
||||
@ -272,7 +271,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
* @return True if the approval was successful
|
||||
*/
|
||||
function approve(address _spender, uint256 _amount) external returns (bool success) {
|
||||
doApprove(msg.sender, _spender, _amount);
|
||||
return doApprove(msg.sender, _spender, _amount);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,7 +308,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
public
|
||||
returns (bool success)
|
||||
{
|
||||
require(doApprove(msg.sender, _spender, _amount));
|
||||
require(doApprove(msg.sender, _spender, _amount), "Approve failed");
|
||||
|
||||
ApproveAndCallFallBack(_spender).receiveApproval(
|
||||
msg.sender,
|
||||
@ -354,8 +353,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
// requires that the `parentToken.balanceOfAt` be queried at the
|
||||
// genesis block for that token as this contains initial balance of
|
||||
// this token
|
||||
if ((balances[_owner].length == 0)
|
||||
|| (balances[_owner][0].fromBlock > _blockNumber)) {
|
||||
if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) {
|
||||
if (address(parentToken) != address(0)) {
|
||||
return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock));
|
||||
} else {
|
||||
@ -381,8 +379,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
// requires that the `parentToken.totalSupplyAt` be queried at the
|
||||
// genesis block for this token as that contains totalSupply of this
|
||||
// token at this block number.
|
||||
if ((totalSupplyHistory.length == 0)
|
||||
|| (totalSupplyHistory[0].fromBlock > _blockNumber)) {
|
||||
if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) {
|
||||
if (address(parentToken) != address(0)) {
|
||||
return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock));
|
||||
} else {
|
||||
@ -460,9 +457,9 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
returns (bool)
|
||||
{
|
||||
uint curTotalSupply = totalSupplyAt(block.number);
|
||||
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
|
||||
require(curTotalSupply + _amount >= curTotalSupply, "Total overflow"); // Check for overflow
|
||||
uint previousBalanceTo = balanceOfAt(_owner, block.number);
|
||||
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
|
||||
require(previousBalanceTo + _amount >= previousBalanceTo, "Balance overflow"); // Check for overflow
|
||||
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
|
||||
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
|
||||
emit Transfer(address(0), _owner, _amount);
|
||||
@ -484,9 +481,9 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
returns (bool)
|
||||
{
|
||||
uint curTotalSupply = totalSupplyAt(block.number);
|
||||
require(curTotalSupply >= _amount);
|
||||
require(curTotalSupply >= _amount, "No enough supply");
|
||||
uint previousBalanceFrom = balanceOfAt(_owner, block.number);
|
||||
require(previousBalanceFrom >= _amount);
|
||||
require(previousBalanceFrom >= _amount, "No enough balance");
|
||||
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
|
||||
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
|
||||
emit Transfer(_owner, address(0), _amount);
|
||||
@ -556,8 +553,7 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
* @param _value The new number of tokens
|
||||
*/
|
||||
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value) internal {
|
||||
if ((checkpoints.length == 0)
|
||||
|| (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
|
||||
if ((checkpoints.length == 0) || (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
|
||||
Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++];
|
||||
newCheckPoint.fromBlock = uint128(block.number);
|
||||
newCheckPoint.value = uint128(_value);
|
||||
@ -596,8 +592,8 @@ contract MiniMeToken is MiniMeTokenInterface, Controlled {
|
||||
* ether and creates tokens as described in the token controller contract
|
||||
*/
|
||||
function () external payable {
|
||||
require(isContract(controller));
|
||||
require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
|
||||
require(isContract(controller), "Deposit unallowed");
|
||||
require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender), "Deposit denied");
|
||||
}
|
||||
|
||||
//////////
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "./MiniMeToken.sol";
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "./ERC20Token.sol";
|
||||
|
||||
contract StandardToken is ERC20Token {
|
||||
|
||||
uint256 private supply;
|
||||
uint256 public totalSupply;
|
||||
mapping (address => uint256) balances;
|
||||
mapping (address => mapping (address => uint256)) allowed;
|
||||
|
||||
@ -63,14 +63,6 @@ contract StandardToken is ERC20Token {
|
||||
return balances[_owner];
|
||||
}
|
||||
|
||||
function totalSupply()
|
||||
external
|
||||
view
|
||||
returns(uint256 currentTotalSupply)
|
||||
{
|
||||
return supply;
|
||||
}
|
||||
|
||||
function mint(
|
||||
address _to,
|
||||
uint256 _amount
|
||||
@ -78,7 +70,7 @@ contract StandardToken is ERC20Token {
|
||||
internal
|
||||
{
|
||||
balances[_to] += _amount;
|
||||
supply += _amount;
|
||||
totalSupply += _amount;
|
||||
emit Transfer(address(0x0), _to, _amount);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
/**
|
||||
* @dev The token controller contract must implement these functions
|
||||
*/
|
||||
|
11
embark.json
11
embark.json
@ -1,10 +1,13 @@
|
||||
{
|
||||
"contracts": ["contracts/**"],
|
||||
"app": {},
|
||||
"buildDir": "dist/",
|
||||
"config": "config/",
|
||||
"plugins": {
|
||||
},
|
||||
"versions": {
|
||||
"solc": "0.4.23"
|
||||
}
|
||||
"web3": "1.0.0-beta",
|
||||
"solc": "0.5.0",
|
||||
"ipfs-api": "17.2.4",
|
||||
"p-iteration": "1.1.7"
|
||||
},
|
||||
"plugins": {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user