|
|
@ -12,28 +12,34 @@ module.exports = getBuyEthUrl |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function getBuyEthUrl({ network, amount, address, service }) { |
|
|
|
function getBuyEthUrl({ network, amount, address, service }) { |
|
|
|
let url |
|
|
|
// default service by network if not specified
|
|
|
|
if (typeof network !== 'undefined') { |
|
|
|
if (!service) service = getDefaultServiceForNetwork(network) |
|
|
|
switch (network) { |
|
|
|
|
|
|
|
case '1': |
|
|
|
switch (service) { |
|
|
|
url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH` |
|
|
|
case 'coinswitch': |
|
|
|
break |
|
|
|
return `https://metamask.coinswitch.co/?address=${address}&to=eth` |
|
|
|
case '3': |
|
|
|
case 'coinbase': |
|
|
|
url = 'https://faucet.metamask.io/' |
|
|
|
return `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH` |
|
|
|
break |
|
|
|
case 'metamask-faucet': |
|
|
|
case '4': |
|
|
|
return 'https://faucet.metamask.io/' |
|
|
|
url = 'https://www.rinkeby.io/' |
|
|
|
case 'rinkeby-faucet': |
|
|
|
break |
|
|
|
return 'https://www.rinkeby.io/' |
|
|
|
case '42': |
|
|
|
case 'kovan-faucet': |
|
|
|
url = 'https://github.com/kovan-testnet/faucet' |
|
|
|
return 'https://github.com/kovan-testnet/faucet' |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
throw new Error(`Unknown cryptocurrency exchange or faucet: "${service}"`) |
|
|
|
} else { |
|
|
|
} |
|
|
|
switch (service) { |
|
|
|
|
|
|
|
case 'coinswitch': |
|
|
|
function getDefaultServiceForNetwork (networkId) { |
|
|
|
url = `https://metamask.coinswitch.co/?address=${address}&to=eth` |
|
|
|
switch (network) { |
|
|
|
break |
|
|
|
case '1': |
|
|
|
} |
|
|
|
return 'coinbase' |
|
|
|
|
|
|
|
case '3': |
|
|
|
|
|
|
|
return 'metamask-faucet' |
|
|
|
|
|
|
|
case '4': |
|
|
|
|
|
|
|
return 'rinkeby-faucet' |
|
|
|
|
|
|
|
case '42': |
|
|
|
|
|
|
|
return 'kovan-faucet' |
|
|
|
} |
|
|
|
} |
|
|
|
return url |
|
|
|
throw new Error(`No default cryptocurrency exchange or faucet for networkId: "${networkId}"`) |
|
|
|
} |
|
|
|
} |
|
|
|