Handle network errors for cosmos-sdk modules that are not enabled #4

Merged
nabarun merged 3 commits from deep-stack/cosmos-explorer:pj-check-mint-module-enabled into master 2025-11-07 08:26:13 +00:00
2 changed files with 33 additions and 19 deletions
Showing only changes of commit f4362ec57f - Show all commits
+21 -14
View File
@@ -152,7 +152,7 @@ export const useIndexModule = defineStore('module-index', {
const mintStore = useMintStore();
const formatter = useFormatter();
return [
const statsArray = [
{
title: 'Height',
color: 'primary',
@@ -185,24 +185,31 @@ export const useIndexModule = defineStore('module-index', {
}),
change: 0,
},
{
];
// Only show Inflation if mint module is enabled
if (mintStore.mintModuleEnabled) {
statsArray.push({
title: 'Inflation',
color: 'success',
icon: 'mdi-chart-multiple',
stats: formatter.formatDecimalToPercent(mintStore.inflation),
change: 0,
},
{
title: 'Community Pool',
color: 'primary',
icon: 'mdi-bank',
stats: formatter.formatTokens(
// @ts-ignore
this.communityPool?.filter((x: Coin) => x.denom === staking.params.bond_denom)
),
change: 0,
},
];
});
}
statsArray.push({
title: 'Community Pool',
color: 'primary',
icon: 'mdi-bank',
stats: formatter.formatTokens(
// @ts-ignore
this.communityPool?.filter((x: Coin) => x.denom === staking.params.bond_denom)
),
change: 0,
});
return statsArray;
},
coingeckoId() {
+12 -5
View File
@@ -5,6 +5,7 @@ export const useMintStore = defineStore('mintStore', {
state: () => {
return {
inflation: '0',
mintModuleEnabled: true,
};
},
getters: {
@@ -18,14 +19,20 @@ export const useMintStore = defineStore('mintStore', {
},
async fetchInflation() {
try {
const res = await this.blockchain?.rpc?.getMintInflation().catch(() => {
this.inflation = '0';
});
const res = await this.blockchain?.rpc?.getMintInflation();
if (res) {
this.inflation = res.inflation;
this.mintModuleEnabled = true;
}
} catch (e: any) {
// Check if module is not implemented/enabled
const errorMessage = e?.message || e?.toString() || '';
if (errorMessage.includes('Not Implemented') || e?.status === 501) {
// Module not enabled
this.mintModuleEnabled = false;
} else {
console.log(e);
}
} catch (e) {
console.log(e);
}
},
},