forked from brave/browser-laptop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds transition for disabled wallets
Resolves brave#11611 Auditors: Test Plan:
- Loading branch information
Showing
5 changed files
with
100 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const assert = require('assert') | ||
|
||
const {makeImmutable, isMap} = require('../../common/state/immutableUtil') | ||
|
||
const validateState = function (state) { | ||
state = makeImmutable(state) | ||
assert.ok(isMap(state), 'state must be an Immutable.Map') | ||
assert.ok(isMap(state.get('migrations')), 'state must contain an Immutable.Map of migrations') | ||
return state | ||
} | ||
|
||
const migrationState = { | ||
setTransitionStatus: (state, value) => { | ||
state = validateState(state) | ||
if (value == null) { | ||
return state | ||
} | ||
|
||
return state.setIn(['migrations', 'btc2BatTransitionPending'], value) | ||
}, | ||
|
||
setConversionTimestamp: (state, value) => { | ||
state = validateState(state) | ||
if (value == null) { | ||
return state | ||
} | ||
|
||
return state.setIn(['migrations', 'btc2BatTimestamp'], value) | ||
}, | ||
|
||
setNotifiedTimestamp: (state, value) => { | ||
state = validateState(state) | ||
if (value == null) { | ||
return state | ||
} | ||
|
||
return state.setIn(['migrations', 'btc2BatNotifiedTimestamp'], value) | ||
}, | ||
|
||
isNewInstall: (state) => { | ||
state = validateState(state) | ||
return state.get('firstRunTimestamp') === state.getIn(['migrations', 'batMercuryTimestamp']) | ||
}, | ||
|
||
hasUpgradedWallet: (state) => { | ||
state = validateState(state) | ||
return state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btc2BatTimestamp']) | ||
}, | ||
|
||
hasBeenNotified: (state) => { | ||
state = validateState(state) | ||
return state.getIn(['migrations', 'batMercuryTimestamp']) !== state.getIn(['migrations', 'btc2BatNotifiedTimestamp']) | ||
} | ||
} | ||
|
||
module.exports = migrationState |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters