Unverified Commit 97894a14 by Nicolás Venturo Committed by GitHub

Adhere to naming convention (#2150)

* Upgrade to latest solhint rc

* Add private-vars-leading-underscore linter rule

* Add leading underscore to GSNRecipient constants

* Remove leading underscore from ERC165Checker functions

* Add leading underscore to multiple private constants

* Fix linter errors in mocks

* Add leading underscore to ERC777's ERC1820 registry

* Add changelog entry
parent 4476a2d5
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
"func-order": "off", "func-order": "off",
"mark-callable-contracts": "off", "mark-callable-contracts": "off",
"no-empty-blocks": "off", "no-empty-blocks": "off",
"compiler-version": ["error", "^0.6.0"] "compiler-version": ["error", "^0.6.0"],
"private-vars-leading-underscore": "error"
} }
} }
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
* `Address`: removed `toPayable`, use `payable(address)` instead. ([#2133](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2133)) * `Address`: removed `toPayable`, use `payable(address)` instead. ([#2133](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2133))
* `ERC777`: `_send`, `_mint` and `_burn` now use the caller as the operator. ([#2134](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2134)) * `ERC777`: `_send`, `_mint` and `_burn` now use the caller as the operator. ([#2134](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2134))
* `ERC777`: removed `_callsTokensToSend` and `_callTokensReceived`. ([#2134](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2134)) * `ERC777`: removed `_callsTokensToSend` and `_callTokensReceived`. ([#2134](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2134))
* `ERC165Checker`: functions no longer have a leading underscore. ([#2150](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2150))
## 2.5.0 (2020-02-04) ## 2.5.0 (2020-02-04)
......
...@@ -19,11 +19,11 @@ abstract contract GSNRecipient is IRelayRecipient, Context { ...@@ -19,11 +19,11 @@ abstract contract GSNRecipient is IRelayRecipient, Context {
// Default RelayHub address, deployed on mainnet and all testnets at the same address // Default RelayHub address, deployed on mainnet and all testnets at the same address
address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494; address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494;
uint256 constant private RELAYED_CALL_ACCEPTED = 0; uint256 constant private _RELAYED_CALL_ACCEPTED = 0;
uint256 constant private RELAYED_CALL_REJECTED = 11; uint256 constant private _RELAYED_CALL_REJECTED = 11;
// How much gas is forwarded to postRelayedCall // How much gas is forwarded to postRelayedCall
uint256 constant internal POST_RELAYED_CALL_MAX_GAS = 100000; uint256 constant internal _POST_RELAYED_CALL_MAX_GAS = 100000;
/** /**
* @dev Emitted when a contract changes its {IRelayHub} contract to a new one. * @dev Emitted when a contract changes its {IRelayHub} contract to a new one.
...@@ -170,14 +170,14 @@ abstract contract GSNRecipient is IRelayRecipient, Context { ...@@ -170,14 +170,14 @@ abstract contract GSNRecipient is IRelayRecipient, Context {
* This overload forwards `context` to _preRelayedCall and _postRelayedCall. * This overload forwards `context` to _preRelayedCall and _postRelayedCall.
*/ */
function _approveRelayedCall(bytes memory context) internal pure returns (uint256, bytes memory) { function _approveRelayedCall(bytes memory context) internal pure returns (uint256, bytes memory) {
return (RELAYED_CALL_ACCEPTED, context); return (_RELAYED_CALL_ACCEPTED, context);
} }
/** /**
* @dev Return this in acceptRelayedCall to impede execution of a relayed call. No fees will be charged. * @dev Return this in acceptRelayedCall to impede execution of a relayed call. No fees will be charged.
*/ */
function _rejectRelayedCall(uint256 errorCode) internal pure returns (uint256, bytes memory) { function _rejectRelayedCall(uint256 errorCode) internal pure returns (uint256, bytes memory) {
return (RELAYED_CALL_REJECTED + errorCode, ""); return (_RELAYED_CALL_REJECTED + errorCode, "");
} }
/* /*
......
...@@ -97,7 +97,7 @@ contract GSNRecipientERC20Fee is GSNRecipient { ...@@ -97,7 +97,7 @@ contract GSNRecipientERC20Fee is GSNRecipient {
// actualCharge is an _estimated_ charge, which assumes postRelayedCall will use all available gas. // actualCharge is an _estimated_ charge, which assumes postRelayedCall will use all available gas.
// This implementation's gas cost can be roughly estimated as 10k gas, for the two SSTORE operations in an // This implementation's gas cost can be roughly estimated as 10k gas, for the two SSTORE operations in an
// ERC20 transfer. // ERC20 transfer.
uint256 overestimation = _computeCharge(POST_RELAYED_CALL_MAX_GAS.sub(10000), gasPrice, transactionFee); uint256 overestimation = _computeCharge(_POST_RELAYED_CALL_MAX_GAS.sub(10000), gasPrice, transactionFee);
actualCharge = actualCharge.sub(overestimation); actualCharge = actualCharge.sub(overestimation);
// After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned // After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned
...@@ -113,7 +113,7 @@ contract GSNRecipientERC20Fee is GSNRecipient { ...@@ -113,7 +113,7 @@ contract GSNRecipientERC20Fee is GSNRecipient {
*/ */
// solhint-disable-next-line contract-name-camelcase // solhint-disable-next-line contract-name-camelcase
contract __unstable__ERC20Owned is ERC20, ERC20Detailed, Ownable { contract __unstable__ERC20Owned is ERC20, ERC20Detailed, Ownable {
uint256 private constant UINT256_MAX = 2**256 - 1; uint256 private constant _UINT256_MAX = 2**256 - 1;
constructor(string memory name, string memory symbol, uint8 decimals) public ERC20Detailed(name, symbol, decimals) { } constructor(string memory name, string memory symbol, uint8 decimals) public ERC20Detailed(name, symbol, decimals) { }
...@@ -125,7 +125,7 @@ contract __unstable__ERC20Owned is ERC20, ERC20Detailed, Ownable { ...@@ -125,7 +125,7 @@ contract __unstable__ERC20Owned is ERC20, ERC20Detailed, Ownable {
// The owner has 'infinite' allowance for all token holders // The owner has 'infinite' allowance for all token holders
function allowance(address tokenOwner, address spender) public view override(ERC20, IERC20) returns (uint256) { function allowance(address tokenOwner, address spender) public view override(ERC20, IERC20) returns (uint256) {
if (spender == owner()) { if (spender == owner()) {
return UINT256_MAX; return _UINT256_MAX;
} else { } else {
return super.allowance(tokenOwner, spender); return super.allowance(tokenOwner, spender);
} }
......
...@@ -19,7 +19,7 @@ library ERC165Checker { ...@@ -19,7 +19,7 @@ library ERC165Checker {
/** /**
* @dev Returns true if `account` supports the {IERC165} interface, * @dev Returns true if `account` supports the {IERC165} interface,
*/ */
function _supportsERC165(address account) internal view returns (bool) { function supportsERC165(address account) internal view returns (bool) {
// Any contract that implements ERC165 must explicitly indicate support of // Any contract that implements ERC165 must explicitly indicate support of
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
...@@ -32,9 +32,9 @@ library ERC165Checker { ...@@ -32,9 +32,9 @@ library ERC165Checker {
* *
* See {IERC165-supportsInterface}. * See {IERC165-supportsInterface}.
*/ */
function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
// query support of both ERC165 as per the spec and support of _interfaceId // query support of both ERC165 as per the spec and support of _interfaceId
return _supportsERC165(account) && return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId); _supportsERC165Interface(account, interfaceId);
} }
...@@ -47,9 +47,9 @@ library ERC165Checker { ...@@ -47,9 +47,9 @@ library ERC165Checker {
* *
* See {IERC165-supportsInterface}. * See {IERC165-supportsInterface}.
*/ */
function _supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
// query support of ERC165 itself // query support of ERC165 itself
if (!_supportsERC165(account)) { if (!supportsERC165(account)) {
return false; return false;
} }
...@@ -72,7 +72,7 @@ library ERC165Checker { ...@@ -72,7 +72,7 @@ library ERC165Checker {
* identifier interfaceId, false otherwise * identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise * @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked * the behavior of this method is undefined. This precondition can be checked
* with the `supportsERC165` method in this library. * with {supportsERC165}.
* Interface identification is specified in ERC-165. * Interface identification is specified in ERC-165.
*/ */
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
......
...@@ -11,7 +11,7 @@ import "./IERC1820Implementer.sol"; ...@@ -11,7 +11,7 @@ import "./IERC1820Implementer.sol";
* registration to be complete. * registration to be complete.
*/ */
contract ERC1820Implementer is IERC1820Implementer { contract ERC1820Implementer is IERC1820Implementer {
bytes32 constant private ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); bytes32 constant private _ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
...@@ -19,7 +19,7 @@ contract ERC1820Implementer is IERC1820Implementer { ...@@ -19,7 +19,7 @@ contract ERC1820Implementer is IERC1820Implementer {
* See {IERC1820Implementer-canImplementInterfaceForAddress}. * See {IERC1820Implementer-canImplementInterfaceForAddress}.
*/ */
function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view override returns (bytes32) { function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view override returns (bytes32) {
return _supportedInterfaces[interfaceHash][account] ? ERC1820_ACCEPT_MAGIC : bytes32(0x00); return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00);
} }
/** /**
......
...@@ -5,7 +5,7 @@ pragma solidity ^0.6.0; ...@@ -5,7 +5,7 @@ pragma solidity ^0.6.0;
* @dev Signed math operations with safety checks that revert on error. * @dev Signed math operations with safety checks that revert on error.
*/ */
library SignedSafeMath { library SignedSafeMath {
int256 constant private INT256_MIN = -2**255; int256 constant private _INT256_MIN = -2**255;
/** /**
* @dev Multiplies two signed integers, reverts on overflow. * @dev Multiplies two signed integers, reverts on overflow.
...@@ -18,7 +18,7 @@ library SignedSafeMath { ...@@ -18,7 +18,7 @@ library SignedSafeMath {
return 0; return 0;
} }
require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: multiplication overflow"); require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");
int256 c = a * b; int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow"); require(c / a == b, "SignedSafeMath: multiplication overflow");
...@@ -31,7 +31,7 @@ library SignedSafeMath { ...@@ -31,7 +31,7 @@ library SignedSafeMath {
*/ */
function div(int256 a, int256 b) internal pure returns (int256) { function div(int256 a, int256 b) internal pure returns (int256) {
require(b != 0, "SignedSafeMath: division by zero"); require(b != 0, "SignedSafeMath: division by zero");
require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: division overflow"); require(!(b == -1 && a == _INT256_MIN), "SignedSafeMath: division overflow");
int256 c = a / b; int256 c = a / b;
......
...@@ -5,13 +5,13 @@ import "../utils/Arrays.sol"; ...@@ -5,13 +5,13 @@ import "../utils/Arrays.sol";
contract ArraysImpl { contract ArraysImpl {
using Arrays for uint256[]; using Arrays for uint256[];
uint256[] private array; uint256[] private _array;
constructor (uint256[] memory _array) public { constructor (uint256[] memory array) public {
array = _array; _array = array;
} }
function findUpperBound(uint256 _element) external view returns (uint256) { function findUpperBound(uint256 element) external view returns (uint256) {
return array.findUpperBound(_element); return _array.findUpperBound(element);
} }
} }
...@@ -6,14 +6,14 @@ contract ERC165CheckerMock { ...@@ -6,14 +6,14 @@ contract ERC165CheckerMock {
using ERC165Checker for address; using ERC165Checker for address;
function supportsERC165(address account) public view returns (bool) { function supportsERC165(address account) public view returns (bool) {
return account._supportsERC165(); return account.supportsERC165();
} }
function supportsInterface(address account, bytes4 interfaceId) public view returns (bool) { function supportsInterface(address account, bytes4 interfaceId) public view returns (bool) {
return account._supportsInterface(interfaceId); return account.supportsInterface(interfaceId);
} }
function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) { function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) public view returns (bool) {
return account._supportsAllInterfaces(interfaceIds); return account.supportsAllInterfaces(interfaceIds);
} }
} }
...@@ -37,8 +37,8 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ...@@ -37,8 +37,8 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
bytes32 constant private TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender"); bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient"); bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
function tokensToSend( function tokensToSend(
address operator, address operator,
...@@ -103,7 +103,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ...@@ -103,7 +103,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
} }
function senderFor(address account) public { function senderFor(address account) public {
_registerInterfaceForAddress(TOKENS_SENDER_INTERFACE_HASH, account); _registerInterfaceForAddress(_TOKENS_SENDER_INTERFACE_HASH, account);
address self = address(this); address self = address(this);
if (account == self) { if (account == self) {
...@@ -112,11 +112,11 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ...@@ -112,11 +112,11 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
} }
function registerSender(address sender) public { function registerSender(address sender) public {
_erc1820.setInterfaceImplementer(address(this), TOKENS_SENDER_INTERFACE_HASH, sender); _erc1820.setInterfaceImplementer(address(this), _TOKENS_SENDER_INTERFACE_HASH, sender);
} }
function recipientFor(address account) public { function recipientFor(address account) public {
_registerInterfaceForAddress(TOKENS_RECIPIENT_INTERFACE_HASH, account); _registerInterfaceForAddress(_TOKENS_RECIPIENT_INTERFACE_HASH, account);
address self = address(this); address self = address(this);
if (account == self) { if (account == self) {
...@@ -125,7 +125,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient, ...@@ -125,7 +125,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
} }
function registerRecipient(address recipient) public { function registerRecipient(address recipient) public {
_erc1820.setInterfaceImplementer(address(this), TOKENS_RECIPIENT_INTERFACE_HASH, recipient); _erc1820.setInterfaceImplementer(address(this), _TOKENS_RECIPIENT_INTERFACE_HASH, recipient);
} }
function setShouldRevertSend(bool shouldRevert) public { function setShouldRevertSend(bool shouldRevert) public {
......
...@@ -7,31 +7,31 @@ contract EnumerableSetMock{ ...@@ -7,31 +7,31 @@ contract EnumerableSetMock{
event TransactionResult(bool result); event TransactionResult(bool result);
EnumerableSet.AddressSet private set; EnumerableSet.AddressSet private _set;
function contains(address value) public view returns (bool) { function contains(address value) public view returns (bool) {
return set.contains(value); return _set.contains(value);
} }
function add(address value) public { function add(address value) public {
bool result = set.add(value); bool result = _set.add(value);
emit TransactionResult(result); emit TransactionResult(result);
} }
function remove(address value) public { function remove(address value) public {
bool result = set.remove(value); bool result = _set.remove(value);
emit TransactionResult(result); emit TransactionResult(result);
} }
function enumerate() public view returns (address[] memory) { function enumerate() public view returns (address[] memory) {
return set.enumerate(); return _set.enumerate();
} }
function length() public view returns (uint256) { function length() public view returns (uint256) {
return set.length(); return _set.length();
} }
function get(uint256 index) public view returns (address) { function get(uint256 index) public view returns (address) {
return set.get(index); return _set.get(index);
} }
} }
...@@ -11,19 +11,19 @@ contract ReentrancyMock is ReentrancyGuard { ...@@ -11,19 +11,19 @@ contract ReentrancyMock is ReentrancyGuard {
} }
function callback() external nonReentrant { function callback() external nonReentrant {
count(); _count();
} }
function countLocalRecursive(uint256 n) public nonReentrant { function countLocalRecursive(uint256 n) public nonReentrant {
if (n > 0) { if (n > 0) {
count(); _count();
countLocalRecursive(n - 1); countLocalRecursive(n - 1);
} }
} }
function countThisRecursive(uint256 n) public nonReentrant { function countThisRecursive(uint256 n) public nonReentrant {
if (n > 0) { if (n > 0) {
count(); _count();
// solhint-disable-next-line avoid-low-level-calls // solhint-disable-next-line avoid-low-level-calls
(bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); (bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
require(success, "ReentrancyMock: failed call"); require(success, "ReentrancyMock: failed call");
...@@ -31,12 +31,12 @@ contract ReentrancyMock is ReentrancyGuard { ...@@ -31,12 +31,12 @@ contract ReentrancyMock is ReentrancyGuard {
} }
function countAndCall(ReentrancyAttack attacker) public nonReentrant { function countAndCall(ReentrancyAttack attacker) public nonReentrant {
count(); _count();
bytes4 func = bytes4(keccak256("callback()")); bytes4 func = bytes4(keccak256("callback()"));
attacker.callSender(func); attacker.callSender(func);
} }
function count() private { function _count() private {
counter += 1; counter += 1;
} }
} }
...@@ -18,11 +18,11 @@ library SafeERC20 { ...@@ -18,11 +18,11 @@ library SafeERC20 {
using Address for address; using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal { function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
} }
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
} }
function safeApprove(IERC20 token, address spender, uint256 value) internal { function safeApprove(IERC20 token, address spender, uint256 value) internal {
...@@ -33,17 +33,17 @@ library SafeERC20 { ...@@ -33,17 +33,17 @@ library SafeERC20 {
require((value == 0) || (token.allowance(address(this), spender) == 0), require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance" "SafeERC20: approve from non-zero to non-zero allowance"
); );
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
} }
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value); uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
} }
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
} }
/** /**
...@@ -52,7 +52,7 @@ library SafeERC20 { ...@@ -52,7 +52,7 @@ library SafeERC20 {
* @param token The token targeted by the call. * @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants). * @param data The call data (encoded using abi.encode or one of its variants).
*/ */
function callOptionalReturn(IERC20 token, bytes memory data) private { function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. // we're implementing it ourselves.
......
...@@ -28,7 +28,7 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -28,7 +28,7 @@ contract ERC777 is Context, IERC777, IERC20 {
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
IERC1820Registry constant internal ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); IERC1820Registry constant internal _ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
mapping(address => uint256) private _balances; mapping(address => uint256) private _balances;
...@@ -41,11 +41,11 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -41,11 +41,11 @@ contract ERC777 is Context, IERC777, IERC20 {
// See https://github.com/ethereum/solidity/issues/4024. // See https://github.com/ethereum/solidity/issues/4024.
// keccak256("ERC777TokensSender") // keccak256("ERC777TokensSender")
bytes32 constant private TOKENS_SENDER_INTERFACE_HASH = bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH =
0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895; 0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895;
// keccak256("ERC777TokensRecipient") // keccak256("ERC777TokensRecipient")
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH =
0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; 0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b;
// This isn't ever read from - it's only used to respond to the defaultOperators query. // This isn't ever read from - it's only used to respond to the defaultOperators query.
...@@ -78,8 +78,8 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -78,8 +78,8 @@ contract ERC777 is Context, IERC777, IERC20 {
} }
// register interfaces // register interfaces
ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this)); _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this));
ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this)); _ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this));
} }
/** /**
...@@ -440,7 +440,7 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -440,7 +440,7 @@ contract ERC777 is Context, IERC777, IERC20 {
) )
private private
{ {
address implementer = ERC1820_REGISTRY.getInterfaceImplementer(from, TOKENS_SENDER_INTERFACE_HASH); address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(from, _TOKENS_SENDER_INTERFACE_HASH);
if (implementer != address(0)) { if (implementer != address(0)) {
IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData); IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData);
} }
...@@ -468,7 +468,7 @@ contract ERC777 is Context, IERC777, IERC20 { ...@@ -468,7 +468,7 @@ contract ERC777 is Context, IERC777, IERC20 {
) )
private private
{ {
address implementer = ERC1820_REGISTRY.getInterfaceImplementer(to, TOKENS_RECIPIENT_INTERFACE_HASH); address implementer = _ERC1820_REGISTRY.getInterfaceImplementer(to, _TOKENS_RECIPIENT_INTERFACE_HASH);
if (implementer != address(0)) { if (implementer != address(0)) {
IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData);
} else if (requireReceptionAck) { } else if (requireReceptionAck) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"lodash.startcase": "^4.4.0", "lodash.startcase": "^4.4.0",
"micromatch": "^4.0.2", "micromatch": "^4.0.2",
"mocha": "^7.1.1", "mocha": "^7.1.1",
"solhint": "^3.0.0-rc.5", "solhint": "^3.0.0-rc.6",
"solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477", "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
"solidity-docgen": "^0.4.1" "solidity-docgen": "^0.4.1"
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment