Skip to content

Commit

Permalink
bridge_ui: Don't display amount on Redeem step (formatUnits throws on
Browse files Browse the repository at this point in the history
fractional amounts)
  • Loading branch information
kev1n-peters authored and evan-gray committed Dec 22, 2021
1 parent a91fe77 commit d6945bf
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions bridge_ui/src/components/Transfer/Redeem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@ import {
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
isEVMChain,
MAX_VAA_DECIMALS,
WSOL_ADDRESS,
} from "@certusone/wormhole-sdk";
import { formatUnits } from "@ethersproject/units";
import {
Checkbox,
FormControlLabel,
Link,
makeStyles,
} from "@material-ui/core";
import { Alert } from "@material-ui/lab";
import { useCallback, useMemo, useState } from "react";
import { useCallback, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import useGetIsTransferCompleted from "../../hooks/useGetIsTransferCompleted";
import { useHandleRedeem } from "../../hooks/useHandleRedeem";
import useIsWalletReady from "../../hooks/useIsWalletReady";
import useMetadata from "../../hooks/useMetadata";
import {
selectTransferAmount,
selectTransferIsRecovery,
selectTransferTargetAsset,
selectTransferTargetChain,
Expand Down Expand Up @@ -61,17 +57,11 @@ function Redeem() {
const targetChain = useSelector(selectTransferTargetChain);
const targetAsset = useSelector(selectTransferTargetAsset);
const isRecovery = useSelector(selectTransferIsRecovery);
const transferAmount = useSelector(selectTransferAmount);
const { isTransferCompletedLoading, isTransferCompleted } =
useGetIsTransferCompleted(true);
const classes = useStyles();
const dispatch = useDispatch();
const { isReady, statusMessage } = useIsWalletReady(targetChain);
const targetAssetArrayed = useMemo(
() => (targetAsset ? [targetAsset] : []),
[targetAsset]
);
const metadata = useMetadata(targetChain, targetAssetArrayed);
//TODO better check, probably involving a hook & the VAA
const isEthNative =
targetChain === CHAIN_ID_ETH &&
Expand Down Expand Up @@ -118,14 +108,6 @@ function Redeem() {
}, [dispatch]);
const howToAddTokensUrl = getHowToAddTokensToWalletUrl(targetChain);

const formattedTransferAmount = useMemo(() => {
const decimals =
(targetAsset && metadata.data?.get(targetAsset)?.decimals) || undefined;
return decimals
? formatUnits(transferAmount, Math.min(decimals, MAX_VAA_DECIMALS))
: undefined;
}, [targetAsset, metadata, transferAmount]);

return (
<>
<StepDescription>Receive the tokens on the target chain</StepDescription>
Expand Down Expand Up @@ -184,7 +166,6 @@ function Redeem() {
chainId={targetChain}
address={targetAsset || undefined}
/>
{formattedTransferAmount ? <span>{`Amount: ${formattedTransferAmount}`}</span> : null}
</>
) : null}
{isEVMChain(targetChain) ? <AddToMetamask /> : null}
Expand Down

0 comments on commit d6945bf

Please sign in to comment.