Skip to content

Commit

Permalink
fix xstar responce format (#2392)
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev authored Nov 13, 2024
1 parent ba1a213 commit db405c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/xStarScore/useFetchXStarScore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function useFetchXStarScore({ hash }: Params) {
pathParams: { hash },
queryOptions: {
select: (response) => {
const parsedResponse = v.safeParse(v.object({ data: v.string() }), response);
const parsedResponse = v.safeParse(v.object({ data: v.object({ level: v.nullable(v.string()) }) }), response);

if (!parsedResponse.success) {
throw Error(ERROR_NAME);
Expand All @@ -27,7 +27,7 @@ export default function useFetchXStarScore({ hash }: Params) {
},
enabled: Boolean(hash) && config.features.xStarScore.isEnabled,
placeholderData: {
data: 'Base' as const,
data: { level: 'Base' },
},
retry: 0,
},
Expand Down
4 changes: 3 additions & 1 deletion types/api/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,7 @@ export type AddressEpochRewardsItem = {
};

export type AddressXStarResponse = {
data: string | null;
data: {
level: string | null;
};
};
4 changes: 2 additions & 2 deletions ui/pages/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ const AddressPageContent = () => {
undefined,
...formatUserTags(addressQuery.data),
...(addressMetadataQuery.data?.addresses?.[hash.toLowerCase()]?.tags.filter(tag => tag.tagType !== 'note') || []),
!addressQuery.data?.is_contract && xScoreFeature.isEnabled && xStarQuery.data?.data ?
!addressQuery.data?.is_contract && xScoreFeature.isEnabled && xStarQuery.data?.data.level ?
{
slug: 'xstar',
name: `XHS ${ xStarQuery.data.data } level`,
name: `XHS ${ xStarQuery.data.data.level } level`,
tagType: 'custom' as const,
ordinal: 12,
meta: {
Expand Down

0 comments on commit db405c1

Please sign in to comment.