Skip to content

Commit

Permalink
Fix gas on grant and publish (#366)
Browse files Browse the repository at this point in the history
  • Loading branch information
kernelwhisperer authored Feb 15, 2019
1 parent a19932c commit 4044d0d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"prepare": "npm run build",
"test": "ava",
"lint": "eslint src test && documentation lint src test",
"extract-roles": "scripts/extract-roles"
"extract-roles": "node scripts/extract-roles"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/acl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = ({ web3, network }) => {
const roleId = await getRoleId(repoAddr)

const call = acl.methods.grantPermission(grantee, repoAddr, roleId)
const estimatedGas = call.estimatedGas()
const estimatedGas = call.estimateGas()

return {
to: acl.options.address,
Expand Down
6 changes: 1 addition & 5 deletions src/commands/apm_cmds/grant.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const APM = require('@aragon/apm')
const ACL = require('../../acl')
const { ensureWeb3 } = require('../../helpers/web3-fallback')
const { getRecommendedGasLimit } = require('../../util')

exports.command = 'grant [grantees..]'
exports.describe =
Expand Down Expand Up @@ -61,10 +60,7 @@ exports.handler = async function({
.defaultGasPrice
transaction.from = from
transaction.gasPrice = network.gasPrice || DEFAULT_GAS_PRICE
transaction.gas = await getRecommendedGasLimit(
web3,
await transaction.estimateGas()
)
// the recommended gasLimit is already calculated by the ACL module

try {
const receipt = await web3.eth.sendTransaction(transaction)
Expand Down
6 changes: 1 addition & 5 deletions src/commands/apm_cmds/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const deploy = require('../deploy')
const startIPFS = require('../ipfs')
const getRepoTask = require('../dao_cmds/utils/getRepoTask')
const listrOpts = require('../../helpers/listr-options')
const { getRecommendedGasLimit } = require('../../util')

const DEFAULT_GAS_PRICE = require('../../../package.json').aragon
.defaultGasPrice
Expand Down Expand Up @@ -578,10 +577,7 @@ exports.task = function({

transaction.from = from
transaction.gasPrice = network.gasPrice || DEFAULT_GAS_PRICE
transaction.gas = await getRecommendedGasLimit(
web3,
await transaction.estimateGas()
)
// apm.js already calculates the recommended gas

ctx.receipt = await web3.eth.sendTransaction(transaction)
} catch (e) {
Expand Down

0 comments on commit 4044d0d

Please sign in to comment.