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 #12810 from NejcZdovc/hotfix/#12727-legacy
Browse files Browse the repository at this point in the history
Removes legacy code from BTC times
  • Loading branch information
bsclifton authored Jan 23, 2018
2 parents 4e6cbdd + 320b65a commit 6dece0e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
19 changes: 1 addition & 18 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1931,24 +1931,7 @@ const initialize = (state, paymentsEnabled) => {
}

const getContributionAmount = (state) => {
let amount = ledgerState.getContributionAmount(state)

// if amount is 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
switch (amount) {
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
}
return amount
return ledgerState.getContributionAmount(state)
}

const onInitRead = (state, parsedData) => {
Expand Down
34 changes: 0 additions & 34 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,40 +280,6 @@ describe('ledger api unit tests', function () {
ledgerApi.onInitRead(defaultAppState, parsedLedgerData)
assert(setPaymentInfoSpy.withArgs(10).calledOnce)
})

describe('when contribution amount is still set to the USD amount (before BAT Mercury)', function () {
after(function () {
contributionAmount = 10
})
describe('when set to 15 USD', function () {
before(function () {
setPaymentInfoSpy.reset()
onChangeSettingSpy.reset()
contributionAmount = 15
ledgerApi.onInitRead(defaultAppState, parsedLedgerData)
})
it('converts to 75 BAT', function () {
assert(setPaymentInfoSpy.withArgs(75).calledOnce)
})
it('updates the setting', function () {
assert(onChangeSettingSpy.withArgs(settings.PAYMENTS_CONTRIBUTION_AMOUNT, 75).calledOnce)
})
})
describe('when set to 20 USD', function () {
before(function () {
setPaymentInfoSpy.reset()
onChangeSettingSpy.reset()
contributionAmount = 20
ledgerApi.onInitRead(defaultAppState, parsedLedgerData)
})
it('converts to 100 BAT', function () {
assert(setPaymentInfoSpy.withArgs(100).calledOnce)
})
it('updates the setting', function () {
assert(onChangeSettingSpy.withArgs(settings.PAYMENTS_CONTRIBUTION_AMOUNT, 100).calledOnce)
})
})
})
})

describe('checkBtcBatMigrated', function () {
Expand Down

0 comments on commit 6dece0e

Please sign in to comment.