@multiversx/sdk-dapp-liquidity 2.1.0 → 2.2.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/index.d.ts +1 -0
- package/helpers/index.js +1 -1
- package/helpers/index.mjs +18 -16
- package/helpers/isValidAddressForChainType.d.ts +3 -0
- package/helpers/isValidAddressForChainType.js +2 -0
- package/helpers/isValidAddressForChainType.mjs +37 -0
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.js +1 -1
- package/helpers/tests/assertRateConfirmationMatchesIntent.spec.mjs +3 -3
- package/helpers/tests/isValidAddressForChainType.spec.d.ts +1 -0
- package/helpers/tests/isValidAddressForChainType.spec.js +2 -0
- package/helpers/tests/isValidAddressForChainType.spec.mjs +102 -0
- package/index.js +1 -1
- package/index.mjs +162 -160
- package/package.json +3 -2
- package/reactjs/components/BridgeForm/Deposit.js +1 -1
- package/reactjs/components/BridgeForm/Deposit.mjs +269 -260
- package/reactjs/components/BridgeForm/Transfer.js +1 -1
- package/reactjs/components/BridgeForm/Transfer.mjs +210 -201
- package/reactjs/components/BridgeHistory/BridgeHistory.js +1 -1
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +5 -3
- package/reactjs/components/Connect/BridgeConnectButton.js +1 -1
- package/reactjs/components/Connect/BridgeConnectButton.mjs +17 -14
- package/reactjs/hooks/useBridgeFormik.d.ts +6 -1
- package/reactjs/hooks/useBridgeFormik.js +1 -1
- package/reactjs/hooks/useBridgeFormik.mjs +94 -85
- package/reactjs/queries/useGetNonMvxTokensBalances.query.js +1 -1
- package/reactjs/queries/useGetNonMvxTokensBalances.query.mjs +11 -9
- package/style.css +1 -1
|
@@ -1,34 +1,37 @@
|
|
|
1
|
-
import { jsx as n, Fragment as
|
|
2
|
-
import { faSpinner as
|
|
3
|
-
import { FontAwesomeIcon as
|
|
4
|
-
import { formatAmount as
|
|
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
|
|
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
|
|
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
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
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
|
|
41
|
-
import { BridgeConnectButton as
|
|
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
|
|
44
|
-
import { BridgeAccountDisplay as
|
|
45
|
-
import { MvxAccountDisplay as
|
|
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
|
|
48
|
-
import { TokenSelector as
|
|
50
|
+
import { ToggleDirection as it } from "../ToggleDirection/ToggleDirection.mjs";
|
|
51
|
+
import { TokenSelector as He } from "../TokenSelector/TokenSelector.mjs";
|
|
49
52
|
let Q;
|
|
50
|
-
const
|
|
53
|
+
const Tt = ({
|
|
51
54
|
mvxChainId: _,
|
|
52
55
|
mvxAddress: l,
|
|
53
|
-
username:
|
|
54
|
-
callbackRoute:
|
|
55
|
-
firstTokenIdentifier:
|
|
56
|
-
secondTokenIdentifier:
|
|
56
|
+
username: Oe,
|
|
57
|
+
callbackRoute: We = "/",
|
|
58
|
+
firstTokenIdentifier: Xe,
|
|
59
|
+
secondTokenIdentifier: ze,
|
|
57
60
|
firstTokenAmount: P,
|
|
58
|
-
secondTokenAmount:
|
|
59
|
-
refetchTrigger:
|
|
60
|
-
showHistory:
|
|
61
|
-
forcedDestinationTokenSymbol:
|
|
61
|
+
secondTokenAmount: N,
|
|
62
|
+
refetchTrigger: Ge,
|
|
63
|
+
showHistory: Qe,
|
|
64
|
+
forcedDestinationTokenSymbol: _e,
|
|
62
65
|
onSuccessfullySentTransaction: V,
|
|
63
66
|
onFailedSentTransaction: I,
|
|
64
|
-
onHistoryClose:
|
|
65
|
-
onMvxConnect:
|
|
66
|
-
onMvxDisconnect:
|
|
67
|
-
onNavigate:
|
|
68
|
-
onChangeDirection:
|
|
67
|
+
onHistoryClose: F,
|
|
68
|
+
onMvxConnect: me,
|
|
69
|
+
onMvxDisconnect: $e,
|
|
70
|
+
onNavigate: Ke,
|
|
71
|
+
onChangeDirection: Ye
|
|
69
72
|
}) => {
|
|
70
|
-
var
|
|
71
|
-
const
|
|
72
|
-
config:
|
|
73
|
-
options:
|
|
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:
|
|
77
|
-
} =
|
|
78
|
-
evmTokensWithBalances:
|
|
79
|
-
mvxTokensWithBalances:
|
|
80
|
-
isTokensLoading:
|
|
81
|
-
isLoadingEvmTokensBalances:
|
|
82
|
-
isLoadingMvxTokensBalances:
|
|
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:
|
|
85
|
-
} =
|
|
86
|
-
refetchTrigger:
|
|
87
|
+
isChainsLoading: si
|
|
88
|
+
} = Xi({
|
|
89
|
+
refetchTrigger: Ge,
|
|
87
90
|
mvxAddress: l,
|
|
88
|
-
mvxApiURL:
|
|
89
|
-
}), T =
|
|
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:
|
|
92
|
-
mutate:
|
|
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:
|
|
96
|
-
} =
|
|
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
|
|
99
|
-
(c) =>
|
|
101
|
+
const v = A.find(
|
|
102
|
+
(c) => de(c.id, i.id)
|
|
100
103
|
);
|
|
101
|
-
|
|
104
|
+
v && pe(v);
|
|
102
105
|
},
|
|
103
|
-
[A,
|
|
106
|
+
[A, pe]
|
|
104
107
|
), {
|
|
105
108
|
firstToken: e,
|
|
106
|
-
secondToken:
|
|
107
|
-
fromOptions:
|
|
108
|
-
toOptions:
|
|
109
|
+
secondToken: a,
|
|
110
|
+
fromOptions: U,
|
|
111
|
+
toOptions: mi,
|
|
109
112
|
selectedChainOption: r,
|
|
110
|
-
onChangeFirstSelect:
|
|
111
|
-
onChangeSecondSelect:
|
|
112
|
-
handleChangeDirection:
|
|
113
|
-
} =
|
|
113
|
+
onChangeFirstSelect: ye,
|
|
114
|
+
onChangeSecondSelect: ui,
|
|
115
|
+
handleChangeDirection: pi
|
|
116
|
+
} = Vi({
|
|
114
117
|
chains: D,
|
|
115
|
-
activeChain:
|
|
118
|
+
activeChain: li,
|
|
116
119
|
sdkChains: A,
|
|
117
|
-
switchNetwork:
|
|
118
|
-
fromTokens:
|
|
119
|
-
toTokens:
|
|
120
|
-
firstTokenIdentifier:
|
|
121
|
-
secondTokenIdentifier:
|
|
122
|
-
forcedDestinationTokenSymbol:
|
|
120
|
+
switchNetwork: di,
|
|
121
|
+
fromTokens: ti,
|
|
122
|
+
toTokens: ni,
|
|
123
|
+
firstTokenIdentifier: Xe,
|
|
124
|
+
secondTokenIdentifier: ze,
|
|
125
|
+
forcedDestinationTokenSymbol: _e,
|
|
123
126
|
isTokensLoading: T,
|
|
124
|
-
callbackRoute:
|
|
125
|
-
onNavigate:
|
|
126
|
-
}),
|
|
127
|
-
(i) =>
|
|
128
|
-
) ?? r : r, [e == null ? void 0 : e.chainId, D, r]),
|
|
129
|
-
() =>
|
|
130
|
-
[e == null ? void 0 : e.chainId,
|
|
131
|
-
), ee =
|
|
132
|
-
|
|
133
|
-
!i || !Number(i) || !
|
|
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:
|
|
139
|
-
tokenOut:
|
|
141
|
+
fromChainId: O,
|
|
142
|
+
tokenOut: a.address,
|
|
140
143
|
toChainId: _
|
|
141
144
|
}
|
|
142
145
|
});
|
|
143
146
|
}, 500),
|
|
144
147
|
[
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
q.address,
|
|
149
|
+
O,
|
|
147
150
|
e == null ? void 0 : e.address,
|
|
148
|
-
|
|
151
|
+
a == null ? void 0 : a.address,
|
|
149
152
|
r
|
|
150
153
|
]
|
|
151
|
-
),
|
|
152
|
-
|
|
153
|
-
}, []),
|
|
154
|
-
|
|
155
|
-
}, []),
|
|
156
|
-
|
|
157
|
-
}, [
|
|
158
|
-
const i =
|
|
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
|
-
|
|
165
|
-
}, [e == null ? void 0 : e.balance, e == null ? void 0 : e.decimals,
|
|
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
|
-
|
|
170
|
+
p(""), B(""), he(), he(), V == null || V(i);
|
|
168
171
|
},
|
|
169
172
|
[
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
p,
|
|
174
|
+
B,
|
|
172
175
|
V
|
|
173
176
|
]
|
|
174
|
-
),
|
|
175
|
-
|
|
177
|
+
), vi = () => {
|
|
178
|
+
pi(), Ye();
|
|
176
179
|
};
|
|
177
|
-
|
|
178
|
-
const i =
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
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 (!
|
|
186
|
+
if (!v)
|
|
184
187
|
return;
|
|
185
|
-
|
|
188
|
+
ye(v);
|
|
186
189
|
}
|
|
187
190
|
}, [r == null ? void 0 : r.chainId]);
|
|
188
|
-
const
|
|
191
|
+
const Ii = f(
|
|
189
192
|
async ({
|
|
190
193
|
transactions: i,
|
|
191
|
-
provider:
|
|
194
|
+
provider: v
|
|
192
195
|
}) => {
|
|
193
|
-
var
|
|
196
|
+
var Se, Re, Me;
|
|
194
197
|
const c = [];
|
|
195
|
-
|
|
198
|
+
w(!0), Y(() => i.length);
|
|
196
199
|
try {
|
|
197
|
-
let
|
|
200
|
+
let M = -1;
|
|
198
201
|
for (const t of i) {
|
|
199
|
-
++
|
|
202
|
+
++M;
|
|
200
203
|
try {
|
|
201
|
-
switch (
|
|
202
|
-
case
|
|
203
|
-
const
|
|
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 (!
|
|
212
|
+
if (!h || (c.push({
|
|
210
213
|
...t,
|
|
211
|
-
txHash:
|
|
212
|
-
}),
|
|
214
|
+
txHash: h
|
|
215
|
+
}), M === i.length - 1 || !h))
|
|
213
216
|
break;
|
|
214
|
-
const
|
|
215
|
-
|
|
217
|
+
const X = await Ei(
|
|
218
|
+
ge,
|
|
216
219
|
{
|
|
217
220
|
confirmations: 1,
|
|
218
|
-
hash:
|
|
221
|
+
hash: h
|
|
219
222
|
}
|
|
220
223
|
);
|
|
221
224
|
console.info({
|
|
222
|
-
transactionReceipt:
|
|
223
|
-
hash:
|
|
225
|
+
transactionReceipt: X,
|
|
226
|
+
hash: h
|
|
224
227
|
});
|
|
225
228
|
break;
|
|
226
229
|
}
|
|
227
|
-
case
|
|
230
|
+
case E.sol:
|
|
228
231
|
if (!t.instructions || !t.feePayer)
|
|
229
232
|
break;
|
|
230
|
-
const
|
|
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 (!
|
|
238
|
+
if (!ce)
|
|
236
239
|
break;
|
|
237
240
|
c.push({
|
|
238
241
|
...t,
|
|
239
|
-
txHash:
|
|
242
|
+
txHash: ce
|
|
240
243
|
});
|
|
241
244
|
break;
|
|
242
|
-
case
|
|
245
|
+
case E.btc:
|
|
243
246
|
if (!t.bitcoinParams) {
|
|
244
247
|
console.error("No bitcoin params");
|
|
245
248
|
break;
|
|
246
249
|
}
|
|
247
|
-
const
|
|
250
|
+
const Ai = await Ie.signTransaction(
|
|
248
251
|
t.bitcoinParams
|
|
249
252
|
);
|
|
250
253
|
c.push({
|
|
251
254
|
...t,
|
|
252
|
-
txHash:
|
|
255
|
+
txHash: Ai
|
|
253
256
|
});
|
|
254
257
|
break;
|
|
255
|
-
case
|
|
256
|
-
const
|
|
257
|
-
if (!
|
|
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
|
|
262
|
-
transaction:
|
|
263
|
-
address:
|
|
264
|
+
const Pe = await xe.signTransaction({
|
|
265
|
+
transaction: h,
|
|
266
|
+
address: X
|
|
264
267
|
});
|
|
265
|
-
if (!
|
|
268
|
+
if (!Pe)
|
|
266
269
|
break;
|
|
267
270
|
c.push({
|
|
268
271
|
...t,
|
|
269
272
|
suiParams: {
|
|
270
273
|
...t.suiParams,
|
|
271
|
-
signature:
|
|
274
|
+
signature: Pe
|
|
272
275
|
}
|
|
273
276
|
});
|
|
274
277
|
break;
|
|
275
278
|
}
|
|
276
279
|
default:
|
|
277
|
-
|
|
280
|
+
k.error("Provider not supported"), w(!1);
|
|
278
281
|
return;
|
|
279
282
|
}
|
|
280
283
|
Y(
|
|
281
|
-
() => i.length - 1 -
|
|
284
|
+
() => i.length - 1 - M
|
|
282
285
|
);
|
|
283
286
|
} catch {
|
|
284
|
-
|
|
287
|
+
k.dismiss(), k.error("Transaction aborted"), I == null || I("Transaction aborted"), w(!1);
|
|
285
288
|
return;
|
|
286
289
|
}
|
|
287
290
|
}
|
|
288
|
-
const { data:
|
|
291
|
+
const { data: le } = await Be({
|
|
289
292
|
transactions: c,
|
|
290
|
-
provider:
|
|
291
|
-
url:
|
|
293
|
+
provider: v,
|
|
294
|
+
url: Li() ?? "",
|
|
292
295
|
token: J ?? ""
|
|
293
|
-
}), ke = ((
|
|
294
|
-
|
|
295
|
-
} catch (
|
|
296
|
-
console.error(
|
|
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
|
-
|
|
303
|
+
m == null ? void 0 : m.chainType,
|
|
301
304
|
ee,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
ge,
|
|
306
|
+
p,
|
|
307
|
+
B,
|
|
305
308
|
J,
|
|
306
|
-
|
|
307
|
-
|
|
309
|
+
Ne,
|
|
310
|
+
Be,
|
|
311
|
+
Ie.signTransaction,
|
|
308
312
|
be.signTransaction,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
Ie.signTransaction
|
|
313
|
+
ve.signTransaction,
|
|
314
|
+
xe.signTransaction
|
|
312
315
|
]
|
|
313
316
|
), {
|
|
314
|
-
formik:
|
|
317
|
+
formik: b,
|
|
315
318
|
firstAmountError: ne,
|
|
316
319
|
secondAmountError: re,
|
|
317
|
-
fromChainError:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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:
|
|
330
|
+
sender: q.address ?? "",
|
|
326
331
|
receiver: l ?? "",
|
|
327
332
|
firstToken: e,
|
|
328
|
-
firstAmount:
|
|
329
|
-
fromChainId:
|
|
333
|
+
firstAmount: u,
|
|
334
|
+
fromChainId: O,
|
|
330
335
|
toChainId: _,
|
|
331
|
-
secondToken:
|
|
332
|
-
secondAmount:
|
|
333
|
-
setForceRefetchRate:
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
},
|
|
341
|
-
|
|
342
|
-
}, [
|
|
343
|
-
|
|
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
|
-
),
|
|
347
|
-
}, []),
|
|
348
|
-
|
|
353
|
+
), p(P));
|
|
354
|
+
}, []), C(() => {
|
|
355
|
+
N && (b.setFieldValue(
|
|
349
356
|
G.secondAmount,
|
|
350
|
-
|
|
351
|
-
),
|
|
352
|
-
}, [
|
|
357
|
+
N
|
|
358
|
+
), B(N));
|
|
359
|
+
}, [N]), /* @__PURE__ */ n(Di, { children: /* @__PURE__ */ s(
|
|
353
360
|
"form",
|
|
354
361
|
{
|
|
355
|
-
ref:
|
|
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:
|
|
366
|
+
onSubmit: xi,
|
|
360
367
|
children: [
|
|
361
|
-
|
|
368
|
+
Qe && /* @__PURE__ */ n(Yi, { mvxAddress: l, onClose: qi }),
|
|
362
369
|
/* @__PURE__ */ s(
|
|
363
|
-
|
|
370
|
+
Ue,
|
|
364
371
|
{
|
|
365
|
-
className:
|
|
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
|
-
|
|
383
|
+
Ti,
|
|
377
384
|
{
|
|
378
385
|
disabled: S,
|
|
379
|
-
activeChain:
|
|
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
|
-
|
|
393
|
+
je,
|
|
386
394
|
{
|
|
387
395
|
inputName: "firstAmount",
|
|
388
|
-
inputValue:
|
|
396
|
+
inputValue: b.values.firstAmount,
|
|
389
397
|
amountError: Ci,
|
|
390
398
|
disabled: !1,
|
|
391
|
-
onInputDebounceChange:
|
|
392
|
-
onInputChange:
|
|
393
|
-
onBlur:
|
|
399
|
+
onInputDebounceChange: p,
|
|
400
|
+
onInputChange: we,
|
|
401
|
+
onBlur: W
|
|
394
402
|
}
|
|
395
403
|
),
|
|
396
404
|
/* @__PURE__ */ n(
|
|
397
|
-
|
|
405
|
+
He,
|
|
398
406
|
{
|
|
399
407
|
name: "firstToken",
|
|
400
408
|
disabled: S,
|
|
401
|
-
options:
|
|
409
|
+
options: U,
|
|
402
410
|
areOptionsLoading: T,
|
|
403
|
-
isMvxSelector:
|
|
411
|
+
isMvxSelector: hi,
|
|
404
412
|
isDestination: !1,
|
|
405
413
|
color: "neutral-850",
|
|
406
|
-
onChange:
|
|
407
|
-
onBlur:
|
|
408
|
-
onMaxBtnClick:
|
|
414
|
+
onChange: ye,
|
|
415
|
+
onBlur: W,
|
|
416
|
+
onMaxBtnClick: bi,
|
|
409
417
|
selectedOption: e,
|
|
410
|
-
onTokenSelectorDisplay: (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:
|
|
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
|
-
|
|
427
|
+
Ue,
|
|
420
428
|
{
|
|
421
|
-
className:
|
|
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
|
-
|
|
439
|
+
et,
|
|
432
440
|
{
|
|
433
441
|
accountAddress: l,
|
|
434
|
-
chainIcon:
|
|
435
|
-
username:
|
|
436
|
-
accountExplorerUrl: `${
|
|
442
|
+
chainIcon: z(o == null ? void 0 : o.pngUrl),
|
|
443
|
+
username: Oe,
|
|
444
|
+
accountExplorerUrl: `${fe.mvxExplorerAddress}/accounts/${l}`,
|
|
437
445
|
showTag: !0,
|
|
438
|
-
onDisconnect:
|
|
439
|
-
onConnect:
|
|
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
|
-
|
|
454
|
+
je,
|
|
446
455
|
{
|
|
447
456
|
inputName: "secondAmount",
|
|
448
|
-
inputValue:
|
|
449
|
-
amountError:
|
|
457
|
+
inputValue: b.values.secondAmount,
|
|
458
|
+
amountError: Ni,
|
|
450
459
|
disabled: !1,
|
|
451
|
-
onInputDebounceChange:
|
|
452
|
-
onInputChange:
|
|
453
|
-
onBlur:
|
|
460
|
+
onInputDebounceChange: B,
|
|
461
|
+
onInputChange: we,
|
|
462
|
+
onBlur: W
|
|
454
463
|
}
|
|
455
464
|
),
|
|
456
465
|
/* @__PURE__ */ n(
|
|
457
|
-
|
|
466
|
+
He,
|
|
458
467
|
{
|
|
459
468
|
name: "secondToken",
|
|
460
469
|
disabled: S,
|
|
461
470
|
omitDisableClass: !0,
|
|
462
|
-
options:
|
|
471
|
+
options: mi,
|
|
463
472
|
areOptionsLoading: T,
|
|
464
|
-
isMvxSelector:
|
|
473
|
+
isMvxSelector: gi,
|
|
465
474
|
color: "neutral-850",
|
|
466
|
-
onChange:
|
|
467
|
-
onBlur:
|
|
468
|
-
selectedOption:
|
|
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
|
-
|
|
486
|
+
Zi,
|
|
478
487
|
{
|
|
479
488
|
mvxAccountAddress: l,
|
|
480
|
-
icon:
|
|
481
|
-
onClick:
|
|
489
|
+
icon: z(o == null ? void 0 : o.pngUrl),
|
|
490
|
+
onClick: me
|
|
482
491
|
}
|
|
483
492
|
),
|
|
484
493
|
l && !Ce && /* @__PURE__ */ n(
|
|
485
|
-
|
|
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:
|
|
498
|
+
activeChain: m
|
|
490
499
|
}
|
|
491
500
|
),
|
|
492
501
|
l && Ce && /* @__PURE__ */ s(
|
|
493
|
-
|
|
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 || !
|
|
507
|
+
disabled: !ie || S || !l || !q.address || yi || L,
|
|
499
508
|
children: [
|
|
500
|
-
ie && !
|
|
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:
|
|
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 && !
|
|
513
|
-
|
|
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
|
-
|
|
524
|
+
Ri,
|
|
516
525
|
{
|
|
517
|
-
icon:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
559
|
+
Tt as Deposit
|
|
551
560
|
};
|