From 16c79b58c4f46d654f60f84950acc2947d7f7a4a Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Wed, 1 Apr 2020 23:48:36 -0400 Subject: [PATCH 01/10] Add from argument to grant function --- packages/toolkit/src/apm/grantNewVersionsPermission.js | 2 +- packages/toolkit/src/apm/util/acl.js | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/toolkit/src/apm/grantNewVersionsPermission.js b/packages/toolkit/src/apm/grantNewVersionsPermission.js index 086077e4f..7329e0bcd 100644 --- a/packages/toolkit/src/apm/grantNewVersionsPermission.js +++ b/packages/toolkit/src/apm/grantNewVersionsPermission.js @@ -36,7 +36,7 @@ export default async ( const from = accounts[0] // Build transaction - const transaction = await acl.grant(repo.options.address, address) + const transaction = await acl.grant(repo.options.address, address, from) transaction.from = from transaction.gasPrice = gasPrice diff --git a/packages/toolkit/src/apm/util/acl.js b/packages/toolkit/src/apm/util/acl.js index eea90602f..4b297da3f 100644 --- a/packages/toolkit/src/apm/util/acl.js +++ b/packages/toolkit/src/apm/util/acl.js @@ -21,13 +21,12 @@ export default web3 => { } return { - grant: async (repoAddr, grantee) => { + grant: async (repoAddr, grantee, from) => { const acl = await getACL(repoAddr) const roleId = await getRoleId(repoAddr) - const call = acl.methods.grantPermission(grantee, repoAddr, roleId) - const estimatedGas = call.estimateGas() + const estimatedGas = call.estimateGas({ from }) return { to: acl.options.address, From 95ce984fbb3b5a786fee7b65c305cdd664762843 Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 10:13:40 -0400 Subject: [PATCH 02/10] Add revoke function to acl --- packages/toolkit/src/apm/util/acl.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/toolkit/src/apm/util/acl.js b/packages/toolkit/src/apm/util/acl.js index 4b297da3f..4a5590911 100644 --- a/packages/toolkit/src/apm/util/acl.js +++ b/packages/toolkit/src/apm/util/acl.js @@ -34,5 +34,19 @@ export default web3 => { gas: await getRecommendedGasLimit(web3, estimatedGas), } }, + + revoke: async (repoAddr, grantee, from) => { + const acl = await getACL(repoAddr) + + const roleId = await getRoleId(repoAddr) + const call = acl.methods.revokePermission(grantee, repoAddr, roleId) + const estimatedGas = call.estimateGas({ from }) + + return { + to: acl.options.address, + data: call.encodeABI(), + gas: await getRecommendedGasLimit(web3, estimatedGas), + } + }, } } From 5af55fd727032a6a6835e5961b62361c3256f72d Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 14:32:09 -0400 Subject: [PATCH 03/10] Add revokePermission function --- packages/toolkit/src/apm/revokePermission.js | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/toolkit/src/apm/revokePermission.js diff --git a/packages/toolkit/src/apm/revokePermission.js b/packages/toolkit/src/apm/revokePermission.js new file mode 100644 index 000000000..ec7a8dce4 --- /dev/null +++ b/packages/toolkit/src/apm/revokePermission.js @@ -0,0 +1,48 @@ +import APM from '@aragon/apm' +import ACL from './util/acl' + +export default async ( + web3, + apmRepoName, + apmOptions, + entity, + progressHandler = () => {}, + { gasPrice } +) => { + if (entity.length === 0) { + throw new Error('No addresse provided') + } + + const apm = await APM(web3, apmOptions) + const acl = ACL(web3) + + progressHandler(1) + + const repo = await apm.getRepository(apmRepoName) + if (repo === null) { + throw new Error( + `Repository ${apmRepoName} does not exist and it's registry does not exist` + ) + } + + const receipts = [] + + /* eslint-disable-next-line */ + progressHandler(2, address) + + // Decode sender + const accounts = await web3.eth.getAccounts() + const from = accounts[0] + + // Build transaction + const transaction = await acl.revoke(repo.options.address, address, from) + + transaction.from = from + transaction.gasPrice = gasPrice + // the recommended gasLimit is already calculated by the ACL module + + const receipt = await web3.eth.sendTransaction(transaction) + progressHandler(3, receipt.transactionHash) + + return receipt +} From 95fc70fbf7148b833896165acbf25fa2ccecc11e Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 16:14:28 -0400 Subject: [PATCH 04/10] Add revoke command --- packages/cli/src/commands/apm_cmds/revoke.js | 59 ++++++++++++++++++++ packages/toolkit/src/apm/index.js | 1 + packages/toolkit/src/apm/revokePermission.js | 5 +- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 packages/cli/src/commands/apm_cmds/revoke.js diff --git a/packages/cli/src/commands/apm_cmds/revoke.js b/packages/cli/src/commands/apm_cmds/revoke.js new file mode 100644 index 000000000..2e09e3178 --- /dev/null +++ b/packages/cli/src/commands/apm_cmds/revoke.js @@ -0,0 +1,59 @@ +import { blue } from 'chalk' +import { revokePermission } from '@aragon/toolkit' +// +import { ensureWeb3 } from '../../helpers/web3-fallback' + +export const command = 'revoke entity' +export const describe = + 'Revoke and entity the permission to create new versions in this package' + +export const builder = function(yargs) { + return yargs.positional('entity', { + description: + 'The address being revoked the permission to publish to the repo', + }) +} + +export const handler = async function({ + // Globals + reporter, + gasPrice, + network, + module, + apm: apmOptions, + // Arguments + entity, +}) { + const web3 = await ensureWeb3(network) + + const progressHandler = (step, data) => { + switch (step) { + case 1: + reporter.info(`Fetching repository`) + break + case 2: + // eslint-disable-next-line no-case-declarations + const address = data + reporter.info( + `Revoking permission to publish on ${blue( + module.appName + )} for ${address}` + ) + break + case 3: + // eslint-disable-next-line no-case-declarations + const txHash = data + reporter.success(`Successful transaction (${blue(txHash)})`) + break + } + } + + await revokePermission( + web3, + module.appName, + apmOptions, + entity, + progressHandler, + { gasPrice: gasPrice || network.gasPrice } + ) +} diff --git a/packages/toolkit/src/apm/index.js b/packages/toolkit/src/apm/index.js index 2543d7a9f..851ff1ce3 100644 --- a/packages/toolkit/src/apm/index.js +++ b/packages/toolkit/src/apm/index.js @@ -6,3 +6,4 @@ export { default as grantNewVersionsPermission } from './grantNewVersionsPermiss export { default as apmPublishVersion } from './apmPublishVersion' export { default as apmPublishVersionIntent } from './apmPublishVersionIntent' export { default as apmGetFile } from './apmGetFile' +export { default as revokePermission } from './revokePermission' diff --git a/packages/toolkit/src/apm/revokePermission.js b/packages/toolkit/src/apm/revokePermission.js index ec7a8dce4..9cbfa7cc9 100644 --- a/packages/toolkit/src/apm/revokePermission.js +++ b/packages/toolkit/src/apm/revokePermission.js @@ -25,17 +25,16 @@ export default async ( ) } - const receipts = [] /* eslint-disable-next-line */ - progressHandler(2, address) + progressHandler(2, entity) // Decode sender const accounts = await web3.eth.getAccounts() const from = accounts[0] // Build transaction - const transaction = await acl.revoke(repo.options.address, address, from) + const transaction = await acl.revoke(repo.options.address, entity, from) transaction.from = from transaction.gasPrice = gasPrice From cf5f30de70259345f8d5b8977ecd4515a4ce38a3 Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 16:31:42 -0400 Subject: [PATCH 05/10] Add apm manager command --- packages/cli/src/commands/apm_cmds/manager.js | 59 +++++++++++++++++++ packages/cli/src/commands/apm_cmds/revoke.js | 2 +- .../src/apm/apmSetPermissionManager.js | 47 +++++++++++++++ packages/toolkit/src/apm/index.js | 1 + packages/toolkit/src/apm/util/acl.js | 14 +++++ 5 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 packages/cli/src/commands/apm_cmds/manager.js create mode 100644 packages/toolkit/src/apm/apmSetPermissionManager.js diff --git a/packages/cli/src/commands/apm_cmds/manager.js b/packages/cli/src/commands/apm_cmds/manager.js new file mode 100644 index 000000000..e229a1336 --- /dev/null +++ b/packages/cli/src/commands/apm_cmds/manager.js @@ -0,0 +1,59 @@ +import { blue } from 'chalk' +import { apmSetPermissionManager } from '@aragon/toolkit' +// +import { ensureWeb3 } from '../../helpers/web3-fallback' + +export const command = 'manager ' +export const describe = + 'Set an entity as the permission manager of this package' + +export const builder = function(yargs) { + return yargs.positional('entity', { + description: + 'The address to be the new permission manager ofthe repo', + }) +} + +export const handler = async function({ + // Globals + reporter, + gasPrice, + network, + module, + apm: apmOptions, + // Arguments + entity, +}) { + const web3 = await ensureWeb3(network) + + const progressHandler = (step, data) => { + switch (step) { + case 1: + reporter.info(`Fetching repository`) + break + case 2: + // eslint-disable-next-line no-case-declarations + const address = data + reporter.info( + `Setting permission manager for ${blue( + module.appName + )} for ${address}` + ) + break + case 3: + // eslint-disable-next-line no-case-declarations + const txHash = data + reporter.success(`Successful transaction (${blue(txHash)})`) + break + } + } + + await apmSetPermissionManager( + web3, + module.appName, + apmOptions, + entity, + progressHandler, + { gasPrice: gasPrice || network.gasPrice } + ) +} diff --git a/packages/cli/src/commands/apm_cmds/revoke.js b/packages/cli/src/commands/apm_cmds/revoke.js index 2e09e3178..7921cbcff 100644 --- a/packages/cli/src/commands/apm_cmds/revoke.js +++ b/packages/cli/src/commands/apm_cmds/revoke.js @@ -5,7 +5,7 @@ import { ensureWeb3 } from '../../helpers/web3-fallback' export const command = 'revoke entity' export const describe = - 'Revoke and entity the permission to create new versions in this package' + 'Revoke an entity the permission to create new versions in this package' export const builder = function(yargs) { return yargs.positional('entity', { diff --git a/packages/toolkit/src/apm/apmSetPermissionManager.js b/packages/toolkit/src/apm/apmSetPermissionManager.js new file mode 100644 index 000000000..85e1987e3 --- /dev/null +++ b/packages/toolkit/src/apm/apmSetPermissionManager.js @@ -0,0 +1,47 @@ +import APM from '@aragon/apm' +import ACL from './util/acl' + +export default async ( + web3, + apmRepoName, + apmOptions, + entity, + progressHandler = () => {}, + { gasPrice } +) => { + if (entity.length === 0) { + throw new Error('No addresse provided') + } + + const apm = await APM(web3, apmOptions) + const acl = ACL(web3) + + progressHandler(1) + + const repo = await apm.getRepository(apmRepoName) + if (repo === null) { + throw new Error( + `Repository ${apmRepoName} does not exist and it's registry does not exist` + ) + } + + + /* eslint-disable-next-line */ + progressHandler(2, entity) + + // Decode sender + const accounts = await web3.eth.getAccounts() + const from = accounts[0] + + // Build transaction + const transaction = await acl.setPermissionManager(entity, repo.options.address, from) + + transaction.from = from + transaction.gasPrice = gasPrice + // the recommended gasLimit is already calculated by the ACL module + + const receipt = await web3.eth.sendTransaction(transaction) + progressHandler(3, receipt.transactionHash) + + return receipt +} diff --git a/packages/toolkit/src/apm/index.js b/packages/toolkit/src/apm/index.js index 851ff1ce3..a882d146c 100644 --- a/packages/toolkit/src/apm/index.js +++ b/packages/toolkit/src/apm/index.js @@ -7,3 +7,4 @@ export { default as apmPublishVersion } from './apmPublishVersion' export { default as apmPublishVersionIntent } from './apmPublishVersionIntent' export { default as apmGetFile } from './apmGetFile' export { default as revokePermission } from './revokePermission' +export { default as apmSetPermissionManager } from './apmSetPermissionManager' diff --git a/packages/toolkit/src/apm/util/acl.js b/packages/toolkit/src/apm/util/acl.js index 4a5590911..8becc19b5 100644 --- a/packages/toolkit/src/apm/util/acl.js +++ b/packages/toolkit/src/apm/util/acl.js @@ -48,5 +48,19 @@ export default web3 => { gas: await getRecommendedGasLimit(web3, estimatedGas), } }, + + setPermissionManager: async (entity, repoAddr, from) => { + const acl = await getACL(repoAddr) + + const roleId = await getRoleId(repoAddr) + const call = acl.methods.setPermissionManager(entity, repoAddr, roleId) + const estimatedGas = call.estimateGas({ from }) + + return { + to: acl.options.address, + data: call.encodeABI(), + gas: await getRecommendedGasLimit(web3, estimatedGas), + } + }, } } From f0788cff50da8740ea37258ba95e5a275543d32d Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 17:25:10 -0400 Subject: [PATCH 06/10] Add tests --- ...Permission.test.js => permissions.test.js} | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) rename packages/toolkit/test/apm/{grantNewVersionsPermission.test.js => permissions.test.js} (67%) diff --git a/packages/toolkit/test/apm/grantNewVersionsPermission.test.js b/packages/toolkit/test/apm/permissions.test.js similarity index 67% rename from packages/toolkit/test/apm/grantNewVersionsPermission.test.js rename to packages/toolkit/test/apm/permissions.test.js index c54db4520..9045bec88 100644 --- a/packages/toolkit/test/apm/grantNewVersionsPermission.test.js +++ b/packages/toolkit/test/apm/permissions.test.js @@ -2,6 +2,8 @@ import test from 'ava' import sinon from 'sinon' // import grantNewVersionsPermission from '../../src/apm/grantNewVersionsPermission' +import revokePermission from '../../src/apm/revokePermission' +import apmSetPermissionManager from '../../src/apm/apmSetPermissionManager' import { getLocalWeb3, getApmOptions } from '../test-helpers' import { abi as aclAbi } from '@aragon/abis/os/artifacts/ACL' @@ -67,7 +69,7 @@ test.before('setup and make a successful call', async t => { /* Tests */ -test('permissions are not set for any accounts', async t => { +test.serial('permissions are not set for any accounts', async t => { const anyone = accounts[2] const hasPermission = await acl.methods @@ -77,7 +79,7 @@ test('permissions are not set for any accounts', async t => { t.false(hasPermission) }) -test('properly sets permissions for grantees', async t => { +test.serial('properly sets permissions for grantees', async t => { const grantee = grantees[0] const hasPermission = await acl.methods @@ -87,7 +89,7 @@ test('properly sets permissions for grantees', async t => { t.true(hasPermission) }) -test('properly calls the progressHandler', t => { +test.serial('properly calls the progressHandler', t => { const receipt = receipts[0] t.is(progressHandler.callCount, 3) @@ -96,7 +98,7 @@ test('properly calls the progressHandler', t => { t.true(progressHandler.getCall(2).calledWith(3, receipt.transactionHash)) }) -test('Should throw when no grantees are provided', async t => { +test.serial('Should throw when no grantees are provided', async t => { await t.throwsAsync( grantNewVersionsPermission( web3, @@ -108,3 +110,41 @@ test('Should throw when no grantees are provided', async t => { ) ) }) + +test.serial('revokePermission properly revokes permission for entity', async t => { + const entity = grantees[0] + + await revokePermission( + web3, + apmRepoName, + apmOptions, + entity, + () => {}, + txOptions) + + const hasPermission = await acl.methods + .hasPermission(entity, repoAddress, role) + .call() + + t.false(hasPermission) +}) + +test.serial('apmSetPermissionManager properly sets the permission manager', async t => { + const entity = grantees[0] + + await apmSetPermissionManager( + web3, + apmRepoName, + apmOptions, + entity, + () => {}, + txOptions) + + const permissionManager = await acl.methods + .getPermissionManager(repoAddress, role) + .call() + + console.log(permissionManager) + + t.is(entity, permissionManager) +}) From dcc4d1739831c869ead52a3631c88f93eb95ae0b Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 18:01:06 -0400 Subject: [PATCH 07/10] Lint fix --- packages/cli/src/commands/apm_cmds/manager.js | 3 +- .../src/apm/apmSetPermissionManager.js | 7 +- packages/toolkit/src/apm/revokePermission.js | 1 - packages/toolkit/test/apm/permissions.test.js | 66 +++++++++++-------- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/packages/cli/src/commands/apm_cmds/manager.js b/packages/cli/src/commands/apm_cmds/manager.js index e229a1336..a3ada62bd 100644 --- a/packages/cli/src/commands/apm_cmds/manager.js +++ b/packages/cli/src/commands/apm_cmds/manager.js @@ -9,8 +9,7 @@ export const describe = export const builder = function(yargs) { return yargs.positional('entity', { - description: - 'The address to be the new permission manager ofthe repo', + description: 'The address to be the new permission manager ofthe repo', }) } diff --git a/packages/toolkit/src/apm/apmSetPermissionManager.js b/packages/toolkit/src/apm/apmSetPermissionManager.js index 85e1987e3..623748832 100644 --- a/packages/toolkit/src/apm/apmSetPermissionManager.js +++ b/packages/toolkit/src/apm/apmSetPermissionManager.js @@ -25,7 +25,6 @@ export default async ( ) } - /* eslint-disable-next-line */ progressHandler(2, entity) @@ -34,7 +33,11 @@ export default async ( const from = accounts[0] // Build transaction - const transaction = await acl.setPermissionManager(entity, repo.options.address, from) + const transaction = await acl.setPermissionManager( + entity, + repo.options.address, + from + ) transaction.from = from transaction.gasPrice = gasPrice diff --git a/packages/toolkit/src/apm/revokePermission.js b/packages/toolkit/src/apm/revokePermission.js index 9cbfa7cc9..03e4f9fd4 100644 --- a/packages/toolkit/src/apm/revokePermission.js +++ b/packages/toolkit/src/apm/revokePermission.js @@ -25,7 +25,6 @@ export default async ( ) } - /* eslint-disable-next-line */ progressHandler(2, entity) diff --git a/packages/toolkit/test/apm/permissions.test.js b/packages/toolkit/test/apm/permissions.test.js index 9045bec88..e8a24fe62 100644 --- a/packages/toolkit/test/apm/permissions.test.js +++ b/packages/toolkit/test/apm/permissions.test.js @@ -111,40 +111,48 @@ test.serial('Should throw when no grantees are provided', async t => { ) }) -test.serial('revokePermission properly revokes permission for entity', async t => { - const entity = grantees[0] +test.serial( + 'revokePermission properly revokes permission for entity', + async t => { + const entity = grantees[0] - await revokePermission( - web3, - apmRepoName, - apmOptions, - entity, - () => {}, - txOptions) + await revokePermission( + web3, + apmRepoName, + apmOptions, + entity, + () => {}, + txOptions + ) - const hasPermission = await acl.methods - .hasPermission(entity, repoAddress, role) - .call() + const hasPermission = await acl.methods + .hasPermission(entity, repoAddress, role) + .call() - t.false(hasPermission) -}) + t.false(hasPermission) + } +) -test.serial('apmSetPermissionManager properly sets the permission manager', async t => { - const entity = grantees[0] +test.serial( + 'apmSetPermissionManager properly sets the permission manager', + async t => { + const entity = grantees[0] - await apmSetPermissionManager( - web3, - apmRepoName, - apmOptions, - entity, - () => {}, - txOptions) + await apmSetPermissionManager( + web3, + apmRepoName, + apmOptions, + entity, + () => {}, + txOptions + ) - const permissionManager = await acl.methods - .getPermissionManager(repoAddress, role) - .call() + const permissionManager = await acl.methods + .getPermissionManager(repoAddress, role) + .call() - console.log(permissionManager) + console.log(permissionManager) - t.is(entity, permissionManager) -}) + t.is(entity, permissionManager) + } +) From fde3a17673f7c53616815897f774cb179365524a Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 18:41:53 -0400 Subject: [PATCH 08/10] Rename revokePermission function to apmRevokePermission --- packages/cli/src/commands/apm_cmds/revoke.js | 4 ++-- packages/cli/src/helpers/ensureDevchain.js | 2 +- .../apm/{revokePermission.js => apmRevokePermission.js} | 0 packages/toolkit/src/apm/index.js | 2 +- packages/toolkit/test/apm/permissions.test.js | 9 ++++----- 5 files changed, 8 insertions(+), 9 deletions(-) rename packages/toolkit/src/apm/{revokePermission.js => apmRevokePermission.js} (100%) diff --git a/packages/cli/src/commands/apm_cmds/revoke.js b/packages/cli/src/commands/apm_cmds/revoke.js index 7921cbcff..001b5afaf 100644 --- a/packages/cli/src/commands/apm_cmds/revoke.js +++ b/packages/cli/src/commands/apm_cmds/revoke.js @@ -1,5 +1,5 @@ import { blue } from 'chalk' -import { revokePermission } from '@aragon/toolkit' +import { apmRevokePermission } from '@aragon/toolkit' // import { ensureWeb3 } from '../../helpers/web3-fallback' @@ -48,7 +48,7 @@ export const handler = async function({ } } - await revokePermission( + await apmRevokePermission( web3, module.appName, apmOptions, diff --git a/packages/cli/src/helpers/ensureDevchain.js b/packages/cli/src/helpers/ensureDevchain.js index 69143d3fc..445c1ceb8 100644 --- a/packages/cli/src/helpers/ensureDevchain.js +++ b/packages/cli/src/helpers/ensureDevchain.js @@ -15,7 +15,7 @@ export const ensureDevchain = async ({ port, logger = noop }) => { try { const { detach } = await startProcess({ cmd: 'node', - args: [binPath, 'devchain', '--port', port], + args: [binPath, 'devchain', '--port', port, '--reset'], readyOutput: 'Devchain running at', execaOpts: { detached: true, diff --git a/packages/toolkit/src/apm/revokePermission.js b/packages/toolkit/src/apm/apmRevokePermission.js similarity index 100% rename from packages/toolkit/src/apm/revokePermission.js rename to packages/toolkit/src/apm/apmRevokePermission.js diff --git a/packages/toolkit/src/apm/index.js b/packages/toolkit/src/apm/index.js index a882d146c..5956cf254 100644 --- a/packages/toolkit/src/apm/index.js +++ b/packages/toolkit/src/apm/index.js @@ -6,5 +6,5 @@ export { default as grantNewVersionsPermission } from './grantNewVersionsPermiss export { default as apmPublishVersion } from './apmPublishVersion' export { default as apmPublishVersionIntent } from './apmPublishVersionIntent' export { default as apmGetFile } from './apmGetFile' -export { default as revokePermission } from './revokePermission' +export { default as apmRevokePermission } from './apmRevokePermission' export { default as apmSetPermissionManager } from './apmSetPermissionManager' diff --git a/packages/toolkit/test/apm/permissions.test.js b/packages/toolkit/test/apm/permissions.test.js index e8a24fe62..219364548 100644 --- a/packages/toolkit/test/apm/permissions.test.js +++ b/packages/toolkit/test/apm/permissions.test.js @@ -2,7 +2,7 @@ import test from 'ava' import sinon from 'sinon' // import grantNewVersionsPermission from '../../src/apm/grantNewVersionsPermission' -import revokePermission from '../../src/apm/revokePermission' +import apmRevokePermission from '../../src/apm/apmRevokePermission' import apmSetPermissionManager from '../../src/apm/apmSetPermissionManager' import { getLocalWeb3, getApmOptions } from '../test-helpers' @@ -67,6 +67,7 @@ test.before('setup and make a successful call', async t => { ) }) + /* Tests */ test.serial('permissions are not set for any accounts', async t => { @@ -112,11 +113,11 @@ test.serial('Should throw when no grantees are provided', async t => { }) test.serial( - 'revokePermission properly revokes permission for entity', + 'apmRevokePermission properly revokes permission for entity', async t => { const entity = grantees[0] - await revokePermission( + await apmRevokePermission( web3, apmRepoName, apmOptions, @@ -151,8 +152,6 @@ test.serial( .getPermissionManager(repoAddress, role) .call() - console.log(permissionManager) - t.is(entity, permissionManager) } ) From 126c8f7f71fddea21f40f2bbd32da0a82d815cd0 Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 18:49:43 -0400 Subject: [PATCH 09/10] Add doc --- docs/Apm-commands.md | 20 +++++++++++++++++++ packages/cli/src/commands/apm_cmds/manager.js | 8 ++------ packages/cli/src/commands/apm_cmds/revoke.js | 8 ++------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/docs/Apm-commands.md b/docs/Apm-commands.md index f88d1382f..275a6dfa4 100644 --- a/docs/Apm-commands.md +++ b/docs/Apm-commands.md @@ -87,3 +87,23 @@ aragon apm grant [addr1 ... addrN] ``` - `addresses`: The addresses being granted the permission to publish to the repo. + +## aragon apm revoke + +Revoke an address the permission to create new versions in your package (defined in `arapp.json`), by interacting directly with the ACL, without performing transaction pathing. + +```sh +aragon apm revoke +``` + +- `entity`: The entity address being revoked the permission to publish to the repo. + +## aragon apm manager + +Set an address to be the permission manager of your package (defined in `arapp.json`), by interacting directly with the ACL, without performing transaction pathing. + +```sh +aragon apm manager +``` + +- `entity`: The entity address being set as permission manager. diff --git a/packages/cli/src/commands/apm_cmds/manager.js b/packages/cli/src/commands/apm_cmds/manager.js index a3ada62bd..1b9a0537a 100644 --- a/packages/cli/src/commands/apm_cmds/manager.js +++ b/packages/cli/src/commands/apm_cmds/manager.js @@ -31,18 +31,14 @@ export const handler = async function({ reporter.info(`Fetching repository`) break case 2: - // eslint-disable-next-line no-case-declarations - const address = data reporter.info( `Setting permission manager for ${blue( module.appName - )} for ${address}` + )} for ${data}` ) break case 3: - // eslint-disable-next-line no-case-declarations - const txHash = data - reporter.success(`Successful transaction (${blue(txHash)})`) + reporter.success(`Successful transaction (${blue(data)})`) break } } diff --git a/packages/cli/src/commands/apm_cmds/revoke.js b/packages/cli/src/commands/apm_cmds/revoke.js index 001b5afaf..51f5867fb 100644 --- a/packages/cli/src/commands/apm_cmds/revoke.js +++ b/packages/cli/src/commands/apm_cmds/revoke.js @@ -32,18 +32,14 @@ export const handler = async function({ reporter.info(`Fetching repository`) break case 2: - // eslint-disable-next-line no-case-declarations - const address = data reporter.info( `Revoking permission to publish on ${blue( module.appName - )} for ${address}` + )} for ${data}` ) break case 3: - // eslint-disable-next-line no-case-declarations - const txHash = data - reporter.success(`Successful transaction (${blue(txHash)})`) + reporter.success(`Successful transaction (${blue(data)})`) break } } From 48d574c288939579878116e874aba6216720c07d Mon Sep 17 00:00:00 2001 From: Mathew Cormier Date: Thu, 2 Apr 2020 18:50:18 -0400 Subject: [PATCH 10/10] Lint fix --- packages/cli/src/commands/apm_cmds/manager.js | 4 +--- packages/toolkit/test/apm/permissions.test.js | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/cli/src/commands/apm_cmds/manager.js b/packages/cli/src/commands/apm_cmds/manager.js index 1b9a0537a..7499e11ec 100644 --- a/packages/cli/src/commands/apm_cmds/manager.js +++ b/packages/cli/src/commands/apm_cmds/manager.js @@ -32,9 +32,7 @@ export const handler = async function({ break case 2: reporter.info( - `Setting permission manager for ${blue( - module.appName - )} for ${data}` + `Setting permission manager for ${blue(module.appName)} for ${data}` ) break case 3: diff --git a/packages/toolkit/test/apm/permissions.test.js b/packages/toolkit/test/apm/permissions.test.js index 219364548..965c66cd2 100644 --- a/packages/toolkit/test/apm/permissions.test.js +++ b/packages/toolkit/test/apm/permissions.test.js @@ -67,7 +67,6 @@ test.before('setup and make a successful call', async t => { ) }) - /* Tests */ test.serial('permissions are not set for any accounts', async t => {