Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adhere to naming convention #2150

Merged
merged 8 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"func-order": "off",
"mark-callable-contracts": "off",
"no-empty-blocks": "off",
"compiler-version": ["error", "^0.6.0"]
"compiler-version": ["error", "^0.6.0"],
"private-vars-leading-underscore": "error"
}
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* `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`: 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)

Expand Down
10 changes: 5 additions & 5 deletions contracts/GSN/GSNRecipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ abstract contract GSNRecipient is IRelayRecipient, Context {
// Default RelayHub address, deployed on mainnet and all testnets at the same address
address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494;

uint256 constant private RELAYED_CALL_ACCEPTED = 0;
uint256 constant private RELAYED_CALL_REJECTED = 11;
uint256 constant private _RELAYED_CALL_ACCEPTED = 0;
uint256 constant private _RELAYED_CALL_REJECTED = 11;

// 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.
Expand Down Expand Up @@ -170,14 +170,14 @@ abstract contract GSNRecipient is IRelayRecipient, Context {
* This overload forwards `context` to _preRelayedCall and _postRelayedCall.
*/
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.
*/
function _rejectRelayedCall(uint256 errorCode) internal pure returns (uint256, bytes memory) {
return (RELAYED_CALL_REJECTED + errorCode, "");
return (_RELAYED_CALL_REJECTED + errorCode, "");
}

/*
Expand Down
6 changes: 3 additions & 3 deletions contracts/GSN/GSNRecipientERC20Fee.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ contract GSNRecipientERC20Fee is GSNRecipient {
// 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
// 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);

// After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned
Expand All @@ -113,7 +113,7 @@ contract GSNRecipientERC20Fee is GSNRecipient {
*/
// solhint-disable-next-line contract-name-camelcase
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) { }

Expand All @@ -125,7 +125,7 @@ contract __unstable__ERC20Owned is ERC20, ERC20Detailed, Ownable {
// The owner has 'infinite' allowance for all token holders
function allowance(address tokenOwner, address spender) public view override(ERC20, IERC20) returns (uint256) {
if (spender == owner()) {
return UINT256_MAX;
return _UINT256_MAX;
} else {
return super.allowance(tokenOwner, spender);
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/introspection/ERC165Checker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library ERC165Checker {
/**
* @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
// InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
Expand All @@ -32,9 +32,9 @@ library ERC165Checker {
*
* 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
return _supportsERC165(account) &&
return supportsERC165(account) &&
_supportsERC165Interface(account, interfaceId);
}

Expand All @@ -47,9 +47,9 @@ library ERC165Checker {
*
* 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
if (!_supportsERC165(account)) {
if (!supportsERC165(account)) {
return false;
}

Expand All @@ -72,7 +72,7 @@ library ERC165Checker {
* identifier interfaceId, false otherwise
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* 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.
*/
function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
Expand Down
4 changes: 2 additions & 2 deletions contracts/introspection/ERC1820Implementer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import "./IERC1820Implementer.sol";
* registration to be complete.
*/
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;

/**
* See {IERC1820Implementer-canImplementInterfaceForAddress}.
*/
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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions contracts/math/SignedSafeMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.6.0;
* @dev Signed math operations with safety checks that revert on error.
*/
library SignedSafeMath {
int256 constant private INT256_MIN = -2**255;
int256 constant private _INT256_MIN = -2**255;

/**
* @dev Multiplies two signed integers, reverts on overflow.
Expand All @@ -18,7 +18,7 @@ library SignedSafeMath {
return 0;
}

require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: multiplication overflow");
require(!(a == -1 && b == _INT256_MIN), "SignedSafeMath: multiplication overflow");

int256 c = a * b;
require(c / a == b, "SignedSafeMath: multiplication overflow");
Expand All @@ -31,7 +31,7 @@ library SignedSafeMath {
*/
function div(int256 a, int256 b) internal pure returns (int256) {
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;

Expand Down
10 changes: 5 additions & 5 deletions contracts/mocks/ArraysImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import "../utils/Arrays.sol";
contract ArraysImpl {
using Arrays for uint256[];

uint256[] private array;
uint256[] private _array;

constructor (uint256[] memory _array) public {
array = _array;
constructor (uint256[] memory array) public {
_array = array;
}

function findUpperBound(uint256 _element) external view returns (uint256) {
return array.findUpperBound(_element);
function findUpperBound(uint256 element) external view returns (uint256) {
return _array.findUpperBound(element);
}
}
6 changes: 3 additions & 3 deletions contracts/mocks/ERC165CheckerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ contract ERC165CheckerMock {
using ERC165Checker for address;

function supportsERC165(address account) public view returns (bool) {
return account._supportsERC165();
return account.supportsERC165();
}

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) {
return account._supportsAllInterfaces(interfaceIds);
return account.supportsAllInterfaces(interfaceIds);
}
}
12 changes: 6 additions & 6 deletions contracts/mocks/ERC777SenderRecipientMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,

IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);

bytes32 constant private TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
bytes32 constant private _TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
bytes32 constant private _TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");

function tokensToSend(
address operator,
Expand Down Expand Up @@ -103,7 +103,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
}

function senderFor(address account) public {
_registerInterfaceForAddress(TOKENS_SENDER_INTERFACE_HASH, account);
_registerInterfaceForAddress(_TOKENS_SENDER_INTERFACE_HASH, account);

address self = address(this);
if (account == self) {
Expand All @@ -112,11 +112,11 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
}

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 {
_registerInterfaceForAddress(TOKENS_RECIPIENT_INTERFACE_HASH, account);
_registerInterfaceForAddress(_TOKENS_RECIPIENT_INTERFACE_HASH, account);

address self = address(this);
if (account == self) {
Expand All @@ -125,7 +125,7 @@ contract ERC777SenderRecipientMock is Context, IERC777Sender, IERC777Recipient,
}

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 {
Expand Down
14 changes: 7 additions & 7 deletions contracts/mocks/EnumerableSetMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ contract EnumerableSetMock{

event TransactionResult(bool result);

EnumerableSet.AddressSet private set;
EnumerableSet.AddressSet private _set;

function contains(address value) public view returns (bool) {
return set.contains(value);
return _set.contains(value);
}

function add(address value) public {
bool result = set.add(value);
bool result = _set.add(value);
emit TransactionResult(result);
}

function remove(address value) public {
bool result = set.remove(value);
bool result = _set.remove(value);
emit TransactionResult(result);
}

function enumerate() public view returns (address[] memory) {
return set.enumerate();
return _set.enumerate();
}

function length() public view returns (uint256) {
return set.length();
return _set.length();
}

function get(uint256 index) public view returns (address) {
return set.get(index);
return _set.get(index);
}
}
10 changes: 5 additions & 5 deletions contracts/mocks/ReentrancyMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ contract ReentrancyMock is ReentrancyGuard {
}

function callback() external nonReentrant {
count();
_count();
}

function countLocalRecursive(uint256 n) public nonReentrant {
if (n > 0) {
count();
_count();
countLocalRecursive(n - 1);
}
}

function countThisRecursive(uint256 n) public nonReentrant {
if (n > 0) {
count();
_count();
// solhint-disable-next-line avoid-low-level-calls
(bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1));
require(success, "ReentrancyMock: failed call");
}
}

function countAndCall(ReentrancyAttack attacker) public nonReentrant {
count();
_count();
bytes4 func = bytes4(keccak256("callback()"));
attacker.callSender(func);
}

function count() private {
function _count() private {
counter += 1;
}
}
12 changes: 6 additions & 6 deletions contracts/token/ERC20/SafeERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ library SafeERC20 {
using Address for address;

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 {
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 {
Expand All @@ -33,17 +33,17 @@ library SafeERC20 {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"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 {
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 {
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));
}

/**
Expand All @@ -52,7 +52,7 @@ library SafeERC20 {
* @param token The token targeted by the call.
* @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're implementing it ourselves.

Expand Down
Loading