From 37135766e76c2f87c9aa49b2232a2bdd635b7f1f Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Mon, 23 Apr 2018 02:04:49 -0300 Subject: [PATCH] cleanup contents and update solc --- .gitignore | 2 + config/contracts.json | 51 +------------- contracts/common/Controlled.sol | 4 +- contracts/common/Owned.sol | 4 +- contracts/common/SafeMath.sol | 2 +- contracts/token/ERC20Token.sol | 22 +++--- contracts/token/StandardToken.sol | 112 +++++++++++++++++++----------- embark.json | 2 +- package.json | 9 ++- 9 files changed, 94 insertions(+), 114 deletions(-) diff --git a/.gitignore b/.gitignore index d4826d6..33d2b94 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ __pycache__/ # embark .embark/ chains.json +config/production/password +config/livenet/password # egg-related viper.egg-info/ diff --git a/config/contracts.json b/config/contracts.json index 1bf2556..3ebb190 100644 --- a/config/contracts.json +++ b/config/contracts.json @@ -2,7 +2,7 @@ "default": { "versions": { "web3.js": "1.0.0-beta", - "solc": "0.4.21" + "solc": "0.4.23" }, "deployment": { "host": "localhost", @@ -15,55 +15,6 @@ ], "gas": "auto", "contracts": { - "Bounty": {"deploy": false}, - "BountyFactory": {"deploy": false}, - "BountyKernel": {"deploy": false}, - "BountyManager": {"deploy": false}, - "BountyManagerFactory": {"deploy": false}, - "BountyManagerKernel": {"deploy": false}, - "BountyManagerPreSigned": {"deploy": false}, - "Controlled": { "deploy": false }, - "ContributionWallet": {"deploy": false}, - "DelayedUpdatableInstance": { "deploy": false }, - "DelayedUpdatableInstanceStorage": { "deploy": false }, - "DelegatedCall": { "deploy": false }, - "DelegationProxy": {"deploy": false}, - "DelegationProxyInterface": {"deploy": false}, - "DelegationProxyKernel": {"deploy": false}, - "DelegationProxyFactory": {"deploy": false}, - "Democracy": {"deploy": false}, - "DemocracyStorage": {"deploy": false}, - "DevTokensHolder": {"deploy": false}, - "DynamicCeiling": {"deploy": false}, - "EmojiBoard": {"deploy": false}, - "EmojiTable": {"deploy": false}, - "ERC725": { "deploy": false }, - "ERC735": { "deploy": false }, - "Factory": { "deploy": false }, - "FeeRecycler": {"deploy": false}, - "FriendsRecovery": { "deploy": false }, - "Identity": { "gas": 5000000 }, - "IdentityFactory": { "deploy": false }, - "IdentityKernel": { "gas": 5000000 }, - "Instance": { "deploy": false }, - "InstanceStorage": { "deploy": false }, - "MessageDeliveryPayout": {"deploy": false}, - "MiniMeToken": {"deploy": false}, - "MiniMeTokenFactory": {"deploy": false}, - "MultiSig": {"deploy": false}, - "Ownable": {"deploy": false}, - "Owned": {"deploy": false}, - "ProposalManager": {"deploy": false}, - "SGTExchanger": {"deploy": false}, - "SNT": {"deploy": false}, - "SNTPlaceHolder": {"deploy": false}, - "StandardToken": {"deploy": false}, - "StatusContribution": {"deploy": false}, - "TestContract": { "deploy": false }, - "TokenRegistry": {"deploy": false}, - "TrustNetwork": {"deploy": false}, - "UpdatableInstance": { "deploy": false }, - "UpdatedIdentityKernel": { "deploy": false } } } } diff --git a/contracts/common/Controlled.sol b/contracts/common/Controlled.sol index 334b6c5..d2773f3 100644 --- a/contracts/common/Controlled.sol +++ b/contracts/common/Controlled.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.8; +pragma solidity ^0.4.23; contract Controlled { /// @notice The address of the controller is the only address that can call @@ -10,7 +10,7 @@ contract Controlled { address public controller; - function Controlled() public { + constructor() public { controller = msg.sender; } diff --git a/contracts/common/Owned.sol b/contracts/common/Owned.sol index 193a160..177bf0f 100644 --- a/contracts/common/Owned.sol +++ b/contracts/common/Owned.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.21; +pragma solidity ^0.4.23; /// @dev `Owned` is a base level contract that assigns an `owner` that can be /// later changed @@ -14,7 +14,7 @@ contract Owned { address public owner; /// @notice The Constructor assigns the message sender to be `owner` - function Owned() public { + constructor() public { owner = msg.sender; } diff --git a/contracts/common/SafeMath.sol b/contracts/common/SafeMath.sol index ac387c9..0b5602d 100644 --- a/contracts/common/SafeMath.sol +++ b/contracts/common/SafeMath.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.21; +pragma solidity ^0.4.23; /** * Math operations with safety checks diff --git a/contracts/token/ERC20Token.sol b/contracts/token/ERC20Token.sol index 67cd1f1..c210342 100644 --- a/contracts/token/ERC20Token.sol +++ b/contracts/token/ERC20Token.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.11; +pragma solidity ^0.4.17; // Abstract contract for the full ERC 20 Token standard // https://github.com/ethereum/EIPs/issues/20 @@ -16,16 +16,18 @@ contract ERC20Token { /// total amount of tokens uint256 public totalSupply; - /// @param _owner The address from which the balance will be retrieved - /// @return The balance - function balanceOf(address _owner) public constant returns (uint256 balance); - /// @notice send `_value` token to `_to` from `msg.sender` /// @param _to The address of the recipient /// @param _value The amount of token to be transferred /// @return Whether the transfer was successful or not function transfer(address _to, uint256 _value) public returns (bool success); + /// @notice `msg.sender` approves `_spender` to spend `_value` tokens + /// @param _spender The address of the account able to transfer the tokens + /// @param _value The amount of tokens to be approved for transfer + /// @return Whether the approval was successful or not + function approve(address _spender, uint256 _value) public returns (bool success); + /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` /// @param _from The address of the sender /// @param _to The address of the recipient @@ -33,16 +35,14 @@ contract ERC20Token { /// @return Whether the transfer was successful or not function transferFrom(address _from, address _to, uint256 _value) public returns (bool success); - /// @notice `msg.sender` approves `_spender` to spend `_value` tokens - /// @param _spender The address of the account able to transfer the tokens - /// @param _value The amount of tokens to be approved for transfer - /// @return Whether the approval was successful or not - function approve(address _spender, uint256 _value) public returns (bool success); + /// @param _owner The address from which the balance will be retrieved + /// @return The balance + function balanceOf(address _owner) public view returns (uint256 balance); /// @param _owner The address of the account owning tokens /// @param _spender The address of the account able to transfer the tokens /// @return Amount of remaining tokens allowed to spent - function allowance(address _owner, address _spender) public constant returns (uint256 remaining); + function allowance(address _owner, address _spender) public view returns (uint256 remaining); event Transfer(address indexed _from, address indexed _to, uint256 _value); event Approval(address indexed _owner, address indexed _spender, uint256 _value); diff --git a/contracts/token/StandardToken.sol b/contracts/token/StandardToken.sol index d54944c..10ca74a 100644 --- a/contracts/token/StandardToken.sol +++ b/contracts/token/StandardToken.sol @@ -1,56 +1,84 @@ -/* -You should inherit from StandardToken or, for a token like you would want to -deploy in something like Mist, see HumanStandardToken.sol. -(This implements ONLY the standard functions and NOTHING else. -If you deploy this, you won't have anything useful.) - -Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20 -.*/ -pragma solidity ^0.4.8; +pragma solidity ^0.4.23; import "./ERC20Token.sol"; contract StandardToken is ERC20Token { - function transfer(address _to, uint256 _value) returns (bool success) { - //Default assumes totalSupply can't be over max (2^256 - 1). - //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. - //Replace the if with this one instead. - //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { - if (balances[msg.sender] >= _value && _value > 0) { - balances[msg.sender] -= _value; - balances[_to] += _value; - Transfer(msg.sender, _to, _value); - return true; - } else { return false; } + mapping (address => uint256) balances; + mapping (address => mapping (address => uint256)) allowed; + + constructor() internal { } + + function transfer( + address _to, + uint256 _value + ) + public + returns (bool success) + { + return transfer(msg.sender, _to, _value); } - function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { - //same as above. Replace this line with the following if you want to protect against wrapping uints. - //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { - if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { - balances[_to] += _value; - balances[_from] -= _value; - allowed[_from][msg.sender] -= _value; - Transfer(_from, _to, _value); - return true; - } else { return false; } - } - - function balanceOf(address _owner) constant returns (uint256 balance) { - return balances[_owner]; - } - - function approve(address _spender, uint256 _value) returns (bool success) { + function approve(address _spender, uint256 _value) + public + returns (bool success) + { allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); + emit Approval(msg.sender, _spender, _value); return true; } - function allowance(address _owner, address _spender) constant returns (uint256 remaining) { - return allowed[_owner][_spender]; + function transferFrom( + address _from, + address _to, + uint256 _value + ) + public + returns (bool success) + { + if (balances[_from] >= _value && + allowed[_from][msg.sender] >= _value && + _value > 0) { + allowed[_from][msg.sender] -= _value; + return transfer(_from, _to, _value); + } else { + return false; + } } - mapping (address => uint256) balances; - mapping (address => mapping (address => uint256)) allowed; + function allowance(address _owner, address _spender) + public + view + returns (uint256 remaining) + { + return allowed[_owner][_spender]; + } + + function balanceOf(address _owner) + public + view + returns (uint256 balance) + { + return balances[_owner]; + } + + function transfer( + address _from, + address _to, + uint256 _value + ) + internal + returns (bool success) + { + if (balances[_from] >= _value && _value > 0) { + balances[_from] -= _value; + balances[_to] += _value; + emit Transfer(_from, _to, _value); + return true; + } else { + return false; + } + } + + } diff --git a/embark.json b/embark.json index fb7de2c..ba742a4 100644 --- a/embark.json +++ b/embark.json @@ -5,6 +5,6 @@ "plugins": { }, "versions": { - "solc": "0.4.21" + "solc": "0.4.23" } } diff --git a/package.json b/package.json index 8317ed6..7cf6084 100644 --- a/package.json +++ b/package.json @@ -9,20 +9,19 @@ "type": "git", "url": "git+https://github.com/status-im/contracts.git" }, - "author": "", + "author": "Status Research & Development GMBH", "license": "ISC", "bugs": { "url": "https://github.com/status-im/contracts/issues" }, "homepage": "https://github.com/status-im/contracts#readme", "devDependencies": { - "solidity-coverage": "^0.4.4", + "solidity-coverage": "^0.5.0", "elliptic": "^6.4.0" }, "dependencies": { - "elliptic-curve": "^0.1.0", "embark": "^2.7.0", - "ethereumjs-util": "^5.1.5", - "solidity-coverage": "^0.4.4" + "elliptic-curve": "^0.1.0", + "ethereumjs-util": "^5.1.5" } }