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

Removes legacy code from BTC times #12810

Merged
merged 1 commit into from
Jan 23, 2018
Merged
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
19 changes: 1 addition & 18 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
@@ -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) => {
34 changes: 0 additions & 34 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
@@ -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 () {