Skip to content

Commit

Permalink
dao act: working
Browse files Browse the repository at this point in the history
  • Loading branch information
izqui authored and kernelwhisperer committed Feb 16, 2019
1 parent 0487d9f commit 7a8a9d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
11 changes: 7 additions & 4 deletions .babelrc
@@ -1,10 +1,13 @@
{
"presets": [
["@babel/preset-env", {
"useBuiltIns": "entry"
}]
[
"@babel/preset-env",
{
"useBuiltIns": "entry"
}
]
],
"plugins": [
"@babel/plugin-proposal-object-rest-spread"
]
}
}
21 changes: 11 additions & 10 deletions src/commands/dao_cmds/act.js
Expand Up @@ -3,6 +3,8 @@ const getAppKernel = require('./utils/app-kernel')
const { ensureWeb3 } = require('../../helpers/web3-fallback')
const ABI = require('web3-eth-abi')

const EXECUTE_FUNCTION_NAME = 'execute'

exports.command = 'act <agent-address> <target> <signature> [call-args..]'

exports.describe = 'Executes a call from the Agent app'
Expand Down Expand Up @@ -32,11 +34,14 @@ exports.builder = function(yargs) {
const encodeCalldata = (signature, params) => {
const sigBytes = ABI.encodeFunctionSignature(signature)

const types = signature
.replace(')', '')
.split('(')[1]
.split(',')
const paramBytes = ABI.encodeParameters(types, params)
const types = signature.replace(')', '').split('(')[1]

// No params, return signature directly
if (types === '') {
return sigBytes
}

const paramBytes = ABI.encodeParameters(types.split(','), params)

return `${sigBytes}${paramBytes.slice(2)}`
}
Expand All @@ -55,14 +60,10 @@ exports.handler = async function({
const dao = await getAppKernel(web3, agentAddress)

// TODO: assert dao != 0x00...00

const fn = 'execute'
const fnArgs = [target, 0, encodeCalldata(signature, callArgs)]

// console.log(fn, fnArgs)

const getTransactionPath = wrapper =>
wrapper.getTransactionPath(agentAddress, fn, fnArgs)
wrapper.getTransactionPath(agentAddress, EXECUTE_FUNCTION_NAME, fnArgs)

return execHandler(dao, getTransactionPath, {
reporter,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/dao_cmds/install.js
Expand Up @@ -9,7 +9,7 @@ const chalk = require('chalk')
const getRepoTask = require('./utils/getRepoTask')
const encodeInitPayload = require('./utils/encodeInitPayload')
const { getContract, ANY_ENTITY, NO_MANAGER } = require('../../util')
const kernelABI = require('@aragon/wrapper/abi/aragon/Kernel')
const kernelABI = require('@aragon/wrapper/artifacts/aragon/Kernel')
const listrOpts = require('../../helpers/listr-options')

const addressesEqual = (a, b) => a.toLowerCase() === b.toLowerCase()
Expand Down

0 comments on commit 7a8a9d5

Please sign in to comment.