Skip to content

Commit

Permalink
fix: errors in balance pool (#1788)
Browse files Browse the repository at this point in the history
* fix: unawaited promise in chaindata provider

* fix: null check in balance pool

* fix: unawaited promise

* chore: add async await back to wrapObservableWithGetter

---------

Co-authored-by: alecdwm <2741569+alecdwm@users.noreply.github.com>
  • Loading branch information
0xKheops and alecdwm authored Jan 22, 2025
1 parent d4ebb87 commit d20764a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-penguins-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@talismn/chaindata-provider": patch
---

fix: unawaited promise
7 changes: 5 additions & 2 deletions packages/chaindata-provider/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ export const wrapObservableWithGetter = async <O extends Observable<any>>(
return await withErrorReason(errorReason, () => firstValueFrom(observable))
}

export const withErrorReason = <T>(reason: string, task: () => T): T => {
export const withErrorReason = async <T>(
reason: string,
task: () => Promise<T> | T,
): Promise<T> => {
try {
return task()
return await task()
} catch (cause) {
throw new Error(reason, { cause })
}
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-core/src/domains/balances/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const getActiveStuff = <T extends { isTestnet?: boolean }, A extends Record<stri
return combineLatest([dataObservable, activeStoreObservable, settingsStore.observable]).pipe(
map(([data, active, { useTestnets }]) => {
return data
.filter((item) => isActiveFn(item, active))
.filter((item) => !!item && isActiveFn(item, active))
.filter((item) => (useTestnets ? true : !item.isTestnet))
}),
)
Expand Down

0 comments on commit d20764a

Please sign in to comment.