From 89a5eff270ee98bc7f6065a17b564fa09e3f396f Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 11 Jan 2017 14:40:35 -0800 Subject: currency conversion - less noisy error --- app/scripts/lib/config-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts') 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') }) -- cgit v1.2.3 From d5ad84aa125280e86c5ae3c3cec5a0f73dfb35fe Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 16 Jan 2017 23:26:48 -0800 Subject: Wrote fix for eth.sign --- app/scripts/keyrings/simple.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/scripts') diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index 6b16137ae..d604430b8 100644 --- a/app/scripts/keyrings/simple.js +++ b/app/scripts/keyrings/simple.js @@ -54,8 +54,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)) -- cgit v1.2.3 From 7ae2e005eda08907cbab33a42ecc0c9d899c6802 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Jan 2017 00:03:56 -0800 Subject: Fix removeHexPrefix to stripHexPrefix --- app/scripts/keyrings/hd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts') 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)) -- cgit v1.2.3 From 8fcade92d309d363ca223e4ec4aceaee0c330b68 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Jan 2017 00:13:38 -0800 Subject: Fix bug where signed messages were not dismissed --- app/scripts/keyring-controller.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app/scripts') diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 79cfe6fbd..4be00a5a5 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -397,6 +397,7 @@ module.exports = class KeyringController extends EventEmitter { }).then((rawSig) => { cb(null, rawSig) approvalCb(null, true) + messageManager.confirmMsg(msgId) return rawSig }) } catch (e) { -- cgit v1.2.3 From 1ff4894b674bbcbac1998228454129018e4642b6 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Tue, 17 Jan 2017 16:22:22 -0800 Subject: Allow importing of private key strings Fixes #1021 A top-right menu item now allows `Account Import`. It has a menu (with one item for now) that allows importing a private key string. Errors are displayed, and a success navigates the user to their account list, where the imported account is labeled `LOOSE`. --- app/scripts/keyring-controller.js | 5 ++++- app/scripts/keyrings/simple.js | 18 ++++++++++++------ app/scripts/metamask-controller.js | 7 ++++++- 3 files changed, 22 insertions(+), 8 deletions(-) (limited to 'app/scripts') diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 4be00a5a5..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) diff --git a/app/scripts/keyrings/simple.js b/app/scripts/keyrings/simple.js index d604430b8..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) { 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), -- cgit v1.2.3 From 3b7301488f0711ea76e60b6d1bfff36f33314fb1 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 18 Jan 2017 11:33:37 -0800 Subject: tx-manager - use rpc-specified txHash --- app/scripts/transaction-manager.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'app/scripts') diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js index 87f99ce62..9261bb54a 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) } /* -- cgit v1.2.3