From 01a10e777291b4a851c5f7fda1ada9384c346ce7 Mon Sep 17 00:00:00 2001 From: miaomiao Date: Tue, 5 May 2026 21:39:23 +0800 Subject: [PATCH 1/2] fix: dapp connect --- app/database/DappDatabase.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/database/DappDatabase.ts b/app/database/DappDatabase.ts index 7f0bbabe..5b4c637c 100644 --- a/app/database/DappDatabase.ts +++ b/app/database/DappDatabase.ts @@ -7,11 +7,6 @@ import { import { CoinType } from "core/types"; export class DappDatabase extends Dexie { - /** - * @deprecated - */ - aleo_history: Dexie.Table; - dapp_history: Dexie.Table; request: Dexie.Table; @@ -31,16 +26,21 @@ export class DappDatabase extends Dexie { .stores({ dapp_history: "++id, [address+coinType+network], site.origin", }) - .upgrade(async (tx) => - // TODO check this - this.aleo_history.each( - async (aleoHistory) => - this.dapp_history?.add({ - ...aleoHistory, - coinType: CoinType.ALEO, - }), - ), - ); + .upgrade(async (tx) => { + const aleoHistories = (await tx + .table("aleo_history") + .toArray()) as AleoConnectHistory[]; + if (!aleoHistories.length) { + return; + } + + await tx.table("dapp_history").bulkAdd( + aleoHistories.map((aleoHistory) => ({ + ...aleoHistory, + coinType: CoinType.ALEO, + })), + ); + }); this.version(4).stores({ aleo_history: null, From 4b719494a19854404eaab81101a6f12fe40302d5 Mon Sep 17 00:00:00 2001 From: miaomiao Date: Wed, 6 May 2026 11:12:13 +0800 Subject: [PATCH 2/2] fix: add a new migration to backfill missing coinType --- app/database/DappDatabase.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/database/DappDatabase.ts b/app/database/DappDatabase.ts index 5b4c637c..32f2b1a0 100644 --- a/app/database/DappDatabase.ts +++ b/app/database/DappDatabase.ts @@ -47,6 +47,20 @@ export class DappDatabase extends Dexie { aleo_connect_history: null, }); + this.version(5).upgrade(async (tx) => { + await tx + .table("dapp_history") + .filter((history: Partial) => !history.coinType) + .modify((history: Partial) => { + history.coinType = history.address?.startsWith("aleo1") + ? CoinType.ALEO + : CoinType.ETH; + if (history.coinType === CoinType.ETH && !history.network) { + history.network = ""; + } + }); + }); + this.dapp_history = this.table("dapp_history"); this.request = this.table("request"); }