@orderly.network/ui-transfer 3.0.0-beta.1 → 3.0.0-beta.2

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.js CHANGED
@@ -9,6 +9,7 @@ var jsxRuntime = require('react/jsx-runtime');
9
9
  var types = require('@orderly.network/types');
10
10
  var uiConnector = require('@orderly.network/ui-connector');
11
11
  var reactApp = require('@orderly.network/react-app');
12
+ var qr = require('@akamfoad/qr');
12
13
  var perp = require('@orderly.network/perp');
13
14
  var core = require('@orderly.network/core');
14
15
  var uiChainSelector = require('@orderly.network/ui-chain-selector');
@@ -599,6 +600,392 @@ var ExchangeDivider = ({ icon }) => {
599
600
  /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
600
601
  ] });
601
602
  };
603
+ var CopyIcon = ({ copied }) => /* @__PURE__ */ jsxRuntime.jsx(
604
+ "svg",
605
+ {
606
+ width: "17",
607
+ height: "16",
608
+ viewBox: "0 0 17 16",
609
+ fill: "currentColor",
610
+ xmlns: "http://www.w3.org/2000/svg",
611
+ className: `oui-fill-base-contrast oui-text-base-contrast-54 ${copied ? "oui-fill-success oui-text-success" : ""}`,
612
+ children: copied ? /* @__PURE__ */ jsxRuntime.jsx(
613
+ "path",
614
+ {
615
+ d: "M14 4L6 11.5L3 8.5",
616
+ fill: "none",
617
+ stroke: "currentColor",
618
+ strokeWidth: "2",
619
+ strokeLinecap: "round",
620
+ strokeLinejoin: "round"
621
+ }
622
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
623
+ "path",
624
+ {
625
+ 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",
626
+ fill: "currentColor"
627
+ }
628
+ )
629
+ }
630
+ );
631
+ var CopyAddress = ({ address }) => {
632
+ const [copied, setCopied] = react.useState(false);
633
+ const handleCopy = () => {
634
+ navigator.clipboard.writeText(address);
635
+ setCopied(true);
636
+ setTimeout(() => setCopied(false), 2e3);
637
+ };
638
+ return /* @__PURE__ */ jsxRuntime.jsxs(
639
+ ui.Flex,
640
+ {
641
+ gap: 1,
642
+ itemAlign: "start",
643
+ className: "oui-mt-6 oui-w-full oui-cursor-pointer oui-justify-center",
644
+ onClick: handleCopy,
645
+ children: [
646
+ /* @__PURE__ */ jsxRuntime.jsx(
647
+ ui.Text,
648
+ {
649
+ size: "xs",
650
+ className: "oui-break-all oui-text-center oui-text-base-contrast-80",
651
+ title: address,
652
+ children: address
653
+ }
654
+ ),
655
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mt-0.5 oui-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, { copied }) })
656
+ ]
657
+ }
658
+ );
659
+ };
660
+ var DepositStatusBlock = ({
661
+ amount,
662
+ symbol = "USDC",
663
+ pendingCount,
664
+ explorerUrl
665
+ }) => {
666
+ const { t: t0 } = i18n.useTranslation();
667
+ const t = t0;
668
+ const label = t("transfer.exclusiveDeposit.depositPending", {
669
+ amount,
670
+ symbol
671
+ });
672
+ const handleClick = () => {
673
+ window.open(explorerUrl, "_blank", "noopener,noreferrer");
674
+ };
675
+ return /* @__PURE__ */ jsxRuntime.jsxs(
676
+ ui.Flex,
677
+ {
678
+ itemAlign: "center",
679
+ gap: 2,
680
+ className: "oui-group oui-mt-6 oui-w-full oui-cursor-pointer",
681
+ onClick: handleClick,
682
+ children: [
683
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "oui-size-2 oui-shrink-0 oui-rounded-full oui-bg-primary" }),
684
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, className: "oui-flex-1", children: label }),
685
+ pendingCount > 1 && /* @__PURE__ */ jsxRuntime.jsx(
686
+ ui.Flex,
687
+ {
688
+ justify: "center",
689
+ itemAlign: "center",
690
+ r: "full",
691
+ width: 18,
692
+ height: 18,
693
+ className: "oui-bg-line-12",
694
+ children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "3xs", intensity: 80, children: pendingCount })
695
+ }
696
+ ),
697
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ChevronRightIcon, { className: "oui-size-4 oui-text-base-contrast-54 oui-transition-colors group-hover:oui-text-base-contrast-80" })
698
+ ]
699
+ }
700
+ );
701
+ };
702
+ var NetworkTokenSelect = ({
703
+ selectedNetwork,
704
+ selectedToken,
705
+ onNetworkChange,
706
+ onTokenChange,
707
+ networkOptions,
708
+ tokenOptions
709
+ }) => {
710
+ const { t: t0 } = i18n.useTranslation();
711
+ const t = t0;
712
+ const selectContentProps = {
713
+ align: "end",
714
+ sideOffset: -4,
715
+ className: "oui-custom-scrollbar"
716
+ };
717
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
718
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
719
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.network") }),
720
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
721
+ ui.Select,
722
+ {
723
+ size: "xs",
724
+ value: selectedNetwork || void 0,
725
+ onValueChange: onNetworkChange,
726
+ placeholder: t("transfer.exclusiveDeposit.selectNetwork"),
727
+ variant: "text",
728
+ classNames: { trigger: "oui-pr-0" },
729
+ maxHeight: 128,
730
+ contentProps: selectContentProps,
731
+ children: networkOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
732
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ChainIcon, { chainId: opt.chainId, size: "2xs" }),
733
+ opt.label
734
+ ] }) }, opt.value))
735
+ }
736
+ ) })
737
+ ] }),
738
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
739
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.token") }),
740
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
741
+ ui.Select,
742
+ {
743
+ size: "xs",
744
+ value: selectedToken || void 0,
745
+ onValueChange: onTokenChange,
746
+ placeholder: t("transfer.exclusiveDeposit.selectToken"),
747
+ variant: "text",
748
+ classNames: { trigger: "oui-pr-0" },
749
+ maxHeight: 128,
750
+ contentProps: selectContentProps,
751
+ children: tokenOptions.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: opt.value, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
752
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TokenIcon, { name: opt.value, size: "2xs" }),
753
+ opt.label
754
+ ] }) }, opt.value))
755
+ }
756
+ ) })
757
+ ] })
758
+ ] });
759
+ };
760
+ var QRCodeDisplay = ({ address }) => {
761
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { direction: "column", className: "oui-mt-5 oui-w-full", itemAlign: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.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__ */ jsxRuntime.jsx(QRCodeCanvas, { width: 124, height: 124, content: address }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-size-full oui-border-8 oui-border-dashed oui-border-black oui-opacity-50" }) }) });
762
+ };
763
+ var QRCodeCanvas = ({ width, height, content }) => {
764
+ const canvasRef = react.useRef(null);
765
+ react.useEffect(() => {
766
+ if (!canvasRef.current || !content) return;
767
+ const qrcode = qr.qrcode(content);
768
+ const ctx = canvasRef.current.getContext("2d");
769
+ const cells = qrcode.modules;
770
+ const tileW = width / cells.length;
771
+ const tileH = height / cells.length;
772
+ for (let r = 0; r < cells.length; ++r) {
773
+ const row = cells[r];
774
+ for (let c = 0; c < row.length; ++c) {
775
+ ctx.fillStyle = row[c] ? "#000" : "#fff";
776
+ const w = Math.ceil((c + 1) * tileW) - Math.floor(c * tileW);
777
+ const h = Math.ceil((r + 1) * tileH) - Math.floor(r * tileH);
778
+ ctx.fillRect(Math.round(c * tileW), Math.round(r * tileH), w, h);
779
+ }
780
+ }
781
+ }, [content, width, height]);
782
+ return /* @__PURE__ */ jsxRuntime.jsx("canvas", { width, height, ref: canvasRef });
783
+ };
784
+ var WarningBanner = ({ message }) => {
785
+ return /* @__PURE__ */ jsxRuntime.jsxs(
786
+ ui.Flex,
787
+ {
788
+ itemAlign: "start",
789
+ gap: 1,
790
+ 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]",
791
+ children: [
792
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mt-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(ui.WarningIcon, { width: 16, height: 16 }) }),
793
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 80, className: "oui-w-full oui-text-[#FF7D00]", children: message })
794
+ ]
795
+ }
796
+ );
797
+ };
798
+ var buildExplorerUrl = (baseUrl, txId) => {
799
+ const url = baseUrl;
800
+ if (url.endsWith("/")) {
801
+ return `${url}tx/${txId}`;
802
+ }
803
+ return `${url}/tx/${txId}`;
804
+ };
805
+ var useExclusiveDeposit = (options2) => {
806
+ const active = options2.active ?? true;
807
+ const confirmed = options2.confirmed ?? true;
808
+ const { chainId, explorerBaseUrl } = options2;
809
+ const { t: t0 } = i18n.useTranslation();
810
+ const t = t0;
811
+ const receiverAddressKey = confirmed && chainId ? `/v1/client/asset/receiver_address?chain_id=${chainId}` : null;
812
+ const receiverEventsKey = active && confirmed ? "/v1/client/asset/receiver_events" : null;
813
+ const {
814
+ data: addressData,
815
+ isLoading: isAddressLoading,
816
+ error: addressError
817
+ } = hooks.usePrivateQuery(receiverAddressKey, {
818
+ revalidateOnFocus: false
819
+ });
820
+ const {
821
+ data: eventsData,
822
+ isLoading: isEventsLoading,
823
+ error: eventsError
824
+ } = hooks.usePrivateQuery(receiverEventsKey, {
825
+ refreshInterval: active ? 1e4 : 0,
826
+ revalidateOnFocus: false
827
+ });
828
+ const { latestEvent, pendingCount, explorerUrl } = react.useMemo(() => {
829
+ const events = eventsData ?? [];
830
+ if (!events.length) {
831
+ return {
832
+ latestEvent: void 0,
833
+ pendingCount: 0,
834
+ explorerUrl: void 0
835
+ };
836
+ }
837
+ const latest = events.reduce((acc, curr) => {
838
+ if (!acc) return curr;
839
+ return curr.created_time > acc.created_time ? curr : acc;
840
+ }, void 0);
841
+ const count = events.length;
842
+ const url = latest?.tx_id ? buildExplorerUrl(explorerBaseUrl, latest.tx_id) : void 0;
843
+ return {
844
+ latestEvent: latest,
845
+ pendingCount: count,
846
+ explorerUrl: url
847
+ };
848
+ }, [explorerBaseUrl, eventsData]);
849
+ return {
850
+ address: addressData?.receiver_address,
851
+ qrUri: addressData?.receiver_address,
852
+ minimumDeposit: addressData?.minimum_deposit,
853
+ estimatedArrivalText: t("transfer.exclusiveDeposit.estimatedTime.default"),
854
+ latestEvent,
855
+ pendingCount,
856
+ explorerUrl,
857
+ isAddressLoading,
858
+ isEventsLoading,
859
+ addressError,
860
+ eventsError
861
+ };
862
+ };
863
+ var SUPPORTED_CHAINS = {
864
+ prod: [42161],
865
+ testnet: [421614]
866
+ };
867
+ var SUPPORTED_TOKENS = ["USDC"];
868
+ var useExclusiveDepositOptions = () => {
869
+ const env = hooks.useConfig("env");
870
+ const networkId = hooks.useConfig("networkId");
871
+ const [chains, { findByChainId }] = hooks.useChains(networkId, {
872
+ pick: "network_infos"
873
+ });
874
+ const supportedChainIds = env === "prod" ? SUPPORTED_CHAINS.prod : SUPPORTED_CHAINS.testnet;
875
+ const networkOptions = react.useMemo(() => {
876
+ return supportedChainIds.map((chainId) => {
877
+ const chain = findByChainId(chainId);
878
+ const name = chain?.network_infos?.name ?? `Chain ${chainId}`;
879
+ const explorerUrl = chain?.network_infos?.explorer_base_url ?? "";
880
+ return {
881
+ label: name,
882
+ value: String(chainId),
883
+ chainId,
884
+ explorerUrl
885
+ };
886
+ });
887
+ }, [supportedChainIds, findByChainId]);
888
+ const tokenOptions = react.useMemo(() => {
889
+ return SUPPORTED_TOKENS.map((symbol) => ({
890
+ label: symbol,
891
+ value: symbol
892
+ }));
893
+ }, []);
894
+ return { networkOptions, tokenOptions };
895
+ };
896
+ var ExclusiveDeposit = ({ active }) => {
897
+ const { t: t0 } = i18n.useTranslation();
898
+ const t = t0;
899
+ const [selectedNetwork, setSelectedNetwork] = react.useState("");
900
+ const [selectedToken, setSelectedToken] = react.useState("");
901
+ const { networkOptions, tokenOptions } = useExclusiveDepositOptions();
902
+ const confirmed = !!selectedNetwork && !!selectedToken;
903
+ const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
904
+ const selectedChainId = selectedNetworkOption?.chainId;
905
+ const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
906
+ const {
907
+ address,
908
+ qrUri,
909
+ minimumDeposit,
910
+ estimatedArrivalText,
911
+ latestEvent,
912
+ pendingCount,
913
+ explorerUrl
914
+ } = useExclusiveDeposit({
915
+ active,
916
+ confirmed,
917
+ chainId: selectedChainId,
918
+ explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
919
+ });
920
+ const networkName = selectedNetworkOption?.label ?? "";
921
+ const tokenName = selectedTokenOption?.label ?? "";
922
+ const warningMessage = confirmed ? t("transfer.exclusiveDeposit.warning", {
923
+ token: tokenName,
924
+ network: networkName
925
+ }) : t("transfer.exclusiveDeposit.selectFirst");
926
+ const minText = confirmed && typeof minimumDeposit === "number" ? `${minimumDeposit} ${tokenName}` : "--";
927
+ const estText = confirmed ? estimatedArrivalText ?? t("transfer.exclusiveDeposit.estimatedTime.default") : "--";
928
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-flex oui-flex-col oui-items-center oui-rounded-xl oui-bg-base-8 oui-tracking-[0.03em]", children: [
929
+ /* @__PURE__ */ jsxRuntime.jsx(WarningBanner, { message: warningMessage }),
930
+ confirmed && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
931
+ /* @__PURE__ */ jsxRuntime.jsx(QRCodeDisplay, { address: qrUri }),
932
+ address && /* @__PURE__ */ jsxRuntime.jsx(CopyAddress, { address })
933
+ ] }),
934
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
935
+ confirmed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
936
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
937
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.network") }),
938
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
939
+ /* @__PURE__ */ jsxRuntime.jsx(ui.ChainIcon, { chainId: selectedChainId, size: "2xs" }),
940
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: networkName })
941
+ ] })
942
+ ] }),
943
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
944
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.token") }),
945
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
946
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TokenIcon, { name: tokenName, size: "2xs" }),
947
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: tokenName })
948
+ ] })
949
+ ] })
950
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
951
+ NetworkTokenSelect,
952
+ {
953
+ selectedNetwork,
954
+ selectedToken,
955
+ onNetworkChange: setSelectedNetwork,
956
+ onTokenChange: setSelectedToken,
957
+ networkOptions,
958
+ tokenOptions
959
+ }
960
+ ),
961
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
962
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
963
+ /* @__PURE__ */ jsxRuntime.jsx(
964
+ ui.Text,
965
+ {
966
+ size: "xs",
967
+ className: confirmed ? "oui-text-[#FF7D00]" : "",
968
+ intensity: confirmed ? void 0 : 98,
969
+ children: minText
970
+ }
971
+ )
972
+ ] }),
973
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
974
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.estimatedTime") }),
975
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: estText })
976
+ ] })
977
+ ] }),
978
+ confirmed && latestEvent && explorerUrl && /* @__PURE__ */ jsxRuntime.jsx(
979
+ DepositStatusBlock,
980
+ {
981
+ amount: latestEvent.amount,
982
+ symbol: latestEvent.token,
983
+ pendingCount,
984
+ explorerUrl
985
+ }
986
+ )
987
+ ] });
988
+ };
602
989
  var Fee = (props) => {
603
990
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
604
991
  const { t } = i18n.useTranslation();
@@ -1523,7 +1910,10 @@ var DepositForm = (props) => {
1523
1910
  showSourceDepositCap,
1524
1911
  showTargetDepositCap,
1525
1912
  slippageValidate,
1526
- quantityNotional
1913
+ quantityNotional,
1914
+ activeSubTab,
1915
+ setActiveSubTab,
1916
+ showExclusiveDeposit
1527
1917
  } = props;
1528
1918
  const { t } = i18n.useTranslation();
1529
1919
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -1584,101 +1974,129 @@ var DepositForm = (props) => {
1584
1974
  /* @__PURE__ */ jsxRuntime.jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1585
1975
  ] });
