From d8bad21f20cb715509895de55ac74e593ac53fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20J=C3=B8rgensen?= Date: Fri, 6 Sep 2019 09:56:21 +0200 Subject: [PATCH] add: identity renounce claimer function --- contracts/identity/Identity.sol | 18 +++++++++++++----- test/Identity.test.ts | 7 +++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/contracts/identity/Identity.sol b/contracts/identity/Identity.sol index 2c425024..fa438ade 100644 --- a/contracts/identity/Identity.sol +++ b/contracts/identity/Identity.sol @@ -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 @@ -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 diff --git a/test/Identity.test.ts b/test/Identity.test.ts index 9bd7966d..a7cef060 100644 --- a/test/Identity.test.ts +++ b/test/Identity.test.ts @@ -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();