@orderly.network/ui-transfer 2.12.4-alpha.0 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -208,11 +208,22 @@ declare const WithdrawFormWidget: FC<WithdrawFormWidgetProps>;
208
208
 
209
209
  declare const DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
210
210
  declare const DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
211
+ interface DepositTabExtension {
212
+ id: string;
213
+ title: string;
214
+ icon: React.ReactNode;
215
+ component: React.ComponentType<{
216
+ close?: () => void;
217
+ }>;
218
+ order?: number;
219
+ }
211
220
  type DepositAndWithdrawProps = {
212
- activeTab?: "deposit" | "withdraw";
221
+ activeTab?: string;
213
222
  close?: () => void;
223
+ extraTabs?: DepositTabExtension[];
214
224
  };
215
225
  declare const DepositAndWithdraw: FC<DepositAndWithdrawProps>;
226
+ declare const InjectableDepositAndWithdraw: react.ComponentType<DepositAndWithdrawProps>;
216
227
 
217
228
  type TransferFormScriptReturn = ReturnType<typeof useTransferFormScript>;
218
229
  type TransferFormScriptOptions = {
@@ -310,6 +321,7 @@ declare const useConvertFormScript: (options: ConvertFormScriptOptions) => {
310
321
  chain_id?: string | undefined;
311
322
  contract_address?: string | undefined;
312
323
  decimals?: number | undefined;
324
+ exclusive_deposit_supported?: boolean;
313
325
  withdrawal_fee?: number | undefined;
314
326
  chain_name?: string;
315
327
  cross_chain_withdrawal_fee?: number | undefined;
@@ -515,4 +527,4 @@ declare const DepositStatus: react__default.FC<DepositStatusProps>;
515
527
  type DepositStatusWidgetProps = Pick<DepositStatusProps, "className" | "onClick">;
516
528
  declare const DepositStatusWidget: react__default.FC<DepositStatusWidgetProps>;
517
529
 
518
- export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, type ConvertFormProps, ConvertFormUI, ConvertFormWidget, type CurrentChain, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, type DepositAndWithdrawProps, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, type DepositFormScriptOptions, DepositFormWidget, type DepositFormWidgetProps, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, type InputStatus, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, type TransferFormWidgetProps, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, type WithdrawFormScriptOptions, WithdrawFormWidget, type WithdrawFormWidgetProps, WithdrawTo, YIELD_BEARING_ASSETS, type YieldBearingAsset, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
530
+ export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, type ConvertFormProps, ConvertFormUI, ConvertFormWidget, type CurrentChain, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, type DepositAndWithdrawProps, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, type DepositFormScriptOptions, DepositFormWidget, type DepositFormWidgetProps, DepositStatus, DepositStatusWidget, type DepositTabExtension, ExchangeDivider, Fee, InjectableDepositAndWithdraw, type InputStatus, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, type TransferFormWidgetProps, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, type WithdrawFormScriptOptions, WithdrawFormWidget, type WithdrawFormWidgetProps, WithdrawTo, YIELD_BEARING_ASSETS, type YieldBearingAsset, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
package/dist/index.d.ts CHANGED
@@ -208,11 +208,22 @@ declare const WithdrawFormWidget: FC<WithdrawFormWidgetProps>;
208
208
 
209
209
  declare const DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
210
210
  declare const DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
211
+ interface DepositTabExtension {
212
+ id: string;
213
+ title: string;
214
+ icon: React.ReactNode;
215
+ component: React.ComponentType<{
216
+ close?: () => void;
217
+ }>;
218
+ order?: number;
219
+ }
211
220
  type DepositAndWithdrawProps = {
212
- activeTab?: "deposit" | "withdraw";
221
+ activeTab?: string;
213
222
  close?: () => void;
223
+ extraTabs?: DepositTabExtension[];
214
224
  };
215
225
  declare const DepositAndWithdraw: FC<DepositAndWithdrawProps>;
226
+ declare const InjectableDepositAndWithdraw: react.ComponentType<DepositAndWithdrawProps>;
216
227
 
217
228
  type TransferFormScriptReturn = ReturnType<typeof useTransferFormScript>;
218
229
  type TransferFormScriptOptions = {
@@ -310,6 +321,7 @@ declare const useConvertFormScript: (options: ConvertFormScriptOptions) => {
310
321
  chain_id?: string | undefined;
311
322
  contract_address?: string | undefined;
312
323
  decimals?: number | undefined;
324
+ exclusive_deposit_supported?: boolean;
313
325
  withdrawal_fee?: number | undefined;
314
326
  chain_name?: string;
315
327
  cross_chain_withdrawal_fee?: number | undefined;
@@ -515,4 +527,4 @@ declare const DepositStatus: react__default.FC<DepositStatusProps>;
515
527
  type DepositStatusWidgetProps = Pick<DepositStatusProps, "className" | "onClick">;
516
528
  declare const DepositStatusWidget: react__default.FC<DepositStatusWidgetProps>;
517
529
 
518
- export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, type ConvertFormProps, ConvertFormUI, ConvertFormWidget, type CurrentChain, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, type DepositAndWithdrawProps, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, type DepositFormScriptOptions, DepositFormWidget, type DepositFormWidgetProps, DepositStatus, DepositStatusWidget, ExchangeDivider, Fee, type InputStatus, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, type TransferFormWidgetProps, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, type WithdrawFormScriptOptions, WithdrawFormWidget, type WithdrawFormWidgetProps, WithdrawTo, YIELD_BEARING_ASSETS, type YieldBearingAsset, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
530
+ export { ActionButton, AvailableQuantity, BrokerWallet, ChainSelect, type ConvertFormProps, ConvertFormUI, ConvertFormWidget, type CurrentChain, DEPOSIT_ERROR_CODE_MAP, DepositAction, DepositAndWithdraw, type DepositAndWithdrawProps, DepositAndWithdrawWithDialogId, DepositAndWithdrawWithSheetId, DepositForm, type DepositFormScriptOptions, DepositFormWidget, type DepositFormWidgetProps, DepositStatus, DepositStatusWidget, type DepositTabExtension, ExchangeDivider, Fee, InjectableDepositAndWithdraw, type InputStatus, QuantityInput, SwapCoin, TransferDialogId, TransferForm, TransferFormWidget, type TransferFormWidgetProps, TransferSheetId, TransferWidget, Web3Wallet, WithdrawForm, type WithdrawFormScriptOptions, WithdrawFormWidget, type WithdrawFormWidgetProps, WithdrawTo, YIELD_BEARING_ASSETS, type YieldBearingAsset, YieldBearingReminder, checkIsAccountId, feeDecimalsOffset, getDepositKnownErrorMessage, getTransferErrorMessage, getUSDCToken, getYieldBearingAsset, isYieldBearingAsset, sortTokensWithUSDCFirst, useConvertFormScript as useConvertForm, useDepositFormScript, useDepositStatusScript, useTransferFormScript, useWithdrawFormScript };
package/dist/index.js CHANGED
@@ -15,6 +15,7 @@ var core = require('@orderly.network/core');
15
15
  var uiChainSelector = require('@orderly.network/ui-chain-selector');
16
16
  var web3_js = require('@solana/web3.js');
17
17
  var ethers = require('ethers');
18
+ var pluginCore = require('@orderly.network/plugin-core');
18
19
  var defaultSolanaAdapter = require('@orderly.network/default-solana-adapter');
19
20
 
20
21
  // src/components/depositForm/depositForm.ui.tsx
@@ -804,10 +805,10 @@ var buildExplorerUrl = (baseUrl, txId) => {
804
805
  var useExclusiveDeposit = (options2) => {
805
806
  const active = options2.active ?? true;
806
807
  const confirmed = options2.confirmed ?? true;
807
- const { chainId, explorerBaseUrl } = options2;
808
+ const { chainId, token, explorerBaseUrl } = options2;
808
809
  const { t: t0 } = i18n.useTranslation();
809
810
  const t = t0;
810
- const receiverAddressKey = confirmed && chainId ? `/v1/client/asset/receiver_address?chain_id=${chainId}` : null;
811
+ const receiverAddressKey = confirmed && chainId && token ? `/v1/client/asset/receiver_address?chain_id=${chainId}&token=${token}` : null;
811
812
  const receiverEventsKey = active && confirmed ? "/v1/client/asset/receiver_events" : null;
812
813
  const {
813
814
  data: addressData,
@@ -859,46 +860,87 @@ var useExclusiveDeposit = (options2) => {
859
860
  eventsError
860
861
  };
861
862
  };
862
- var SUPPORTED_CHAINS = {
863
- prod: [42161],
864
- testnet: [421614]
865
- };
866
- var SUPPORTED_TOKENS = ["USDC"];
867
- var useExclusiveDepositOptions = () => {
868
- const env = hooks.useConfig("env");
863
+ var useExclusiveDepositOptions = (params) => {
869
864
  const networkId = hooks.useConfig("networkId");
870
- const [chains, { findByChainId }] = hooks.useChains(networkId, {
865
+ const tokensInfo = hooks.useTokensInfo();
866
+ const selectedNetwork = params?.selectedNetwork;
867
+ const [, { findByChainId }] = hooks.useChains(networkId, {
871
868
  pick: "network_infos"
872
869
  });
873
- const supportedChainIds = env === "prod" ? SUPPORTED_CHAINS.prod : SUPPORTED_CHAINS.testnet;
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]);
874
889
  const networkOptions = react.useMemo(() => {
875
- return supportedChainIds.map((chainId) => {
876
- const chain = findByChainId(chainId);
877
- const name = chain?.network_infos?.name ?? `Chain ${chainId}`;
878
- const explorerUrl = chain?.network_infos?.explorer_base_url ?? "";
879
- return {
880
- label: name,
881
- value: String(chainId),
882
- chainId,
883
- explorerUrl
884
- };
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;
885
906
  });
886
- }, [supportedChainIds, findByChainId]);
907
+ return list;
908
+ }, [combos]);
887
909
  const tokenOptions = react.useMemo(() => {
888
- return SUPPORTED_TOKENS.map((symbol) => ({
889
- label: symbol,
890
- value: symbol
891
- }));
892
- }, []);
893
- return { networkOptions, tokenOptions };
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 };
894
929
  };
895
930
  var ExclusiveDeposit = ({ active }) => {
896
931
  const { t: t0 } = i18n.useTranslation();
897
932
  const t = t0;
898
933
  const [selectedNetwork, setSelectedNetwork] = react.useState("");
899
934
  const [selectedToken, setSelectedToken] = react.useState("");
900
- const { networkOptions, tokenOptions } = useExclusiveDepositOptions();
935
+ const { networkOptions, tokenOptions} = useExclusiveDepositOptions({
936
+ selectedNetwork
937
+ });
901
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]);
902
944
  const selectedNetworkOption = selectedNetwork ? networkOptions.find((n) => n.value === selectedNetwork) : void 0;
903
945
  const selectedChainId = selectedNetworkOption?.chainId;
904
946
  const selectedTokenOption = selectedToken ? tokenOptions.find((t2) => t2.value === selectedToken) : void 0;
@@ -914,6 +956,7 @@ var ExclusiveDeposit = ({ active }) => {
914
956
  active,
915
957
  confirmed,
916
958
  chainId: selectedChainId,
959
+ token: selectedToken,
917
960
  explorerBaseUrl: selectedNetworkOption?.explorerUrl ?? ""
918
961
  });
919
962
  const networkName = selectedNetworkOption?.label ?? "";
@@ -931,31 +974,20 @@ var ExclusiveDeposit = ({ active }) => {
931
974
  address && /* @__PURE__ */ jsxRuntime.jsx(CopyAddress, { address })
932
975
  ] }),
