@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.js CHANGED
@@ -9,11 +9,13 @@ 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');
15
16
  var web3_js = require('@solana/web3.js');
16
17
  var ethers = require('ethers');
18
+ var pluginCore = require('@orderly.network/plugin-core');
17
19
  var defaultSolanaAdapter = require('@orderly.network/default-solana-adapter');
18
20
 
19
21
  // src/components/depositForm/depositForm.ui.tsx
@@ -598,6 +600,423 @@ var ExchangeDivider = ({ icon }) => {
598
600
  /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { height: 1, className: "oui-flex-1 oui-bg-base-contrast-12" })
599
601
  ] });
600
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, token, explorerBaseUrl } = options2;
809
+ const { t: t0 } = i18n.useTranslation();
810
+ const t = t0;
811
+ const receiverAddressKey = confirmed && chainId && token ? `/v1/client/asset/receiver_address?chain_id=${chainId}&token=${token}` : 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 useExclusiveDepositOptions = (params) => {
864
+ const networkId = hooks.useConfig("networkId");
865
+ const tokensInfo = hooks.useTokensInfo();
866
+ const selectedNetwork = params?.selectedNetwork;
867
+ const [, { findByChainId }] = hooks.useChains(networkId, {
868
+ pick: "network_infos"
869
+ });
870
+ const combos = react.useMemo(() => {
871
+ if (!tokensInfo?.length) return [];
872
+ const result = [];
873
+ for (const token of tokensInfo) {
874
+ for (const detail of token.chain_details ?? []) {
875
+ if (detail.exclusive_deposit_supported === true) {
876
+ const chainId = Number(detail.chain_id);
877
+ const chain = findByChainId(chainId);
878
+ result.push({
879
+ chainId,
880
+ chainName: chain?.network_infos?.name ?? `Chain ${chainId}`,
881
+ explorerUrl: chain?.network_infos?.explorer_base_url ?? "",
882
+ tokenSymbol: token.token
883
+ });
884
+ }
885
+ }
886
+ }
887
+ return result;
888
+ }, [tokensInfo, findByChainId]);
889
+ const networkOptions = react.useMemo(() => {
890
+ const seen = /* @__PURE__ */ new Map();
891
+ for (const combo of combos) {
892
+ if (!seen.has(combo.chainId)) {
893
+ seen.set(combo.chainId, {
894
+ label: combo.chainName,
895
+ value: String(combo.chainId),
896
+ chainId: combo.chainId,
897
+ explorerUrl: combo.explorerUrl
898
+ });
899
+ }
900
+ }
901
+ const list = Array.from(seen.values());
902
+ list.sort((a, b) => {
903
+ if (a.chainId === 42161) return -1;
904
+ if (b.chainId === 42161) return 1;
905
+ return 0;
906
+ });
907
+ return list;
908
+ }, [combos]);
909
+ const tokenOptions = react.useMemo(() => {
910
+ if (!selectedNetwork) return [];
911
+ const chainId = Number(selectedNetwork);
912
+ const seen = /* @__PURE__ */ new Set();
913
+ const result = [];
914
+ for (const combo of combos) {
915
+ if (combo.chainId === chainId && !seen.has(combo.tokenSymbol)) {
916
+ seen.add(combo.tokenSymbol);
917
+ result.push({ label: combo.tokenSymbol, value: combo.tokenSymbol });
918
+ }
919
+ }
920
+ result.sort((a, b) => {
921
+ if (a.value === "USDC") return -1;
922
+ if (b.value === "USDC") return 1;
923
+ return 0;
924
+ });
925
+ return result;
926
+ }, [combos, selectedNetwork]);
927
+ const isSupported = combos.length > 0;
928
+ return { networkOptions, tokenOptions, isSupported };
929
+ };
930
+ var ExclusiveDeposit = ({ active }) => {
931
+ const { t: t0 } = i18n.useTranslation();
932
+ const t = t0;
933
+ const [selectedNetwork, setSelectedNetwork] = react.useState("");
934
+ const [selectedToken, setSelectedToken] = react.useState("");
935
+ const { networkOptions, tokenOptions} = useExclusiveDepositOptions({
936
+ selectedNetwork
937
+ });
938
+ const confirmed = !!selectedNetwork && !!selectedToken;
939
+ react.useEffect(() => {
940
+ if (selectedToken && tokenOptions.length > 0 && !tokenOptions.some((t2) => t2.value === selectedToken)) {
941
+ setSelectedToken("");
942
+ }
943
+ }, [selectedNetwork, selectedToken, tokenOptions]);
944
+ const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
945
+ const selectedChainId = selectedNetworkOption?.chainId;
946
+ const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
947
+ const {
948
+ address,
949
+ qrUri,
950
+ minimumDeposit,
951
+ estimatedArrivalText,
952
+ latestEvent,
953
+ pendingCount,
954
+ explorerUrl
955
+ } = useExclusiveDeposit({
956
+ active,
957
+ confirmed,
958
+ chainId: selectedChainId,
959
+ token: selectedToken,
960
+ explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
961
+ });
962
+ const networkName = selectedNetworkOption?.label ?? "";
963
+ const tokenName = selectedTokenOption?.label ?? "";
964
+ const warningMessage = confirmed ? t("transfer.exclusiveDeposit.warning", {
965
+ token: tokenName,
966
+ network: networkName
967
+ }) : t("transfer.exclusiveDeposit.selectFirst");
968
+ const minText = confirmed && typeof minimumDeposit === "number" ? `${minimumDeposit} ${tokenName}` : "--";
969
+ const estText = confirmed ? estimatedArrivalText ?? t("transfer.exclusiveDeposit.estimatedTime.default") : "--";
970
+ 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: [
971
+ /* @__PURE__ */ jsxRuntime.jsx(WarningBanner, { message: warningMessage }),
972
+ confirmed && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
973
+ /* @__PURE__ */ jsxRuntime.jsx(QRCodeDisplay, { address: qrUri }),
974
+ address && /* @__PURE__ */ jsxRuntime.jsx(CopyAddress, { address })
975
+ ] }),
976
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
977
+ /* @__PURE__ */ jsxRuntime.jsx(
978
+ NetworkTokenSelect,
979
+ {
980
+ selectedNetwork,
981
+ selectedToken,
982
+ onNetworkChange: (value) => {
983
+ setSelectedNetwork(value);
984
+ setSelectedToken("");
985
+ },
986
+ onTokenChange: setSelectedToken,
987
+ networkOptions,
988
+ tokenOptions
989
+ },
990
+ selectedNetwork
991
+ ),
992
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
993
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
994
+ /* @__PURE__ */ jsxRuntime.jsx(
995
+ ui.Text,
996
+ {
997
+ size: "xs",
998
+ className: confirmed ? "oui-text-[#FF7D00]" : "",
999
+ intensity: confirmed ? void 0 : 98,
1000
+ children: minText
1001
+ }
1002
+ )
1003
+ ] }),
1004
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.estimatedTime") }),
1006
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: estText })
1007
+ ] })
1008
+ ] }),
1009
+ confirmed && latestEvent && explorerUrl && /* @__PURE__ */ jsxRuntime.jsx(
1010
+ DepositStatusBlock,
1011
+ {
1012
+ amount: latestEvent.amount,
1013
+ symbol: latestEvent.token,
1014
+ pendingCount,
1015
+ explorerUrl
1016
+ }
1017
+ )
1018
+ ] });
1019
+ };
601
1020
  var Fee = (props) => {
602
1021
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
603
1022
  const { t } = i18n.useTranslation();
@@ -1522,7 +1941,10 @@ var DepositForm = (props) => {
1522
1941
  showSourceDepositCap,
1523
1942
  showTargetDepositCap,
1524
1943
  slippageValidate,
1525
- quantityNotional
1944
+ quantityNotional,
1945
+ activeSubTab,
1946
+ setActiveSubTab,
1947
+ showExclusiveDeposit
1526
1948
  } = props;
1527
1949
  const { t } = i18n.useTranslation();
1528
1950
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -1583,101 +2005,129 @@ var DepositForm = (props) => {
1583
2005
  /* @__PURE__ */ jsxRuntime.jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1584
2006
  ] });
