Skip to content

Commit

Permalink
Migration v4 (#983)
Browse files Browse the repository at this point in the history
* fix damaged wallet criteria

* move migration 3 to 4 so it runs again

* fix comment
  • Loading branch information
brunobar79 authored Aug 6, 2020
1 parent 0e2c546 commit 1a1bd52
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/model/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,30 @@ export default async function runMigrations() {
};

migrations.push(v2);

/*
*************** Migration v3 ******************
* Not in use
*/

const v3 = async () => {
logger.sentry('Ignoring migration v3');
return true;
};

migrations.push(v3);

/*
*************** Migration v4 ******************
* This step makes sure there are no wallets marked as damaged
* incorrectly by the keychain integrity checks
*/
const v3 = async () => {
logger.sentry('Start migration v3');
const v4 = async () => {
logger.sentry('Start migration v4');
const { wallets, selected } = store.getState().wallets;

if (!wallets) {
logger.sentry('Complete migration v3 early');
logger.sentry('Complete migration v4 early');
return;
}

Expand Down Expand Up @@ -198,10 +211,10 @@ export default async function runMigrations() {
}
}
}
logger.sentry('Complete migration v3');
logger.sentry('Complete migration v4');
};

migrations.push(v3);
migrations.push(v4);

logger.sentry(
`Migrations: ready to run migrations starting on number ${currentVersion}`
Expand Down
13 changes: 13 additions & 0 deletions src/redux/wallets.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,19 @@ export const checkKeychainIntegrity = () => async (dispatch, getState) => {
}
}

// Handle race condition:
// A wallet is NOT damaged if:
// - it's not imported
// - and hasn't been migrated yet
// - and the old seedphrase is still there
if (
!wallet.imported &&
!oldSeedPhraseMigratedKey &&
hasOldSeedphraseKey
) {
healthyWallet = true;
}

if (!healthyWallet) {
logger.sentry(
'[KeychainIntegrityCheck]: declaring wallet unhealthy...'
Expand Down

0 comments on commit 1a1bd52

Please sign in to comment.