933
976
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", gap: 2, className: "oui-mt-5 oui-w-full", children: [
934
- confirmed ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
935
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
936
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.network") }),
937
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
938
- /* @__PURE__ */ jsxRuntime.jsx(ui.ChainIcon, { chainId: selectedChainId, size: "2xs" }),
939
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: networkName })
940
- ] })
941
- ] }),
942
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", itemAlign: "center", children: [
943
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("common.token") }),
944
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, itemAlign: "center", children: [
945
- /* @__PURE__ */ jsxRuntime.jsx(ui.TokenIcon, { name: tokenName, size: "2xs" }),
946
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 98, children: tokenName })
947
- ] })
948
- ] })
949
- ] }) : /* @__PURE__ */ jsxRuntime.jsx(
977
+ /* @__PURE__ */ jsxRuntime.jsx(
950
978
  NetworkTokenSelect,
951
979
  {
952
980
  selectedNetwork,
953
981
  selectedToken,
954
- onNetworkChange: setSelectedNetwork,
982
+ onNetworkChange: (value) => {
983
+ setSelectedNetwork(value);
984
+ setSelectedToken("");
985
+ },
955
986
  onTokenChange: setSelectedToken,
956
987
  networkOptions,
957
988
  tokenOptions
958
- }
989
+ },
990
+ selectedNetwork
959
991
  ),
