From 0ab227d8a267c63109d671fd34509e7a417b9114 Mon Sep 17 00:00:00 2001 From: David Yoo Date: Mon, 2 Apr 2018 17:04:27 -0700 Subject: Address Add Token design feedback --- app/_locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 34575b4dd..b372326ee 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -56,7 +56,7 @@ "message": "Balance:" }, "balances": { - "message": "Your balances" + "message": "Token balance(s)" }, "balanceIsInsufficientGas": { "message": "Insufficient balance for current gas total" -- cgit v1.2.3 From 00657e14a8b102051157e18bbea24630ff050488 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 3 Apr 2018 09:51:33 -0700 Subject: build - correctly set METAMASK_ENV via envify --- app/scripts/background.js | 4 ++-- app/scripts/config.js | 2 +- app/scripts/first-time-state.js | 2 +- app/scripts/inpage.js | 2 +- app/scripts/lib/setupRaven.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/scripts/background.js b/app/scripts/background.js index 7782fc41e..3ad0a7863 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -22,7 +22,7 @@ const EdgeEncryptor = require('./edge-encryptor') const getFirstPreferredLangCode = require('./lib/get-first-preferred-lang-code') const STORAGE_KEY = 'metamask-config' -const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' +const METAMASK_DEBUG = process.env.METAMASK_DEBUG window.log = log log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn') @@ -94,7 +94,7 @@ function setupController (initState, initLangCode) { // // MetaMask Controller // - + const controller = new MetamaskController({ // User confirmation callbacks: showUnconfirmedMessage: triggerUi, diff --git a/app/scripts/config.js b/app/scripts/config.js index 74c5b576e..a8470ed82 100644 --- a/app/scripts/config.js +++ b/app/scripts/config.js @@ -13,7 +13,7 @@ const DEFAULT_RPC = 'rinkeby' const OLD_UI_NETWORK_TYPE = 'network' const BETA_UI_NETWORK_TYPE = 'networkBeta' -global.METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' +global.METAMASK_DEBUG = process.env.METAMASK_DEBUG module.exports = { network: { diff --git a/app/scripts/first-time-state.js b/app/scripts/first-time-state.js index 5e8577100..3063df627 100644 --- a/app/scripts/first-time-state.js +++ b/app/scripts/first-time-state.js @@ -1,6 +1,6 @@ // test and development environment variables const env = process.env.METAMASK_ENV -const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' +const METAMASK_DEBUG = process.env.METAMASK_DEBUG // // The default state of MetaMask diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 9261e7d64..ec99bfc35 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -9,7 +9,7 @@ const setupDappAutoReload = require('./lib/auto-reload.js') const MetamaskInpageProvider = require('./lib/inpage-provider.js') restoreContextAfterImports() -const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' +const METAMASK_DEBUG = process.env.METAMASK_DEBUG window.log = log log.setDefaultLevel(METAMASK_DEBUG ? 'debug' : 'warn') diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js index b93591e65..9ec9a256f 100644 --- a/app/scripts/lib/setupRaven.js +++ b/app/scripts/lib/setupRaven.js @@ -1,5 +1,5 @@ const Raven = require('raven-js') -const METAMASK_DEBUG = 'GULP_METAMASK_DEBUG' +const METAMASK_DEBUG = process.env.METAMASK_DEBUG const extractEthjsErrorMessage = require('./extractEthjsErrorMessage') const PROD = 'https://3567c198f8a8412082d32655da2961d0@sentry.io/273505' const DEV = 'https://f59f3dd640d2429d9d0e2445a87ea8e1@sentry.io/273496' -- cgit v1.2.3 From ecbab14cae659cdcec9e59dc0a3f450069a6a05f Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 3 Apr 2018 10:33:10 -0700 Subject: app - warn on fetch errors instead of spamming sentry --- app/scripts/controllers/blacklist.js | 5 ++--- app/scripts/controllers/currency.js | 22 ++++++++++------------ app/scripts/controllers/infura.js | 18 ++++++++---------- app/scripts/controllers/shapeshift.js | 15 ++++++++------- 4 files changed, 28 insertions(+), 32 deletions(-) (limited to 'app') diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js index 33c31dab9..df41c90c0 100644 --- a/app/scripts/controllers/blacklist.js +++ b/app/scripts/controllers/blacklist.js @@ -41,9 +41,9 @@ class BlacklistController { scheduleUpdates () { if (this._phishingUpdateIntervalRef) return - this.updatePhishingList() + this.updatePhishingList().catch(log.warn) this._phishingUpdateIntervalRef = setInterval(() => { - this.updatePhishingList() + this.updatePhishingList().catch(log.warn) }, POLLING_INTERVAL) } @@ -57,4 +57,3 @@ class BlacklistController { } module.exports = BlacklistController - diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 930fc52e8..aca57dc71 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -43,20 +43,18 @@ class CurrencyController { this.store.updateState({ conversionDate }) } - updateConversionRate () { - const currentCurrency = this.getCurrentCurrency() - return fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) - .then(response => response.json()) - .then((parsedResponse) => { + await updateConversionRate () { + try { + const currentCurrency = this.getCurrentCurrency() + const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) + const parsedResponse = await response.json() this.setConversionRate(Number(parsedResponse.bid)) this.setConversionDate(Number(parsedResponse.timestamp)) - }).catch((err) => { - if (err) { - console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) - this.setConversionRate(0) - this.setConversionDate('N/A') - } - }) + } catch (err) { + console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) + this.setConversionRate(0) + this.setConversionDate('N/A') + } } scheduleConversionInterval () { diff --git a/app/scripts/controllers/infura.js b/app/scripts/controllers/infura.js index 10adb1004..c6b4c9de2 100644 --- a/app/scripts/controllers/infura.js +++ b/app/scripts/controllers/infura.js @@ -19,15 +19,13 @@ class InfuraController { // Responsible for retrieving the status of Infura's nodes. Can return either // ok, degraded, or down. - checkInfuraNetworkStatus () { - return fetch('https://api.infura.io/v1/status/metamask') - .then(response => response.json()) - .then((parsedResponse) => { - this.store.updateState({ - infuraNetworkStatus: parsedResponse, - }) - return parsedResponse - }) + async checkInfuraNetworkStatus () { + const response = await fetch('https://api.infura.io/v1/status/metamask') + const parsedResponse = await response.json() + this.store.updateState({ + infuraNetworkStatus: parsedResponse, + }) + return parsedResponse } scheduleInfuraNetworkCheck () { @@ -35,7 +33,7 @@ class InfuraController { clearInterval(this.conversionInterval) } this.conversionInterval = setInterval(() => { - this.checkInfuraNetworkStatus() + this.checkInfuraNetworkStatus().catch(log.warn) }, POLLING_INTERVAL) } } diff --git a/app/scripts/controllers/shapeshift.js b/app/scripts/controllers/shapeshift.js index 3d955c01f..3bbfaa1c5 100644 --- a/app/scripts/controllers/shapeshift.js +++ b/app/scripts/controllers/shapeshift.js @@ -45,18 +45,19 @@ class ShapeshiftController { }) } - updateTx (tx) { - const url = `https://shapeshift.io/txStat/${tx.depositAddress}` - return fetch(url) - .then((response) => { - return response.json() - }).then((json) => { + async updateTx (tx) { + try { + const url = `https://shapeshift.io/txStat/${tx.depositAddress}` + const response = await fetch(url) + const json = await response.json() tx.response = json if (tx.response.status === 'complete') { tx.time = new Date().getTime() } return tx - }) + } catch (err) { + log.warn(err) + } } saveTx (tx) { -- cgit v1.2.3 From 79d63332eeb798346f5cd4af6fc4ff91372ab014 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 3 Apr 2018 10:35:41 -0700 Subject: app - currency - fix typo --- app/scripts/controllers/currency.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index aca57dc71..266d8ff1d 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -43,7 +43,7 @@ class CurrencyController { this.store.updateState({ conversionDate }) } - await updateConversionRate () { + async updateConversionRate () { try { const currentCurrency = this.getCurrentCurrency() const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) -- cgit v1.2.3 From 038ad914541c3a4e6579da5b1ac79ba41b33cfb3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 3 Apr 2018 10:39:23 -0700 Subject: app - currency - fix typo + prefer log over console --- app/scripts/controllers/currency.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/scripts/controllers/currency.js b/app/scripts/controllers/currency.js index 266d8ff1d..36b8808aa 100644 --- a/app/scripts/controllers/currency.js +++ b/app/scripts/controllers/currency.js @@ -44,14 +44,15 @@ class CurrencyController { } async updateConversionRate () { + let currentCurrency try { - const currentCurrency = this.getCurrentCurrency() + currentCurrency = this.getCurrentCurrency() const response = await fetch(`https://api.infura.io/v1/ticker/eth${currentCurrency.toLowerCase()}`) const parsedResponse = await response.json() this.setConversionRate(Number(parsedResponse.bid)) this.setConversionDate(Number(parsedResponse.timestamp)) } catch (err) { - console.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) + log.warn(`MetaMask - Failed to query currency conversion:`, currentCurrency, err) this.setConversionRate(0) this.setConversionDate('N/A') } -- cgit v1.2.3 From 3b1e4c74f5c8d503184a75584dca570187a13b8c Mon Sep 17 00:00:00 2001 From: frankiebee Date: Tue, 3 Apr 2018 12:14:30 -0700 Subject: transactions - dont throw if chain id is not a string --- app/scripts/lib/tx-state-manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index 23c915a61..3577d45d0 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -140,8 +140,8 @@ module.exports = class TransactionStateManager extends EventEmitter { validateTxParams(txParams) { Object.keys(txParams).forEach((key) => { const value = txParams[key] - if (typeof value !== 'string') throw new Error(`${key}: ${value} in txParams is not a string`) - if (!ethUtil.isHexPrefixed(value)) throw new Error('is not hex prefixed, everything on txParams must be hex prefixed') + if (typeof value !== 'string' && key !== 'chainId') throw new Error(`${key}: ${value} in txParams is not a string`) + if (!ethUtil.isHexPrefixed(value) && key !== 'chainId') throw new Error('is not hex prefixed, everything on txParams must be hex prefixed') }) } -- cgit v1.2.3 From 83df8b58ba470b6446c158789a308e801bf5becb Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 3 Apr 2018 13:55:20 -0700 Subject: tx-state-manager - validateTxParams - validate chainId is Number --- app/scripts/lib/tx-state-manager.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index 3577d45d0..9e597ef37 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -140,8 +140,16 @@ module.exports = class TransactionStateManager extends EventEmitter { validateTxParams(txParams) { Object.keys(txParams).forEach((key) => { const value = txParams[key] - if (typeof value !== 'string' && key !== 'chainId') throw new Error(`${key}: ${value} in txParams is not a string`) - if (!ethUtil.isHexPrefixed(value) && key !== 'chainId') throw new Error('is not hex prefixed, everything on txParams must be hex prefixed') + // validate types + switch (key) { + case 'chainId': + if (typeof value !== 'number') throw new Error(`${key} in txParams is not a Number. got: (${value})`) + break + default: + if (typeof value !== 'string') throw new Error(`${key} in txParams is not a string. got: (${value})`) + if (!ethUtil.isHexPrefixed(value)) throw new Error(`${key} in txParams is not hex prefixed. got: (${value})`) + break + } }) } -- cgit v1.2.3 From 31a9fb38c8e944653ea8c087c9bca17309b8b801 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 3 Apr 2018 14:28:30 -0700 Subject: 4.5.1 --- app/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/manifest.json b/app/manifest.json index 73496adfa..99305f20e 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_appName__", "short_name": "__MSG_appName__", - "version": "4.5.0", + "version": "4.5.1", "manifest_version": 2, "author": "https://metamask.io", "description": "__MSG_appDescription__", -- cgit v1.2.3