From 9db63b9b01ffe4cf9b61637c29686fa86a7d9241 Mon Sep 17 00:00:00 2001 From: benk10 Date: Wed, 19 Feb 2020 13:08:44 +0200 Subject: [PATCH] Fix unregister DAO --- contracts/DAORegistry.sol | 8 ++-- package-lock.json | 83 +++++++++++++++++++++++---------------- package.json | 2 +- test/daoregistry.js | 14 ++++--- 4 files changed, 64 insertions(+), 43 deletions(-) diff --git a/contracts/DAORegistry.sol b/contracts/DAORegistry.sol index f084327..626a8c4 100644 --- a/contracts/DAORegistry.sol +++ b/contracts/DAORegistry.sol @@ -6,7 +6,7 @@ contract DAORegistry is Ownable { event Propose(address indexed _avatar); event Register(address indexed _avatar, string _name); - event UnRegister(address indexed _avatar); + event UnRegister(address indexed _avatar, string _name); mapping(string=>bool) private registry; @@ -20,8 +20,10 @@ contract DAORegistry is Ownable { emit Register(_avatar, _name); } - function unRegister(address _avatar) public onlyOwner { - emit UnRegister(_avatar); + function unRegister(address _avatar, string memory _name) public onlyOwner { + require(registry[_name]); + registry[_name] = false; + emit UnRegister(_avatar, _name); } //This getter is needed because Dynamically-sized keys for public mappings are not supported. diff --git a/package-lock.json b/package-lock.json index 18dd119..57793da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc-hive", - "version": "0.0.1-rc.5", + "version": "0.0.1-rc.6", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3392,8 +3392,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3414,14 +3413,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3436,20 +3433,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3566,8 +3560,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3579,7 +3572,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3594,7 +3586,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3602,14 +3593,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -3628,7 +3617,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3709,8 +3697,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3722,7 +3709,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3808,8 +3794,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3845,7 +3830,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3865,7 +3849,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3909,14 +3892,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -4605,6 +4586,12 @@ } } }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -7260,6 +7247,18 @@ } } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, "require-uncached": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/require-uncached/-/require-uncached-1.0.3.tgz", @@ -7493,6 +7492,12 @@ "xhr": "^2.3.3" } }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -9596,7 +9601,7 @@ "requires": { "underscore": "1.9.1", "web3-core-helpers": "1.2.1", - "websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis" + "websocket": "github:web3-js/WebSocket-Node#905deb4812572b344f5801f8c9ce8bb02799d82e" } }, "web3-shh": { @@ -9768,6 +9773,12 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, "yaeti": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", @@ -9791,15 +9802,21 @@ }, "yargs": { "version": "11.1.0", - "resolved": "", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", + "integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==", "dev": true, "requires": { "cliui": "^4.0.0", "decamelize": "^1.1.1", "find-up": "^2.1.0", + "get-caller-file": "^1.0.1", "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", "string-width": "^2.0.0", "which-module": "^2.0.0", + "y18n": "^3.2.1", "yargs-parser": "^9.0.2" }, "dependencies": { diff --git a/package.json b/package.json index 306f7c2..5693685 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc-hive", - "version": "0.0.1-rc.5", + "version": "0.0.1-rc.6", "description": "A dao's registry", "files": [ "contracts/", diff --git a/test/daoregistry.js b/test/daoregistry.js index c429878..87070f5 100644 --- a/test/daoregistry.js +++ b/test/daoregistry.js @@ -56,21 +56,23 @@ contract('DAORegistry', accounts => { await daoRegistry.initialize(accounts[1]); await daoRegistry.register(accounts[0],"test",{from:accounts[1]}); try { - await daoRegistry.unRegister(accounts[0]); + await daoRegistry.unRegister(accounts[0],"test"); assert(false, 'wrong owner'); - } catch (ex) { - assertVMException(ex); - } + } catch (ex) { + assertVMException(ex); + } + assert.equal(await daoRegistry.isRegister("test"),true); }); it("unRegister", async () => { var daoRegistry = await DAORegistry.new(); await daoRegistry.initialize(accounts[0]); await daoRegistry.register(accounts[0],"test"); - var tx = await daoRegistry.unRegister(accounts[0]); + var tx = await daoRegistry.unRegister(accounts[0],"test"); assert.equal(tx.logs.length, 1); assert.equal(tx.logs[0].event, "UnRegister"); assert.equal(tx.logs[0].args._avatar,accounts[0]); - assert.equal(await daoRegistry.isRegister("test"),true); + assert.equal(tx.logs[0].args._name,"test"); + assert.equal(await daoRegistry.isRegister("test"),false); }); });