Skip to content

Commit

Permalink
feat(explorer): add burned and minted token amounts to ended epochs (#…
Browse files Browse the repository at this point in the history
…4764)

* feat: add burnt and minted tokens

* fix

* fix workflow

* feat: add hook
  • Loading branch information
evavirseda authored Jan 15, 2025
1 parent 5dd0863 commit 1b9f001
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:

- name: Build apps-backend
if: inputs.isAppsBackend || github.ref_name == 'develop'
run: pnpm --filter apps-backend build
run: pnpm turbo --filter apps-backend build

- name: Run apps-backend e2e tests
if: inputs.isAppsBackend || github.ref_name == 'develop'
Expand Down
19 changes: 19 additions & 0 deletions apps/apps-backend/src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { Controller, Get } from '@nestjs/common';
import { Feature } from '@iota/core/enums/features.enums';
import { Network } from '@iota/iota-sdk/client';

@Controller('/api/features')
export class FeaturesController {
Expand Down Expand Up @@ -70,6 +71,15 @@ export class FeaturesController {
[Feature.SupplyIncreaseVesting]: {
defaultValue: true,
},
[Feature.BurntAndMintedTokensInEndedEpochs]: {
defaultValue: {
[Network.Mainnet]: false,
[Network.Devnet]: true,
[Network.Testnet]: false,
[Network.Localnet]: false,
[Network.Custom]: false,
},
},
},
dateUpdated: new Date().toISOString(),
};
Expand Down Expand Up @@ -139,6 +149,15 @@ export class FeaturesController {
[Feature.SupplyIncreaseVesting]: {
defaultValue: true,
},
[Feature.BurntAndMintedTokensInEndedEpochs]: {
defaultValue: {
[Network.Mainnet]: false,
[Network.Devnet]: true,
[Network.Testnet]: false,
[Network.Localnet]: false,
[Network.Custom]: false,
},
},
},
dateUpdated: new Date().toISOString(),
};
Expand Down
1 change: 1 addition & 0 deletions apps/core/src/enums/features.enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export enum Feature {
WalletEffectsOnlySharedTransaction = 'wallet-effects-only-shared-transaction',
StardustMigration = 'migration',
SupplyIncreaseVesting = 'supply-increase-vesting',
BurntAndMintedTokensInEndedEpochs = 'burnt-and-minted-tokens-in-ended-epochs',
}
2 changes: 2 additions & 0 deletions apps/core/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,7 @@ export * from './useStakeRewardStatus';
export * from './useGetNFTs';
export * from './useRecognizedPackages';
export * from './useTransferAsset';
export * from './useFeatureEnabledByNetwork';

export * from './stake';
export * from './ui';
15 changes: 15 additions & 0 deletions apps/core/src/hooks/useFeatureEnabledByNetwork.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { useFeature } from '@growthbook/growthbook-react';
import type { Network } from '@iota/iota-sdk/client';
import { Feature } from '../enums';

type NetworkBasedFeature = {
[key in Network]: boolean;
};

export function useFeatureEnabledByNetwork(feature: Feature, network: Network): boolean {
const featureFlag = useFeature<NetworkBasedFeature>(feature)?.value;
return featureFlag?.[network] ?? false;
}
42 changes: 34 additions & 8 deletions apps/explorer/src/pages/epochs/stats/EpochTopStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import { ProgressBar } from '~/components';
import { EpochStatsGrid } from './EpochStats';
import { LabelText, LabelTextSize } from '@iota/apps-ui-kit';
import { formatDate } from '@iota/core';
import { Feature, formatDate, useFeatureEnabledByNetwork } from '@iota/core';
import { TokenStats } from './TokenStats';
import { getSupplyChangeAfterEpochEnd } from '~/lib';
import { useEpochProgress } from '../utils';
import type { EndOfEpochInfo } from '@iota/iota-sdk/src/client';
import type { Network, EndOfEpochInfo } from '@iota/iota-sdk/client';
import { useNetworkContext } from '~/contexts';

interface EpochProgressProps {
start: number;
Expand All @@ -25,8 +26,15 @@ export function EpochTopStats({
endOfEpochInfo,
}: EpochProgressProps): React.JSX.Element {
const { progress, label } = useEpochProgress();
const [network] = useNetworkContext();

const endTime = inProgress ? label : end ? formatDate(end) : undefined;

const isBurntAndMintedTokensInEndedEpochsFeatureEnabled = useFeatureEnabledByNetwork(
Feature.BurntAndMintedTokensInEndedEpochs,
network as Network,
);

return (
<div className="flex w-full flex-col gap-md--rs">
{inProgress ? <ProgressBar progress={progress || 0} /> : null}
Expand All @@ -35,12 +43,30 @@ export function EpochTopStats({
<LabelText text={formatDate(start)} label="Start" />
{endTime ? <LabelText text={endTime} label="End" /> : null}
{endOfEpochInfo && (
<TokenStats
label="Supply Change"
size={LabelTextSize.Large}
amount={getSupplyChangeAfterEpochEnd(endOfEpochInfo)}
showSign
/>
<>
{isBurntAndMintedTokensInEndedEpochsFeatureEnabled && (
<>
<TokenStats
label="Burnt Tokens"
size={LabelTextSize.Large}
amount={BigInt(endOfEpochInfo?.burntTokensAmount)}
showSign
/>
<TokenStats
label="Minted Tokens"
size={LabelTextSize.Large}
amount={BigInt(endOfEpochInfo?.mintedTokensAmount)}
showSign
/>
</>
)}
<TokenStats
label="Supply Change"
size={LabelTextSize.Large}
amount={getSupplyChangeAfterEpochEnd(endOfEpochInfo)}
showSign
/>
</>
)}
</EpochStatsGrid>
</div>
Expand Down

0 comments on commit 1b9f001

Please sign in to comment.