diff --git a/examples/next/src/hooks/useNetwork.tsx b/examples/next/src/hooks/useNetwork.tsx index fd56808a..867c87d3 100644 --- a/examples/next/src/hooks/useNetwork.tsx +++ b/examples/next/src/hooks/useNetwork.tsx @@ -1,4 +1,4 @@ -import { networks } from '@autonomys/auto-utils' +import { NetworkId, networks } from '@autonomys/auto-utils' import { useParams } from 'next/navigation' import { useCallback, useEffect, useMemo, useState } from 'react' @@ -17,7 +17,7 @@ export const useNetwork = () => { const listOfNetworks = useMemo(() => networks.map((network) => network.id), []) const handleNetworkChange = useCallback( - (networkId: string) => { + (networkId: NetworkId) => { if (!listOfNetworks.includes(networkId)) { throw new Error(`Network ${networkId} not found`) } @@ -29,7 +29,7 @@ export const useNetwork = () => { useEffect(() => { if (networkName && config.networkId !== networkName && Array.isArray(networkName) === false) - handleNetworkChange(networkName) + handleNetworkChange(networkName as NetworkId) }, [networkName]) return { config, handleNetworkChange } diff --git a/packages/auto-utils/src/types/network.ts b/packages/auto-utils/src/types/network.ts index f9bde31a..11509b57 100644 --- a/packages/auto-utils/src/types/network.ts +++ b/packages/auto-utils/src/types/network.ts @@ -1,5 +1,6 @@ // file: src/types/network.ts import type { ApiOptions } from '@polkadot/api/types' +import { NetworkId, NetworkName } from '../constants/network' import type { NetworkDomains } from './domain' import { Token } from './token' @@ -9,8 +10,8 @@ export type Explorer = { } export type Network = { - id: string - name: string + id: NetworkId + name: NetworkName rpcUrls: string[] explorer: Explorer[] domains: NetworkDomains[]