From 8f58f891d52d937f6532a67596d80721b9c43b27 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Mon, 24 Feb 2025 10:27:03 -0800 Subject: [PATCH] Fixed issue with no rex balance breaking the staking page --- src/lib/state/client/account.svelte.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/state/client/account.svelte.ts b/src/lib/state/client/account.svelte.ts index 3b7782fe..bb094c40 100644 --- a/src/lib/state/client/account.svelte.ts +++ b/src/lib/state/client/account.svelte.ts @@ -59,7 +59,7 @@ export class AccountState { public delegations = $derived(getDelegations(this.sources)); public resources = $derived.by(() => getResources(this.sources, this.network)); - public rex = $derived(SystemContract.Types.rex_balance.from(this.sources.rexbal)); + public rex = $derived.by(() => getRex(this.sources)); public permissions = $derived(API.v1.AccountObject.from(this.sources.get_account).permissions); public proposals = $derived.by(() => this.sources.proposals); public refundRequest = $derived.by(() => this.sources.refund_request); @@ -150,6 +150,13 @@ export class AccountState { } } +export function getRex(sources: AccountDataSources) { + if (!sources.rexbal) { + return defaultAccountDataSources.rexbal; + } + return SystemContract.Types.rex_balance.from(sources.rexbal); +} + export function getResources( sources: AccountDataSources, network?: NetworkState