Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: errors in balance pool #1788

Merged
merged 4 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading