ERC223TokenMock.sol 888 B

123456789101112131415161718192021222324252627282930313233
  1. pragma solidity ^0.4.24;
  2. import "../token/ERC20/StandardToken.sol";
  3. contract ERC223ContractInterface {
  4. function tokenFallback(address _from, uint256 _value, bytes _data) external;
  5. }
  6. contract ERC223TokenMock is StandardToken {
  7. constructor(address _initialAccount, uint256 _initialBalance) public {
  8. _mint(_initialAccount, _initialBalance);
  9. }
  10. // ERC223 compatible transfer function (except the name)
  11. function transferERC223(address _to, uint256 _value, bytes _data) public
  12. returns (bool success)
  13. {
  14. transfer(_to, _value);
  15. bool isContract = false;
  16. // solium-disable-next-line security/no-inline-assembly
  17. assembly {
  18. isContract := not(iszero(extcodesize(_to)))
  19. }
  20. if (isContract) {
  21. ERC223ContractInterface receiver = ERC223ContractInterface(_to);
  22. receiver.tokenFallback(msg.sender, _value, _data);
  23. }
  24. return true;
  25. }
  26. }