Get scraped chains list from DB instead of registry (#106)
- Update Next and Hyperlane deps - Query scraped chains from domains DB tablepull/109/head
parent
d93cc6ca37
commit
6b116b1dc2
@ -0,0 +1,21 @@ |
||||
export const DOMAINS_QUERY = ` |
||||
query @cached { |
||||
domain { |
||||
id |
||||
native_token |
||||
name |
||||
is_test_net |
||||
is_deprecated |
||||
chain_id |
||||
} |
||||
} |
||||
`;
|
||||
|
||||
export interface DomainsEntry { |
||||
id: number; // domainId
|
||||
native_token: string; |
||||
name: string; |
||||
is_test_net: boolean; |
||||
is_deprecated: boolean; |
||||
chain_id: string | number; |
||||
} |
@ -0,0 +1,30 @@ |
||||
import { useEffect } from 'react'; |
||||
import { useQuery } from 'urql'; |
||||
|
||||
import { useStore } from '../../../store'; |
||||
|
||||
import { DOMAINS_QUERY, DomainsEntry } from './fragments'; |
||||
|
||||
export function useScrapedChains() { |
||||
const { scrapedChains, setScrapedChains } = useStore((s) => ({ |
||||
scrapedChains: s.scrapedChains, |
||||
setScrapedChains: s.setScrapedChains, |
||||
})); |
||||
|
||||
const [result] = useQuery<{ domain: Array<DomainsEntry> }>({ |
||||
query: DOMAINS_QUERY, |
||||
pause: !!scrapedChains?.length, |
||||
}); |
||||
const { data, fetching: isFetching, error } = result; |
||||
|
||||
useEffect(() => { |
||||
if (!data) return; |
||||
setScrapedChains(data.domain); |
||||
}, [data, error, setScrapedChains]); |
||||
|
||||
return { |
||||
scrapedChains, |
||||
isFetching, |
||||
isError: !!error, |
||||
}; |
||||
} |
Loading…
Reference in new issue