Merge pull request #25 from poanetwork/buy-poa-options

(Feature) Buy POA coin options
This commit is contained in:
Franco Victorio 2018-07-23 12:59:41 -03:00 committed by GitHub
commit 91c255ee23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 8 deletions

View File

@ -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
}

View File

@ -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 })
}

View File

@ -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', {