Skip to content

Commit

Permalink
Merge pull request #127 from TokenMarketNet/feat/erc827
Browse files Browse the repository at this point in the history
ERC827: Support for ERC827 tokens, including basic acceptance tests
  • Loading branch information
miohtama committed Apr 18, 2018
2 parents 4941c63 + ec7e9aa commit d81d76c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion contracts/StandardTokenExt.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
pragma solidity ^0.4.14;

import "zeppelin/contracts/token/ERC20/StandardToken.sol";
import "zeppelin/contracts/token/ERC827/ERC827Token.sol";
import "./Recoverable.sol";


Expand All @@ -16,7 +17,7 @@ import "./Recoverable.sol";
* @notice Interface marker is used by crowdsale contracts to validate that addresses point a good token contract.
*
*/
contract StandardTokenExt is StandardToken, Recoverable {
contract StandardTokenExt is StandardToken, ERC827Token, Recoverable {

/* Interface declaration */
function isToken() public constant returns (bool weAre) {
Expand Down
11 changes: 11 additions & 0 deletions contracts/test/ERC827Receiver.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma solidity ^0.4.8;

contract ERC827Receiver {
function ERC827Receiver() {

}

function receive() returns(bool){
return true;
}
}
37 changes: 37 additions & 0 deletions ico/tests/contracts/test_erc827.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""ERC-20 compatibility."""
import pytest
from web3.contract import Contract
from rlp.utils import decode_hex

@pytest.fixture
def testpayload() -> str:
return decode_hex("a3e76c0f") # function receive() returns(bool)

@pytest.fixture
def receiver(chain, team_multisig, token_name, token_symbol, initial_supply) -> Contract:
"""Create the token contract."""

tx = {
"from": team_multisig
}

contract, hash = chain.provider.deploy_contract('ERC827Receiver', deploy_transaction=tx)
return contract

def test_erc827_allowance(token, team_multisig, testpayload, receiver, customer):
"""Token satisfies ERC-827 interface."""

assert token.call().allowance(team_multisig, customer) == 0
token.transact({"from": team_multisig}).approve(customer, 50, testpayload)
assert token.call().allowance(team_multisig, customer) == 50
token.transact({"from": team_multisig}).increaseApproval(customer, 100, testpayload)
assert token.call().allowance(team_multisig, customer) == 150
token.transact({"from": team_multisig}).decreaseApproval(customer, 50, testpayload)
assert token.call().allowance(team_multisig, customer) == 100

token.transact({"from": customer}).transferFrom(team_multisig, receiver.address, 100, testpayload)

def test_erc827_transfer(token, team_multisig, testpayload, receiver):
assert token.call().balanceOf(receiver.address) == 0
token.transact({"from": team_multisig}).transfer(receiver.address, 100, testpayload)
assert token.call().balanceOf(receiver.address) == 100

0 comments on commit d81d76c

Please sign in to comment.