aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2019-03-29 10:20:19 +0800
committerkumavis <aaron@kumavis.me>2019-03-29 10:20:19 +0800
commit38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8 (patch)
treed41ec29bb4797952e465799601ab7d4f46c90bb7 /app/scripts
parent649a1d483a574dcff902708f95b37329a02709a8 (diff)
parentb004b182bfafc317412d8dff1a43020db8dac3fe (diff)
downloadtangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.tar
tangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.tar.gz
tangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.tar.bz2
tangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.tar.lz
tangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.tar.xz
tangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.tar.zst
tangerine-wallet-browser-38b85adbe01fe3f01ec81f395026dc1cbe2c0ec8.zip
Merge branch 'develop' of https://github.com/vimalsagar/metamask-extension into vimalsagar-develop
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/lib/buy-eth-url.js41
1 files changed, 27 insertions, 14 deletions
diff --git a/app/scripts/lib/buy-eth-url.js b/app/scripts/lib/buy-eth-url.js
index 040b5695b..d9d5155c2 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 (networkId) {
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: "${networkId}"`)
}