@multiversx/sdk-dapp-liquidity 1.1.0-alpha.18 → 1.1.0-alpha.19
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/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/reactjs/components/BridgeForm/BridgeForm.js +53 -36
- package/reactjs/components/BridgeForm/BridgeForm.mjs +53 -36
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +1 -1
- package/reactjs/hooks/useBalances.js +2 -1
- package/reactjs/hooks/useBalances.mjs +2 -1
- package/reactjs/index.js +1 -1
- package/reactjs/index.mjs +1 -1
- package/reactjs/queries/useGetEvmTokensBalances.query.js +1 -1
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +1 -1
- package/{useBalances-C-yCGDYA.mjs → useBalances-B7J7g6dD.mjs} +6 -15
- package/{useBalances-DtAB8tpU.js → useBalances-D7Fze-E_.js} +6 -15
package/index.js
CHANGED
|
@@ -53,7 +53,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./reactjs/hooks/
|
|
|
53
53
|
const reactjs_hooks_validation_useTestHasEnoughFunds = require("./reactjs/hooks/validation/useTestHasEnoughFunds.js");
|
|
54
54
|
const reactjs_hooks_validation_useTestIsConnected = require("./reactjs/hooks/validation/useTestIsConnected.js");
|
|
55
55
|
const reactjs_hooks_useAccount = require("./reactjs/hooks/useAccount.js");
|
|
56
|
-
const reactjs_hooks_useBalances = require("./useBalances-
|
|
56
|
+
const reactjs_hooks_useBalances = require("./useBalances-D7Fze-E_.js");
|
|
57
57
|
const reactjs_hooks_useBridgeFormik = require("./reactjs/hooks/useBridgeFormik.js");
|
|
58
58
|
const reactjs_hooks_useDebounce = require("./reactjs/hooks/useDebounce.js");
|
|
59
59
|
const reactjs_hooks_useFetchBridgeData = require("./reactjs/hooks/useFetchBridgeData.js");
|
package/index.mjs
CHANGED
|
@@ -50,7 +50,7 @@ import { useSecondAmountSchema } from "./reactjs/hooks/validation/useSecondAmoun
|
|
|
50
50
|
import { useTestHasEnoughFunds } from "./reactjs/hooks/validation/useTestHasEnoughFunds.mjs";
|
|
51
51
|
import { useTestIsConnected } from "./reactjs/hooks/validation/useTestIsConnected.mjs";
|
|
52
52
|
import { useAccount } from "./reactjs/hooks/useAccount.mjs";
|
|
53
|
-
import { u } from "./useBalances-
|
|
53
|
+
import { u } from "./useBalances-B7J7g6dD.mjs";
|
|
54
54
|
import { BridgeFormikValuesEnum, useBridgeFormik } from "./reactjs/hooks/useBridgeFormik.mjs";
|
|
55
55
|
import { useDebounce } from "./reactjs/hooks/useDebounce.mjs";
|
|
56
56
|
import { useFetchBridgeData } from "./reactjs/hooks/useFetchBridgeData.mjs";
|
package/package.json
CHANGED
|
@@ -44,7 +44,7 @@ const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAcco
|
|
|
44
44
|
const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
|
|
45
45
|
const viem = require("viem");
|
|
46
46
|
const actions = require("viem/actions");
|
|
47
|
-
const reactjs_hooks_useBalances = require("../../../useBalances-
|
|
47
|
+
const reactjs_hooks_useBalances = require("../../../useBalances-D7Fze-E_.js");
|
|
48
48
|
function deepEqual(a, b) {
|
|
49
49
|
if (a === b)
|
|
50
50
|
return true;
|
|
@@ -134,6 +134,7 @@ const BridgeForm = ({
|
|
|
134
134
|
}) => {
|
|
135
135
|
var _a, _b, _c, _d, _e, _f;
|
|
136
136
|
const ref = React.useRef(null);
|
|
137
|
+
const initializedInitialTokensRef = React.useRef(false);
|
|
137
138
|
const [isTokenSelectorVisible, setIsTokenSelectorVisible] = React.useState(false);
|
|
138
139
|
const [pendingSigning, setPendingSigning] = React.useState(false);
|
|
139
140
|
const [siginingTransactionsCount, setSigningTransactionsCount] = React.useState(0);
|
|
@@ -189,30 +190,33 @@ const BridgeForm = ({
|
|
|
189
190
|
})) ?? [],
|
|
190
191
|
[evmTokensWithBalances]
|
|
191
192
|
);
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const foundTokens = [];
|
|
197
|
-
for (const availableToken of firstToken.availableTokens) {
|
|
198
|
-
const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
199
|
-
(mvxToken) => mvxToken.address === availableToken.address
|
|
200
|
-
);
|
|
201
|
-
if (foundToken) {
|
|
202
|
-
foundTokens.push(foundToken);
|
|
193
|
+
const getAvailableTokens = React.useCallback(
|
|
194
|
+
(option) => {
|
|
195
|
+
if (!(option == null ? void 0 : option.availableTokens)) {
|
|
196
|
+
return [];
|
|
203
197
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
198
|
+
const foundTokens = [];
|
|
199
|
+
for (const availableToken of option.availableTokens) {
|
|
200
|
+
const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
201
|
+
(mvxToken) => mvxToken.address === availableToken.address
|
|
202
|
+
);
|
|
203
|
+
if (foundToken) {
|
|
204
|
+
foundTokens.push(foundToken);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return foundTokens;
|
|
208
|
+
},
|
|
209
|
+
[mvxTokensWithBalances]
|
|
210
|
+
);
|
|
207
211
|
const toOptions = React.useMemo(
|
|
208
|
-
() => (availableTokens &&
|
|
212
|
+
() => ((firstToken == null ? void 0 : firstToken.availableTokens) && getAvailableTokens(firstToken).map((token) => {
|
|
209
213
|
return {
|
|
210
214
|
...token,
|
|
211
215
|
identifier: token.address,
|
|
212
216
|
ticker: token.symbol
|
|
213
217
|
};
|
|
214
218
|
})) ?? [],
|
|
215
|
-
[availableTokens]
|
|
219
|
+
[firstToken == null ? void 0 : firstToken.availableTokens]
|
|
216
220
|
);
|
|
217
221
|
const selectedChainOption = React.useMemo(
|
|
218
222
|
() => (chains == null ? void 0 : chains.find(
|
|
@@ -220,9 +224,11 @@ const BridgeForm = ({
|
|
|
220
224
|
)) ?? (chains == null ? void 0 : chains[0]),
|
|
221
225
|
[activeChain == null ? void 0 : activeChain.id, chains]
|
|
222
226
|
);
|
|
223
|
-
const
|
|
224
|
-
() =>
|
|
225
|
-
|
|
227
|
+
const getDefaultReceivingToken = React.useCallback(
|
|
228
|
+
(values) => values.find((x) => x.symbol.toLowerCase().includes("usdc")) ?? (mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
229
|
+
(x) => x.symbol.toLowerCase().includes("usdc")
|
|
230
|
+
)),
|
|
231
|
+
[mvxTokensWithBalances]
|
|
226
232
|
);
|
|
227
233
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
228
234
|
const fetchRateDebounced = React.useCallback(
|
|
@@ -285,7 +291,7 @@ const BridgeForm = ({
|
|
|
285
291
|
);
|
|
286
292
|
const updateUrlParams = React.useCallback(
|
|
287
293
|
({ firstTokenId, secondTokenId }) => {
|
|
288
|
-
if (isTokensLoading
|
|
294
|
+
if (isTokensLoading) {
|
|
289
295
|
return;
|
|
290
296
|
}
|
|
291
297
|
const currentUrl = reactjs_utils_getCompletePathname.getCompletePathname();
|
|
@@ -302,8 +308,14 @@ const BridgeForm = ({
|
|
|
302
308
|
}
|
|
303
309
|
onNavigate == null ? void 0 : onNavigate(newUrl, { replace: true });
|
|
304
310
|
},
|
|
305
|
-
[
|
|
311
|
+
[callbackRoute, isTokensLoading, onNavigate]
|
|
306
312
|
);
|
|
313
|
+
console.log("BridgeForm", {
|
|
314
|
+
firstToken,
|
|
315
|
+
secondToken,
|
|
316
|
+
fromOptions,
|
|
317
|
+
toOptions
|
|
318
|
+
});
|
|
307
319
|
const onChangeFirstSelect = React.useCallback(
|
|
308
320
|
(option) => {
|
|
309
321
|
if (!option) {
|
|
@@ -311,9 +323,13 @@ const BridgeForm = ({
|
|
|
311
323
|
}
|
|
312
324
|
setFirstToken(() => option);
|
|
313
325
|
updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
|
|
326
|
+
const availableTokens = getAvailableTokens(option);
|
|
327
|
+
const secondOption = availableTokens.find(
|
|
328
|
+
(x) => {
|
|
329
|
+
var _a2;
|
|
330
|
+
return x.symbol.toLowerCase() === ((_a2 = availableTokens == null ? void 0 : availableTokens[0]) == null ? void 0 : _a2.symbol.toLowerCase());
|
|
331
|
+
}
|
|
332
|
+
) ?? getDefaultReceivingToken(availableTokens);
|
|
317
333
|
if (!secondOption) {
|
|
318
334
|
return;
|
|
319
335
|
}
|
|
@@ -342,7 +358,7 @@ const BridgeForm = ({
|
|
|
342
358
|
);
|
|
343
359
|
const setInitialSelectedTokens = () => {
|
|
344
360
|
var _a2, _b2, _c2, _d2;
|
|
345
|
-
if (isTokensLoading) {
|
|
361
|
+
if (isTokensLoading || initializedInitialTokensRef.current) {
|
|
346
362
|
return;
|
|
347
363
|
}
|
|
348
364
|
const initialTokens = reactjs_utils_getInitialTokens.getInitialTokens();
|
|
@@ -353,31 +369,37 @@ const BridgeForm = ({
|
|
|
353
369
|
var _a3;
|
|
354
370
|
return option.chainId.toString() === ((_a3 = activeChain == null ? void 0 : activeChain.id) == null ? void 0 : _a3.toString());
|
|
355
371
|
}
|
|
356
|
-
);
|
|
357
|
-
const
|
|
372
|
+
) ?? (fromOptions == null ? void 0 : fromOptions[0]);
|
|
373
|
+
const availableTokens = getAvailableTokens(firstOption);
|
|
374
|
+
const secondOption = (availableTokens == null ? void 0 : availableTokens.find(
|
|
358
375
|
({ address }) => {
|
|
359
376
|
var _a3;
|
|
360
377
|
return address.toLowerCase() === ((_a3 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a3.toLowerCase());
|
|
361
378
|
}
|
|
362
|
-
)) ??
|
|
379
|
+
)) ?? availableTokens.find(
|
|
363
380
|
(x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
|
|
364
|
-
) ??
|
|
381
|
+
) ?? getDefaultReceivingToken(availableTokens);
|
|
365
382
|
const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a2 = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a2.toLowerCase()) === ((_b2 = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b2.toLowerCase()) && ((_c2 = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c2.toLowerCase()) === ((_d2 = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d2.toLowerCase());
|
|
366
383
|
if (hasOptionsSelected) {
|
|
367
384
|
return;
|
|
368
385
|
}
|
|
386
|
+
let initializedFirstToken = false;
|
|
369
387
|
if (firstOption) {
|
|
370
388
|
setFirstToken(firstOption);
|
|
371
389
|
updateUrlParams({
|
|
372
390
|
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
373
391
|
});
|
|
392
|
+
initializedFirstToken = true;
|
|
374
393
|
}
|
|
394
|
+
let initializedSecondToken = false;
|
|
375
395
|
if (secondOption) {
|
|
376
396
|
setSecondToken(secondOption);
|
|
377
397
|
updateUrlParams({
|
|
378
398
|
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
379
399
|
});
|
|
400
|
+
initializedSecondToken = true;
|
|
380
401
|
}
|
|
402
|
+
initializedInitialTokensRef.current = initializedFirstToken && initializedSecondToken;
|
|
381
403
|
};
|
|
382
404
|
const onSubmit = React.useCallback(
|
|
383
405
|
async ({
|
|
@@ -552,12 +574,7 @@ const BridgeForm = ({
|
|
|
552
574
|
setSecondAmount("0");
|
|
553
575
|
}
|
|
554
576
|
}, [rateValidationError]);
|
|
555
|
-
React.useEffect(setInitialSelectedTokens, [
|
|
556
|
-
isTokensLoading,
|
|
557
|
-
fromOptions,
|
|
558
|
-
toOptions,
|
|
559
|
-
chainId
|
|
560
|
-
]);
|
|
577
|
+
React.useEffect(setInitialSelectedTokens, [isTokensLoading, fromOptions]);
|
|
561
578
|
React.useEffect(() => {
|
|
562
579
|
const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
|
|
563
580
|
(x) => x.address === (firstToken == null ? void 0 : firstToken.address)
|
|
@@ -41,7 +41,7 @@ import { MvxAccountDisplay } from "../Connect/MvxAccountDisplay.mjs";
|
|
|
41
41
|
import { TokenSelector } from "../TokenSelector/TokenSelector.mjs";
|
|
42
42
|
import { hexToString } from "viem";
|
|
43
43
|
import { waitForTransactionReceipt as waitForTransactionReceipt$1, getTransaction, call } from "viem/actions";
|
|
44
|
-
import { g as getAction } from "../../../useBalances-
|
|
44
|
+
import { g as getAction } from "../../../useBalances-B7J7g6dD.mjs";
|
|
45
45
|
function deepEqual(a, b) {
|
|
46
46
|
if (a === b)
|
|
47
47
|
return true;
|
|
@@ -131,6 +131,7 @@ const BridgeForm = ({
|
|
|
131
131
|
}) => {
|
|
132
132
|
var _a, _b, _c, _d, _e, _f;
|
|
133
133
|
const ref = useRef(null);
|
|
134
|
+
const initializedInitialTokensRef = useRef(false);
|
|
134
135
|
const [isTokenSelectorVisible, setIsTokenSelectorVisible] = useState(false);
|
|
135
136
|
const [pendingSigning, setPendingSigning] = useState(false);
|
|
136
137
|
const [siginingTransactionsCount, setSigningTransactionsCount] = useState(0);
|
|
@@ -186,30 +187,33 @@ const BridgeForm = ({
|
|
|
186
187
|
})) ?? [],
|
|
187
188
|
[evmTokensWithBalances]
|
|
188
189
|
);
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const foundTokens = [];
|
|
194
|
-
for (const availableToken of firstToken.availableTokens) {
|
|
195
|
-
const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
196
|
-
(mvxToken) => mvxToken.address === availableToken.address
|
|
197
|
-
);
|
|
198
|
-
if (foundToken) {
|
|
199
|
-
foundTokens.push(foundToken);
|
|
190
|
+
const getAvailableTokens = useCallback(
|
|
191
|
+
(option) => {
|
|
192
|
+
if (!(option == null ? void 0 : option.availableTokens)) {
|
|
193
|
+
return [];
|
|
200
194
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
const foundTokens = [];
|
|
196
|
+
for (const availableToken of option.availableTokens) {
|
|
197
|
+
const foundToken = mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
198
|
+
(mvxToken) => mvxToken.address === availableToken.address
|
|
199
|
+
);
|
|
200
|
+
if (foundToken) {
|
|
201
|
+
foundTokens.push(foundToken);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return foundTokens;
|
|
205
|
+
},
|
|
206
|
+
[mvxTokensWithBalances]
|
|
207
|
+
);
|
|
204
208
|
const toOptions = useMemo(
|
|
205
|
-
() => (availableTokens &&
|
|
209
|
+
() => ((firstToken == null ? void 0 : firstToken.availableTokens) && getAvailableTokens(firstToken).map((token) => {
|
|
206
210
|
return {
|
|
207
211
|
...token,
|
|
208
212
|
identifier: token.address,
|
|
209
213
|
ticker: token.symbol
|
|
210
214
|
};
|
|
211
215
|
})) ?? [],
|
|
212
|
-
[availableTokens]
|
|
216
|
+
[firstToken == null ? void 0 : firstToken.availableTokens]
|
|
213
217
|
);
|
|
214
218
|
const selectedChainOption = useMemo(
|
|
215
219
|
() => (chains == null ? void 0 : chains.find(
|
|
@@ -217,9 +221,11 @@ const BridgeForm = ({
|
|
|
217
221
|
)) ?? (chains == null ? void 0 : chains[0]),
|
|
218
222
|
[activeChain == null ? void 0 : activeChain.id, chains]
|
|
219
223
|
);
|
|
220
|
-
const
|
|
221
|
-
() =>
|
|
222
|
-
|
|
224
|
+
const getDefaultReceivingToken = useCallback(
|
|
225
|
+
(values) => values.find((x) => x.symbol.toLowerCase().includes("usdc")) ?? (mvxTokensWithBalances == null ? void 0 : mvxTokensWithBalances.find(
|
|
226
|
+
(x) => x.symbol.toLowerCase().includes("usdc")
|
|
227
|
+
)),
|
|
228
|
+
[mvxTokensWithBalances]
|
|
223
229
|
);
|
|
224
230
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
225
231
|
const fetchRateDebounced = useCallback(
|
|
@@ -282,7 +288,7 @@ const BridgeForm = ({
|
|
|
282
288
|
);
|
|
283
289
|
const updateUrlParams = useCallback(
|
|
284
290
|
({ firstTokenId, secondTokenId }) => {
|
|
285
|
-
if (isTokensLoading
|
|
291
|
+
if (isTokensLoading) {
|
|
286
292
|
return;
|
|
287
293
|
}
|
|
288
294
|
const currentUrl = getCompletePathname();
|
|
@@ -299,8 +305,14 @@ const BridgeForm = ({
|
|
|
299
305
|
}
|
|
300
306
|
onNavigate == null ? void 0 : onNavigate(newUrl, { replace: true });
|
|
301
307
|
},
|
|
302
|
-
[
|
|
308
|
+
[callbackRoute, isTokensLoading, onNavigate]
|
|
303
309
|
);
|
|
310
|
+
console.log("BridgeForm", {
|
|
311
|
+
firstToken,
|
|
312
|
+
secondToken,
|
|
313
|
+
fromOptions,
|
|
314
|
+
toOptions
|
|
315
|
+
});
|
|
304
316
|
const onChangeFirstSelect = useCallback(
|
|
305
317
|
(option) => {
|
|
306
318
|
if (!option) {
|
|
@@ -308,9 +320,13 @@ const BridgeForm = ({
|
|
|
308
320
|
}
|
|
309
321
|
setFirstToken(() => option);
|
|
310
322
|
updateUrlParams({ firstTokenId: option == null ? void 0 : option.address });
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
323
|
+
const availableTokens = getAvailableTokens(option);
|
|
324
|
+
const secondOption = availableTokens.find(
|
|
325
|
+
(x) => {
|
|
326
|
+
var _a2;
|
|
327
|
+
return x.symbol.toLowerCase() === ((_a2 = availableTokens == null ? void 0 : availableTokens[0]) == null ? void 0 : _a2.symbol.toLowerCase());
|
|
328
|
+
}
|
|
329
|
+
) ?? getDefaultReceivingToken(availableTokens);
|
|
314
330
|
if (!secondOption) {
|
|
315
331
|
return;
|
|
316
332
|
}
|
|
@@ -339,7 +355,7 @@ const BridgeForm = ({
|
|
|
339
355
|
);
|
|
340
356
|
const setInitialSelectedTokens = () => {
|
|
341
357
|
var _a2, _b2, _c2, _d2;
|
|
342
|
-
if (isTokensLoading) {
|
|
358
|
+
if (isTokensLoading || initializedInitialTokensRef.current) {
|
|
343
359
|
return;
|
|
344
360
|
}
|
|
345
361
|
const initialTokens = getInitialTokens();
|
|
@@ -350,31 +366,37 @@ const BridgeForm = ({
|
|
|
350
366
|
var _a3;
|
|
351
367
|
return option.chainId.toString() === ((_a3 = activeChain == null ? void 0 : activeChain.id) == null ? void 0 : _a3.toString());
|
|
352
368
|
}
|
|
353
|
-
);
|
|
354
|
-
const
|
|
369
|
+
) ?? (fromOptions == null ? void 0 : fromOptions[0]);
|
|
370
|
+
const availableTokens = getAvailableTokens(firstOption);
|
|
371
|
+
const secondOption = (availableTokens == null ? void 0 : availableTokens.find(
|
|
355
372
|
({ address }) => {
|
|
356
373
|
var _a3;
|
|
357
374
|
return address.toLowerCase() === ((_a3 = (firstOption == null ? void 0 : firstOption.symbol) ?? (initialTokens == null ? void 0 : initialTokens.secondTokenId)) == null ? void 0 : _a3.toLowerCase());
|
|
358
375
|
}
|
|
359
|
-
)) ??
|
|
376
|
+
)) ?? availableTokens.find(
|
|
360
377
|
(x) => x.symbol.toLowerCase() === (firstOption == null ? void 0 : firstOption.symbol.toLowerCase())
|
|
361
|
-
) ??
|
|
378
|
+
) ?? getDefaultReceivingToken(availableTokens);
|
|
362
379
|
const hasOptionsSelected = Boolean(firstToken) && Boolean(secondToken) && ((_a2 = firstToken == null ? void 0 : firstToken.address) == null ? void 0 : _a2.toLowerCase()) === ((_b2 = firstOption == null ? void 0 : firstOption.address) == null ? void 0 : _b2.toLowerCase()) && ((_c2 = secondToken == null ? void 0 : secondToken.address) == null ? void 0 : _c2.toLowerCase()) === ((_d2 = secondOption == null ? void 0 : secondOption.address) == null ? void 0 : _d2.toLowerCase());
|
|
363
380
|
if (hasOptionsSelected) {
|
|
364
381
|
return;
|
|
365
382
|
}
|
|
383
|
+
let initializedFirstToken = false;
|
|
366
384
|
if (firstOption) {
|
|
367
385
|
setFirstToken(firstOption);
|
|
368
386
|
updateUrlParams({
|
|
369
387
|
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
370
388
|
});
|
|
389
|
+
initializedFirstToken = true;
|
|
371
390
|
}
|
|
391
|
+
let initializedSecondToken = false;
|
|
372
392
|
if (secondOption) {
|
|
373
393
|
setSecondToken(secondOption);
|
|
374
394
|
updateUrlParams({
|
|
375
395
|
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
376
396
|
});
|
|
397
|
+
initializedSecondToken = true;
|
|
377
398
|
}
|
|
399
|
+
initializedInitialTokensRef.current = initializedFirstToken && initializedSecondToken;
|
|
378
400
|
};
|
|
379
401
|
const onSubmit = useCallback(
|
|
380
402
|
async ({
|
|
@@ -549,12 +571,7 @@ const BridgeForm = ({
|
|
|
549
571
|
setSecondAmount("0");
|
|
550
572
|
}
|
|
551
573
|
}, [rateValidationError]);
|
|
552
|
-
useEffect(setInitialSelectedTokens, [
|
|
553
|
-
isTokensLoading,
|
|
554
|
-
fromOptions,
|
|
555
|
-
toOptions,
|
|
556
|
-
chainId
|
|
557
|
-
]);
|
|
574
|
+
useEffect(setInitialSelectedTokens, [isTokensLoading, fromOptions]);
|
|
558
575
|
useEffect(() => {
|
|
559
576
|
const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
|
|
560
577
|
(x) => x.address === (firstToken == null ? void 0 : firstToken.address)
|
package/reactjs/hooks/index.js
CHANGED
|
@@ -6,7 +6,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./validation/use
|
|
|
6
6
|
const reactjs_hooks_validation_useTestHasEnoughFunds = require("./validation/useTestHasEnoughFunds.js");
|
|
7
7
|
const reactjs_hooks_validation_useTestIsConnected = require("./validation/useTestIsConnected.js");
|
|
8
8
|
const reactjs_hooks_useAccount = require("./useAccount.js");
|
|
9
|
-
const reactjs_hooks_useBalances = require("../../useBalances-
|
|
9
|
+
const reactjs_hooks_useBalances = require("../../useBalances-D7Fze-E_.js");
|
|
10
10
|
const reactjs_hooks_useBridgeFormik = require("./useBridgeFormik.js");
|
|
11
11
|
const reactjs_hooks_useDebounce = require("./useDebounce.js");
|
|
12
12
|
const reactjs_hooks_useFetchBridgeData = require("./useFetchBridgeData.js");
|
package/reactjs/hooks/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { useSecondAmountSchema } from "./validation/useSecondAmountSchema.mjs";
|
|
|
3
3
|
import { useTestHasEnoughFunds } from "./validation/useTestHasEnoughFunds.mjs";
|
|
4
4
|
import { useTestIsConnected } from "./validation/useTestIsConnected.mjs";
|
|
5
5
|
import { useAccount } from "./useAccount.mjs";
|
|
6
|
-
import { u } from "../../useBalances-
|
|
6
|
+
import { u } from "../../useBalances-B7J7g6dD.mjs";
|
|
7
7
|
import { BridgeFormikValuesEnum, useBridgeFormik } from "./useBridgeFormik.mjs";
|
|
8
8
|
import { useDebounce } from "./useDebounce.mjs";
|
|
9
9
|
import { useFetchBridgeData } from "./useFetchBridgeData.mjs";
|
|
@@ -5,6 +5,7 @@ require("@reown/appkit/react");
|
|
|
5
5
|
require("@solana/web3.js");
|
|
6
6
|
require("axios");
|
|
7
7
|
require("react");
|
|
8
|
+
require("../../helpers/getApiURL.js");
|
|
8
9
|
require("./useGetChainId.js");
|
|
9
10
|
require("../../types/chainType.js");
|
|
10
11
|
require("../context/useWeb3App.js");
|
|
@@ -14,7 +15,7 @@ require("yup");
|
|
|
14
15
|
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
15
16
|
require("../../bignumber-B8vjg9qn.js");
|
|
16
17
|
require("wagmi");
|
|
17
|
-
const reactjs_hooks_useBalances = require("../../useBalances-
|
|
18
|
+
const reactjs_hooks_useBalances = require("../../useBalances-D7Fze-E_.js");
|
|
18
19
|
require("formik");
|
|
19
20
|
require("../constants/index.js");
|
|
20
21
|
require("@reown/appkit-adapter-solana/react");
|
|
@@ -2,6 +2,7 @@ import "@reown/appkit/react";
|
|
|
2
2
|
import "@solana/web3.js";
|
|
3
3
|
import "axios";
|
|
4
4
|
import "react";
|
|
5
|
+
import "../../helpers/getApiURL.mjs";
|
|
5
6
|
import "./useGetChainId.mjs";
|
|
6
7
|
import "../../types/chainType.mjs";
|
|
7
8
|
import "../context/useWeb3App.mjs";
|
|
@@ -11,7 +12,7 @@ import "yup";
|
|
|
11
12
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
12
13
|
import "../../bignumber-CKZkoo0g.mjs";
|
|
13
14
|
import "wagmi";
|
|
14
|
-
import { u } from "../../useBalances-
|
|
15
|
+
import { u } from "../../useBalances-B7J7g6dD.mjs";
|
|
15
16
|
import "formik";
|
|
16
17
|
import "../constants/index.mjs";
|
|
17
18
|
import "@reown/appkit-adapter-solana/react";
|
package/reactjs/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const reactjs_hooks_validation_useSecondAmountSchema = require("./hooks/validati
|
|
|
36
36
|
const reactjs_hooks_validation_useTestHasEnoughFunds = require("./hooks/validation/useTestHasEnoughFunds.js");
|
|
37
37
|
const reactjs_hooks_validation_useTestIsConnected = require("./hooks/validation/useTestIsConnected.js");
|
|
38
38
|
const reactjs_hooks_useAccount = require("./hooks/useAccount.js");
|
|
39
|
-
const reactjs_hooks_useBalances = require("../useBalances-
|
|
39
|
+
const reactjs_hooks_useBalances = require("../useBalances-D7Fze-E_.js");
|
|
40
40
|
const reactjs_hooks_useBridgeFormik = require("./hooks/useBridgeFormik.js");
|
|
41
41
|
const reactjs_hooks_useDebounce = require("./hooks/useDebounce.js");
|
|
42
42
|
const reactjs_hooks_useFetchBridgeData = require("./hooks/useFetchBridgeData.js");
|
package/reactjs/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ import { useSecondAmountSchema } from "./hooks/validation/useSecondAmountSchema.
|
|
|
33
33
|
import { useTestHasEnoughFunds } from "./hooks/validation/useTestHasEnoughFunds.mjs";
|
|
34
34
|
import { useTestIsConnected } from "./hooks/validation/useTestIsConnected.mjs";
|
|
35
35
|
import { useAccount } from "./hooks/useAccount.mjs";
|
|
36
|
-
import { u } from "../useBalances-
|
|
36
|
+
import { u } from "../useBalances-B7J7g6dD.mjs";
|
|
37
37
|
import { BridgeFormikValuesEnum, useBridgeFormik } from "./hooks/useBridgeFormik.mjs";
|
|
38
38
|
import { useDebounce } from "./hooks/useDebounce.mjs";
|
|
39
39
|
import { useFetchBridgeData } from "./hooks/useFetchBridgeData.mjs";
|
|
@@ -9,7 +9,7 @@ require("react");
|
|
|
9
9
|
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
10
10
|
require("../../bignumber-B8vjg9qn.js");
|
|
11
11
|
require("wagmi");
|
|
12
|
-
const reactjs_hooks_useBalances = require("../../useBalances-
|
|
12
|
+
const reactjs_hooks_useBalances = require("../../useBalances-D7Fze-E_.js");
|
|
13
13
|
require("formik");
|
|
14
14
|
require("axios");
|
|
15
15
|
require("../context/Web3AppProvider.js");
|
|
@@ -6,7 +6,7 @@ import "react";
|
|
|
6
6
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
7
7
|
import "../../bignumber-CKZkoo0g.mjs";
|
|
8
8
|
import "wagmi";
|
|
9
|
-
import { u as useBalances } from "../../useBalances-
|
|
9
|
+
import { u as useBalances } from "../../useBalances-B7J7g6dD.mjs";
|
|
10
10
|
import "formik";
|
|
11
11
|
import "axios";
|
|
12
12
|
import "../context/Web3AppProvider.mjs";
|
|
@@ -2,6 +2,7 @@ import { useAppKitAccount } from "@reown/appkit/react";
|
|
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
import { useMemo, useCallback } from "react";
|
|
5
|
+
import { getApiURL } from "./helpers/getApiURL.mjs";
|
|
5
6
|
import { useGetChainId } from "./reactjs/hooks/useGetChainId.mjs";
|
|
6
7
|
import { ChainType } from "./types/chainType.mjs";
|
|
7
8
|
import { useWeb3App } from "./reactjs/context/useWeb3App.mjs";
|
|
@@ -183,23 +184,13 @@ const useBalances = () => {
|
|
|
183
184
|
const balance = await connection.getBalance(publicKey);
|
|
184
185
|
return BigInt(balance.toString());
|
|
185
186
|
};
|
|
186
|
-
const getBtcBalance = async (
|
|
187
|
-
const url = `${
|
|
187
|
+
const getBtcBalance = async () => {
|
|
188
|
+
const url = `${getApiURL()}/user/balance/${address}`;
|
|
188
189
|
try {
|
|
189
190
|
const { data } = await axios.get(url);
|
|
190
|
-
|
|
191
|
-
if (!utxos || utxos.length === 0) {
|
|
192
|
-
throw new Error(`No UTXOs found for address ${address}`);
|
|
193
|
-
}
|
|
194
|
-
let totalInput = 0;
|
|
195
|
-
const chosenUtxos = [];
|
|
196
|
-
for (const utxo of utxos) {
|
|
197
|
-
chosenUtxos.push(utxo);
|
|
198
|
-
totalInput += Number(utxo.value);
|
|
199
|
-
}
|
|
200
|
-
return BigInt(totalInput);
|
|
191
|
+
return BigInt(data.balance);
|
|
201
192
|
} catch (error) {
|
|
202
|
-
throw new Error(`Error fetching
|
|
193
|
+
throw new Error(`Error fetching BTC balance: ${error}`);
|
|
203
194
|
}
|
|
204
195
|
};
|
|
205
196
|
const fetchBalances = useCallback(
|
|
@@ -233,7 +224,7 @@ const useBalances = () => {
|
|
|
233
224
|
if (!(activeChain == null ? void 0 : activeChain.rpc)) {
|
|
234
225
|
throw new Error(`RPC URL not found for chain ID: ${chainId}`);
|
|
235
226
|
}
|
|
236
|
-
balance = await getBtcBalance(
|
|
227
|
+
balance = await getBtcBalance();
|
|
237
228
|
break;
|
|
238
229
|
case ChainType.mvx:
|
|
239
230
|
break;
|
|
@@ -4,6 +4,7 @@ const react = require("@reown/appkit/react");
|
|
|
4
4
|
const web3_js = require("@solana/web3.js");
|
|
5
5
|
const axios = require("axios");
|
|
6
6
|
const React = require("react");
|
|
7
|
+
const helpers_getApiURL = require("./helpers/getApiURL.js");
|
|
7
8
|
const reactjs_hooks_useGetChainId = require("./reactjs/hooks/useGetChainId.js");
|
|
8
9
|
const types_chainType = require("./types/chainType.js");
|
|
9
10
|
const reactjs_context_useWeb3App = require("./reactjs/context/useWeb3App.js");
|
|
@@ -185,23 +186,13 @@ const useBalances = () => {
|
|
|
185
186
|
const balance = await connection.getBalance(publicKey);
|
|
186
187
|
return BigInt(balance.toString());
|
|
187
188
|
};
|
|
188
|
-
const getBtcBalance = async (
|
|
189
|
-
const url = `${
|
|
189
|
+
const getBtcBalance = async () => {
|
|
190
|
+
const url = `${helpers_getApiURL.getApiURL()}/user/balance/${address}`;
|
|
190
191
|
try {
|
|
191
192
|
const { data } = await axios.get(url);
|
|
192
|
-
|
|
193
|
-
if (!utxos || utxos.length === 0) {
|
|
194
|
-
throw new Error(`No UTXOs found for address ${address}`);
|
|
195
|
-
}
|
|
196
|
-
let totalInput = 0;
|
|
197
|
-
const chosenUtxos = [];
|
|
198
|
-
for (const utxo of utxos) {
|
|
199
|
-
chosenUtxos.push(utxo);
|
|
200
|
-
totalInput += Number(utxo.value);
|
|
201
|
-
}
|
|
202
|
-
return BigInt(totalInput);
|
|
193
|
+
return BigInt(data.balance);
|
|
203
194
|
} catch (error) {
|
|
204
|
-
throw new Error(`Error fetching
|
|
195
|
+
throw new Error(`Error fetching BTC balance: ${error}`);
|
|
205
196
|
}
|
|
206
197
|
};
|
|
207
198
|
const fetchBalances = React.useCallback(
|
|
@@ -235,7 +226,7 @@ const useBalances = () => {
|
|
|
235
226
|
if (!(activeChain == null ? void 0 : activeChain.rpc)) {
|
|
236
227
|
throw new Error(`RPC URL not found for chain ID: ${chainId}`);
|
|
237
228
|
}
|
|
238
|
-
balance = await getBtcBalance(
|
|
229
|
+
balance = await getBtcBalance();
|
|
239
230
|
break;
|
|
240
231
|
case types_chainType.ChainType.mvx:
|
|
241
232
|
break;
|