1585
2007
  };
1586
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { id: "oui-deposit-form", className: ui.textVariants({ weight: "semibold" }), children: [
1587
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-mb-6 lg:oui-mb-8", children: [
1588
- /* @__PURE__ */ jsxRuntime.jsx(Web3Wallet, {}),
1589
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { mt: 3, mb: 1, children: [
1590
- /* @__PURE__ */ jsxRuntime.jsx(
1591
- ChainSelect,
2008
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { id: "oui-deposit-form", className: ui.textVariants({ weight: "semibold" }), children: /* @__PURE__ */ jsxRuntime.jsxs(
2009
+ ui.Tabs,
2010
+ {
2011
+ value: activeSubTab,
2012
+ onValueChange: (value) => setActiveSubTab(value),
2013
+ variant: "contained",
2014
+ classNames: {
2015
+ tabsList: "oui-w-fit"
2016
+ },
2017
+ children: [
2018
+ /* @__PURE__ */ jsxRuntime.jsxs(
2019
+ ui.TabPanel,
1592
2020
  {
1593
- chains,
1594
- value: currentChain,
1595
- onValueChange: onChainChange,
1596
- wrongNetwork,
1597
- loading: settingChain,
1598
- disabled: !props.isLoggedIn
2021
+ title: t("transfer.deposit.tab.connectedWallet"),
2022
+ value: "web3",
2023
+ children: [
2024
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { className: "oui-mt-3", children: [
2025
+ /* @__PURE__ */ jsxRuntime.jsx(Web3Wallet, {}),
2026
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Box, { mt: 3, mb: 1, children: [
2027
+ /* @__PURE__ */ jsxRuntime.jsx(
2028
+ ChainSelect,
2029
+ {
2030
+ chains,
2031
+ value: currentChain,
2032
+ onValueChange: onChainChange,
2033
+ wrongNetwork,
2034
+ loading: settingChain,
2035
+ disabled: !props.isLoggedIn
2036
+ }
2037
+ ),
2038
+ /* @__PURE__ */ jsxRuntime.jsx(
2039
+ QuantityInput,
2040
+ {
2041
+ "data-testId": "oui-testid-deposit-dialog-quantity-input",
2042
+ classNames: {
2043
+ root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
2044
+ },
2045
+ value: quantity,
2046
+ onValueChange: onQuantityChange,
2047
+ token: sourceToken,
2048
+ tokens: sourceTokens,
2049
+ onTokenChange: onSourceTokenChange,
2050
+ status: inputStatus,
2051
+ hintMessage,
2052
+ tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
2053
+ tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
2054
+ disabled: !props.isLoggedIn,
2055
+ balancesRevalidating: batchBalancesRevalidating,
2056
+ showBalance: true
2057
+ }
2058
+ )
2059
+ ] }),
2060
+ /* @__PURE__ */ jsxRuntime.jsx(
2061
+ AvailableQuantity,
2062
+ {
2063
+ token: sourceToken,
2064
+ quantity,
2065
+ maxQuantity,
2066
+ notional: quantityNotional,
2067
+ loading: balanceRevalidating,
2068
+ onClick: () => {
2069
+ onQuantityChange(maxDepositAmount);
2070
+ }
2071
+ }
2072
+ ),
2073
+ /* @__PURE__ */ jsxRuntime.jsx(
2074
+ YieldBearingReminder,
2075
+ {
2076
+ symbol: targetToken?.symbol,
2077
+ className: "oui-mt-3"
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ jsxRuntime.jsx(ExchangeDivider, {}),
2081
+ /* @__PURE__ */ jsxRuntime.jsx(BrokerWallet, {}),
2082
+ /* @__PURE__ */ jsxRuntime.jsx(
2083
+ QuantityInput,
2084
+ {
2085
+ classNames: {
2086
+ root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
2087
+ },
2088
+ token: targetToken,
2089
+ tokens: targetTokens,
2090
+ onTokenChange: onTargetTokenChange,
2091
+ value: targetQuantity,
2092
+ loading: targetQuantityLoading,
2093
+ disabled: !props.isLoggedIn,
2094
+ readOnly: true,
2095
+ status: targetInputStatus,
2096
+ hintMessage: targetHintMessage,
2097
+ tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
2098
+ tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
2099
+ }
2100
+ ),
2101
+ renderContent()
2102
+ ] }),
2103
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { className: "oui-mb-6 lg:oui-mb-8", children: /* @__PURE__ */ jsxRuntime.jsx(Notice, { message: warningMessage, wrongNetwork }) }),
2104
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2105
+ ActionButton,
2106
+ {
2107
+ actionType,
2108
+ symbol: sourceToken?.symbol,
2109
+ disabled,
2110
+ loading,
2111
+ onDeposit,
2112
+ onApprove,
2113
+ onApproveAndDeposit,
2114
+ networkId
2115
+ }
2116
+ ) })
2117
+ ]
1599
2118
  }
1600
2119
  ),
1601
- /* @__PURE__ */ jsxRuntime.jsx(
1602
- QuantityInput,
2120
+ showExclusiveDeposit && /* @__PURE__ */ jsxRuntime.jsx(
2121
+ ui.TabPanel,
1603
2122
  {
1604
- "data-testId": "oui-testid-deposit-dialog-quantity-input",
1605
- classNames: {
1606
- root: "oui-mt-[2px] oui-rounded-t-sm oui-rounded-b-xl"
1607
- },
1608
- value: quantity,
1609
- onValueChange: onQuantityChange,
1610
- token: sourceToken,
1611
- tokens: sourceTokens,
1612
- onTokenChange: onSourceTokenChange,
1613
- status: inputStatus,
1614
- hintMessage,
1615
- tokenShowCaret: !showSourceDepositCap && sourceTokens?.length > 1,
1616
- tokenValueFormatter: showSourceDepositCap ? tokenValueFormatter : void 0,
1617
- disabled: !props.isLoggedIn,
1618
- balancesRevalidating: batchBalancesRevalidating,
1619
- showBalance: true
2123
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2124
+ value: "exclusive_deposit",
2125
+ children: /* @__PURE__ */ jsxRuntime.jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1620
2126
  }
1621
2127
  )
1622
- ] }),
1623
- /* @__PURE__ */ jsxRuntime.jsx(
1624
- AvailableQuantity,
1625
- {
1626
- token: sourceToken,
1627
- quantity,
1628
- maxQuantity,
1629
- notional: quantityNotional,
1630
- loading: balanceRevalidating,
1631
- onClick: () => {
1632
- onQuantityChange(maxDepositAmount);
1633
- }
1634
- }
1635
- ),
1636
- /* @__PURE__ */ jsxRuntime.jsx(
1637
- YieldBearingReminder,
1638
- {
1639
- symbol: targetToken?.symbol,
1640
- className: "oui-mt-3"
1641
- }
1642
- ),
1643
- /* @__PURE__ */ jsxRuntime.jsx(ExchangeDivider, {}),
1644
- /* @__PURE__ */ jsxRuntime.jsx(BrokerWallet, {}),
1645
- /* @__PURE__ */ jsxRuntime.jsx(
1646
- QuantityInput,
1647
- {
1648
- classNames: {
1649
- root: "oui-mt-3 oui-border-transparent focus-within:oui-outline-transparent"
1650
- },
1651
- token: targetToken,
1652
- tokens: targetTokens,
1653
- onTokenChange: onTargetTokenChange,
1654
- value: targetQuantity,
1655
- loading: targetQuantityLoading,
1656
- disabled: !props.isLoggedIn,
1657
- readOnly: true,
1658
- status: targetInputStatus,
1659
- hintMessage: targetHintMessage,
1660
- tokenShowCaret: !showTargetDepositCap && targetTokens?.length > 1,
1661
- tokenValueFormatter: showTargetDepositCap ? tokenValueFormatter : void 0
1662
- }
1663
- ),
1664
- renderContent()
1665
- ] }),
1666
- /* @__PURE__ */ jsxRuntime.jsx(Notice, { message: warningMessage, wrongNetwork }),
1667
- /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
1668
- ActionButton,
1669
- {
1670
- actionType,
1671
- symbol: sourceToken?.symbol,
1672
- disabled,
1673
- loading,
1674
- onDeposit,
1675
- onApprove,
1676
- onApproveAndDeposit,
1677
- networkId
1678
- }
1679
- ) })
1680
- ] });
2128
+ ]
2129
+ }
2130
+ ) });
1681
2131
  };
