@orderly.network/ui-transfer 3.0.0-beta.0 → 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,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,392 @@ 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, 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
+ };
601
989
  var Fee = (props) => {
602
990
  const { dstGasFee, feeQty, feeAmount, dp, nativeSymbol } = props;
603
991
  const { t } = i18n.useTranslation();
@@ -1522,7 +1910,10 @@ var DepositForm = (props) => {
1522
1910
  showSourceDepositCap,
1523
1911
  showTargetDepositCap,
1524
1912
  slippageValidate,
1525
- quantityNotional
1913
+ quantityNotional,
1914
+ activeSubTab,
1915
+ setActiveSubTab,
1916
+ showExclusiveDeposit
1526
1917
  } = props;
1527
1918
  const { t } = i18n.useTranslation();
1528
1919
  const tokenValueFormatter = (value) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -1583,101 +1974,129 @@ var DepositForm = (props) => {
1583
1974
  /* @__PURE__ */ jsxRuntime.jsx(Fee, { ...fee, nativeSymbol: props.nativeSymbol })
1584
1975
  ] });
1585
1976
  };
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,
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,
1592
1989
  {
1593
- chains,
1594
- value: currentChain,
1595
- onValueChange: onChainChange,
1596
- wrongNetwork,
1597
- loading: settingChain,
1598
- 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
+ ]
1599
2087
  }
1600
2088
  ),
1601
- /* @__PURE__ */ jsxRuntime.jsx(
1602
- QuantityInput,
2089
+ showExclusiveDeposit && /* @__PURE__ */ jsxRuntime.jsx(
2090
+ ui.TabPanel,
1603
2091
  {
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
2092
+ title: t("transfer.deposit.tab.exchangeOrOtherWallet"),
2093
+ value: "exclusive_deposit",
2094
+ children: /* @__PURE__ */ jsxRuntime.jsx(ExclusiveDeposit, { active: activeSubTab === "exclusive_deposit" })
1620
2095
  }
1621
2096
  )
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
- ] });
2097
+ ]
2098
+ }
2099
+ ) });
1681
2100
  };
