diff --git a/apps/namadillo/src/App/AppRoutes.tsx b/apps/namadillo/src/App/AppRoutes.tsx index 8400bae3d..cccc7090e 100644 --- a/apps/namadillo/src/App/AppRoutes.tsx +++ b/apps/namadillo/src/App/AppRoutes.tsx @@ -51,7 +51,7 @@ export const MainRoutes = (): JSX.Element => { const settingsAnimationKey = location.pathname.indexOf(routes.settings) > -1 ? "settings-modal" - : location.pathname; + : location.pathname; return ( <> diff --git a/apps/namadillo/src/atoms/chain/atoms.ts b/apps/namadillo/src/atoms/chain/atoms.ts index 5defbc32a..680fbe50d 100644 --- a/apps/namadillo/src/atoms/chain/atoms.ts +++ b/apps/namadillo/src/atoms/chain/atoms.ts @@ -50,7 +50,6 @@ export const nativeTokenAddressAtom = atomWithQuery((get) => { queryKey: ["native-token-address"], enabled: chain.isSuccess, queryFn: async () => { - console.log("native token", chain.data!.nativeTokenAddress); return chain.data!.nativeTokenAddress; }, }; diff --git a/apps/namadillo/src/atoms/settings/atoms.ts b/apps/namadillo/src/atoms/settings/atoms.ts index 658369085..2e1951be0 100644 --- a/apps/namadillo/src/atoms/settings/atoms.ts +++ b/apps/namadillo/src/atoms/settings/atoms.ts @@ -43,7 +43,6 @@ export const applicationFeaturesAtom = atomWithQuery((get) => { const chainId = chainParameters.data?.chainId; if (chainId) { const features = await fetchEnabledFeatures(chainId); - console.log("FEATURES", features); return features; } return defaultApplicationFeatures; @@ -77,10 +76,10 @@ export const settingsAtom = atomWithStorage( const changeSettings = (key: keyof SettingsStorage) => - (get: Getter, set: Setter, value: T) => { - const settings = get(settingsAtom); - set(settingsAtom, { ...settings, [key]: value }); - }; + (get: Getter, set: Setter, value: T) => { + const settings = get(settingsAtom); + set(settingsAtom, { ...settings, [key]: value }); + }; const changeSettingsUrl = ( @@ -88,24 +87,24 @@ const changeSettingsUrl = healthCheck: (url: string) => Promise, allowEmpty = false ) => - async (inputUrl: string) => { - const allowedEmpty = allowEmpty && inputUrl.length === 0; - const url = allowedEmpty ? "" : sanitizeUrl(inputUrl); - - if (!allowedEmpty && !isUrlValid(url)) { - throw new Error( - "Invalid URL. The URL should be valid starting with 'http', 'https', 'ws', or 'wss'." - ); - } - if (allowedEmpty || (await healthCheck(url))) { - const { get, set } = getDefaultStore(); - changeSettings(key)(get, set, url); - } else { - throw new Error( - "Couldn't reach the URL. Please provide a valid Namada URL service." - ); - } - }; + async (inputUrl: string) => { + const allowedEmpty = allowEmpty && inputUrl.length === 0; + const url = allowedEmpty ? "" : sanitizeUrl(inputUrl); + + if (!allowedEmpty && !isUrlValid(url)) { + throw new Error( + "Invalid URL. The URL should be valid starting with 'http', 'https', 'ws', or 'wss'." + ); + } + if (allowedEmpty || (await healthCheck(url))) { + const { get, set } = getDefaultStore(); + changeSettings(key)(get, set, url); + } else { + throw new Error( + "Couldn't reach the URL. Please provide a valid Namada URL service." + ); + } + }; export const updateSettingsProps = atomWithMutation(() => { return { diff --git a/apps/namadillo/src/atoms/settings/services.ts b/apps/namadillo/src/atoms/settings/services.ts index 3de6d600a..d4acf62ef 100644 --- a/apps/namadillo/src/atoms/settings/services.ts +++ b/apps/namadillo/src/atoms/settings/services.ts @@ -12,7 +12,7 @@ const namadaChainRegistryUrl = const namadaChainRegistryMap = new Map([ ["namada-dryrun.abaaeaf7b78cb3ac", "namadadryrun"], - ["housefire-cotton.d3c912fee7462", "namadahousefire"], + ["housefire-equal.130b1076e3250f", "namadahousefire"], ["internal-devnet-44a.1bd3e6ca62", "namadainternaldevnet"], ]); @@ -24,6 +24,15 @@ type Feature = | "shieldingRewards" | "namTransfers"; +const allFeaturesEnabled = { + claimRewardsEnabled: true, + shieldingRewardsEnabled: true, + maspEnabled: true, + ibcTransfersEnabled: true, + ibcShieldingEnabled: true, + namTransfersEnabled: true, +}; + export const isIndexerAlive = async (url: string): Promise => { if (!isUrlValid(url)) { return false; @@ -68,10 +77,16 @@ export const fetchDefaultTomlConfig = return toml.parse(await response.text()) as SettingsTomlOptions; }; +// TODO: Clean this whole thing up! export const fetchEnabledFeatures = async ( chainId: string ): Promise => { const chainName = namadaChainRegistryMap.get(chainId); + + if (!chainName) { + // Enable every feature for non-mapped chains + return allFeaturesEnabled; + } const chainConfigFile = "chain.json"; const options = defaultApplicationFeatures; @@ -79,8 +94,13 @@ export const fetchEnabledFeatures = async ( const response = await fetch( `${namadaChainRegistryUrl}/${chainName}/${chainConfigFile}` ); + const { features } = (await response.json()) as { features: Feature[] }; - console.log("features?", features); + + if (!features || features.length === 0) { + // Enable every feature for non-registry chains + return allFeaturesEnabled; + } features.forEach((feature: Feature) => { switch (feature) { @@ -99,6 +119,9 @@ export const fetchEnabledFeatures = async ( case "namTransfers": options.namTransfersEnabled = true; break; + case "shieldingRewards": + options.shieldingRewardsEnabled = true; + break; } });