From cb99cb40865a1ba71674b0eb82e2e5018a4f39da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bego=C3=B1a=20Alvarez?= Date: Mon, 22 Jan 2024 18:25:44 +0100 Subject: [PATCH] feat: replace chronicle balance response sigLockedBalance with availableBalance --- .../api/stardust/chronicle/IAddressBalanceResponse.ts | 2 +- client/src/app/routes/stardust/AddressPage.tsx | 4 ++-- client/src/app/routes/stardust/AddressState.ts | 10 +++++----- client/src/helpers/hooks/useAddressBalance.ts | 8 ++++---- .../api/stardust/address/IAddressBalanceResponse.ts | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/api/src/models/api/stardust/chronicle/IAddressBalanceResponse.ts b/api/src/models/api/stardust/chronicle/IAddressBalanceResponse.ts index 92fa362e1..4e65c9c7b 100644 --- a/api/src/models/api/stardust/chronicle/IAddressBalanceResponse.ts +++ b/api/src/models/api/stardust/chronicle/IAddressBalanceResponse.ts @@ -9,7 +9,7 @@ export interface IAddressBalanceResponse extends IResponse { /** * The balance of trivialy unlockable outputs with address unlock condition. */ - sigLockedBalance?: number; + availableBalance?: number; /** * The ledger index at which this balance data was valid. diff --git a/client/src/app/routes/stardust/AddressPage.tsx b/client/src/app/routes/stardust/AddressPage.tsx index fee122518..8972379d8 100644 --- a/client/src/app/routes/stardust/AddressPage.tsx +++ b/client/src/app/routes/stardust/AddressPage.tsx @@ -23,7 +23,7 @@ const AddressPage: React.FC> = ({ const { bech32AddressDetails, balance, - sigLockedBalance, + availableBalance, storageRentBalance, isBasicOutputsLoading, isAliasOutputsLoading, @@ -87,7 +87,7 @@ const AddressPage: React.FC> = ({ {balance !== null && ( )} diff --git a/client/src/app/routes/stardust/AddressState.ts b/client/src/app/routes/stardust/AddressState.ts index bd414d5eb..19d7ec90b 100644 --- a/client/src/app/routes/stardust/AddressState.ts +++ b/client/src/app/routes/stardust/AddressState.ts @@ -37,7 +37,7 @@ import { IDIDResolverResponse } from "~/models/api/IDIDResolverResponse"; export interface IAddressState { bech32AddressDetails: IBech32AddressDetails | null; balance: number | null; - sigLockedBalance: number | null; + availableBalance: number | null; storageRentBalance: number | null; addressOutputs: OutputResponse[] | null; addressBasicOutputs: OutputResponse[] | null; @@ -69,7 +69,7 @@ export interface IAddressState { const initialState = { bech32AddressDetails: null, balance: null, - sigLockedBalance: null, + availableBalance: null, storageRentBalance: null, addressOutputs: null, addressBasicOutputs: null, @@ -127,7 +127,7 @@ export const useAddressPageState = (): [IAddressState, React.Dispatch(`api-client-${STARDUST}`)); const [balance, setBalance] = useState(null); - const [sigLockedBalance, setSigLockedBalance] = useState(null); + const [availableBalance, setAvailableBalance] = useState(null); const [isLoading, setIsLoading] = useState(true); useEffect(() => { @@ -26,14 +26,14 @@ export function useAddressBalance(network: string, address: string | null): [num if (response?.totalBalance !== undefined && isMounted) { setBalance(response.totalBalance); - setSigLockedBalance(response.sigLockedBalance ?? null); + setAvailableBalance(response.availableBalance ?? null); } else if (isMounted) { // Fallback balance from iotajs (node) const addressDetailsWithBalance = await apiClient.addressBalance({ network, address }); if (addressDetailsWithBalance && isMounted) { setBalance(Number(addressDetailsWithBalance.balance)); - setSigLockedBalance(null); + setAvailableBalance(null); } } })(); @@ -42,5 +42,5 @@ export function useAddressBalance(network: string, address: string | null): [num } }, [network, address]); - return [balance, sigLockedBalance, isLoading]; + return [balance, availableBalance, isLoading]; } diff --git a/client/src/models/api/stardust/address/IAddressBalanceResponse.ts b/client/src/models/api/stardust/address/IAddressBalanceResponse.ts index 92fa362e1..4e65c9c7b 100644 --- a/client/src/models/api/stardust/address/IAddressBalanceResponse.ts +++ b/client/src/models/api/stardust/address/IAddressBalanceResponse.ts @@ -9,7 +9,7 @@ export interface IAddressBalanceResponse extends IResponse { /** * The balance of trivialy unlockable outputs with address unlock condition. */ - sigLockedBalance?: number; + availableBalance?: number; /** * The ledger index at which this balance data was valid.