Skip to content

Commit

Permalink
Fix publish with intent (#1424)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xGabi authored Feb 10, 2020
1 parent 6fe5bf5 commit 7e9a8ee
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
31 changes: 16 additions & 15 deletions packages/cli/src/commands/apm_cmds/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,13 @@ export const handler = async function({
if (!reply) return console.log()
}

const { receipt /*, transactionPath */ } = await runPublishTask({
const { receipt, transactionPath } = await runPublishTask({
reporter,
gasPrice,
web3,
wsProvider,
module,
network,
http,
provider,
apm: apmOptions,
Expand All @@ -290,21 +291,21 @@ export const handler = async function({
reporter.error(`\nPublish transaction reverted:\n`)
} else {
// If the version is still the same, the publish intent was forwarded but not immediately executed (p.e. Voting)
// if (initialVersion === version) {
// console.log(
// '\n',
// `Successfully executed: "${green(transactionPath[0].description)}"`,
// '\n'
// )
// } else {
const logVersion = 'v' + version
if (initialVersion === version) {
console.log(
'\n',
`Successfully executed: "${green(transactionPath[0].description)}"`,
'\n'
)
} else {
const logVersion = 'v' + version

console.log(
'\n',
`Successfully published ${appName} ${green(logVersion)} :`,
'\n'
)
// }
console.log(
'\n',
`Successfully published ${appName} ${green(logVersion)} :`,
'\n'
)
}
}

console.log(`Transaction hash: ${blue(transactionHash)}`, '\n')
Expand Down
81 changes: 40 additions & 41 deletions packages/cli/src/commands/apm_cmds/util/runPublishTask.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TaskList from 'listr'
import { apmPublishVersion } from '@aragon/toolkit'
//
// import { task as execTask } from '../../commands/dao_cmds/utils/execHandler'
import { task as execTask } from '../../../commands/dao_cmds/utils/execHandler'
import listrOpts from '../../../helpers/listr-options'

export default async function runPublishTask({
Expand All @@ -10,8 +10,9 @@ export default async function runPublishTask({
// Globals
gasPrice,
web3,
// wsProvider,
wsProvider,
module,
network,
http,
provider,
apm: apmOptions,
Expand All @@ -26,57 +27,55 @@ export default async function runPublishTask({
version,
pathToPublish,
contractAddress,
// dao,
// proxyAddress,
// methodName,
// params,
dao,
proxyAddress,
methodName,
params,
}) {
const appName = module.appName
return new TaskList(
[
// { // TODO: Use this task once we fix publish with intent
// title: `Publish ${appName}`,
// enabled: () => !onlyArtifacts,
// task: async (ctx, task) =>
// execTask({
// dao,
// app: proxyAddress,
// method: methodName,
// params,
// reporter,
// gasPrice,
// apm: apmOptions,
// web3,
// wsProvider,
// }),
// },
{
title: `Publish ${appName}`,
enabled: () => !onlyArtifacts,
task: async (ctx, task) => {
ctx.contractInstance = null // clean up deploy sub-command artifacts
if ((network.name === 'rpc') | (network.name === 'development')) {
ctx.contractInstance = null // clean up deploy sub-command artifacts

task.output = 'Generating transaction and waiting for confirmation'
const accounts = await web3.eth.getAccounts()
const from = accounts[0]
task.output = 'Generating transaction and waiting for confirmation'
const accounts = await web3.eth.getAccounts()
const from = accounts[0]

const transaction = await apmPublishVersion(
web3,
from,
appName,
version,
http ? 'http' : provider,
http || pathToPublish,
contractAddress,
from,
apmOptions
)
const transaction = await apmPublishVersion(
web3,
from,
appName,
version,
http ? 'http' : provider,
http || pathToPublish,
contractAddress,
from,
apmOptions
)

transaction.from = from
transaction.gasPrice = gasPrice
// apm.js already calculates the recommended gas
transaction.from = from
transaction.gasPrice = gasPrice
// apm.js already calculates the recommended gas

ctx.receipt = await web3.eth.sendTransaction(transaction)
ctx.receipt = await web3.eth.sendTransaction(transaction)
} else {
return execTask({
dao,
app: proxyAddress,
method: methodName,
params,
reporter,
gasPrice,
apm: apmOptions,
web3,
wsProvider,
})
}
},
},
],
Expand Down

0 comments on commit 7e9a8ee

Please sign in to comment.