@orderly.network/ui-transfer 3.0.0-beta.0 → 3.0.0-beta.10

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.mjs CHANGED
@@ -1,17 +1,19 @@
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, TokenIcon, Checkbox, CloseIcon } from '@orderly.network/ui';
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';
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, TokenIcon, WarningIcon, SelectItem, ChevronRightIcon, Checkbox, CloseIcon } from '@orderly.network/ui';
3
+ import { forwardRef, useState, isValidElement, 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, 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, ChainNamespace, ABSTRACT_CHAIN_ID_MAP, nativeTokenAddress } from '@orderly.network/types';
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';
13
14
  import { PublicKey } from '@solana/web3.js';
14
15
  import { ethers } from 'ethers';
16
+ import { injectable } from '@orderly.network/plugin-core';
15
17
  import { DefaultSolanaWalletAdapter } from '@orderly.network/default-solana-adapter';
16
18
 
17
19
  // src/components/depositForm/depositForm.ui.tsx
@@ -596,6 +598,423 @@ var ExchangeDivider = ({ icon }) => {
596
598
  /* @__PURE__ */ jsx(Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
597
599
  ] });
598
600
  };
601
+ var CopyIcon = ({ copied }) => /* @__PURE__ */ jsx(
602
+ "svg",
603
+ {
604
+ width: "17",
605
+ height: "16",
606
+ viewBox: "0 0 17 16",
607
+ fill: "currentColor",
608
+ xmlns: "http://www.w3.org/2000/svg",
609
+ className: `oui-fill-base-contrast oui-text-base-contrast-54 ${copied ? "oui-fill-success oui-text-success" : ""}`,
610
+ children: copied ? /* @__PURE__ */ jsx(
611
+ "path",
612
+ {
613
+ d: "M14 4L6 11.5L3 8.5",
614
+ fill: "none",
615
+ stroke: "currentColor",
616
+ strokeWidth: "2",
617
+ strokeLinecap: "round",
618
+ strokeLinejoin: "round"
619
+ }
620
+ ) : /* @__PURE__ */ jsx(
621
+ "path",
622
+ {
623
+ 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",
624
+ fill: "currentColor"
625
+ }
626
+ )
627
+ }
628
+ );
629
+ var CopyAddress = ({ address }) => {
630
+ const [copied, setCopied] = useState(false);
631
+ const handleCopy = () => {
632
+ navigator.clipboard.writeText(address);
633
+ setCopied(true);
634
+ setTimeout(() => setCopied(false), 2e3);
635
+ };
636
+ return /* @__PURE__ */ jsxs(
637
+ Flex,
638
+ {
639
+ gap: 1,
640
+ itemAlign: "start",
641
+ className: "oui-mt-6 oui-w-full oui-cursor-pointer oui-justify-center",
642
+ onClick: handleCopy,
643
+ children: [
644
+ /* @__PURE__ */ jsx(
645
+ Text,
646
+ {
647
+ size: "xs",
648
+ className: "oui-break-all oui-text-center oui-text-base-contrast-80",
649
+ title: address,
650
+ children: address
651
+ }
652
+ ),
653
+ /* @__PURE__ */ jsx(Box, { className: "oui-mt-0.5 oui-shrink-0", children: /* @__PURE__ */ jsx(CopyIcon, { copied }) })
654
+ ]
655
+ }
656
+ );
657
+ };
658
+ var DepositStatusBlock = ({
659
+ amount,
660
+ symbol = "USDC",
661
+ pendingCount,
662
+ explorerUrl
663
+ }) => {
664
+ const { t: t0 } = useTranslation();
665
+ const t = t0;
666
+ const label = t("transfer.exclusiveDeposit.depositPending", {
667
+ amount,
668
+ symbol
669
+ });
670
+ const handleClick = () => {
671
+ window.open(explorerUrl, "_blank", "noopener,noreferrer");
672
+ };
673
+ return /* @__PURE__ */ jsxs(
674
+ Flex,
675
+ {
676
+ itemAlign: "center",
677
+ gap: 2,
678
+ className: "oui-group oui-mt-6 oui-w-full oui-cursor-pointer",
679
+ onClick: handleClick,
680
+ children: [
681
+ /* @__PURE__ */ jsx("div", { className: "oui-size-2 oui-shrink-0 oui-rounded-full oui-bg-primary" }),
682
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, className: "oui-flex-1", children: label }),
683
+ pendingCount > 1 && /* @__PURE__ */ jsx(
684
+ Flex,
685
+ {
686
+ justify: "center",
687
+ itemAlign: "center",
688
+ r: "full",
689
+ width: 18,
690
+ height: 18,
691
+ className: "oui-bg-line-12",
692
+ children: /* @__PURE__ */ jsx(Text, { size: "3xs", intensity: 80, children: pendingCount })
693
+ }
694
+ ),
695
+ /* @__PURE__ */ jsx(ChevronRightIcon, { className: "oui-size-4 oui-text-base-contrast-54 oui-transition-colors group-hover:oui-text-base-contrast-80" })
696
+ ]
697
+ }
698
+ );
699
+ };
700
+ var NetworkTokenSelect = ({
701
+ selectedNetwork,
702
+ selectedToken,
703
+ onNetworkChange,
704
+ onTokenChange,
705
+ networkOptions,
706
+ tokenOptions
707
+ }) => {
708
+ const { t: t0 } = useTranslation();
709
+ const t = t0;
710
+ const selectContentProps = {
711
+ align: "end",
712
+ sideOffset: -4,
713
+ className: "oui-custom-scrollbar"
714
+ };
715
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
716
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
717
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.network") }),
718
+ /* @__PURE__ */ jsx(Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsx(
719
+ Select,
720
+ {
721
+ size: "xs",
722
+ value: selectedNetwork || void 0,
723
+ onValueChange: onNetworkChange,
724
+ placeholder: t("transfer.exclusiveDeposit.selectNetwork"),
725
+ variant: "text",
726
+ classNames: { trigger: "oui-pr-0" },
727
+ maxHeight: 128,
728
+ contentProps: selectContentProps,
729
+ children: networkOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
730
+ /* @__PURE__ */ jsx(ChainIcon, { chainId: opt.chainId, size: "2xs" }),
731
+ opt.label
732
+ ] }) }, opt.value))
733
+ }
734
+ ) })
735
+ ] }),
736
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
737
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("common.token") }),
738
+ /* @__PURE__ */ jsx(Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsx(
739
+ Select,
740
+ {
741
+ size: "xs",
742
+ value: selectedToken || void 0,
743
+ onValueChange: onTokenChange,
744
+ placeholder: t("transfer.exclusiveDeposit.selectToken"),
745
+ variant: "text",
746
+ classNames: { trigger: "oui-pr-0" },
747
+ maxHeight: 128,
748
+ contentProps: selectContentProps,
749
+ children: tokenOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, itemAlign: "center", children: [
750
+ /* @__PURE__ */ jsx(TokenIcon, { name: opt.value, size: "2xs" }),
751
+ opt.label
752
+ ] }) }, opt.value))
753
+ }
754
+ ) })
755
+ ] })
756
+ ] });
757
+ };
758
+ var QRCodeDisplay = ({ address }) => {
759
+ 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" }) }) });
760
+ };
761
+ var QRCodeCanvas = ({ width, height, content }) => {
762
+ const canvasRef = useRef(null);
763
+ useEffect(() => {
764
+ if (!canvasRef.current || !content) return;
765
+ const qrcode$1 = qrcode(content);
766
+ const ctx = canvasRef.current.getContext("2d");
767
+ const cells = qrcode$1.modules;
768
+ const tileW = width / cells.length;
769
+ const tileH = height / cells.length;
770
+ for (let r = 0; r < cells.length; ++r) {
771
+ const row = cells[r];
772
+ for (let c = 0; c < row.length; ++c) {
773
+ ctx.fillStyle = row[c] ? "#000" : "#fff";
774
+ const w = Math.ceil((c + 1) * tileW) - Math.floor(c * tileW);
775
+ const h = Math.ceil((r + 1) * tileH) - Math.floor(r * tileH);
776
+ ctx.fillRect(Math.round(c * tileW), Math.round(r * tileH), w, h);
777
+ }
778
+ }
779
+ }, [content, width, height]);
780
+ return /* @__PURE__ */ jsx("canvas", { width, height, ref: canvasRef });
781
+ };
782
+ var WarningBanner = ({ message }) => {
783
+ return /* @__PURE__ */ jsxs(
784
+ Flex,
785
+ {
786
+ itemAlign: "start",
787
+ gap: 1,
788
+ 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]",
789
+ children: [
790
+ /* @__PURE__ */ jsx(Box, { className: "oui-mt-0.5", children: /* @__PURE__ */ jsx(WarningIcon, { width: 16, height: 16 }) }),
791
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 80, className: "oui-w-full oui-text-[#FF7D00]", children: message })
792
+ ]
793
+ }
794
+ );
795
+ };
796
+ var buildExplorerUrl = (baseUrl, txId) => {
797
+ const url = baseUrl;
798
+ if (url.endsWith("/")) {
799
+ return `${url}tx/${txId}`;
800
+ }
801
+ return `${url}/tx/${txId}`;
802
+ };
803
+ var useExclusiveDeposit = (options2) => {
804
+ const active = options2.active ?? true;
805
+ const confirmed = options2.confirmed ?? true;
806
+ const { chainId, token, explorerBaseUrl } = options2;
807
+ const { t: t0 } = useTranslation();
808
+ const t = t0;
809
+ const receiverAddressKey = confirmed && chainId && token ? `/v1/client/asset/receiver_address?chain_id=${chainId}&token=${token}` : null;
810
+ const receiverEventsKey = active && confirmed ? "/v1/client/asset/receiver_events" : null;
811
+ const {
812
+ data: addressData,
813
+ isLoading: isAddressLoading,
814
+ error: addressError
815
+ } = usePrivateQuery(receiverAddressKey, {
816
+ revalidateOnFocus: false
817
+ });
818
+ const {
819
+ data: eventsData,
820
+ isLoading: isEventsLoading,
821
+ error: eventsError
822
+ } = usePrivateQuery(receiverEventsKey, {
823
+ refreshInterval: active ? 1e4 : 0,
824
+ revalidateOnFocus: false
825
+ });
826
+ const { latestEvent, pendingCount, explorerUrl } = useMemo(() => {
827
+ const events = eventsData ?? [];
828
+ if (!events.length) {
829
+ return {
830
+ latestEvent: void 0,
831
+ pendingCount: 0,
832
+ explorerUrl: void 0
833
+ };
834
+ }
835
+ const latest = events.reduce((acc, curr) => {
836
+ if (!acc) return curr;
837
+ return curr.created_time > acc.created_time ? curr : acc;
838
+ }, void 0);
839
+ const count = events.length;
840
+ const url = latest?.tx_id ? buildExplorerUrl(explorerBaseUrl, latest.tx_id) : void 0;
841
+ return {
842
+ latestEvent: latest,
843
+ pendingCount: count,
844
+ explorerUrl: url
845
+ };
846
+ }, [explorerBaseUrl, eventsData]);
847
+ return {
848
+ address: addressData?.receiver_address,
849
+ qrUri: addressData?.receiver_address,
850
+ minimumDeposit: addressData?.minimum_deposit,
851
+ estimatedArrivalText: t("transfer.exclusiveDeposit.estimatedTime.default"),
852
+ latestEvent,
853
+ pendingCount,
854
+ explorerUrl,
855
+ isAddressLoading,
856
+ isEventsLoading,
857
+ addressError,
858
+ eventsError
859
+ };
860
+ };
861
+ var useExclusiveDepositOptions = (params) => {
862
+ const networkId = useConfig("networkId");
863
+ const tokensInfo = useTokensInfo();
864
+ const selectedNetwork = params?.selectedNetwork;
865
+ const [, { findByChainId }] = useChains(networkId, {
866
+ pick: "network_infos"
867
+ });
868
+ const combos = useMemo(() => {
869
+ if (!tokensInfo?.length) return [];
870
+ const result = [];
871
+ for (const token of tokensInfo) {
872
+ for (const detail of token.chain_details ?? []) {
873
+ if (detail.exclusive_deposit_supported === true) {
874
+ const chainId = Number(detail.chain_id);
875
+ const chain = findByChainId(chainId);
876
+ result.push({
877
+ chainId,
878
+ chainName: chain?.network_infos?.name ?? `Chain ${chainId}`,
879
+ explorerUrl: chain?.network_infos?.explorer_base_url ?? "",
880
+ tokenSymbol: token.token
881
+ });
882
+ }
883
+ }
884
+ }
885
+ return result;
886
+ }, [tokensInfo, findByChainId]);
887
+ const networkOptions = useMemo(() => {
888
+ const seen = /* @__PURE__ */ new Map();
889
+ for (const combo of combos) {
890
+ if (!seen.has(combo.chainId)) {
891
+ seen.set(combo.chainId, {
892
+ label: combo.chainName,
893
+ value: String(combo.chainId),
894
+ chainId: combo.chainId,
895
+ explorerUrl: combo.explorerUrl
896
+ });
897
+ }
898
+ }
899
+ const list = Array.from(seen.values());
900
+ list.sort((a, b) => {
901
+ if (a.chainId === 42161) return -1;
902
+ if (b.chainId === 42161) return 1;
903
+ return 0;
904
+ });
905
+ return list;
906
+ }, [combos]);
907
+ const tokenOptions = useMemo(() => {
908
+ if (!selectedNetwork) return [];
909
+ const chainId = Number(selectedNetwork);
910
+ const seen = /* @__PURE__ */ new Set();
911
+ const result = [];
912
+ for (const combo of combos) {
913
+ if (combo.chainId === chainId && !seen.has(combo.tokenSymbol)) {
914
+ seen.add(combo.tokenSymbol);
915
+ result.push({ label: combo.tokenSymbol, value: combo.tokenSymbol });
916
+ }
917
+ }
918
+ result.sort((a, b) => {
919
+ if (a.value === "USDC") return -1;
920
+ if (b.value === "USDC") return 1;
921
+ return 0;
922
+ });
923
+ return result;
924
+ }, [combos, selectedNetwork]);
925
+ const isSupported = combos.length > 0;
926
+ return { networkOptions, tokenOptions, isSupported };
927
+ };
928
+ var ExclusiveDeposit = ({ active }) => {
929
+ const { t: t0 } = useTranslation();
930
+ const t = t0;
931
+ const [selectedNetwork, setSelectedNetwork] = useState("");
932
+ const [selectedToken, setSelectedToken] = useState("");
933
+ const { networkOptions, tokenOptions} = useExclusiveDepositOptions({
934
+ selectedNetwork
935
+ });
936
+ const confirmed = !!selectedNetwork && !!selectedToken;
937
+ useEffect(() => {
938
+ if (selectedToken && tokenOptions.length > 0 && !tokenOptions.some((t2) => t2.value === selectedToken)) {
939
+ setSelectedToken("");
940
+ }
941
+ }, [selectedNetwork, selectedToken, tokenOptions]);
942
+ const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
943
+ const selectedChainId = selectedNetworkOption?.chainId;
944
+ const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
945
+ const {
946
+ address,
947
+ qrUri,
948
+ minimumDeposit,
949
+ estimatedArrivalText,
950
+ latestEvent,
951
+ pendingCount,
952
+ explorerUrl
953
+ } = useExclusiveDeposit({
954
+ active,
955
+ confirmed,
956
+ chainId: selectedChainId,
957
+ token: selectedToken,
958
+ explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
959
+ });
960
+ const networkName = selectedNetworkOption?.label ?? "";
961
+ const tokenName = selectedTokenOption?.label ?? "";
962
+ const warningMessage = confirmed ? t("transfer.exclusiveDeposit.warning", {
963
+ token: tokenName,
964
+ network: networkName
965
+ }) : t("transfer.exclusiveDeposit.selectFirst");
966
+ const minText = confirmed && typeof minimumDeposit === "number" ? `${minimumDeposit} ${tokenName}` : "--";
967
+ const estText = confirmed ? estimatedArrivalText ?? t("transfer.exclusiveDeposit.estimatedTime.default") : "--";
968
+ 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: [
969
+ /* @__PURE__ */ jsx(WarningBanner, { message: warningMessage }),
970
+ confirmed && /* @__PURE__ */ jsxs(Fragment, { children: [
971
+ /* @__PURE__ */ jsx(QRCodeDisplay, { address: qrUri }),
972
+ address && /* @__PURE__ */ jsx(CopyAddress, { address })
973
+ ] }),
974
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
975
+ /* @__PURE__ */ jsx(
976
+ NetworkTokenSelect,
977
+ {
978
+ selectedNetwork,
979
+ selectedToken,
980
+ onNetworkChange: (value) => {
981
+ setSelectedNetwork(value);
982
+ setSelectedToken("");
983
+ },
984
+ onTokenChange: setSelectedToken,
985
+ networkOptions,
986
+ tokenOptions
987
+ },
988
+ selectedNetwork
989
+ ),
990
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", children: [
991
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
992
+ /* @__PURE__ */ jsx(
993
+ Text,
994
+ {
995
+ size: "xs",
996
+ className: confirmed ? "oui-text-[#FF7D00]" : "",
997
+ intensity: confirmed ? void 0 : 98,
998
+ children: minText
999
+ }
1000
+ )
1001
+ ] }),
1002
+ /* @__PURE__ */ jsxs(Flex, { className: "oui-w-full", justify: "between", children: [
1003
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.estimatedTime") }),
1004
+ /* @__PURE__ */ jsx(Text, { size: "xs", intensity: 98, children: estText })
1005
+ ] })
1006
+ ] }),
1007
+ confirmed && latestEvent && explorerUrl && /* @__PURE__ */ jsx(
1008
+ DepositStatusBlock,
1009
+ {
1010
+ amount: latestEvent.amount,
1011
+ symbol: latestEvent.token,
1012
+ pendingCount,
1013
+ explorerUrl
1014
+ }
1015
+ )
1016
+ ] });
1017
+ };
599
1018
  var Fee = (props) => {
600
1019
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
601
1020
  const { t } = useTranslation();
@@ -1520,7 +1939,10 @@ var DepositForm = (props) => {
1520
1939
  showSourceDepositCap,
1521
1940
  showTargetDepositCap,
1522
1941
  slippageValidate,
1523
- quantityNotional
1942
+ quantityNotional,
1943
+ activeSubTab,
1944
+ setActiveSubTab,
1945
+ showExclusiveDeposit
1524
1946
  } = props;
1525
1947
  const { t } = useTranslation();
1526
1948
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsx(
@@ -1581,101 +2003,129 @@ var DepositForm = (props) => {
1581
2003
  /* @__PURE__ */ jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1582
2004
  ] });
