diff --git a/lib/QueryAlliances.ts b/lib/QueryAlliances.ts index 08fdf1e..ebad857 100644 --- a/lib/QueryAlliances.ts +++ b/lib/QueryAlliances.ts @@ -12,11 +12,15 @@ export const QueryAlliances = async (chain: Chain): Promise => // for the rates of the hub contract per each coin. if (chain.hasAllianceHub()) { const allianceHubAsset = alliances.find((a) => a.denom === chain.getAllianceHubDenom()) as AllianceAsset; - const alliancefromHub = await queryAllianceHubAssets(chain.getAllianceHubAddress(), allianceHubAsset); + // Remove the hub asset from the list of alliances + alliances.filter((a) => a.denom === chain.getAllianceHubDenom()) + const alliancesfromHub = await queryAllianceHubAssets(chain.getAllianceHubAddress(), allianceHubAsset); + // Used to filter out any asset that is not available in + // application's state to avoid broken assets in the list. alliances = alliances - .concat(...alliancefromHub) - .filter((a) => a.denom !== chain.getAllianceHubDenom()); + .concat(alliancesfromHub) + .filter(alliance => chain.allianceCoins[alliance.denom] !== undefined); } return alliances; diff --git a/lib/QueryInflation.ts b/lib/QueryInflation.ts index fb4d926..52f9eb5 100644 --- a/lib/QueryInflation.ts +++ b/lib/QueryInflation.ts @@ -7,11 +7,21 @@ import { CarbonInflationRes } from "../const/chains"; const INFLATION_CACHE: { [chainId: string]: Dec } = {}; // If carbon would have used the standard API this would haven't been necessary -export const GetInflationEndpoint = (chainId: string): Promise => { +export const GetInflationEndpoint = async (chainId: string): Promise => { if (INFLATION_CACHE[chainId]) return Promise.resolve(); + if (chainId === "carbon-1") { - return fetch("https://api-insights.carbon.network/chain/inflation") + let res = await fetch("https://api-insights.carbon.network/chain/inflation") + .catch(_ => { + return Promise.resolve({ + result: { + inflationRate: "0" + } + }) + }); + + return res; } return LCD.mint.inflation(chainId);