@multiversx/sdk-dapp-liquidity 1.1.7 → 2.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.
Files changed (81) hide show
  1. package/index.js +7 -0
  2. package/index.mjs +8 -1
  3. package/package.json +19 -16
  4. package/reactjs/adapters/SuiAdapter.d.ts +60 -0
  5. package/reactjs/adapters/SuiAdapter.js +350 -0
  6. package/reactjs/adapters/SuiAdapter.mjs +349 -0
  7. package/reactjs/components/AmountInput/AmountInput.js +1 -1
  8. package/reactjs/components/AmountInput/AmountInput.mjs +1 -1
  9. package/reactjs/components/BridgeForm/Deposit.js +57 -18
  10. package/reactjs/components/BridgeForm/Deposit.mjs +57 -18
  11. package/reactjs/components/BridgeForm/Transfer.js +17 -10
  12. package/reactjs/components/BridgeForm/Transfer.mjs +17 -10
  13. package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.js +31 -9
  14. package/reactjs/components/BridgeForm/hooks/useBridgeTokenSelection.mjs +31 -9
  15. package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.d.ts +6 -0
  16. package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.js +18 -0
  17. package/reactjs/components/BridgeForm/utils/bridgeFormHelpers.mjs +18 -0
  18. package/reactjs/components/BridgeHistory/BridgeHistory.js +2 -2
  19. package/reactjs/components/BridgeHistory/BridgeHistory.mjs +2 -2
  20. package/reactjs/components/Connect/BridgeAccountDisplay.js +77 -25
  21. package/reactjs/components/Connect/BridgeAccountDisplay.mjs +77 -25
  22. package/reactjs/components/Connect/BridgeConnectButton.js +1 -1
  23. package/reactjs/components/Connect/BridgeConnectButton.mjs +1 -1
  24. package/reactjs/components/Connect/ChainSelectConnect.d.ts +7 -0
  25. package/reactjs/components/Connect/ChainSelectConnect.js +144 -0
  26. package/reactjs/components/Connect/ChainSelectConnect.mjs +143 -0
  27. package/reactjs/components/Connect/MvxAccountDisplay.js +17 -3
  28. package/reactjs/components/Connect/MvxAccountDisplay.mjs +17 -3
  29. package/reactjs/components/Connect/MvxConnectButton.js +2 -2
  30. package/reactjs/components/Connect/MvxConnectButton.mjs +2 -2
  31. package/reactjs/components/Connect/index.d.ts +1 -0
  32. package/reactjs/components/Connect/index.js +2 -0
  33. package/reactjs/components/Connect/index.mjs +2 -0
  34. package/reactjs/components/TokenSelector/components/TokenItem.js +11 -1
  35. package/reactjs/components/TokenSelector/components/TokenItem.mjs +11 -1
  36. package/reactjs/components/TrimAddress/TrimAddress.js +1 -1
  37. package/reactjs/components/TrimAddress/TrimAddress.mjs +1 -1
  38. package/reactjs/components/index.js +2 -0
  39. package/reactjs/components/index.mjs +2 -0
  40. package/reactjs/constants/chains.d.ts +7 -1
  41. package/reactjs/constants/chains.js +6 -0
  42. package/reactjs/constants/chains.mjs +6 -0
  43. package/reactjs/helpers/index.d.ts +1 -0
  44. package/reactjs/helpers/index.js +7 -0
  45. package/reactjs/helpers/index.mjs +6 -0
  46. package/reactjs/helpers/resolveBridgeApiChainId.d.ts +18 -0
  47. package/reactjs/helpers/resolveBridgeApiChainId.js +41 -0
  48. package/reactjs/helpers/resolveBridgeApiChainId.mjs +40 -0
  49. package/reactjs/hooks/index.d.ts +2 -0
  50. package/reactjs/hooks/index.js +4 -0
  51. package/reactjs/hooks/index.mjs +4 -0
  52. package/reactjs/hooks/useBridgeApiChainId.d.ts +2 -0
  53. package/reactjs/hooks/useBridgeApiChainId.js +14 -0
  54. package/reactjs/hooks/useBridgeApiChainId.mjs +13 -0
  55. package/reactjs/hooks/useFetchTokens.js +17 -17
  56. package/reactjs/hooks/useFetchTokens.mjs +17 -17
  57. package/reactjs/hooks/useGenericSignMessage.d.ts +1 -1
  58. package/reactjs/hooks/useGenericSignMessage.js +14 -0
  59. package/reactjs/hooks/useGenericSignMessage.mjs +14 -0
  60. package/reactjs/hooks/useSignTransaction.d.ts +418 -3
  61. package/reactjs/hooks/useSignTransaction.js +28 -0
  62. package/reactjs/hooks/useSignTransaction.mjs +28 -0
  63. package/reactjs/hooks/useSuiConnect.d.ts +8 -0
  64. package/reactjs/hooks/useSuiConnect.js +87 -0
  65. package/reactjs/hooks/useSuiConnect.mjs +86 -0
  66. package/reactjs/index.js +7 -0
  67. package/reactjs/index.mjs +8 -1
  68. package/reactjs/init/index.js +1 -0
  69. package/reactjs/init/index.mjs +2 -1
  70. package/reactjs/init/init.d.ts +9 -30
  71. package/reactjs/init/init.js +90 -9
  72. package/reactjs/init/init.mjs +91 -10
  73. package/reactjs/queries/useCheckAccount.query.js +4 -14
  74. package/reactjs/queries/useCheckAccount.query.mjs +4 -14
  75. package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -0
  76. package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +1 -0
  77. package/style.css +51 -0
  78. package/types/chainType.d.ts +2 -1
  79. package/types/chainType.js +1 -0
  80. package/types/chainType.mjs +1 -0
  81. package/types/transaction.d.ts +5 -0
