From 0aec49b25b8a2f39b658f1494d53ad73571ae632 Mon Sep 17 00:00:00 2001 From: Danny Morabito Date: Wed, 9 Jul 2025 12:54:15 +0200 Subject: [PATCH] fix initailization order --- index.ts | 7 ++++--- tsconfig.json | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 025e043..76bb43d 100644 --- a/index.ts +++ b/index.ts @@ -95,8 +95,6 @@ export default class PortalBtcWallet { private async init() { await initBreez(); - await this.cashuSDK.init(); - await this.maybeMelt(); this.breezSDK = await breezConnect({ mnemonic: this.mnemonic, config: defaultBreezConfig(this.network, this.breezApiKey), @@ -116,11 +114,14 @@ export default class PortalBtcWallet { } }, }); + await this.cashuSDK.init(); await this.redeemCashuQuotes(); + await this.maybeMelt(); } private async refreshBreezBalances() { - const info = await this.breezSDK?.getInfo(); + if (!this.breezSDK) throw new Error("Breez SDK not initialized"); + const info = await this.breezSDK.getInfo(); this.balances.balance = info?.walletInfo.balanceSat ?? 0; this.balances.pendingReceive = info?.walletInfo.pendingReceiveSat ?? 0; this.balances.pendingSend = info?.walletInfo.pendingSendSat ?? 0; diff --git a/tsconfig.json b/tsconfig.json index a36cf40..b595374 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "target": "ESNext", "module": "Preserve", "moduleDetection": "force", - "allowJs": true, + "allowJs": false, "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true,