Skip to content

Commit 34f16a8

Browse files
committed
fix interchain-kit issue in chain-admin
1 parent e5e42a0 commit 34f16a8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,26 @@ export const useStarshipChains = () => {
3131
const { chains = [] } =
3232
(await fetcher<{ chains: Chain[] }>(`${baseUrl}/chains`)) ?? {};
3333

34+
const chainsWithType = chains.map(chain => ({
35+
...chain,
36+
chainType: "cosmos" as const
37+
}));
38+
3439
const assets = (await Promise.all(
35-
chains.map((chain) =>
40+
chainsWithType.map((chain) =>
3641
// @ts-ignore
3742
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)
3843
)
3944
).then((assetLists) => assetLists.filter(Boolean))) as AssetList[];
4045

41-
return chains.length > 0 && assets.length > 0
46+
return chainsWithType.length > 0 && assets.length > 0
4247
? {
4348
v1: {
44-
chains,
49+
chains: chainsWithType,
4550
assets,
4651
},
4752
v2: {
48-
chains: convertKeysToCamelCase(chains) as ChainV2[],
53+
chains: convertKeysToCamelCase(chainsWithType) as ChainV2[],
4954
assets: convertKeysToCamelCase(assets) as AssetListV2[],
5055
},
5156
}

templates/chain-admin/pages/_app.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import '../styles/globals.css';
22
import '@interchain-ui/react/styles';
33

44
import type { AppProps } from 'next/app';
5-
import { ChainProvider } from '@interchain-kit/react';
5+
import { ChainProvider, InterchainWalletModal } from '@interchain-kit/react';
66
import { chains, assetLists } from 'chain-registry';
77
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
88
import { Box, Toaster, useTheme } from '@interchain-ui/react';
@@ -36,6 +36,7 @@ function AppContent({ Component, pageProps }: AppProps) {
3636
}
3737
return chains;
3838
}, [starshipData]);
39+
console.log('combinedChains', combinedChains);
3940

4041
// Merge chain-registry and starship assetLists
4142
const combinedAssetLists = useMemo(() => {
@@ -51,7 +52,9 @@ function AppContent({ Component, pageProps }: AppProps) {
5152
}
5253

5354
return (
54-
<ChainProvider chains={combinedChains} assetLists={combinedAssetLists} wallets={wallets}>
55+
<ChainProvider chains={combinedChains} assetLists={combinedAssetLists} wallets={wallets}
56+
walletModal={() => <InterchainWalletModal />}
57+
>
5558
<Box className={themeClass}>
5659
<Layout>
5760
<Component {...pageProps} />

0 commit comments

Comments
 (0)