Skip to content

Commit

Permalink
Merge branch 'master' into azavalla-feature/inheritable-contract
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 authored Jan 18, 2018
2 parents c01203b + 5a42a45 commit a5ea0af
Show file tree
Hide file tree
Showing 28 changed files with 596 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mkdir myproject && cd myproject
truffle init
```

To install the OpenZeppelin library, run:
To install the OpenZeppelin library, run the following in your Solidity project root directory:
```sh
npm init
npm install zeppelin-solidity
Expand Down
2 changes: 1 addition & 1 deletion contracts/lifecycle/TokenDestructible.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;

import "../ownership/Ownable.sol";
import "../token/ERC20Basic.sol";
import "../token/ERC20/ERC20Basic.sol";


/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/DetailedERC20Mock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;

import "../token/StandardToken.sol";
import "../token/DetailedERC20.sol";
import "../token/ERC20/DetailedERC20.sol";


contract DetailedERC20Mock is StandardToken, DetailedERC20 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ pragma solidity ^0.4.18;
import "../token/BasicToken.sol";


contract ERC23ContractInterface {
contract ERC223ContractInterface {
function tokenFallback(address _from, uint256 _value, bytes _data) external;
}

contract ERC223TokenMock is BasicToken {

contract ERC23TokenMock is BasicToken {

function ERC23TokenMock(address initialAccount, uint256 initialBalance) public {
function ERC223TokenMock(address initialAccount, uint256 initialBalance) public {
balances[initialAccount] = initialBalance;
totalSupply = initialBalance;
}

// ERC23 compatible transfer function (except the name)
function transferERC23(address _to, uint256 _value, bytes _data) public
// ERC223 compatible transfer function (except the name)
function transferERC223(address _to, uint256 _value, bytes _data) public
returns (bool success)
{
transfer(_to, _value);
Expand All @@ -26,7 +25,7 @@ contract ERC23TokenMock is BasicToken {
is_contract := not(iszero(extcodesize(_to)))
}
if (is_contract) {
ERC23ContractInterface receiver = ERC23ContractInterface(_to);
ERC223ContractInterface receiver = ERC223ContractInterface(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
return true;
Expand Down
15 changes: 15 additions & 0 deletions contracts/mocks/ERC827TokenMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.4.13;


import "../token/ERC827/ERC827Token.sol";


// mock class using ERC827 Token
contract ERC827TokenMock is ERC827Token {

function ERC827TokenMock(address initialAccount, uint256 initialBalance) public {
balances[initialAccount] = initialBalance;
totalSupply = initialBalance;
}

}
23 changes: 23 additions & 0 deletions contracts/mocks/MessageHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pragma solidity ^0.4.11;

contract MessageHelper {

event Show(bytes32 b32, uint256 number, string text);

function showMessage( bytes32 message, uint256 number, string text ) public returns (bool) {
Show(message, number, text);
return true;
}

function fail() public {
require(false);
}

function call(address to, bytes data) public returns (bool) {
if (to.call(data))
return true;
else
return false;
}

}
4 changes: 2 additions & 2 deletions contracts/mocks/SafeERC20Helper.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;

import "../token/ERC20.sol";
import "../token/SafeERC20.sol";
import "../token/ERC20/ERC20.sol";
import "../token/ERC20/SafeERC20.sol";


contract ERC20FailingMock is ERC20 {
Expand Down
4 changes: 2 additions & 2 deletions contracts/ownership/CanReclaimToken.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pragma solidity ^0.4.18;

import "./Ownable.sol";
import "../token/ERC20Basic.sol";
import "../token/SafeERC20.sol";
import "../token/ERC20/ERC20Basic.sol";
import "../token/ERC20/SafeERC20.sol";


/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/ownership/HasNoTokens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import "./CanReclaimToken.sol";
/**
* @title Contracts that should not own Tokens
* @author Remco Bloemen <remco@2π.com>
* @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
* @dev This blocks incoming ERC223 tokens to prevent accidental loss of tokens.
* Should tokens (any ERC20Basic compatible) end up in the contract, it allows the
* owner to reclaim the tokens.
*/
contract HasNoTokens is CanReclaimToken {

/**
* @dev Reject all ERC23 compatible tokens
* @dev Reject all ERC223 compatible tokens
* @param from_ address The address that is transferring the tokens
* @param value_ uint256 the amount of the specified token
* @param data_ Bytes The data passed from the caller.
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/BasicToken.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;


import "./ERC20Basic.sol";
import "./ERC20/ERC20Basic.sol";
import "../math/SafeMath.sol";


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions contracts/token/ERC827/ERC827.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pragma solidity ^0.4.13;


import "../ERC20/ERC20.sol";


/**
@title ERC827 interface, an extension of ERC20 token standard
Interface of a ERC827 token, following the ERC20 standard with extra
methods to transfer value and data and execute calls in transfers and
approvals.
*/
contract ERC827 is ERC20 {

function approve( address _spender, uint256 _value, bytes _data ) public returns (bool);
function transfer( address _to, uint256 _value, bytes _data ) public returns (bool);
function transferFrom( address _from, address _to, uint256 _value, bytes _data ) public returns (bool);

}
126 changes: 126 additions & 0 deletions contracts/token/ERC827/ERC827Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
pragma solidity ^0.4.13;

import "./ERC827.sol";
import "../StandardToken.sol";

/**
@title ERC827, an extension of ERC20 token standard
Implementation the ERC827, following the ERC20 standard with extra
methods to transfer value and data and execute calls in transfers and
approvals.
Uses OpenZeppelin StandardToken.
*/
contract ERC827Token is ERC827, StandardToken {

/**
@dev Addition to ERC20 token methods. It allows to
approve the transfer of value and execute a call with the sent data.
Beware that changing an allowance with this method brings the risk that
someone may use both the old and the new allowance by unfortunate
transaction ordering. One possible solution to mitigate this race condition
is to first reduce the spender's allowance to 0 and set the desired value
afterwards:
https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
@param _spender The address that will spend the funds.
@param _value The amount of tokens to be spent.
@param _data ABI-encoded contract call to call `_to` address.
@return true if the call function was executed successfully
*/
function approve(address _spender, uint256 _value, bytes _data) public returns (bool) {
require(_spender != address(this));

super.approve(_spender, _value);

require(_spender.call(_data));

return true;
}

/**
@dev Addition to ERC20 token methods. Transfer tokens to a specified
address and execute a call with the sent data on the same transaction
@param _to address The address which you want to transfer to
@param _value uint256 the amout of tokens to be transfered
@param _data ABI-encoded contract call to call `_to` address.
@return true if the call function was executed successfully
*/
function transfer(address _to, uint256 _value, bytes _data) public returns (bool) {
require(_to != address(this));

super.transfer(_to, _value);

require(_to.call(_data));
return true;
}

/**
@dev Addition to ERC20 token methods. Transfer tokens from one address to
another and make a contract call on the same transaction
@param _from The address which you want to send tokens from
@param _to The address which you want to transfer to
@param _value The amout of tokens to be transferred
@param _data ABI-encoded contract call to call `_to` address.
@return true if the call function was executed successfully
*/
function transferFrom(address _from, address _to, uint256 _value, bytes _data) public returns (bool) {
require(_to != address(this));

super.transferFrom(_from, _to, _value);

require(_to.call(_data));
return true;
}

/**
* @dev Addition to StandardToken methods. Increase the amount of tokens that
* an owner allowed to a spender and execute a call with the sent data.
*
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
* @param _data ABI-encoded contract call to call `_spender` address.
*/
function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) {
require(_spender != address(this));

super.increaseApproval(_spender, _addedValue);

require(_spender.call(_data));

return true;
}

/**
* @dev Addition to StandardToken methods. Decrease the amount of tokens that
* an owner allowed to a spender and execute a call with the sent data.
*
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
* @param _data ABI-encoded contract call to call `_spender` address.
*/
function decreaseApproval(address _spender, uint _subtractedValue, bytes _data) public returns (bool) {
require(_spender != address(this));

super.decreaseApproval(_spender, _subtractedValue);

require(_spender.call(_data));

return true;
}

}
2 changes: 1 addition & 1 deletion contracts/token/StandardToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pragma solidity ^0.4.18;


import "./BasicToken.sol";
import "./ERC20.sol";
import "./ERC20/ERC20.sol";


/**
Expand Down
3 changes: 1 addition & 2 deletions contracts/token/TokenTimelock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pragma solidity ^0.4.18;

import "./ERC20Basic.sol";
import "../token/SafeERC20.sol";
import "./ERC20/SafeERC20.sol";


/**
Expand Down
4 changes: 2 additions & 2 deletions contracts/token/TokenVesting.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pragma solidity ^0.4.18;

import "./ERC20Basic.sol";
import "./SafeERC20.sol";
import "./ERC20/ERC20Basic.sol";
import "./ERC20/SafeERC20.sol";
import "../ownership/Ownable.sol";
import "../math/SafeMath.sol";

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"truffle-hdwallet-provider": "0.0.3"
},
"dependencies": {
"dotenv": "^4.0.0"
"dotenv": "^4.0.0",
"ethjs-abi": "^0.2.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import decodeLogs from './helpers/decodeLogs';
const SimpleToken = artifacts.require('examples/SimpleToken.sol');
import decodeLogs from '../helpers/decodeLogs';
const SimpleToken = artifacts.require('SimpleToken.sol');

contract('SimpleToken', accounts => {
let token;
Expand All @@ -23,7 +23,7 @@ contract('SimpleToken', accounts => {
const decimals = await token.decimals();
assert(decimals.eq(18));
});

it('assigns the initial total supply to the creator', async function () {
const totalSupply = await token.totalSupply();
const creatorBalance = await token.balanceOf(creator);
Expand Down
6 changes: 3 additions & 3 deletions test/ECRecovery.test.js → test/library/ECRecovery.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var ECRecoveryMock = artifacts.require('../contracts/mocks/ECRecoveryMock.sol');
var ECRecoveryLib = artifacts.require('../contracts/ECRecovery.sol');
var ECRecoveryMock = artifacts.require('ECRecoveryMock.sol');
var ECRecoveryLib = artifacts.require('ECRecovery.sol');

var hashMessage = require('./helpers/hashMessage.js');
var hashMessage = require('../helpers/hashMessage.js');

contract('ECRecovery', function (accounts) {
let ecrecovery;
Expand Down
2 changes: 1 addition & 1 deletion test/Math.test.js → test/library/Math.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var MathMock = artifacts.require('./mocks/MathMock.sol');
var MathMock = artifacts.require('../mocks/MathMock.sol');

contract('Math', function (accounts) {
let math;
Expand Down
4 changes: 2 additions & 2 deletions test/MerkleProof.test.js → test/library/MerkleProof.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import MerkleTree from './helpers/merkleTree.js';
import MerkleTree from '../helpers/merkleTree.js';
import { sha3, bufferToHex } from 'ethereumjs-util';

var MerkleProof = artifacts.require('./MerkleProof.sol');
var MerkleProof = artifacts.require('MerkleProof.sol');

contract('MerkleProof', function (accounts) {
let merkleProof;
Expand Down
Loading

0 comments on commit a5ea0af

Please sign in to comment.