1586
1976
  };
1587
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { id: "oui-deposit-form", className: ui.textVariants({ weight: "semibold" }), children: [
1588
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-mb-6 lg:oui-mb-8", children: [
1589
- /* @__PURE__ */ jsxRuntime.jsx(Web3Wallet, {}),
1590
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { mt: 3, mb: 1, children: [
1591
- /* @__PURE__ */ jsxRuntime.jsx(
1592
- ChainSelect,
1977
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { id: "oui-deposit-form", className: ui.textVariants({ weight: "semibold" }), children: /* @__PURE__ */ jsxRuntime.jsxs(
1978
+ ui.Tabs,
1979
+ {
1980
+ value: activeSubTab,
1981
+ onValueChange: (value) => setActiveSubTab(value),
1982
+ variant: "contained",
1983
+ classNames: {
1984
+ tabsList: "oui-w-fit"
1985
+ },
1986
+ children: [
1987
+ /* @__PURE__ */ jsxRuntime.jsxs(
1988
+ ui.TabPanel,
1593
1989
  {
1594
- chains,
1595
- value: currentChain,
1596
- onValueChange: onChainChange,
1597
- wrongNetwork,
1598
- loading: settingChain,
1599
- disabled: !props.isLoggedIn
1990
+ title: t("transfer.deposit.tab.connectedWallet"),
1991
+ value: "web3",
1992
+ children: [
1993
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-mt-3", children: [
1994
+ /* @__PURE__ */ jsxRuntime.jsx(Web3Wallet, {}),
1995
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { mt: 3, mb: 1, children: [
1996
+ /* @__PURE__ */ jsxRuntime.jsx(
1997
+ ChainSelect,
1998
+ {
1999
+ chains,
2000
+ value: currentChain,
2001
+ onValueChange: onChainChange,
2002
+ wrongNetwork,
2003
+ loading: settingChain,
2004
+ disabled: !props.isLoggedIn
2005
+ }
2006
+ ),
2007
+ /* @__PURE__ */ jsxRuntime.jsx(
2008
+ QuantityInput,
2009
+ {
2010
+ "data-testId": "oui-testid-deposit-dialog-quantity-input",
2011
+ classNames: {
2012
+ root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
2013
+ },
2014
+ value: quantity,
2015
+ onValueChange: onQuantityChange,
2016
+ token: sourceToken,
2017
+ tokens: sourceTokens,
2018
+ onTokenChange: onSourceTokenChange,
2019
+ status: inputStatus,
2020
+ hintMessage,
2021
+ tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
2022
+ tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
2023
+ disabled: !props.isLoggedIn,
2024
+ balancesRevalidating: batchBalancesRevalidating,
2025
+ showBalance: true
2026
+ }
2027
+ )
2028
+ ] }),
2029
+ /* @__PURE__ */ jsxRuntime.jsx(
2030
+ AvailableQuantity,
2031
+ {
2032
+ token: sourceToken,
2033
+ quantity,
2034
+ maxQuantity,
2035
+ notional: quantityNotional,
2036
+ loading: balanceRevalidating,
2037
+ onClick: () => {
2038
+ onQuantityChange(maxDepositAmount);
2039
+ }
2040
+ }
2041
+ ),
2042
+ /* @__PURE__ */ jsxRuntime.jsx(
2043
+ YieldBearingReminder,
2044
+ {
2045
+ symbol: targetToken?.symbol,
2046
+ className: "oui-mt-3"
2047
+ }
2048
+ ),
2049
+ /* @__PURE__ */ jsxRuntime.jsx(ExchangeDivider, {}),
2050
+ /* @__PURE__ */ jsxRuntime.jsx(BrokerWallet, {}),
2051
+ /* @__PURE__ */ jsxRuntime.jsx(
2052
+ QuantityInput,
2053
+ {
2054
+ classNames: {
2055
+ root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
2056
+ },
2057
+ token: targetToken,
2058
+ tokens: targetTokens,
2059
+ onTokenChange: onTargetTokenChange,
2060
+ value: targetQuantity,
2061
+ loading: targetQuantityLoading,
2062
+ disabled: !props.isLoggedIn,
2063
+ readOnly: true,
2064
+ status: targetInputStatus,
2065
+ hintMessage: targetHintMessage,
2066
+ tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
2067
+ tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
2068
+ }
2069
+ ),
2070
+ renderContent()
2071
+ ] }),
2072
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mb-6 lg:oui-mb-8", children: /* @__PURE__ */ jsxRuntime.jsx(Notice, { message: warningMessage, wrongNetwork }) }),
2073
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2074
+ ActionButton,
2075
+ {
2076
+ actionType,
2077
+ symbol: sourceToken?.symbol,
2078
+ disabled,
2079
+ loading,
2080
+ onDeposit,
2081
+ onApprove,
2082
+ onApproveAndDeposit,
2083
+ networkId
2084
+ }
2085
+ ) })
2086
+ ]
1600
2087
  }
1601
2088
  ),
1602
- /* @__PURE__ */ jsxRuntime.jsx(
1603
- QuantityInput,
2089
+ showExclusiveDeposit && /* @__PURE__ */ jsxRuntime.jsx(
2090
+ ui.TabPanel,
1604
2091
  {
1605
- "data-testId": "oui-testid-deposit-dialog-quantity-input",
1606
- classNames: {
1607
- root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
1608
- },
1609
- value: quantity,
1610
- onValueChange: onQuantityChange,
1611
- token: sourceToken,
1612
- tokens: sourceTokens,
1613
- onTokenChange: onSourceTokenChange,
1614
- status: inputStatus,
1615
- hintMessage,
1616
- tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
1617
- tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
1618
- disabled: !props.isLoggedIn,
1619
- balancesRevalidating: batchBalancesRevalidating,
1620
- showBalance: true
2092
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2093
+ value: "exclusive_deposit",
2094
+ children: /* @__PURE__ */ jsxRuntime.jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1621
2095
  }
1622
2096
  )
1623
- ] }),
1624
- /* @__PURE__ */ jsxRuntime.jsx(
1625
- AvailableQuantity,
1626
- {
1627
- token: sourceToken,
1628
- quantity,
1629
- maxQuantity,
1630
- notional: quantityNotional,
1631
- loading: balanceRevalidating,
1632
- onClick: () => {
1633
- onQuantityChange(maxDepositAmount);
1634
- }
1635
- }
1636
- ),
1637
- /* @__PURE__ */ jsxRuntime.jsx(
1638
- YieldBearingReminder,
1639
- {
1640
- symbol: targetToken?.symbol,
1641
- className: "oui-mt-3"
1642
- }
1643
- ),
1644
- /* @__PURE__ */ jsxRuntime.jsx(ExchangeDivider, {}),
1645
- /* @__PURE__ */ jsxRuntime.jsx(BrokerWallet, {}),
1646
- /* @__PURE__ */ jsxRuntime.jsx(
1647
- QuantityInput,
1648
- {
1649
- classNames: {
1650
- root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
1651
- },
1652
- token: targetToken,
1653
- tokens: targetTokens,
1654
- onTokenChange: onTargetTokenChange,
1655
- value: targetQuantity,
1656
- loading: targetQuantityLoading,
1657
- disabled: !props.isLoggedIn,
1658
- readOnly: true,
1659
- status: targetInputStatus,
1660
- hintMessage: targetHintMessage,
1661
- tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
1662
- tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
1663
- }
1664
- ),
1665
- renderContent()
1666
- ] }),
1667
- /* @__PURE__ */ jsxRuntime.jsx(Notice, { message: warningMessage, wrongNetwork }),
1668
- /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
1669
- ActionButton,
1670
- {
1671
- actionType,
1672
- symbol: sourceToken?.symbol,
1673
- disabled,
1674
- loading,
1675
- onDeposit,
1676
- onApprove,
1677
- onApproveAndDeposit,
1678
- networkId
1679
- }
1680
- ) })
1681
- ] });
2097
+ ]
2098
+ }
2099
+ ) });
1682
2100
  };
