Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5797 from brave/addfunds
Browse files Browse the repository at this point in the history
Addfunds
  • Loading branch information
mrose17 authored Nov 22, 2016
2 parents 5d86ccd + d89d29c commit 8b6dada
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
15 changes: 14 additions & 1 deletion app/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ledgerClient = require('ledger-client')
const ledgerGeoIP = require('ledger-geoip')
const ledgerPublisher = require('ledger-publisher')
const qr = require('qr-image')
const querystring = require('querystring')
const random = require('random-lib')
const tldjs = require('tldjs')
const underscore = require('underscore')
Expand Down Expand Up @@ -994,7 +995,19 @@ var updateLedgerInfo = () => {
underscore.extend(ledgerInfo,
underscore.pick(info, [ 'address', 'passphrase', 'balance', 'unconfirmed', 'satoshis', 'btc', 'amount',
'currency' ]))
if ((!info.buyURLExpires) || (info.buyURLExpires > now)) ledgerInfo.buyURL = info.buyURL
if ((!info.buyURLExpires) || (info.buyURLExpires > now)) {
ledgerInfo.buyURL = info.buyURL
ledgerInfo.buyMaximumUSD = 6
}
if (typeof process.env.ADDFUNDS_URL !== 'undefined') {
ledgerInfo.buyURLFrame = true
ledgerInfo.buyURL = process.env.ADDFUNDS_URL + '?' +
querystring.stringify({ currency: ledgerInfo.currency,
amount: getSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT),
address: ledgerInfo.address })
ledgerInfo.buyMaximumUSD = false
}

underscore.extend(ledgerInfo, ledgerInfo._internal.cache || {})
}

Expand Down
24 changes: 21 additions & 3 deletions js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,25 @@ class BitcoinDashboard extends ImmutableComponent {
constructor () {
super()
this.buyCompleted = false
this.openBuyURLTab = this.openBuyURLTab.bind(this)
}
openBuyURLTab () {
// close parent dialog
this.props.hideParentOverlay()
// open the new buyURL frame
aboutActions.newFrame({ location: this.ledgerData.get('buyURL') }, true)
}
get ledgerData () {
return this.props.ledgerData
}
get bitcoinOverlayContent () {
return <iframe src={this.ledgerData.get('buyURL')} />
}
get bitcoinPurchaseButton () {
if (!this.ledgerData.get('buyURLFrame')) return <Button l10nId='add' className='primaryButton' onClick={this.props.showOverlay.bind(this)} />
// should also do this.props.hideParentalOverlay
return <Button l10nId='add' className='primaryButton' onClick={this.openBuyURLTab} />
}
get qrcodeOverlayContent () {
return <div>
<img src={this.ledgerData.get('paymentIMG')} title='Brave wallet QR code' />
Expand All @@ -339,7 +351,9 @@ class BitcoinDashboard extends ImmutableComponent {
return getSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT, this.props.settings) || 0
}
get canUseCoinbase () {
return this.currency === 'USD' && this.amount < 6
if (!this.props.ledgerData.get('buyMaximumUSD')) return true

return this.currency === 'USD' && this.amount < this.props.ledgerData.get('buyMaximumUSD')
}
get userInAmerica () {
const countryCode = this.props.ledgerData.get('countryCode')
Expand Down Expand Up @@ -367,7 +381,7 @@ class BitcoinDashboard extends ImmutableComponent {
<div className='settingsListSubTitle' data-l10n-id='moneyAddSubTitle' />
</div>
<div className='settingsPanelDivider'>
<Button l10nId='add' className='primaryButton' onClick={this.props.showOverlay.bind(this)} />
{this.bitcoinPurchaseButton}
<div className='settingsListSubTitle' data-l10n-id='transferTime' />
</div>
</div>
Expand Down Expand Up @@ -416,7 +430,11 @@ class BitcoinDashboard extends ImmutableComponent {
</div>
}
get panelFooter () {
if (coinbaseCountries.indexOf(this.props.ledgerData.get('countryCode')) > -1) {
if (this.ledgerData.get('buyURLFrame')) {
return <div className='panelFooter'>
<Button l10nId='done' className='pull-right whiteButton' onClick={this.props.hideParentOverlay} />
</div>
} else if (coinbaseCountries.indexOf(this.props.ledgerData.get('countryCode')) > -1) {
return <div className='panelFooter'>
<div id='coinbaseLogo' />
<span className='coinbaseMessage' data-l10n-id='coinbaseMessage' />
Expand Down

0 comments on commit 8b6dada

Please sign in to comment.