Display Inflation only if mint module is enabled

This commit is contained in:
Pranav 2025-11-05 19:06:06 +05:30
parent b5a4a60759
commit f4362ec57f
2 changed files with 33 additions and 19 deletions

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() {

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);
}
},
},