From 2e585ca634e7720a0d6c17030239597d3368db5d Mon Sep 17 00:00:00 2001 From: Radu Mojic Date: Fri, 10 Jan 2025 14:08:35 +0200 Subject: [PATCH] update account details according to latest api changes --- src/hooks/adapter/adapter.ts | 12 +++--------- src/layouts/AccountLayout/AccountLayout.tsx | 19 +++++++++++-------- src/types/adapter.types.ts | 9 +++++++++ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/hooks/adapter/adapter.ts b/src/hooks/adapter/adapter.ts index 2207e898c..afe2d4b89 100644 --- a/src/hooks/adapter/adapter.ts +++ b/src/hooks/adapter/adapter.ts @@ -1,5 +1,5 @@ import { PAGE_SIZE, TRANSACTIONS_TABLE_FIELDS } from 'appConstants'; -import { AccountRolesTypeEnum } from 'types'; +import { AccountRolesTypeEnum, GetAccountType } from 'types'; import { BaseApiType, GetBlocksType, @@ -224,14 +224,8 @@ export const useAdapter = () => { /* Account */ - getAccount: ({ - address, - ...rest - }: { - address: string; - fields?: string; - withGuardianInfo?: boolean; - }) => provider({ url: `/accounts/${address}`, params: rest }), + getAccount: ({ address, ...rest }: GetAccountType) => + provider({ url: `/accounts/${address}`, params: rest }), getAccounts: ({ page, diff --git a/src/layouts/AccountLayout/AccountLayout.tsx b/src/layouts/AccountLayout/AccountLayout.tsx index d8eb91034..c71fc3731 100644 --- a/src/layouts/AccountLayout/AccountLayout.tsx +++ b/src/layouts/AccountLayout/AccountLayout.tsx @@ -31,15 +31,18 @@ export const AccountLayout = () => { const fetchBalanceAndCount = () => { if (address) { - getAccount({ address, withGuardianInfo: true }).then( - ({ success, data }) => { - if (success && data) { - dispatch(setAccount({ isFetched: true, account: data })); - } - - setIsDataReady(success); + getAccount({ + address, + withGuardianInfo: true, + withAssets: true, + withTxCount: true + }).then(({ success, data }) => { + if (success && data) { + dispatch(setAccount({ isFetched: true, account: data })); } - ); + + setIsDataReady(success); + }); } }; diff --git a/src/types/adapter.types.ts b/src/types/adapter.types.ts index e26e30688..0e72d87cd 100644 --- a/src/types/adapter.types.ts +++ b/src/types/adapter.types.ts @@ -19,6 +19,14 @@ export interface SortableApiType extends BaseApiType { order?: SortOrderEnum; } +export interface GetAccountType { + address: string; + withGuardianInfo?: boolean; + withTxCount?: boolean; + withScrCount?: boolean; + withAssets?: boolean; +} + export interface GetAccountsType extends SortableApiType { ownerAddress?: string; isSmartContract?: boolean; @@ -26,6 +34,7 @@ export interface GetAccountsType extends SortableApiType { withDeployInfo?: boolean; withTxCount?: boolean; withScrCount?: boolean; + withAssets?: boolean; } export interface GetBlocksType extends BaseApiType { shard?: number;