aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorThomas <thomas.b.huang@gmail.com>2018-08-15 01:44:42 +0800
committerThomas <thomas.b.huang@gmail.com>2018-08-15 01:44:42 +0800
commit96d789d2cffa91da9d65be0de75d2e864d309305 (patch)
treeb3cea0eb6a4638244fd99bf64509c69b0b720a7a /app
parent7918240833871648dea6f9787519ba20f1e51899 (diff)
parent742aa8bb11c1273151ad907171061d4c5e4d1dca (diff)
downloadtangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar
tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.gz
tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.bz2
tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.lz
tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.xz
tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.tar.zst
tangerine-wallet-browser-96d789d2cffa91da9d65be0de75d2e864d309305.zip
Merge branch 'develop' into network-remove-provider-engine
Override package-lock and fix merge conflicts
Diffstat (limited to 'app')
-rw-r--r--app/_locales/de/messages.json4
-rw-r--r--app/_locales/en/messages.json38
-rw-r--r--app/_locales/es/messages.json4
-rw-r--r--app/_locales/fr/messages.json4
-rw-r--r--app/_locales/it/messages.json6
-rw-r--r--app/_locales/nl/messages.json6
-rw-r--r--app/_locales/ph/messages.json2
-rw-r--r--app/_locales/pt/messages.json2
-rw-r--r--app/_locales/ru/messages.json2
-rw-r--r--app/_locales/th/messages.json2
-rw-r--r--app/_locales/tr/messages.json6
-rw-r--r--app/_locales/vi/messages.json2
-rw-r--r--app/_locales/zh_CN/messages.json2
-rw-r--r--app/_locales/zh_TW/messages.json2
-rw-r--r--app/images/webcam.svg18
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/background.js4
-rw-r--r--app/scripts/contentscript.js2
-rw-r--r--app/scripts/controllers/detect-tokens.js2
-rw-r--r--app/scripts/controllers/preferences.js94
-rw-r--r--app/scripts/lib/enums.js11
-rw-r--r--app/scripts/lib/ipfsContent.js6
-rw-r--r--app/scripts/lib/setupRaven.js4
-rw-r--r--app/scripts/lib/util.js29
-rw-r--r--app/scripts/metamask-controller.js3
-rw-r--r--app/scripts/migrations/028.js40
-rw-r--r--app/scripts/migrations/index.js1
-rw-r--r--app/scripts/platforms/extension.js7
28 files changed, 251 insertions, 54 deletions
diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json
index 1d2619672..c06a99250 100644
--- a/app/_locales/de/messages.json
+++ b/app/_locales/de/messages.json
@@ -84,7 +84,7 @@
"message": "Auf Coinbase kaufen"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase ist die weltweit bekannteste Art und Weise um bitcoin, ethereum und litecoin zu kaufen und verkaufen."
+ "message": "Coinbase ist die weltweit bekannteste Art und Weise um Bitcoin, Ethereum und Litecoin zu kaufen und verkaufen."
},
"ok": {
"message": "Ok"
@@ -828,7 +828,7 @@
"message": "Willkommen zur neuen Oberfläche (Beta)"
},
"uiWelcomeMessage": {
- "message": "Du verwendest nun die neue Metamask Oberfläche. Schau dich um, teste die neuen Features wie z.B. das Senden von Token und lass es uns wissen falls du irgendwelche Probleme hast."
+ "message": "Du verwendest nun die neue MetaMask Oberfläche. Schau dich um, teste die neuen Features wie z.B. das Senden von Token und lass es uns wissen falls du irgendwelche Probleme hast."
},
"unapproved": {
"message": "Nicht genehmigt"
diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json
index 1b0183c92..ddfcf6f12 100644
--- a/app/_locales/en/messages.json
+++ b/app/_locales/en/messages.json
@@ -2,6 +2,9 @@
"accept": {
"message": "Accept"
},
+ "accessingYourCamera": {
+ "message": "Accesing your camera..."
+ },
"account": {
"message": "Account"
},
@@ -96,7 +99,7 @@
"message": "Buy on Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase is the world’s most popular way to buy and sell bitcoin, ethereum, and litecoin."
+ "message": "Coinbase is the world’s most popular way to buy and sell Bitcoin, Ethereum, and Litecoin."
},
"bytes": {
"message": "Bytes"
@@ -117,7 +120,7 @@
"message": "Close"
},
"chromeRequiredForTrezor":{
- "message": "You need to use Metamask on Google Chrome in order to connect to your TREZOR device."
+ "message": "You need to use MetaMask on Google Chrome in order to connect to your TREZOR device."
},
"confirm": {
"message": "Confirm"
@@ -147,7 +150,7 @@
"message": "Connect to Trezor"
},
"connectToTrezorHelp": {
- "message": "Metamask is able to access your TREZOR ethereum accounts. First make sure your device is connected and unlocked."
+ "message": "MetaMask is able to access your TREZOR Ethereum accounts. First make sure your device is connected and unlocked."
},
"connectToTrezorTrouble": {
"message": "If you are having trouble, please make sure you are using the latest version of the TREZOR firmware."
@@ -656,6 +659,12 @@
"notStarted": {
"message": "Not Started"
},
+ "noWebcamFoundTitle": {
+ "message": "Webcam not found"
+ },
+ "noWebcamFound": {
+ "message": "Your computer's webcam was not found. Please try again."
+ },
"oldUI": {
"message": "Old UI"
},
@@ -940,6 +949,12 @@
"info": {
"message": "Info"
},
+ "scanInstructions": {
+ "message": "Place the QR code in front of your camera"
+ },
+ "scanQrCode": {
+ "message": "Scan QR Code"
+ },
"shapeshiftBuy": {
"message": "Buy with Shapeshift"
},
@@ -1059,6 +1074,9 @@
"message": "We had trouble loading your token balances. You can view them ",
"description": "Followed by a link (here) to view token balances"
},
+ "tryAgain": {
+ "message": "Try again"
+ },
"twelveWords": {
"message": "These 12 words are the only way to restore your MetaMask accounts.\nSave them somewhere safe and secret."
},
@@ -1069,7 +1087,7 @@
"message": "Welcome to the New UI (Beta)"
},
"uiWelcomeMessage": {
- "message": "You are now using the new Metamask UI."
+ "message": "You are now using the new MetaMask UI."
},
"unapproved": {
"message": "Unapproved"
@@ -1089,6 +1107,15 @@
"unknownNetworkId": {
"message": "Unknown network ID"
},
+ "unknownQrCode": {
+ "message": "Error: We couldn't identify that QR code"
+ },
+ "unknownCameraErrorTitle": {
+ "message": "Ooops! Something went wrong...."
+ },
+ "unknownCameraError": {
+ "message": "There was an error while trying to access you camera. Please try again..."
+ },
"unlock": {
"message": "Unlock"
},
@@ -1135,6 +1162,9 @@
"whatsThis": {
"message": "What's this?"
},
+ "youNeedToAllowCameraAccess": {
+ "message": "You need to allow camera access to use this feature."
+ },
"yourSigRequested": {
"message": "Your signature is being requested"
},
diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json
index f287674f1..ed7f8f681 100644
--- a/app/_locales/es/messages.json
+++ b/app/_locales/es/messages.json
@@ -75,7 +75,7 @@
"message": "Pedir prestado con Dharma (Beta)"
},
"builtInCalifornia": {
- "message": "Metamask fue diseñado y construido en California"
+ "message": "MetaMask fue diseñado y construido en California"
},
"buy": {
"message": "Comprar"
@@ -874,7 +874,7 @@
"message": "Advertencia"
},
"welcomeBeta": {
- "message": "Bienvenido a Metamask Beta"
+ "message": "Bienvenido a MetaMask Beta"
},
"whatsThis": {
"message": "¿Qué es esto?"
diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json
index da2cfe4f8..1463e2b5f 100644
--- a/app/_locales/fr/messages.json
+++ b/app/_locales/fr/messages.json
@@ -63,7 +63,7 @@
"message": "Acheter sur Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase est le moyen le plus populaire au monde d'acheter et de vendre du bitcoin, de l'ethereum et du litecoin."
+ "message": "Coinbase est le moyen le plus populaire au monde d'acheter et de vendre du Bitcoin, de l'Ethereum et du Litecoin."
},
"cancel": {
"message": "Annuler"
@@ -570,7 +570,7 @@
"message": "Bienvenue dans la nouvelle interface utilisateur (Beta)"
},
"uiWelcomeMessage": {
- "message": "Vous utilisez maintenant la nouvelle interface utilisateur Metamask. Jetez un coup d'oeil, essayez de nouvelles fonctionnalités comme l'envoi de jetons, et faites-nous savoir si vous avez des problèmes."
+ "message": "Vous utilisez maintenant la nouvelle interface utilisateur MetaMask. Jetez un coup d'oeil, essayez de nouvelles fonctionnalités comme l'envoi de jetons, et faites-nous savoir si vous avez des problèmes."
},
"unavailable": {
"message": "Indisponible"
diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json
index ef3ed4025..2ae5fae72 100644
--- a/app/_locales/it/messages.json
+++ b/app/_locales/it/messages.json
@@ -81,7 +81,7 @@
"message": "Compra su Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase è il servizio più popolare al mondo per comprare e vendere bitcoin, ethereum e litecoin."
+ "message": "Coinbase è il servizio più popolare al mondo per comprare e vendere Bitcoin, Ethereum e Litecoin."
},
"cancel": {
"message": "Cancella"
@@ -178,7 +178,7 @@
"message": "La rete predefinita per transazioni in Ether è la Rete Ethereum Principale."
},
"denExplainer": {
- "message": "Il DEN è il tuo archivio crittato con password dentro Metamask."
+ "message": "Il DEN è il tuo archivio crittato con password dentro MetaMask."
},
"deposit": {
"message": "Deposita"
@@ -816,4 +816,4 @@
"youSign": {
"message": "Ti stai connettendo"
}
-} \ No newline at end of file
+}
diff --git a/app/_locales/nl/messages.json b/app/_locales/nl/messages.json
index 38289f602..46847f1bf 100644
--- a/app/_locales/nl/messages.json
+++ b/app/_locales/nl/messages.json
@@ -81,7 +81,7 @@
"message": "Koop op Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase is 's werelds populairste manier om bitcoin, ethereum en litecoin te kopen en verkopen."
+ "message": "Coinbase is 's werelds populairste manier om Bitcoin, Ethereum en Litecoin te kopen en verkopen."
},
"cancel": {
"message": "Annuleer"
@@ -435,7 +435,7 @@
"message": "back-up woorden hebben alleen kleine letters"
},
"mainnet": {
- "message": "belangrijkste ethereum-netwerk"
+ "message": "belangrijkste Ethereum-netwerk"
},
"message": {
"message": "Bericht"
@@ -762,7 +762,7 @@
"message": "Welkom bij de nieuwe gebruikersinterface (bèta)"
},
"uiWelcomeMessage": {
- "message": "U gebruikt nu de nieuwe gebruikersinterface van Metamask. Kijk rond, probeer nieuwe functies uit zoals het verzenden van tokens en laat ons weten of u problemen ondervindt."
+ "message": "U gebruikt nu de nieuwe gebruikersinterface van MetaMask. Kijk rond, probeer nieuwe functies uit zoals het verzenden van tokens en laat ons weten of u problemen ondervindt."
},
"unavailable": {
"message": "Niet beschikbaar"
diff --git a/app/_locales/ph/messages.json b/app/_locales/ph/messages.json
index 29d63be02..9a243447a 100644
--- a/app/_locales/ph/messages.json
+++ b/app/_locales/ph/messages.json
@@ -63,7 +63,7 @@
"message": "Bumili sa Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Ang Coinbase ang pinakasikat na paraan upang bumili at magbenta ng bitcoin, ethereum, at litecoin sa buong mundo."
+ "message": "Ang Coinbase ang pinakasikat na paraan upang bumili at magbenta ng Bitcoin, Ethereum, at Litecoin sa buong mundo."
},
"cancel": {
"message": "Kanselahin"
diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json
index e770392d0..6f0bb1584 100644
--- a/app/_locales/pt/messages.json
+++ b/app/_locales/pt/messages.json
@@ -81,7 +81,7 @@
"message": "Comprar no Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase é a forma mais conhecida para comprar e vender bitcoin, ethereum, e litecoin."
+ "message": "Coinbase é a forma mais conhecida para comprar e vender Bitcoin, Ethereum, e Litecoin."
},
"cancel": {
"message": "Cancelar"
diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json
index b43251064..bb722735d 100644
--- a/app/_locales/ru/messages.json
+++ b/app/_locales/ru/messages.json
@@ -84,7 +84,7 @@
"message": "Купить на Coinbase"
},
"buyCoinbaseExplainer": {
- "message": "Биржа Coinbase – это наиболее популярный способ купить или продать bitcoin, ethereum и litecoin."
+ "message": "Биржа Coinbase – это наиболее популярный способ купить или продать Bitcoin, Ethereum и Litecoin."
},
"ok": {
"message": "ОК"
diff --git a/app/_locales/th/messages.json b/app/_locales/th/messages.json
index 3d7dec226..c9aaa0394 100644
--- a/app/_locales/th/messages.json
+++ b/app/_locales/th/messages.json
@@ -762,7 +762,7 @@
"message": "ยินดีต้อนรับสู่หน้าตาใหม่ (เบต้า)"
},
"uiWelcomeMessage": {
- "message": "ขณะนี้คุณใช้งาน Metamask หน้าตาใหม่แล้ว ลองใช้ความสามรถใหม่ ๆ เช่นการส่งโทเค็นและหากพบปัญหากรุณาแจ้งให้เราทราบ"
+ "message": "ขณะนี้คุณใช้งาน MetaMask หน้าตาใหม่แล้ว ลองใช้ความสามรถใหม่ ๆ เช่นการส่งโทเค็นและหากพบปัญหากรุณาแจ้งให้เราทราบ"
},
"unavailable": {
"message": "ใช้งานไม่ได้"
diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json
index c2c09bc91..08ba6cde8 100644
--- a/app/_locales/tr/messages.json
+++ b/app/_locales/tr/messages.json
@@ -84,7 +84,7 @@
"message": "Coinbase'de satın al"
},
"buyCoinbaseExplainer": {
- "message": "Coinbase bitcoin, ethereum, and litecoin alıp satmanın dünyadaki en popüler yolu"
+ "message": "Coinbase Bitcoin, Ethereum, and Litecoin alıp satmanın dünyadaki en popüler yolu"
},
"ok": {
"message": "Tamam"
@@ -852,7 +852,7 @@
"message": "Yeni UI (Beta)'ya hoşgeldiniz"
},
"uiWelcomeMessage": {
- "message": "Şu anda yeni Metamask UI kullanmaktasınız. Gözatın, jeton gönderme gibi yeni özellikleri deneyin ve herhangi bir sorunlar karşılaşırsanız bize haber verin"
+ "message": "Şu anda yeni MetaMask UI kullanmaktasınız. Gözatın, jeton gönderme gibi yeni özellikleri deneyin ve herhangi bir sorunlar karşılaşırsanız bize haber verin"
},
"unapproved": {
"message": "Onaylanmadı"
@@ -909,4 +909,4 @@
"youSign": {
"message": "İmzalıyorsunuz"
}
-} \ No newline at end of file
+}
diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json
index cd30de4de..782dfd119 100644
--- a/app/_locales/vi/messages.json
+++ b/app/_locales/vi/messages.json
@@ -570,7 +570,7 @@
"message": "Chào mừng bạn đến với giao diện mới (Beta)"
},
"uiWelcomeMessage": {
- "message": "Bạn đang sử dụng giao diện mới của Metamask. Chúng tôi khuyến khích bạn thử nghiệm và khám phá các tính năng mới như gửi token, và nếu bạn có gặp phải vấn đề gì khó khăn, xin hãy liên hệ ngay để chúng tôi có thể giúp đỡ bạn."
+ "message": "Bạn đang sử dụng giao diện mới của MetaMask. Chúng tôi khuyến khích bạn thử nghiệm và khám phá các tính năng mới như gửi token, và nếu bạn có gặp phải vấn đề gì khó khăn, xin hãy liên hệ ngay để chúng tôi có thể giúp đỡ bạn."
},
"unavailable": {
"message": "Không có sẵn"
diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json
index 241ea948d..a39bba9da 100644
--- a/app/_locales/zh_CN/messages.json
+++ b/app/_locales/zh_CN/messages.json
@@ -879,7 +879,7 @@
"message": "欢迎使用新版界面 (Beta)"
},
"uiWelcomeMessage": {
- "message": "你现在正在使用新的 Metamask 界面。 尝试发送代币等新功能,有任何问题请告知我们。"
+ "message": "你现在正在使用新的 MetaMask 界面。 尝试发送代币等新功能,有任何问题请告知我们。"
},
"unapproved": {
"message": "未批准"
diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json
index 9aaee0e16..200c75c3c 100644
--- a/app/_locales/zh_TW/messages.json
+++ b/app/_locales/zh_TW/messages.json
@@ -362,7 +362,7 @@
"message": "你想怎麼存入 Ether?"
},
"holdEther": {
- "message": "Metamask 讓您能保存 ether 和代幣, 並成為您接觸分散式應用程式的途徑."
+ "message": "MetaMask 讓您能保存 ether 和代幣, 並成為您接觸分散式應用程式的途徑."
},
"import": {
"message": "導入",
diff --git a/app/images/webcam.svg b/app/images/webcam.svg
new file mode 100644
index 000000000..4b9b58148
--- /dev/null
+++ b/app/images/webcam.svg
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg width="53px" height="53px" viewBox="0 0 53 53" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <!-- Generator: Sketch 50.2 (55047) - http://www.bohemiancoding.com/sketch -->
+ <title>webcam</title>
+ <desc>Created with Sketch.</desc>
+ <defs></defs>
+ <g id="QR-Code-Scan" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
+ <g id="Group-4-Copy" transform="translate(-482.000000, -218.000000)">
+ <g id="webcam" transform="translate(482.000000, 218.000000)">
+ <circle id="Oval" fill="#D5ECFA" cx="26.5" cy="26.5" r="26.5"></circle>
+ <g id="Group" transform="translate(14.000000, 19.000000)" fill="#259DE5">
+ <rect id="Rectangle" x="0" y="0" width="18" height="16"></rect>
+ <polygon id="Triangle" points="19 6.57142857 26 3 26 13 19 9.42857143"></polygon>
+ </g>
+ </g>
+ </g>
+ </g>
+</svg> \ No newline at end of file
diff --git a/app/manifest.json b/app/manifest.json
index ed328f19f..84cedd687 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appName__",
- "version": "4.8.0",
+ "version": "4.9.1",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "__MSG_appDescription__",
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 4cd6dac4c..c7395c810 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -47,8 +47,8 @@ const notificationManager = new NotificationManager()
global.METAMASK_NOTIFIER = notificationManager
// setup sentry error reporting
-const releaseVersion = platform.getVersion()
-const raven = setupRaven({ releaseVersion })
+const release = platform.getVersion()
+const raven = setupRaven({ release })
// browser check if it is Edge - https://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser
// Internet Explorer 6-11
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index b7496f318..e0a2b0061 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -198,6 +198,6 @@ function blacklistedDomainCheck () {
*/
function redirectToPhishingWarning () {
console.log('MetaMask - routing to Phishing Warning component')
- let extensionURL = extension.runtime.getURL('phishing.html')
+ const extensionURL = extension.runtime.getURL('phishing.html')
window.location.href = extensionURL
}
diff --git a/app/scripts/controllers/detect-tokens.js b/app/scripts/controllers/detect-tokens.js
index 195ec918a..62e639795 100644
--- a/app/scripts/controllers/detect-tokens.js
+++ b/app/scripts/controllers/detect-tokens.js
@@ -85,7 +85,7 @@ class DetectTokensController {
set preferences (preferences) {
if (!preferences) { return }
this._preferences = preferences
- preferences.store.subscribe(({ tokens }) => { this.tokenAddresses = tokens.map((obj) => { return obj.address }) })
+ preferences.store.subscribe(({ tokens = [] }) => { this.tokenAddresses = tokens.map((obj) => { return obj.address }) })
preferences.store.subscribe(({ selectedAddress }) => {
if (this.selectedAddress !== selectedAddress) {
this.selectedAddress = selectedAddress
diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js
index f6250dc16..707fd7de9 100644
--- a/app/scripts/controllers/preferences.js
+++ b/app/scripts/controllers/preferences.js
@@ -13,6 +13,7 @@ class PreferencesController {
* @property {array} store.frequentRpcList A list of custom rpcs to provide the user
* @property {string} store.currentAccountTab Indicates the selected tab in the ui
* @property {array} store.tokens The tokens the user wants display in their token lists
+ * @property {object} store.accountTokens The tokens stored per account and then per network type
* @property {boolean} store.useBlockie The users preference for blockie identicons within the UI
* @property {object} store.featureFlags A key-boolean map, where keys refer to features and booleans to whether the
* user wishes to see that feature
@@ -24,6 +25,7 @@ class PreferencesController {
const initState = extend({
frequentRpcList: [],
currentAccountTab: 'history',
+ accountTokens: {},
tokens: [],
useBlockie: false,
featureFlags: {},
@@ -33,8 +35,9 @@ class PreferencesController {
}, opts.initState)
this.diagnostics = opts.diagnostics
-
+ this.network = opts.network
this.store = new ObservableStore(initState)
+ this._subscribeProviderType()
}
// PUBLIC METHODS
@@ -77,12 +80,19 @@ class PreferencesController {
*/
setAddresses (addresses) {
const oldIdentities = this.store.getState().identities
+ const oldAccountTokens = this.store.getState().accountTokens
+
const identities = addresses.reduce((ids, address, index) => {
const oldId = oldIdentities[address] || {}
ids[address] = {name: `Account ${index + 1}`, address, ...oldId}
return ids
}, {})
- this.store.updateState({ identities })
+ const accountTokens = addresses.reduce((tokens, address) => {
+ const oldTokens = oldAccountTokens[address] || {}
+ tokens[address] = oldTokens
+ return tokens
+ }, {})
+ this.store.updateState({ identities, accountTokens })
}
/**
@@ -93,11 +103,13 @@ class PreferencesController {
*/
removeAddress (address) {
const identities = this.store.getState().identities
+ const accountTokens = this.store.getState().accountTokens
if (!identities[address]) {
throw new Error(`${address} can't be deleted cause it was not found`)
}
delete identities[address]
- this.store.updateState({ identities })
+ delete accountTokens[address]
+ this.store.updateState({ identities, accountTokens })
// If the selected account is no longer valid,
// select an arbitrary other account:
@@ -117,14 +129,17 @@ class PreferencesController {
*/
addAddresses (addresses) {
const identities = this.store.getState().identities
+ const accountTokens = this.store.getState().accountTokens
addresses.forEach((address) => {
// skip if already exists
if (identities[address]) return
// add missing identity
const identityCount = Object.keys(identities).length
+
+ accountTokens[address] = {}
identities[address] = { name: `Account ${identityCount + 1}`, address }
})
- this.store.updateState({ identities })
+ this.store.updateState({ identities, accountTokens })
}
/*
@@ -175,15 +190,15 @@ class PreferencesController {
* Setter for the `selectedAddress` property
*
* @param {string} _address A new hex address for an account
- * @returns {Promise<void>} Promise resolves with undefined
+ * @returns {Promise<void>} Promise resolves with tokens
*
*/
setSelectedAddress (_address) {
- return new Promise((resolve, reject) => {
- const address = normalizeAddress(_address)
- this.store.updateState({ selectedAddress: address })
- resolve()
- })
+ const address = normalizeAddress(_address)
+ this._updateTokens(address)
+ this.store.updateState({ selectedAddress: address })
+ const tokens = this.store.getState().tokens
+ return Promise.resolve(tokens)
}
/**
@@ -232,9 +247,7 @@ class PreferencesController {
} else {
tokens.push(newEntry)
}
-
- this.store.updateState({ tokens })
-
+ this._updateAccountTokens(tokens)
return Promise.resolve(tokens)
}
@@ -247,10 +260,8 @@ class PreferencesController {
*/
removeToken (rawAddress) {
const tokens = this.store.getState().tokens
-
const updatedTokens = tokens.filter(token => token.address !== rawAddress)
-
- this.store.updateState({ tokens: updatedTokens })
+ this._updateAccountTokens(updatedTokens)
return Promise.resolve(updatedTokens)
}
@@ -376,6 +387,57 @@ class PreferencesController {
//
// PRIVATE METHODS
//
+ /**
+ * Subscription to network provider type.
+ *
+ *
+ */
+ _subscribeProviderType () {
+ this.network.providerStore.subscribe(() => {
+ const { tokens } = this._getTokenRelatedStates()
+ this.store.updateState({ tokens })
+ })
+ }
+
+ /**
+ * Updates `accountTokens` and `tokens` of current account and network according to it.
+ *
+ * @param {array} tokens Array of tokens to be updated.
+ *
+ */
+ _updateAccountTokens (tokens) {
+ const { accountTokens, providerType, selectedAddress } = this._getTokenRelatedStates()
+ accountTokens[selectedAddress][providerType] = tokens
+ this.store.updateState({ accountTokens, tokens })
+ }
+
+ /**
+ * Updates `tokens` of current account and network.
+ *
+ * @param {string} selectedAddress Account address to be updated with.
+ *
+ */
+ _updateTokens (selectedAddress) {
+ const { tokens } = this._getTokenRelatedStates(selectedAddress)
+ this.store.updateState({ tokens })
+ }
+
+ /**
+ * A getter for `tokens` and `accountTokens` related states.
+ *
+ * @param {string} selectedAddress A new hex address for an account
+ * @returns {Object.<array, object, string, string>} States to interact with tokens in `accountTokens`
+ *
+ */
+ _getTokenRelatedStates (selectedAddress) {
+ const accountTokens = this.store.getState().accountTokens
+ if (!selectedAddress) selectedAddress = this.store.getState().selectedAddress
+ const providerType = this.network.providerStore.getState().type
+ if (!(selectedAddress in accountTokens)) accountTokens[selectedAddress] = {}
+ if (!(providerType in accountTokens[selectedAddress])) accountTokens[selectedAddress][providerType] = []
+ const tokens = accountTokens[selectedAddress][providerType]
+ return { tokens, accountTokens, providerType, selectedAddress }
+ }
}
module.exports = PreferencesController
diff --git a/app/scripts/lib/enums.js b/app/scripts/lib/enums.js
index 0a3afca47..c6d57a1bc 100644
--- a/app/scripts/lib/enums.js
+++ b/app/scripts/lib/enums.js
@@ -2,8 +2,19 @@ const ENVIRONMENT_TYPE_POPUP = 'popup'
const ENVIRONMENT_TYPE_NOTIFICATION = 'notification'
const ENVIRONMENT_TYPE_FULLSCREEN = 'fullscreen'
+const PLATFORM_BRAVE = 'Brave'
+const PLATFORM_CHROME = 'Chrome'
+const PLATFORM_EDGE = 'Edge'
+const PLATFORM_FIREFOX = 'Firefox'
+const PLATFORM_OPERA = 'Opera'
+
module.exports = {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN,
+ PLATFORM_BRAVE,
+ PLATFORM_CHROME,
+ PLATFORM_EDGE,
+ PLATFORM_FIREFOX,
+ PLATFORM_OPERA,
}
diff --git a/app/scripts/lib/ipfsContent.js b/app/scripts/lib/ipfsContent.js
index 5222151ea..5db63f47d 100644
--- a/app/scripts/lib/ipfsContent.js
+++ b/app/scripts/lib/ipfsContent.js
@@ -5,7 +5,7 @@ module.exports = function (provider) {
function ipfsContent (details) {
const name = details.url.substring(7, details.url.length - 1)
let clearTime = null
- extension.tabs.getSelected(null, tab => {
+ extension.tabs.query({active: true}, tab => {
extension.tabs.update(tab.id, { url: 'loading.html' })
clearTime = setTimeout(() => {
@@ -34,11 +34,11 @@ module.exports = function (provider) {
return { cancel: true }
}
- extension.webRequest.onBeforeRequest.addListener(ipfsContent, {urls: ['*://*.eth/', '*://*.test/']})
+ extension.webRequest.onErrorOccurred.addListener(ipfsContent, {urls: ['*://*.eth/', '*://*.test/']})
return {
remove () {
- extension.webRequest.onBeforeRequest.removeListener(ipfsContent)
+ extension.webRequest.onErrorOccurred.removeListener(ipfsContent)
},
}
}
diff --git a/app/scripts/lib/setupRaven.js b/app/scripts/lib/setupRaven.js
index 9aa2dec0a..e6e511640 100644
--- a/app/scripts/lib/setupRaven.js
+++ b/app/scripts/lib/setupRaven.js
@@ -8,7 +8,7 @@ module.exports = setupRaven
// Setup raven / sentry remote error reporting
function setupRaven (opts) {
- const { releaseVersion } = opts
+ const { release } = opts
let ravenTarget
// detect brave
const isBrave = Boolean(window.chrome.ipcRenderer)
@@ -22,7 +22,7 @@ function setupRaven (opts) {
}
const client = Raven.config(ravenTarget, {
- releaseVersion,
+ release,
transport: function (opts) {
opts.data.extra.isBrave = isBrave
const report = opts.data
diff --git a/app/scripts/lib/util.js b/app/scripts/lib/util.js
index 2b3fe3d6e..ea13b26be 100644
--- a/app/scripts/lib/util.js
+++ b/app/scripts/lib/util.js
@@ -5,6 +5,11 @@ const {
ENVIRONMENT_TYPE_POPUP,
ENVIRONMENT_TYPE_NOTIFICATION,
ENVIRONMENT_TYPE_FULLSCREEN,
+ PLATFORM_FIREFOX,
+ PLATFORM_OPERA,
+ PLATFORM_CHROME,
+ PLATFORM_EDGE,
+ PLATFORM_BRAVE,
} = require('./enums')
/**
@@ -38,6 +43,29 @@ const getEnvironmentType = (url = window.location.href) => {
}
/**
+ * Returns the platform (browser) where the extension is running.
+ *
+ * @returns {string} the platform ENUM
+ *
+ */
+const getPlatform = _ => {
+ const ua = navigator.userAgent
+ if (ua.search('Firefox') !== -1) {
+ return PLATFORM_FIREFOX
+ } else {
+ if (window && window.chrome && window.chrome.ipcRenderer) {
+ return PLATFORM_BRAVE
+ } else if (ua.search('Edge') !== -1) {
+ return PLATFORM_EDGE
+ } else if (ua.search('OPR') !== -1) {
+ return PLATFORM_OPERA
+ } else {
+ return PLATFORM_CHROME
+ }
+ }
+}
+
+/**
* Checks whether a given balance of ETH, represented as a hex string, is sufficient to pay a value plus a gas fee
*
* @param {object} txParams Contains data about a transaction
@@ -114,6 +142,7 @@ function removeListeners (listeners, emitter) {
module.exports = {
removeListeners,
applyListeners,
+ getPlatform,
getStack,
getEnvironmentType,
sufficientBalance,
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 12daf1603..81bb080ab 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -86,6 +86,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.preferencesController = new PreferencesController({
initState: initState.PreferencesController,
initLangCode: opts.initLangCode,
+ network: this.networkController,
})
// currency controller
@@ -1405,7 +1406,7 @@ module.exports = class MetamaskController extends EventEmitter {
}
/**
- * A method for activating the retrieval of price data and auto detect tokens,
+ * A method for activating the retrieval of price data,
* which should only be fetched when the UI is visible.
* @private
* @param {boolean} active - True if price data should be getting fetched.
diff --git a/app/scripts/migrations/028.js b/app/scripts/migrations/028.js
new file mode 100644
index 000000000..9e995ee1a
--- /dev/null
+++ b/app/scripts/migrations/028.js
@@ -0,0 +1,40 @@
+// next version number
+const version = 28
+
+/*
+
+normalizes txParams on unconfirmed txs
+
+*/
+const clone = require('clone')
+
+module.exports = {
+ version,
+
+ migrate: async function (originalVersionedData) {
+ const versionedData = clone(originalVersionedData)
+ versionedData.meta.version = version
+ const state = versionedData.data
+ const newState = transformState(state)
+ versionedData.data = newState
+ return versionedData
+ },
+}
+
+function transformState (state) {
+ const newState = state
+
+ if (newState.PreferencesController) {
+ if (newState.PreferencesController.tokens && newState.PreferencesController.identities) {
+ const identities = newState.PreferencesController.identities
+ const tokens = newState.PreferencesController.tokens
+ newState.PreferencesController.accountTokens = {}
+ for (const identity in identities) {
+ newState.PreferencesController.accountTokens[identity] = {'mainnet': tokens}
+ }
+ newState.PreferencesController.tokens = []
+ }
+ }
+
+ return newState
+}
diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js
index bd0005221..3b512715e 100644
--- a/app/scripts/migrations/index.js
+++ b/app/scripts/migrations/index.js
@@ -38,4 +38,5 @@ module.exports = [
require('./025'),
require('./026'),
require('./027'),
+ require('./028'),
]
diff --git a/app/scripts/platforms/extension.js b/app/scripts/platforms/extension.js
index 0803164e8..71b162dd0 100644
--- a/app/scripts/platforms/extension.js
+++ b/app/scripts/platforms/extension.js
@@ -24,8 +24,13 @@ class ExtensionPlatform {
return extension.runtime.getManifest().version
}
- openExtensionInBrowser (route = null) {
+ openExtensionInBrowser (route = null, queryString = null) {
let extensionURL = extension.runtime.getURL('home.html')
+
+ if (queryString) {
+ extensionURL += `?${queryString}`
+ }
+
if (route) {
extensionURL += `#${route}`
}