From 4426284d1405c22b92b77d5677f67ea6c35684d4 Mon Sep 17 00:00:00 2001 From: soulBit Date: Fri, 24 Feb 2023 13:48:35 +0000 Subject: [PATCH] SOV-1903: Reward SOV claiming using stakingRewardsProxy contract balance check (#2486) fix: Reward SOV claiming using stakingRewardsProxy contract balance check --- .../ClaimForms/BaseClaimForm/index.tsx | 21 ++++++------------- .../ClaimForms/LiquidClaimForm/index.tsx | 18 +++++++++++++++- .../ClaimForms/RewardClaimForm/index.tsx | 21 ++++++++++++++++++- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/app/pages/RewardPage/components/ClaimForms/BaseClaimForm/index.tsx b/src/app/pages/RewardPage/components/ClaimForms/BaseClaimForm/index.tsx index 0084f39332..526119ff38 100644 --- a/src/app/pages/RewardPage/components/ClaimForms/BaseClaimForm/index.tsx +++ b/src/app/pages/RewardPage/components/ClaimForms/BaseClaimForm/index.tsx @@ -4,7 +4,7 @@ import { Button, ButtonSize } from 'app/components/Button'; import { ErrorBadge } from 'app/components/Form/ErrorBadge'; import { Input } from 'app/components/Form/Input'; import { TransactionDialog } from 'app/components/TransactionDialog'; -import { useCacheCallWithValue } from 'app/hooks/useCacheCallWithValue'; + import { useMaintenance } from 'app/hooks/useMaintenance'; import { ResetTxResponseInterface } from 'app/hooks/useSendContractTx'; import classNames from 'classnames'; @@ -14,7 +14,7 @@ import React, { useMemo } from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { TxStatus } from 'store/global/transactions-store/types'; import { Asset } from 'types'; -import { getContract } from 'utils/blockchain/contract-helpers'; + import { weiTo18 } from 'utils/blockchain/math-helpers'; import { discordInvite } from 'utils/classifiers'; import { weiToNumberFormat } from 'utils/display-text/format'; @@ -22,6 +22,7 @@ import { weiToNumberFormat } from 'utils/display-text/format'; interface IBaseClaimFormProps { className?: string; amountToClaim: string; + hasTokenBalance: boolean; tx: ResetTxResponseInterface; footer?: JSX.Element; onSubmit: () => void; @@ -33,6 +34,7 @@ interface IBaseClaimFormProps { export const BaseClaimForm: React.FC = ({ className, amountToClaim, + hasTokenBalance, tx, footer, onSubmit, @@ -43,17 +45,6 @@ export const BaseClaimForm: React.FC = ({ const { t } = useTranslation(); const { checkMaintenance, States } = useMaintenance(); const rewardsLocked = checkMaintenance(States.CLAIM_REWARDS); - const { address } = getContract('stakingRewards'); - const { value: tokenBalance } = useCacheCallWithValue( - 'SOV_token', - 'balanceOf', - '0', - address, - ); - - const isTokenBalance = useMemo(() => { - return bignumber(tokenBalance).greaterThanOrEqualTo(amountToClaim); - }, [amountToClaim, tokenBalance]); const isDisabled = useMemo( () => @@ -119,14 +110,14 @@ export const BaseClaimForm: React.FC = ({ {t(translations.rewardPage.claimForm.claimDisabled)} } >