From 43fc7ab2e330fdbe49e6d072c6b12bcfeffa5296 Mon Sep 17 00:00:00 2001
From: Daniel Constantin <hello@danielconstantin.net>
Date: Fri, 15 Feb 2019 17:21:06 +0200
Subject: [PATCH] Fix gas on grant and publish

---
 package.json                     | 2 +-
 src/acl/index.js                 | 2 +-
 src/commands/apm_cmds/grant.js   | 6 +-----
 src/commands/apm_cmds/publish.js | 6 +-----
 4 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/package.json b/package.json
index d0ecb976f..134549de2 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/acl/index.js b/src/acl/index.js
index 53d5b693c..072ee18a3 100644
--- a/src/acl/index.js
+++ b/src/acl/index.js
@@ -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,
diff --git a/src/commands/apm_cmds/grant.js b/src/commands/apm_cmds/grant.js
index a7834e0e8..e67ef75b2 100644
--- a/src/commands/apm_cmds/grant.js
+++ b/src/commands/apm_cmds/grant.js
@@ -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 =
@@ -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)
diff --git a/src/commands/apm_cmds/publish.js b/src/commands/apm_cmds/publish.js
index 7190c642e..21d8d4db1 100644
--- a/src/commands/apm_cmds/publish.js
+++ b/src/commands/apm_cmds/publish.js
@@ -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
@@ -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) {