aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md4
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/lib/idStore.js11
-rw-r--r--package.json2
-rw-r--r--test/unit/idStore-test.js48
5 files changed, 49 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 73fde7504..a6015ccb3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
## Current Master
+## 2.13.7 2016-11-8
+
+- Fix bug where gas estimate would sometimes be very high.
+- Increased our gas estimate from 100k gas to 20% of estimate.
- Fix github link on info page to point at current repository.
## 2.13.6 2016-10-26
diff --git a/app/manifest.json b/app/manifest.json
index e35f2918d..a21809ce8 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "MetaMask",
"short_name": "Metamask",
- "version": "2.13.6",
+ "version": "2.13.7",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "Ethereum Browser Extension",
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js
index 46d53c4e1..0ce91f471 100644
--- a/app/scripts/lib/idStore.js
+++ b/app/scripts/lib/idStore.js
@@ -287,11 +287,12 @@ IdentityStore.prototype.checkForDelegateCall = function (codeHex) {
}
}
-IdentityStore.prototype.addGasBuffer = function (gasHex) {
- var gas = new BN(gasHex, 16)
- var buffer = new BN('100000', 10)
- var result = gas.add(buffer)
- return ethUtil.addHexPrefix(result.toString(16))
+IdentityStore.prototype.addGasBuffer = function (gas) {
+ const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
+ const five = new BN('5', 10)
+ const gasBuffer = bnGas.div(five)
+ const correct = bnGas.add(gasBuffer)
+ return ethUtil.addHexPrefix(correct.toString(16))
}
// comes from metamask ui
diff --git a/package.json b/package.json
index 2ed978cd5..4579e0166 100644
--- a/package.json
+++ b/package.json
@@ -53,7 +53,7 @@
"iframe": "^1.0.0",
"iframe-stream": "^1.0.2",
"inject-css": "^0.1.1",
- "jazzicon": "^1.1.3",
+ "jazzicon": "1.1.5",
"menu-droppo": "^1.1.0",
"metamask-logo": "^2.1.2",
"mississippi": "^1.2.0",
diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js
index da465f511..064483ba0 100644
--- a/test/unit/idStore-test.js
+++ b/test/unit/idStore-test.js
@@ -142,20 +142,45 @@ describe('IdentityStore', function() {
})
describe('#addGasBuffer', function() {
- const idStore = new IdentityStore({
- configManager: configManagerGen(),
- ethStore: {
- addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
- },
+ it('formats the result correctly', function() {
+ const idStore = new IdentityStore({
+ configManager: configManagerGen(),
+ ethStore: {
+ addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
+ },
+ })
+
+ const gas = '0x01'
+ const bnGas = new BN(gas, 16)
+ const result = idStore.addGasBuffer(gas)
+ const bnResult = new BN(result, 16)
+
+ assert.ok(bnResult.gt(gas), 'added more gas as buffer.')
+ assert.equal(result.indexOf('0x'), 0, 'include hex prefix')
})
- const gas = '0x01'
- const bnGas = new BN(gas, 16)
- const result = idStore.addGasBuffer(gas)
- const bnResult = new BN(result, 16)
+ it('buffers 20%', function() {
+ const idStore = new IdentityStore({
+ configManager: configManagerGen(),
+ ethStore: {
+ addAccount(acct) { accounts.push(ethUtil.addHexPrefix(acct)) },
+ },
+ })
+
+ const gas = '0x04ee59' // Actual estimated gas example
+ const bnGas = new BN(ethUtil.stripHexPrefix(gas), 16)
+ const five = new BN('5', 10)
+ const correctBuffer = bnGas.div(five)
+ const correct = bnGas.add(correctBuffer)
+
+ const result = idStore.addGasBuffer(gas)
+ const bnResult = new BN(ethUtil.stripHexPrefix(result), 16)
- assert.ok(bnResult.gt(gas), 'added more gas as buffer.')
- assert.equal(result.indexOf('0x'), 0, 'include hex prefix')
+ assert.equal(result.indexOf('0x'), 0, 'included hex prefix')
+ assert(bnResult.gt(bnGas), 'Estimate increased in value.')
+ assert.equal(bnResult.sub(bnGas).toString(10), correctBuffer.toString(10), 'added 20% gas')
+ assert.equal(result, '0x' + correct.toString(16), 'Added the right amount')
+ })
})
describe('#checkForDelegateCall', function() {
@@ -169,4 +194,5 @@ describe('IdentityStore', function() {
var result = idStore.checkForDelegateCall(delegateCallCode)
assert.equal(result, true, 'no delegate call in provided code')
})
+
})