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

Commit

Permalink
Amount from config needs to call parseInt
Browse files Browse the repository at this point in the history
Properly fixes #11719

Also fixes a `ledgerClient is not defined` error I saw when testing (fix is to call clientPrep). This only impacted folks that quit and needed to reload from file.

Auditors: @bbondy, @evq
  • Loading branch information
bsclifton committed Nov 1, 2017
1 parent 67e9b00 commit 8377614
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2037,7 +2037,8 @@ const initialize = (state, paymentsEnabled) => {
}

const getContributionAmount = () => {
const amount = getSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT)
let amount = parseInt(getSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT), 10)

// if amount is 5, 10, 15, or 20... the amount wasn't updated when changing
// from BTC to BAT (see https://github.com/brave/browser-laptop/issues/11719)
let updatedAmount
Expand All @@ -2047,7 +2048,11 @@ const getContributionAmount = () => {
case 15: updatedAmount = 75; break
case 20: updatedAmount = 100; break
}

if (updatedAmount) {
if (clientOptions.verboseP) {
console.log('\nmigrating contribution amount of ' + amount + ' from USD to BAT (new amount is ' + updatedAmount + ')')
}
appActions.changeSetting(settings.PAYMENTS_CONTRIBUTION_AMOUNT, updatedAmount)
return updatedAmount
}
Expand Down Expand Up @@ -2387,6 +2392,7 @@ const transitionWalletToBat = () => {
if (!newClient) {
const fs = require('fs')
try {
clientprep()
fs.accessSync(pathName(newClientPath), fs.FF_OK)
fs.readFile(pathName(newClientPath), (error, data) => {
if (error) {
Expand Down

0 comments on commit 8377614

Please sign in to comment.