diff options
Diffstat (limited to 'app')
32 files changed, 283 insertions, 138 deletions
diff --git a/app/_locales/cs/messages.json b/app/_locales/cs/messages.json index 2bce52cd9..a28c4cb4a 100644 --- a/app/_locales/cs/messages.json +++ b/app/_locales/cs/messages.json @@ -131,6 +131,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase je světově nejoblíbenější místo k nákupu a prodeji bitcoinu, etherea nebo litecoinu." }, + "buyCoinSwitch": { + "message": "Nákup na CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch je jediným místem, kde můžete vyměňovat více než 300 kryptocurrencí za nejlepší cenu." + }, "ok": { "message": "Ok" }, @@ -164,6 +170,9 @@ "continueToCoinbase": { "message": "Přejít na Coinbase" }, + "continueToCoinSwitch": { + "message": "Přejít na CoinSwitch" + }, "contractDeployment": { "message": "Nasazení kontraktu" }, diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 25ec628f0..b76f87772 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -131,6 +131,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase ist die weltweit bekannteste Art und Weise um Bitcoin, Ethereum und Litecoin zu kaufen und verkaufen." }, + "buyCoinSwitch": { + "message": "Auf CoinSwitch kaufen" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch ist die One-Stop-Destination, um mehr als 300 Kryptowährungen zum besten Preis zu tauschen." + }, "ok": { "message": "Ok" }, @@ -164,6 +170,9 @@ "continueToCoinbase": { "message": "Zu Coinbase fortfahren" }, + "continueToCoinSwitch": { + "message": "Zu CoinSwitch fortfahren" + }, "contractDeployment": { "message": "Smart Contract Ausführung" }, diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index eab243b8a..154925d1a 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -44,6 +44,12 @@ "providerRequestInfo": { "message": "This site is requesting access to view your current account address. Always make sure you trust the sites you interact with." }, + "about": { + "message": "About" + }, + "aboutSettingsDescription": { + "message": "Version, support center, and contact info." + }, "aboutUs": { "message": "About Us" }, @@ -201,7 +207,13 @@ "message": "Buy ETH with Wyre" }, "buyWithWyreDescription": { - "message": "Wyre lets you use aa credit card to deposit ETH right in to your MetaMask account. From the Airswap website, click \"Use Fiat\" in the top-right corner. You can also use Airswap to get started with ERC 20 tokens!" + "message": "Wyre lets you use a credit card to deposit ETH right in to your MetaMask account." + }, + "buyCoinSwitch": { + "message": "Buy on CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch is the one-stop destination to exchange more than 300 cryptocurrencies at the best rate." }, "bytes": { "message": "Bytes" @@ -314,6 +326,9 @@ "continueToWyre": { "message": "Continue to Wyre" }, + "continueToCoinSwitch": { + "message": "Continue to CoinSwitch" + }, "contractDeployment": { "message": "Contract Deployment" }, diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index 8033b962c..3bdbfa852 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -131,6 +131,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase es la plataforma global más popular para comprar y vender Bitcoin, Ethereum y Litecoin" }, + "buyCoinSwitch": { + "message": "Comprar en CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch es el destino de una sola parada para intercambiar más de 300 criptomonedas al mejor precio." + }, "cancel": { "message": "Cancelar" }, @@ -176,6 +182,9 @@ "continueToCoinbase": { "message": "Continuar a Coinbase" }, + "continueToCoinSwitch": { + "message": "Continuar a CoinSwitch" + }, "contractDeployment": { "message": "Desplegar (Deploy) contrato" }, diff --git a/app/_locales/fr/messages.json b/app/_locales/fr/messages.json index 9018ef578..d2ba10009 100644 --- a/app/_locales/fr/messages.json +++ b/app/_locales/fr/messages.json @@ -152,6 +152,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase est le moyen le plus populaire d'acheter et de vendre des Ethers." }, + "buyCoinSwitch": { + "message": "Acheter sur CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch est la destination unique pour échanger plus de 300 crypto-devises au meilleur taux." + }, "bytes": { "message": "Bytes" }, @@ -233,6 +239,9 @@ "continueToCoinbase": { "message": "Continuer vers Coinbase" }, + "continueToCoinSwitch": { + "message": "Continuer vers CoinSwitch" + }, "contractDeployment": { "message": "Déploiement de contrat" }, diff --git a/app/_locales/hn/messages.json b/app/_locales/hn/messages.json index 4face7bd6..6c27ee1bc 100644 --- a/app/_locales/hn/messages.json +++ b/app/_locales/hn/messages.json @@ -128,6 +128,12 @@ "buyCoinbaseExplainer": { "message": "बिल्टकोइन, इथीरियम और लाइटकोइन खरीदने और बेचने के लिए दुनिया का सबसे लोकप्रिय तरीका कॉइनबेस है।" }, + "buyCoinSwitch": { + "message": "कॉइनस्विच पर खरीदें" + }, + "buyCoinSwitchExplainer": { + "message": "कॉइनस्विच 300 से अधिक क्रिप्टोक्रांसियों को सर्वोत्तम दर पर विनिमय करने का एक-स्टॉप गंतव्य है।" + }, "cancel": { "message": "रद्द करें" }, @@ -155,6 +161,9 @@ "continueToCoinbase": { "message": "कॉइनबेस को ब्हेजना जारी रखें" }, + "continueToCoinSwitch": { + "message": "कॉइनस्विच को ब्हेजना जारी रखें" + }, "contractDeployment": { "message": "अनुबंध परिनियोजन व तैनाती" }, diff --git a/app/_locales/ht/messages.json b/app/_locales/ht/messages.json index c94ddc8d2..4a4c92f3a 100644 --- a/app/_locales/ht/messages.json +++ b/app/_locales/ht/messages.json @@ -155,6 +155,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase se fason ki pi popilè nan mond lan yo achte ak vann Bitcoin, Ethereum, ak Litecoin." }, + "buyCoinSwitch": { + "message": "Achte sou CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch se destinasyon nan yon sèl-Stop nan echanj plis pase 300 kriptoksèr nan pousantaj la pi byen." + }, "bytes": { "message": "Bytes" }, @@ -239,6 +245,9 @@ "continueToCoinbase": { "message": "Kontinye Coinbase" }, + "continueToCoinSwitch": { + "message": "Kontinye CoinSwitch" + }, "contractDeployment": { "message": "Kontra Deplwaman" }, diff --git a/app/_locales/it/messages.json b/app/_locales/it/messages.json index 999bb8ec4..9e0f1f06d 100644 --- a/app/_locales/it/messages.json +++ b/app/_locales/it/messages.json @@ -179,6 +179,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase è il servizio più popolare al mondo per comprare e vendere Bitcoin, Ethereum e Litecoin." }, + "buyCoinSwitch": { + "message": "Compra su CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch è la destinazione one-stop per lo scambio di oltre 300 criptovalute alla migliore tariffa." + }, "bytes": { "message": "Bytes" }, @@ -281,6 +287,9 @@ "continueToCoinbase": { "message": "Continua su Coinbase" }, + "continueToCoinSwitch": { + "message": "Continua su CoinSwitch" + }, "contractDeployment": { "message": "Distribuzione Contratto" }, diff --git a/app/_locales/ja/messages.json b/app/_locales/ja/messages.json index 93b5447d7..fcac67894 100644 --- a/app/_locales/ja/messages.json +++ b/app/_locales/ja/messages.json @@ -122,6 +122,12 @@ "buyCoinbaseExplainer": { "message": "Etherを購入できます。Coinbaseは、世界的なBitcoin、Ethereum、そしてLitecoinの取引所です。" }, + "buyCoinSwitch": { + "message": "CoinSwitchのサイトで購入" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitchは、最高のレートで300以上の暗号化交換を行うワンストップの宛先です。" + }, "cancel": { "message": "キャンセル" }, @@ -149,6 +155,9 @@ "continueToCoinbase": { "message": "Coinbaseを開く" }, + "continueToCoinSwitch": { + "message": "CoinSwitchを開く" + }, "contractDeployment": { "message": "コントラクトのデプロイ" }, diff --git a/app/_locales/ko/messages.json b/app/_locales/ko/messages.json index b824cd72f..bf11640e2 100644 --- a/app/_locales/ko/messages.json +++ b/app/_locales/ko/messages.json @@ -182,6 +182,12 @@ "buyCoinbaseExplainer": { "message": "코인베이스는 비트코인, 이더리움, 라이트코인을 거래할 수 있는 유명한 거래소입니다." }, + "buyCoinSwitch": { + "message": "코인 스위치 구입" + }, + "buyCoinSwitchExplainer": { + "message": "코인 스위치는 최상의 속도로 300 개 이상의 크립토 카드를 교환하는 원 스톱 목적지입니다." + }, "bytes": { "message": "바이트" }, @@ -287,6 +293,9 @@ "continueToCoinbase": { "message": "코인베이스로 계속하기" }, + "continueToCoinSwitch": { + "message": "코인 스위치 계속하기" + }, "contractDeployment": { "message": "컨트랙트 배포" }, diff --git a/app/_locales/nl/messages.json b/app/_locales/nl/messages.json index b7b06e075..12bde6585 100644 --- a/app/_locales/nl/messages.json +++ b/app/_locales/nl/messages.json @@ -128,6 +128,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase is 's werelds populairste manier om Bitcoin, Ethereum en Litecoin te kopen en verkopen." }, + "buyCoinSwitch": { + "message": "Koop op CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch is de one-stop-bestemming om meer dan 300 cryptocurrencies tegen de beste prijs in te wisselen." + }, "cancel": { "message": "Annuleer" }, @@ -155,6 +161,9 @@ "continueToCoinbase": { "message": "Ga verder naar Coinbase" }, + "continueToCoinSwitch": { + "message": "Ga verder naar CoinSwitch" + }, "contractDeployment": { "message": "Contractimplementatie" }, diff --git a/app/_locales/ph/messages.json b/app/_locales/ph/messages.json index cef686868..da3cf266d 100644 --- a/app/_locales/ph/messages.json +++ b/app/_locales/ph/messages.json @@ -110,6 +110,12 @@ "buyCoinbaseExplainer": { "message": "Ang Coinbase ang pinakasikat na paraan upang bumili at magbenta ng Bitcoin, Ethereum, at Litecoin sa buong mundo." }, + "buyCoinSwitch": { + "message": "Bumili sa CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "Ang CoinSwitch ay isang one-stop destination upang makipagpalitan ng higit sa 300 mga cryptocurrency sa pinakamahusay na rate." + }, "cancel": { "message": "Kanselahin" }, @@ -131,6 +137,9 @@ "continueToCoinbase": { "message": "Magpatuloy sa Coinbase" }, + "continueToCoinSwitch": { + "message": "Magpatuloy sa CoinSwitch" + }, "contractDeployment": { "message": "Pag-deploy ng Contract" }, diff --git a/app/_locales/pt/messages.json b/app/_locales/pt/messages.json index 08af4b2a6..e51b1f72e 100644 --- a/app/_locales/pt/messages.json +++ b/app/_locales/pt/messages.json @@ -128,6 +128,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase é a forma mais conhecida para comprar e vender Bitcoin, Ethereum, e Litecoin." }, + "buyCoinSwitch": { + "message": "Comprar no CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch é o destino único para trocar mais de 300 moedas criptográficas com a melhor taxa." + }, "cancel": { "message": "Cancelar" }, @@ -155,6 +161,9 @@ "continueToCoinbase": { "message": "Continuar para o Coinbase" }, + "continueToCoinSwitch": { + "message": "Continuar para o CoinSwitch" + }, "contractDeployment": { "message": "Distribuição do Contrato" }, diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index 9568c64e6..f80efcc56 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -131,6 +131,12 @@ "buyCoinbaseExplainer": { "message": "Биржа Coinbase – это наиболее популярный способ купить или продать Bitcoin, Ethereum и Litecoin." }, + "buyCoinSwitch": { + "message": "Купить на CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch - это однонаправленное место для обмена более 300 криптоконверсий по наилучшей цене." + }, "ok": { "message": "ОК" }, @@ -164,6 +170,9 @@ "continueToCoinbase": { "message": "Продолжить в Coinbase" }, + "continueToCoinSwitch": { + "message": "Продолжить в CoinSwitch" + }, "contractDeployment": { "message": "Развертывание контракта" }, diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index 857c37021..2f3616dee 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -218,6 +218,12 @@ "ok": { "message": "V redu" }, + "buyCoinSwitch": { + "message": "Kupi na CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch je destinacija na enem mestu za izmenjavo več kot 300 kriptokotovitev po najboljši hitrosti." + }, "cancel": { "message": "Prekliči" }, @@ -305,6 +311,9 @@ "continueToCoinbase": { "message": "Nadaljuj na Coinbase" }, + "continueToCoinSwitch": { + "message": "Nadaljuj na CoinSwitch" + }, "contractDeployment": { "message": "Ustvarjanje pogodbe" }, diff --git a/app/_locales/th/messages.json b/app/_locales/th/messages.json index b80c39b98..d851d325f 100644 --- a/app/_locales/th/messages.json +++ b/app/_locales/th/messages.json @@ -128,6 +128,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase เป็นแหล่งซื้อขายบิตคอยน์ไลท์คอยน์และอีเธอเรียมที่ได้รับความนิยมสูงสุดในโลก" }, + "buyCoinSwitch": { + "message": "ซื้อด้วย CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch เป็นจุดหมายปลายทางแบบครบวงจรในการแลกเปลี่ยนสกุลเงินมากกว่า 300 ครั้งในอัตราที่ดีที่สุด" + }, "cancel": { "message": "ยกเลิก" }, @@ -155,6 +161,9 @@ "continueToCoinbase": { "message": "ไปที่ Coinbase" }, + "continueToCoinSwitch": { + "message": "ไปที่ CoinSwitch" + }, "contractDeployment": { "message": "การติดตั้งสัญญา" }, diff --git a/app/_locales/tml/messages.json b/app/_locales/tml/messages.json index 03ae4b7ff..e1ef45138 100644 --- a/app/_locales/tml/messages.json +++ b/app/_locales/tml/messages.json @@ -131,6 +131,12 @@ "buyCoinbaseExplainer": { "message": "கோஇன்பசே பிறகாய்ன் , எதெரியும் மற்றும் ளிட்டசோன் வாங்க மற்றும் விற்க உலகின் மிகவும் பிரபலமான வழி" }, + "buyCoinSwitch": { + "message": "நாணயம் ஸ்விட்சில் வாங்கவும்" + }, + "buyCoinSwitchExplainer": { + "message": "சிறந்த விகிதத்தில் 300 க்கும் அதிகமான cryptocurrencies ஐ பரிமாறிக்கொள்ள ஒரு நாணயமாற்று இலக்கு நாணயம் ஸ்விட்ச் ஆகும்." + }, "ok": { "message": "சரி" }, @@ -164,6 +170,9 @@ "continueToCoinbase": { "message": "கோஇன்பசே ஐத் தொடரவும்" }, + "continueToCoinSwitch": { + "message": "நாணயம் மாறாமல் தொடர்க" + }, "contractDeployment": { "message": "ஒப்பந்த வரிசைப்படுத்தல்" }, diff --git a/app/_locales/tr/messages.json b/app/_locales/tr/messages.json index b085828a2..bcf96dece 100644 --- a/app/_locales/tr/messages.json +++ b/app/_locales/tr/messages.json @@ -131,6 +131,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase Bitcoin, Ethereum, and Litecoin alıp satmanın dünyadaki en popüler yolu" }, + "buyCoinSwitch": { + "message": "CoinSwitch'de satın al" + }, + "buyCoinSwitchExplainer": { + "message": "Cairnswich, 300'den fazla kriptona en iyi oranda eşlik eden tek durak noktasıdır." + }, "ok": { "message": "Tamam" }, @@ -164,6 +170,9 @@ "continueToCoinbase": { "message": "Coinbase'e devam et" }, + "continueToCoinSwitch": { + "message": "CoinSwitch'e devam et" + }, "contractDeployment": { "message": "Sözleşme kurulumu" }, diff --git a/app/_locales/vi/messages.json b/app/_locales/vi/messages.json index f0837ba98..857f78597 100644 --- a/app/_locales/vi/messages.json +++ b/app/_locales/vi/messages.json @@ -110,6 +110,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase là dịch vụ ví điện tử thông dụng nhất thế giới để mua bán Bitcoin, Ethereum, và Litecoin" }, + "buyCoinSwitch": { + "message": "Mua trên CoinSwitch" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch là điểm đến duy nhất để trao đổi hơn 300 tiền điện tử với tốc độ tốt nhất." + }, "cancel": { "message": "Hủy" }, @@ -131,6 +137,9 @@ "continueToCoinbase": { "message": "Tiếp tục đến Coinbase" }, + "continueToCoinSwitch": { + "message": "Tiếp tục đến CoinSwitch" + }, "contractDeployment": { "message": "Triển khai hợp đồng" }, diff --git a/app/_locales/zh_CN/messages.json b/app/_locales/zh_CN/messages.json index 9d929d9a3..0d3727703 100644 --- a/app/_locales/zh_CN/messages.json +++ b/app/_locales/zh_CN/messages.json @@ -134,6 +134,12 @@ "buyCoinbaseExplainer": { "message": "Coinbase 是世界上最流行的买卖比特币,以太币和莱特币的交易所。" }, + "buyCoinSwitch": { + "message": "在CoinSwitch上购买" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch是以最优惠的价格交换超过300种加密货币的一站式目的地。" + }, "ok": { "message": "确认" }, @@ -173,6 +179,9 @@ "continueToCoinbase": { "message": "继续访问 Coinbase" }, + "continueToCoinSwitch": { + "message": "继续访问 CoinSwitch" + }, "contractDeployment": { "message": "合约部署" }, diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index d9d84b173..c645f2af1 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -188,6 +188,12 @@ "bytes": { "message": "位元組" }, + "buyCoinSwitch": { + "message": "在CoinSwitch上购买" + }, + "buyCoinSwitchExplainer": { + "message": "CoinSwitch是以最优惠的价格交换超过300种加密货币的一站式目的地。" + }, "ok": { "message": "Ok" }, @@ -272,6 +278,9 @@ "continueToCoinbase": { "message": "繼續前往 Coinbase" }, + "continueToCoinSwitch": { + "message": "繼續前往 CoinSwitch" + }, "contractDeployment": { "message": "部署合約" }, diff --git a/app/images/coinswitch_logo.png b/app/images/coinswitch_logo.png Binary files differnew file mode 100644 index 000000000..445ecf02e --- /dev/null +++ b/app/images/coinswitch_logo.png diff --git a/app/manifest.json b/app/manifest.json index df5b67bb9..941842636 100644 --- a/app/manifest.json +++ b/app/manifest.json @@ -1,7 +1,7 @@ { "name": "__MSG_appName__", "short_name": "__MSG_appName__", - "version": "6.2.2", + "version": "6.3.1", "manifest_version": 2, "author": "https://metamask.io", "description": "__MSG_appDescription__", diff --git a/app/scripts/background.js b/app/scripts/background.js index 7fea3c8c6..cca0d4709 100644 --- a/app/scripts/background.js +++ b/app/scripts/background.js @@ -106,7 +106,6 @@ setupMetamaskMeshMetrics() * @property {string} rpcTarget - DEPRECATED - The URL of the current RPC provider. * @property {Object} identities - An object matching lower-case hex addresses to Identity objects with "address" and "name" (nickname) keys. * @property {Object} unapprovedTxs - An object mapping transaction hashes to unapproved transactions. - * @property {boolean} noActiveNotices - False if there are notices the user should confirm before using the application. * @property {Array} frequentRpcList - A list of frequently used RPCs, including custom user-provided ones. * @property {Array} addressBook - A list of previously sent to addresses. * @property {address} selectedTokenAddress - Used to indicate if a token is globally selected. Should be deprecated in favor of UI-centric token selection. diff --git a/app/scripts/controllers/network/network.js b/app/scripts/controllers/network/network.js index 0c6327f6e..47432c1e2 100644 --- a/app/scripts/controllers/network/network.js +++ b/app/scripts/controllers/network/network.js @@ -25,10 +25,18 @@ const INFURA_PROVIDER_TYPES = [ROPSTEN, RINKEBY, KOVAN, MAINNET] const env = process.env.METAMASK_ENV const METAMASK_DEBUG = process.env.METAMASK_DEBUG -const testMode = (METAMASK_DEBUG || env === 'test') + +let defaultProviderConfigType +if (process.env.IN_TEST === 'true') { + defaultProviderConfigType = LOCALHOST +} else if (METAMASK_DEBUG || env === 'test') { + defaultProviderConfigType = RINKEBY +} else { + defaultProviderConfigType = MAINNET +} const defaultProviderConfig = { - type: testMode ? RINKEBY : MAINNET, + type: defaultProviderConfigType, } const defaultNetworkConfig = { diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index f92341353..737411890 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -40,7 +40,9 @@ class PreferencesController { // Feature flag toggling is available in the global namespace // for convenient testing of pre-release features, and should never // perform sensitive operations. - featureFlags: {}, + featureFlags: { + privacyMode: true, + }, knownMethodData: {}, participateInMetaMetrics: null, firstTimeFlowType: null, diff --git a/app/scripts/lib/buy-eth-url.js b/app/scripts/lib/buy-eth-url.js index 040b5695b..fbe6c6c9e 100644 --- a/app/scripts/lib/buy-eth-url.js +++ b/app/scripts/lib/buy-eth-url.js @@ -11,24 +11,37 @@ module.exports = getBuyEthUrl * network does not match any of the specified cases, or if no network is given, returns undefined. * */ -function getBuyEthUrl ({ network, amount, address }) { - let url +function getBuyEthUrl ({ network, amount, address, service }) { + // default service by network if not specified + if (!service) service = getDefaultServiceForNetwork(network) + + switch (service) { + case 'wyre': + return `https://dash.sendwyre.com/sign-up` + case 'coinswitch': + return `https://metamask.coinswitch.co/?address=${address}&to=eth` + case 'coinbase': + return `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH` + case 'metamask-faucet': + return 'https://faucet.metamask.io/' + case 'rinkeby-faucet': + return 'https://www.rinkeby.io/' + case 'kovan-faucet': + return 'https://github.com/kovan-testnet/faucet' + } + throw new Error(`Unknown cryptocurrency exchange or faucet: "${service}"`) +} + +function getDefaultServiceForNetwork (network) { switch (network) { case '1': - url = `https://dash.sendwyre.com/sign-up` - break - + return 'wyre' case '3': - url = 'https://faucet.metamask.io/' - break - + return 'metamask-faucet' case '4': - url = 'https://www.rinkeby.io/' - break - + return 'rinkeby-faucet' case '42': - url = 'https://github.com/kovan-testnet/faucet' - break + return 'kovan-faucet' } - return url + throw new Error(`No default cryptocurrency exchange or faucet for networkId: "${network}"`) } diff --git a/app/scripts/lib/nodeify.js b/app/scripts/lib/nodeify.js index 25be6537b..a813ae679 100644 --- a/app/scripts/lib/nodeify.js +++ b/app/scripts/lib/nodeify.js @@ -1,5 +1,5 @@ const promiseToCallback = require('promise-to-callback') -const noop = function () {} +const callbackNoop = function (err) { if (err) throw err } /** * A generator that returns a function which, when passed a promise, can treat that promise as a node style callback. @@ -11,6 +11,7 @@ const noop = function () {} */ module.exports = function nodeify (fn, context) { return function () { + // parse arguments const args = [].slice.call(arguments) const lastArg = args[args.length - 1] const lastArgIsCallback = typeof lastArg === 'function' @@ -19,8 +20,16 @@ module.exports = function nodeify (fn, context) { callback = lastArg args.pop() } else { - callback = noop + callback = callbackNoop } - promiseToCallback(fn.apply(context, args))(callback) + // call the provided function and ensure result is a promise + let result + try { + result = Promise.resolve(fn.apply(context, args)) + } catch (err) { + result = Promise.reject(err) + } + // wire up promise resolution to callback + promiseToCallback(result)(callback) } } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 540aee936..4108ed4c0 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -24,7 +24,6 @@ const KeyringController = require('eth-keyring-controller') const NetworkController = require('./controllers/network') const PreferencesController = require('./controllers/preferences') const CurrencyController = require('./controllers/currency') -const NoticeController = require('./notice-controller') const ShapeShiftController = require('./controllers/shapeshift') const InfuraController = require('./controllers/infura') const BlacklistController = require('./controllers/blacklist') @@ -211,13 +210,6 @@ module.exports = class MetamaskController extends EventEmitter { }) this.balancesController.updateAllBalances() - // notices - this.noticeController = new NoticeController({ - initState: initState.NoticeController, - version, - firstVersion: initState.firstTimeInfo.version, - }) - this.shapeshiftController = new ShapeShiftController({ initState: initState.ShapeShiftController, }) @@ -243,7 +235,6 @@ module.exports = class MetamaskController extends EventEmitter { PreferencesController: this.preferencesController.store, AddressBookController: this.addressBookController, CurrencyController: this.currencyController.store, - NoticeController: this.noticeController.store, ShapeShiftController: this.shapeshiftController.store, NetworkController: this.networkController.store, InfuraController: this.infuraController.store, @@ -265,7 +256,6 @@ module.exports = class MetamaskController extends EventEmitter { RecentBlocksController: this.recentBlocksController.store, AddressBookController: this.addressBookController, CurrencyController: this.currencyController.store, - NoticeController: this.noticeController.memStore, ShapeshiftController: this.shapeshiftController.store, InfuraController: this.infuraController.store, ProviderApprovalController: this.providerApprovalController.store, @@ -371,7 +361,6 @@ module.exports = class MetamaskController extends EventEmitter { const keyringController = this.keyringController const preferencesController = this.preferencesController const txController = this.txController - const noticeController = this.noticeController const networkController = this.networkController const providerApprovalController = this.providerApprovalController @@ -470,10 +459,6 @@ module.exports = class MetamaskController extends EventEmitter { signTypedMessage: nodeify(this.signTypedMessage, this), cancelTypedMessage: this.cancelTypedMessage.bind(this), - // notices - checkNotices: noticeController.updateNoticesList.bind(noticeController), - markNoticeRead: noticeController.markNoticeRead.bind(noticeController), - approveProviderRequest: providerApprovalController.approveProviderRequest.bind(providerApprovalController), clearApprovedOrigins: providerApprovalController.clearApprovedOrigins.bind(providerApprovalController), rejectProviderRequest: providerApprovalController.rejectProviderRequest.bind(providerApprovalController), diff --git a/app/scripts/migrations/033.js b/app/scripts/migrations/033.js new file mode 100644 index 000000000..3abb2593e --- /dev/null +++ b/app/scripts/migrations/033.js @@ -0,0 +1,32 @@ +// next version number +const version = 33 + +/* + +Cleans up notices and assocated notice controller code + +*/ + +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 + // transform state here + if (state.NoticeController) { + delete newState.NoticeController + } + return newState +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index eb1b51685..be3328bad 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -42,4 +42,6 @@ module.exports = [ require('./029'), require('./030'), require('./031'), + require('./032'), + require('./033'), ] diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js deleted file mode 100644 index 6fe8b8cf0..000000000 --- a/app/scripts/notice-controller.js +++ /dev/null @@ -1,100 +0,0 @@ -const {EventEmitter} = require('events') -const semver = require('semver') -const extend = require('xtend') -const ObservableStore = require('obs-store') -const hardCodedNotices = require('../../notices/notices.js') -const uniqBy = require('lodash.uniqby') - -module.exports = class NoticeController extends EventEmitter { - - constructor (opts = {}) { - super() - this.noticePoller = null - this.firstVersion = opts.firstVersion - this.version = opts.version - const initState = extend({ - noticesList: [], - }, opts.initState) - this.store = new ObservableStore(initState) - // setup memStore - this.memStore = new ObservableStore({}) - this.store.subscribe(() => this._updateMemstore()) - this._updateMemstore() - // pull in latest notices - this.updateNoticesList() - } - - getNoticesList () { - return this.store.getState().noticesList - } - - getUnreadNotices () { - const notices = this.getNoticesList() - return notices.filter((notice) => notice.read === false) - } - - getNextUnreadNotice () { - const unreadNotices = this.getUnreadNotices() - return unreadNotices[0] - } - - async setNoticesList (noticesList) { - this.store.updateState({ noticesList }) - return true - } - - markNoticeRead (noticeToMark, cb) { - cb = cb || function (err) { if (err) throw err } - try { - const notices = this.getNoticesList() - const index = notices.findIndex((currentNotice) => currentNotice.id === noticeToMark.id) - notices[index].read = true - notices[index].body = '' - this.setNoticesList(notices) - const latestNotice = this.getNextUnreadNotice() - cb(null, latestNotice) - } catch (err) { - cb(err) - } - } - - async updateNoticesList () { - const newNotices = await this._retrieveNoticeData() - const oldNotices = this.getNoticesList() - const combinedNotices = this._mergeNotices(oldNotices, newNotices) - const filteredNotices = this._filterNotices(combinedNotices) - const result = this.setNoticesList(filteredNotices) - this._updateMemstore() - return result - } - - _mergeNotices (oldNotices, newNotices) { - return uniqBy(oldNotices.concat(newNotices), 'id') - } - - _filterNotices (notices) { - return notices.filter((newNotice) => { - if ('version' in newNotice) { - const satisfied = semver.satisfies(this.version, newNotice.version) - return satisfied - } - if ('firstVersion' in newNotice) { - const satisfied = semver.satisfies(this.firstVersion, newNotice.firstVersion) - return satisfied - } - return true - }) - } - - async _retrieveNoticeData () { - // Placeholder for remote notice API. - return hardCodedNotices - } - - _updateMemstore () { - const nextUnreadNotice = this.getNextUnreadNotice() - const noActiveNotices = !nextUnreadNotice - this.memStore.updateState({ nextUnreadNotice, noActiveNotices }) - } - -} |