Remove abbreviations from parameters (#1142)
* Add an initial document for our code style * Remove abbreviations from parameters * Rename the param in AddressUtils * fix comment
This commit is contained in:
committed by
Nicolás Venturo
parent
7fdca7b025
commit
f49721576f
@ -22,10 +22,10 @@ import "../ECRecovery.sol";
|
||||
* `onlyValidSignatureAndData` can be used to restrict access to only a given method
|
||||
* or a given method with given parameters respectively.
|
||||
* See the tests Bouncer.test.js for specific usage examples.
|
||||
* @notice A method that uses the `onlyValidSignatureAndData` modifier must make the _sig
|
||||
* @notice A method that uses the `onlyValidSignatureAndData` modifier must make the _signature
|
||||
* parameter the "last" parameter. You cannot sign a message that has its own
|
||||
* signature in it so the last 128 bytes of msg.data (which represents the
|
||||
* length of the _sig data and the _sig data itself) is ignored when validating.
|
||||
* length of the _signature data and the _signaature data itself) is ignored when validating.
|
||||
* Also non fixed sized parameters make constructing the data in the signature
|
||||
* much more complex. See https://ethereum.stackexchange.com/a/50616 for more details.
|
||||
*/
|
||||
@ -40,27 +40,27 @@ contract SignatureBouncer is Ownable, RBAC {
|
||||
/**
|
||||
* @dev requires that a valid signature of a bouncer was provided
|
||||
*/
|
||||
modifier onlyValidSignature(bytes _sig)
|
||||
modifier onlyValidSignature(bytes _signature)
|
||||
{
|
||||
require(isValidSignature(msg.sender, _sig));
|
||||
require(isValidSignature(msg.sender, _signature));
|
||||
_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev requires that a valid signature with a specifed method of a bouncer was provided
|
||||
*/
|
||||
modifier onlyValidSignatureAndMethod(bytes _sig)
|
||||
modifier onlyValidSignatureAndMethod(bytes _signature)
|
||||
{
|
||||
require(isValidSignatureAndMethod(msg.sender, _sig));
|
||||
require(isValidSignatureAndMethod(msg.sender, _signature));
|
||||
_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev requires that a valid signature with a specifed method and params of a bouncer was provided
|
||||
*/
|
||||
modifier onlyValidSignatureAndData(bytes _sig)
|
||||
modifier onlyValidSignatureAndData(bytes _signature)
|
||||
{
|
||||
require(isValidSignatureAndData(msg.sender, _sig));
|
||||
require(isValidSignatureAndData(msg.sender, _signature));
|
||||
_;
|
||||
}
|
||||
|
||||
@ -90,14 +90,14 @@ contract SignatureBouncer is Ownable, RBAC {
|
||||
* @dev is the signature of `this + sender` from a bouncer?
|
||||
* @return bool
|
||||
*/
|
||||
function isValidSignature(address _address, bytes _sig)
|
||||
function isValidSignature(address _address, bytes _signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return isValidDataHash(
|
||||
keccak256(abi.encodePacked(address(this), _address)),
|
||||
_sig
|
||||
_signature
|
||||
);
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ contract SignatureBouncer is Ownable, RBAC {
|
||||
* @dev is the signature of `this + sender + methodId` from a bouncer?
|
||||
* @return bool
|
||||
*/
|
||||
function isValidSignatureAndMethod(address _address, bytes _sig)
|
||||
function isValidSignatureAndMethod(address _address, bytes _signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
@ -116,16 +116,16 @@ contract SignatureBouncer is Ownable, RBAC {
|
||||
}
|
||||
return isValidDataHash(
|
||||
keccak256(abi.encodePacked(address(this), _address, data)),
|
||||
_sig
|
||||
_signature
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev is the signature of `this + sender + methodId + params(s)` from a bouncer?
|
||||
* @notice the _sig parameter of the method being validated must be the "last" parameter
|
||||
* @notice the _signature parameter of the method being validated must be the "last" parameter
|
||||
* @return bool
|
||||
*/
|
||||
function isValidSignatureAndData(address _address, bytes _sig)
|
||||
function isValidSignatureAndData(address _address, bytes _signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
@ -137,7 +137,7 @@ contract SignatureBouncer is Ownable, RBAC {
|
||||
}
|
||||
return isValidDataHash(
|
||||
keccak256(abi.encodePacked(address(this), _address, data)),
|
||||
_sig
|
||||
_signature
|
||||
);
|
||||
}
|
||||
|
||||
@ -146,14 +146,14 @@ contract SignatureBouncer is Ownable, RBAC {
|
||||
* and then recover the signature and check it against the bouncer role
|
||||
* @return bool
|
||||
*/
|
||||
function isValidDataHash(bytes32 _hash, bytes _sig)
|
||||
function isValidDataHash(bytes32 _hash, bytes _signature)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
address signer = _hash
|
||||
.toEthSignedMessageHash()
|
||||
.recover(_sig);
|
||||
.recover(_signature);
|
||||
return hasRole(signer, ROLE_BOUNCER);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,43 +13,43 @@ library Roles {
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev give an address access to this role
|
||||
* @dev give an account access to this role
|
||||
*/
|
||||
function add(Role storage _role, address _addr)
|
||||
function add(Role storage _role, address _account)
|
||||
internal
|
||||
{
|
||||
_role.bearer[_addr] = true;
|
||||
_role.bearer[_account] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev remove an address' access to this role
|
||||
* @dev remove an account's access to this role
|
||||
*/
|
||||
function remove(Role storage _role, address _addr)
|
||||
function remove(Role storage _role, address _account)
|
||||
internal
|
||||
{
|
||||
_role.bearer[_addr] = false;
|
||||
_role.bearer[_account] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev check if an address has this role
|
||||
* @dev check if an account has this role
|
||||
* // reverts
|
||||
*/
|
||||
function check(Role storage _role, address _addr)
|
||||
function check(Role storage _role, address _account)
|
||||
internal
|
||||
view
|
||||
{
|
||||
require(has(_role, _addr));
|
||||
require(has(_role, _account));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev check if an address has this role
|
||||
* @dev check if an account has this role
|
||||
* @return bool
|
||||
*/
|
||||
function has(Role storage _role, address _addr)
|
||||
function has(Role storage _role, address _account)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
return _role.bearer[_addr];
|
||||
return _role.bearer[_account];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user