1682
2132
  function useActionType(options2) {
1683
2133
  const { allowance, quantity, maxQuantity } = options2;
@@ -1993,7 +2443,7 @@ function useDepositFee(options2) {
1993
2443
  }
1994
2444
  var useMaxDepositAmount = (sourceToken, balance) => {
1995
2445
  const maxDepositAmount = react.useMemo(() => {
1996
- const balanceDecimal = new utils.Decimal(balance || 0).todp(
2446
+ const balanceDecimal = new utils.Decimal(balance).todp(
1997
2447
  sourceToken?.precision ?? 2,
1998
2448
  utils.Decimal.ROUND_DOWN
1999
2449
  );
@@ -2024,7 +2474,7 @@ var useDepositFormQuantities = ({
2024
2474
  getIndexPrice
2025
2475
  }) => {
2026
2476
  const maxQuantity = react.useMemo(
2027
- () => new utils.Decimal(balance || 0).todp(sourceToken?.precision ?? 2, utils.Decimal.ROUND_DOWN).toString(),
2477
+ () => new utils.Decimal(balance).todp(sourceToken?.precision ?? 2, utils.Decimal.ROUND_DOWN).toString(),
2028
2478
  [balance, sourceToken?.precision]
2029
2479
  );
2030
2480
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2482,9 +2932,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2482
2932
  logo_uri: item.logoURI
2483
2933
  }));
2484
2934
  }, [data]);
2485
- if (!enableSwapDeposit) {
2486
- return [];
2487
- }
2488
2935
  return tokens;
2489
2936
  };