1682
2101
  function useActionType(options2) {
1683
2102
  const { allowance, quantity, maxQuantity } = options2;
@@ -1993,7 +2412,7 @@ function useDepositFee(options2) {
1993
2412
  }
1994
2413
  var useMaxDepositAmount = (sourceToken, balance) => {
1995
2414
  const maxDepositAmount = react.useMemo(() => {
1996
- const balanceDecimal = new utils.Decimal(balance || 0).todp(
2415
+ const balanceDecimal = new utils.Decimal(balance).todp(
1997
2416
  sourceToken?.precision ?? 2,
1998
2417
  utils.Decimal.ROUND_DOWN
1999
2418
  );
@@ -2024,7 +2443,7 @@ var useDepositFormQuantities = ({
2024
2443
  getIndexPrice
2025
2444
  }) => {
2026
2445
  const maxQuantity = react.useMemo(
2027
- () => 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(),
2028
2447
  [balance, sourceToken?.precision]
2029
2448
  );
2030
2449
  const maxDepositAmount = useMaxDepositAmount(sourceToken, balance);
@@ -2482,9 +2901,6 @@ var useSwapTokens = (chainId, enableSwapDeposit) => {
2482
2901
  logo_uri: item.logoURI
2483
2902
  }));
2484
2903
  }, [data]);
2485
- if (!enableSwapDeposit) {
2486
- return [];
2487
- }
2488
2904
  return tokens;
2489
2905
  };
2490
2906
 
@@ -3779,7 +4195,7 @@ var useDepositFormScript = (options2) => {
3779
4195
  } = useDepositFormQuantities({
3780
4196
  sourceToken,
3781
4197
  targetToken,
3782
- balance,
4198
+ balance: balance || "0",
3783
4199
  quantity,
3784
4200
  needSwap,
3785
4201
  swapQuantity,
@@ -3866,6 +4282,8 @@ var useDepositFormScript = (options2) => {
3866
4282
  const disabled = !sourceToken || !quantity || Number(quantity) === 0 || depositDisabled || loading || !!swapErrorMessage;
3867
4283
  const targetQuantityLoading = swapPriceRevalidating;
3868
4284
  const warningMessage = validationMessage || swapErrorMessage;
4285
+ const [activeSubTab, setActiveSubTab] = react.useState("web3");
4286
+ const showExclusiveDeposit = account2.walletAdapter?.chainNamespace !== types.ChainNamespace.solana;
3869
4287
  return {
3870
4288
  sourceToken,
3871
4289
  targetToken,
@@ -3919,7 +4337,10 @@ var useDepositFormScript = (options2) => {
3919
4337
  isLoggedIn,
3920
4338
  showSourceDepositCap,
3921
4339
  showTargetDepositCap,
3922
- quantityNotional
4340
+ quantityNotional,
4341
+ activeSubTab,
4342
+ setActiveSubTab,
4343
+ showExclusiveDeposit
3923
4344
  };
3924
4345
  };
3925
4346
  var DepositFormWidget = (props) => {
@@ -5991,10 +6412,14 @@ var WithdrawSlot = (props) => {
5991
6412
  var DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
5992
6413
  var DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
5993
6414
  var DepositAndWithdraw = (props) => {
6415
+ const { extraTabs = [] } = props;
5994
6416
  const [activeTab, setActiveTab] = react.useState(
5995
6417
  props.activeTab || "deposit"
5996
6418
  );
5997
6419
  const { t } = i18n.useTranslation();
6420
+ const sortedExtra = [...extraTabs].sort(
6421
+ (a, b) => (a.order ?? 100) - (b.order ?? 100)
6422
+ );
5998
6423
  return /* @__PURE__ */ jsxRuntime.jsxs(
5999
6424
  ui.Tabs,
6000
6425
  {
@@ -6024,18 +6449,39 @@ var DepositAndWithdraw = (props) => {
6024
6449
  value: "withdraw",
6025
6450
  children: /* @__PURE__ */ jsxRuntime.jsx(WithdrawSlot, { close: props.close })
6026
6451
  }
6027
- )
6452
+ ),
6453
+ sortedExtra.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(
6454
+ ui.TabPanel,
6455
+ {
6456
+ title: tab.title,
6457
+ icon: react.isValidElement(tab.icon) ? tab.icon : void 0,
6458
+ value: tab.id,
6459
+ children: /* @__PURE__ */ jsxRuntime.jsx(tab.component, { close: props.close })
6460
+ },
6461
+ tab.id
6462
+ ))
6028
6463
  ]
6029
6464
  }
6030
6465
  );
6031
6466
  };
6032
- ui.registerSimpleDialog(DepositAndWithdrawWithDialogId, DepositAndWithdraw, {
6033
- size: "md",
6034
- classNames: {
6035
- content: "oui-border oui-border-line-6"
6467
+ var InjectableDepositAndWithdraw = pluginCore.injectable(
6468
+ DepositAndWithdraw,
6469
+ "Transfer.DepositAndWithdraw"
6470
+ );
6471
+ ui.registerSimpleDialog(
6472
+ DepositAndWithdrawWithDialogId,
6473
+ InjectableDepositAndWithdraw,
6474
+ {
6475
+ size: "md",
6476
+ classNames: {
6477
+ content: "oui-border oui-border-line-6"
6478
+ }
6036
6479
  }
6037
- });
6038
- ui.registerSimpleSheet(DepositAndWithdrawWithSheetId, DepositAndWithdraw);
6480
+ );
6481
+ ui.registerSimpleSheet(
6482
+ DepositAndWithdrawWithSheetId,
6483
+ InjectableDepositAndWithdraw
6484
+ );
6039
6485
  var AccountSelect = (props) => {
6040
6486
  const { subAccounts = [], value } = props;
6041
6487
  const [open, setOpen] = react.useState(false);
@@ -7890,6 +8336,7 @@ exports.DepositStatus = DepositStatus;
7890
8336
  exports.DepositStatusWidget = DepositStatusWidget;
7891
8337
  exports.ExchangeDivider = ExchangeDivider;
7892
8338
  exports.Fee = Fee;
8339
+ exports.InjectableDepositAndWithdraw = InjectableDepositAndWithdraw;
7893
8340
  exports.QuantityInput = QuantityInput;
7894
8341
  exports.SwapCoin = SwapCoin;
7895
8342
  exports.TransferDialogId = TransferDialogId;