aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-07-27 02:56:52 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-08-02 22:26:25 +0800
commit432f516ab005dd2b4eb4b2e8766ed30216386d98 (patch)
tree1e150e48c39ca55d14f9b2b6f1838dbd84b34732 /app/scripts/metamask-controller.js
parent5af753a597d565e4654899ea37349ba7e839bb00 (diff)
downloadtangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.tar
tangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.tar.gz
tangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.tar.bz2
tangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.tar.lz
tangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.tar.xz
tangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.tar.zst
tangerine-wallet-browser-432f516ab005dd2b4eb4b2e8766ed30216386d98.zip
make addUnapprovedTransaction async function and use promise based ethQuery
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js29
1 files changed, 13 insertions, 16 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 11dcde2c1..f7c92e618 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -195,7 +195,7 @@ module.exports = class MetamaskController extends EventEmitter {
cb(null, result)
},
// tx signing
- processTransaction: (txParams, cb) => this.newUnapprovedTransaction(txParams, cb),
+ processTransaction: nodeify(this.newUnapprovedTransaction, this),
// old style msg signing
processMessage: this.newUnsignedMessage.bind(this),
@@ -308,7 +308,7 @@ module.exports = class MetamaskController extends EventEmitter {
exportAccount: nodeify(keyringController.exportAccount, keyringController),
// txController
- cancelTransaction: txController.cancelTransaction.bind(txController),
+ cancelTransaction: nodeify(txController.cancelTransaction, txController),
updateAndApproveTransaction: nodeify(txController.updateAndApproveTransaction, txController),
// messageManager
@@ -440,22 +440,21 @@ module.exports = class MetamaskController extends EventEmitter {
// Identity Management
//
- newUnapprovedTransaction (txParams, cb) {
+ async newUnapprovedTransaction (txParams) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
- const self = this
- self.txController.addUnapprovedTransaction(txParams, (err, txMeta) => {
- if (err) return cb(err)
- self.sendUpdate()
- self.opts.showUnapprovedTx(txMeta)
- // listen for tx completion (success, fail)
- self.txController.once(`${txMeta.id}:finished`, (completedTx) => {
+ const txMeta = await this.txController.addUnapprovedTransaction(txParams)
+ this.sendUpdate()
+ this.opts.showUnapprovedTx(txMeta)
+ // listen for tx completion (success, fail)
+ return new Promise ((resolve, reject) => {
+ this.txController.once(`${txMeta.id}:finished`, (completedTx) => {
switch (completedTx.status) {
case 'submitted':
- return cb(null, completedTx.hash)
+ return reoslve(completedTx.hash)
case 'rejected':
- return cb(new Error('MetaMask Tx Signature: User denied transaction signature.'))
+ return reject(new Error('MetaMask Tx Signature: User denied transaction signature.'))
default:
- return cb(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(completedTx.txParams)}`))
+ return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(completedTx.txParams)}`))
}
})
})
@@ -646,6 +645,4 @@ module.exports = class MetamaskController extends EventEmitter {
return Promise.resolve(rpcTarget)
})
}
-
-
-}
+} \ No newline at end of file