@multiversx/sdk-dapp-liquidity 2.1.1-alpha.0 → 2.3.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/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/assertRateConfirmationMatchesIntent.spec.js +1 -1
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.mjs +3 -3
- 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 +250 -247
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +228 -225
- 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
|
|
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 me, 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,100 +41,100 @@ 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:
|
|
66
|
-
onFailedSentTransaction:
|
|
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,
|
|
67
|
+
onFailedSentTransaction: v,
|
|
67
68
|
onHistoryClose: F,
|
|
68
|
-
onMvxConnect:
|
|
69
|
-
onMvxDisconnect:
|
|
70
|
-
onNavigate:
|
|
71
|
-
onChangeDirection:
|
|
69
|
+
onMvxConnect: ue,
|
|
70
|
+
onMvxDisconnect: Ke,
|
|
71
|
+
onNavigate: Ye,
|
|
72
|
+
onChangeDirection: Je
|
|
72
73
|
}) => {
|
|
73
|
-
var
|
|
74
|
-
const
|
|
75
|
-
config:
|
|
76
|
-
options:
|
|
77
|
-
supportedChains:
|
|
74
|
+
var De, Se;
|
|
75
|
+
const Ze = Fe(null), pe = Fe(void 0), [$, Te] = y(!1), [L, A] = y(!1), [ei, ii] = y(1), [K, Y] = y(0), I = Wi(), { switchNetwork: he } = Vi(), ge = Yi(), {
|
|
76
|
+
config: fe,
|
|
77
|
+
options: qe,
|
|
78
|
+
supportedChains: w,
|
|
78
79
|
nativeAuthToken: J,
|
|
79
|
-
bridgeOnly:
|
|
80
|
-
} =
|
|
81
|
-
evmTokensWithBalances:
|
|
82
|
-
mvxTokensWithBalances:
|
|
83
|
-
isTokensLoading:
|
|
84
|
-
isLoadingEvmTokensBalances:
|
|
85
|
-
isLoadingMvxTokensBalances:
|
|
80
|
+
bridgeOnly: ti
|
|
81
|
+
} = Hi(), Z = Qi(), be = Xi(), {
|
|
82
|
+
evmTokensWithBalances: ni,
|
|
83
|
+
mvxTokensWithBalances: ri,
|
|
84
|
+
isTokensLoading: ai,
|
|
85
|
+
isLoadingEvmTokensBalances: oi,
|
|
86
|
+
isLoadingMvxTokensBalances: si,
|
|
86
87
|
chains: D = [],
|
|
87
|
-
isChainsLoading:
|
|
88
|
-
} =
|
|
89
|
-
refetchTrigger:
|
|
90
|
-
mvxAddress:
|
|
91
|
-
mvxApiURL:
|
|
92
|
-
}), T =
|
|
88
|
+
isChainsLoading: li
|
|
89
|
+
} = Gi({
|
|
90
|
+
refetchTrigger: Qe,
|
|
91
|
+
mvxAddress: c,
|
|
92
|
+
mvxApiURL: qe.mvxApiURL
|
|
93
|
+
}), T = ai || oi || si || li, ci = g(() => w.find((i) => me(i.id, Z)), [Z, w]), o = g(() => D.find(
|
|
93
94
|
(i) => i.chainId.toString() === _.toString()
|
|
94
|
-
), [Z, D]), { evm:
|
|
95
|
-
mutate:
|
|
96
|
-
data:
|
|
95
|
+
), [Z, D]), { evm: ve, solana: Ie, bitcoin: xe, sui: Be } = Ki(), ye = $i(), {
|
|
96
|
+
mutate: di,
|
|
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, mi = f(
|
|
100
101
|
(i) => {
|
|
101
|
-
const
|
|
102
|
-
(
|
|
102
|
+
const b = w.find(
|
|
103
|
+
(d) => me(d.id, i.id)
|
|
103
104
|
);
|
|
104
|
-
|
|
105
|
+
b && he(b);
|
|
105
106
|
},
|
|
106
|
-
[
|
|
107
|
+
[w, he]
|
|
107
108
|
), {
|
|
108
109
|
firstToken: e,
|
|
109
110
|
secondToken: a,
|
|
110
111
|
fromOptions: U,
|
|
111
|
-
toOptions:
|
|
112
|
+
toOptions: ui,
|
|
112
113
|
selectedChainOption: r,
|
|
113
|
-
onChangeFirstSelect:
|
|
114
|
-
onChangeSecondSelect:
|
|
115
|
-
handleChangeDirection:
|
|
116
|
-
} =
|
|
114
|
+
onChangeFirstSelect: Ne,
|
|
115
|
+
onChangeSecondSelect: pi,
|
|
116
|
+
handleChangeDirection: hi
|
|
117
|
+
} = Li({
|
|
117
118
|
chains: D,
|
|
118
|
-
activeChain:
|
|
119
|
-
sdkChains:
|
|
120
|
-
switchNetwork:
|
|
121
|
-
fromTokens:
|
|
122
|
-
toTokens:
|
|
123
|
-
firstTokenIdentifier:
|
|
124
|
-
secondTokenIdentifier:
|
|
125
|
-
forcedDestinationTokenSymbol:
|
|
119
|
+
activeChain: ci,
|
|
120
|
+
sdkChains: w,
|
|
121
|
+
switchNetwork: mi,
|
|
122
|
+
fromTokens: ni,
|
|
123
|
+
toTokens: ri,
|
|
124
|
+
firstTokenIdentifier: ze,
|
|
125
|
+
secondTokenIdentifier: Ge,
|
|
126
|
+
forcedDestinationTokenSymbol: $e,
|
|
126
127
|
isTokensLoading: T,
|
|
127
|
-
callbackRoute:
|
|
128
|
-
onNavigate:
|
|
129
|
-
}),
|
|
130
|
-
(i) =>
|
|
128
|
+
callbackRoute: Xe,
|
|
129
|
+
onNavigate: Ye
|
|
130
|
+
}), gi = g(() => e ? Le.includes(e.chainId.toString()) : !1, [e == null ? void 0 : e.chainId]), fi = g(() => a ? Le.includes(a.chainId.toString()) : !1, [a == null ? void 0 : a.chainId]), [u, qi] = y(V ?? ""), [j, H] = y(C ?? ""), s = g(() => e ? D.find(
|
|
131
|
+
(i) => me(i.chainId, e.chainId)
|
|
131
132
|
) ?? r : r, [e == null ? void 0 : e.chainId, D, r]), O = g(
|
|
132
|
-
() =>
|
|
133
|
-
[e == null ? void 0 : e.chainId,
|
|
134
|
-
), ee =
|
|
135
|
-
|
|
136
|
-
!i || !Number(i) || !
|
|
133
|
+
() => Oi(e == null ? void 0 : e.chainId) ?? be,
|
|
134
|
+
[e == null ? void 0 : e.chainId, be]
|
|
135
|
+
), bi = _i(s == null ? void 0 : s.chainType), ee = I.address, Ce = I.isConnected && !!ee, ie = u !== "" && j !== "", te = f(
|
|
136
|
+
Fi(async (i) => {
|
|
137
|
+
!i || !Number(i) || !I.address || !(e != null && e.address) || !(a != null && a.address) || !r || !O || di({
|
|
137
138
|
nativeAuthToken: J ?? "",
|
|
138
139
|
body: {
|
|
139
140
|
tokenIn: e.address,
|
|
@@ -145,77 +146,77 @@ const Tt = ({
|
|
|
145
146
|
});
|
|
146
147
|
}, 500),
|
|
147
148
|
[
|
|
148
|
-
|
|
149
|
+
I.address,
|
|
149
150
|
O,
|
|
150
151
|
e == null ? void 0 : e.address,
|
|
151
152
|
a == null ? void 0 : a.address,
|
|
152
153
|
r
|
|
153
154
|
]
|
|
154
155
|
), p = f((i) => {
|
|
155
|
-
|
|
156
|
+
qi(() => 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
|
-
}, [e == null ? void 0 : e.balance, e == null ? void 0 : e.decimals, p]),
|
|
168
|
+
q.setFieldValue("firstAmount", i), p(i);
|
|
169
|
+
}, [e == null ? void 0 : e.balance, e == null ? void 0 : e.decimals, p]), Ae = f(
|
|
169
170
|
async (i) => {
|
|
170
|
-
p(""), B(""),
|
|
171
|
+
p(""), B(""), ge(), ge(), k == null || k(i);
|
|
171
172
|
},
|
|
172
173
|
[
|
|
173
174
|
p,
|
|
174
175
|
B,
|
|
175
|
-
|
|
176
|
+
k
|
|
176
177
|
]
|
|
177
|
-
),
|
|
178
|
-
|
|
178
|
+
), xi = () => {
|
|
179
|
+
hi(), Je();
|
|
179
180
|
};
|
|
180
|
-
|
|
181
|
-
const i =
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
(
|
|
181
|
+
N(() => {
|
|
182
|
+
const i = pe.current;
|
|
183
|
+
if (pe.current = r == null ? void 0 : r.chainId, !!i && (r == null ? void 0 : r.chainId) !== (e == null ? void 0 : e.chainId)) {
|
|
184
|
+
const b = U == null ? void 0 : U.find(
|
|
185
|
+
(d) => d.chainId.toString() === (r == null ? void 0 : r.chainId)
|
|
185
186
|
);
|
|
186
|
-
if (!
|
|
187
|
+
if (!b)
|
|
187
188
|
return;
|
|
188
|
-
|
|
189
|
+
Ne(b);
|
|
189
190
|
}
|
|
190
191
|
}, [r == null ? void 0 : r.chainId]);
|
|
191
|
-
const
|
|
192
|
+
const Bi = f(
|
|
192
193
|
async ({
|
|
193
194
|
transactions: i,
|
|
194
|
-
provider:
|
|
195
|
+
provider: b
|
|
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
|
|
206
|
-
const h = await
|
|
205
|
+
switch (Ui(t, s)) {
|
|
206
|
+
case P.evm: {
|
|
207
|
+
const h = await ve.signTransaction({
|
|
207
208
|
...t,
|
|
208
209
|
value: BigInt(t.value),
|
|
209
210
|
gas: BigInt(t.gasLimit),
|
|
210
211
|
account: ee
|
|
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
|
-
|
|
218
|
+
const X = await ki(
|
|
219
|
+
fe,
|
|
219
220
|
{
|
|
220
221
|
confirmations: 1,
|
|
221
222
|
hash: h
|
|
@@ -227,149 +228,150 @@ 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
|
-
const
|
|
234
|
+
const de = await Ie.signTransaction({
|
|
234
235
|
feePayer: t.feePayer,
|
|
235
236
|
instructions: t.instructions,
|
|
236
237
|
recentBlockhash: t.recentBlockhash
|
|
237
238
|
});
|
|
238
|
-
if (!
|
|
239
|
+
if (!de)
|
|
239
240
|
break;
|
|
240
|
-
|
|
241
|
+
d.push({
|
|
241
242
|
...t,
|
|
242
|
-
txHash:
|
|
243
|
+
txHash: de
|
|
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 xe.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 Be.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"), v == null || v("Transaction aborted"), A(!1);
|
|
288
289
|
return;
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
|
-
const { data:
|
|
292
|
-
transactions:
|
|
293
|
-
provider:
|
|
294
|
-
url:
|
|
292
|
+
const { data: ce } = await ye({
|
|
293
|
+
transactions: d,
|
|
294
|
+
provider: b,
|
|
295
|
+
url: ji() ?? "",
|
|
295
296
|
token: J ?? ""
|
|
296
|
-
}),
|
|
297
|
-
|
|
298
|
-
} catch (
|
|
299
|
-
console.error(
|
|
297
|
+
}), Pe = ((Me = ce.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 : ce.batchId ? [ce.batchId] : [];
|
|
298
|
+
Ae(Di), A(!1);
|
|
299
|
+
} catch (E) {
|
|
300
|
+
console.error(E), M.dismiss(), M.error("Transaction cancelled"), v == null || v("Transaction cancelled"), A(!1), Y(0), Ni(), p(""), B("");
|
|
300
301
|
}
|
|
301
302
|
},
|
|
302
303
|
[
|
|
303
|
-
|
|
304
|
+
s == null ? void 0 : s.chainType,
|
|
304
305
|
ee,
|
|
305
|
-
|
|
306
|
+
fe,
|
|
306
307
|
p,
|
|
307
308
|
B,
|
|
308
309
|
J,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
be.signTransaction,
|
|
310
|
+
Ae,
|
|
311
|
+
ye,
|
|
312
|
+
xe.signTransaction,
|
|
313
313
|
ve.signTransaction,
|
|
314
|
-
|
|
314
|
+
Ie.signTransaction,
|
|
315
|
+
Be.signTransaction
|
|
315
316
|
]
|
|
316
317
|
), {
|
|
317
|
-
formik:
|
|
318
|
+
formik: q,
|
|
318
319
|
firstAmountError: ne,
|
|
319
320
|
secondAmountError: re,
|
|
320
321
|
fromChainError: ae,
|
|
321
322
|
senderAddressError: oe,
|
|
322
323
|
receiverAddressError: se,
|
|
324
|
+
confirmRateError: le,
|
|
323
325
|
handleBlur: W,
|
|
324
326
|
handleChange: we,
|
|
325
|
-
handleSubmit:
|
|
326
|
-
resetSwapForm:
|
|
327
|
-
} =
|
|
328
|
-
isMvxConnected: !!
|
|
329
|
-
rate:
|
|
330
|
-
sender:
|
|
331
|
-
receiver:
|
|
327
|
+
handleSubmit: yi,
|
|
328
|
+
resetSwapForm: Ni
|
|
329
|
+
} = zi({
|
|
330
|
+
isMvxConnected: !!c,
|
|
331
|
+
rate: m,
|
|
332
|
+
sender: bi ?? "",
|
|
333
|
+
receiver: c ?? "",
|
|
332
334
|
firstToken: e,
|
|
333
335
|
firstAmount: u,
|
|
334
336
|
fromChainId: O,
|
|
335
337
|
toChainId: _,
|
|
336
338
|
secondToken: a,
|
|
337
339
|
secondAmount: j,
|
|
338
|
-
setForceRefetchRate:
|
|
339
|
-
senderChainType:
|
|
340
|
-
receiverChainType:
|
|
341
|
-
onSubmit:
|
|
342
|
-
}),
|
|
343
|
-
return
|
|
340
|
+
setForceRefetchRate: ii,
|
|
341
|
+
senderChainType: s == null ? void 0 : s.chainType,
|
|
342
|
+
receiverChainType: P.mvx,
|
|
343
|
+
onSubmit: Bi
|
|
344
|
+
}), Ci = !!(ne || re || ae || R || oe || se || le), Ai = g(() => u !== "" ? R ?? ne : void 0, [ne, u, R]), wi = g(() => j !== "" ? ae ?? re : void 0, [ae, re, j]);
|
|
345
|
+
return N(() => (u || H(""), te(u), Q && clearInterval(Q), Q = setInterval(() => {
|
|
344
346
|
te(u);
|
|
345
|
-
}, 50 * 1e3), () => clearInterval(Q)), [u,
|
|
346
|
-
|
|
347
|
-
}, [
|
|
348
|
-
R && (
|
|
349
|
-
}, [R]),
|
|
350
|
-
|
|
347
|
+
}, 50 * 1e3), () => clearInterval(Q)), [u, ei, te]), N(() => {
|
|
348
|
+
m != null && m.amountOut && (q.setFieldValue(G.secondAmount, m.amountOut), H(m.amountOut));
|
|
349
|
+
}, [m == null ? void 0 : m.amountOut]), N(() => {
|
|
350
|
+
R && (q.setFieldValue(G.secondAmount, "0"), H("0"));
|
|
351
|
+
}, [R]), N(() => {
|
|
352
|
+
V && (q.setFieldValue(
|
|
351
353
|
G.firstAmount,
|
|
352
|
-
|
|
353
|
-
), p(
|
|
354
|
-
}, []),
|
|
355
|
-
|
|
354
|
+
V
|
|
355
|
+
), p(V));
|
|
356
|
+
}, []), N(() => {
|
|
357
|
+
C && (q.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
|
-
inputValue:
|
|
397
|
-
amountError:
|
|
398
|
+
inputValue: q.values.firstAmount,
|
|
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: gi,
|
|
412
414
|
isDestination: !1,
|
|
413
415
|
color: "neutral-850",
|
|
414
|
-
onChange:
|
|
416
|
+
onChange: Ne,
|
|
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: ti && /* @__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:
|
|
443
|
+
accountAddress: c,
|
|
442
444
|
chainIcon: z(o == null ? void 0 : o.pngUrl),
|
|
443
|
-
username:
|
|
444
|
-
accountExplorerUrl: `${
|
|
445
|
+
username: We,
|
|
446
|
+
accountExplorerUrl: `${qe.mvxExplorerAddress}/accounts/${c}`,
|
|
445
447
|
showTag: !0,
|
|
446
|
-
onDisconnect:
|
|
447
|
-
onConnect:
|
|
448
|
+
onDisconnect: Ke,
|
|
449
|
+
onConnect: ue
|
|
448
450
|
}
|
|
449
451
|
)
|
|
450
452
|
] }),
|
|
451
453
|
se && /* @__PURE__ */ n("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: se }),
|
|
452
|
-
/* @__PURE__ */
|
|
454
|
+
le && /* @__PURE__ */ n("div", { className: "liq-text-red-400 liq-text-xs liq-mt-1", children: le }),
|
|
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
|
-
inputValue:
|
|
458
|
-
amountError:
|
|
460
|
+
inputValue: q.values.secondAmount,
|
|
461
|
+
amountError: wi,
|
|
459
462
|
disabled: !1,
|
|
460
463
|
onInputDebounceChange: B,
|
|
461
464
|
onInputChange: we,
|
|
@@ -463,16 +466,16 @@ 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: ui,
|
|
472
475
|
areOptionsLoading: T,
|
|
473
|
-
isMvxSelector:
|
|
476
|
+
isMvxSelector: fi,
|
|
474
477
|
color: "neutral-850",
|
|
475
|
-
onChange:
|
|
478
|
+
onChange: pi,
|
|
476
479
|
onBlur: W,
|
|
477
480
|
selectedOption: a
|
|
478
481
|
}
|
|
@@ -481,32 +484,32 @@ const Tt = ({
|
|
|
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:
|
|
491
|
+
mvxAccountAddress: c,
|
|
489
492
|
icon: z(o == null ? void 0 : o.pngUrl),
|
|
490
|
-
onClick:
|
|
493
|
+
onClick: ue
|
|
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: !ie || S || !
|
|
510
|
+
disabled: !ie || S || !c || !I.address || Ci || L,
|
|
508
511
|
children: [
|
|
509
|
-
ie && !L && /* @__PURE__ */
|
|
512
|
+
ie && !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",
|
|
@@ -519,11 +522,11 @@ const Tt = ({
|
|
|
519
522
|
/* @__PURE__ */ n("div", { children: "MultiversX" })
|
|
520
523
|
] }),
|
|
521
524
|
!ie && !L && /* @__PURE__ */ n("span", { className: "liq-text-neutral-100", children: "Enter amount" }),
|
|
522
|
-
L && /* @__PURE__ */
|
|
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
|
}
|
|
@@ -543,7 +546,7 @@ const Tt = ({
|
|
|
543
546
|
}
|
|
544
547
|
)
|
|
545
548
|
] }),
|
|
546
|
-
|
|
549
|
+
I.address && 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
|
};
|