From 3fefac4c74a12e162568e4fc00368add45b217cc Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Wed, 9 May 2018 02:19:07 -0300 Subject: [PATCH] use _execute in "shortcut" modifier to respect nonces, txCounts & events --- contracts/identity/Identity.sol | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/contracts/identity/Identity.sol b/contracts/identity/Identity.sol index b7fb70d..d48b289 100644 --- a/contracts/identity/Identity.sol +++ b/contracts/identity/Identity.sol @@ -29,16 +29,11 @@ contract Identity is ERC725, ERC735, MessageSigned { mapping(bytes32 => bool) approvals; } - modifier selfOrSenderKey(uint256 keyPurpose) { + modifier managementOnly { if(msg.sender == address(this)) { _; } else { - require(isKeyPurpose(keccak256(msg.sender), keyPurpose)); - if (purposeThreshold[keyPurpose] == 1) { - _; - } else { - execute(address(this), 0, msg.data); - } + _execute(keccak256(msg.sender), address(this), 0, msg.data); } } @@ -162,7 +157,7 @@ contract Identity is ERC725, ERC735, MessageSigned { uint256 _type ) public - selfOrSenderKey(MANAGEMENT_KEY) + managementOnly returns (bool success) { _addKey(_key, _purpose, _type); @@ -175,7 +170,7 @@ contract Identity is ERC725, ERC735, MessageSigned { uint256 _newType ) public - selfOrSenderKey(MANAGEMENT_KEY) + managementOnly returns (bool success) { uint256 purpose = keys[_oldKey].purpose; @@ -189,7 +184,7 @@ contract Identity is ERC725, ERC735, MessageSigned { uint256 _purpose ) public - selfOrSenderKey(MANAGEMENT_KEY) + managementOnly returns (bool success) { _removeKey(_key, _purpose); @@ -201,7 +196,7 @@ contract Identity is ERC725, ERC735, MessageSigned { uint256 _minimumApprovals ) public - selfOrSenderKey(MANAGEMENT_KEY) + managementOnly { require(_minimumApprovals > 0); require(_minimumApprovals <= keysByPurpose[_purpose].length); @@ -210,7 +205,7 @@ contract Identity is ERC725, ERC735, MessageSigned { function setupRecovery(address _recoveryContract) public - selfOrSenderKey(MANAGEMENT_KEY) + managementOnly { require(recoveryContract == address(0)); recoveryContract = _recoveryContract;