aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-01 01:58:03 +0800
committerDan <danjm.com@gmail.com>2018-06-01 01:58:03 +0800
commit5091b03e4b2499697cda376a44405139827068cd (patch)
treeda91af2a0ce21871c15611f768f09757ef2c8533 /app
parent6d8344d0d0af3734255a0e9e79d857d84b5fe2aa (diff)
parentcc73d869fed79c63261821fb7ad8f1e5180ffca2 (diff)
downloadtangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.tar
tangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.tar.gz
tangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.tar.bz2
tangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.tar.lz
tangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.tar.xz
tangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.tar.zst
tangerine-wallet-browser-5091b03e4b2499697cda376a44405139827068cd.zip
Merge branch 'develop' into i3725-refactor-send-component-
Diffstat (limited to 'app')
-rw-r--r--app/_locales/en/messages.json23
-rw-r--r--app/images/check-icon.svg17
-rw-r--r--app/manifest.json5
-rw-r--r--app/scripts/background.js14
-rw-r--r--app/scripts/controllers/transactions/index.js8
-rw-r--r--app/scripts/controllers/transactions/tx-state-manager.js21
-rw-r--r--app/scripts/lib/cleanErrorStack.js24
-rw-r--r--app/scripts/lib/get-first-preferred-lang-code.js11
-rw-r--r--app/scripts/metamask-controller.js35
9 files changed, 117 insertions, 41 deletions
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index d820739c8..457c3c3b1 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -405,6 +405,9 @@
"infoHelp": {
"message": "Info & Help"
},
+ "initialTransactionConfirmed": {
+ "message": "Your initial transaction was confirmed by the network. Click OK to go back."
+ },
"insufficientFunds": {
"message": "Insufficient funds."
},
@@ -523,6 +526,9 @@
"networks": {
"message": "Networks"
},
+ "nevermind": {
+ "message": "Nevermind"
+ },
"newAccount": {
"message": "New Account"
},
@@ -637,9 +643,15 @@
"rejected": {
"message": "Rejected"
},
+ "reset": {
+ "message": "Reset"
+ },
"resetAccount": {
"message": "Reset Account"
},
+ "resetAccountDescription": {
+ "message": "Resetting your account will clear your transaction history."
+ },
"restoreFromSeed": {
"message": "Restore account?"
},
@@ -679,6 +691,9 @@
"ropsten": {
"message": "Ropsten Test Network"
},
+ "rpc": {
+ "message": "Custom RPC"
+ },
"currentRpc": {
"message": "Current RPC"
},
@@ -704,10 +719,10 @@
"save": {
"message": "Save"
},
- "reprice_title": {
- "message": "Reprice Transaction"
+ "speedUpTitle": {
+ "message": "Speed Up Transaction"
},
- "reprice_subtitle": {
+ "speedUpSubtitle": {
"message": "Increase your gas price to attempt to overwrite and speed up your transaction"
},
"saveAsCsvFile": {
@@ -898,7 +913,7 @@
"message": "Welcome to the New UI (Beta)"
},
"uiWelcomeMessage": {
- "message": "You are now using the new Metamask UI. Take a look around, try out new features like sending tokens, and let us know if you have any issues."
+ "message": "You are now using the new Metamask UI."
},
"unapproved": {
"message": "Unapproved"
diff --git a/app/images/check-icon.svg b/app/images/check-icon.svg
new file mode 100644
index 000000000..cafa864e5
--- /dev/null
+++ b/app/images/check-icon.svg
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <!-- Generator: sketchtool 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
+ <title>76BCDB09-52B0-41CB-908F-12F9087A2F1B</title>
+ <desc>Created with sketchtool.</desc>
+ <defs></defs>
+ <g id="Confirm-TX-screen" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
+ <g id="confirmed-alert" transform="translate(-144.000000, -53.000000)" stroke="#61BA00" stroke-width="4">
+ <g id="Group-17-Copy" transform="translate(22.000000, 20.000000)">
+ <g id="check-icon" transform="translate(124.000000, 35.000000)">
+ <circle id="Oval-5" cx="48" cy="48" r="48"></circle>
+ <polyline id="Path-3" stroke-linecap="round" points="29.76 52.8 41.0023819 64.32 71.04 34.56"></polyline>
+ </g>
+ </g>
+ </g>
+ </g>
+</svg> \ No newline at end of file
diff --git a/app/manifest.json b/app/manifest.json
index 3e5eed205..141026d10 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
- "version": "4.6.0",
+ "version": "4.6.1",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "__MSG_appDescription__",
@@ -67,6 +67,7 @@
"externally_connectable": {
"matches": [
"https://metamask.io/*"
- ]
+ ],
+ "ids": ["*"]
}
} \ No newline at end of file
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 686296329..56e190f97 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -309,6 +309,7 @@ function setupController (initState, initLangCode) {
// connect to other contexts
//
extension.runtime.onConnect.addListener(connectRemote)
+ extension.runtime.onConnectExternal.addListener(connectExternal)
const metamaskInternalProcessHash = {
[ENVIRONMENT_TYPE_POPUP]: true,
@@ -335,9 +336,9 @@ function setupController (initState, initLangCode) {
function connectRemote (remotePort) {
const processName = remotePort.name
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]
- const portStream = new PortStream(remotePort)
if (isMetaMaskInternalProcess) {
+ const portStream = new PortStream(remotePort)
// communication with popup
controller.isClientOpen = true
controller.setupTrustedCommunication(portStream, 'MetaMask')
@@ -370,12 +371,17 @@ function setupController (initState, initLangCode) {
})
}
} else {
- // communication with page
- const originDomain = urlUtil.parse(remotePort.sender.url).hostname
- controller.setupUntrustedCommunication(portStream, originDomain)
+ connectExternal(remotePort)
}
}
+ // communication with page or other extension
+ function connectExternal(remotePort) {
+ const originDomain = urlUtil.parse(remotePort.sender.url).hostname
+ const portStream = new PortStream(remotePort)
+ controller.setupUntrustedCommunication(portStream, originDomain)
+ }
+
//
// User Interface setup
//
diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js
index 541f1db73..aff5db984 100644
--- a/app/scripts/controllers/transactions/index.js
+++ b/app/scripts/controllers/transactions/index.js
@@ -8,6 +8,7 @@ const TxGasUtil = require('./tx-gas-utils')
const PendingTransactionTracker = require('./pending-tx-tracker')
const NonceTracker = require('./nonce-tracker')
const txUtils = require('./lib/util')
+const cleanErrorStack = require('../../lib/cleanErrorStack')
const log = require('loglevel')
/**
@@ -118,6 +119,7 @@ class TransactionController extends EventEmitter {
@param txParams {object} - txParams for the transaction
@param opts {object} - with the key origin to put the origin on the txMeta
*/
+
async newUnapprovedTransaction (txParams, opts = {}) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
const initialTxMeta = await this.addUnapprovedTransaction(txParams)
@@ -130,11 +132,11 @@ class TransactionController extends EventEmitter {
case 'submitted':
return resolve(finishedTxMeta.hash)
case 'rejected':
- return reject(new Error('MetaMask Tx Signature: User denied transaction signature.'))
+ return reject(cleanErrorStack(new Error('MetaMask Tx Signature: User denied transaction signature.')))
case 'failed':
- return reject(new Error(finishedTxMeta.err.message))
+ return reject(cleanErrorStack(new Error(finishedTxMeta.err.message)))
default:
- return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`))
+ return reject(cleanErrorStack(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`)))
}
})
})
diff --git a/app/scripts/controllers/transactions/tx-state-manager.js b/app/scripts/controllers/transactions/tx-state-manager.js
index 00e837571..0aae4774b 100644
--- a/app/scripts/controllers/transactions/tx-state-manager.js
+++ b/app/scripts/controllers/transactions/tx-state-manager.js
@@ -2,6 +2,7 @@ const extend = require('xtend')
const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
+const log = require('loglevel')
const txStateHistoryHelper = require('./lib/tx-state-history-helper')
const createId = require('../../lib/random-id')
const { getFinalStates } = require('./lib/util')
@@ -398,13 +399,19 @@ class TransactionStateManager extends EventEmitter {
_setTxStatus (txId, status) {
const txMeta = this.getTx(txId)
txMeta.status = status
- this.emit(`${txMeta.id}:${status}`, txId)
- this.emit(`tx:status-update`, txId, status)
- if (['submitted', 'rejected', 'failed'].includes(status)) {
- this.emit(`${txMeta.id}:finished`, txMeta)
- }
- this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
- this.emit('update:badge')
+ setTimeout(() => {
+ try {
+ this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
+ this.emit(`${txMeta.id}:${status}`, txId)
+ this.emit(`tx:status-update`, txId, status)
+ if (['submitted', 'rejected', 'failed'].includes(status)) {
+ this.emit(`${txMeta.id}:finished`, txMeta)
+ }
+ this.emit('update:badge')
+ } catch (error) {
+ log.error(error)
+ }
+ })
}
/**
diff --git a/app/scripts/lib/cleanErrorStack.js b/app/scripts/lib/cleanErrorStack.js
new file mode 100644
index 000000000..fe1bfb0ce
--- /dev/null
+++ b/app/scripts/lib/cleanErrorStack.js
@@ -0,0 +1,24 @@
+/**
+ * Returns error without stack trace for better UI display
+ * @param {Error} err - error
+ * @returns {Error} Error with clean stack trace.
+ */
+function cleanErrorStack(err){
+ var name = err.name
+ name = (name === undefined) ? 'Error' : String(name)
+
+ var msg = err.message
+ msg = (msg === undefined) ? '' : String(msg)
+
+ if (name === '') {
+ err.stack = err.message
+ } else if (msg === '') {
+ err.stack = err.name
+ } else {
+ err.stack = err.name + ': ' + err.message
+ }
+
+ return err
+}
+
+module.exports = cleanErrorStack
diff --git a/app/scripts/lib/get-first-preferred-lang-code.js b/app/scripts/lib/get-first-preferred-lang-code.js
index 5473fccf0..1e6a83ba6 100644
--- a/app/scripts/lib/get-first-preferred-lang-code.js
+++ b/app/scripts/lib/get-first-preferred-lang-code.js
@@ -2,6 +2,12 @@ const extension = require('extensionizer')
const promisify = require('pify')
const allLocales = require('../../_locales/index.json')
+const isSupported = extension.i18n && extension.i18n.getAcceptLanguages
+const getPreferredLocales = isSupported ? promisify(
+ extension.i18n.getAcceptLanguages,
+ { errorFirst: false }
+) : async () => []
+
const existingLocaleCodes = allLocales.map(locale => locale.code.toLowerCase().replace('_', '-'))
/**
@@ -12,10 +18,7 @@ const existingLocaleCodes = allLocales.map(locale => locale.code.toLowerCase().r
*
*/
async function getFirstPreferredLangCode () {
- const userPreferredLocaleCodes = await promisify(
- extension.i18n.getAcceptLanguages,
- { errorFirst: false }
- )()
+ const userPreferredLocaleCodes = await getPreferredLocales()
const firstPreferredLangCode = userPreferredLocaleCodes
.map(code => code.toLowerCase())
.find(code => existingLocaleCodes.includes(code))
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 1b1d26886..a570f2567 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -45,6 +45,7 @@ const BN = require('ethereumjs-util').BN
const GWEI_BN = new BN('1000000000')
const percentile = require('percentile')
const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
+const cleanErrorStack = require('./lib/cleanErrorStack')
const log = require('loglevel')
module.exports = class MetamaskController extends EventEmitter {
@@ -350,7 +351,7 @@ module.exports = class MetamaskController extends EventEmitter {
verifySeedPhrase: nodeify(this.verifySeedPhrase, this),
clearSeedWordCache: this.clearSeedWordCache.bind(this),
resetAccount: nodeify(this.resetAccount, this),
- importAccountWithStrategy: this.importAccountWithStrategy.bind(this),
+ importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this),
// vault management
submitPassword: nodeify(keyringController.submitPassword, keyringController),
@@ -608,15 +609,15 @@ module.exports = class MetamaskController extends EventEmitter {
* @param {any} args - The data required by that strategy to import an account.
* @param {Function} cb - A callback function called with a state update on success.
*/
- importAccountWithStrategy (strategy, args, cb) {
- accountImporter.importAccount(strategy, args)
- .then((privateKey) => {
- return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ])
- })
- .then(keyring => keyring.getAccounts())
- .then((accounts) => this.preferencesController.setSelectedAddress(accounts[0]))
- .then(() => { cb(null, this.keyringController.fullUpdate()) })
- .catch((reason) => { cb(reason) })
+ async importAccountWithStrategy (strategy, args) {
+ const privateKey = await accountImporter.importAccount(strategy, args)
+ const keyring = await this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ])
+ const accounts = await keyring.getAccounts()
+ // update accounts in preferences controller
+ const allAccounts = await this.keyringController.getAccounts()
+ this.preferencesController.setAddresses(allAccounts)
+ // set new account as selected
+ await this.preferencesController.setSelectedAddress(accounts[0])
}
// ---------------------------------------------------------------------------
@@ -642,9 +643,9 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
- return cb(new Error('MetaMask Message Signature: User denied message signature.'))
+ return cb(cleanErrorStack(new Error('MetaMask Message Signature: User denied message signature.')))
default:
- return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
+ return cb(cleanErrorStack(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
}
})
}
@@ -702,7 +703,7 @@ module.exports = class MetamaskController extends EventEmitter {
*/
newUnsignedPersonalMessage (msgParams, cb) {
if (!msgParams.from) {
- return cb(new Error('MetaMask Message Signature: from field is required.'))
+ return cb(cleanErrorStack(new Error('MetaMask Message Signature: from field is required.')))
}
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
@@ -713,9 +714,9 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
- return cb(new Error('MetaMask Message Signature: User denied message signature.'))
+ return cb(cleanErrorStack(new Error('MetaMask Message Signature: User denied message signature.')))
default:
- return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
+ return cb(cleanErrorStack(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
}
})
}
@@ -781,9 +782,9 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
- return cb(new Error('MetaMask Message Signature: User denied message signature.'))
+ return cb(cleanErrorStack(new Error('MetaMask Message Signature: User denied message signature.')))
default:
- return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
+ return cb(cleanErrorStack(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
}
})
}