@multiversx/sdk-dapp-liquidity 1.1.0-alpha.13 → 1.1.0-alpha.14
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 +112 -56
- package/reactjs/components/BridgeForm/BridgeForm.mjs +112 -56
- package/reactjs/components/TokenSelector/TokenSelector.d.ts +2 -1
- package/reactjs/components/TokenSelector/TokenSelector.js +7 -0
- package/reactjs/components/TokenSelector/TokenSelector.mjs +7 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.d.ts +2 -1
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.js +4 -0
- package/reactjs/components/TokenSelector/components/ChainSelect/ChainSelect.mjs +4 -0
- package/reactjs/components/TokenSelector/components/SelectContent.d.ts +2 -1
- package/reactjs/components/TokenSelector/components/SelectContent.js +4 -1
- package/reactjs/components/TokenSelector/components/SelectContent.mjs +4 -1
- 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/hooks/useSignTransaction.d.ts +80 -67
- package/reactjs/hooks/useSignTransaction.js +40 -4
- package/reactjs/hooks/useSignTransaction.mjs +40 -4
- package/reactjs/index.js +1 -1
- package/reactjs/index.mjs +1 -1
- package/reactjs/queries/useGetEvmTokensBalances.query.js +3 -1
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +3 -1
- package/types/transaction.d.ts +19 -0
- package/{useBalances-QuJwkRzs.js → useBalances-CPQr6NnQ.js} +1 -0
- package/{useBalances-MNOkt0CT.mjs → useBalances-DZcebYxR.mjs} +1 -0
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-CPQr6NnQ.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-DZcebYxR.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
|
@@ -9,6 +9,7 @@ const debounce = require("lodash/debounce");
|
|
|
9
9
|
const React = require("react");
|
|
10
10
|
const reactToastify = require("react-toastify");
|
|
11
11
|
const helpers_getApiURL = require("../../../helpers/getApiURL.js");
|
|
12
|
+
const types_chainType = require("../../../types/chainType.js");
|
|
12
13
|
const reactjs_constants_index = require("../../constants/index.js");
|
|
13
14
|
const reactjs_context_useWeb3App = require("../../context/useWeb3App.js");
|
|
14
15
|
const reactjs_hooks_useAccount = require("../../hooks/useAccount.js");
|
|
@@ -43,7 +44,7 @@ const reactjs_components_Connect_MvxAccountDisplay = require("../Connect/MvxAcco
|
|
|
43
44
|
const reactjs_components_TokenSelector_TokenSelector = require("../TokenSelector/TokenSelector.js");
|
|
44
45
|
const viem = require("viem");
|
|
45
46
|
const actions = require("viem/actions");
|
|
46
|
-
const reactjs_hooks_useBalances = require("../../../useBalances-
|
|
47
|
+
const reactjs_hooks_useBalances = require("../../../useBalances-CPQr6NnQ.js");
|
|
47
48
|
function deepEqual(a, b) {
|
|
48
49
|
if (a === b)
|
|
49
50
|
return true;
|
|
@@ -163,7 +164,7 @@ const BridgeForm = ({
|
|
|
163
164
|
(chain) => chain.chainId.toString() === mvxChainId.toString()
|
|
164
165
|
);
|
|
165
166
|
}, [chainId, chains]);
|
|
166
|
-
const {
|
|
167
|
+
const { evm, solana } = reactjs_hooks_useSignTransaction.useSignTransaction();
|
|
167
168
|
const sendTransactions = reactjs_hooks_useSendTransactions.useSendTransactions();
|
|
168
169
|
const {
|
|
169
170
|
mutate: getRate,
|
|
@@ -188,15 +189,30 @@ const BridgeForm = ({
|
|
|
188
189
|
})) ?? [],
|
|
189
190
|
[evmTokensWithBalances]
|
|
190
191
|
);
|
|
192
|
+
const availableTokens = React.useMemo(() => {
|
|
193
|
+
if (!(firstToken == null ? void 0 : firstToken.availableTokens)) {
|
|
194
|
+
return [];
|
|
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);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return foundTokens;
|
|
206
|
+
}, [mvxTokensWithBalances, firstToken == null ? void 0 : firstToken.availableTokens]);
|
|
191
207
|
const toOptions = React.useMemo(
|
|
192
|
-
() => (
|
|
208
|
+
() => (availableTokens && availableTokens.map((token) => {
|
|
193
209
|
return {
|
|
194
210
|
...token,
|
|
195
211
|
identifier: token.address,
|
|
196
212
|
ticker: token.symbol
|
|
197
213
|
};
|
|
198
214
|
})) ?? [],
|
|
199
|
-
[
|
|
215
|
+
[availableTokens]
|
|
200
216
|
);
|
|
201
217
|
const selectedChainOption = React.useMemo(
|
|
202
218
|
() => (chains == null ? void 0 : chains.find(
|
|
@@ -209,7 +225,7 @@ const BridgeForm = ({
|
|
|
209
225
|
selectedChainOption
|
|
210
226
|
});
|
|
211
227
|
const defaultReceivingToken = React.useMemo(
|
|
212
|
-
() => toOptions.find((x) => x.symbol.toLowerCase().includes("
|
|
228
|
+
() => toOptions.find((x) => x.symbol.toLowerCase().includes("egld")),
|
|
213
229
|
[toOptions]
|
|
214
230
|
);
|
|
215
231
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
@@ -354,15 +370,18 @@ const BridgeForm = ({
|
|
|
354
370
|
if (hasOptionsSelected) {
|
|
355
371
|
return;
|
|
356
372
|
}
|
|
357
|
-
if (
|
|
358
|
-
|
|
373
|
+
if (firstOption) {
|
|
374
|
+
setFirstToken(firstOption);
|
|
375
|
+
updateUrlParams({
|
|
376
|
+
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
if (secondOption) {
|
|
380
|
+
setSecondToken(secondOption);
|
|
381
|
+
updateUrlParams({
|
|
382
|
+
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
383
|
+
});
|
|
359
384
|
}
|
|
360
|
-
setFirstToken(firstOption);
|
|
361
|
-
setSecondToken(secondOption);
|
|
362
|
-
updateUrlParams({
|
|
363
|
-
firstTokenId: firstOption == null ? void 0 : firstOption.address,
|
|
364
|
-
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
365
|
-
});
|
|
366
385
|
};
|
|
367
386
|
const onSubmit = React.useCallback(
|
|
368
387
|
async ({
|
|
@@ -373,51 +392,82 @@ const BridgeForm = ({
|
|
|
373
392
|
setPendingSigning(true);
|
|
374
393
|
setSigningTransactionsCount(() => transactions.length);
|
|
375
394
|
try {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
})
|
|
390
|
-
|
|
391
|
-
()
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
+
switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
|
|
396
|
+
case types_chainType.ChainType.sol:
|
|
397
|
+
try {
|
|
398
|
+
for (const transaction of transactions) {
|
|
399
|
+
if (!transaction.instructions || !transaction.feePayer) {
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
await solana.signTransaction({
|
|
403
|
+
feePayer: transaction.feePayer,
|
|
404
|
+
instructions: transaction.instructions
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
setPendingSigning(false);
|
|
408
|
+
} catch (e) {
|
|
409
|
+
reactToastify.toast.dismiss();
|
|
410
|
+
reactToastify.toast.error("Transaction aborted");
|
|
411
|
+
onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
|
|
412
|
+
setPendingSigning(false);
|
|
413
|
+
return;
|
|
395
414
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
415
|
+
break;
|
|
416
|
+
case types_chainType.ChainType.evm:
|
|
417
|
+
let txIndex = -1;
|
|
418
|
+
for (const transaction of transactions) {
|
|
419
|
+
++txIndex;
|
|
420
|
+
try {
|
|
421
|
+
const txHash = await evm.signTransaction({
|
|
422
|
+
...transaction,
|
|
423
|
+
value: BigInt(transaction.value),
|
|
424
|
+
gas: BigInt(transaction.gasLimit),
|
|
425
|
+
account: bridgeAddress
|
|
426
|
+
});
|
|
427
|
+
signedTransactions.push({
|
|
428
|
+
...transaction,
|
|
429
|
+
txHash
|
|
430
|
+
});
|
|
431
|
+
setSigningTransactionsCount(
|
|
432
|
+
() => transactions.length - 1 - txIndex
|
|
433
|
+
);
|
|
434
|
+
if (txIndex === transactions.length - 1) {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
const transactionReceipt = await waitForTransactionReceipt(
|
|
438
|
+
config,
|
|
439
|
+
{
|
|
440
|
+
confirmations: 1,
|
|
441
|
+
hash: txHash
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
console.info({
|
|
445
|
+
transactionReceipt,
|
|
446
|
+
hash: txHash
|
|
447
|
+
});
|
|
448
|
+
} catch (e) {
|
|
449
|
+
reactToastify.toast.dismiss();
|
|
450
|
+
reactToastify.toast.error("Transaction aborted");
|
|
451
|
+
onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
|
|
452
|
+
setPendingSigning(false);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
await sendTransactions({
|
|
457
|
+
transactions: signedTransactions,
|
|
458
|
+
provider,
|
|
459
|
+
url: helpers_getApiURL.getApiURL() ?? "",
|
|
460
|
+
token: nativeAuthToken ?? ""
|
|
403
461
|
});
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
462
|
+
const txHashes = signedTransactions.map((tx) => tx.txHash);
|
|
463
|
+
onSuccess(txHashes);
|
|
464
|
+
setPendingSigning(false);
|
|
465
|
+
break;
|
|
466
|
+
default:
|
|
467
|
+
reactToastify.toast.error("Provider not supported");
|
|
408
468
|
setPendingSigning(false);
|
|
409
469
|
return;
|
|
410
|
-
}
|
|
411
470
|
}
|
|
412
|
-
await sendTransactions({
|
|
413
|
-
transactions: signedTransactions,
|
|
414
|
-
provider,
|
|
415
|
-
url: helpers_getApiURL.getApiURL() ?? "",
|
|
416
|
-
token: nativeAuthToken ?? ""
|
|
417
|
-
});
|
|
418
|
-
const txHashes = signedTransactions.map((tx) => tx.txHash);
|
|
419
|
-
onSuccess(txHashes);
|
|
420
|
-
setPendingSigning(false);
|
|
421
471
|
} catch (e) {
|
|
422
472
|
console.error(e);
|
|
423
473
|
reactToastify.toast.dismiss();
|
|
@@ -437,7 +487,7 @@ const BridgeForm = ({
|
|
|
437
487
|
nativeAuthToken,
|
|
438
488
|
onSuccess,
|
|
439
489
|
sendTransactions,
|
|
440
|
-
signTransaction
|
|
490
|
+
evm.signTransaction
|
|
441
491
|
]
|
|
442
492
|
);
|
|
443
493
|
const {
|
|
@@ -491,7 +541,12 @@ const BridgeForm = ({
|
|
|
491
541
|
setSecondAmount("0");
|
|
492
542
|
}
|
|
493
543
|
}, [rateValidationError]);
|
|
494
|
-
React.useEffect(setInitialSelectedTokens, [
|
|
544
|
+
React.useEffect(setInitialSelectedTokens, [
|
|
545
|
+
isTokensLoading,
|
|
546
|
+
fromOptions,
|
|
547
|
+
toOptions,
|
|
548
|
+
chainId
|
|
549
|
+
]);
|
|
495
550
|
React.useEffect(() => {
|
|
496
551
|
const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
|
|
497
552
|
(x) => x.address === (firstToken == null ? void 0 : firstToken.address)
|
|
@@ -631,10 +686,11 @@ const BridgeForm = ({
|
|
|
631
686
|
reactjs_components_TokenSelector_TokenSelector.TokenSelector,
|
|
632
687
|
{
|
|
633
688
|
name: "secondToken",
|
|
634
|
-
disabled:
|
|
689
|
+
disabled: isPendingRate,
|
|
635
690
|
omitDisableClass: true,
|
|
636
691
|
options: toOptions,
|
|
637
692
|
areOptionsLoading: isTokensLoading,
|
|
693
|
+
isMvxSelector: true,
|
|
638
694
|
color: "neutral-850",
|
|
639
695
|
onChange: onChangeSecondSelect,
|
|
640
696
|
onBlur: handleBlur,
|
|
@@ -6,6 +6,7 @@ import debounce from "lodash/debounce";
|
|
|
6
6
|
import { useRef, useState, useMemo, useCallback, useEffect } from "react";
|
|
7
7
|
import { toast } from "react-toastify";
|
|
8
8
|
import { getApiURL } from "../../../helpers/getApiURL.mjs";
|
|
9
|
+
import { ChainType } from "../../../types/chainType.mjs";
|
|
9
10
|
import { safeWindow } from "../../constants/index.mjs";
|
|
10
11
|
import { useWeb3App } from "../../context/useWeb3App.mjs";
|
|
11
12
|
import { useAccount } from "../../hooks/useAccount.mjs";
|
|
@@ -40,7 +41,7 @@ import { MvxAccountDisplay } from "../Connect/MvxAccountDisplay.mjs";
|
|
|
40
41
|
import { TokenSelector } from "../TokenSelector/TokenSelector.mjs";
|
|
41
42
|
import { hexToString } from "viem";
|
|
42
43
|
import { waitForTransactionReceipt as waitForTransactionReceipt$1, getTransaction, call } from "viem/actions";
|
|
43
|
-
import { g as getAction } from "../../../useBalances-
|
|
44
|
+
import { g as getAction } from "../../../useBalances-DZcebYxR.mjs";
|
|
44
45
|
function deepEqual(a, b) {
|
|
45
46
|
if (a === b)
|
|
46
47
|
return true;
|
|
@@ -160,7 +161,7 @@ const BridgeForm = ({
|
|
|
160
161
|
(chain) => chain.chainId.toString() === mvxChainId.toString()
|
|
161
162
|
);
|
|
162
163
|
}, [chainId, chains]);
|
|
163
|
-
const {
|
|
164
|
+
const { evm, solana } = useSignTransaction();
|
|
164
165
|
const sendTransactions = useSendTransactions();
|
|
165
166
|
const {
|
|
166
167
|
mutate: getRate,
|
|
@@ -185,15 +186,30 @@ const BridgeForm = ({
|
|
|
185
186
|
})) ?? [],
|
|
186
187
|
[evmTokensWithBalances]
|
|
187
188
|
);
|
|
189
|
+
const availableTokens = useMemo(() => {
|
|
190
|
+
if (!(firstToken == null ? void 0 : firstToken.availableTokens)) {
|
|
191
|
+
return [];
|
|
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);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return foundTokens;
|
|
203
|
+
}, [mvxTokensWithBalances, firstToken == null ? void 0 : firstToken.availableTokens]);
|
|
188
204
|
const toOptions = useMemo(
|
|
189
|
-
() => (
|
|
205
|
+
() => (availableTokens && availableTokens.map((token) => {
|
|
190
206
|
return {
|
|
191
207
|
...token,
|
|
192
208
|
identifier: token.address,
|
|
193
209
|
ticker: token.symbol
|
|
194
210
|
};
|
|
195
211
|
})) ?? [],
|
|
196
|
-
[
|
|
212
|
+
[availableTokens]
|
|
197
213
|
);
|
|
198
214
|
const selectedChainOption = useMemo(
|
|
199
215
|
() => (chains == null ? void 0 : chains.find(
|
|
@@ -206,7 +222,7 @@ const BridgeForm = ({
|
|
|
206
222
|
selectedChainOption
|
|
207
223
|
});
|
|
208
224
|
const defaultReceivingToken = useMemo(
|
|
209
|
-
() => toOptions.find((x) => x.symbol.toLowerCase().includes("
|
|
225
|
+
() => toOptions.find((x) => x.symbol.toLowerCase().includes("egld")),
|
|
210
226
|
[toOptions]
|
|
211
227
|
);
|
|
212
228
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
@@ -351,15 +367,18 @@ const BridgeForm = ({
|
|
|
351
367
|
if (hasOptionsSelected) {
|
|
352
368
|
return;
|
|
353
369
|
}
|
|
354
|
-
if (
|
|
355
|
-
|
|
370
|
+
if (firstOption) {
|
|
371
|
+
setFirstToken(firstOption);
|
|
372
|
+
updateUrlParams({
|
|
373
|
+
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
if (secondOption) {
|
|
377
|
+
setSecondToken(secondOption);
|
|
378
|
+
updateUrlParams({
|
|
379
|
+
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
380
|
+
});
|
|
356
381
|
}
|
|
357
|
-
setFirstToken(firstOption);
|
|
358
|
-
setSecondToken(secondOption);
|
|
359
|
-
updateUrlParams({
|
|
360
|
-
firstTokenId: firstOption == null ? void 0 : firstOption.address,
|
|
361
|
-
secondTokenId: secondOption == null ? void 0 : secondOption.address
|
|
362
|
-
});
|
|
363
382
|
};
|
|
364
383
|
const onSubmit = useCallback(
|
|
365
384
|
async ({
|
|
@@ -370,51 +389,82 @@ const BridgeForm = ({
|
|
|
370
389
|
setPendingSigning(true);
|
|
371
390
|
setSigningTransactionsCount(() => transactions.length);
|
|
372
391
|
try {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
()
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
|
|
393
|
+
case ChainType.sol:
|
|
394
|
+
try {
|
|
395
|
+
for (const transaction of transactions) {
|
|
396
|
+
if (!transaction.instructions || !transaction.feePayer) {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
await solana.signTransaction({
|
|
400
|
+
feePayer: transaction.feePayer,
|
|
401
|
+
instructions: transaction.instructions
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
setPendingSigning(false);
|
|
405
|
+
} catch (e) {
|
|
406
|
+
toast.dismiss();
|
|
407
|
+
toast.error("Transaction aborted");
|
|
408
|
+
onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
|
|
409
|
+
setPendingSigning(false);
|
|
410
|
+
return;
|
|
392
411
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
412
|
+
break;
|
|
413
|
+
case ChainType.evm:
|
|
414
|
+
let txIndex = -1;
|
|
415
|
+
for (const transaction of transactions) {
|
|
416
|
+
++txIndex;
|
|
417
|
+
try {
|
|
418
|
+
const txHash = await evm.signTransaction({
|
|
419
|
+
...transaction,
|
|
420
|
+
value: BigInt(transaction.value),
|
|
421
|
+
gas: BigInt(transaction.gasLimit),
|
|
422
|
+
account: bridgeAddress
|
|
423
|
+
});
|
|
424
|
+
signedTransactions.push({
|
|
425
|
+
...transaction,
|
|
426
|
+
txHash
|
|
427
|
+
});
|
|
428
|
+
setSigningTransactionsCount(
|
|
429
|
+
() => transactions.length - 1 - txIndex
|
|
430
|
+
);
|
|
431
|
+
if (txIndex === transactions.length - 1) {
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const transactionReceipt = await waitForTransactionReceipt(
|
|
435
|
+
config,
|
|
436
|
+
{
|
|
437
|
+
confirmations: 1,
|
|
438
|
+
hash: txHash
|
|
439
|
+
}
|
|
440
|
+
);
|
|
441
|
+
console.info({
|
|
442
|
+
transactionReceipt,
|
|
443
|
+
hash: txHash
|
|
444
|
+
});
|
|
445
|
+
} catch (e) {
|
|
446
|
+
toast.dismiss();
|
|
447
|
+
toast.error("Transaction aborted");
|
|
448
|
+
onFailedSentTransaction == null ? void 0 : onFailedSentTransaction("Transaction aborted");
|
|
449
|
+
setPendingSigning(false);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
await sendTransactions({
|
|
454
|
+
transactions: signedTransactions,
|
|
455
|
+
provider,
|
|
456
|
+
url: getApiURL() ?? "",
|
|
457
|
+
token: nativeAuthToken ?? ""
|
|
400
458
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
459
|
+
const txHashes = signedTransactions.map((tx) => tx.txHash);
|
|
460
|
+
onSuccess(txHashes);
|
|
461
|
+
setPendingSigning(false);
|
|
462
|
+
break;
|
|
463
|
+
default:
|
|
464
|
+
toast.error("Provider not supported");
|
|
405
465
|
setPendingSigning(false);
|
|
406
466
|
return;
|
|
407
|
-
}
|
|
408
467
|
}
|
|
409
|
-
await sendTransactions({
|
|
410
|
-
transactions: signedTransactions,
|
|
411
|
-
provider,
|
|
412
|
-
url: getApiURL() ?? "",
|
|
413
|
-
token: nativeAuthToken ?? ""
|
|
414
|
-
});
|
|
415
|
-
const txHashes = signedTransactions.map((tx) => tx.txHash);
|
|
416
|
-
onSuccess(txHashes);
|
|
417
|
-
setPendingSigning(false);
|
|
418
468
|
} catch (e) {
|
|
419
469
|
console.error(e);
|
|
420
470
|
toast.dismiss();
|
|
@@ -434,7 +484,7 @@ const BridgeForm = ({
|
|
|
434
484
|
nativeAuthToken,
|
|
435
485
|
onSuccess,
|
|
436
486
|
sendTransactions,
|
|
437
|
-
signTransaction
|
|
487
|
+
evm.signTransaction
|
|
438
488
|
]
|
|
439
489
|
);
|
|
440
490
|
const {
|
|
@@ -488,7 +538,12 @@ const BridgeForm = ({
|
|
|
488
538
|
setSecondAmount("0");
|
|
489
539
|
}
|
|
490
540
|
}, [rateValidationError]);
|
|
491
|
-
useEffect(setInitialSelectedTokens, [
|
|
541
|
+
useEffect(setInitialSelectedTokens, [
|
|
542
|
+
isTokensLoading,
|
|
543
|
+
fromOptions,
|
|
544
|
+
toOptions,
|
|
545
|
+
chainId
|
|
546
|
+
]);
|
|
492
547
|
useEffect(() => {
|
|
493
548
|
const selectedTokenOption = evmTokensWithBalances == null ? void 0 : evmTokensWithBalances.find(
|
|
494
549
|
(x) => x.address === (firstToken == null ? void 0 : firstToken.address)
|
|
@@ -628,10 +683,11 @@ const BridgeForm = ({
|
|
|
628
683
|
TokenSelector,
|
|
629
684
|
{
|
|
630
685
|
name: "secondToken",
|
|
631
|
-
disabled:
|
|
686
|
+
disabled: isPendingRate,
|
|
632
687
|
omitDisableClass: true,
|
|
633
688
|
options: toOptions,
|
|
634
689
|
areOptionsLoading: isTokensLoading,
|
|
690
|
+
isMvxSelector: true,
|
|
635
691
|
color: "neutral-850",
|
|
636
692
|
onChange: onChangeSecondSelect,
|
|
637
693
|
onBlur: handleBlur,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { TokenType } from '../../../types/token';
|
|
2
2
|
|
|
3
|
-
export declare const TokenSelector: ({ name, options, selectedOption, areOptionsLoading, className, disabled, omitDisableClass, color, onBlur, onChange, onMaxBtnClick, onTokenSelectorDisplay }: {
|
|
3
|
+
export declare const TokenSelector: ({ name, options, selectedOption, areOptionsLoading, className, disabled, isMvxSelector, omitDisableClass, color, onBlur, onChange, onMaxBtnClick, onTokenSelectorDisplay }: {
|
|
4
4
|
name: string;
|
|
5
5
|
options: TokenType[];
|
|
6
6
|
selectedOption?: TokenType;
|
|
7
7
|
areOptionsLoading?: boolean;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
+
isMvxSelector?: boolean;
|
|
9
10
|
omitDisableClass?: boolean;
|
|
10
11
|
className?: string;
|
|
11
12
|
color?: "neutral-750" | "neutral-850";
|
|
@@ -22,6 +22,7 @@ const TokenSelector = ({
|
|
|
22
22
|
areOptionsLoading = false,
|
|
23
23
|
className = "",
|
|
24
24
|
disabled = false,
|
|
25
|
+
isMvxSelector = false,
|
|
25
26
|
omitDisableClass = false,
|
|
26
27
|
color = "neutral-750",
|
|
27
28
|
onBlur,
|
|
@@ -35,6 +36,11 @@ const TokenSelector = ({
|
|
|
35
36
|
token: selectedOption
|
|
36
37
|
});
|
|
37
38
|
const chains = React.useMemo(() => {
|
|
39
|
+
if (isMvxSelector) {
|
|
40
|
+
return (data == null ? void 0 : data.filter(
|
|
41
|
+
(chain) => constants_index.MVX_CHAIN_IDS.includes(chain.chainId.toString())
|
|
42
|
+
)) ?? [];
|
|
43
|
+
}
|
|
38
44
|
return (data == null ? void 0 : data.filter(
|
|
39
45
|
(chain) => !constants_index.MVX_CHAIN_IDS.includes(chain.chainId.toString())
|
|
40
46
|
)) ?? [];
|
|
@@ -77,6 +83,7 @@ const TokenSelector = ({
|
|
|
77
83
|
},
|
|
78
84
|
tokens: options,
|
|
79
85
|
chains,
|
|
86
|
+
isMvxSelector: true,
|
|
80
87
|
areChainsLoading,
|
|
81
88
|
selectedToken: selectedOption
|
|
82
89
|
}
|
|
@@ -19,6 +19,7 @@ const TokenSelector = ({
|
|
|
19
19
|
areOptionsLoading = false,
|
|
20
20
|
className = "",
|
|
21
21
|
disabled = false,
|
|
22
|
+
isMvxSelector = false,
|
|
22
23
|
omitDisableClass = false,
|
|
23
24
|
color = "neutral-750",
|
|
24
25
|
onBlur,
|
|
@@ -32,6 +33,11 @@ const TokenSelector = ({
|
|
|
32
33
|
token: selectedOption
|
|
33
34
|
});
|
|
34
35
|
const chains = useMemo(() => {
|
|
36
|
+
if (isMvxSelector) {
|
|
37
|
+
return (data == null ? void 0 : data.filter(
|
|
38
|
+
(chain) => MVX_CHAIN_IDS.includes(chain.chainId.toString())
|
|
39
|
+
)) ?? [];
|
|
40
|
+
}
|
|
35
41
|
return (data == null ? void 0 : data.filter(
|
|
36
42
|
(chain) => !MVX_CHAIN_IDS.includes(chain.chainId.toString())
|
|
37
43
|
)) ?? [];
|
|
@@ -74,6 +80,7 @@ const TokenSelector = ({
|
|
|
74
80
|
},
|
|
75
81
|
tokens: options,
|
|
76
82
|
chains,
|
|
83
|
+
isMvxSelector: true,
|
|
77
84
|
areChainsLoading,
|
|
78
85
|
selectedToken: selectedOption
|
|
79
86
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChainDTO } from '../../../../../dto/Chain.dto';
|
|
2
2
|
|
|
3
|
-
export declare const ChainSelect: ({ isLoading, selectedChainId, onChange, chains }: {
|
|
3
|
+
export declare const ChainSelect: ({ isLoading, selectedChainId, ignoreAllChains, onChange, chains }: {
|
|
4
4
|
isLoading?: boolean;
|
|
5
5
|
selectedChainId?: string;
|
|
6
|
+
ignoreAllChains?: boolean;
|
|
6
7
|
onChange?: (chainId: string) => void;
|
|
7
8
|
chains: ChainDTO[];
|
|
8
9
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -12,6 +12,7 @@ const reactjs_constants_chains = require("../../../../constants/chains.js");
|
|
|
12
12
|
const ChainSelect = ({
|
|
13
13
|
isLoading,
|
|
14
14
|
selectedChainId,
|
|
15
|
+
ignoreAllChains = false,
|
|
15
16
|
onChange,
|
|
16
17
|
chains
|
|
17
18
|
}) => {
|
|
@@ -26,6 +27,9 @@ const ChainSelect = ({
|
|
|
26
27
|
svgUrl: chain.svgUrl
|
|
27
28
|
}
|
|
28
29
|
}));
|
|
30
|
+
if (ignoreAllChains) {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
29
33
|
options.unshift({
|
|
30
34
|
label: "All",
|
|
31
35
|
value: reactjs_constants_chains.ALL_NETWORK_ID,
|
|
@@ -9,6 +9,7 @@ import { ALL_NETWORK_ID } from "../../../../constants/chains.mjs";
|
|
|
9
9
|
const ChainSelect = ({
|
|
10
10
|
isLoading,
|
|
11
11
|
selectedChainId,
|
|
12
|
+
ignoreAllChains = false,
|
|
12
13
|
onChange,
|
|
13
14
|
chains
|
|
14
15
|
}) => {
|
|
@@ -23,6 +24,9 @@ const ChainSelect = ({
|
|
|
23
24
|
svgUrl: chain.svgUrl
|
|
24
25
|
}
|
|
25
26
|
}));
|
|
27
|
+
if (ignoreAllChains) {
|
|
28
|
+
return options;
|
|
29
|
+
}
|
|
26
30
|
options.unshift({
|
|
27
31
|
label: "All",
|
|
28
32
|
value: ALL_NETWORK_ID,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { TokenType } from '../../../../types/token';
|
|
2
2
|
import { ChainDTO } from '../../../../dto/Chain.dto';
|
|
3
3
|
|
|
4
|
-
export declare const SelectContent: ({ onSelect, tokens, chains, areChainsLoading, selectedToken }: {
|
|
4
|
+
export declare const SelectContent: ({ onSelect, tokens, chains, isMvxSelector, areChainsLoading, selectedToken }: {
|
|
5
5
|
onSelect: (token: TokenType) => void;
|
|
6
6
|
tokens: TokenType[];
|
|
7
7
|
chains: ChainDTO[];
|
|
8
|
+
isMvxSelector?: boolean;
|
|
8
9
|
areChainsLoading?: boolean;
|
|
9
10
|
selectedToken?: TokenType;
|
|
10
11
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,15 +13,17 @@ const SelectContent = ({
|
|
|
13
13
|
onSelect,
|
|
14
14
|
tokens = [],
|
|
15
15
|
chains = [],
|
|
16
|
+
isMvxSelector = false,
|
|
16
17
|
areChainsLoading,
|
|
17
18
|
selectedToken
|
|
18
19
|
}) => {
|
|
20
|
+
var _a;
|
|
19
21
|
const [filteredTokens, setFilteredTokens] = React.useState(tokens);
|
|
20
22
|
const [selected, setSelected] = React.useState(selectedToken);
|
|
21
23
|
const searchPatternRef = React.useRef("");
|
|
22
24
|
const activeChainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
23
25
|
const [selectedChainId, setSelectedChainId] = React.useState(
|
|
24
|
-
(activeChainId == null ? void 0 : activeChainId.toString()) ?? reactjs_constants_chains.ALL_NETWORK_ID
|
|
26
|
+
isMvxSelector ? ((_a = chains[0]) == null ? void 0 : _a.chainId.toString()) ?? reactjs_constants_chains.ALL_NETWORK_ID : (activeChainId == null ? void 0 : activeChainId.toString()) ?? reactjs_constants_chains.ALL_NETWORK_ID
|
|
25
27
|
);
|
|
26
28
|
const filteredTokensText = React.useMemo(() => {
|
|
27
29
|
const selectedChain = chains.find(
|
|
@@ -71,6 +73,7 @@ const SelectContent = ({
|
|
|
71
73
|
reactjs_components_TokenSelector_components_ChainSelect_ChainSelect.ChainSelect,
|
|
72
74
|
{
|
|
73
75
|
chains,
|
|
76
|
+
ignoreAllChains: isMvxSelector,
|
|
74
77
|
selectedChainId,
|
|
75
78
|
onChange: (chainId) => {
|
|
76
79
|
setSelectedChainId(chainId);
|
|
@@ -10,15 +10,17 @@ const SelectContent = ({
|
|
|
10
10
|
onSelect,
|
|
11
11
|
tokens = [],
|
|
12
12
|
chains = [],
|
|
13
|
+
isMvxSelector = false,
|
|
13
14
|
areChainsLoading,
|
|
14
15
|
selectedToken
|
|
15
16
|
}) => {
|
|
17
|
+
var _a;
|
|
16
18
|
const [filteredTokens, setFilteredTokens] = useState(tokens);
|
|
17
19
|
const [selected, setSelected] = useState(selectedToken);
|
|
18
20
|
const searchPatternRef = useRef("");
|
|
19
21
|
const activeChainId = useGetChainId();
|
|
20
22
|
const [selectedChainId, setSelectedChainId] = useState(
|
|
21
|
-
(activeChainId == null ? void 0 : activeChainId.toString()) ?? ALL_NETWORK_ID
|
|
23
|
+
isMvxSelector ? ((_a = chains[0]) == null ? void 0 : _a.chainId.toString()) ?? ALL_NETWORK_ID : (activeChainId == null ? void 0 : activeChainId.toString()) ?? ALL_NETWORK_ID
|
|
22
24
|
);
|
|
23
25
|
const filteredTokensText = useMemo(() => {
|
|
24
26
|
const selectedChain = chains.find(
|
|
@@ -68,6 +70,7 @@ const SelectContent = ({
|
|
|
68
70
|
ChainSelect,
|
|
69
71
|
{
|
|
70
72
|
chains,
|
|
73
|
+
ignoreAllChains: isMvxSelector,
|
|
71
74
|
selectedChainId,
|
|
72
75
|
onChange: (chainId) => {
|
|
73
76
|
setSelectedChainId(chainId);
|
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-CPQr6NnQ.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-DZcebYxR.mjs";
|
|
7
7
|
import { BridgeFormikValuesEnum, useBridgeFormik } from "./useBridgeFormik.mjs";
|
|
8
8
|
import { useDebounce } from "./useDebounce.mjs";
|
|
9
9
|
import { useFetchBridgeData } from "./useFetchBridgeData.mjs";
|
|
@@ -13,7 +13,8 @@ require("yup");
|
|
|
13
13
|
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
14
14
|
require("../../bignumber-B8vjg9qn.js");
|
|
15
15
|
require("wagmi");
|
|
16
|
-
const reactjs_hooks_useBalances = require("../../useBalances-
|
|
16
|
+
const reactjs_hooks_useBalances = require("../../useBalances-CPQr6NnQ.js");
|
|
17
17
|
require("formik");
|
|
18
18
|
require("../constants/index.js");
|
|
19
|
+
require("@reown/appkit-adapter-solana/react");
|
|
19
20
|
exports.useBalances = reactjs_hooks_useBalances.useBalances;
|
|
@@ -10,9 +10,10 @@ import "yup";
|
|
|
10
10
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
11
11
|
import "../../bignumber-CKZkoo0g.mjs";
|
|
12
12
|
import "wagmi";
|
|
13
|
-
import { u } from "../../useBalances-
|
|
13
|
+
import { u } from "../../useBalances-DZcebYxR.mjs";
|
|
14
14
|
import "formik";
|
|
15
15
|
import "../constants/index.mjs";
|
|
16
|
+
import "@reown/appkit-adapter-solana/react";
|
|
16
17
|
export {
|
|
17
18
|
u as useBalances
|
|
18
19
|
};
|
|
@@ -1,69 +1,82 @@
|
|
|
1
|
+
import { ServerTransactionInstruction } from '../../types';
|
|
2
|
+
import { Provider } from '@reown/appkit-adapter-solana/react';
|
|
3
|
+
|
|
1
4
|
export declare const useSignTransaction: () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
5
|
+
evm: {
|
|
6
|
+
error: null;
|
|
7
|
+
status: "idle";
|
|
8
|
+
reset: () => void;
|
|
9
|
+
context: unknown;
|
|
10
|
+
variables: undefined;
|
|
11
|
+
isError: false;
|
|
12
|
+
isIdle: true;
|
|
13
|
+
isPending: false;
|
|
14
|
+
isSuccess: false;
|
|
15
|
+
failureCount: number;
|
|
16
|
+
failureReason: import('@wagmi/core').SendTransactionErrorType | null;
|
|
17
|
+
isPaused: boolean;
|
|
18
|
+
submittedAt: number;
|
|
19
|
+
sendTransaction: import('wagmi/query').SendTransactionMutate<import('wagmi').Config, unknown>;
|
|
20
|
+
hash: `0x${string}` | undefined;
|
|
21
|
+
signTransaction: import('wagmi/query').SendTransactionMutateAsync<import('wagmi').Config, unknown>;
|
|
22
|
+
} | {
|
|
23
|
+
error: null;
|
|
24
|
+
status: "pending";
|
|
25
|
+
reset: () => void;
|
|
26
|
+
context: unknown;
|
|
27
|
+
variables: import('wagmi/query').SendTransactionVariables<import('wagmi').Config, number>;
|
|
28
|
+
isError: false;
|
|
29
|
+
isIdle: false;
|
|
30
|
+
isPending: true;
|
|
31
|
+
isSuccess: false;
|
|
32
|
+
failureCount: number;
|
|
33
|
+
failureReason: import('@wagmi/core').SendTransactionErrorType | null;
|
|
34
|
+
isPaused: boolean;
|
|
35
|
+
submittedAt: number;
|
|
36
|
+
sendTransaction: import('wagmi/query').SendTransactionMutate<import('wagmi').Config, unknown>;
|
|
37
|
+
hash: `0x${string}` | undefined;
|
|
38
|
+
signTransaction: import('wagmi/query').SendTransactionMutateAsync<import('wagmi').Config, unknown>;
|
|
39
|
+
} | {
|
|
40
|
+
error: import('@wagmi/core').SendTransactionErrorType;
|
|
41
|
+
status: "error";
|
|
42
|
+
reset: () => void;
|
|
43
|
+
context: unknown;
|
|
44
|
+
variables: import('wagmi/query').SendTransactionVariables<import('wagmi').Config, number>;
|
|
45
|
+
isError: true;
|
|
46
|
+
isIdle: false;
|
|
47
|
+
isPending: false;
|
|
48
|
+
isSuccess: false;
|
|
49
|
+
failureCount: number;
|
|
50
|
+
failureReason: import('@wagmi/core').SendTransactionErrorType | null;
|
|
51
|
+
isPaused: boolean;
|
|
52
|
+
submittedAt: number;
|
|
53
|
+
sendTransaction: import('wagmi/query').SendTransactionMutate<import('wagmi').Config, unknown>;
|
|
54
|
+
hash: `0x${string}` | undefined;
|
|
55
|
+
signTransaction: import('wagmi/query').SendTransactionMutateAsync<import('wagmi').Config, unknown>;
|
|
56
|
+
} | {
|
|
57
|
+
error: null;
|
|
58
|
+
status: "success";
|
|
59
|
+
reset: () => void;
|
|
60
|
+
context: unknown;
|
|
61
|
+
variables: import('wagmi/query').SendTransactionVariables<import('wagmi').Config, number>;
|
|
62
|
+
isError: false;
|
|
63
|
+
isIdle: false;
|
|
64
|
+
isPending: false;
|
|
65
|
+
isSuccess: true;
|
|
66
|
+
failureCount: number;
|
|
67
|
+
failureReason: import('@wagmi/core').SendTransactionErrorType | null;
|
|
68
|
+
isPaused: boolean;
|
|
69
|
+
submittedAt: number;
|
|
70
|
+
sendTransaction: import('wagmi/query').SendTransactionMutate<import('wagmi').Config, unknown>;
|
|
71
|
+
hash: `0x${string}` | undefined;
|
|
72
|
+
signTransaction: import('wagmi/query').SendTransactionMutateAsync<import('wagmi').Config, unknown>;
|
|
73
|
+
};
|
|
74
|
+
solana: {
|
|
75
|
+
signTransaction: ({ feePayer, instructions }: {
|
|
76
|
+
feePayer: string;
|
|
77
|
+
instructions: ServerTransactionInstruction[];
|
|
78
|
+
}) => Promise<void>;
|
|
79
|
+
connection: import('@solana/web3.js').Connection | undefined;
|
|
80
|
+
walletProvider: Provider;
|
|
81
|
+
};
|
|
69
82
|
};
|
|
@@ -1,17 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react$1 = require("@reown/appkit/react");
|
|
5
|
+
const react = require("@reown/appkit-adapter-solana/react");
|
|
6
|
+
const web3_js = require("@solana/web3.js");
|
|
4
7
|
const wagmi = require("wagmi");
|
|
5
8
|
const useSignTransaction = () => {
|
|
6
9
|
const {
|
|
7
10
|
data: hash,
|
|
8
|
-
sendTransactionAsync:
|
|
11
|
+
sendTransactionAsync: signEvmTransaction,
|
|
9
12
|
...rest
|
|
10
13
|
} = wagmi.useSendTransaction();
|
|
14
|
+
const { connection } = react.useAppKitConnection();
|
|
15
|
+
const { walletProvider } = react$1.useAppKitProvider("solana");
|
|
16
|
+
async function signTransactionSolanaTransaction({
|
|
17
|
+
feePayer,
|
|
18
|
+
instructions
|
|
19
|
+
}) {
|
|
20
|
+
for (const instruction of instructions) {
|
|
21
|
+
const instructionData = Buffer.from(instruction.data);
|
|
22
|
+
const sender = new web3_js.PublicKey(instruction.keys[0].pubkey);
|
|
23
|
+
const receiver = new web3_js.PublicKey(instruction.keys[1].pubkey);
|
|
24
|
+
const transactionInstruction = new web3_js.TransactionInstruction({
|
|
25
|
+
keys: [
|
|
26
|
+
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
27
|
+
{ pubkey: receiver, isSigner: false, isWritable: true }
|
|
28
|
+
],
|
|
29
|
+
programId: new web3_js.PublicKey(instruction.programId),
|
|
30
|
+
data: instructionData
|
|
31
|
+
});
|
|
32
|
+
const transaction = new web3_js.Transaction().add(transactionInstruction);
|
|
33
|
+
transaction.feePayer = new web3_js.PublicKey(feePayer);
|
|
34
|
+
if (connection) {
|
|
35
|
+
transaction.recentBlockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
|
|
36
|
+
}
|
|
37
|
+
await walletProvider.signAndSendTransaction(transaction);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
11
40
|
return {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
41
|
+
evm: {
|
|
42
|
+
hash,
|
|
43
|
+
signTransaction: signEvmTransaction,
|
|
44
|
+
...rest
|
|
45
|
+
},
|
|
46
|
+
solana: {
|
|
47
|
+
signTransaction: signTransactionSolanaTransaction,
|
|
48
|
+
connection,
|
|
49
|
+
walletProvider
|
|
50
|
+
}
|
|
15
51
|
};
|
|
16
52
|
};
|
|
17
53
|
exports.useSignTransaction = useSignTransaction;
|
|
@@ -1,14 +1,50 @@
|
|
|
1
|
+
import { useAppKitProvider } from "@reown/appkit/react";
|
|
2
|
+
import { useAppKitConnection } from "@reown/appkit-adapter-solana/react";
|
|
3
|
+
import { PublicKey, TransactionInstruction, Transaction } from "@solana/web3.js";
|
|
1
4
|
import { useSendTransaction } from "wagmi";
|
|
2
5
|
const useSignTransaction = () => {
|
|
3
6
|
const {
|
|
4
7
|
data: hash,
|
|
5
|
-
sendTransactionAsync:
|
|
8
|
+
sendTransactionAsync: signEvmTransaction,
|
|
6
9
|
...rest
|
|
7
10
|
} = useSendTransaction();
|
|
11
|
+
const { connection } = useAppKitConnection();
|
|
12
|
+
const { walletProvider } = useAppKitProvider("solana");
|
|
13
|
+
async function signTransactionSolanaTransaction({
|
|
14
|
+
feePayer,
|
|
15
|
+
instructions
|
|
16
|
+
}) {
|
|
17
|
+
for (const instruction of instructions) {
|
|
18
|
+
const instructionData = Buffer.from(instruction.data);
|
|
19
|
+
const sender = new PublicKey(instruction.keys[0].pubkey);
|
|
20
|
+
const receiver = new PublicKey(instruction.keys[1].pubkey);
|
|
21
|
+
const transactionInstruction = new TransactionInstruction({
|
|
22
|
+
keys: [
|
|
23
|
+
{ pubkey: sender, isSigner: true, isWritable: true },
|
|
24
|
+
{ pubkey: receiver, isSigner: false, isWritable: true }
|
|
25
|
+
],
|
|
26
|
+
programId: new PublicKey(instruction.programId),
|
|
27
|
+
data: instructionData
|
|
28
|
+
});
|
|
29
|
+
const transaction = new Transaction().add(transactionInstruction);
|
|
30
|
+
transaction.feePayer = new PublicKey(feePayer);
|
|
31
|
+
if (connection) {
|
|
32
|
+
transaction.recentBlockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
|
|
33
|
+
}
|
|
34
|
+
await walletProvider.signAndSendTransaction(transaction);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
8
37
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
38
|
+
evm: {
|
|
39
|
+
hash,
|
|
40
|
+
signTransaction: signEvmTransaction,
|
|
41
|
+
...rest
|
|
42
|
+
},
|
|
43
|
+
solana: {
|
|
44
|
+
signTransaction: signTransactionSolanaTransaction,
|
|
45
|
+
connection,
|
|
46
|
+
walletProvider
|
|
47
|
+
}
|
|
12
48
|
};
|
|
13
49
|
};
|
|
14
50
|
export {
|
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-CPQr6NnQ.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-DZcebYxR.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,11 +9,13 @@ 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-CPQr6NnQ.js");
|
|
13
13
|
require("formik");
|
|
14
14
|
require("axios");
|
|
15
15
|
require("../context/Web3AppProvider.js");
|
|
16
16
|
require("../constants/index.js");
|
|
17
|
+
require("@reown/appkit-adapter-solana/react");
|
|
18
|
+
require("@solana/web3.js");
|
|
17
19
|
const useGetEvmTokensBalancesQuery = ({
|
|
18
20
|
tokens,
|
|
19
21
|
chainId
|
|
@@ -6,11 +6,13 @@ 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-DZcebYxR.mjs";
|
|
10
10
|
import "formik";
|
|
11
11
|
import "axios";
|
|
12
12
|
import "../context/Web3AppProvider.mjs";
|
|
13
13
|
import "../constants/index.mjs";
|
|
14
|
+
import "@reown/appkit-adapter-solana/react";
|
|
15
|
+
import "@solana/web3.js";
|
|
14
16
|
const useGetEvmTokensBalancesQuery = ({
|
|
15
17
|
tokens,
|
|
16
18
|
chainId
|
package/types/transaction.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { TransactionBase, Transaction as ViemTransaction } from 'viem/types/transaction';
|
|
2
2
|
|
|
3
|
+
export type ServerTransactionInstruction = {
|
|
4
|
+
keys: [
|
|
5
|
+
{
|
|
6
|
+
pubkey: string;
|
|
7
|
+
isSigner: boolean;
|
|
8
|
+
isWritable: boolean;
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
pubkey: string;
|
|
12
|
+
isSigner: boolean;
|
|
13
|
+
isWritable: boolean;
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
programId: string;
|
|
17
|
+
data: ArrayBuffer;
|
|
18
|
+
};
|
|
3
19
|
export type ServerTransaction = {
|
|
4
20
|
to: `0x${string}`;
|
|
5
21
|
data: `0x${string}`;
|
|
@@ -7,6 +23,9 @@ export type ServerTransaction = {
|
|
|
7
23
|
value: bigint;
|
|
8
24
|
account: string;
|
|
9
25
|
txHash: string;
|
|
26
|
+
signatures?: string[];
|
|
27
|
+
feePayer?: string;
|
|
28
|
+
instructions?: ServerTransactionInstruction[];
|
|
10
29
|
};
|
|
11
30
|
export type TransactionType = TransactionBase & {
|
|
12
31
|
account: `0x${string}`;
|
|
@@ -14,6 +14,7 @@ require("./bignumber-B8vjg9qn.js");
|
|
|
14
14
|
require("wagmi");
|
|
15
15
|
require("formik");
|
|
16
16
|
require("./reactjs/constants/index.js");
|
|
17
|
+
require("@reown/appkit-adapter-solana/react");
|
|
17
18
|
const viem = require("viem");
|
|
18
19
|
const actions = require("viem/actions");
|
|
19
20
|
function getAction(client, actionFn, name) {
|
|
@@ -12,6 +12,7 @@ import "./bignumber-CKZkoo0g.mjs";
|
|
|
12
12
|
import "wagmi";
|
|
13
13
|
import "formik";
|
|
14
14
|
import "./reactjs/constants/index.mjs";
|
|
15
|
+
import "@reown/appkit-adapter-solana/react";
|
|
15
16
|
import { weiUnits, ContractFunctionExecutionError, hexToString, trim, formatUnits } from "viem";
|
|
16
17
|
import { multicall as multicall$1, readContract as readContract$1, getBalance as getBalance$1 } from "viem/actions";
|
|
17
18
|
function getAction(client, actionFn, name) {
|