Skip to content

Commit a19dbee

Browse files
committed
fixed issue that asset list show no assets
1 parent e0843c8 commit a19dbee

File tree

3 files changed

+70
-11
lines changed

3 files changed

+70
-11
lines changed

templates/chain-admin/hooks/asset-list/useAssets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const useAssets = (chainName: string) => {
100100
const dollarValue = calcCoinDollarValue(prices, { amount, denom });
101101
return {
102102
symbol,
103-
logoUrl: asset.logoURIs?.png || asset.logoURIs?.svg,
103+
logoUrl: asset?.logoURIs?.png || asset?.logoURIs?.svg,
104104
prettyChainName: getPrettyChainName(denom),
105105
displayAmount: convRawToDispAmount(denom, amount),
106106
dollarValue,

templates/chain-admin/hooks/asset-list/useChainAssetsPrices.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,27 @@ export const useChainAssetsPrices = (chainName: string) => {
4848
return useQuery({
4949
queryKey: ['useChainAssetsPrices', chainName],
5050
queryFn: () => fetchPrices(geckoIds),
51-
select: (data) => ({
52-
...formatPrices(data, assetsWithGeckoIds),
53-
...(isStarshipChain
54-
? { [allAssets[0].base]: DEFAULT_HYPERWEB_TOKEN_PRICE }
55-
: {}),
56-
}),
51+
select: (data) => {
52+
const formattedPrices = formatPrices(data, assetsWithGeckoIds);
53+
54+
// Always add hyperweb price for hyperweb chain
55+
const hyperwebPrice =
56+
chainName === 'hyperweb'
57+
? { uhyper: DEFAULT_HYPERWEB_TOKEN_PRICE }
58+
: {};
59+
60+
// Also add for starship chains if detected
61+
const starshipPrice =
62+
isStarshipChain && allAssets.length > 0
63+
? { [allAssets[0].base]: DEFAULT_HYPERWEB_TOKEN_PRICE }
64+
: {};
65+
66+
return {
67+
...formattedPrices,
68+
...hyperwebPrice,
69+
...starshipPrice,
70+
};
71+
},
5772
staleTime: Infinity,
5873
});
5974
};

templates/chain-admin/hooks/asset-list/useChainUtils.ts

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,34 @@ export const useChainUtils = (chainName: string) => {
4949
};
5050

5151
const getAssetByDenom = (denom: CoinDenom): Asset => {
52-
return allAssets.find((asset) => asset.base === denom) as Asset;
52+
const asset = allAssets.find((asset) => asset.base === denom);
53+
54+
// Fallback for hyperweb native token if not found in asset lists
55+
if (!asset && denom === 'uhyper' && chainName === 'hyperweb') {
56+
return {
57+
base: 'uhyper',
58+
name: 'Hyperweb',
59+
display: 'hyper',
60+
symbol: 'HYPER',
61+
denomUnits: [
62+
{
63+
denom: 'uhyper',
64+
exponent: 0,
65+
},
66+
{
67+
denom: 'hyper',
68+
exponent: 6,
69+
},
70+
],
71+
logoURIs: {
72+
png: '',
73+
svg: '',
74+
},
75+
typeAsset: 'sdk.coin',
76+
} as unknown as Asset;
77+
}
78+
79+
return asset as Asset;
5380
};
5481

5582
const denomToSymbol = (denom: CoinDenom): CoinSymbol => {
@@ -77,8 +104,15 @@ export const useChainUtils = (chainName: string) => {
77104
};
78105

79106
const getExponentByDenom = (denom: CoinDenom): Exponent => {
107+
// Special handling for hyperweb native token
108+
if (denom === 'uhyper') {
109+
return 6;
110+
}
111+
80112
const asset = getAssetByDenom(denom);
81-
const unit = asset?.denomUnits.find(({ denom }) => denom === asset.display);
113+
const unit = asset?.denomUnits?.find(
114+
({ denom }) => denom === asset.display
115+
);
82116
return unit?.exponent || 0;
83117
};
84118

@@ -98,6 +132,11 @@ export const useChainUtils = (chainName: string) => {
98132
};
99133

100134
const getChainName = (ibcDenom: CoinDenom) => {
135+
// Special handling for hyperweb native token
136+
if (ibcDenom === 'uhyper' && chainName === 'hyperweb') {
137+
return chainName;
138+
}
139+
101140
if (nativeAssets.find((asset) => asset.base === ibcDenom)) {
102141
return chainName;
103142
}
@@ -109,8 +148,13 @@ export const useChainUtils = (chainName: string) => {
109148
};
110149

111150
const getPrettyChainName = (ibcDenom: CoinDenom) => {
112-
const chainName = getChainName(ibcDenom);
113-
const chain = chains.find((chain) => chain.chainName === chainName);
151+
// Special handling for hyperweb native token
152+
if (ibcDenom === 'uhyper' && chainName === 'hyperweb') {
153+
return 'Hyperweb Devnet';
154+
}
155+
156+
const resolvedChainName = getChainName(ibcDenom);
157+
const chain = chains.find((chain) => chain.chainName === resolvedChainName);
114158
if (!chain) throw Error('chain not found');
115159
return chain.prettyName;
116160
};

0 commit comments

Comments
 (0)