aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/keyring-controller.js6
-rw-r--r--app/scripts/keyrings/hd.js2
-rw-r--r--app/scripts/keyrings/simple.js21
-rw-r--r--app/scripts/lib/config-manager.js2
-rw-r--r--app/scripts/metamask-controller.js7
-rw-r--r--app/scripts/transaction-manager.js11
6 files changed, 31 insertions, 18 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 79cfe6fbd..e609403cc 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -234,7 +234,10 @@ module.exports = class KeyringController extends EventEmitter {
addNewKeyring (type, opts) {
const Keyring = this.getKeyringClassForType(type)
const keyring = new Keyring(opts)
- return keyring.getAccounts()
+ return keyring.deserialize(opts)
+ .then(() => {
+ return keyring.getAccounts()
+ })
.then((accounts) => {
this.keyrings.push(keyring)
return this.setupAccounts(accounts)
@@ -397,6 +400,7 @@ module.exports = class KeyringController extends EventEmitter {
}).then((rawSig) => {
cb(null, rawSig)
approvalCb(null, true)
+ messageManager.confirmMsg(msgId)
return rawSig
})
} catch (e) {
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js
index 80b713b58..1b9796e07 100644
--- a/app/scripts/keyrings/hd.js
+++ b/app/scripts/keyrings/hd.js
@@ -76,7 +76,7 @@ class HdKeyring extends EventEmitter {
// For eth_sign, we need to sign transactions:
signMessage (withAccount, data) {
const wallet = this._getWalletForAccount(withAccount)
- const message = ethUtil.removeHexPrefix(data)
+ const message = ethUtil.stripHexPrefix(data)
var privKey = wallet.getPrivateKey()
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))
diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js
index 6b16137ae..46687fcaf 100644
--- a/app/scripts/keyrings/simple.js
+++ b/app/scripts/keyrings/simple.js
@@ -20,13 +20,19 @@ class SimpleKeyring extends EventEmitter {
}
deserialize (privateKeys = []) {
- this.wallets = privateKeys.map((privateKey) => {
- const stripped = ethUtil.stripHexPrefix(privateKey)
- const buffer = new Buffer(stripped, 'hex')
- const wallet = Wallet.fromPrivateKey(buffer)
- return wallet
+ return new Promise((resolve, reject) => {
+ try {
+ this.wallets = privateKeys.map((privateKey) => {
+ const stripped = ethUtil.stripHexPrefix(privateKey)
+ const buffer = new Buffer(stripped, 'hex')
+ const wallet = Wallet.fromPrivateKey(buffer)
+ return wallet
+ })
+ } catch (e) {
+ reject(e)
+ }
+ resolve()
})
- return Promise.resolve()
}
addAccounts (n = 1) {
@@ -54,8 +60,7 @@ class SimpleKeyring extends EventEmitter {
// For eth_sign, we need to sign transactions:
signMessage (withAccount, data) {
const wallet = this._getWalletForAccount(withAccount)
-
- const message = ethUtil.removeHexPrefix(data)
+ const message = ethUtil.stripHexPrefix(data)
var privKey = wallet.getPrivateKey()
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey)
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s))
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index 3a1f12ac0..e927c78ec 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -306,7 +306,7 @@ ConfigManager.prototype.updateConversionRate = function () {
this.setConversionPrice(parsedResponse.ticker.price)
this.setConversionDate(parsedResponse.timestamp)
}).catch((err) => {
- console.error('Error in conversion.', err)
+ console.warn('MetaMask - Failed to query currency conversion.')
this.setConversionPrice(0)
this.setConversionDate('N/A')
})
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index b94b98eac..629216e42 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -115,7 +115,12 @@ module.exports = class MetamaskController extends EventEmitter {
.then((newState) => { cb(null, newState) })
.catch((reason) => { cb(reason) })
},
- addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController),
+ addNewKeyring: (type, opts, cb) => {
+ keyringController.addNewKeyring(type, opts)
+ .then(() => keyringController.fullUpdate())
+ .then((newState) => { cb(null, newState) })
+ .catch((reason) => { cb(reason) })
+ },
addNewAccount: nodeify(keyringController.addNewAccount).bind(keyringController),
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController),
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js
index cc9082394..6d0121afd 100644
--- a/app/scripts/transaction-manager.js
+++ b/app/scripts/transaction-manager.js
@@ -190,7 +190,7 @@ module.exports = class TransactionManager extends EventEmitter {
let fromAddress = txParams.from
let ethTx = this.txProviderUtils.buildEthTxFromParams(txParams, txMeta.gasMultiplier)
this.signEthTx(ethTx, fromAddress).then(() => {
- this.updateTxAsSigned(txMeta.id, ethTx)
+ this.setTxStatusSigned(txMeta.id)
cb(null, ethUtil.bufferToHex(ethTx.serialize()))
}).catch((err) => {
cb(err)
@@ -198,21 +198,20 @@ module.exports = class TransactionManager extends EventEmitter {
}
publishTransaction (txId, rawTx, cb) {
- this.txProviderUtils.publishTransaction(rawTx, (err) => {
+ this.txProviderUtils.publishTransaction(rawTx, (err, txHash) => {
if (err) return cb(err)
+ this.setTxHash(txId, txHash)
this.setTxStatusSubmitted(txId)
cb()
})
}
- // receives a signed tx object and updates the tx hash
- updateTxAsSigned (txId, ethTx) {
+ // receives a txHash records the tx as signed
+ setTxHash (txId, txHash) {
// Add the tx hash to the persisted meta-tx object
- let txHash = ethUtil.bufferToHex(ethTx.hash())
let txMeta = this.getTx(txId)
txMeta.hash = txHash
this.updateTx(txMeta)
- this.setTxStatusSigned(txMeta.id)
}
/*