2490
2937
 
@@ -3779,7 +4226,7 @@ var useDepositFormScript = (options2) => {
3779
4226
  } = useDepositFormQuantities({
3780
4227
  sourceToken,
3781
4228
  targetToken,
3782
- balance,
4229
+ balance: balance || "0",
3783
4230
  quantity,
3784
4231
  needSwap,
3785
4232
  swapQuantity,
@@ -3866,6 +4313,8 @@ var useDepositFormScript = (options2) => {
3866
4313
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3867
4314
  const targetQuantityLoading = swapPriceRevalidating;
3868
4315
  const warningMessage = validationMessage || swapErrorMessage;
4316
+ const [activeSubTab, setActiveSubTab] = react.useState("web3");
4317
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== types.ChainNamespace.solana;
3869
4318
  return {
3870
4319
  sourceToken,
3871
4320
  targetToken,
@@ -3919,7 +4368,10 @@ var useDepositFormScript = (options2) => {
3919
4368
  isLoggedIn,
3920
4369
  showSourceDepositCap,
3921
4370
  showTargetDepositCap,
3922
- quantityNotional
4371
+ quantityNotional,
4372
+ activeSubTab,
4373
+ setActiveSubTab,
4374
+ showExclusiveDeposit
3923
4375
  };
3924
4376
  };
3925
4377
  var DepositFormWidget = (props) => {
@@ -5991,10 +6443,14 @@ var WithdrawSlot = (props) => {
5991
6443
  var DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
5992
6444
  var DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
5993
6445
  var DepositAndWithdraw = (props) => {
6446
+ const { extraTabs = [] } = props;
5994
6447
  const [activeTab, setActiveTab] = react.useState(
5995
6448
  props.activeTab || "deposit"
5996
6449
  );
5997
6450
  const { t } = i18n.useTranslation();
6451
+ const sortedExtra = [...extraTabs].sort(
6452
+ (a, b) => (a.order ?? 100) - (b.order ?? 100)
6453
+ );
5998
6454
  return /* @__PURE__ */ jsxRuntime.jsxs(
5999
6455
  ui.Tabs,
6000
6456
  {
@@ -6024,18 +6480,39 @@ var DepositAndWithdraw = (props) => {
6024
6480
  value: "withdraw",
6025
6481
  children: /* @__PURE__ */ jsxRuntime.jsx(WithdrawSlot, { close: props.close })
6026
6482
  }
6027
- )
6483
+ ),
6484
+ sortedExtra.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(
6485
+ ui.TabPanel,
6486
+ {
6487
+ title: tab.title,
6488
+ icon: react.isValidElement(tab.icon) ? tab.icon : void 0,
6489
+ value: tab.id,
6490
+ children: /* @__PURE__ */ jsxRuntime.jsx(tab.component, { close: props.close })
6491
+ },
6492
+ tab.id
6493
+ ))
6028
6494
  ]
6029
6495
  }
6030
6496
  );
6031
6497
  };
6032
- ui.registerSimpleDialog(DepositAndWithdrawWithDialogId, DepositAndWithdraw, {
6033
- size: "md",
6034
- classNames: {
6035
- content: "oui-border oui-border-line-6"
6498
+ var InjectableDepositAndWithdraw = pluginCore.injectable(
6499
+ DepositAndWithdraw,
6500
+ "Transfer.DepositAndWithdraw"
6501
+ );
6502
+ ui.registerSimpleDialog(
6503
+ DepositAndWithdrawWithDialogId,
6504
+ InjectableDepositAndWithdraw,
6505
+ {
6506
+ size: "md",
6507
+ classNames: {
6508
+ content: "oui-border oui-border-line-6"
6509
+ }
6036
6510
  }
6037
- });
6038
- ui.registerSimpleSheet(DepositAndWithdrawWithSheetId, DepositAndWithdraw);
6511
+ );
6512
+ ui.registerSimpleSheet(
6513
+ DepositAndWithdrawWithSheetId,
6514
+ InjectableDepositAndWithdraw
6515
+ );
6039
6516
  var AccountSelect = (props) => {
6040
6517
  const { subAccounts = [], value } = props;
6041
6518
  const [open, setOpen] = react.useState(false);
@@ -7890,6 +8367,7 @@ exports.DepositStatus = DepositStatus;
7890
8367
  exports.DepositStatusWidget = DepositStatusWidget;
7891
8368
  exports.ExchangeDivider = ExchangeDivider;
7892
8369
  exports.Fee = Fee;
8370
+ exports.InjectableDepositAndWithdraw = InjectableDepositAndWithdraw;
7893
8371
  exports.QuantityInput = QuantityInput;
7894
8372
  exports.SwapCoin = SwapCoin;
7895
8373
  exports.TransferDialogId = TransferDialogId;