Skip to content

Commit

Permalink
fix: white whale inflation to 0 if fails and filter alliances
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Feb 19, 2024
1 parent ffd0835 commit 6f04fe8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/QueryAlliances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ export const QueryAlliances = async (chain: Chain): Promise<AllianceAsset[]> =>
// 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;
Expand Down
14 changes: 12 additions & 2 deletions lib/QueryInflation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> => {
export const GetInflationEndpoint = async (chainId: string): Promise<any> => {
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);
Expand Down

0 comments on commit 6f04fe8

Please sign in to comment.