Skip to content

Commit

Permalink
Fix approve on native token (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeating authored Jan 31, 2023
1 parent 8323bf0 commit bbc1881
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/TxForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { Button } from '@chakra-ui/button';
import { FormControl, FormLabel } from '@chakra-ui/form-control';
import { Input, InputGroup, InputRightElement } from '@chakra-ui/input';
Expand All @@ -18,7 +18,7 @@ import { networks } from '@/utils/networks';

export const TxForm = () => {
// TODO: Placeholder notification for shielding
const { tokenAllowances } = useToken();
const { tokenAllowances, tokenList } = useToken();
const { chain } = useNetwork();
const network = networks[chain?.id || 1];
const { notifyUser, txNotify } = useNotifications();
Expand Down Expand Up @@ -47,6 +47,16 @@ export const TxForm = () => {
tokenAddress !== ethAddress &&
ethers.utils.parseUnits(tokenAmount || '0', tokenDecimals).gt(tokenAllowance);

useEffect(() => {
const token = tokenList[0];
if (!tokenAddress && token) {
setTokenAddress(token.address);
setTokenDecimals(token.decimals);
setTokenSymbol(token.symbol);
setTokenName(token.name);
}
}, [tokenAddress, tokenList]);

return (
<Box width="24rem">
<FormControl>
Expand Down

0 comments on commit bbc1881

Please sign in to comment.