1683
2101
  function useActionType(options2) {
1684
2102
  const { allowance, quantity, maxQuantity } = options2;
@@ -1994,7 +2412,7 @@ function useDepositFee(options2) {
1994
2412
  }
1995
2413
  var useMaxDepositAmount = (sourceToken, balance) => {
1996
2414
  const maxDepositAmount = react.useMemo(() => {
1997
- const balanceDecimal = new utils.Decimal(balance || 0).todp(
2415
+ const balanceDecimal = new utils.Decimal(balance).todp(
1998
2416
  sourceToken?.precision ?? 2,
1999
2417
  utils.Decimal.ROUND_DOWN
2000
2418
  );
@@ -2025,7 +2443,7 @@ var useDepositFormQuantities = ({
2025
2443
  getIndexPrice
2026
2444
  }) => {
2027
2445
  const maxQuantity = react.useMemo(
2028
- () => new utils.Decimal(balance || 0).todp(sourceToken?.precision ?? 2, utils.Decimal.ROUND_DOWN).toString(),
2446
+ () => new utils.Decimal(balance).todp(sourceToken?.precision ?? 2, utils.Decimal.ROUND_DOWN).toString(),
2029
2447
  [balance, sourceToken?.precision]
2030
2448
  );
2031
2449
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2483,9 +2901,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2483
2901
  logo_uri: item.logoURI
2484
2902
  }));
2485
2903
  }, [data]);
2486
- if (!enableSwapDeposit) {
2487
- return [];
2488
- }
2489
2904
  return tokens;
2490
2905
  };
