mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Merge pull request #1857 from MetaMask/hotFixCancleTx
fix cancelTransaction not receiving a callback
This commit is contained in:
commit
c4cb371ce8
@ -1,9 +1,10 @@
|
||||
const promiseToCallback = require('promise-to-callback')
|
||||
|
||||
module.exports = function(fn, context) {
|
||||
module.exports = function nodeify (fn, context) {
|
||||
return function(){
|
||||
const args = [].slice.call(arguments)
|
||||
const callback = args.pop()
|
||||
if (typeof callback !== 'function') throw new Error('callback is not a function')
|
||||
promiseToCallback(fn.apply(context, args))(callback)
|
||||
}
|
||||
}
|
||||
|
@ -45,13 +45,15 @@ describe('tx confirmation screen', function () {
|
||||
before(function (done) {
|
||||
actions._setBackgroundConnection({
|
||||
approveTransaction (txId, cb) { cb('An error!') },
|
||||
cancelTransaction (txId) { /* noop */ },
|
||||
cancelTransaction (txId, cb) { cb() },
|
||||
clearSeedWordCache (cb) { cb() },
|
||||
})
|
||||
|
||||
const action = actions.cancelTx({value: firstTxId})
|
||||
result = reducers(initialState, action)
|
||||
done()
|
||||
actions.cancelTx({value: firstTxId})((action) => {
|
||||
result = reducers(initialState, action)
|
||||
done()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
it('should transition to the account detail view', function () {
|
||||
|
@ -17,4 +17,15 @@ describe('nodeify', function () {
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw if the last argument is not a function', function (done) {
|
||||
const nodified = nodeify(obj.promiseFunc, obj)
|
||||
try {
|
||||
nodified('baz')
|
||||
done(new Error('should have thrown if the last argument is not a function'))
|
||||
} catch (err) {
|
||||
assert.equal(err.message, 'callback is not a function')
|
||||
done()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -462,9 +462,12 @@ function cancelPersonalMsg (msgData) {
|
||||
}
|
||||
|
||||
function cancelTx (txData) {
|
||||
log.debug(`background.cancelTransaction`)
|
||||
background.cancelTransaction(txData.id)
|
||||
return actions.completedTx(txData.id)
|
||||
return (dispatch) => {
|
||||
log.debug(`background.cancelTransaction`)
|
||||
background.cancelTransaction(txData.id, () => {
|
||||
dispatch(actions.completedTx(txData.id))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user