Skip to content

Commit

Permalink
Fix app install command
Browse files Browse the repository at this point in the history
Add NO_MANAGER (0x00..) to set permission task on app installation. Before
ANY_ENTITTY (0xff...) was being used, so permissions were being blocked.
  • Loading branch information
bingen committed Dec 7, 2018
1 parent 389b08d commit 972837b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
15 changes: 11 additions & 4 deletions src/commands/dao_cmds/acl_cmds/view.js
Expand Up @@ -12,6 +12,8 @@ const Table = require('cli-table')
const knownRoles = rolesForApps()
const ANY_ENTITY = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF'
const ANY_ENTITY_TEXT = 'Any entity'
const { NO_MANAGER } = require('../../../util')
const NO_MANAGER_TEXT = 'No Manager'

const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'

Expand All @@ -27,6 +29,7 @@ exports.builder = function(yargs) {

const printAppName = (appId, addr) => {
if (addr === ANY_ENTITY) return ANY_ENTITY_TEXT
if (addr === NO_MANAGER) return NO_MANAGER_TEXT
return knownApps[appId]
? `${knownApps[appId].split('.')[0]} (${addr.slice(0, 6)})`
: addr.slice(0, 16) + '...'
Expand Down Expand Up @@ -58,10 +61,14 @@ const formatRow = ({ to, role, allowedEntities, manager }, apps) => {
return acc + '\n' + allowedEmoji + ' ' + allowedName
}, '')
.slice(1) // remove first newline
const formattedManager = printAppName(
appFromProxyAddress(manager, apps).appId,
manager
)
const formattedManager = (() => {
const managerName = printAppName(
appFromProxyAddress(manager, apps).appId,
manager
)
const managerEmoji = managerName === NO_MANAGER_TEXT ? '🆓' : ''
return managerEmoji + ' ' + managerName
})()

return [formattedTo, formattedRole, formattedAllowed, formattedManager]
}
Expand Down
7 changes: 4 additions & 3 deletions src/commands/dao_cmds/install.js
Expand Up @@ -7,7 +7,7 @@ const chalk = require('chalk')
const getRepoTask = require('./utils/getRepoTask')
const encodeInitPayload = require('./utils/encodeInitPayload')
const upgrade = require('./upgrade')
const { getContract, ANY_ENTITY } = require('../../util')
const { getContract, ANY_ENTITY, NO_MANAGER } = require('../../util')
const listrOpts = require('../../helpers/listr-options')

const setPermissions = async (web3, sender, aclAddress, permissions) => {
Expand All @@ -16,8 +16,8 @@ const setPermissions = async (web3, sender, aclAddress, permissions) => {
aclAddress
)
return Promise.all(
permissions.map(([who, where, what]) =>
acl.methods.createPermission(who, where, what, who).send({
permissions.map(([who, where, what, manager]) =>
acl.methods.createPermission(who, where, what, manager).send({
from: sender,
gasLimit: 1e6,
})
Expand Down Expand Up @@ -135,6 +135,7 @@ exports.task = async ({
ANY_ENTITY,
ctx.appAddress,
role.bytes,
NO_MANAGER,
])

return setPermissions(
Expand Down
2 changes: 2 additions & 0 deletions src/util.js
Expand Up @@ -92,6 +92,7 @@ const getContract = (pkg, contract) => {
}

const ANY_ENTITY = '0xffffffffffffffffffffffffffffffffffffffff'
const NO_MANAGER = '0x0000000000000000000000000000000000000000'

module.exports = {
findProjectRoot,
Expand All @@ -101,4 +102,5 @@ module.exports = {
getNPMBinary,
getContract,
ANY_ENTITY,
NO_MANAGER,
}

0 comments on commit 972837b

Please sign in to comment.