@@ -0,0 +1,86 @@
1
+ import { useAppKit, useAppKitState, useDisconnect, useAppKitAccount } from "@reown/appkit/react";
2
+ import { ChainController } from "@reown/appkit-controllers";
3
+ import { useRef, useState, useEffect, useCallback } from "react";
4
+ const SUI_NS = "sui";
5
+ const STUCK_WHILE_MODAL_OPEN_MS = 6e4;
6
+ const STUCK_WHILE_MODAL_CLOSED_MS = 8e3;
7
+ const MODAL_CLOSE_SETTLE_MS = 200;
8
+ const WC_RECONNECT_GRACE_MS = 25e3;
9
+ function useSuiConnect() {
10
+ const { open: openAppKitModal } = useAppKit();
11
+ const { open: isModalOpen } = useAppKitState();
12
+ const { disconnect: appKitDisconnect } = useDisconnect();
13
+ const appKitAccount = useAppKitAccount({ namespace: SUI_NS });
14
+ const wasModalOpenRef = useRef(isModalOpen);
15
+ const [reconnectGraceExpired, setReconnectGraceExpired] = useState(false);
16
+ useEffect(() => {
17
+ const t = globalThis.setTimeout(
18
+ () => setReconnectGraceExpired(true),
19
+ WC_RECONNECT_GRACE_MS
20
+ );
21
+ return () => globalThis.clearTimeout(t);
22
+ }, []);
23
+ const clearStuckConnecting = useCallback(async () => {
24
+ if (appKitAccount.status !== "connecting" || appKitAccount.isConnected) {
25
+ return;
26
+ }
27
+ try {
28
+ await appKitDisconnect({ namespace: SUI_NS });
29
+ } catch {
30
+ }
31
+ try {
32
+ ChainController.resetAccount(SUI_NS);
33
+ } catch {
34
+ }
35
+ }, [appKitAccount.status, appKitAccount.isConnected, appKitDisconnect]);
36
+ useEffect(() => {
37
+ const prev = wasModalOpenRef.current;
38
+ wasModalOpenRef.current = isModalOpen;
39
+ if (prev === true && isModalOpen === false) {
40
+ const t = globalThis.setTimeout(() => {
41
+ void clearStuckConnecting();
42
+ }, MODAL_CLOSE_SETTLE_MS);
43
+ return () => globalThis.clearTimeout(t);
44
+ }
45
+ }, [isModalOpen, clearStuckConnecting]);
46
+ useEffect(() => {
47
+ if (appKitAccount.status !== "connecting" || appKitAccount.isConnected) {
48
+ return;
49
+ }
50
+ if (!reconnectGraceExpired) {
51
+ return;
52
+ }
53
+ const delayMs = isModalOpen ? STUCK_WHILE_MODAL_OPEN_MS : STUCK_WHILE_MODAL_CLOSED_MS;
54
+ const t = globalThis.setTimeout(() => {
55
+ void clearStuckConnecting();
56
+ }, delayMs);
57
+ return () => globalThis.clearTimeout(t);
58
+ }, [
59
+ appKitAccount.status,
60
+ appKitAccount.isConnected,
61
+ isModalOpen,
62
+ reconnectGraceExpired,
63
+ clearStuckConnecting
64
+ ]);
65
+ const connect = useCallback(() => {
66
+ openAppKitModal({ view: "Connect", namespace: SUI_NS });
67
+ }, [openAppKitModal]);
68
+ const disconnect = useCallback(async () => {
69
+ try {
70
+ await appKitDisconnect({ namespace: SUI_NS });
71
+ } catch (error) {
72
+ console.error("Sui disconnect failed:", error);
73
+ }
74
+ }, [appKitDisconnect]);
75
+ return {
76
+ suiAddress: appKitAccount.address ?? null,
77
+ isConnecting: appKitAccount.status === "connecting",
78
+ isConnected: appKitAccount.isConnected,
79
+ connect,
80
+ disconnect,
81
+ cancelPendingConnection: clearStuckConnecting
82
+ };
83
+ }
84
+ export {
85
+ useSuiConnect
86
+ };
package/reactjs/index.js CHANGED
@@ -19,6 +19,7 @@ const reactjs_components_Connect_MvxConnectButton = require("./components/Connec
19
19
  const reactjs_components_Connect_SwitchChainButton = require("./components/Connect/SwitchChainButton.js");
20
20
  const reactjs_components_Connect_BridgeAccountDisplay = require("./components/Connect/BridgeAccountDisplay.js");
21
21
  const reactjs_components_Connect_MvxAccountDisplay = require("./components/Connect/MvxAccountDisplay.js");
22
+ const reactjs_components_Connect_ChainSelectConnect = require("./components/Connect/ChainSelectConnect.js");
22
23
  const reactjs_components_CopyButton_CopyButton = require("./components/CopyButton/CopyButton.js");
23
24
  const reactjs_components_DisplayAmount_DisplayAmount = require("./components/DisplayAmount/DisplayAmount.js");
24
25
  const reactjs_components_SmallLoader_SmallLoader = require("./components/SmallLoader/SmallLoader.js");
@@ -42,9 +43,11 @@ const reactjs_hooks_useDebounce = require("./hooks/useDebounce.js");
42
43
  const reactjs_hooks_useFetchBridgeData = require("./hooks/useFetchBridgeData.js");
43
44
  const reactjs_hooks_useFetchTokens = require("./hooks/useFetchTokens.js");
44
45
  const reactjs_hooks_useGetChainId = require("./hooks/useGetChainId.js");
46
+ const reactjs_hooks_useBridgeApiChainId = require("./hooks/useBridgeApiChainId.js");
45
47
  const reactjs_hooks_useResolveTokenChain = require("./hooks/useResolveTokenChain.js");
46
48
  const reactjs_hooks_useSendTransactions = require("./hooks/useSendTransactions.js");
47
49
  const reactjs_hooks_useSignTransaction = require("./hooks/useSignTransaction.js");
50
+ const reactjs_hooks_useSuiConnect = require("./hooks/useSuiConnect.js");
48
51
  const reactjs_init_init = require("./init/init.js");
49
52
  const reactjs_queries_useGetAllTokens_query = require("./queries/useGetAllTokens.query.js");
50
53
  const reactjs_queries_useGetChains_query = require("./queries/useGetChains.query.js");
@@ -84,6 +87,7 @@ exports.MvxConnectButton = reactjs_components_Connect_MvxConnectButton.MvxConnec
84
87
  exports.SwitchChainButton = reactjs_components_Connect_SwitchChainButton.SwitchChainButton;
85
88
  exports.BridgeAccountDisplay = reactjs_components_Connect_BridgeAccountDisplay.BridgeAccountDisplay;
86
89
  exports.MvxAccountDisplay = reactjs_components_Connect_MvxAccountDisplay.MvxAccountDisplay;
90
+ exports.ChainSelectConnect = reactjs_components_Connect_ChainSelectConnect.ChainSelectConnect;
87
91
  exports.CopyButton = reactjs_components_CopyButton_CopyButton.CopyButton;
88
92
  exports.DisplayAmount = reactjs_components_DisplayAmount_DisplayAmount.DisplayAmount;
89
93
  exports.SmallLoader = reactjs_components_SmallLoader_SmallLoader.SmallLoader;
@@ -110,9 +114,12 @@ exports.useDebounce = reactjs_hooks_useDebounce.useDebounce;
110
114
  exports.useFetchBridgeData = reactjs_hooks_useFetchBridgeData.useFetchBridgeData;
111
115
  exports.useFetchTokens = reactjs_hooks_useFetchTokens.useFetchTokens;
112
116
  exports.useGetChainId = reactjs_hooks_useGetChainId.useGetChainId;
117
+ exports.useBridgeApiChainId = reactjs_hooks_useBridgeApiChainId.useBridgeApiChainId;
113
118
  exports.useResolveTokenChain = reactjs_hooks_useResolveTokenChain.useResolveTokenChain;
114
119
  exports.useSendTransactions = reactjs_hooks_useSendTransactions.useSendTransactions;
115
120
  exports.useSignTransaction = reactjs_hooks_useSignTransaction.useSignTransaction;
121
+ exports.useSuiConnect = reactjs_hooks_useSuiConnect.useSuiConnect;
122
+ exports.SuiMethods = reactjs_init_init.SuiMethods;
116
123
  exports.init = reactjs_init_init.init;
117
124
  exports.useGetAllTokensQuery = reactjs_queries_useGetAllTokens_query.useGetAllTokensQuery;
118
125
  exports.useGetChainsQuery = reactjs_queries_useGetChains_query.useGetChainsQuery;
package/reactjs/index.mjs CHANGED
@@ -16,6 +16,7 @@ import { MvxConnectButton } from "./components/Connect/MvxConnectButton.mjs";
16
16
  import { SwitchChainButton } from "./components/Connect/SwitchChainButton.mjs";
17
17
  import { BridgeAccountDisplay } from "./components/Connect/BridgeAccountDisplay.mjs";
18
18
  import { MvxAccountDisplay } from "./components/Connect/MvxAccountDisplay.mjs";
19
+ import { ChainSelectConnect } from "./components/Connect/ChainSelectConnect.mjs";
19
20
  import { CopyButton } from "./components/CopyButton/CopyButton.mjs";
20
21
  import { DisplayAmount } from "./components/DisplayAmount/DisplayAmount.mjs";
21
22
  import { SmallLoader } from "./components/SmallLoader/SmallLoader.mjs";
@@ -39,10 +40,12 @@ import { useDebounce } from "./hooks/useDebounce.mjs";
39
40
  import { useFetchBridgeData } from "./hooks/useFetchBridgeData.mjs";
40
41
  import { useFetchTokens } from "./hooks/useFetchTokens.mjs";
41
42
  import { useGetChainId } from "./hooks/useGetChainId.mjs";
43
+ import { useBridgeApiChainId } from "./hooks/useBridgeApiChainId.mjs";
42
44
  import { useResolveTokenChain } from "./hooks/useResolveTokenChain.mjs";
43
45
  import { useSendTransactions } from "./hooks/useSendTransactions.mjs";
44
46
  import { useSignTransaction } from "./hooks/useSignTransaction.mjs";
45
- import { init } from "./init/init.mjs";
47
+ import { useSuiConnect } from "./hooks/useSuiConnect.mjs";
48
+ import { SuiMethods, init } from "./init/init.mjs";
46
49
  import { useGetAllTokensQuery } from "./queries/useGetAllTokens.query.mjs";
47
50
  import { useGetChainsQuery } from "./queries/useGetChains.query.mjs";
48
51
  import { invalidateEvmTokensBalances, useGetNonMvxTokensBalancesQuery } from "./queries/useGetNonMvxTokensBalances.query.mjs";
@@ -75,6 +78,7 @@ export {
75
78
  BridgeFormikValuesEnum,
76
79
  BridgeHistory,
77
80
  ChainName,
81
+ ChainSelectConnect,
78
82
  CopyButton,
79
83
  CustomConnectButton,
80
84
  DisplayAmount,
@@ -88,6 +92,7 @@ export {
88
92
  MxSlideover,
89
93
  MxTooltip,
90
94
  SmallLoader,
95
+ SuiMethods,
91
96
  SwitchChainButton,
92
97
  TokenSelector,
93
98
  TransactionToast,
@@ -126,6 +131,7 @@ export {
126
131
  useAppKitState,
127
132
  useAppKitTheme,
128
133
  useBalances,
134
+ useBridgeApiChainId,
129
135
  useBridgeFormik,
130
136
  useDebounce,
131
137
  useDisconnect,
@@ -142,6 +148,7 @@ export {
142
148
  useSecondAmountSchema,
143
149
  useSendTransactions,
144
150
  useSignTransaction,
151
+ useSuiConnect,
145
152
  useTestHasEnoughFunds,
146
153
  useTestIsConnected,
147
154
  useWaitForTransactionReceipt,
@@ -2,4 +2,5 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  const reactjs_init_init = require("./init.js");
5
+ exports.SuiMethods = reactjs_init_init.SuiMethods;
5
6
  exports.init = reactjs_init_init.init;
@@ -1,4 +1,5 @@
1
- import { init } from "./init.mjs";
1
+ import { SuiMethods, init } from "./init.mjs";
2
2
  export {
3
+ SuiMethods,
3
4
  init
4
5
  };
@@ -3,47 +3,26 @@ import { AppKitNetwork } from '@reown/appkit-common';
3
3
  import { AppKitOptions } from '@reown/appkit/react';
4
4
 
5
5
  export type InitOptions = {
6
- /**
7
- * @reown AppKit options
8
- */
9
6
  appKitOptions: Omit<AppKitOptions, 'networks'>;
10
- /**
11
- * WagmiAdapter config
12
- */
13
7
  adapterConfig: Partial<CreateConfigParameters>;
14
- /**
15
- * Accepted chain IDs. The chains with ids [31, 44, 54] will be ignored as these are mapped to the mvx networks as [1, D, T]
16
- */
17
8
  acceptedChainIDs: string[];
18
- /**
19
- * Accepted connectors IDs
20
- */
21
9
  acceptedConnectorsIDs?: string[];
22
- /**
23
- * Liquidity API URL
24
- */
25
10
  apiURL: string;
26
- /**
27
- * Bridge URL. This is used to redirect the user to the bridge status page for tracking transactions (history). Will be removed in the next major release.
28
- */
29
11
  bridgeURL: string;
30
- /**
31
- * MultiversX API URL
32
- */
33
12
  mvxApiURL: string;
34
- /**
35
- * MultiversX Explorer URL
36
- */
37
13
  mvxExplorerAddress: string;
38
- /**
39
- * MultiversX Chain ID
40
- * Possible options 31 | 44 | 54 which are mapped to 1 | D | T
41
- */
42
14
  mvxChainId: '31' | '44' | '54';
15
+ suiEnvironment?: 'mainnet' | 'testnet' | 'devnet';
16
+ suiFeaturedWalletIds?: string[];
43
17
  };
44
- export declare function init(options: InitOptions): {
18
+ export declare enum SuiMethods {
19
+ SIGN_TRANSACTION = "sui_signTransaction",
20
+ SIGN_AND_EXECUTE_TRANSACTION = "sui_signAndExecuteTransaction",
21
+ SIGN_PERSONAL_MESSAGE = "sui_signPersonalMessage"
22
+ }
23
+ export declare function init(options: InitOptions): Promise<{
45
24
  config: Config;
46
25
  appKit: any;
47
26
  options: InitOptions;
48
27
  supportedChains: AppKitNetwork[];
49
- };
28
+ }>;
@@ -7,6 +7,7 @@ const appkitAdapterWagmi = require("@reown/appkit-adapter-wagmi");
7
7
  const viemNetworks = require("viem/chains");
8
8
  const constants_index = require("../../constants/index.js");
9
9
  const store_inMemoryStore = require("../../store/inMemoryStore.js");
10
+ const reactjs_adapters_SuiAdapter = require("../adapters/SuiAdapter.js");
10
11
  function _interopNamespaceDefault(e) {
11
12
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
12
13
  if (e) {
@@ -24,36 +25,116 @@ function _interopNamespaceDefault(e) {
24
25
  return Object.freeze(n);
25
26
  }
26
27
  const viemNetworks__namespace = /* @__PURE__ */ _interopNamespaceDefault(viemNetworks);
27
- function init(options) {
28
+ const suiMainnet = networks.defineChain({
29
+ id: "mainnet",
30
+ name: "SUI Mainnet",
31
+ nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
32
+ rpcUrls: {
33
+ default: { http: ["https://fullnode.mainnet.sui.io:443"] }
34
+ },
35
+ blockExplorers: {
36
+ default: { name: "SUI Explorer", url: "https://explorer.sui.io/" }
37
+ },
38
+ chainNamespace: "sui",
39
+ caipNetworkId: "sui:mainnet"
40
+ });
41
+ const suiTestnet = networks.defineChain({
42
+ id: "testnet",
43
+ name: "SUI Testnet",
44
+ nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
45
+ rpcUrls: {
46
+ default: { http: ["https://fullnode.testnet.sui.io:443"] }
47
+ },
48
+ blockExplorers: {
49
+ default: {
50
+ name: "SUI Explorer",
51
+ url: "https://explorer.sui.io/?network=testnet"
52
+ }
53
+ },
54
+ chainNamespace: "sui",
55
+ caipNetworkId: "sui:testnet"
56
+ });
57
+ const suiDevnet = networks.defineChain({
58
+ id: "devnet",
59
+ name: "SUI Devnet",
60
+ nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
61
+ rpcUrls: {
62
+ default: { http: ["https://fullnode.devnet.sui.io:443"] }
63
+ },
64
+ blockExplorers: {
65
+ default: {
66
+ name: "SUI Explorer",
67
+ url: "https://explorer.sui.io/?network=devnet"
68
+ }
69
+ },
70
+ chainNamespace: "sui",
71
+ caipNetworkId: "sui:devnet"
72
+ });
73
+ const suiNetworkDefinitions = {
74
+ mainnet: suiMainnet,
75
+ testnet: suiTestnet,
76
+ devnet: suiDevnet
77
+ };
78
+ var SuiMethods = /* @__PURE__ */ ((SuiMethods2) => {
79
+ SuiMethods2["SIGN_TRANSACTION"] = "sui_signTransaction";
80
+ SuiMethods2["SIGN_AND_EXECUTE_TRANSACTION"] = "sui_signAndExecuteTransaction";
81
+ SuiMethods2["SIGN_PERSONAL_MESSAGE"] = "sui_signPersonalMessage";
82
+ return SuiMethods2;
83
+ })(SuiMethods || {});
84
+ async function init(options) {
85
+ var _a, _b, _c, _d;
28
86
  const store = store_inMemoryStore.InMemoryStore.getInstance();
29
87
  store.setItem("apiURL", options.apiURL);
30
88
  store.setItem("bridgeURL", options.bridgeURL);
31
89
  store.setItem("mvxApiURL", options.mvxApiURL);
32
90
  store.setItem("mvxExplorerAddress", options.mvxExplorerAddress);
33
91
  store.setItem("mvxChainId", options.mvxChainId);
34
- const networks$1 = {
35
- ...viemNetworks__namespace
36
- };
92
+ const networks$1 = { ...viemNetworks__namespace };
37
93
  const acceptedNetworks = Object.values(networks$1).filter(
38
94
  (chain) => options.acceptedChainIDs.includes(chain.id.toString()) && !constants_index.MVX_CHAIN_IDS.includes(chain.id.toString())
39
95
  ).map((network) => network);
40
- const supportedChains = [networks.mainnet, networks.bsc, networks.bscTestnet, ...acceptedNetworks];
96
+ const evmChains = [
97
+ networks.mainnet,
98
+ networks.bsc,
99
+ networks.bscTestnet,
100
+ ...acceptedNetworks
101
+ ];
102
+ const allNetworks = [...evmChains];
103
+ if (options.suiEnvironment) {
104
+ const suiNetwork = suiNetworkDefinitions[options.suiEnvironment];
105
+ allNetworks.push(suiNetwork);
106
+ }
41
107
  const wagmiAdapter = new appkitAdapterWagmi.WagmiAdapter({
42
108
  ...options.adapterConfig,
43
109
  ssr: options.adapterConfig.ssr ?? true,
44
110
  projectId: options.appKitOptions.projectId,
45
- networks: supportedChains
111
+ networks: evmChains
46
112
  });
113
+ const adapters = [wagmiAdapter];
114
+ if (options.suiEnvironment) {
115
+ const suiNetwork = suiNetworkDefinitions[options.suiEnvironment];
116
+ const explicitSuiCaip = suiNetwork.caipNetworkId ?? `sui:${suiNetwork.id}`;
117
+ adapters.push(new reactjs_adapters_SuiAdapter.SuiAdapter({ explicitCaipChains: [explicitSuiCaip] }));
118
+ }
47
119
  const appKit = react.createAppKit({
48
120
  ...options.appKitOptions,
49
- adapters: [wagmiAdapter],
50
- networks: [supportedChains[0], ...supportedChains.slice(1)]
121
+ adapters,
122
+ networks: [allNetworks[0], ...allNetworks.slice(1)]
51
123
  });
124
+ await appKit.ready();
125
+ if (options.suiEnvironment) {
126
+ const wc = await appKit.getUniversalProvider();
127
+ const suiNs = (_b = (_a = wc == null ? void 0 : wc.session) == null ? void 0 : _a.namespaces) == null ? void 0 : _b["sui"];
128
+ if (((_c = suiNs == null ? void 0 : suiNs.accounts) == null ? void 0 : _c.length) && !appKit.getCaipAddress("sui")) {
129
+ await ((_d = appKit.syncWalletConnectAccount) == null ? void 0 : _d.call(appKit));
130
+ }
131
+ }
52
132
  return {
53
133
  config: wagmiAdapter.wagmiConfig,
54
134
  appKit,
55
135
  options,
56
- supportedChains
136
+ supportedChains: allNetworks
57
137
  };
58
138
  }
139
+ exports.SuiMethods = SuiMethods;
59
140
  exports.init = init;
@@ -1,41 +1,122 @@
1
- import { mainnet, bsc, bscTestnet } from "@reown/appkit/networks";
1
+ import { defineChain, mainnet, bsc, bscTestnet } from "@reown/appkit/networks";
2
2
  import { createAppKit } from "@reown/appkit/react";
3
3
  import { WagmiAdapter } from "@reown/appkit-adapter-wagmi";
4
4
  import * as viemNetworks from "viem/chains";
5
5
  import { MVX_CHAIN_IDS } from "../../constants/index.mjs";
6
6
  import { InMemoryStore } from "../../store/inMemoryStore.mjs";
7
- function init(options) {
7
+ import { SuiAdapter } from "../adapters/SuiAdapter.mjs";
8
+ const suiMainnet = defineChain({
9
+ id: "mainnet",
10
+ name: "SUI Mainnet",
11
+ nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
12
+ rpcUrls: {
13
+ default: { http: ["https://fullnode.mainnet.sui.io:443"] }
14
+ },
15
+ blockExplorers: {
16
+ default: { name: "SUI Explorer", url: "https://explorer.sui.io/" }
17
+ },
18
+ chainNamespace: "sui",
19
+ caipNetworkId: "sui:mainnet"
20
+ });
21
+ const suiTestnet = defineChain({
22
+ id: "testnet",
23
+ name: "SUI Testnet",
24
+ nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
25
+ rpcUrls: {
26
+ default: { http: ["https://fullnode.testnet.sui.io:443"] }
27
+ },
28
+ blockExplorers: {
29
+ default: {
30
+ name: "SUI Explorer",
31
+ url: "https://explorer.sui.io/?network=testnet"
32
+ }
33
+ },
34
+ chainNamespace: "sui",
35
+ caipNetworkId: "sui:testnet"
36
+ });
37
+ const suiDevnet = defineChain({
38
+ id: "devnet",
39
+ name: "SUI Devnet",
40
+ nativeCurrency: { name: "SUI", symbol: "SUI", decimals: 9 },
41
+ rpcUrls: {
42
+ default: { http: ["https://fullnode.devnet.sui.io:443"] }
43
+ },
44
+ blockExplorers: {
45
+ default: {
46
+ name: "SUI Explorer",
47
+ url: "https://explorer.sui.io/?network=devnet"
48
+ }
49
+ },
50
+ chainNamespace: "sui",
51
+ caipNetworkId: "sui:devnet"
52
+ });
53
+ const suiNetworkDefinitions = {
54
+ mainnet: suiMainnet,
55
+ testnet: suiTestnet,
56
+ devnet: suiDevnet
57
+ };
58
+ var SuiMethods = /* @__PURE__ */ ((SuiMethods2) => {
59
+ SuiMethods2["SIGN_TRANSACTION"] = "sui_signTransaction";
60
+ SuiMethods2["SIGN_AND_EXECUTE_TRANSACTION"] = "sui_signAndExecuteTransaction";
61
+ SuiMethods2["SIGN_PERSONAL_MESSAGE"] = "sui_signPersonalMessage";
62
+ return SuiMethods2;
63
+ })(SuiMethods || {});
64
+ async function init(options) {
65
+ var _a, _b, _c, _d;
8
66
  const store = InMemoryStore.getInstance();
9
67
  store.setItem("apiURL", options.apiURL);
10
68
  store.setItem("bridgeURL", options.bridgeURL);
11
69
  store.setItem("mvxApiURL", options.mvxApiURL);
12
70
  store.setItem("mvxExplorerAddress", options.mvxExplorerAddress);
13
71
  store.setItem("mvxChainId", options.mvxChainId);
14
- const networks = {
15
- ...viemNetworks
16
- };
72
+ const networks = { ...viemNetworks };
17
73
  const acceptedNetworks = Object.values(networks).filter(
18
74
  (chain) => options.acceptedChainIDs.includes(chain.id.toString()) && !MVX_CHAIN_IDS.includes(chain.id.toString())
19
75
  ).map((network) => network);
20
- const supportedChains = [mainnet, bsc, bscTestnet, ...acceptedNetworks];
76
+ const evmChains = [
77
+ mainnet,
78
+ bsc,
79
+ bscTestnet,
80
+ ...acceptedNetworks
81
+ ];
82
+ const allNetworks = [...evmChains];
83
+ if (options.suiEnvironment) {
84
+ const suiNetwork = suiNetworkDefinitions[options.suiEnvironment];
85
+ allNetworks.push(suiNetwork);
86
+ }
21
87
  const wagmiAdapter = new WagmiAdapter({
22
88
  ...options.adapterConfig,
23
89
  ssr: options.adapterConfig.ssr ?? true,
24
90
  projectId: options.appKitOptions.projectId,
25
- networks: supportedChains
91
+ networks: evmChains
26
92
  });
93
+ const adapters = [wagmiAdapter];
94
+ if (options.suiEnvironment) {
95
+ const suiNetwork = suiNetworkDefinitions[options.suiEnvironment];
96
+ const explicitSuiCaip = suiNetwork.caipNetworkId ?? `sui:${suiNetwork.id}`;
97
+ adapters.push(new SuiAdapter({ explicitCaipChains: [explicitSuiCaip] }));
98
+ }
27
99
  const appKit = createAppKit({
28
100
  ...options.appKitOptions,
29
- adapters: [wagmiAdapter],
30
- networks: [supportedChains[0], ...supportedChains.slice(1)]
101
+ adapters,
102
+ networks: [allNetworks[0], ...allNetworks.slice(1)]
31
103
  });
104
+ await appKit.ready();
105
+ if (options.suiEnvironment) {
106
+ const wc = await appKit.getUniversalProvider();
107
+ const suiNs = (_b = (_a = wc == null ? void 0 : wc.session) == null ? void 0 : _a.namespaces) == null ? void 0 : _b["sui"];
108
+ if (((_c = suiNs == null ? void 0 : suiNs.accounts) == null ? void 0 : _c.length) && !appKit.getCaipAddress("sui")) {
109
+ await ((_d = appKit.syncWalletConnectAccount) == null ? void 0 : _d.call(appKit));
110
+ }
111
+ }
32
112
  return {
33
113
  config: wagmiAdapter.wagmiConfig,
34
114
  appKit,
35
115
  options,
36
- supportedChains
116
+ supportedChains: allNetworks
37
117
  };
38
118
  }
39
119
  export {
120
+ SuiMethods,
40
121
  init
41
122
  };
@@ -6,27 +6,17 @@ const reactQuery = require("@tanstack/react-query");
6
6
  const api_checkAccount = require("../../api/checkAccount.js");
7
7
  const helpers_getApiURL = require("../../helpers/getApiURL.js");
8
8
  const reactjs_context_useWeb3App = require("../context/useWeb3App.js");
9
- require("yup");
10
- require("react");
11
- require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
12
- require("bignumber.js");
13
- require("wagmi");
14
- require("axios");
15
- require("formik");
16
- const reactjs_hooks_useGetChainId = require("../hooks/useGetChainId.js");
17
- require("../constants/index.js");
18
- require("@reown/appkit-adapter-solana/react");
19
- require("@solana/web3.js");
9
+ const reactjs_hooks_useBridgeApiChainId = require("../hooks/useBridgeApiChainId.js");
20
10
  const useCheckAccountQuery = () => {
21
11
  const { address } = react.useAppKitAccount();
22
- const chainId = reactjs_hooks_useGetChainId.useGetChainId();
12
+ const bridgeApiChainId = reactjs_hooks_useBridgeApiChainId.useBridgeApiChainId();
23
13
  const { nativeAuthToken } = reactjs_context_useWeb3App.useWeb3App();
24
14
  const queryFn = async () => {
25
15
  try {
26
16
  const { data } = await api_checkAccount.checkAccount({
27
17
  url: helpers_getApiURL.getApiURL(),
28
18
  walletAddress: address ?? "",
29
- chainId: chainId ? chainId.toString() : "",
19
+ chainId: bridgeApiChainId ?? "",
30
20
  nativeAuthToken
31
21
  });
32
22
  return data;
@@ -39,7 +29,7 @@ const useCheckAccountQuery = () => {
39
29
  return ((_a = error.response) == null ? void 0 : _a.status) === 404;
40
30
  };
41
31
  return reactQuery.useQuery({
42
- queryKey: ["check-account", address, chainId, nativeAuthToken],
32
+ queryKey: ["check-account", address, bridgeApiChainId, nativeAuthToken],
43
33
  queryFn,
44
34
  retry,
45
35
  refetchOnWindowFocus: false,
@@ -3,27 +3,17 @@ import { useQuery } from "@tanstack/react-query";
3
3
  import { checkAccount } from "../../api/checkAccount.mjs";
4
4
  import { getApiURL } from "../../helpers/getApiURL.mjs";
5
5
  import { useWeb3App } from "../context/useWeb3App.mjs";
6
- import "yup";
7
- import "react";
8
- import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
9
- import "bignumber.js";
10
- import "wagmi";
11
- import "axios";
12
- import "formik";
13
- import { useGetChainId } from "../hooks/useGetChainId.mjs";
14
- import "../constants/index.mjs";
15
- import "@reown/appkit-adapter-solana/react";
16
- import "@solana/web3.js";
6
+ import { useBridgeApiChainId } from "../hooks/useBridgeApiChainId.mjs";
17
7
  const useCheckAccountQuery = () => {
18
8
  const { address } = useAppKitAccount();
19
- const chainId = useGetChainId();
9
+ const bridgeApiChainId = useBridgeApiChainId();
20
10
  const { nativeAuthToken } = useWeb3App();
21
11
  const queryFn = async () => {
22
12
  try {
23
13
  const { data } = await checkAccount({
24
14
  url: getApiURL(),
25
15
  walletAddress: address ?? "",
26
- chainId: chainId ? chainId.toString() : "",
16
+ chainId: bridgeApiChainId ?? "",
27
17
  nativeAuthToken
28
18
  });
29
19
  return data;
@@ -36,7 +26,7 @@ const useCheckAccountQuery = () => {
36
26
  return ((_a = error.response) == null ? void 0 : _a.status) === 404;
37
27
  };
38
28
  return useQuery({
39
- queryKey: ["check-account", address, chainId, nativeAuthToken],
29
+ queryKey: ["check-account", address, bridgeApiChainId, nativeAuthToken],
40
30
  queryFn,
41
31
  retry,
42
32
  refetchOnWindowFocus: false,
@@ -16,6 +16,7 @@ require("../context/Web3AppProvider.js");
16
16
  require("../constants/index.js");
17
17
  require("@reown/appkit-adapter-solana/react");
18
18
  require("@solana/web3.js");
19
+ require("@reown/appkit-controllers");
19
20
  const useGetNonMvxTokensBalancesQuery = ({
20
21
  tokens,
21
22
  chainId
@@ -13,6 +13,7 @@ import "../context/Web3AppProvider.mjs";
13
13
  import "../constants/index.mjs";
14
14
  import "@reown/appkit-adapter-solana/react";
15
15
  import "@solana/web3.js";
16
+ import "@reown/appkit-controllers";
16
17
  const useGetNonMvxTokensBalancesQuery = ({
17
18
  tokens,
18
19
  chainId