-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add database versioning (#1489)
- Closes #1490
- Loading branch information
1 parent
48d4df4
commit 9f4334c
Showing
3 changed files
with
51 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@fuel-wallet/connections": patch | ||
"@fuel-wallet/types": patch | ||
"fuels-wallet": patch | ||
"@fuels/playwright-utils": patch | ||
--- | ||
|
||
feat: add db versioning |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { createUUID } from '@fuel-wallet/connections'; | ||
import type Dexie from 'dexie'; | ||
import { CHAIN_IDS, DEVNET_NETWORK_URL, TESTNET_NETWORK_URL } from 'fuels'; | ||
|
||
export const applyDbVersioning = (db: Dexie) => { | ||
db.version(19) | ||
.stores({ | ||
vaults: 'key', | ||
accounts: '&address, &name', | ||
networks: '&id, &url, &name', | ||
connections: 'origin', | ||
transactions: '&id', | ||
assets: '&assetId, &name, &symbol', | ||
abis: '&contractId', | ||
errors: '&id', | ||
}) | ||
.upgrade(async (tx) => { | ||
const networks = tx.table('networks'); | ||
|
||
// Clean networks | ||
await networks.clear(); | ||
|
||
// Insert testnet network | ||
await networks.add({ | ||
chainId: CHAIN_IDS.fuel.testnet, | ||
name: 'Fuel Sepolia Testnet', | ||
url: TESTNET_NETWORK_URL, | ||
isSelected: true, | ||
id: createUUID(), | ||
}); | ||
|
||
// Insert devnet network | ||
await networks.add({ | ||
chainId: CHAIN_IDS.fuel.devnet, | ||
name: 'Fuel Ignition Sepolia Devnet', | ||
url: DEVNET_NETWORK_URL, | ||
isSelected: false, | ||
id: createUUID(), | ||
}); | ||
}); | ||
}; |