Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1579: Market page / Exolix Top-up #1233

Merged
merged 29 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4270b7d
market page / remove withdraw tab
lendihop Nov 28, 2024
665bfee
fix some minor bugs
lendihop Nov 28, 2024
8283415
update icon
lendihop Nov 29, 2024
41f13fb
first step basic layout
lendihop Dec 2, 2024
e388988
order creation step layout
lendihop Dec 3, 2024
483bbe4
fix input button overlapping value
lendihop Dec 3, 2024
36c472a
Merge branch 'refs/heads/development-2' into TW-1579-market-page-exol…
lendihop Dec 6, 2024
69fd738
resolve merge conflicts
lendihop Dec 6, 2024
b90e575
show send/get tokens
lendihop Dec 7, 2024
9c36515
layout effect
lendihop Dec 7, 2024
08726bb
fade transition
lendihop Dec 9, 2024
bc7531f
Merge branch 'refs/heads/development-2' into TW-1579-market-page-exol…
lendihop Dec 9, 2024
d192fa8
some renaming
lendihop Dec 9, 2024
2fcbe08
order creation step
lendihop Dec 11, 2024
e90a922
deposit step layout
lendihop Dec 11, 2024
91a4f35
deposit step finished
lendihop Dec 12, 2024
b6a5a23
status tracking screens
lendihop Dec 13, 2024
08f2031
some fixes
lendihop Dec 13, 2024
5ea93df
move networksMap to backend
lendihop Dec 13, 2024
6649241
applied changes according to review comments
lendihop Dec 17, 2024
8fa29b7
rm unused export
lendihop Dec 17, 2024
fa65c56
fix review comment
lendihop Dec 17, 2024
50348e3
show depositExtraId + some minor fixes
lendihop Dec 20, 2024
852efa9
fix import
lendihop Dec 20, 2024
59584c0
fix typo
lendihop Dec 20, 2024
320488f
apply review changes
lendihop Dec 20, 2024
412d5f2
Merge branch 'refs/heads/development-2' into TW-1579-market-page-exol…
lendihop Dec 30, 2024
7efe4b8
fix after-merge issues
lendihop Dec 30, 2024
9ea7e64
fix import
lendihop Dec 30, 2024
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
14 changes: 14 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3319,6 +3319,20 @@
"orderExpiredDescription": {
"message": "Retry the top-up by creating a new exchange order. If the funds have already been sent, wait for the deposit to be confirmed."
},
"memo": {
"message": "MEMO"
},
"bothMemoAndAddressAreRequired": {
"message": "Both the memo and address are required to successfully deposit your funds to Exolix"
},
"memoDisclaimer": {
"message": "You must copy both the $networkName$ address and MEMO to complete deposit, or you’ll lose your funds.",
"placeholders": {
"networkName": {
"content": "$1"
}
}
},
"sendInOneTransaction": {
"message": "Send in one transaction to the $networkName$ deposit address",
"placeholders": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React, { memo, useMemo } from 'react';

import Money from 'app/atoms/Money';

import { EXOLIX_DECIMALS } from '../config';
import { getCurrencyDisplayCode } from '../utils';

interface Props {
value: string | number;
currencyCode: string;
showAllDecimals?: boolean;
}

export const DisplayExchangeValue = memo<Props>(({ value, currencyCode, showAllDecimals = false }) => {
const decimals = useMemo(
() => (showAllDecimals ? EXOLIX_DECIMALS : String(value).length > 10 ? 2 : EXOLIX_DECIMALS),
lendihop marked this conversation as resolved.
Show resolved Hide resolved
[value, showAllDecimals]
);

return (
<>
<Money cryptoDecimals={decimals} smallFractionFont={false} tooltipPlacement="bottom">
{value}
</Money>{' '}
{getCurrencyDisplayCode(currencyCode)}
</>
);
});
1 change: 1 addition & 0 deletions src/app/pages/Market/crypto-exchange/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const EXOLIX_PRIVICY_LINK = 'https://exolix.com/privacy';
export const TEZOS_EXOLIX_NETWORK_CODE = 'XTZ';

export const VALUE_PLACEHOLDER = '---';
export const EXOLIX_DECIMALS = 8;

export const INITIAL_INPUT_CURRENCY: StoredExolixCurrency = {
code: 'ETH',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { memo, useCallback, useMemo } from 'react';

import { Anchor, HashShortView, IconBase, Money } from 'app/atoms';
import { Anchor, HashShortView, IconBase } from 'app/atoms';
import { HashChip } from 'app/atoms/HashChip';
import { ReactComponent as CopyIcon } from 'app/icons/base/copy.svg';
import { ReactComponent as OutLinkIcon } from 'app/icons/base/outLink.svg';
Expand All @@ -9,6 +9,7 @@ import { ExchangeHash } from 'lib/apis/exolix/types';
import { t } from 'lib/i18n';

import { CurrencyIcon } from '../../../components/CurrencyIcon';
import { DisplayExchangeValue } from '../../../components/DisplayExchangeValue';
import { InfoContainer, InfoRaw } from '../../../components/InfoBlock';
import { VALUE_PLACEHOLDER } from '../../../config';
import { useCryptoExchangeDataState } from '../../../context';
Expand Down Expand Up @@ -45,10 +46,7 @@ export const CompletedStatusInfoBlocks = memo(() => {
<InfoRaw bottomSeparator title="youSent">
<div className="flex flex-row gap-x-0.5">
<span className="p-1 text-font-description-bold">
<Money smallFractionFont={false} tooltipPlacement="bottom">
{exchangeData.amount}
</Money>{' '}
{exchangeData.coinFrom.coinCode}
<DisplayExchangeValue value={exchangeData.amount} currencyCode={exchangeData.coinFrom.coinCode} />
</span>
<CurrencyIcon src={exchangeData.coinFrom.icon} code={exchangeData.coinFrom.coinCode} size={24} />
</div>
Expand All @@ -65,10 +63,7 @@ export const CompletedStatusInfoBlocks = memo(() => {
<InfoRaw bottomSeparator title="youReceived">
<div className="flex flex-row gap-x-0.5">
<span className="p-1 text-font-description-bold">
<Money smallFractionFont={false} tooltipPlacement="bottom">
{exchangeData.amountTo}
</Money>{' '}
{exchangeData.coinTo.coinCode}
<DisplayExchangeValue value={exchangeData.amountTo} currencyCode={exchangeData.coinTo.coinCode} />
</span>
<CurrencyIcon src={exchangeData.coinTo.icon} code={exchangeData.coinTo.coinCode} size={24} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React, { memo, useCallback } from 'react';

import { IconBase } from 'app/atoms';
import { HashChip } from 'app/atoms/HashChip';
import Money from 'app/atoms/Money';
import { ReactComponent as CopyIcon } from 'app/icons/base/copy.svg';
import { toastSuccess } from 'app/toaster';
import { t } from 'lib/i18n';

import { CurrencyIcon } from '../../../components/CurrencyIcon';
import { DisplayExchangeValue } from '../../../components/DisplayExchangeValue';
import { InfoContainer, InfoRaw } from '../../../components/InfoBlock';
import { useCryptoExchangeDataState } from '../../../context';

Expand All @@ -27,10 +27,7 @@ export const InProgressStatusInfoBlocks = memo(() => {
<InfoRaw bottomSeparator title="youSent">
<div className="flex flex-row gap-x-0.5">
<span className="p-1 text-font-description-bold">
<Money smallFractionFont={false} tooltipPlacement="bottom">
{exchangeData.amount}
</Money>{' '}
{exchangeData.coinFrom.coinCode}
<DisplayExchangeValue value={exchangeData.amount} currencyCode={exchangeData.coinFrom.coinCode} />
</span>
<CurrencyIcon src={exchangeData.coinFrom.icon} code={exchangeData.coinFrom.coinCode} size={24} />
</div>
Expand All @@ -47,10 +44,7 @@ export const InProgressStatusInfoBlocks = memo(() => {
<InfoRaw bottomSeparator title="youGet">
<div className="flex flex-row gap-x-0.5">
<span className="p-1 text-font-description-bold">
<Money smallFractionFont={false} tooltipPlacement="bottom">
{exchangeData.amountTo}
</Money>{' '}
{exchangeData.coinTo.coinCode}
<DisplayExchangeValue value={exchangeData.amountTo} currencyCode={exchangeData.coinTo.coinCode} />
</span>
<CurrencyIcon src={exchangeData.coinTo.icon} code={exchangeData.coinTo.coinCode} size={24} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useBooleanState } from 'lib/ui/hooks';

import { useCryptoExchangeDataState } from '../../../context';

import { DepositQrCodeModal } from './DepositQrCodeModal';
import { DepositAddressQrCodeModal } from './DepositAddressQrCodeModal';

interface Props {
className?: string;
Expand Down Expand Up @@ -49,7 +49,7 @@ export const DepositAddressBlock = memo<Props>(({ className }) => {
</div>
</div>

{isQrCodeModalOpened && <DepositQrCodeModal onClose={closeQrCodeModal} />}
{isQrCodeModalOpened && <DepositAddressQrCodeModal onClose={closeQrCodeModal} />}
</>
);
});
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import React, { memo } from 'react';

import { Money, QRCode } from 'app/atoms';
import { QRCode } from 'app/atoms';
import { ActionModal, ActionModalBodyContainer } from 'app/atoms/action-modal';
import { T } from 'lib/i18n';

import { CurrencyIcon } from '../../../components/CurrencyIcon';
import { DisplayExchangeValue } from '../../../components/DisplayExchangeValue';
import { useCryptoExchangeDataState } from '../../../context';

interface Props {
onClose: EmptyFn;
}

export const DepositQrCodeModal = memo<Props>(({ onClose }) => {
export const DepositAddressQrCodeModal = memo<Props>(({ onClose }) => {
const { exchangeData } = useCryptoExchangeDataState();

if (!exchangeData) return null;
Expand All @@ -24,13 +25,14 @@ export const DepositQrCodeModal = memo<Props>(({ onClose }) => {
</div>

<div className="flex flex-col justify-center items-center gap-y-2">
<div className="flex flex-row gap-x-2">
<div className="flex flex-row items-center gap-x-2">
<CurrencyIcon src={exchangeData.coinFrom.icon} code={exchangeData.coinFrom.coinCode} size={24} />
<span className="text-font-num-bold-16">
<Money smallFractionFont={false} tooltipPlacement="bottom">
{exchangeData.amount}
</Money>{' '}
{exchangeData.coinFrom.coinCode}
<span className={exchangeData.amount.length > 12 ? 'text-font-num-bold-14' : 'text-font-num-bold-16'}>
<DisplayExchangeValue
showAllDecimals
value={exchangeData.amount}
currencyCode={exchangeData.coinFrom.coinCode}
/>
</span>
</div>
<span className="text-font-description text-grey-1 text-center">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React, { memo, useCallback } from 'react';

import clsx from 'clsx';

import { CaptionAlert } from 'app/atoms';
import { IconButton } from 'app/atoms/IconButton';
import { ReactComponent as CopyIcon } from 'app/icons/base/copy.svg';
import { ReactComponent as QrCodeIcon } from 'app/icons/base/qr_code.svg';
import { toastSuccess } from 'app/toaster';
import { t, T } from 'lib/i18n';
import { useBooleanState } from 'lib/ui/hooks';

import { useCryptoExchangeDataState } from '../../../context';

import { DepositMemoQrCodeModal } from './DepositMemoQrCodeModal';

interface Props {
className?: string;
}

export const DepositMemoBlock = memo<Props>(({ className }) => {
const { exchangeData } = useCryptoExchangeDataState();

const [isQrCodeModalOpened, openQrCodeModal, closeQrCodeModal] = useBooleanState(false);

const handleCopyButtonClick = useCallback(() => {
if (!exchangeData?.depositExtraId) return;

window.navigator.clipboard.writeText(exchangeData.depositExtraId);
toastSuccess(t('copiedAddress'));
}, [exchangeData]);

if (!exchangeData?.depositExtraId) return null;

return (
<>
<div
className={clsx(
'flex justify-between items-center p-4 mb-4 rounded-lg shadow-bottom border-0.5 border-transparent',
className
)}
>
<div className="flex flex-col gap-y-1">
<span className="text-font-regular-bold">
<T id="memo" />
</span>
<span className="text-font-description text-grey-1 w-56 h-8 py-2 break-words">
{exchangeData.depositExtraId}
</span>
</div>
<div className="flex flex-row gap-x-2 self-end">
<IconButton Icon={CopyIcon} color="blue" onClick={handleCopyButtonClick} />
<IconButton Icon={QrCodeIcon} color="blue" onClick={openQrCodeModal} />
</div>
</div>

<CaptionAlert
type="warning"
message={t('memoDisclaimer', [exchangeData.coinFrom.networkName])}
className="mb-6"
/>

{isQrCodeModalOpened && <DepositMemoQrCodeModal onClose={closeQrCodeModal} />}
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { memo } from 'react';

import { QRCode } from 'app/atoms';
import { ActionModal, ActionModalBodyContainer } from 'app/atoms/action-modal';
import { t, T } from 'lib/i18n';

import { useCryptoExchangeDataState } from '../../../context';

interface Props {
onClose: EmptyFn;
}

export const DepositMemoQrCodeModal = memo<Props>(({ onClose }) => {
const { exchangeData } = useCryptoExchangeDataState();

if (!exchangeData?.depositExtraId) return null;

return (
<ActionModal title={t('memo')} hasCloseButton onClose={onClose} className="w-82" contentClassName="!w-full">
<ActionModalBodyContainer className="items-center pt-4 pb-4">
<div className="mb-5 rounded-lg shadow-center overflow-hidden p-4">
<QRCode size={188} data={exchangeData.depositExtraId} />
</div>

<div className="flex flex-col justify-center items-center gap-y-2 text-center">
<span className="text-font-num-bold-16">{exchangeData.depositExtraId}</span>
<span className="text-font-description text-grey-1">
<T id="bothMemoAndAddressAreRequired" />
</span>
</div>
</ActionModalBodyContainer>
</ActionModal>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React, { memo } from 'react';

import clsx from 'clsx';

import Money from 'app/atoms/Money';
import { T } from 'lib/i18n';

import { CurrencyIcon } from '../../../components/CurrencyIcon';
import { DisplayExchangeValue } from '../../../components/DisplayExchangeValue';
import { ExchangeCountdown } from '../../../components/ExchangeCountdown';
import { useCryptoExchangeDataState } from '../../../context';

Expand All @@ -27,17 +27,14 @@ export const ExpiresInBlock = memo<Props>(({ className }) => {
<ExchangeCountdown className="text-font-num-bold-12 w-8" />
</div>
<div className="flex flex-col justify-center items-center gap-y-2 p-4 pt-2.5">
<div className="flex flex-row gap-x-2">
<div className="flex flex-row items-center gap-x-2">
<CurrencyIcon src={exchangeData.coinFrom.icon} code={exchangeData.coinFrom.coinCode} size={24} />
<span className="text-font-num-bold-16">
<Money
cryptoDecimals={exchangeData.amount.length > 12 ? 2 : 6}
smallFractionFont={false}
tooltipPlacement="bottom"
>
{exchangeData.amount}
</Money>{' '}
{exchangeData.coinFrom.coinCode}
<span className={exchangeData.amount.length > 12 ? 'text-font-num-bold-14' : 'text-font-num-bold-16'}>
<DisplayExchangeValue
showAllDecimals
value={exchangeData.amount}
currencyCode={exchangeData.coinFrom.coinCode}
/>
</span>
</div>
<span className="text-font-description text-grey-1 text-center">
Expand Down
Loading
Loading