2491
2906
 
@@ -3780,7 +4195,7 @@ var useDepositFormScript = (options2) => {
3780
4195
  } = useDepositFormQuantities({
3781
4196
  sourceToken,
3782
4197
  targetToken,
3783
- balance,
4198
+ balance: balance || "0",
3784
4199
  quantity,
3785
4200
  needSwap,
3786
4201
  swapQuantity,
@@ -3867,6 +4282,8 @@ var useDepositFormScript = (options2) => {
3867
4282
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3868
4283
  const targetQuantityLoading = swapPriceRevalidating;
3869
4284
  const warningMessage = validationMessage || swapErrorMessage;
4285
+ const [activeSubTab, setActiveSubTab] = react.useState("web3");
4286
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== types.ChainNamespace.solana;
3870
4287
  return {
3871
4288
  sourceToken,
3872
4289
  targetToken,
@@ -3920,7 +4337,10 @@ var useDepositFormScript = (options2) => {
3920
4337
  isLoggedIn,
3921
4338
  showSourceDepositCap,
3922
4339
  showTargetDepositCap,
3923
- quantityNotional
4340
+ quantityNotional,
4341
+ activeSubTab,
4342
+ setActiveSubTab,
4343
+ showExclusiveDeposit
3924
4344
  };
3925
4345
  };
3926
4346
  var DepositFormWidget = (props) => {