1583
2005
  };
1584
- return /* @__PURE__ */ jsxs(Box, { id: "oui-deposit-form", className: textVariants({ weight: "semibold" }), children: [
1585
- /* @__PURE__ */ jsxs(Box, { className: "oui-mb-6 lg:oui-mb-8", children: [
1586
- /* @__PURE__ */ jsx(Web3Wallet, {}),
1587
- /* @__PURE__ */ jsxs(Box, { mt: 3, mb: 1, children: [
1588
- /* @__PURE__ */ jsx(
1589
- ChainSelect,
2006
+ return /* @__PURE__ */ jsx(Box, { id: "oui-deposit-form", className: textVariants({ weight: "semibold" }), children: /* @__PURE__ */ jsxs(
2007
+ Tabs,
2008
+ {
2009
+ value: activeSubTab,
2010
+ onValueChange: (value) => setActiveSubTab(value),
2011
+ variant: "contained",
2012
+ classNames: {
2013
+ tabsList: "oui-w-fit"
2014
+ },
2015
+ children: [
2016
+ /* @__PURE__ */ jsxs(
2017
+ TabPanel,
1590
2018
  {
1591
- chains,
1592
- value: currentChain,
1593
- onValueChange: onChainChange,
1594
- wrongNetwork,
1595
- loading: settingChain,
1596
- disabled: !props.isLoggedIn
2019
+ title: t("transfer.deposit.tab.connectedWallet"),
2020
+ value: "web3",
2021
+ children: [
2022
+ /* @__PURE__ */ jsxs(Box, { className: "oui-mt-3", children: [
2023
+ /* @__PURE__ */ jsx(Web3Wallet, {}),
2024
+ /* @__PURE__ */ jsxs(Box, { mt: 3, mb: 1, children: [
2025
+ /* @__PURE__ */ jsx(
2026
+ ChainSelect,
2027
+ {
2028
+ chains,
2029
+ value: currentChain,
2030
+ onValueChange: onChainChange,
2031
+ wrongNetwork,
2032
+ loading: settingChain,
2033
+ disabled: !props.isLoggedIn
2034
+ }
2035
+ ),
2036
+ /* @__PURE__ */ jsx(
2037
+ QuantityInput,
2038
+ {
2039
+ "data-testId": "oui-testid-deposit-dialog-quantity-input",
2040
+ classNames: {
2041
+ root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
2042
+ },
2043
+ value: quantity,
2044
+ onValueChange: onQuantityChange,
2045
+ token: sourceToken,
2046
+ tokens: sourceTokens,
2047
+ onTokenChange: onSourceTokenChange,
2048
+ status: inputStatus,
2049
+ hintMessage,
2050
+ tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
2051
+ tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
2052
+ disabled: !props.isLoggedIn,
2053
+ balancesRevalidating: batchBalancesRevalidating,
2054
+ showBalance: true
2055
+ }
2056
+ )
2057
+ ] }),
2058
+ /* @__PURE__ */ jsx(
2059
+ AvailableQuantity,
2060
+ {
2061
+ token: sourceToken,
2062
+ quantity,
2063
+ maxQuantity,
2064
+ notional: quantityNotional,
2065
+ loading: balanceRevalidating,
2066
+ onClick: () => {
2067
+ onQuantityChange(maxDepositAmount);
2068
+ }
2069
+ }
2070
+ ),
2071
+ /* @__PURE__ */ jsx(
2072
+ YieldBearingReminder,
2073
+ {
2074
+ symbol: targetToken?.symbol,
2075
+ className: "oui-mt-3"
2076
+ }
2077
+ ),
2078
+ /* @__PURE__ */ jsx(ExchangeDivider, {}),
2079
+ /* @__PURE__ */ jsx(BrokerWallet, {}),
2080
+ /* @__PURE__ */ jsx(
2081
+ QuantityInput,
2082
+ {
2083
+ classNames: {
2084
+ root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
2085
+ },
2086
+ token: targetToken,
2087
+ tokens: targetTokens,
2088
+ onTokenChange: onTargetTokenChange,
2089
+ value: targetQuantity,
2090
+ loading: targetQuantityLoading,
2091
+ disabled: !props.isLoggedIn,
2092
+ readOnly: true,
2093
+ status: targetInputStatus,
2094
+ hintMessage: targetHintMessage,
2095
+ tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
2096
+ tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
2097
+ }
2098
+ ),
2099
+ renderContent()
2100
+ ] }),
2101
+ /* @__PURE__ */ jsx(Box, { className: "oui-mb-6 lg:oui-mb-8", children: /* @__PURE__ */ jsx(Notice, { message: warningMessage, wrongNetwork }) }),
2102
+ /* @__PURE__ */ jsx(Flex, { justify: "center", children: /* @__PURE__ */ jsx(
2103
+ ActionButton,
2104
+ {
2105
+ actionType,
2106
+ symbol: sourceToken?.symbol,
2107
+ disabled,
2108
+ loading,
2109
+ onDeposit,
2110
+ onApprove,
2111
+ onApproveAndDeposit,
2112
+ networkId
2113
+ }
2114
+ ) })
2115
+ ]
1597
2116
  }
1598
2117
  ),
1599
- /* @__PURE__ */ jsx(
1600
- QuantityInput,
2118
+ showExclusiveDeposit && /* @__PURE__ */ jsx(
2119
+ TabPanel,
1601
2120
  {
1602
- "data-testId": "oui-testid-deposit-dialog-quantity-input",
1603
- classNames: {
1604
- root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
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
2121
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2122
+ value: "exclusive_deposit",
2123
+ children: /* @__PURE__ */ jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1618
2124
  }
1619
2125
  )
1620
- ] }),
1621
- /* @__PURE__ */ jsx(
1622
- AvailableQuantity,
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
- ] });
2126
+ ]
2127
+ }
2128
+ ) });
1679
2129
  };
1680
2130
  function useActionType(options2) {
1681
2131
  const { allowance, quantity, maxQuantity } = options2;
@@ -1991,7 +2441,7 @@ function useDepositFee(options2) {
1991
2441
  }
1992
2442
  var useMaxDepositAmount = (sourceToken, balance) => {
1993
2443
  const maxDepositAmount = useMemo(() => {
1994
- const balanceDecimal = new Decimal(balance || 0).todp(
2444
+ const balanceDecimal = new Decimal(balance).todp(
1995
2445
  sourceToken?.precision ?? 2,
1996
2446
  Decimal.ROUND_DOWN
1997
2447
  );
@@ -2022,7 +2472,7 @@ var useDepositFormQuantities = ({
2022
2472
  getIndexPrice
2023
2473
  }) => {
2024
2474
  const maxQuantity = useMemo(
2025
- () => new Decimal(balance || 0).todp(sourceToken?.precision ?? 2, Decimal.ROUND_DOWN).toString(),
2475
+ () => new Decimal(balance).todp(sourceToken?.precision ?? 2, Decimal.ROUND_DOWN).toString(),
2026
2476
  [balance, sourceToken?.precision]
2027
2477
  );
2028
2478
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2480,9 +2930,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2480
2930
  logo_uri: item.logoURI
2481
2931
  }));
2482
2932
  }, [data]);
2483
- if (!enableSwapDeposit) {
2484
- return [];
2485
- }
2486
2933
  return tokens;
2487
2934
  };
2488
2935
 
@@ -3777,7 +4224,7 @@ var useDepositFormScript = (options2) => {
3777
4224
  } = useDepositFormQuantities({
3778
4225
  sourceToken,
3779
4226
  targetToken,
3780
- balance,
4227
+ balance: balance || "0",
3781
4228
  quantity,
3782
4229
  needSwap,
3783
4230
  swapQuantity,
@@ -3864,6 +4311,8 @@ var useDepositFormScript = (options2) => {
3864
4311
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3865
4312
  const targetQuantityLoading = swapPriceRevalidating;
3866
4313
  const warningMessage = validationMessage || swapErrorMessage;
4314
+ const [activeSubTab, setActiveSubTab] = useState("web3");
4315
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== ChainNamespace.solana;
3867
4316
  return {
3868
4317
  sourceToken,
3869
4318
  targetToken,
@@ -3917,7 +4366,10 @@ var useDepositFormScript = (options2) => {
3917
4366
  isLoggedIn,
3918
4367
  showSourceDepositCap,
3919
4368
  showTargetDepositCap,
3920
- quantityNotional
4369
+ quantityNotional,
4370
+ activeSubTab,
4371
+ setActiveSubTab,
4372
+ showExclusiveDeposit
3921
4373
  };
3922
4374
  };
3923
4375
  var DepositFormWidget = (props) => {
@@ -5989,10 +6441,14 @@ var WithdrawSlot = (props) => {
5989
6441
  var DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
5990
6442
  var DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
5991
6443
  var DepositAndWithdraw = (props) => {
6444
+ const { extraTabs = [] } = props;
5992
6445
  const [activeTab, setActiveTab] = useState(
5993
6446
  props.activeTab || "deposit"
5994
6447
  );
5995
6448
  const { t } = useTranslation();
6449
+ const sortedExtra = [...extraTabs].sort(
6450
+ (a, b) => (a.order ?? 100) - (b.order ?? 100)
6451
+ );
5996
6452
  return /* @__PURE__ */ jsxs(
5997
6453
  Tabs,
5998
6454
  {
@@ -6022,18 +6478,39 @@ var DepositAndWithdraw = (props) => {
6022
6478
  value: "withdraw",
6023
6479
  children: /* @__PURE__ */ jsx(WithdrawSlot, { close: props.close })
6024
6480
  }
6025
- )
6481
+ ),
6482
+ sortedExtra.map((tab) => /* @__PURE__ */ jsx(
6483
+ TabPanel,
6484
+ {
6485
+ title: tab.title,
6486
+ icon: isValidElement(tab.icon) ? tab.icon : void 0,
6487
+ value: tab.id,
6488
+ children: /* @__PURE__ */ jsx(tab.component, { close: props.close })
6489
+ },
6490
+ tab.id
6491
+ ))
6026
6492
  ]
6027
6493
  }
6028
6494
  );
6029
6495
  };
6030
- registerSimpleDialog(DepositAndWithdrawWithDialogId, DepositAndWithdraw, {
6031
- size: "md",
6032
- classNames: {
6033
- content: "oui-border oui-border-line-6"
6496
+ var InjectableDepositAndWithdraw = injectable(
6497
+ DepositAndWithdraw,
6498
+ "Transfer.DepositAndWithdraw"
6499
+ );
6500
+ registerSimpleDialog(
6501
+ DepositAndWithdrawWithDialogId,
6502
+ InjectableDepositAndWithdraw,
6503
+ {
6504
+ size: "md",
6505
+ classNames: {
6506
+ content: "oui-border oui-border-line-6"
6507
+ }
6034
6508
  }
6035
- });
6036
- registerSimpleSheet(DepositAndWithdrawWithSheetId, DepositAndWithdraw);
6509
+ );
6510
+ registerSimpleSheet(
6511
+ DepositAndWithdrawWithSheetId,
6512
+ InjectableDepositAndWithdraw
6513
+ );
6037
6514
  var AccountSelect = (props) => {
6038
6515
  const { subAccounts = [], value } = props;
6039
6516
  const [open, setOpen] = useState(false);
@@ -7871,6 +8348,6 @@ var DepositStatusWidget = (props) => {
7871
8348
  return /* @__PURE__ */ jsx(DepositStatus, { ...state, ...props });
7872
8349
  };
7873
8350
 
7874
- export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, ConvertFormUI, ConvertFormWidget, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, DepositFormWidget, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, WithdrawFormWidget, WithdrawTo, YIELD_BEARING_ASSETS, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
8351
+ export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, ConvertFormUI, ConvertFormWidget, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, DepositFormWidget, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, InjectableDepositAndWithdraw, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, WithdrawFormWidget, WithdrawTo, YIELD_BEARING_ASSETS, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
7875
8352
  //# sourceMappingURL=index.mjs.map
7876
8353
  //# sourceMappingURL=index.mjs.map