mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { useStakes } from '@/hooks/useStakes';
|
|
import { addresses, isValidChainId } from '@session/contracts';
|
|
import { useWallet } from '@session/wallet/hooks/useWallet';
|
|
import { useTranslations } from 'next-intl';
|
|
import { useMemo } from 'react';
|
|
|
|
/**
|
|
* Hook to get the banned rewards addresses.
|
|
* @returns The banned rewards addresses.
|
|
* These addresses are not allowed to receive rewards and are used to prevent users from inputting them in address fields.
|
|
*/
|
|
export function useBannedRewardsAddresses() {
|
|
const dictRewardsAddress = useTranslations('actionModules.rewardsAddress.validation');
|
|
const { chainId } = useWallet();
|
|
const { vesting } = useStakes();
|
|
|
|
return useMemo(() => {
|
|
if (!isValidChainId(chainId)) return [];
|
|
|
|
const contracts = [
|
|
addresses.ServiceNodeRewards[chainId],
|
|
addresses.ServiceNodeContributionFactory[chainId],
|
|
addresses.Token[chainId],
|
|
].map((address) => ({ address, errorMessage: dictRewardsAddress('bannedSessionContract') }));
|
|
|
|
const vestingContracts = vesting.map(({ address }) => ({
|
|
address,
|
|
errorMessage: dictRewardsAddress('bannedVestingContract'),
|
|
}));
|
|
|
|
return contracts.concat(vestingContracts);
|
|
}, [chainId, vesting, dictRewardsAddress]);
|
|
}
|