aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-11-30 07:59:18 +0800
committerGitHub <noreply@github.com>2016-11-30 07:59:18 +0800
commit5af41573638e438f4af496afe18d9a01f89c7733 (patch)
tree049f27faa136cbba35794aba844343c478d5a9a3
parentf8fbeb88ff6ae367b126dbe826e7613ea7c8a9ac (diff)
parent95bcc21a066d0849b0b5399a8d7825b01d6390aa (diff)
downloadtangerine-wallet-browser-5af41573638e438f4af496afe18d9a01f89c7733.tar.gz
tangerine-wallet-browser-5af41573638e438f4af496afe18d9a01f89c7733.tar.zst
tangerine-wallet-browser-5af41573638e438f4af496afe18d9a01f89c7733.zip
Merge pull request #899 from MetaMask/i893-DenodeifyKeyringController
Fix incorrect nodeification and add descriptive error to help find in future
-rw-r--r--app/scripts/keyring-controller.js2
-rw-r--r--app/scripts/lib/nodeify.js11
2 files changed, 10 insertions, 3 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 900b3ca25..ac9409dbb 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -282,7 +282,7 @@ module.exports = class KeyringController extends EventEmitter {
setSelectedAccount (address) {
var addr = normalize(address)
this.configManager.setSelectedAccount(addr)
- Promise.resolve(addr)
+ return Promise.resolve(addr)
}
// Save Account Label
diff --git a/app/scripts/lib/nodeify.js b/app/scripts/lib/nodeify.js
index 56b793852..51d89a8fb 100644
--- a/app/scripts/lib/nodeify.js
+++ b/app/scripts/lib/nodeify.js
@@ -6,12 +6,19 @@ module.exports = function (promiseFn) {
}
var cb = arguments[arguments.length - 1]
- return promiseFn.apply(this, args)
- .then(function (result) {
+ const nodeified = promiseFn.apply(this, args)
+
+ if (!nodeified) {
+ const methodName = String(promiseFn).split('(')[0]
+ throw new Error(`The ${methodName} did not return a Promise, but was nodeified.`)
+ }
+ nodeified.then(function (result) {
cb(null, result)
})
.catch(function (reason) {
cb(reason)
})
+
+ return nodeified
}
}