@multiversx/sdk-dapp-liquidity 2.1.0 → 2.1.1-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.
@@ -1,34 +1,37 @@
1
- import { jsx as n, Fragment as Ni, jsxs as s } from "react/jsx-runtime";
2
- import { faSpinner as Ai } from "@fortawesome/free-solid-svg-icons/faSpinner";
3
- import { FontAwesomeIcon as Di } from "@fortawesome/react-fontawesome";
4
- import { formatAmount as Si } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
1
+ import { jsx as n, Fragment as Di, jsxs as s } from "react/jsx-runtime";
2
+ import { faSpinner as Si } from "@fortawesome/free-solid-svg-icons/faSpinner";
3
+ import { FontAwesomeIcon as Ri } from "@fortawesome/react-fontawesome";
4
+ import { formatAmount as Mi } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
5
5
  import { useAppKitNetwork as ki } from "@reown/appkit/react";
6
- import { waitForTransactionReceipt as Ri } from "@wagmi/core";
7
- import Mi from "lodash/debounce";
8
- import { useRef as Pe, useState as x, useMemo as h, useCallback as g, useEffect as y } from "react";
9
- import { toast as M } from "react-toastify";
10
- import { useBridgeTokenSelection as Pi } from "./hooks/useBridgeTokenSelection.mjs";
11
- import { resolveSigningChainType as Vi } from "./utils/bridgeFormHelpers.mjs";
12
- import { MVX_CHAIN_IDS as Ve } from "../../../constants/index.mjs";
13
- import { getApiURL as Ei } from "../../../helpers/getApiURL.mjs";
6
+ import { waitForTransactionReceipt as Ei } from "@wagmi/core";
7
+ import Pi from "lodash/debounce";
8
+ import { useRef as Ve, useState as y, useMemo as g, useCallback as f, useEffect as C } from "react";
9
+ import { toast as k } from "react-toastify";
10
+ import { useBridgeTokenSelection as Vi } from "./hooks/useBridgeTokenSelection.mjs";
11
+ import { resolveSigningChainType as Fi } from "./utils/bridgeFormHelpers.mjs";
12
+ import { MVX_CHAIN_IDS as Fe } from "../../../constants/index.mjs";
13
+ import { getApiURL as Li } from "../../../helpers/getApiURL.mjs";
14
14
  import "../../constants/index.mjs";
15
- import { safeImageUrl as X } from "../../../helpers/safeImageUrl.mjs";
16
- import { ChainType as z } from "../../../types/chainType.mjs";
17
- import { useWeb3App as Fi } from "../../context/useWeb3App.mjs";
18
- import { sameBridgeApiChainId as le, toBridgeApiChainId as Li } from "../../helpers/resolveBridgeApiChainId.mjs";
19
- import { useAccount as Ui } from "../../hooks/useAccount.mjs";
20
- import { useBridgeApiChainId as ji } from "../../hooks/useBridgeApiChainId.mjs";
21
- import { useBridgeFormik as Hi, BridgeFormikValuesEnum as G } from "../../hooks/useBridgeFormik.mjs";
22
- import { useFetchBridgeData as Oi } from "../../hooks/useFetchBridgeData.mjs";
23
- import { useGetChainId as Wi } from "../../hooks/useGetChainId.mjs";
24
- import { useSendTransactions as Xi } from "../../hooks/useSendTransactions.mjs";
25
- import { useSignTransaction as zi } from "../../hooks/useSignTransaction.mjs";
26
- import { useInvalidateHistoryQuery as Gi } from "../../queries/useGetHistory.query.mjs";
27
- import { useGetRateMutation as Qi } from "../../queries/useGetRate.mutation.mjs";
28
- import { mxClsx as Ee } from "../../utils/mxClsx.mjs";
29
- import { AmountCard as Fe } from "../AmountCard/AmountCard.mjs";
30
- import { AmountInput as Le } from "../AmountInput/AmountInput.mjs";
31
- import { MxButton as _i } from "../base/MxButton/MxButton.mjs";
15
+ import { safeImageUrl as z } from "../../../helpers/safeImageUrl.mjs";
16
+ import "@solana/web3.js";
17
+ import "bitcoinjs-lib";
18
+ import "viem";
19
+ import { ChainType as E } from "../../../types/chainType.mjs";
20
+ import { useWeb3App as Ui } from "../../context/useWeb3App.mjs";
21
+ import { sameBridgeApiChainId as de, toBridgeApiChainId as ji } from "../../helpers/resolveBridgeApiChainId.mjs";
22
+ import { useAccount as Hi } from "../../hooks/useAccount.mjs";
23
+ import { useBridgeApiChainId as Oi } from "../../hooks/useBridgeApiChainId.mjs";
24
+ import { useBridgeFormik as Wi, BridgeFormikValuesEnum as G } from "../../hooks/useBridgeFormik.mjs";
25
+ import { useFetchBridgeData as Xi } from "../../hooks/useFetchBridgeData.mjs";
26
+ import { useGetChainId as zi } from "../../hooks/useGetChainId.mjs";
27
+ import { useSendTransactions as Gi } from "../../hooks/useSendTransactions.mjs";
28
+ import { useSignTransaction as Qi } from "../../hooks/useSignTransaction.mjs";
29
+ import { useInvalidateHistoryQuery as _i } from "../../queries/useGetHistory.query.mjs";
30
+ import { useGetRateMutation as $i } from "../../queries/useGetRate.mutation.mjs";
31
+ import { mxClsx as Le } from "../../utils/mxClsx.mjs";
32
+ import { AmountCard as Ue } from "../AmountCard/AmountCard.mjs";
33
+ import { AmountInput as je } from "../AmountInput/AmountInput.mjs";
34
+ import { MxButton as Ki } from "../base/MxButton/MxButton.mjs";
32
35
  import "../base/MxCard/MxCard.mjs";
