Skip to content

Commit

Permalink
feat: always use extension storage
Browse files Browse the repository at this point in the history
ignore posthog feature flag
  • Loading branch information
mkazlauskas committed Jan 24, 2025
1 parent 330393e commit fbb8e6b
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions apps/browser-extension-wallet/src/lib/scripts/background/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,18 @@ export const extensionStorageStoresFactory: StoresFactory = {
})
};

// Used for migrations to get feature flags, which are enabled per chainId
// This is coupled with WalletManager implementation (getWalletStoreId function)
const getNetworkMagic = (storeName: string) => Number.parseInt(storeName.split('-')[1]) as Cardano.NetworkMagic;

const storesFactory: StoresFactory = {
async create(props) {
const featureFlags = await getFeatureFlags(getNetworkMagic(props.name));
if (isExperimentEnabled(featureFlags, ExperimentName.EXTENSION_STORAGE)) {
const extensionStores = await extensionStorageStoresFactory.create(props);
if (await shouldAttemptWalletStoresMigration(extensionStores)) {
const pouchdbStores = await pouchdbStoresFactory.create(props);
if (await migrateWalletStores(pouchdbStores, extensionStores, logger)) {
// TODO: safe to destroy pouchdb stores on successful migration
// once EXTENSION_STORAGE experiment runs in production for some time
// and we are sure that it's working well
}
const extensionStores = await extensionStorageStoresFactory.create(props);
if (await shouldAttemptWalletStoresMigration(extensionStores)) {
const pouchdbStores = await pouchdbStoresFactory.create(props);
if (await migrateWalletStores(pouchdbStores, extensionStores, logger)) {
// TODO: safe to destroy pouchdb stores on successful migration
// once EXTENSION_STORAGE experiment runs in production for some time
// and we are sure that it's working well
}
return extensionStores;
}
return pouchdbStoresFactory.create(props);
return extensionStores;
}
};

Expand Down

0 comments on commit fbb8e6b

Please sign in to comment.