diff --git a/apps/extension/src/routes/popup/settings/settings.tsx b/apps/extension/src/routes/popup/settings/settings.tsx index a2c56f47..dd682320 100644 --- a/apps/extension/src/routes/popup/settings/settings.tsx +++ b/apps/extension/src/routes/popup/settings/settings.tsx @@ -13,6 +13,8 @@ import { passwordSelector } from '../../../state/password'; import { usePopupNav } from '../../../utils/navigate'; import { PopupPath } from '../paths'; import { SettingsScreen } from './settings-screen'; +import { useChainIdQuery } from '../../../hooks/chain-id'; +import { getNumeraireFromRegistry } from '../../../utils/get-numeraires-from-registry'; const links = [ { @@ -39,6 +41,7 @@ const links = [ title: 'Price denomination', icon: , href: PopupPath.SETTINGS_NUMERAIRES, + disabled: false, }, { title: 'Advanced', @@ -51,6 +54,11 @@ export const Settings = () => { const navigate = usePopupNav(); const { clearSessionPassword } = useStore(passwordSelector); + const { chainId } = useChainIdQuery(); + const numeraires = getNumeraireFromRegistry(chainId); + + console.log(chainId, numeraires); + return (
@@ -61,6 +69,7 @@ export const Settings = () => { title={i.title} icon={i.icon} onClick={() => navigate(i.href)} + disabled={i.href === PopupPath.SETTINGS_NUMERAIRES && numeraires.length === 0} /> ))}
diff --git a/apps/extension/src/shared/components/default-frontend-form/index.tsx b/apps/extension/src/shared/components/default-frontend-form/index.tsx index 8deb917b..6d509481 100644 --- a/apps/extension/src/shared/components/default-frontend-form/index.tsx +++ b/apps/extension/src/shared/components/default-frontend-form/index.tsx @@ -14,13 +14,17 @@ interface DisplayedFrontend { } const getFrontendsFromRegistry = (selectedRpc?: string): DisplayedFrontend[] => { - const registryClient = new ChainRegistryClient(); - const { frontends } = registryClient.globals(); - - const registeredFrontends = frontends.map(frontend => ({ - title: extractDomain(frontend), - url: frontend, - })); + let registeredFrontends: DisplayedFrontend[] = []; + try { + const registryClient = new ChainRegistryClient(); + const { frontends } = registryClient.globals(); + registeredFrontends = frontends.map(frontend => ({ + title: extractDomain(frontend), + url: frontend, + })); + } catch (e) { + console.error('Registry globals is not available', e); + } if (selectedRpc) { registeredFrontends.push({ title: 'Embedded RPC frontend', url: `${selectedRpc}/app/` }); diff --git a/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts b/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts index 770f330b..dcf2d90c 100644 --- a/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts +++ b/apps/extension/src/shared/components/grpc-endpoint-form/use-grpc-endpoint-form.ts @@ -18,9 +18,14 @@ const useSaveGrpcEndpointSelector = (state: AllSlices) => ({ }); const getRpcsFromRegistry = () => { - const registryClient = new ChainRegistryClient(); - const { rpcs } = registryClient.globals(); - return rpcs.toSorted(randomSort); + try { + const registryClient = new ChainRegistryClient(); + const { rpcs } = registryClient.globals(); + return rpcs.toSorted(randomSort); + } catch (e) { + console.error('Registry globals is not available', e); + return []; + } }; export const useGrpcEndpointForm = () => { diff --git a/apps/extension/src/shared/components/link.tsx b/apps/extension/src/shared/components/link.tsx index 13073d56..892d6b38 100644 --- a/apps/extension/src/shared/components/link.tsx +++ b/apps/extension/src/shared/components/link.tsx @@ -5,12 +5,14 @@ interface LinkProps { icon: ReactElement; title: string; onClick: () => void; + disabled?: boolean; } -export const CustomLink = ({ icon, title, onClick }: LinkProps) => { +export const CustomLink = ({ icon, title, onClick, disabled }: LinkProps) => { return (