Skip to content

Commit

Permalink
chore: follow up fix to #110
Browse files Browse the repository at this point in the history
  • Loading branch information
canhtrinh committed Sep 21, 2022
1 parent 5103d0f commit a166e92
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
17 changes: 10 additions & 7 deletions components/modal/EvmAssetWarningModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cn from "classnames";

import { tokenContractDocs } from "../../config/constants";
import { useGetAssetBalance } from "../../hooks";
import { getSelectedAssetSymbol, getSelectedAssetSymbolDestinationChain, useSwapStore } from "../../store";
import { getSelectedAssetName, getSelectedAssetNameDestChain, getSelectedAssetSymbol, getSelectedAssetSymbolDestinationChain, isAXLToken, useSwapStore } from "../../store";
import { copyToClipboard } from "../../utils";
import { SwapStatus } from "../../utils/enums";
import { AddressShortener } from "../common";
Expand All @@ -14,8 +14,11 @@ export const EvmAssetWarningModal = () => {
const { asset, destChain, resetState, srcChain, swapStatus } = useSwapStore(
(state) => state
);
const selectedAssetSymbol = useSwapStore(getSelectedAssetSymbol);
const selectedAssetSymbolOnSrcChain = useSwapStore(getSelectedAssetSymbol);
const selectedAssetSymbolOnDestinationChain = useSwapStore(getSelectedAssetSymbolDestinationChain);
const selectedAssetNameSrcChain = useSwapStore(getSelectedAssetName);
const selectedAssetNameOnDestinationChain = useSwapStore(getSelectedAssetNameDestChain);
const hasSelectedAXLToken = useSwapStore(isAXLToken);

const { balance } = useGetAssetBalance();
const { address } = useAccount();
Expand Down Expand Up @@ -60,7 +63,7 @@ export const EvmAssetWarningModal = () => {
<div>
<div>
Only send{" "}
<span className="font-bold">{selectedAssetSymbol} </span>
<span className="font-bold">{selectedAssetNameSrcChain} {hasSelectedAXLToken ? `(${selectedAssetSymbolOnSrcChain})` : null} </span>
to this deposit address on
<strong className="capitalize"> {srcChain.chainName}</strong>
<div>Any other tokens sent to this address will be lost.</div>
Expand All @@ -69,7 +72,7 @@ export const EvmAssetWarningModal = () => {
<div className="py-2 text-center">
<div className="mt-2">
<div className="font-light text-gray-300">
{selectedAssetSymbol} token contract address |{" "}
{selectedAssetNameSrcChain} {hasSelectedAXLToken ? `(${selectedAssetSymbolOnSrcChain})` : null} token contract address |{" "}
<strong className="capitalize">{srcChain.chainName}</strong>
<div className="flex items-center justify-center font-bold gap-x-2">
<AddressShortener value={tokenAddress} />
Expand All @@ -91,7 +94,7 @@ export const EvmAssetWarningModal = () => {
<div className="font-light text-gray-300">
Connected wallet balance |{" "}
<strong className="">
{balance} {selectedAssetSymbol}
{balance} {selectedAssetSymbolOnSrcChain}
</strong>
<div className="flex items-center justify-center font-bold gap-x-2">
<AddressShortener value={address} />
Expand All @@ -117,10 +120,10 @@ export const EvmAssetWarningModal = () => {
<div className="mt-5">
<span>
The recipient will receive{" "}
<span className="font-bold">{selectedAssetSymbolOnDestinationChain}</span> on{" "}
<span className="font-bold">{selectedAssetNameOnDestinationChain} {hasSelectedAXLToken ? `(${selectedAssetSymbolOnDestinationChain})` : null}</span> on{" "}
<span className="capitalize">{destChain.chainName}</span>. If your
recipient doesn’t support{" "}
<span className="font-bold">{selectedAssetSymbolOnDestinationChain}</span>{" "}
<span className="font-bold">{selectedAssetNameOnDestinationChain}</span>{" "}
<strong className="font-bold text-red-400">
the funds will be lost!
</strong>
Expand Down
17 changes: 17 additions & 0 deletions store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ export const getSelectedAssetName = memoize(
}
);

export const isAXLToken = memoize(
(state: { asset: AssetConfig | null; srcChain: ChainInfo }) => {
return state?.asset?.common_key[ENVIRONMENT] === "uaxl";
}
);

export const getSelectedAssetNameDestChain = memoize(
(state: { asset: AssetConfig | null; destChain: ChainInfo }) => {
const chainName = state?.destChain?.chainName?.toLowerCase();
if (!chainName) return "";
const assetInfo = state?.asset?.chain_aliases[chainName];
if (!assetInfo) return "";

return assetInfo?.assetName || "";
}
);

export const getSelectedAssetSymbolDestinationChain = memoize(
(state: { asset: AssetConfig | null; destChain: ChainInfo }) => {
const chainName = state?.destChain?.chainName?.toLowerCase();
Expand Down

2 comments on commit a166e92

@vercel
Copy link

@vercel vercel bot commented on a166e92 Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on a166e92 Sep 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.