From d830a4ff66be533d1a0e442d0cac196f267b49bd Mon Sep 17 00:00:00 2001 From: viktor Date: Mon, 23 Jul 2018 14:26:43 +0300 Subject: [PATCH] Buy POA coin options --- app/scripts/lib/buy-eth-url.js | 17 ++++++++++++--- app/scripts/metamask-controller.js | 4 ++-- old-ui/app/components/buy-button-subview.js | 24 ++++++++++++++++++--- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/scripts/lib/buy-eth-url.js b/app/scripts/lib/buy-eth-url.js index 697a1a76e..93274f72c 100644 --- a/app/scripts/lib/buy-eth-url.js +++ b/app/scripts/lib/buy-eth-url.js @@ -11,7 +11,7 @@ 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 }) { +function getBuyEthUrl ({ network, amount, address, exchange }) { let url switch (network) { case '1': @@ -34,9 +34,20 @@ function getBuyEthUrl ({ network, amount, address }) { url = 'https://faucet-sokol.herokuapp.com/' break - case '99': - url = 'https://poa.network/' + case '99': { + switch (exchange) { + case 'binance': + url = 'https://www.binance.com/en/trade/POA_ETH' + break + case 'bibox': + url = 'https://www.bibox.com/exchange?coinPair=POA_ETH' + break + case 'cex.plus': + url = 'http://cex.plus/market/poa_eth' + break + } break + } } return url } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 6e8b7c56b..9794fc52b 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1213,10 +1213,10 @@ module.exports = class MetamaskController extends EventEmitter { * @param {string} address - The address to fund. * @param {string} amount - The amount of ether desired, as a base 10 string. */ - buyEth (address, amount) { + buyEth (address, amount, exchange) { if (!amount) amount = '5' const network = this.networkController.getNetworkState() - const url = getBuyEthUrl({ network, address, amount }) + const url = getBuyEthUrl({ network, address, amount, exchange }) if (url) this.platform.openWindow({ url }) } diff --git a/old-ui/app/components/buy-button-subview.js b/old-ui/app/components/buy-button-subview.js index 45f807d32..586216bbf 100644 --- a/old-ui/app/components/buy-button-subview.js +++ b/old-ui/app/components/buy-button-subview.js @@ -150,7 +150,7 @@ BuyButtonSubview.prototype.primarySubview = function () { case '77': case '99': const networkName = getNetworkDisplayName(network) - const label = network === '99' ? 'POA Network' : `${networkName} Test Faucet` + const label = `${networkName} Test Faucet` return ( h('div.flex-column', { style: { @@ -158,12 +158,30 @@ BuyButtonSubview.prototype.primarySubview = function () { margin: '20px 50px', }, }, [ - h('button.text-transform-uppercase', { + network !== '99' ? h('button.text-transform-uppercase', { onClick: () => this.props.dispatch(actions.buyEth({ network })), style: { marginTop: '15px', }, - }, label), + }, label) : null, + network === '99' ? h('button.text-transform-uppercase', { + onClick: () => this.props.dispatch(actions.buyEth({ network, exchange: 'binance' })), + style: { + marginTop: '15px', + }, + }, 'Binance') : null, + network === '99' ? h('button.text-transform-uppercase', { + onClick: () => this.props.dispatch(actions.buyEth({ network, exchange: 'bibox' })), + style: { + marginTop: '15px', + }, + }, 'BiBox') : null, + network === '99' ? h('button.text-transform-uppercase', { + onClick: () => this.props.dispatch(actions.buyEth({ network, exchange: 'cex.plus' })), + style: { + marginTop: '15px', + }, + }, 'CEX Plus') : null, // Kovan only: Dharma loans beta network === '42' ? ( h('button.text-transform-uppercase', {