Skip to content

Commit

Permalink
Migration v5 (#984)
Browse files Browse the repository at this point in the history
* version bump

* fix naming

* create migration v5

* delete old migration flag
  • Loading branch information
brunobar79 committed Aug 6, 2020
1 parent 1a1bd52 commit 9fcc934
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
8 changes: 4 additions & 4 deletions ios/Rainbow.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.2.26;
MARKETING_VERSION = 1.2.27;
OTHER_CFLAGS = (
"$(inherited)",
"-DFB_SONARKIT_ENABLED=1",
Expand Down Expand Up @@ -723,7 +723,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.2.26;
MARKETING_VERSION = 1.2.27;
OTHER_CFLAGS = (
"$(inherited)",
"-DFB_SONARKIT_ENABLED=1",
Expand Down Expand Up @@ -818,7 +818,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.2.26;
MARKETING_VERSION = 1.2.27;
OTHER_CFLAGS = (
"$(inherited)",
"-DFB_SONARKIT_ENABLED=1",
Expand Down Expand Up @@ -914,7 +914,7 @@
"$(PROJECT_DIR)",
);
LLVM_LTO = YES;
MARKETING_VERSION = 1.2.26;
MARKETING_VERSION = 1.2.27;
OTHER_CFLAGS = (
"$(inherited)",
"-DFB_SONARKIT_ENABLED=1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Rainbow",
"version": "1.2.26-1",
"version": "1.2.27-1",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
22 changes: 17 additions & 5 deletions src/model/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,27 @@ export default async function runMigrations() {

/*
*************** Migration v4 ******************
* Not in use
*/

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

migrations.push(v4);

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

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

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

migrations.push(v4);
migrations.push(v5);

logger.sentry(
`Migrations: ready to run migrations starting on number ${currentVersion}`
Expand Down
1 change: 0 additions & 1 deletion src/model/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const addressKey = 'rainbowAddressKey';
export const selectedWalletKey = 'rainbowSelectedWalletKey';
export const allWalletsKey = 'rainbowAllWalletsKey';
export const oldSeedPhraseMigratedKey = 'rainbowOldSeedPhraseMigratedKey';
export const seedPhraseMigratedKey = 'rainbowSeedPhraseMigratedKey'; // NOT USED ANYMORE!

const privateKeyVersion = 1.0;
const seedPhraseVersion = 1.0;
Expand Down
28 changes: 8 additions & 20 deletions src/redux/wallets.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
saveAddress,
saveAllWallets,
seedPhraseKey,
seedPhraseMigratedKey,
setSelectedWallet,
} from '../model/wallet';
import { settingsUpdateAccountAddress } from '../redux/settings';
Expand Down Expand Up @@ -199,32 +198,21 @@ export const checkKeychainIntegrity = () => async (dispatch, getState) => {
);
}

const hasMigratedFlag = await hasKey(seedPhraseMigratedKey);
if (hasMigratedFlag) {
logger.sentry(
'[KeychainIntegrityCheck]: previous migrated flag is OK [NO LONGER RELEVANT]'
);
} else {
logger.sentry(
`[KeychainIntegrityCheck]: migrated flag is present: ${hasMigratedFlag} [NO LONGER RELEVANT]`
);
}

const hasOldSeedPhraseMigratedKey = await hasKey(oldSeedPhraseMigratedKey);
if (hasOldSeedPhraseMigratedKey) {
const hasOldSeedPhraseMigratedFlag = await hasKey(oldSeedPhraseMigratedKey);
if (hasOldSeedPhraseMigratedFlag) {
logger.sentry('[KeychainIntegrityCheck]: migrated flag is OK');
} else {
logger.sentry(
`[KeychainIntegrityCheck]: migrated flag is present: ${hasOldSeedPhraseMigratedKey}`
`[KeychainIntegrityCheck]: migrated flag is present: ${hasOldSeedPhraseMigratedFlag}`
);
}

const hasOldSeedphraseKey = await hasKey(seedPhraseKey);
if (hasOldSeedphraseKey) {
const hasOldSeedphrase = await hasKey(seedPhraseKey);
if (hasOldSeedphrase) {
logger.sentry('[KeychainIntegrityCheck]: old seed is still present!');
} else {
logger.sentry(
`[KeychainIntegrityCheck]: old seed is present: ${hasOldSeedphraseKey}`
`[KeychainIntegrityCheck]: old seed is present: ${hasOldSeedphrase}`
);
}

Expand Down Expand Up @@ -281,8 +269,8 @@ export const checkKeychainIntegrity = () => async (dispatch, getState) => {
// - and the old seedphrase is still there
if (
!wallet.imported &&
!oldSeedPhraseMigratedKey &&
hasOldSeedphraseKey
!hasOldSeedPhraseMigratedFlag &&
hasOldSeedphrase
) {
healthyWallet = true;
}
Expand Down

0 comments on commit 9fcc934

Please sign in to comment.