Skip to content

Commit 6282a84

Browse files
committed
fix bugs of building failure
1 parent 47e6f77 commit 6282a84

File tree

11 files changed

+82
-81
lines changed

11 files changed

+82
-81
lines changed

templates/chain-admin/components/voting/Voting.tsx

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function Voting({ chainName }: VotingProps) {
5858
const { modal, open: openModal, close: closeModal, setTitle } = useModal('');
5959
const [tallies, setTallies] = useState<{ [key: string]: TallyResult }>({});
6060

61-
const chain = chains.find((c) => c.chain_name === chainName);
61+
const chain = chains.find((c) => c.chainName === chainName);
6262

6363
useEffect(() => {
6464
if (!data.proposals || data.proposals.length === 0) return;
@@ -86,7 +86,7 @@ export function Voting({ chainName }: VotingProps) {
8686
};
8787
});
8888
break;
89-
} catch (e) {}
89+
} catch (e) { }
9090
}
9191
})();
9292
}
@@ -119,46 +119,46 @@ export function Voting({ chainName }: VotingProps) {
119119
{data.proposals?.length === 0
120120
? empty
121121
: data.proposals?.map((proposal, index) => {
122-
let tally = proposal.finalTallyResult;
123-
if (
124-
proposal.status === ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD
125-
) {
126-
tally = tallies[proposal.id.toString()];
127-
}
128-
return (
129-
<Box
130-
my="$8"
131-
key={proposal.id?.toString() || index}
132-
position="relative"
133-
attributes={{ onClick: () => onClickProposal(index) }}
134-
>
135-
{data.votes[proposal.id.toString()] ? (
136-
<Box
137-
position="absolute"
138-
px="$4"
139-
py="$2"
140-
top="$4"
141-
right="$6"
142-
borderRadius="$md"
143-
backgroundColor="$green400"
144-
>
145-
<Text color="$white" fontSize="$xs" fontWeight="$bold">
146-
Voted
147-
</Text>
148-
</Box>
149-
) : null}
150-
<GovernanceProposalItem
151-
id={`# ${proposal.id?.toString()}`}
152-
key={proposal.submitTime?.getTime()}
153-
// @ts-ignore
154-
title={proposal.content?.title || proposal.title || ''}
155-
status={status(proposal.status)}
156-
votes={votes(tally!)}
157-
endTime={formatDate(proposal.votingEndTime)!}
158-
/>
159-
</Box>
160-
);
161-
})}
122+
let tally = proposal.finalTallyResult;
123+
if (
124+
proposal.status === ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD
125+
) {
126+
tally = tallies[proposal.id.toString()];
127+
}
128+
return (
129+
<Box
130+
my="$8"
131+
key={proposal.id?.toString() || index}
132+
position="relative"
133+
attributes={{ onClick: () => onClickProposal(index) }}
134+
>
135+
{data.votes[proposal.id.toString()] ? (
136+
<Box
137+
position="absolute"
138+
px="$4"
139+
py="$2"
140+
top="$4"
141+
right="$6"
142+
borderRadius="$md"
143+
backgroundColor="$green400"
144+
>
145+
<Text color="$white" fontSize="$xs" fontWeight="$bold">
146+
Voted
147+
</Text>
148+
</Box>
149+
) : null}
150+
<GovernanceProposalItem
151+
id={`# ${proposal.id?.toString()}`}
152+
key={proposal.submitTime?.getTime()}
153+
// @ts-ignore
154+
title={proposal.content?.title || proposal.title || ''}
155+
status={status(proposal.status)}
156+
votes={votes(tally!)}
157+
endTime={formatDate(proposal.votingEndTime)!}
158+
/>
159+
</Box>
160+
);
161+
})}
162162
</Box>
163163
);
164164

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.logo_URIs?.png || asset.logo_URIs?.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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ type CoinGeckoUSD = { usd: number };
88
type CoinGeckoUSDResponse = Record<CoinGeckoId, CoinGeckoUSD>;
99

1010
const getAssetsWithGeckoIds = (assets: Asset[]) => {
11-
return assets.filter((asset) => !!asset?.coingecko_id);
11+
return assets.filter((asset) => !!asset?.coingeckoId);
1212
};
1313

