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

Addfunds #5797

Merged
merged 3 commits into from
Nov 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -987,7 +988,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 @@ -307,13 +307,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 @@ -338,7 +350,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 @@ -366,7 +380,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 @@ -415,7 +429,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