@orderly.network/ui-transfer 2.11.3-rc.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +514 -91
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +517 -94
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +14 -13
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { i18n, useTranslation, Trans } from '@orderly.network/i18n';
|
|
2
|
-
import { registerSimpleDialog, registerSimpleSheet, Tabs, TabPanel, ArrowDownSquareFillIcon, ArrowUpSquareFillIcon, ExtensionSlot, ExtensionPositionEnum, Box, textVariants, Flex, toast, Text, cn, Button, Spinner, Select, Input, inputFormatter, useScreen, modal, Tooltip, Tips, AlertDialog, EditIcon, ArrowLeftRightIcon, WalletIcon, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, ScrollArea, ChainIcon, Badge, CaretUpIcon, CaretDownIcon, SimpleDialog, CloseRoundFillIcon, ExclamationFillIcon,
|
|
2
|
+
import { registerSimpleDialog, registerSimpleSheet, Tabs, TabPanel, ArrowDownSquareFillIcon, ArrowUpSquareFillIcon, ExtensionSlot, ExtensionPositionEnum, Box, textVariants, Flex, toast, Text, cn, Button, Spinner, Select, Input, inputFormatter, useScreen, modal, Tooltip, Tips, AlertDialog, EditIcon, ArrowLeftRightIcon, WalletIcon, DropdownMenuRoot, DropdownMenuTrigger, DropdownMenuPortal, DropdownMenuContent, ScrollArea, ChainIcon, Badge, TokenIcon, CaretUpIcon, CaretDownIcon, SimpleDialog, CloseRoundFillIcon, ExclamationFillIcon, WarningIcon, SelectItem, ChevronRightIcon, Checkbox, CloseIcon } from '@orderly.network/ui';
|
|
3
3
|
import { forwardRef, useState, useMemo, useEffect, useCallback, useRef } from 'react';
|
|
4
|
-
import { useConfig, useWalletConnector, useLocalStorage, useConvert, useOdosQuote, useComputedLTV, useAccount, useAppStore, useTransfer, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useTokensInfo, useEventEmitter, usePositionStream, useIndexPricesStream, useOrderlyContext, useDeposit, useAssetsHistory, useChains, useMemoizedFn, useWithdraw, useWalletTopic, useQuery, useSWR, useTokenInfo, useHoldingStream, useInternalTransfer, useDebouncedCallback, useTransferHistory, useBalanceTopic } from '@orderly.network/hooks';
|
|
4
|
+
import { useConfig, useWalletConnector, useLocalStorage, useConvert, useOdosQuote, useComputedLTV, useAccount, useAppStore, useTransfer, useSubAccountDataObserver, useSubAccountMaxWithdrawal, useTokensInfo, useEventEmitter, usePositionStream, useIndexPricesStream, useOrderlyContext, useDeposit, useAssetsHistory, useChains, useMemoizedFn, useWithdraw, useWalletTopic, useQuery, useSWR, useTokenInfo, useHoldingStream, useInternalTransfer, useDebouncedCallback, usePrivateQuery, useTransferHistory, useBalanceTopic } from '@orderly.network/hooks';
|
|
5
5
|
import { Decimal, zero, praseChainIdToNumber, int2hex, toNonExponential, formatWithPrecision, isSolana } from '@orderly.network/utils';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { AccountStatusEnum, AssetHistoryStatusEnum, AssetHistorySideEnum, Arbitrum, EMPTY_OBJECT, isNativeTokenChecker,
|
|
7
|
+
import { AccountStatusEnum, ChainNamespace, AssetHistoryStatusEnum, AssetHistorySideEnum, Arbitrum, EMPTY_OBJECT, isNativeTokenChecker, ABSTRACT_CHAIN_ID_MAP, nativeTokenAddress } from '@orderly.network/types';
|
|
8
8
|
import { AuthGuard, useAuthGuard } from '@orderly.network/ui-connector';
|
|
9
9
|
import { useAppContext, useAppConfig } from '@orderly.network/react-app';
|
|
10
|
+
import { qrcode } from '@akamfoad/qr';
|
|
10
11
|
import { account } from '@orderly.network/perp';
|
|
11
12
|
import { utils } from '@orderly.network/core';
|
|
12
13
|
import { ChainSelectorDialogId } from '@orderly.network/ui-chain-selector';
|
|
@@ -596,6 +597,392 @@ var ExchangeDivider = ({ icon }) => {
|
|
|
596
597
|
/* @__PURE__ */ jsx(Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
|
|
597
598
|
] });
|
|
598
599
|
};
|
|
600
|
+
var CopyIcon = ({ copied }) => /* @__PURE__ */ jsx(
|
|
601
|
+
"svg",
|
|
602
|
+
{
|
|
603
|
+
width: "17",
|
|
604
|
+
height: "16",
|
|
605
|
+
viewBox: "0 0 17 16",
|
|
606
|
+
fill: "currentColor",
|
|
607
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
608
|
+
className: `oui-fill-base-contrast oui-text-base-contrast-54 ${copied ? "oui-fill-success oui-text-success" : ""}`,
|
|
609
|
+
children: copied ? /* @__PURE__ */ jsx(
|
|
610
|
+
"path",
|
|
611
|
+
{
|
|
612
|
+
d: "M14 4L6 11.5L3 8.5",
|
|
613
|
+
fill: "none",
|
|
614
|
+
stroke: "currentColor",
|
|
615
|
+
strokeWidth: "2",
|
|
616
|
+
strokeLinecap: "round",
|
|
617
|
+
strokeLinejoin: "round"
|
|
618
|
+
}
|
|
619
|
+
) : /* @__PURE__ */ jsx(
|
|
620
|
+
"path",
|
|
621
|
+
{
|
|
622
|
+
d: "M5.166 1.994A2.667 2.667 0 0 0 2.499 4.66v4a2.667 2.667 0 0 0 2.667 2.667 2.667 2.667 0 0 0 2.666 2.667h4a2.667 2.667 0 0 0 2.667-2.667v-4a2.667 2.667 0 0 0-2.667-2.667 2.667 2.667 0 0 0-2.666-2.666zm6.666 4c.737 0 1.334.596 1.334 1.333v4c0 .737-.597 1.334-1.334 1.334h-4A1.333 1.333 0 0 1 6.5 11.327h2.667a2.667 2.667 0 0 0 2.666-2.667z",
|
|
623
|
+
fill: "currentColor"
|
|
624
|
+
}
|
|
625
|
+
)
|
|
626
|
+
}
|
|
627
|
+
);
|
|
628
|
+
var CopyAddress = ({ address }) => {
|
|
629
|
+
const [copied, setCopied] = useState(false);
|
|
630
|
+
const handleCopy = () => {
|
|
631
|
+
navigator.clipboard.writeText(address);
|
|
632
|
+
setCopied(true);
|
|
633
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
634
|
+
};
|
|
635
|
+
return /* @__PURE__ */ jsxs(
|
|
636
|
+
Flex,
|
|
637
|
+
{
|
|
638
|
+
gap: 1,
|
|
639
|
+
itemAlign: "start",
|
|
640
|
+
className: "oui-mt-6 oui-w-full oui-cursor-pointer oui-justify-center",
|
|
641
|
+
onClick: handleCopy,
|
|
642
|
+
children: [
|
|
643
|
+
/* @__PURE__ */ jsx(
|
|
644
|
+
Text,
|
|
645
|
+
{
|
|
646
|
+
size: "xs",
|
|
647
|
+
className: "oui-break-all oui-text-center oui-text-base-contrast-80",
|
|
648
|
+
title: address,
|
|
649
|
+
children: address
|
|
650
|
+
}
|
|
651
|
+
),
|
|
652
|
+
/* @__PURE__ */ jsx(Box, { className: "oui-mt-0.5 oui-shrink-0", children: /* @__PURE__ */ jsx(CopyIcon, { copied }) })
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
};
|
|
657
|
+
var DepositStatusBlock = ({
|
|
658
|
+
amount,
|
|
659
|
+
symbol = "USDC",
|
|
660
|
+
pendingCount,
|
|
661
|
+
explorerUrl
|
|
662
|
+
}) => {
|
|
663
|
+
const { t: t0 } = useTranslation();
|
|
664
|
+
const t = t0;
|
|
665
|
+
const label = t("transfer.exclusiveDeposit.depositPending", {
|
|
666
|
+
amount,
|
|
667
|
+
symbol
|
|
668
|
+
});
|
|
669
|
+
const handleClick = () => {
|
|
670
|
+
window.open(explorerUrl, "_blank", "noopener,noreferrer");
|
|
671
|
+
};
|
|
672
|
+
return /* @__PURE__ */ jsxs(
|
|
673
|
+
Flex,
|
|
674
|
+
{
|
|
675
|
+
itemAlign: "center",
|
|
676
|
+
gap: 2,
|
|
677
|
+
className: "oui-group oui-mt-6 oui-w-full oui-cursor-pointer",
|
|
678
|
+
onClick: handleClick,
|
|
679
|
+
children: [
|
|
680
|
+
/* @__PURE__ */ jsx("div", { className: "oui-size-2 oui-shrink-0 oui-rounded-full oui-bg-primary" }),
|
|
681
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, className: "oui-flex-1", children: label }),
|
|
682
|
+
pendingCount > 1 && /* @__PURE__ */ jsx(
|
|
683
|
+
Flex,
|
|
684
|
+
{
|
|
685
|
+
justify: "center",
|
|
686
|
+
itemAlign: "center",
|
|
687
|
+
r: "full",
|
|
688
|
+
width: 18,
|
|
689
|
+
height: 18,
|
|
690
|
+
className: "oui-bg-line-12",
|
|
691
|
+
children: /* @__PURE__ */ jsx(Text, { size: "3xs", intensity: 80, children: pendingCount })
|
|
692
|
+
}
|
|
693
|
+
),
|
|
694
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, { className: "oui-size-4 oui-text-base-contrast-54 oui-transition-colors group-hover:oui-text-base-contrast-80" })
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
);
|
|
698
|
+
};
|
|
699
|
+
var NetworkTokenSelect = ({
|
|
700
|
+
selectedNetwork,
|
|
701
|
+
selectedToken,
|
|
702
|
+
onNetworkChange,
|
|
703
|
+
onTokenChange,
|
|
704
|
+
networkOptions,
|
|
705
|
+
tokenOptions
|
|
706
|
+
}) => {
|
|
707
|
+
const { t: t0 } = useTranslation();
|
|
708
|
+
const t = t0;
|
|
709
|
+
const selectContentProps = {
|
|
710
|
+
align: "end",
|
|
711
|
+
sideOffset: -4,
|
|
712
|
+
className: "oui-custom-scrollbar"
|
|
713
|
+
};
|
|
714
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
715
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
|
|
716
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.network") }),
|
|
717
|
+
/* @__PURE__ */ jsx(Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsx(
|
|
718
|
+
Select,
|
|
719
|
+
{
|
|
720
|
+
size: "xs",
|
|
721
|
+
value: selectedNetwork || void 0,
|
|
722
|
+
onValueChange: onNetworkChange,
|
|
723
|
+
placeholder: t("transfer.exclusiveDeposit.selectNetwork"),
|
|
724
|
+
variant: "text",
|
|
725
|
+
classNames: { trigger: "oui-pr-0" },
|
|
726
|
+
maxHeight: 128,
|
|
727
|
+
contentProps: selectContentProps,
|
|
728
|
+
children: networkOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
729
|
+
/* @__PURE__ */ jsx(ChainIcon, { chainId: opt.chainId, size: "2xs" }),
|
|
730
|
+
opt.label
|
|
731
|
+
] }) }, opt.value))
|
|
732
|
+
}
|
|
733
|
+
) })
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
|
|
736
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.token") }),
|
|
737
|
+
/* @__PURE__ */ jsx(Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsx(
|
|
738
|
+
Select,
|
|
739
|
+
{
|
|
740
|
+
size: "xs",
|
|
741
|
+
value: selectedToken || void 0,
|
|
742
|
+
onValueChange: onTokenChange,
|
|
743
|
+
placeholder: t("transfer.exclusiveDeposit.selectToken"),
|
|
744
|
+
variant: "text",
|
|
745
|
+
classNames: { trigger: "oui-pr-0" },
|
|
746
|
+
maxHeight: 128,
|
|
747
|
+
contentProps: selectContentProps,
|
|
748
|
+
children: tokenOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
749
|
+
/* @__PURE__ */ jsx(TokenIcon, { name: opt.value, size: "2xs" }),
|
|
750
|
+
opt.label
|
|
751
|
+
] }) }, opt.value))
|
|
752
|
+
}
|
|
753
|
+
) })
|
|
754
|
+
] })
|
|
755
|
+
] });
|
|
756
|
+
};
|
|
757
|
+
var QRCodeDisplay = ({ address }) => {
|
|
758
|
+
return /* @__PURE__ */ jsx(Flex, { direction: "column", className: "oui-mt-5 oui-w-full", itemAlign: "center", children: /* @__PURE__ */ jsx(Box, { className: "oui-relative oui-flex oui-size-[140px] oui-items-center oui-justify-center oui-rounded-lg oui-bg-white oui-p-2", children: address ? /* @__PURE__ */ jsx(QRCodeCanvas, { width: 124, height: 124, content: address }) : /* @__PURE__ */ jsx(Box, { className: "oui-size-full oui-border-8 oui-border-dashed oui-border-black oui-opacity-50" }) }) });
|
|
759
|
+
};
|
|
760
|
+
var QRCodeCanvas = ({ width, height, content }) => {
|
|
761
|
+
const canvasRef = useRef(null);
|
|
762
|
+
useEffect(() => {
|
|
763
|
+
if (!canvasRef.current || !content) return;
|
|
764
|
+
const qrcode$1 = qrcode(content);
|
|
765
|
+
const ctx = canvasRef.current.getContext("2d");
|
|
766
|
+
const cells = qrcode$1.modules;
|
|
767
|
+
const tileW = width / cells.length;
|
|
768
|
+
const tileH = height / cells.length;
|
|
769
|
+
for (let r = 0; r < cells.length; ++r) {
|
|
770
|
+
const row = cells[r];
|
|
771
|
+
for (let c = 0; c < row.length; ++c) {
|
|
772
|
+
ctx.fillStyle = row[c] ? "#000" : "#fff";
|
|
773
|
+
const w = Math.ceil((c + 1) * tileW) - Math.floor(c * tileW);
|
|
774
|
+
const h = Math.ceil((r + 1) * tileH) - Math.floor(r * tileH);
|
|
775
|
+
ctx.fillRect(Math.round(c * tileW), Math.round(r * tileH), w, h);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}, [content, width, height]);
|
|
779
|
+
return /* @__PURE__ */ jsx("canvas", { width, height, ref: canvasRef });
|
|
780
|
+
};
|
|
781
|
+
var WarningBanner = ({ message }) => {
|
|
782
|
+
return /* @__PURE__ */ jsxs(
|
|
783
|
+
Flex,
|
|
784
|
+
{
|
|
785
|
+
itemAlign: "start",
|
|
786
|
+
gap: 1,
|
|
787
|
+
className: "oui-mt-4 oui-w-[calc(100%+2.5rem)] oui-rounded oui-bg-[#FF7D00]/10 oui-px-5 oui-py-2 oui-text-[#FF7D00]",
|
|
788
|
+
children: [
|
|
789
|
+
/* @__PURE__ */ jsx(Box, { className: "oui-mt-0.5", children: /* @__PURE__ */ jsx(WarningIcon, { width: 16, height: 16 }) }),
|
|
790
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 80, className: "oui-w-full oui-text-[#FF7D00]", children: message })
|
|
791
|
+
]
|
|
792
|
+
}
|
|
793
|
+
);
|
|
794
|
+
};
|
|
795
|
+
var buildExplorerUrl = (baseUrl, txId) => {
|
|
796
|
+
const url = baseUrl;
|
|
797
|
+
if (url.endsWith("/")) {
|
|
798
|
+
return `${url}tx/${txId}`;
|
|
799
|
+
}
|
|
800
|
+
return `${url}/tx/${txId}`;
|
|
801
|
+
};
|
|
802
|
+
var useExclusiveDeposit = (options2) => {
|
|
803
|
+
const active = options2.active ?? true;
|
|
804
|
+
const confirmed = options2.confirmed ?? true;
|
|
805
|
+
const { chainId, explorerBaseUrl } = options2;
|
|
806
|
+
const { t: t0 } = useTranslation();
|
|
807
|
+
const t = t0;
|
|
808
|
+
const receiverAddressKey = confirmed && chainId ? `/v1/client/asset/receiver_address?chain_id=${chainId}` : null;
|
|
809
|
+
const receiverEventsKey = active && confirmed ? "/v1/client/asset/receiver_events" : null;
|
|
810
|
+
const {
|
|
811
|
+
data: addressData,
|
|
812
|
+
isLoading: isAddressLoading,
|
|
813
|
+
error: addressError
|
|
814
|
+
} = usePrivateQuery(receiverAddressKey, {
|
|
815
|
+
revalidateOnFocus: false
|
|
816
|
+
});
|
|
817
|
+
const {
|
|
818
|
+
data: eventsData,
|
|
819
|
+
isLoading: isEventsLoading,
|
|
820
|
+
error: eventsError
|
|
821
|
+
} = usePrivateQuery(receiverEventsKey, {
|
|
822
|
+
refreshInterval: active ? 1e4 : 0,
|
|
823
|
+
revalidateOnFocus: false
|
|
824
|
+
});
|
|
825
|
+
const { latestEvent, pendingCount, explorerUrl } = useMemo(() => {
|
|
826
|
+
const events = eventsData ?? [];
|
|
827
|
+
if (!events.length) {
|
|
828
|
+
return {
|
|
829
|
+
latestEvent: void 0,
|
|
830
|
+
pendingCount: 0,
|
|
831
|
+
explorerUrl: void 0
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
const latest = events.reduce((acc, curr) => {
|
|
835
|
+
if (!acc) return curr;
|
|
836
|
+
return curr.created_time > acc.created_time ? curr : acc;
|
|
837
|
+
}, void 0);
|
|
838
|
+
const count = events.length;
|
|
839
|
+
const url = latest?.tx_id ? buildExplorerUrl(explorerBaseUrl, latest.tx_id) : void 0;
|
|
840
|
+
return {
|
|
841
|
+
latestEvent: latest,
|
|
842
|
+
pendingCount: count,
|
|
843
|
+
explorerUrl: url
|
|
844
|
+
};
|
|
845
|
+
}, [explorerBaseUrl, eventsData]);
|
|
846
|
+
return {
|
|
847
|
+
address: addressData?.receiver_address,
|
|
848
|
+
qrUri: addressData?.receiver_address,
|
|
849
|
+
minimumDeposit: addressData?.minimum_deposit,
|
|
850
|
+
estimatedArrivalText: t("transfer.exclusiveDeposit.estimatedTime.default"),
|
|
851
|
+
latestEvent,
|
|
852
|
+
pendingCount,
|
|
853
|
+
explorerUrl,
|
|
854
|
+
isAddressLoading,
|
|
855
|
+
isEventsLoading,
|
|
856
|
+
addressError,
|
|
857
|
+
eventsError
|
|
858
|
+
};
|
|
859
|
+
};
|
|
860
|
+
var SUPPORTED_CHAINS = {
|
|
861
|
+
prod: [42161],
|
|
862
|
+
testnet: [421614]
|
|
863
|
+
};
|
|
864
|
+
var SUPPORTED_TOKENS = ["USDC"];
|
|
865
|
+
var useExclusiveDepositOptions = () => {
|
|
866
|
+
const env = useConfig("env");
|
|
867
|
+
const networkId = useConfig("networkId");
|
|
868
|
+
const [chains, { findByChainId }] = useChains(networkId, {
|
|
869
|
+
pick: "network_infos"
|
|
870
|
+
});
|
|
871
|
+
const supportedChainIds = env === "prod" ? SUPPORTED_CHAINS.prod : SUPPORTED_CHAINS.testnet;
|
|
872
|
+
const networkOptions = useMemo(() => {
|
|
873
|
+
return supportedChainIds.map((chainId) => {
|
|
874
|
+
const chain = findByChainId(chainId);
|
|
875
|
+
const name = chain?.network_infos?.name ?? `Chain ${chainId}`;
|
|
876
|
+
const explorerUrl = chain?.network_infos?.explorer_base_url ?? "";
|
|
877
|
+
return {
|
|
878
|
+
label: name,
|
|
879
|
+
value: String(chainId),
|
|
880
|
+
chainId,
|
|
881
|
+
explorerUrl
|
|
882
|
+
};
|
|
883
|
+
});
|
|
884
|
+
}, [supportedChainIds, findByChainId]);
|
|
885
|
+
const tokenOptions = useMemo(() => {
|
|
886
|
+
return SUPPORTED_TOKENS.map((symbol) => ({
|
|
887
|
+
label: symbol,
|
|
888
|
+
value: symbol
|
|
889
|
+
}));
|
|
890
|
+
}, []);
|
|
891
|
+
return { networkOptions, tokenOptions };
|
|
892
|
+
};
|
|
893
|
+
var ExclusiveDeposit = ({ active }) => {
|
|
894
|
+
const { t: t0 } = useTranslation();
|
|
895
|
+
const t = t0;
|
|
896
|
+
const [selectedNetwork, setSelectedNetwork] = useState("");
|
|
897
|
+
const [selectedToken, setSelectedToken] = useState("");
|
|
898
|
+
const { networkOptions, tokenOptions } = useExclusiveDepositOptions();
|
|
899
|
+
const confirmed = !!selectedNetwork && !!selectedToken;
|
|
900
|
+
const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
|
|
901
|
+
const selectedChainId = selectedNetworkOption?.chainId;
|
|
902
|
+
const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
|
|
903
|
+
const {
|
|
904
|
+
address,
|
|
905
|
+
qrUri,
|
|
906
|
+
minimumDeposit,
|
|
907
|
+
estimatedArrivalText,
|
|
908
|
+
latestEvent,
|
|
909
|
+
pendingCount,
|
|
910
|
+
explorerUrl
|
|
911
|
+
} = useExclusiveDeposit({
|
|
912
|
+
active,
|
|
913
|
+
confirmed,
|
|
914
|
+
chainId: selectedChainId,
|
|
915
|
+
explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
|
|
916
|
+
});
|
|
917
|
+
const networkName = selectedNetworkOption?.label ?? "";
|
|
918
|
+
const tokenName = selectedTokenOption?.label ?? "";
|
|
919
|
+
const warningMessage = confirmed ? t("transfer.exclusiveDeposit.warning", {
|
|
920
|
+
token: tokenName,
|
|
921
|
+
network: networkName
|
|
922
|
+
}) : t("transfer.exclusiveDeposit.selectFirst");
|
|
923
|
+
const minText = confirmed && typeof minimumDeposit === "number" ? `${minimumDeposit} ${tokenName}` : "--";
|
|
924
|
+
const estText = confirmed ? estimatedArrivalText ?? t("transfer.exclusiveDeposit.estimatedTime.default") : "--";
|
|
925
|
+
return /* @__PURE__ */ jsxs(Box, { className: "oui-flex oui-flex-col oui-items-center oui-rounded-xl oui-bg-base-8 oui-tracking-[0.03em]", children: [
|
|
926
|
+
/* @__PURE__ */ jsx(WarningBanner, { message: warningMessage }),
|
|
927
|
+
confirmed && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
928
|
+
/* @__PURE__ */ jsx(QRCodeDisplay, { address: qrUri }),
|
|
929
|
+
address && /* @__PURE__ */ jsx(CopyAddress, { address })
|
|
930
|
+
] }),
|
|
931
|
+
/* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
|
|
932
|
+
confirmed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
933
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
|
|
934
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.network") }),
|
|
935
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
936
|
+
/* @__PURE__ */ jsx(ChainIcon, { chainId: selectedChainId, size: "2xs" }),
|
|
937
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: networkName })
|
|
938
|
+
] })
|
|
939
|
+
] }),
|
|
940
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
|
|
941
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.token") }),
|
|
942
|
+
/* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
|
|
943
|
+
/* @__PURE__ */ jsx(TokenIcon, { name: tokenName, size: "2xs" }),
|
|
944
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: tokenName })
|
|
945
|
+
] })
|
|
946
|
+
] })
|
|
947
|
+
] }) : /* @__PURE__ */ jsx(
|
|
948
|
+
NetworkTokenSelect,
|
|
949
|
+
{
|
|
950
|
+
selectedNetwork,
|
|
951
|
+
selectedToken,
|
|
952
|
+
onNetworkChange: setSelectedNetwork,
|
|
953
|
+
onTokenChange: setSelectedToken,
|
|
954
|
+
networkOptions,
|
|
955
|
+
tokenOptions
|
|
956
|
+
}
|
|
957
|
+
),
|
|
958
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", children: [
|
|
959
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
|
|
960
|
+
/* @__PURE__ */ jsx(
|
|
961
|
+
Text,
|
|
962
|
+
{
|
|
963
|
+
size: "xs",
|
|
964
|
+
className: confirmed ? "oui-text-[#FF7D00]" : "",
|
|
965
|
+
intensity: confirmed ? void 0 : 98,
|
|
966
|
+
children: minText
|
|
967
|
+
}
|
|
968
|
+
)
|
|
969
|
+
] }),
|
|
970
|
+
/* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", children: [
|
|
971
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.estimatedTime") }),
|
|
972
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: estText })
|
|
973
|
+
] })
|
|
974
|
+
] }),
|
|
975
|
+
confirmed && latestEvent && explorerUrl && /* @__PURE__ */ jsx(
|
|
976
|
+
DepositStatusBlock,
|
|
977
|
+
{
|
|
978
|
+
amount: latestEvent.amount,
|
|
979
|
+
symbol: latestEvent.token,
|
|
980
|
+
pendingCount,
|
|
981
|
+
explorerUrl
|
|
982
|
+
}
|
|
983
|
+
)
|
|
984
|
+
] });
|
|
985
|
+
};
|
|
599
986
|
var Fee = (props) => {
|
|
600
987
|
const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
|
|
601
988
|
const { t } = useTranslation();
|
|
@@ -1520,7 +1907,10 @@ var DepositForm = (props) => {
|
|
|
1520
1907
|
showSourceDepositCap,
|
|
1521
1908
|
showTargetDepositCap,
|
|
1522
1909
|
slippageValidate,
|
|
1523
|
-
quantityNotional
|
|
1910
|
+
quantityNotional,
|
|
1911
|
+
activeSubTab,
|
|
1912
|
+
setActiveSubTab,
|
|
1913
|
+
showExclusiveDeposit
|
|
1524
1914
|
} = props;
|
|
1525
1915
|
const { t } = useTranslation();
|
|
1526
1916
|
const tokenValueFormatter = (value) => /* @__PURE__ */ jsx(
|
|
@@ -1581,101 +1971,129 @@ var DepositForm = (props) => {
|
|
|
1581
1971
|
/* @__PURE__ */ jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
|
|
1582
1972
|
] });
|
|
1583
1973
|
};
|
|
1584
|
-
return /* @__PURE__ */
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1974
|
+
return /* @__PURE__ */ jsx(Box, { id: "oui-deposit-form", className: textVariants({ weight: "semibold" }), children: /* @__PURE__ */ jsxs(
|
|
1975
|
+
Tabs,
|
|
1976
|
+
{
|
|
1977
|
+
value: activeSubTab,
|
|
1978
|
+
onValueChange: (value) => setActiveSubTab(value),
|
|
1979
|
+
variant: "contained",
|
|
1980
|
+
classNames: {
|
|
1981
|
+
tabsList: "oui-w-fit"
|
|
1982
|
+
},
|
|
1983
|
+
children: [
|
|
1984
|
+
/* @__PURE__ */ jsxs(
|
|
1985
|
+
TabPanel,
|
|
1590
1986
|
{
|
|
1591
|
-
|
|
1592
|
-
value:
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1987
|
+
title: t("transfer.deposit.tab.connectedWallet"),
|
|
1988
|
+
value: "web3",
|
|
1989
|
+
children: [
|
|
1990
|
+
/* @__PURE__ */ jsxs(Box, { className: "oui-mt-3", children: [
|
|
1991
|
+
/* @__PURE__ */ jsx(Web3Wallet, {}),
|
|
1992
|
+
/* @__PURE__ */ jsxs(Box, { mt: 3, mb: 1, children: [
|
|
1993
|
+
/* @__PURE__ */ jsx(
|
|
1994
|
+
ChainSelect,
|
|
1995
|
+
{
|
|
1996
|
+
chains,
|
|
1997
|
+
value: currentChain,
|
|
1998
|
+
onValueChange: onChainChange,
|
|
1999
|
+
wrongNetwork,
|
|
2000
|
+
loading: settingChain,
|
|
2001
|
+
disabled: !props.isLoggedIn
|
|
2002
|
+
}
|
|
2003
|
+
),
|
|
2004
|
+
/* @__PURE__ */ jsx(
|
|
2005
|
+
QuantityInput,
|
|
2006
|
+
{
|
|
2007
|
+
"data-testId": "oui-testid-deposit-dialog-quantity-input",
|
|
2008
|
+
classNames: {
|
|
2009
|
+
root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
|
|
2010
|
+
},
|
|
2011
|
+
value: quantity,
|
|
2012
|
+
onValueChange: onQuantityChange,
|
|
2013
|
+
token: sourceToken,
|
|
2014
|
+
tokens: sourceTokens,
|
|
2015
|
+
onTokenChange: onSourceTokenChange,
|
|
2016
|
+
status: inputStatus,
|
|
2017
|
+
hintMessage,
|
|
2018
|
+
tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
|
|
2019
|
+
tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
|
|
2020
|
+
disabled: !props.isLoggedIn,
|
|
2021
|
+
balancesRevalidating: batchBalancesRevalidating,
|
|
2022
|
+
showBalance: true
|
|
2023
|
+
}
|
|
2024
|
+
)
|
|
2025
|
+
] }),
|
|
2026
|
+
/* @__PURE__ */ jsx(
|
|
2027
|
+
AvailableQuantity,
|
|
2028
|
+
{
|
|
2029
|
+
token: sourceToken,
|
|
2030
|
+
quantity,
|
|
2031
|
+
maxQuantity,
|
|
2032
|
+
notional: quantityNotional,
|
|
2033
|
+
loading: balanceRevalidating,
|
|
2034
|
+
onClick: () => {
|
|
2035
|
+
onQuantityChange(maxDepositAmount);
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
),
|
|
2039
|
+
/* @__PURE__ */ jsx(
|
|
2040
|
+
YieldBearingReminder,
|
|
2041
|
+
{
|
|
2042
|
+
symbol: targetToken?.symbol,
|
|
2043
|
+
className: "oui-mt-3"
|
|
2044
|
+
}
|
|
2045
|
+
),
|
|
2046
|
+
/* @__PURE__ */ jsx(ExchangeDivider, {}),
|
|
2047
|
+
/* @__PURE__ */ jsx(BrokerWallet, {}),
|
|
2048
|
+
/* @__PURE__ */ jsx(
|
|
2049
|
+
QuantityInput,
|
|
2050
|
+
{
|
|
2051
|
+
classNames: {
|
|
2052
|
+
root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
|
|
2053
|
+
},
|
|
2054
|
+
token: targetToken,
|
|
2055
|
+
tokens: targetTokens,
|
|
2056
|
+
onTokenChange: onTargetTokenChange,
|
|
2057
|
+
value: targetQuantity,
|
|
2058
|
+
loading: targetQuantityLoading,
|
|
2059
|
+
disabled: !props.isLoggedIn,
|
|
2060
|
+
readOnly: true,
|
|
2061
|
+
status: targetInputStatus,
|
|
2062
|
+
hintMessage: targetHintMessage,
|
|
2063
|
+
tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
|
|
2064
|
+
tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
|
|
2065
|
+
}
|
|
2066
|
+
),
|
|
2067
|
+
renderContent()
|
|
2068
|
+
] }),
|
|
2069
|
+
/* @__PURE__ */ jsx(Box, { className: "oui-mb-6 lg:oui-mb-8", children: /* @__PURE__ */ jsx(Notice, { message: warningMessage, wrongNetwork }) }),
|
|
2070
|
+
/* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
2071
|
+
ActionButton,
|
|
2072
|
+
{
|
|
2073
|
+
actionType,
|
|
2074
|
+
symbol: sourceToken?.symbol,
|
|
2075
|
+
disabled,
|
|
2076
|
+
loading,
|
|
2077
|
+
onDeposit,
|
|
2078
|
+
onApprove,
|
|
2079
|
+
onApproveAndDeposit,
|
|
2080
|
+
networkId
|
|
2081
|
+
}
|
|
2082
|
+
) })
|
|
2083
|
+
]
|
|
1597
2084
|
}
|
|
1598
2085
|
),
|
|
1599
|
-
/* @__PURE__ */ jsx(
|
|
1600
|
-
|
|
2086
|
+
showExclusiveDeposit && /* @__PURE__ */ jsx(
|
|
2087
|
+
TabPanel,
|
|
1601
2088
|
{
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
},
|
|
1606
|
-
value: quantity,
|
|
1607
|
-
onValueChange: onQuantityChange,
|
|
1608
|
-
token: sourceToken,
|
|
1609
|
-
tokens: sourceTokens,
|
|
1610
|
-
onTokenChange: onSourceTokenChange,
|
|
1611
|
-
status: inputStatus,
|
|
1612
|
-
hintMessage,
|
|
1613
|
-
tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
|
|
1614
|
-
tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
|
|
1615
|
-
disabled: !props.isLoggedIn,
|
|
1616
|
-
balancesRevalidating: batchBalancesRevalidating,
|
|
1617
|
-
showBalance: true
|
|
2089
|
+
title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
|
|
2090
|
+
value: "exclusive_deposit",
|
|
2091
|
+
children: /* @__PURE__ */ jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
|
|
1618
2092
|
}
|
|
1619
2093
|
)
|
|
1620
|
-
]
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
{
|
|
1624
|
-
token: sourceToken,
|
|
1625
|
-
quantity,
|
|
1626
|
-
maxQuantity,
|
|
1627
|
-
notional: quantityNotional,
|
|
1628
|
-
loading: balanceRevalidating,
|
|
1629
|
-
onClick: () => {
|
|
1630
|
-
onQuantityChange(maxDepositAmount);
|
|
1631
|
-
}
|
|
1632
|
-
}
|
|
1633
|
-
),
|
|
1634
|
-
/* @__PURE__ */ jsx(
|
|
1635
|
-
YieldBearingReminder,
|
|
1636
|
-
{
|
|
1637
|
-
symbol: targetToken?.symbol,
|
|
1638
|
-
className: "oui-mt-3"
|
|
1639
|
-
}
|
|
1640
|
-
),
|
|
1641
|
-
/* @__PURE__ */ jsx(ExchangeDivider, {}),
|
|
1642
|
-
/* @__PURE__ */ jsx(BrokerWallet, {}),
|
|
1643
|
-
/* @__PURE__ */ jsx(
|
|
1644
|
-
QuantityInput,
|
|
1645
|
-
{
|
|
1646
|
-
classNames: {
|
|
1647
|
-
root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
|
|
1648
|
-
},
|
|
1649
|
-
token: targetToken,
|
|
1650
|
-
tokens: targetTokens,
|
|
1651
|
-
onTokenChange: onTargetTokenChange,
|
|
1652
|
-
value: targetQuantity,
|
|
1653
|
-
loading: targetQuantityLoading,
|
|
1654
|
-
disabled: !props.isLoggedIn,
|
|
1655
|
-
readOnly: true,
|
|
1656
|
-
status: targetInputStatus,
|
|
1657
|
-
hintMessage: targetHintMessage,
|
|
1658
|
-
tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
|
|
1659
|
-
tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
|
|
1660
|
-
}
|
|
1661
|
-
),
|
|
1662
|
-
renderContent()
|
|
1663
|
-
] }),
|
|
1664
|
-
/* @__PURE__ */ jsx(Notice, { message: warningMessage, wrongNetwork }),
|
|
1665
|
-
/* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
1666
|
-
ActionButton,
|
|
1667
|
-
{
|
|
1668
|
-
actionType,
|
|
1669
|
-
symbol: sourceToken?.symbol,
|
|
1670
|
-
disabled,
|
|
1671
|
-
loading,
|
|
1672
|
-
onDeposit,
|
|
1673
|
-
onApprove,
|
|
1674
|
-
onApproveAndDeposit,
|
|
1675
|
-
networkId
|
|
1676
|
-
}
|
|
1677
|
-
) })
|
|
1678
|
-
] });
|
|
2094
|
+
]
|
|
2095
|
+
}
|
|
2096
|
+
) });
|
|
1679
2097
|
};
|
|
1680
2098
|
function useActionType(options2) {
|
|
1681
2099
|
const { allowance, quantity, maxQuantity } = options2;
|
|
@@ -3861,6 +4279,8 @@ var useDepositFormScript = (options2) => {
|
|
|
3861
4279
|
const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
|
|
3862
4280
|
const targetQuantityLoading = swapPriceRevalidating;
|
|
3863
4281
|
const warningMessage = validationMessage || swapErrorMessage;
|
|
4282
|
+
const [activeSubTab, setActiveSubTab] = useState("web3");
|
|
4283
|
+
const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== ChainNamespace.solana;
|
|
3864
4284
|
return {
|
|
3865
4285
|
sourceToken,
|
|
3866
4286
|
targetToken,
|
|
@@ -3914,7 +4334,10 @@ var useDepositFormScript = (options2) => {
|
|
|
3914
4334
|
isLoggedIn,
|
|
3915
4335
|
showSourceDepositCap,
|
|
3916
4336
|
showTargetDepositCap,
|
|
3917
|
-
quantityNotional
|
|
4337
|
+
quantityNotional,
|
|
4338
|
+
activeSubTab,
|
|
4339
|
+
setActiveSubTab,
|
|
4340
|
+
showExclusiveDeposit
|
|
3918
4341
|
};
|
|
3919
4342
|
};
|
|
3920
4343
|
var DepositFormWidget = (props) => {
|