1414
const getGeckoIds = (assets: Asset[]) => {
15-
return assets.map((asset) => asset.coingecko_id) as string[];
15+
return assets.map((asset) => asset.coingeckoId) as string[];
1616
};
1717

1818
const formatPrices = (
1919
prices: CoinGeckoUSDResponse,
2020
assets: Asset[]
2121
): Record<string, number> => {
2222
return Object.entries(prices).reduce((priceHash, cur) => {
23-
const denom = assets.find((asset) => asset.coingecko_id === cur[0])!.base;
23+
const denom = assets.find((asset) => asset.coingeckoId === cur[0])!.base;
2424
return { ...priceHash, [denom]: cur[1].usd };
2525
}, {});
2626
};

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
22
import { useWalletManager } from '@interchain-kit/react';
33
import { Asset, AssetList } from '@chain-registry/types';
44
import { asset_lists as ibcAssetLists } from '@chain-registry/assets';
5-
import { assets as chainAssets, ibc } from 'chain-registry';
5+
import { assetLists as chainAssets, ibcData as ibc } from 'chain-registry';
66
import { Coin } from '@interchainjs/react/types';
77
import BigNumber from 'bignumber.js';
88

@@ -18,14 +18,14 @@ export const useChainUtils = (chainName: string) => {
1818
starshipData?.v1 ?? {};
1919

2020
const isStarshipChain = starshipChains.some(
21-
(chain) => chain.chain_name === chainName
21+
(chain) => chain.chainName === chainName
2222
);
2323

2424
const filterAssets = (assetList: AssetList[]): Asset[] => {
2525
return (
2626
assetList
27-
.find(({ chain_name }) => chain_name === chainName)
28-
?.assets?.filter(({ type_asset }) => type_asset !== 'ics20') || []
27+
.find(({ chainName }) => chainName === chainName)
28+
?.assets?.filter(({ typeAsset }) => typeAsset !== 'ics20') || []
2929
);
3030
};
3131

@@ -66,7 +66,7 @@ export const useChainUtils = (chainName: string) => {
6666
(asset) =>
6767
asset.symbol === symbol &&
6868
(!chainName ||
69-
asset.traces?.[0].counterparty.chain_name.toLowerCase() ===
69+
asset.traces?.[0].counterparty.chainName.toLowerCase() ===
7070
chainName.toLowerCase())
7171
);
7272
const base = asset?.base;
@@ -78,7 +78,7 @@ export const useChainUtils = (chainName: string) => {
7878

7979
const getExponentByDenom = (denom: CoinDenom): Exponent => {
8080
const asset = getAssetByDenom(denom);
81-
const unit = asset.denom_units.find(({ denom }) => denom === asset.display);
81+
const unit = asset.denomUnits.find(({ denom }) => denom === asset.display);
8282
return unit?.exponent || 0;
8383
};
8484

@@ -102,7 +102,7 @@ export const useChainUtils = (chainName: string) => {
102102
return chainName;
103103
}
104104
const asset = ibcAssets.find((asset) => asset.base === ibcDenom);
105-
const ibcChainName = asset?.traces?.[0].counterparty.chain_name;
105+
const ibcChainName = asset?.traces?.[0].counterparty.chainName;
106106
if (!ibcChainName)
107107
throw Error('chainName not found for ibcDenom: ' + ibcDenom);
108108
return ibcChainName;
@@ -140,15 +140,15 @@ export const useChainUtils = (chainName: string) => {
140140

141141
let ibcInfo = ibc.find(
142142
(i) =>
143-
i.chain_1.chain_name === fromChainName &&
144-
i.chain_2.chain_name === toChainName
143+
i.chain1.chainName === fromChainName &&
144+
i.chain2.chainName === toChainName
145145
);
146146

147147
if (!ibcInfo) {
148148
ibcInfo = ibc.find(
149149
(i) =>
150-
i.chain_1.chain_name === toChainName &&
151-
i.chain_2.chain_name === fromChainName
150+
i.chain1.chainName === toChainName &&
151+
i.chain2.chainName === fromChainName
152152
);
153153
flipped = true;
154154
}
@@ -157,9 +157,9 @@ export const useChainUtils = (chainName: string) => {
157157
throw new Error('cannot find IBC info');
158158
}
159159

160-
const key = flipped ? 'chain_2' : 'chain_1';
161-
const sourcePort = ibcInfo.channels[0][key].port_id;
162-
const sourceChannel = ibcInfo.channels[0][key].channel_id;
160+
const key = flipped ? 'chain2' : 'chain1';
161+
const sourcePort = ibcInfo.channels[0][key].portId;
162+
const sourceChannel = ibcInfo.channels[0][key].channelId;
163163

164164
return { sourcePort, sourceChannel };
165165
};

templates/chain-admin/hooks/common/useStarshipChains.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const useStarshipChains = () => {
3333

3434
const assets = (await Promise.all(
3535
chains.map((chain) =>
36+
// @ts-ignore
3637
fetcher<AssetList>(`${baseUrl}/chains/${chain.chain_id}/assets`) // if use chainId, got error: Cannot read properties of undefined (reading 'chainName') at const { connect, disconnect, address, wallet } = useChain(selectedChain)
3738
)
3839
).then((assetLists) => assetLists.filter(Boolean))) as AssetList[];

templates/chain-admin/hooks/staking/useAssetsPrices.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assets } from 'chain-registry';
1+
import { assetLists as assets } from 'chain-registry';
22
import { useQuery } from '@tanstack/react-query';
33
import { AssetList } from '@chain-registry/types';
44
import { useChainStore } from '@/contexts';
@@ -17,7 +17,7 @@ const handleError = (resp: Response) => {
1717

1818
const getGeckoIdsFromAssets = (assets: AssetList[]) => {
1919
return assets
20-
.map((asset) => asset.assets[0].coingecko_id)
20+
.map((asset) => asset.assets[0].coingeckoId)
2121
.filter(Boolean) as string[];
2222
};
2323

@@ -27,7 +27,7 @@ const formatPrices = (
2727
): Prices => {
2828
return Object.entries(prices).reduce((priceHash, cur) => {
2929
const assetList = assets.find(
30-
(asset) => asset.assets[0].coingecko_id === cur[0]
30+
(asset) => asset.assets[0].coingeckoId === cur[0]
3131
)!;
3232
const denom = assetList.assets[0].base;
3333
return { ...priceHash, [denom]: cur[1].usd };
@@ -53,7 +53,7 @@ export const useAssetsPrices = () => {
5353
starshipData?.v1 ?? {};
5454

5555
const isStarshipChain = starshipChains.some(
56-
(chain) => chain.chain_name === selectedChain
56+
(chain) => chain.chainName === selectedChain
5757
);
5858

5959
return useQuery({

templates/chain-admin/hooks/voting/useVotingData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function useVotingData(chainName: string) {
5151
const { data: rpcEndpoint, isFetching } = useRpcEndpoint(chainName);
5252

5353
const getVote = createGetVote(rpcEndpoint);
54-
const chain = chains.find((c) => c.chain_name === chainName);
54+
const chain = chains.find((c) => c.chainName === chainName);
5555
const isReady = !!address && !!rpcEndpoint;
5656

5757
const proposalsQuery = useGetProposals({

templates/chain-admin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@types/react-dom": "18.0.9"
2020
},
2121
"dependencies": {
22-
"@chain-registry/assets": "1.63.5",
22+
"@chain-registry/assets": "1.70.240",
2323
"@interchain-kit/core": "^0.2.1",
2424
"@interchain-kit/keplr-extension": "^0.2.1",
2525
"@interchain-kit/leap-extension": "^0.2.1",

templates/chain-admin/utils/asset-list/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AssetDenomUnit } from '@chain-registry/types';
1+
import { DenomUnit as AssetDenomUnit } from '@chain-registry/types';
22

33
export type CoinDenom = AssetDenomUnit['denom'];
44

templates/chain-admin/utils/voting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from '@interchainjs/react/cosmos/gov/v1beta1/gov';
88

99
export function getChainLogo(chain: Chain) {
10-
return chain.logo_URIs?.svg || chain.logo_URIs?.png || chain.logo_URIs?.jpeg;
10+
return chain.logoURIs?.svg || chain.logoURIs?.png;
1111
}
1212

1313
export function formatDate(date?: Date) {

0 commit comments

Comments
 (0)