From 400a09e619c5e9e8f6d9ab534cd91988de601abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ti=E1=BA=BFn=20Nguy=E1=BB=85n=20Kh=E1=BA=AFc?= Date: Fri, 14 Jun 2024 14:39:30 +1200 Subject: [PATCH] fix: accounts observable will never produce value if extension is `undefined` --- packages/core/src/wallets/injected.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/core/src/wallets/injected.ts b/packages/core/src/wallets/injected.ts index bc93581d..47f607f0 100644 --- a/packages/core/src/wallets/injected.ts +++ b/packages/core/src/wallets/injected.ts @@ -53,15 +53,18 @@ export default class InjectedWallet extends Wallet { }; override readonly accounts$ = this.#extension$.pipe( - switchMap((extension) => - extension === undefined - ? [] - : new Observable((subscriber) => { + switchMap( + (extension) => + new Observable((subscriber) => { + if (extension === undefined) { + subscriber.next([]); + } else { subscriber.next(extension.getAccounts()); subscriber.add( extension.subscribe((accounts) => subscriber.next(accounts)), ); - }), + } + }), ), );