33
36
  import "../base/MxLink/MxLink.mjs";
34
37
  import "../base/MxSearch/MxSearch.mjs";
@@ -37,332 +40,336 @@ import "@headlessui/react";
37
40
  import "react-dom";
38
41
  import "react-popper";
39
42
  import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
40
- import { BridgeHistory as $i } from "../BridgeHistory/BridgeHistory.mjs";
41
- import { BridgeConnectButton as Ki } from "../Connect/BridgeConnectButton.mjs";
43
+ import { BridgeHistory as Yi } from "../BridgeHistory/BridgeHistory.mjs";
44
+ import { BridgeConnectButton as Ji } from "../Connect/BridgeConnectButton.mjs";
42
45
  import "wagmi";
43
- import { MvxConnectButton as Yi } from "../Connect/MvxConnectButton.mjs";
44
- import { BridgeAccountDisplay as Ji } from "../Connect/BridgeAccountDisplay.mjs";
45
- import { MvxAccountDisplay as Zi } from "../Connect/MvxAccountDisplay.mjs";
46
+ import { MvxConnectButton as Zi } from "../Connect/MvxConnectButton.mjs";
47
+ import { BridgeAccountDisplay as Ti } from "../Connect/BridgeAccountDisplay.mjs";
48
+ import { MvxAccountDisplay as et } from "../Connect/MvxAccountDisplay.mjs";
46
49
  import "@reown/appkit-controllers";
47
- import { ToggleDirection as Ti } from "../ToggleDirection/ToggleDirection.mjs";
48
- import { TokenSelector as Ue } from "../TokenSelector/TokenSelector.mjs";
50
+ import { ToggleDirection as it } from "../ToggleDirection/ToggleDirection.mjs";
51
+ import { TokenSelector as He } from "../TokenSelector/TokenSelector.mjs";
49
52
  let Q;
