Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: make upgrade database more simple #1611

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-queens-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"fuels-wallet": minor
---

fix: update networks more simply
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

tests-e2e:
name: E2E Tests
timeout-minutes: 15
timeout-minutes: 20
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion packages/app/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ VITE_FUEL_PROVIDER_URL=https://testnet.fuel.network/v1/graphql
VITE_FUEL_FAUCET_URL=https://faucet-testnet.fuel.network/
VITE_EXPLORER_URL=https://app.fuel.network/
VITE_MNEMONIC_WORDS=12
VITE_AUTO_LOCK_IN_MINUTES=60
VITE_AUTO_LOCK_IN_MINUTES=2880
VITE_SENTRY_DSN=https://f9a5b923067f4f789fb40ed7eccd6486@o4505280621707264.ingest.sentry.io/4505280648577024
46 changes: 14 additions & 32 deletions packages/app/src/systems/Core/utils/databaseVersioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,39 +200,21 @@ export const applyDbVersioning = (db: Dexie) => {
})
.upgrade(async (tx) => {
const networks = tx.table('networks');
// *
// Drop all networks
// *
await networks.clear();
// *
// Add default networks
// *
for (const [index, network] of DEFAULT_NETWORKS.entries()) {
if (network.hidden) continue;

const network = await networks
.where('chainId')
.equals(CHAIN_IDS.fuel.mainnet)
.or('name')
.equals('Ignition')
.first();

// De-select all networks
await networks.each(async (_, { primaryKey }) => {
await networks.update(primaryKey, { isSelected: false });
});

if (network) {
await networks.update(network.id, { isSelected: true });
return;
}

// Add mainnet network
const networkToAddIndex = DEFAULT_NETWORKS.findIndex(
(network) =>
network.chainId === CHAIN_IDS.fuel.mainnet ||
network.name === 'Ignition'
);

if (networkToAddIndex <= -1) {
return;
await networks.add({
// Ensure we add to database in the same order as the DEFAULT_NETWORKS
id: index.toString(),
...network,
});
}

await networks.add({
id: networkToAddIndex.toString(),
...DEFAULT_NETWORKS[networkToAddIndex],
isSelected: true,
});
});
};
Loading