2017-04-05 03:23:46 +02:00
|
|
|
module.exports = getBuyEthUrl
|
|
|
|
|
2018-04-16 19:08:04 +02:00
|
|
|
/**
|
|
|
|
* Gives the caller a url at which the user can acquire eth, depending on the network they are in
|
|
|
|
*
|
|
|
|
* @param {object} opts Options required to determine the correct url
|
|
|
|
* @param {string} opts.network The network for which to return a url
|
|
|
|
* @param {string} opts.amount The amount of ETH to buy on coinbase. Only relevant if network === '1'.
|
2018-04-17 01:53:29 +02:00
|
|
|
* @param {string} opts.address The address the bought ETH should be sent to. Only relevant if network === '1'.
|
|
|
|
* @returns {string|undefined} The url at which the user can access ETH, while in the given network. If the passed
|
|
|
|
* network does not match any of the specified cases, or if no network is given, returns undefined.
|
2018-04-16 19:08:04 +02:00
|
|
|
*
|
|
|
|
*/
|
2017-04-27 06:05:45 +02:00
|
|
|
function getBuyEthUrl ({ network, amount, address }) {
|
2017-04-05 03:23:46 +02:00
|
|
|
let url
|
|
|
|
switch (network) {
|
|
|
|
case '1':
|
|
|
|
url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH`
|
|
|
|
break
|
|
|
|
|
|
|
|
case '3':
|
|
|
|
url = 'https://faucet.metamask.io/'
|
|
|
|
break
|
|
|
|
|
2017-04-25 23:39:01 +02:00
|
|
|
case '4':
|
|
|
|
url = 'https://www.rinkeby.io/'
|
|
|
|
break
|
|
|
|
|
2017-04-05 03:23:46 +02:00
|
|
|
case '42':
|
|
|
|
url = 'https://github.com/kovan-testnet/faucet'
|
|
|
|
break
|
|
|
|
}
|
|
|
|
return url
|
2017-04-25 23:39:01 +02:00
|
|
|
}
|