use _execute in "shortcut" modifier to respect nonces, txCounts & events

This commit is contained in:
Ricardo Guilherme Schmidt 2018-05-09 02:19:07 -03:00
parent 86dd249b26
commit 3fefac4c74
1 changed files with 7 additions and 12 deletions

View File

@ -29,16 +29,11 @@ contract Identity is ERC725, ERC735, MessageSigned {
mapping(bytes32 => bool) approvals; mapping(bytes32 => bool) approvals;
} }
modifier selfOrSenderKey(uint256 keyPurpose) { modifier managementOnly {
if(msg.sender == address(this)) { if(msg.sender == address(this)) {
_; _;
} else { } else {
require(isKeyPurpose(keccak256(msg.sender), keyPurpose)); _execute(keccak256(msg.sender), address(this), 0, msg.data);
if (purposeThreshold[keyPurpose] == 1) {
_;
} else {
execute(address(this), 0, msg.data);
}
} }
} }
@ -162,7 +157,7 @@ contract Identity is ERC725, ERC735, MessageSigned {
uint256 _type uint256 _type
) )
public public
selfOrSenderKey(MANAGEMENT_KEY) managementOnly
returns (bool success) returns (bool success)
{ {
_addKey(_key, _purpose, _type); _addKey(_key, _purpose, _type);
@ -175,7 +170,7 @@ contract Identity is ERC725, ERC735, MessageSigned {
uint256 _newType uint256 _newType
) )
public public
selfOrSenderKey(MANAGEMENT_KEY) managementOnly
returns (bool success) returns (bool success)
{ {
uint256 purpose = keys[_oldKey].purpose; uint256 purpose = keys[_oldKey].purpose;
@ -189,7 +184,7 @@ contract Identity is ERC725, ERC735, MessageSigned {
uint256 _purpose uint256 _purpose
) )
public public
selfOrSenderKey(MANAGEMENT_KEY) managementOnly
returns (bool success) returns (bool success)
{ {
_removeKey(_key, _purpose); _removeKey(_key, _purpose);
@ -201,7 +196,7 @@ contract Identity is ERC725, ERC735, MessageSigned {
uint256 _minimumApprovals uint256 _minimumApprovals
) )
public public
selfOrSenderKey(MANAGEMENT_KEY) managementOnly
{ {
require(_minimumApprovals > 0); require(_minimumApprovals > 0);
require(_minimumApprovals <= keysByPurpose[_purpose].length); require(_minimumApprovals <= keysByPurpose[_purpose].length);
@ -210,7 +205,7 @@ contract Identity is ERC725, ERC735, MessageSigned {
function setupRecovery(address _recoveryContract) function setupRecovery(address _recoveryContract)
public public
selfOrSenderKey(MANAGEMENT_KEY) managementOnly
{ {
require(recoveryContract == address(0)); require(recoveryContract == address(0));
recoveryContract = _recoveryContract; recoveryContract = _recoveryContract;