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