Skip to content

Commit

Permalink
ERC777 Fix linter errors again... (OpenZeppelin#1159)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bertrand Masius committed Mar 21, 2019
1 parent 7f7d296 commit 990073f
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 39 deletions.
3 changes: 2 additions & 1 deletion contracts/drafts/ERC777/ERC777.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 11 additions & 7 deletions contracts/drafts/ERC777/ERC777Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -203,7 +203,9 @@ contract ERC777Base is IERC777, ERC1820Client {
require(msg.sender != operator);
if (_defaultOps[operator]) {
_reAuthorizeDefaultOperator(operator);
} else _authorizeOperator(operator);
} else {
_authorizeOperator(operator);
}
}

/**
Expand All @@ -214,7 +216,9 @@ contract ERC777Base is IERC777, ERC1820Client {
require(operator != msg.sender);
if (_defaultOps[operator]) {
_revokeDefaultOperator(operator);
} else _revokeOperator(operator);
} else {
_revokeOperator(operator);
}
}

/**
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
34 changes: 17 additions & 17 deletions contracts/drafts/ERC777/IERC777.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down
23 changes: 12 additions & 11 deletions contracts/introspection/IERC1820.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
1 change: 1 addition & 0 deletions contracts/mocks/ERC777SenderMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
7 changes: 4 additions & 3 deletions test/drafts/ERC777/ERC777.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 990073f

Please sign in to comment.