1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-24 16:08:11 +00:00

Merge pull request #137 from trezor/feature/localstorage-version

add and verify local storage version
This commit is contained in:
Vladimir Volek 2018-10-09 10:22:20 +02:00 committed by GitHub
commit 1113c0d077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,6 +88,8 @@ export function update(event: StorageEvent): AsyncAction {
};
}
const VERSION: string = '1';
export function loadTokensFromJSON(): AsyncAction {
return async (dispatch: Dispatch): Promise<void> => {
if (typeof window.localStorage === 'undefined') return;
@ -100,6 +102,13 @@ export function loadTokensFromJSON(): AsyncAction {
dispatch(update(event));
});
// validate version
const version: ?string = get('version');
if (version !== VERSION) {
window.localStorage.clear();
dispatch(save('version', VERSION));
}
// load tokens
const tokens = await config.coins.reduce(async (promise: Promise<TokensCollection>, coin: Coin): Promise<TokensCollection> => {
const collection: TokensCollection = await promise;