move events and nonce increment

This commit is contained in:
Ricardo Guilherme Schmidt 2018-03-24 05:16:54 -03:00
parent 7b179ec04c
commit 334f6754af
1 changed files with 19 additions and 19 deletions

View File

@ -452,7 +452,7 @@ contract Identity is ERC725, ERC735 {
returns (uint256 executionId) returns (uint256 executionId)
{ {
executionId = nonce; executionId = nonce;
emit ExecutionRequested(executionId, _to, _value, _data); nonce++;
txx[executionId] = Transaction({ txx[executionId] = Transaction({
to: _to, to: _to,
value: _value, value: _value,
@ -460,7 +460,7 @@ contract Identity is ERC725, ERC735 {
nonce: nonce, nonce: nonce,
approverCount: 0 approverCount: 0
}); });
nonce++; emit ExecutionRequested(executionId, _to, _value, _data);
} }
function _approve( function _approve(
@ -477,8 +477,6 @@ contract Identity is ERC725, ERC735 {
uint256 approvalCount; uint256 approvalCount;
uint256 requiredKeyPurpose; uint256 requiredKeyPurpose;
emit Approved(_id, _approval);
if (trx.to == address(this)) { if (trx.to == address(this)) {
require(isKeyPurpose(_key, MANAGEMENT_KEY)); require(isKeyPurpose(_key, MANAGEMENT_KEY));
bytes32 managerKeyHash = keccak256(_key, MANAGEMENT_KEY); bytes32 managerKeyHash = keccak256(_key, MANAGEMENT_KEY);
@ -491,6 +489,8 @@ contract Identity is ERC725, ERC735 {
approvalCount = _calculateApprovals(actorKeyHash, _approval, trx); approvalCount = _calculateApprovals(actorKeyHash, _approval, trx);
} }
emit Approved(_id, _approval);
if (approvalCount >= minimumApprovalsByKeyPurpose[requiredKeyPurpose]) { if (approvalCount >= minimumApprovalsByKeyPurpose[requiredKeyPurpose]) {
//(?) success should be included in event? //(?) success should be included in event?
success = trx.to.call.value(trx.value)(trx.data); success = trx.to.call.value(trx.value)(trx.data);
@ -514,9 +514,9 @@ contract Identity is ERC725, ERC735 {
_purpose == CLAIM_SIGNER_KEY || _purpose == CLAIM_SIGNER_KEY ||
_purpose == ENCRYPTION_KEY _purpose == ENCRYPTION_KEY
); );
emit KeyAdded(_key, _purpose, _type);
keys[keyHash] = Key(_purpose, _type, _key); keys[keyHash] = Key(_purpose, _type, _key);
indexes[keyHash] = keysByPurpose[_purpose].push(_key) - 1; indexes[keyHash] = keysByPurpose[_purpose].push(_key) - 1;
emit KeyAdded(_key, _purpose, _type);
} }
function _removeKey( function _removeKey(
@ -526,8 +526,7 @@ contract Identity is ERC725, ERC735 {
private private
{ {
bytes32 keyHash = keccak256(_key, _purpose); bytes32 keyHash = keccak256(_key, _purpose);
Key storage myKey = keys[keyHash]; Key memory myKey = keys[keyHash];
emit KeyRemoved(myKey.key, myKey.purpose, myKey.keyType);
uint index = indexes[keyHash]; uint index = indexes[keyHash];
delete indexes[keyHash]; delete indexes[keyHash];
@ -545,6 +544,7 @@ contract Identity is ERC725, ERC735 {
} }
delete keys[keyHash]; delete keys[keyHash];
emit KeyRemoved(myKey.key, myKey.purpose, myKey.keyType);
} }
function _calculateApprovals( function _calculateApprovals(
@ -615,6 +615,14 @@ contract Identity is ERC725, ERC735 {
private private
{ {
require(msg.sender == _issuer); require(msg.sender == _issuer);
claims[_claimHash] = Claim({
claimType: _claimType,
scheme: _scheme,
issuer: _issuer,
signature: _signature,
data: _data,
uri: _uri
});
emit ClaimChanged( emit ClaimChanged(
_claimHash, _claimHash,
_claimType, _claimType,
@ -624,14 +632,6 @@ contract Identity is ERC725, ERC735 {
_data, _data,
_uri _uri
); );
claims[_claimHash] = Claim({
claimType: _claimType,
scheme: _scheme,
issuer: _issuer,
signature: _signature,
data: _data,
uri: _uri
});
} }