960
992
  /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { className: "oui-w-full", justify: "between", children: [
961
993
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xs", intensity: 36, children: t("transfer.exclusiveDeposit.minDeposit") }),
@@ -6411,10 +6443,14 @@ var WithdrawSlot = (props) => {
6411
6443
  var DepositAndWithdrawWithDialogId = "DepositAndWithdrawWithDialogId";
6412
6444
  var DepositAndWithdrawWithSheetId = "DepositAndWithdrawWithSheetId";
6413
6445
  var DepositAndWithdraw = (props) => {
6446
+ const { extraTabs = [] } = props;
6414
6447
  const [activeTab, setActiveTab] = react.useState(
6415
6448
  props.activeTab || "deposit"
6416
6449
  );
6417
6450
  const { t } = i18n.useTranslation();
6451
+ const sortedExtra = [...extraTabs].sort(
6452
+ (a, b) => (a.order ?? 100) - (b.order ?? 100)
6453
+ );
6418
6454
  return /* @__PURE__ */ jsxRuntime.jsxs(
6419
6455
  ui.Tabs,
6420
6456
  {
@@ -6444,18 +6480,39 @@ var DepositAndWithdraw = (props) => {
6444
6480
  value: "withdraw",
6445
6481
  children: /* @__PURE__ */ jsxRuntime.jsx(WithdrawSlot, { close: props.close })
6446
6482
  }
6447
- )
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
+ ))
6448
6494
  ]
6449
6495
  }
6450
6496
  );
