aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-07-26 06:33:52 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-07-26 06:33:52 +0800
commit30cbe74ba69f2eaa5f79974dba47d8afba6ea97b (patch)
treee759089aca54bca0c15d5e426b912b3be9fa9647
parentba88f7b8dd32b6ffdb46e70b8c9fbd563bb53b69 (diff)
parenta929fb2387de87619192ea0a86fe1ead4f7a0361 (diff)
downloadtangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.tar
tangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.tar.gz
tangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.tar.bz2
tangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.tar.lz
tangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.tar.xz
tangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.tar.zst
tangerine-wallet-browser-30cbe74ba69f2eaa5f79974dba47d8afba6ea97b.zip
Merge branch 'betterErrorsOnTx' of https://github.com/MetaMask/metamask-extension into betterErrorsOnTx
-rw-r--r--app/scripts/controllers/network.js5
-rw-r--r--app/scripts/controllers/transactions.js10
-rw-r--r--package.json2
-rw-r--r--test/unit/network-contoller-test.js36
-rw-r--r--test/unit/tx-controller-test.js8
5 files changed, 36 insertions, 25 deletions
diff --git a/app/scripts/controllers/network.js b/app/scripts/controllers/network.js
index c07f13b8d..0a3e5e26b 100644
--- a/app/scripts/controllers/network.js
+++ b/app/scripts/controllers/network.js
@@ -28,9 +28,9 @@ module.exports = class NetworkController extends EventEmitter {
this._provider = provider
}
- initializeProvider (opts) {
+ initializeProvider (opts, providerContructor = MetaMaskProvider) {
this.providerInit = opts
- this._provider = MetaMaskProvider(opts)
+ this._provider = providerContructor(opts)
this._proxy = new Proxy(this._provider, {
get: (obj, name) => {
if (name === 'on') return this._on.bind(this)
@@ -38,6 +38,7 @@ module.exports = class NetworkController extends EventEmitter {
},
set: (obj, name, value) => {
this._provider[name] = value
+ return value
},
})
this.provider.on('block', this._logBlock.bind(this))
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js
index 263424518..5f2d75b47 100644
--- a/app/scripts/controllers/transactions.js
+++ b/app/scripts/controllers/transactions.js
@@ -469,7 +469,7 @@ module.exports = class TransactionController extends EventEmitter {
}))
}
- async _resubmitTx (txMeta, cb) {
+ async _resubmitTx (txMeta) {
const address = txMeta.txParams.from
const balance = this.ethStore.getState().accounts[address].balance
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
@@ -481,17 +481,17 @@ module.exports = class TransactionController extends EventEmitter {
stack: '_resubmitTx: custom tx-controller error',
message,
})
- cb()
- return log.error(message)
+ log.error(message)
+ return
}
// Only auto-submit already-signed txs:
- if (!('rawTx' in txMeta)) return cb()
+ if (!('rawTx' in txMeta)) return
// Increment a try counter.
txMeta.retryCount++
const rawTx = txMeta.rawTx
- return await this.txProviderUtils.publishTransaction(rawTx, cb)
+ return await this.txProviderUtils.publishTransaction(rawTx)
}
// checks the network for signed txs and
diff --git a/package.json b/package.json
index 375902d09..9b582d3c9 100644
--- a/package.json
+++ b/package.json
@@ -127,7 +127,7 @@
"valid-url": "^1.0.9",
"vreme": "^3.0.2",
"web3": "0.19.1",
- "web3-provider-engine": "^13.2.8",
+ "web3-provider-engine": "^13.2.9",
"web3-stream-provider": "^3.0.1",
"xtend": "^4.0.1"
},
diff --git a/test/unit/network-contoller-test.js b/test/unit/network-contoller-test.js
index 0c7ee9d70..87c2ee7a3 100644
--- a/test/unit/network-contoller-test.js
+++ b/test/unit/network-contoller-test.js
@@ -3,6 +3,9 @@ const NetworkController = require('../../app/scripts/controllers/network')
describe('# Network Controller', function () {
let networkController
+ const networkControllerProviderInit = {
+ getAccounts: () => {},
+ }
beforeEach(function () {
networkController = new NetworkController({
@@ -10,26 +13,13 @@ describe('# Network Controller', function () {
type: 'rinkeby',
},
})
- // stub out provider
- networkController._provider = new Proxy({}, {
- get: (obj, name) => {
- return () => {}
- },
- })
- networkController.providerInit = {
- getAccounts: () => {},
- }
- networkController.ethQuery = new Proxy({}, {
- get: (obj, name) => {
- return () => {}
- },
- })
+ networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
})
describe('network', function () {
describe('#provider', function () {
it('provider should be updatable without reassignment', function () {
- networkController.initializeProvider(networkController.providerInit)
+ networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
const provider = networkController.provider
networkController._provider = {test: true}
assert.ok(provider.test)
@@ -75,3 +65,19 @@ describe('# Network Controller', function () {
})
})
})
+
+function dummyProviderConstructor() {
+ return {
+ // provider
+ sendAsync: noop,
+ // block tracker
+ start: noop,
+ stop: noop,
+ on: noop,
+ addListener: noop,
+ once: noop,
+ removeAllListeners: noop,
+ }
+}
+
+function noop() {} \ No newline at end of file
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 7b86cfe14..31908569a 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -343,13 +343,17 @@ describe('Transaction Controller', function () {
// Adding the fake tx:
txController.addTx(clone(txMeta))
- txController._resubmitTx(txMeta, function (err) {
- assert.ifError(err, 'should not throw an error')
+ txController._resubmitTx(txMeta)
+ .then(() => {
const updatedMeta = txController.getTx(txMeta.id)
assert.notEqual(updatedMeta.status, txMeta.status, 'status changed.')
assert.equal(updatedMeta.status, 'failed', 'tx set to failed.')
done()
})
+ .catch((err) => {
+ assert.ifError(err, 'should not throw an error')
+ done()
+ })
})
})
})