Skip to content

Commit

Permalink
fix fund contest form
Browse files Browse the repository at this point in the history
  • Loading branch information
masvelio authored and ilijabojanovic committed Nov 1, 2024
1 parent 6ea1223 commit c02ff9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const FundContestDrawer = ({
const [txHash, setTxHash] = useState('');

const chainRpc = app?.chain?.meta?.ChainNode?.url || '';
const chainNodeId = app?.chain?.meta?.ChainNode?.id || 0;
const ethChainId = app?.chain?.meta?.ChainNode?.eth_chain_id || 0;

const { addressOptions, selectedAddress, setSelectedAddress } =
Expand All @@ -59,7 +58,6 @@ const FundContestDrawer = ({
contestAddress,
chainRpc,
ethChainId,
chainNodeId,
userAddress: selectedAddress.value,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
useGetUserEthBalanceQuery,
} from 'state/api/communityStake';
import { useGetContestBalanceQuery } from 'state/api/contests';
import { useTokenBalanceQuery, useTokenMetadataQuery } from 'state/api/tokens';
import {
useGetERC20BalanceQuery,
useTokenMetadataQuery,
} from 'state/api/tokens';
import { convertTokenAmountToUsd } from 'views/modals/ManageCommunityStakeModal/utils';
import { calculateNewContractBalance, getAmountError } from './utils';

Expand All @@ -14,7 +17,6 @@ export const INITIAL_AMOUNT = '0.0001';
interface UseFundContestFormProps {
contestAddress: string;
chainRpc: string;
chainNodeId: number;
ethChainId: number;
userAddress: string;
fundingTokenAddress?: string;
Expand All @@ -23,7 +25,6 @@ interface UseFundContestFormProps {
const useFundContestForm = ({
contestAddress,
chainRpc,
chainNodeId,
ethChainId,
userAddress,
fundingTokenAddress,
Expand All @@ -48,16 +49,13 @@ const useFundContestForm = ({
ethChainId,
});

const { data: tokenBalances } = useTokenBalanceQuery({
chainId: chainNodeId,
tokenId: userAddress,
const { data: tokenBalance } = useGetERC20BalanceQuery({
tokenAddress: fundingTokenAddress || '',
userAddress,
nodeRpc: chainRpc,
});

const userTokenBalance = fundingTokenAddress
? tokenBalances?.tokenBalances?.find(
(token) => +token.contractAddress === +fundingTokenAddress,
)?.tokenBalance
: userEthBalance;
const userTokenBalance = fundingTokenAddress ? tokenBalance : userEthBalance;

const { data: contestBalanceData } = useGetContestBalanceQuery({
contestAddress,
Expand Down

0 comments on commit c02ff9d

Please sign in to comment.