6451
6497
  };
6452
- ui.registerSimpleDialog(DepositAndWithdrawWithDialogId, DepositAndWithdraw, {
6453
- size: "md",
6454
- classNames: {
6455
- 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
+ }
6456
6510
  }
6457
- });
6458
- ui.registerSimpleSheet(DepositAndWithdrawWithSheetId, DepositAndWithdraw);
6511
+ );
6512
+ ui.registerSimpleSheet(
6513
+ DepositAndWithdrawWithSheetId,
6514
+ InjectableDepositAndWithdraw
6515
+ );
6459
6516
  var AccountSelect = (props) => {
6460
6517
  const { subAccounts = [], value } = props;
6461
6518
  const [open, setOpen] = react.useState(false);
@@ -8310,6 +8367,7 @@ exports.DepositStatus = DepositStatus;
8310
8367
  exports.DepositStatusWidget = DepositStatusWidget;
8311
8368
  exports.ExchangeDivider = ExchangeDivider;
8312
8369
  exports.Fee = Fee;
8370
+ exports.InjectableDepositAndWithdraw = InjectableDepositAndWithdraw;
8313
8371
  exports.QuantityInput = QuantityInput;
8314
8372
  exports.SwapCoin = SwapCoin;
8315
8373
  exports.TransferDialogId = TransferDialogId;