Skip to content

Commit

Permalink
feat(dashboard): refactor chain initialization to use local registry …
Browse files Browse the repository at this point in the history
…data and improve loading checks for test
  • Loading branch information
snoopy1412 committed Nov 20, 2024
1 parent f301cd1 commit 2bc45a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
4 changes: 3 additions & 1 deletion src/app/(dashboard)/_hooks/use-chain-initlization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ export function useChainInitialization({

useEffect(() => {
const init = async () => {
if (!polkadotAssetRegistry || !chainsInfo?.length) {
if (!polkadotAssetRegistry || !chainsInfo) {
return;
}
console.log('polkadotAssetRegistry', polkadotAssetRegistry);
console.log('chainsInfo', chainsInfo);
setIsLoading(true);

const filteredPolkadotAssetRegistry = await filterHrmpConnections({
Expand Down
41 changes: 24 additions & 17 deletions src/app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
export const dynamic = 'force-dynamic';

import {
fetchPolkadotAssetRegistry,
fetchAssetsInfo,
fetchChainsInfo
} from '@/services/fetch-chain-resources';
import registry from '@/assets/registry.json';
import chainAssets from '@/assets/chains.json';
import assetsInfo from '@/assets/assets.json';
// import {
// fetchPolkadotAssetRegistry,
// fetchAssetsInfo,
// fetchChainsInfo
// } from '@/services/fetch-chain-resources';
import Dashboard from './_components/dashboard';
import type { ChainConfig } from '@/types/asset-registry';
import type { ChainInfo } from '@/types/chains-info';
import type { Asset } from '@/types/assets-info';

export default async function Page() {
const [polkadotAsset, chainAssets, assetsInfo] = await Promise.all([
fetchPolkadotAssetRegistry(),
fetchChainsInfo(),
fetchAssetsInfo()
]);
// const [polkadotAsset, chainAssets, assetsInfo] = await Promise.all([
// fetchPolkadotAssetRegistry(),
// fetchChainsInfo(),
// fetchAssetsInfo()
// ]);

// console.log('polkadotAsset', polkadotAsset);
// console.log('chainAssets', chainAssets);
// console.log('assetsInfo', assetsInfo);

console.log('polkadotAsset', polkadotAsset);
console.log('chainAssets', chainAssets);
console.log('assetsInfo', assetsInfo);
const polkadotAsset = registry?.polkadot;

return (
<Dashboard
polkadotAssetRegistry={polkadotAsset}
chainsInfo={chainAssets}
assetsInfo={assetsInfo}
polkadotAssetRegistry={polkadotAsset as ChainConfig}
chainsInfo={chainAssets as ChainInfo[]}
assetsInfo={assetsInfo as Asset[]}
/>
);
}

0 comments on commit 2bc45a3

Please sign in to comment.