diff --git a/contracts/drafts/ERC777/ERC777.sol b/contracts/drafts/ERC777/ERC777.sol index 84580ce8d2c..672b596e924 100644 --- a/contracts/drafts/ERC777/ERC777.sol +++ b/contracts/drafts/ERC777/ERC777.sol @@ -29,12 +29,13 @@ contract ERC777 is ERC777Base { bytes memory data, bytes memory operatorData ) + public ERC777Base( name, symbol, granularity, defaultOperators - ) public { + ) { _mint( msg.sender, msg.sender, diff --git a/contracts/drafts/ERC777/ERC777Base.sol b/contracts/drafts/ERC777/ERC777Base.sol index d0c89b99cbf..8e47bcdbdff 100644 --- a/contracts/drafts/ERC777/ERC777Base.sol +++ b/contracts/drafts/ERC777/ERC777Base.sol @@ -29,8 +29,8 @@ contract ERC777Base is IERC777, ERC1820Client { address[] private _defaultOpsArray; - bytes32 constant sendHash = keccak256("ERC777TokensSender"); - bytes32 constant receivedHash = keccak256("ERC777TokensRecipient"); + bytes32 constant private SENDHASH = keccak256("ERC777TokensSender"); + bytes32 constant private RECEIVEDHASH = keccak256("ERC777TokensRecipient"); mapping(address => bool) private _defaultOps; mapping(address => mapping(address => bool)) private _revokedDefaultOps; @@ -203,7 +203,9 @@ contract ERC777Base is IERC777, ERC1820Client { require(msg.sender != operator); if (_defaultOps[operator]) { _reAuthorizeDefaultOperator(operator); - } else _authorizeOperator(operator); + } else { + _authorizeOperator(operator); + } } /** @@ -214,7 +216,9 @@ contract ERC777Base is IERC777, ERC1820Client { require(operator != msg.sender); if (_defaultOps[operator]) { _revokeDefaultOperator(operator); - } else _revokeOperator(operator); + } else { + _revokeOperator(operator); + } } /** @@ -435,7 +439,7 @@ contract ERC777Base is IERC777, ERC1820Client { ) private { - address implementer = getInterfaceImplementer(from, sendHash); + address implementer = getInterfaceImplementer(from, SENDHASH); if (implementer != address(0)) { IERC777TokensSender(implementer).tokensToSend( operator, @@ -470,9 +474,9 @@ contract ERC777Base is IERC777, ERC1820Client { private returns(bool) { - address implementer = getInterfaceImplementer(to, receivedHash); + address implementer = getInterfaceImplementer(to, RECEIVEDHASH); if (implementer == address(0)) { - return(! to.isContract()); + return(!to.isContract()); } IERC777TokensRecipient(implementer).tokensReceived( operator, diff --git a/contracts/drafts/ERC777/IERC777.sol b/contracts/drafts/ERC777/IERC777.sol index 4b6b99bfee3..a1ebd09b1d6 100644 --- a/contracts/drafts/ERC777/IERC777.sol +++ b/contracts/drafts/ERC777/IERC777.sol @@ -5,27 +5,10 @@ pragma solidity ^0.5.2; * @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-777.md */ interface IERC777 { - function name() external view returns (string memory); - - function symbol() external view returns (string memory); - - function totalSupply() external view returns (uint256); - - function balanceOf(address owner) external view returns (uint256); - - function granularity() external view returns (uint256); - - function defaultOperators() external view returns (address[] memory); - function authorizeOperator(address operator) external; function revokeOperator(address operator) external; - function isOperatorFor( - address operator, - address tokenHolder - ) external view returns (bool); - function send(address to, uint256 amount, bytes calldata data) external; function operatorSend( @@ -45,6 +28,23 @@ interface IERC777 { bytes calldata operatorData ) external; + function name() external view returns (string memory); + + function symbol() external view returns (string memory); + + function totalSupply() external view returns (uint256); + + function balanceOf(address owner) external view returns (uint256); + + function granularity() external view returns (uint256); + + function defaultOperators() external view returns (address[] memory); + + function isOperatorFor( + address operator, + address tokenHolder + ) external view returns (bool); + event Sent( address indexed operator, address indexed from, diff --git a/contracts/introspection/IERC1820.sol b/contracts/introspection/IERC1820.sol index 1572e39206e..2e68a3e274d 100644 --- a/contracts/introspection/IERC1820.sol +++ b/contracts/introspection/IERC1820.sol @@ -11,29 +11,30 @@ interface IERC1820 { address _implementer ) external; - function getInterfaceImplementer( - address _addr, - bytes32 _interfaceHash - ) external view returns (address); - function setManager( address _addr, address _newManager ) external; - function getManager(address _addr) external view returns(address); - - function interfaceHash( - string calldata _interfaceName - ) external pure returns(bytes32); - function updateERC165Cache( address _contract, bytes4 _interfaceId ) external; + function getInterfaceImplementer( + address _addr, + bytes32 _interfaceHash + ) external view returns (address); + function implementsERC165Interface( address _contract, bytes4 _interfaceId ) external view returns (bool); + + function getManager(address _addr) external view returns(address); + + function interfaceHash( + string calldata _interfaceName + ) external pure returns(bytes32); + } diff --git a/contracts/mocks/ERC777SenderMock.sol b/contracts/mocks/ERC777SenderMock.sol index cd63393846f..b6316e54567 100644 --- a/contracts/mocks/ERC777SenderMock.sol +++ b/contracts/mocks/ERC777SenderMock.sol @@ -45,6 +45,7 @@ contract ERC777SenderMock is IERC777TokensSender, ERC1820Client { uint amount, bytes calldata data ) external { + // solhint-disable-next-line check-send-result IERC777(_erc777).send(to, amount, data); } diff --git a/test/drafts/ERC777/ERC777.test.js b/test/drafts/ERC777/ERC777.test.js index 5598d6c7576..fb82b444f2c 100644 --- a/test/drafts/ERC777/ERC777.test.js +++ b/test/drafts/ERC777/ERC777.test.js @@ -14,15 +14,16 @@ contract('ERC777', function ([_, holder, operator, anotherAccount]) { const USER_DATA = '0xabcd'; const OPERATOR_DATA = '0x0a0b0c0d'; const GRANULARITY = '1'; - var ERC1820Registry; + let ERC1820Registry; before('Deploy ERC1820', function (done) { + // eslint-disable-next-line promise/catch-or-return ERC1820.at(ERC1820_ADDRESS).then( - function(contract) { + function (contract) { ERC1820Registry = contract.address; done(); }, - async function(reject) { + async function (reject) { const address = await ERC1820Deploy(holder); ERC1820Registry = (await ERC1820.at(address)).address; done();