Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ import {
formatWeiToEther,
FungibleTokenDetailed,
isEIP1559Supported,
isSameAddress,
TransactionStateType,
useChainId,
useFungibleTokenBalance,
useGasLimit,
useGasPrice,
useNativeTokenDetailed,
useTokenConstants,
useTokenTransferCallback,
} from '@masknet/web3-shared-evm'
import { isGreaterThan, isZero, multipliedBy, rightShift } from '@masknet/web3-shared-base'
Expand All @@ -34,6 +36,7 @@ interface TransferERC20Props {
const GAS_LIMIT = 30000
export const TransferERC20 = memo<TransferERC20Props>(({ token }) => {
const t = useDashboardI18N()
const { NATIVE_TOKEN_ADDRESS } = useTokenConstants()
const anchorEl = useRef<HTMLDivElement | null>(null)
const [amount, setAmount] = useState('')
const [address, setAddress] = useState('')
Expand All @@ -58,7 +61,10 @@ export const TransferERC20 = memo<TransferERC20Props>(({ token }) => {

// balance
const { value: tokenBalance = '0', retry: tokenBalanceRetry } = useFungibleTokenBalance(
selectedToken?.type ?? EthereumTokenType.Native,
// workaround: transferERC20 should support non-evm network
isSameAddress(selectedToken?.address, NATIVE_TOKEN_ADDRESS)
? EthereumTokenType.Native
: EthereumTokenType.ERC20,
selectedToken?.address ?? '',
)
const nativeToken = useNativeTokenDetailed()
Expand Down Expand Up @@ -101,7 +107,7 @@ export const TransferERC20 = memo<TransferERC20Props>(({ token }) => {
}, [tokenBalance, gasPrice, selectedToken?.type, amount])

const [transferState, transferCallback, resetTransferCallback] = useTokenTransferCallback(
selectedToken.type,
EthereumTokenType.ERC20,
selectedToken.address,
)

Expand Down