Skip to content

Commit

Permalink
feat: add FiatTokenBalance feature
Browse files Browse the repository at this point in the history
  • Loading branch information
VmMad committed Jan 15, 2025
1 parent d2d2772 commit 7cdcf89
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions apps/apps-backend/src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ export class FeaturesController {
[Network.Custom]: false,
},
},
[Feature.FiatTokenPrice]: {
defaultValue: {
[Network.Mainnet]: true,
[Network.Devnet]: false,
[Network.Testnet]: false,
[Network.Localnet]: false,
[Network.Custom]: false,
},
},
},
dateUpdated: new Date().toISOString(),
};
Expand Down Expand Up @@ -158,6 +167,15 @@ export class FeaturesController {
[Network.Custom]: false,
},
},
[Feature.FiatTokenPrice]: {
defaultValue: {
[Network.Mainnet]: true,
[Network.Devnet]: false,
[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 @@ -21,4 +21,5 @@ export enum Feature {
StardustMigration = 'migration',
SupplyIncreaseVesting = 'supply-increase-vesting',
BurntAndMintedTokensInEndedEpochs = 'burnt-and-minted-tokens-in-ended-epochs',
FiatTokenPrice = 'fiat-token-price',
}
5 changes: 4 additions & 1 deletion apps/core/src/hooks/useGetFiatBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import { IOTA_TYPE_ARG } from '@iota/iota-sdk/utils';
import { useBalance } from './useBalance';
import { formatBalanceToUSD } from '../utils';
import { Network } from '@iota/iota-sdk/client';
import { useFeatureEnabledByNetwork } from './useFeatureEnabledByNetwork';
import { Feature } from '../enums';

export function useGetFiatBalance(network: Network): string | null {
const isFiatPriceEnabled = useFeatureEnabledByNetwork(Feature.FiatTokenPrice, network);
if (!isFiatPriceEnabled) return null;
const account = useCurrentAccount();
const address = account?.address;
if (!address) return null;
const { data: coinBalance } = useBalance(address);
console.log(network);
const balance = useBalanceInUSD(IOTA_TYPE_ARG, coinBalance?.totalBalance ?? 0, network);

if (!balance) return null;
Expand Down

0 comments on commit 7cdcf89

Please sign in to comment.