50
- const $t = ({
53
+ const Tt = ({
51
54
  mvxChainId: _,
52
55
  mvxAddress: l,
53
- username: je,
54
- callbackRoute: He = "/",
55
- firstTokenIdentifier: Oe,
56
- secondTokenIdentifier: We,
56
+ username: Oe,
57
+ callbackRoute: We = "/",
58
+ firstTokenIdentifier: Xe,
59
+ secondTokenIdentifier: ze,
57
60
  firstTokenAmount: P,
58
- secondTokenAmount: w,
59
- refetchTrigger: Xe,
60
- showHistory: ze,
61
- forcedDestinationTokenSymbol: Ge,
61
+ secondTokenAmount: N,
62
+ refetchTrigger: Ge,
63
+ showHistory: Qe,
64
+ forcedDestinationTokenSymbol: _e,
62
65
  onSuccessfullySentTransaction: V,
63
66
  onFailedSentTransaction: I,
64
- onHistoryClose: E,
65
- onMvxConnect: ce,
66
- onMvxDisconnect: Qe,
67
- onNavigate: _e,
68
- onChangeDirection: $e
67
+ onHistoryClose: F,
68
+ onMvxConnect: me,
69
+ onMvxDisconnect: $e,
70
+ onNavigate: Ke,
71
+ onChangeDirection: Ye
69
72
  }) => {
70
- var we, Ne;
71
- const Ke = Pe(null), de = Pe(void 0), [$, Ye] = x(!1), [F, N] = x(!1), [Je, Ze] = x(1), [K, Y] = x(0), f = Ui(), { switchNetwork: me } = ki(), ue = Gi(), {
72
- config: pe,
73
- options: he,
73
+ var Ae, De;
74
+ const Je = Ve(null), ue = Ve(void 0), [$, Ze] = y(!1), [L, w] = y(!1), [Te, ei] = y(1), [K, Y] = y(0), q = Hi(), { switchNetwork: pe } = ki(), he = _i(), {
75
+ config: ge,
76
+ options: fe,
74
77
  supportedChains: A,
75
78
  nativeAuthToken: J,
76
- bridgeOnly: Te
77
- } = Fi(), Z = Wi(), ge = ji(), {
78
- evmTokensWithBalances: ei,
79
- mvxTokensWithBalances: ii,
80
- isTokensLoading: ti,
81
- isLoadingEvmTokensBalances: ni,
82
- isLoadingMvxTokensBalances: ri,
79
+ bridgeOnly: ii
80
+ } = Ui(), Z = zi(), qe = Oi(), {
81
+ evmTokensWithBalances: ti,
82
+ mvxTokensWithBalances: ni,
83
+ isTokensLoading: ri,
84
+ isLoadingEvmTokensBalances: ai,
85
+ isLoadingMvxTokensBalances: oi,
83
86
  chains: D = [],
84
- isChainsLoading: oi
85
- } = Oi({
86
- refetchTrigger: Xe,
87
+ isChainsLoading: si
88
+ } = Xi({
89
+ refetchTrigger: Ge,
87
90
  mvxAddress: l,
88
- mvxApiURL: he.mvxApiURL
89
- }), T = ti || ni || ri || oi, ai = h(() => A.find((i) => le(i.id, Z)), [Z, A]), a = h(() => D.find(
91
+ mvxApiURL: fe.mvxApiURL
92
+ }), T = ri || ai || oi || si, li = g(() => A.find((i) => de(i.id, Z)), [Z, A]), o = g(() => D.find(
90
93
  (i) => i.chainId.toString() === _.toString()
91
- ), [Z, D]), { evm: fe, solana: qe, bitcoin: be, sui: Ie } = zi(), ve = Xi(), {
92
- mutate: si,
94
+ ), [Z, D]), { evm: be, solana: ve, bitcoin: Ie, sui: xe } = Qi(), Be = Gi(), {
95
+ mutate: ci,
93
96
  data: d,
94
97
  isPending: S,
95
- error: v
96
- } = Qi(), k = ((we = v == null ? void 0 : v.response) == null ? void 0 : we.status) === 400 ? (Ne = v == null ? void 0 : v.response) == null ? void 0 : Ne.data.message : void 0, li = g(
98
+ error: x
99
+ } = $i(), R = ((Ae = x == null ? void 0 : x.response) == null ? void 0 : Ae.status) === 400 ? (De = x == null ? void 0 : x.response) == null ? void 0 : De.data.message : void 0, di = f(
97
100
  (i) => {
98
- const b = A.find(
99
- (c) => le(c.id, i.id)
101
+ const v = A.find(
102
+ (c) => de(c.id, i.id)
100
103
  );
101
- b && me(b);
104
+ v && pe(v);
102
105
  },
103
- [A, me]
106
+ [A, pe]
104
107
  ), {
105
108
  firstToken: e,
106
- secondToken: o,
107
- fromOptions: L,
108
- toOptions: ci,
109
+ secondToken: a,
110
+ fromOptions: U,
111
+ toOptions: mi,
109
112
  selectedChainOption: r,
110
- onChangeFirstSelect: Be,
111
- onChangeSecondSelect: di,
112
- handleChangeDirection: mi
113
- } = Pi({
113
+ onChangeFirstSelect: ye,
114
+ onChangeSecondSelect: ui,
115
+ handleChangeDirection: pi
116
+ } = Vi({
114
117
  chains: D,
115
- activeChain: ai,
118
+ activeChain: li,
116
119
  sdkChains: A,
117
- switchNetwork: li,
118
- fromTokens: ei,
119
- toTokens: ii,
120
- firstTokenIdentifier: Oe,
121
- secondTokenIdentifier: We,
122
- forcedDestinationTokenSymbol: Ge,
120
+ switchNetwork: di,
121
+ fromTokens: ti,
122
+ toTokens: ni,
123
+ firstTokenIdentifier: Xe,
124
+ secondTokenIdentifier: ze,
125
+ forcedDestinationTokenSymbol: _e,
123
126
  isTokensLoading: T,
124
- callbackRoute: He,
125
- onNavigate: _e
126
- }), ui = h(() => e ? Ve.includes(e.chainId.toString()) : !1, [e == null ? void 0 : e.chainId]), pi = h(() => o ? Ve.includes(o.chainId.toString()) : !1, [o == null ? void 0 : o.chainId]), [m, hi] = x(P ?? ""), [U, j] = x(w ?? ""), B = h(() => e ? D.find(
127
- (i) => le(i.chainId, e.chainId)
128
- ) ?? r : r, [e == null ? void 0 : e.chainId, D, r]), H = h(
129
- () => Li(e == null ? void 0 : e.chainId) ?? ge,
130
- [e == null ? void 0 : e.chainId, ge]
131
- ), ee = f.address, Ce = f.isConnected && !!ee, ie = m !== "" && U !== "", te = g(
132
- Mi(async (i) => {
133
- !i || !Number(i) || !f.address || !(e != null && e.address) || !(o != null && o.address) || !r || !H || si({
127
+ callbackRoute: We,
128
+ onNavigate: Ke
129
+ }), hi = g(() => e ? Fe.includes(e.chainId.toString()) : !1, [e == null ? void 0 : e.chainId]), gi = g(() => a ? Fe.includes(a.chainId.toString()) : !1, [a == null ? void 0 : a.chainId]), [u, fi] = y(P ?? ""), [j, H] = y(N ?? ""), m = g(() => e ? D.find(
130
+ (i) => de(i.chainId, e.chainId)
131
+ ) ?? r : r, [e == null ? void 0 : e.chainId, D, r]), O = g(
132
+ () => ji(e == null ? void 0 : e.chainId) ?? qe,
133
+ [e == null ? void 0 : e.chainId, qe]
134
+ ), ee = q.address, Ce = q.isConnected && !!ee, ie = u !== "" && j !== "", te = f(
135
+ Pi(async (i) => {
136
+ !i || !Number(i) || !q.address || !(e != null && e.address) || !(a != null && a.address) || !r || !O || ci({
134
137
  nativeAuthToken: J ?? "",
135
138
  body: {
136
139
  tokenIn: e.address,
137
140
  amountIn: i,
138
- fromChainId: H,
139
- tokenOut: o.address,
141
+ fromChainId: O,
142
+ tokenOut: a.address,
140
143
  toChainId: _
141
144
  }
142
145
  });
143
146
  }, 500),
144
147
  [
145
- f.address,
146
- H,
148
+ q.address,
149
+ O,
147
150
  e == null ? void 0 : e.address,
148
- o == null ? void 0 : o.address,
151
+ a == null ? void 0 : a.address,
149
152
  r
150
153
  ]
151
- ), u = g((i) => {
152
- hi(() => i);
153
- }, []), C = g((i) => {
154
- j(() => i);
155
- }, []), gi = g(() => {
156
- E == null || E();
157
- }, [E]), fi = g(() => {
158
- const i = Si({
154
+ ), p = f((i) => {
155
+ fi(() => i);
156
+ }, []), B = f((i) => {
157
+ H(() => i);
158
+ }, []), qi = f(() => {
159
+ F == null || F();
160
+ }, [F]), bi = f(() => {
161
+ const i = Mi({
159
162
  decimals: e == null ? void 0 : e.decimals,
160
163
  input: (e == null ? void 0 : e.balance) ?? "0",
161
164
  addCommas: !1,
162
165
  digits: 4
163
166
  });
164
- q.setFieldValue("firstAmount", i), u(i);
165
- }, [e == null ? void 0 : e.balance, e == null ? void 0 : e.decimals, u]), xe = g(
167
+ b.setFieldValue("firstAmount", i), p(i);
168
+ }, [e == null ? void 0 : e.balance, e == null ? void 0 : e.decimals, p]), Ne = f(
166
169
  async (i) => {
167
- u(""), C(""), ue(), ue(), V == null || V(i);
170
+ p(""), B(""), he(), he(), V == null || V(i);
168
171
  },
169
172
  [
170
- u,
171
- C,
173
+ p,
174
+ B,
172
175
  V
173
176
  ]
174
- ), qi = () => {
175
- mi(), $e();
177
+ ), vi = () => {
178
+ pi(), Ye();
176
179
  };
177
- y(() => {
178
- const i = de.current;
179
- if (de.current = r == null ? void 0 : r.chainId, !!i && (r == null ? void 0 : r.chainId) !== (e == null ? void 0 : e.chainId)) {
180
- const b = L == null ? void 0 : L.find(
180
+ C(() => {
181
+ const i = ue.current;
182
+ if (ue.current = r == null ? void 0 : r.chainId, !!i && (r == null ? void 0 : r.chainId) !== (e == null ? void 0 : e.chainId)) {
183
+ const v = U == null ? void 0 : U.find(
181
184
  (c) => c.chainId.toString() === (r == null ? void 0 : r.chainId)
182
185
  );
183
- if (!b)
186
+ if (!v)
184
187
  return;
185
- Be(b);
188
+ ye(v);
186
189
  }
187
190
  }, [r == null ? void 0 : r.chainId]);
188
- const bi = g(
191
+ const Ii = f(
189
192
  async ({
190
193
  transactions: i,
191
- provider: b
194
+ provider: v
192
195
  }) => {
193
- var Ae, De, Se;
196
+ var Se, Re, Me;
194
197
  const c = [];
195
- N(!0), Y(() => i.length);
198
+ w(!0), Y(() => i.length);
196
199
  try {
197
- let R = -1;
200
+ let M = -1;
198
201
  for (const t of i) {
199
- ++R;
202
+ ++M;
200
203
  try {
201
- switch (Vi(t, B)) {
202
- case z.evm: {
203
- const p = await fe.signTransaction({
204
+ switch (Fi(t, m)) {
205
+ case E.evm: {
206
+ const h = await be.signTransaction({
204
207
  ...t,
205
208
  value: BigInt(t.value),
206
209
  gas: BigInt(t.gasLimit),
207
210
  account: ee
208
211
  });
209
- if (!p || (c.push({
212
+ if (!h || (c.push({
210
213
  ...t,
211
- txHash: p
212
- }), R === i.length - 1 || !p))
214
+ txHash: h
215
+ }), M === i.length - 1 || !h))
213
216
  break;
214
- const W = await Ri(
215
- pe,
217
+ const X = await Ei(
218
+ ge,
216
219
  {
217
220
  confirmations: 1,
218
- hash: p
221
+ hash: h
219
222
  }
220
223
  );
221
224
  console.info({
222
- transactionReceipt: W,
223
- hash: p
225
+ transactionReceipt: X,
226
+ hash: h
224
227
  });
225
228
  break;
226
229
  }
227
- case z.sol:
230
+ case E.sol:
228
231
  if (!t.instructions || !t.feePayer)
229
232
  break;
230
- const se = await qe.signTransaction({
233
+ const ce = await ve.signTransaction({
231
234
  feePayer: t.feePayer,
232
235
  instructions: t.instructions,
233
236
  recentBlockhash: t.recentBlockhash
234
237
  });
235
- if (!se)
238
+ if (!ce)
236
239
  break;
237
240
  c.push({
238
241
  ...t,
239
- txHash: se
242
+ txHash: ce
240
243
  });
241
244
  break;
242
- case z.btc:
245
+ case E.btc:
243
246
  if (!t.bitcoinParams) {
244
247
  console.error("No bitcoin params");
245
248
  break;
246
249
  }
247
- const wi = await be.signTransaction(
250
+ const Ai = await Ie.signTransaction(
248
251
  t.bitcoinParams
249
252
  );
250
253
  c.push({
251
254
  ...t,
252
- txHash: wi
255
+ txHash: Ai
253
256
  });
254
257
  break;
255
- case z.sui: {
256
- const p = (Ae = t.suiParams) == null ? void 0 : Ae.transactionBytes, W = (De = t.suiParams) == null ? void 0 : De.sender;
257
- if (!p || !W) {
258
+ case E.sui: {
259
+ const h = (Se = t.suiParams) == null ? void 0 : Se.transactionBytes, X = (Re = t.suiParams) == null ? void 0 : Re.sender;
260
+ if (!h || !X) {
258
261
  console.error("No Sui transaction bytes or sender address");
259
262
  break;
260
263
  }
261
- const Me = await Ie.signTransaction({
262
- transaction: p,
263
- address: W
264
+ const Pe = await xe.signTransaction({
265
+ transaction: h,
266
+ address: X
264
267
  });
265
- if (!Me)
268
+ if (!Pe)
266
269
  break;
267
270
  c.push({
268
271
  ...t,
269
272
  suiParams: {
270
273
  ...t.suiParams,
271
- signature: Me
274
+ signature: Pe
272
275
  }
273
276
  });
274
277
  break;
275
278
  }
276
279
  default:
277
- M.error("Provider not supported"), N(!1);
280
+ k.error("Provider not supported"), w(!1);
278
281
  return;
279
282
  }
280
283
  Y(
281
- () => i.length - 1 - R
284
+ () => i.length - 1 - M
282
285
  );
283
286
  } catch {
284
- M.dismiss(), M.error("Transaction aborted"), I == null || I("Transaction aborted"), N(!1);
287
+ k.dismiss(), k.error("Transaction aborted"), I == null || I("Transaction aborted"), w(!1);
285
288
  return;
286
289
  }
287
290
  }
288
- const { data: ae } = await ve({
291
+ const { data: le } = await Be({
289
292
  transactions: c,
290
- provider: b,
291
- url: Ei() ?? "",
293
+ provider: v,
294
+ url: Li() ?? "",
292
295
  token: J ?? ""
293
- }), ke = ((Se = ae.transactions) == null ? void 0 : Se.map((t) => t.txHash).filter((t) => !!t)) ?? [], Re = c.map((t) => t.txHash).filter((t) => !!t), yi = ke.length > 0 ? ke : Re.length > 0 ? Re : ae.batchId ? [ae.batchId] : [];
294
- xe(yi), N(!1);
295
- } catch (R) {
296
- console.error(R), M.dismiss(), M.error("Transaction cancelled"), I == null || I("Transaction cancelled"), N(!1), Y(0), vi(), u(""), C("");
296
+ }), ke = ((Me = le.transactions) == null ? void 0 : Me.map((t) => t.txHash).filter((t) => !!t)) ?? [], Ee = c.map((t) => t.txHash).filter((t) => !!t), wi = ke.length > 0 ? ke : Ee.length > 0 ? Ee : le.batchId ? [le.batchId] : [];
297
+ Ne(wi), w(!1);
298
+ } catch (M) {
299
+ console.error(M), k.dismiss(), k.error("Transaction cancelled"), I == null || I("Transaction cancelled"), w(!1), Y(0), Bi(), p(""), B("");
297
300
  }
298
301
  },
299
302
  [
300
- B == null ? void 0 : B.chainType,
303
+ m == null ? void 0 : m.chainType,
301
304
  ee,
302
- pe,
303
- u,
304
- C,
305
+ ge,
306
+ p,
307
+ B,
305
308
  J,
306
- xe,
307
- ve,
309
+ Ne,
310
+ Be,
311
+ Ie.signTransaction,
308
312
  be.signTransaction,
309
- fe.signTransaction,
310
- qe.signTransaction,
311
- Ie.signTransaction
313
+ ve.signTransaction,
314
+ xe.signTransaction
312
315
  ]
313
316
  ), {
314
- formik: q,
317
+ formik: b,
315
318
  firstAmountError: ne,
316
319
  secondAmountError: re,
317
- fromChainError: oe,
318
- handleBlur: O,
319
- handleChange: ye,
320
- handleSubmit: Ii,
321
- resetSwapForm: vi
322
- } = Hi({
320
+ fromChainError: ae,
321
+ senderAddressError: oe,
322
+ receiverAddressError: se,
323
+ handleBlur: W,
324
+ handleChange: we,
325
+ handleSubmit: xi,
326
+ resetSwapForm: Bi
327
+ } = Wi({
323
328
  isMvxConnected: !!l,
324
329
  rate: d,
325
- sender: f.address ?? "",
330
+ sender: q.address ?? "",
326
331
  receiver: l ?? "",
327
332
  firstToken: e,
328
- firstAmount: m,
329
- fromChainId: H,
333
+ firstAmount: u,
334
+ fromChainId: O,
330
335
  toChainId: _,
331
- secondToken: o,
332
- secondAmount: U,
333
- setForceRefetchRate: Ze,
334
- onSubmit: bi
335
- }), Bi = !!(ne || re || oe || k), Ci = h(() => m !== "" ? k ?? ne : void 0, [ne, m, k]), xi = h(() => U !== "" ? oe ?? re : void 0, [oe, re, U]);
336
- return y(() => (m || j(""), te(m), Q && clearInterval(Q), Q = setInterval(() => {
337
- te(m);
338
- }, 50 * 1e3), () => clearInterval(Q)), [m, Je, te]), y(() => {
339
- d != null && d.amountOut && (q.setFieldValue(G.secondAmount, d.amountOut), j(d.amountOut));
340
- }, [d == null ? void 0 : d.amountOut]), y(() => {
341
- k && (q.setFieldValue(G.secondAmount, "0"), j("0"));
342
- }, [k]), y(() => {
343
- P && (q.setFieldValue(
336
+ secondToken: a,
337
+ secondAmount: j,
338
+ setForceRefetchRate: ei,
339
+ senderChainType: m == null ? void 0 : m.chainType,
340
+ receiverChainType: E.mvx,
341
+ onSubmit: Ii
342
+ }), yi = !!(ne || re || ae || R || oe || se), Ci = g(() => u !== "" ? R ?? ne : void 0, [ne, u, R]), Ni = g(() => j !== "" ? ae ?? re : void 0, [ae, re, j]);
343
+ return C(() => (u || H(""), te(u), Q && clearInterval(Q), Q = setInterval(() => {
344
+ te(u);
345
+ }, 50 * 1e3), () => clearInterval(Q)), [u, Te, te]), C(() => {
346
+ d != null && d.amountOut && (b.setFieldValue(G.secondAmount, d.amountOut), H(d.amountOut));
347
+ }, [d == null ? void 0 : d.amountOut]), C(() => {
348
+ R && (b.setFieldValue(G.secondAmount, "0"), H("0"));
349
+ }, [R]), C(() => {
350
+ P && (b.setFieldValue(
344
351
  G.firstAmount,
345
352
  P
346
- ), u(P));
347
- }, []), y(() => {
348
- w && (q.setFieldValue(
353
+ ), p(P));
354
+ }, []), C(() => {
355
+ N && (b.setFieldValue(
349
356
  G.secondAmount,
350
- w
351
- ), C(w));
352
- }, [w]), /* @__PURE__ */ n(Ni, { children: /* @__PURE__ */ s(
357
+ N
358
+ ), B(N));
359
+ }, [N]), /* @__PURE__ */ n(Di, { children: /* @__PURE__ */ s(
353
360
  "form",
354
361
  {
355
- ref: Ke,
362
+ ref: Je,
356
363
  noValidate: !0,
357
364
  className: "liq-flex liq-flex-col liq-gap-1 liq-relative",
358
365
  autoComplete: "off",
359
- onSubmit: Ii,
366
+ onSubmit: xi,
360
367
  children: [
361
- ze && /* @__PURE__ */ n($i, { mvxAddress: l, onClose: gi }),
368
+ Qe && /* @__PURE__ */ n(Yi, { mvxAddress: l, onClose: qi }),
362
369
  /* @__PURE__ */ s(
363
- Fe,
370
+ Ue,
364
371
  {
365
- className: Ee(
372
+ className: Le(
366
373
  "liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",
367
374
  {
368
375
  "liq-pointer-events-none": $,
@@ -373,52 +380,53 @@ const $t = ({
373
380
  /* @__PURE__ */ s("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
374
381
  /* @__PURE__ */ n("span", { children: "From" }),
375
382
  /* @__PURE__ */ n(
376
- Ji,
383
+ Ti,
377
384
  {
378
385
  disabled: S,
379
- activeChain: B
386
+ activeChain: m
380
387
  }
381
388
  )
382
389
  ] }),
390
+ oe && /* @__PURE__ */ n("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: oe }),
383
391
  /* @__PURE__ */ s("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
384
392
  /* @__PURE__ */ n(
385
- Le,
393
+ je,
386
394
  {
387
395
  inputName: "firstAmount",
388
- inputValue: q.values.firstAmount,
396
+ inputValue: b.values.firstAmount,
389
397
  amountError: Ci,
390
398
  disabled: !1,
391
- onInputDebounceChange: u,
392
- onInputChange: ye,
393
- onBlur: O
399
+ onInputDebounceChange: p,
400
+ onInputChange: we,
401
+ onBlur: W
394
402
  }
395
403
  ),
396
404
  /* @__PURE__ */ n(
397
- Ue,
405
+ He,
398
406
  {
399
407
  name: "firstToken",
400
408
  disabled: S,
401
- options: L,
409
+ options: U,
402
410
  areOptionsLoading: T,
403
- isMvxSelector: ui,
411
+ isMvxSelector: hi,
404
412
  isDestination: !1,
405
413
  color: "neutral-850",
406
- onChange: Be,
407
- onBlur: O,
408
- onMaxBtnClick: fi,
414
+ onChange: ye,
415
+ onBlur: W,
416
+ onMaxBtnClick: bi,
409
417
  selectedOption: e,
410
- onTokenSelectorDisplay: (i) => Ye(i)
418
+ onTokenSelectorDisplay: (i) => Ze(i)
411
419
  }
412
420
  )
413
421
  ] })
414
422
  ]
415
423
  }
416
424
  ),
417
- /* @__PURE__ */ n("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: Te && /* @__PURE__ */ n(Ti, { onChangeDirection: qi }) }),
425
+ /* @__PURE__ */ n("div", { className: "liq-absolute liq-left-[6%] liq-top-[40%] -liq-mt-1 liq-z-10", children: ii && /* @__PURE__ */ n(it, { onChangeDirection: vi }) }),
418
426
  /* @__PURE__ */ s(
419
- Fe,
427
+ Ue,
420
428
  {
421
- className: Ee(
429
+ className: Le(
422
430
  "liq-pb-8 liq-pt-6 hover:liq-bg-neutral-700/50 sm:liq-pb-6",
423
431
  {
424
432
  "liq-pointer-events-none": $
@@ -428,44 +436,45 @@ const $t = ({
428
436
  /* @__PURE__ */ s("div", { className: "liq-flex liq-items-center liq-gap-1", children: [
429
437
  /* @__PURE__ */ n("span", { children: "To" }),
430
438
  /* @__PURE__ */ n(
431
- Zi,
439
+ et,
432
440
  {
433
441
  accountAddress: l,
434
- chainIcon: X(a == null ? void 0 : a.pngUrl),
435
- username: je,
436
- accountExplorerUrl: `${he.mvxExplorerAddress}/accounts/${l}`,
442
+ chainIcon: z(o == null ? void 0 : o.pngUrl),
443
+ username: Oe,
444
+ accountExplorerUrl: `${fe.mvxExplorerAddress}/accounts/${l}`,
437
445
  showTag: !0,
438
- onDisconnect: Qe,
439
- onConnect: ce
446
+ onDisconnect: $e,
447
+ onConnect: me
440
448
  }
441
449
  )
442
450
  ] }),
451
+ se && /* @__PURE__ */ n("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: se }),
443
452
  /* @__PURE__ */ s("div", { className: "liq-flex liq-justify-between liq-gap-1", children: [
444
453
  /* @__PURE__ */ n(
445
- Le,
454
+ je,
446
455
  {
447
456
  inputName: "secondAmount",
448
- inputValue: q.values.secondAmount,
449
- amountError: xi,
457
+ inputValue: b.values.secondAmount,
458
+ amountError: Ni,
450
459
  disabled: !1,
451
- onInputDebounceChange: C,
452
- onInputChange: ye,
453
- onBlur: O
460
+ onInputDebounceChange: B,
461
+ onInputChange: we,
462
+ onBlur: W
454
463
  }
455
464
  ),
456
465
  /* @__PURE__ */ n(
457
- Ue,
466
+ He,
458
467
  {
459
468
  name: "secondToken",
460
469
  disabled: S,
461
470
  omitDisableClass: !0,
462
- options: ci,
471
+ options: mi,
463
472
  areOptionsLoading: T,
464
- isMvxSelector: pi,
473
+ isMvxSelector: gi,
465
474
  color: "neutral-850",
466
- onChange: di,
467
- onBlur: O,
468
- selectedOption: o
475
+ onChange: ui,
476
+ onBlur: W,
477
+ selectedOption: a
469
478
  }
470
479
  )
471
480
  ] })
@@ -474,47 +483,47 @@ const $t = ({
474
483
  ),
475
484
  /* @__PURE__ */ s("div", { className: "liq-flex liq-items-center liq-justify-center", children: [
476
485
  !l && /* @__PURE__ */ n(
477
- Yi,
486
+ Zi,
478
487
  {
479
488
  mvxAccountAddress: l,
480
- icon: X(a == null ? void 0 : a.pngUrl),
481
- onClick: ce
489
+ icon: z(o == null ? void 0 : o.pngUrl),
490
+ onClick: me
482
491
  }
483
492
  ),
484
493
  l && !Ce && /* @__PURE__ */ n(
485
- Ki,
494
+ Ji,
486
495
  {
487
496
  className: "liq-w-full liq-rounded-xl liq-bg-neutral-850/50 liq-px-8 liq-py-3 liq-font-semibold liq-text-primary-200 liq-transition-colors liq-duration-200 hover:enabled:liq-bg-primary-700/80 disabled:liq-opacity-50",
488
497
  disabled: S,
489
- activeChain: B
498
+ activeChain: m
490
499
  }
491
500
  ),
492
501
  l && Ce && /* @__PURE__ */ s(
493
- _i,
502
+ Ki,
494
503
  {
495
504
  type: "submit",
496
505
  variant: "neutral-850",
497
506
  className: "liq-w-full disabled:liq-bg-neutral-850/50 liq-py-3 hover:enabled:liq-bg-primary !liq-text-primary-200",
498
- disabled: !ie || S || !l || !f.address || Bi || F,
507
+ disabled: !ie || S || !l || !q.address || yi || L,
499
508
  children: [
500
- ie && !F && /* @__PURE__ */ s("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
509
+ ie && !L && /* @__PURE__ */ s("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
501
510
  /* @__PURE__ */ n("div", { children: "Deposit on " }),
502
511
  /* @__PURE__ */ n(
503
512
  "img",
504
513
  {
505
- src: X(a == null ? void 0 : a.pngUrl),
514
+ src: z(o == null ? void 0 : o.pngUrl),
506
515
  alt: "",
507
516
  className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
508
517
  }
509
518
  ),
510
519
  /* @__PURE__ */ n("div", { children: "MultiversX" })
511
520
  ] }),
512
- !ie && !F && /* @__PURE__ */ n("span", { className: "liq-text-neutral-100", children: "Enter amount" }),
513
- F && /* @__PURE__ */ s("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
521
+ !ie && !L && /* @__PURE__ */ n("span", { className: "liq-text-neutral-100", children: "Enter amount" }),
522
+ L && /* @__PURE__ */ s("div", { className: "liq-flex liq-justify-center liq-items-center liq-gap-2", children: [
514
523
  /* @__PURE__ */ n(
515
- Di,
524
+ Ri,
516
525
  {
517
- icon: Ai,
526
+ icon: Si,
518
527
  spin: !0,
519
528
  className: "liq-mx-1 liq-flex liq-items-center"
520
529
  }
@@ -523,7 +532,7 @@ const $t = ({
523
532
  /* @__PURE__ */ n(
524
533
  "img",
525
534
  {
526
- src: X(a == null ? void 0 : a.pngUrl),
535
+ src: z(o == null ? void 0 : o.pngUrl),
527
536
  alt: "",
528
537
  className: "liq-h-[1.5rem] liq-w-[1.5rem] liq-rounded-lg"
529
538
  }
@@ -534,7 +543,7 @@ const $t = ({
534
543
  }
535
544
  )
536
545
  ] }),
537
- f.address && K > 0 && /* @__PURE__ */ n("div", { className: "liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm", children: /* @__PURE__ */ s("div", { children: [
546
+ q.address && K > 0 && /* @__PURE__ */ n("div", { className: "liq-flex liq-items-center liq-justify-center liq-text-neutral-300 liq-text-sm", children: /* @__PURE__ */ s("div", { children: [
538
547
  "You will be asked to sign ",
539
548
  K,
540
549
  " ",
@@ -547,5 +556,5 @@ const $t = ({
547
556
  ) });
548
557
  };
549
558
  export {
550
- $t as Deposit
559
+ Tt as Deposit
551
560
  };