Skip to content

Commit

Permalink
add: identity renounce claimer function
Browse files Browse the repository at this point in the history
  • Loading branch information
Maasdamind committed Sep 6, 2019
1 parent aebbc0c commit d8bad21
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
18 changes: 13 additions & 5 deletions contracts/identity/Identity.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ contract Identity is IdentityAdminRole, SchemeGuard {
onlyRegistered
onlyIdentityAdmin
{
claimers.remove(account);

decreaseClaimerCount(1);
delete dateAdded[account];
_removeClaimer(account);
}

emit ClaimerRemoved(account);
function renounceClaimer() public {
_removeClaimer(msg.sender);
}

/* @dev Reverts if given address has not been added to claimers
Expand Down Expand Up @@ -116,6 +115,15 @@ contract Identity is IdentityAdminRole, SchemeGuard {
emit BlacklistRemoved(account);
}

function _removeClaimer(address account) internal {
claimers.remove(account);

decreaseClaimerCount(1);
delete dateAdded[account];

emit ClaimerRemoved(account);
}

/* @dev Reverts if given address has been added to the blacklist
* @param account the address to check
* @return a bool indicating weather the address is present in the blacklist
Expand Down
7 changes: 7 additions & 0 deletions test/Identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ contract("Identity - Blacklist and Claimer", ([founder, blacklisted, blacklisted
await identity.removeClaimer(claimer);
});

it("should renounce claimer", async () => {
await identity.addClaimer(claimer);
assert(await identity.isClaimer(claimer));
await identity.renounceClaimer({ from: claimer });
assert(!(await identity.isClaimer(claimer)));
})

it("should not allow setting non-registered identity contract", async () => {
await helpers.assertVMException(identityGuard.setIdentity(dangerIdentity.address, avatar.address), "Scheme is not registered");
dangerIdentity = await Identity.new();
Expand Down

0 comments on commit d8bad21

Please sign in to comment.