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

Commit

Permalink
Rename the flags used for BAT Mercury transition as some folks have a…
Browse files Browse the repository at this point in the history
…lready installed the beta and the full process needs to run

Auditors: @evq, @NejcZdovc, @bbondy
  • Loading branch information
bsclifton committed Oct 7, 2017
1 parent 75a442c commit 1ce0968
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const notifications = {

// One time conversion of wallet
const isNewInstall = state.get('firstRunTimestamp') === state.getIn(['migrations', 'batMercuryTimestamp'])
const hasUpgradedWallet = state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btcToBatTimestamp'])
const hasUpgradedWallet = state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btc2BatTimestamp'])
if (!isNewInstall && !hasUpgradedWallet) {
module.exports.transitionWalletToBat(state)
}
Expand All @@ -178,7 +178,7 @@ const notifications = {
// - wallet has been transitioned
// - notification has not already been shown yet
// (see https://github.com/brave/browser-laptop/issues/11021)
const hasBeenNotified = state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btcToBatNotifiedTimestamp'])
const hasBeenNotified = state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btc2BatNotifiedTimestamp'])
if (!isNewInstall && hasUpgradedWallet && !hasBeenNotified) {
notifications.showBraveWalletUpdated()
}
Expand Down
4 changes: 2 additions & 2 deletions app/browser/reducers/ledgerReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,12 @@ const ledgerReducer = (state, action, immutableAction) => {
}
case appConstants.APP_ON_BTC_TO_BAT_NOTIFIED:
{
state = state.setIn(['migrations', 'btcToBatNotifiedTimestamp'], new Date().getTime())
state = state.setIn(['migrations', 'btc2BatNotifiedTimestamp'], new Date().getTime())
break
}
case appConstants.APP_ON_BTC_TO_BAT_TRANSITIONED:
{
state = state.setIn(['migrations', 'btcToBatTimestamp'], new Date().getTime())
state = state.setIn(['migrations', 'btc2BatTimestamp'], new Date().getTime())
break
}
case appConstants.APP_ON_LEDGER_QR_GENERATED:
Expand Down
4 changes: 2 additions & 2 deletions app/sessionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,8 @@ module.exports.defaultAppState = () => {
},
migrations: {
batMercuryTimestamp: now,
btcToBatTimestamp: now,
btcToBatNotifiedTimestamp: now
btc2BatTimestamp: now,
btc2BatNotifiedTimestamp: now
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ AppStore
},
migrations: {
batMercuryTimestamp: integer, // when session is upgraded (and this new schema added)
btcToBatTimestamp: integer, // when call was made to backend to convert BTC => BAT
btcToBatNotifiedTimestamp: integer, // when user was shown "wallet upgraded" notification
btc2BatTimestamp: integer, // when call was made to backend to convert BTC => BAT
btc2BatNotifiedTimestamp: integer, // when user was shown "wallet upgraded" notification
},
menu: {
template: object // used on Windows and by our tests: template object with Menubar control
Expand Down
36 changes: 18 additions & 18 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ describe('ledger api unit tests', function () {
firstRunTimestamp: 12345,
migrations: {
batMercuryTimestamp: 12345,
btcToBatTimestamp: 12345,
btcToBatNotifiedTimestamp: 12345
btc2BatTimestamp: 12345,
btc2BatNotifiedTimestamp: 12345
}
}))
})
Expand All @@ -236,8 +236,8 @@ describe('ledger api unit tests', function () {
it('does not notify the user', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 54321)
.setIn(['migrations', 'btcToBatNotifiedTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 54321)
.setIn(['migrations', 'btc2BatNotifiedTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(showBraveWalletUpdatedSpy.notCalled)
})
Expand All @@ -251,8 +251,8 @@ describe('ledger api unit tests', function () {
it('does not notify the user', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 54321)
.setIn(['migrations', 'btcToBatNotifiedTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 54321)
.setIn(['migrations', 'btc2BatNotifiedTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(showBraveWalletUpdatedSpy.notCalled)
})
Expand All @@ -267,8 +267,8 @@ describe('ledger api unit tests', function () {
const targetSession = ledgerStateWithBalance
.setIn(['ledger', 'info', 'balance'], 0)
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 54321)
.setIn(['migrations', 'btcToBatNotifiedTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 54321)
.setIn(['migrations', 'btc2BatNotifiedTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(showBraveWalletUpdatedSpy.notCalled)
})
Expand All @@ -293,8 +293,8 @@ describe('ledger api unit tests', function () {
it('does not notify the user', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 32145)
.setIn(['migrations', 'btcToBatNotifiedTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 32145)
.setIn(['migrations', 'btc2BatNotifiedTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(showBraveWalletUpdatedSpy.notCalled)
})
Expand All @@ -308,8 +308,8 @@ describe('ledger api unit tests', function () {
it('does not notify the user', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 54321)
.setIn(['migrations', 'btcToBatNotifiedTimestamp'], 54321)
.setIn(['migrations', 'btc2BatTimestamp'], 54321)
.setIn(['migrations', 'btc2BatNotifiedTimestamp'], 54321)
ledgerApi.notifications.onLaunch(targetSession)
assert(showBraveWalletUpdatedSpy.notCalled)
})
Expand All @@ -323,8 +323,8 @@ describe('ledger api unit tests', function () {
it('notifies the user', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 54321)
.setIn(['migrations', 'btcToBatNotifiedTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 54321)
.setIn(['migrations', 'btc2BatNotifiedTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(showBraveWalletUpdatedSpy.calledOnce)
})
Expand All @@ -340,7 +340,7 @@ describe('ledger api unit tests', function () {
it('calls ledger.transitionWalletToBat', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(transitionWalletToBatSpy.calledOnce)
})
Expand All @@ -366,7 +366,7 @@ describe('ledger api unit tests', function () {
const ledgerStateWithoutBalance = ledgerStateWithBalance
.setIn(['ledger', 'info', 'balance'], 0)
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 32145)
ledgerApi.notifications.onLaunch(ledgerStateWithoutBalance)
assert(transitionWalletToBatSpy.calledOnce)
})
Expand All @@ -391,7 +391,7 @@ describe('ledger api unit tests', function () {
it('does not call ledger.transitionWalletToBat', function () {
const ledgerStateSeenNotification = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 54321)
.setIn(['migrations', 'btc2BatTimestamp'], 54321)
ledgerApi.notifications.onLaunch(ledgerStateSeenNotification)
assert(transitionWalletToBatSpy.notCalled)
})
Expand All @@ -405,7 +405,7 @@ describe('ledger api unit tests', function () {
it('calls ledger.transitionWalletToBat', function () {
const targetSession = ledgerStateWithBalance
.setIn(['migrations', 'batMercuryTimestamp'], 32145)
.setIn(['migrations', 'btcToBatTimestamp'], 32145)
.setIn(['migrations', 'btc2BatTimestamp'], 32145)
ledgerApi.notifications.onLaunch(targetSession)
assert(transitionWalletToBatSpy.calledOnce)
})
Expand Down
4 changes: 2 additions & 2 deletions test/unit/app/browser/reducers/ledgerReducerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe('ledgerReducer unit tests', function () {
})
it('sets the notification timestamp', function () {
assert.notDeepEqual(returnedState, appState)
assert(returnedState.getIn(['migrations', 'btcToBatNotifiedTimestamp']))
assert(returnedState.getIn(['migrations', 'btc2BatNotifiedTimestamp']))
})
})

Expand All @@ -521,7 +521,7 @@ describe('ledgerReducer unit tests', function () {
})
it('sets the timestamp', function () {
assert.notDeepEqual(returnedState, appState)
assert(returnedState.getIn(['migrations', 'btcToBatTimestamp']))
assert(returnedState.getIn(['migrations', 'btc2BatTimestamp']))
})
})
})

0 comments on commit 1ce0968

Please sign in to comment.