@multiversx/sdk-dapp-liquidity 1.1.0-alpha.17 → 1.1.0-alpha.18
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 +43 -22
- package/reactjs/components/BridgeForm/BridgeForm.mjs +43 -22
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +1 -1
- package/reactjs/hooks/useBalances.js +3 -2
- package/reactjs/hooks/useBalances.mjs +3 -2
- package/reactjs/hooks/useSignTransaction.d.ts +13 -0
- package/reactjs/hooks/useSignTransaction.js +19 -6
- package/reactjs/hooks/useSignTransaction.mjs +19 -6
- 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/types/transaction.d.ts +9 -0
- package/types/utxo.d.ts +11 -0
- package/types/utxo.js +2 -0
- package/types/utxo.mjs +1 -0
- package/{useBalances-CvRCOieR.mjs → useBalances-C-yCGDYA.mjs} +29 -27
- package/{useBalances-Ds5d90Cc.js → useBalances-DtAB8tpU.js} +29 -27
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-DtAB8tpU.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-C-yCGDYA.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-DtAB8tpU.js");
|
|
48
48
|
function deepEqual(a, b) {
|
|
49
49
|
if (a === b)
|
|
50
50
|
return true;
|
|
@@ -164,7 +164,7 @@ const BridgeForm = ({
|
|
|
164
164
|
(chain) => chain.chainId.toString() === mvxChainId.toString()
|
|
165
165
|
);
|
|
166
166
|
}, [chainId, chains]);
|
|
167
|
-
const { evm, solana } = reactjs_hooks_useSignTransaction.useSignTransaction();
|
|
167
|
+
const { evm, solana, bitcoin } = reactjs_hooks_useSignTransaction.useSignTransaction();
|
|
168
168
|
const sendTransactions = reactjs_hooks_useSendTransactions.useSendTransactions();
|
|
169
169
|
const {
|
|
170
170
|
mutate: getRate,
|
|
@@ -391,14 +391,42 @@ const BridgeForm = ({
|
|
|
391
391
|
let txIndex = -1;
|
|
392
392
|
for (const transaction of transactions) {
|
|
393
393
|
++txIndex;
|
|
394
|
-
let txHash;
|
|
395
394
|
try {
|
|
396
395
|
switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
|
|
396
|
+
case types_chainType.ChainType.evm:
|
|
397
|
+
const hash = await evm.signTransaction({
|
|
398
|
+
...transaction,
|
|
399
|
+
value: BigInt(transaction.value),
|
|
400
|
+
gas: BigInt(transaction.gasLimit),
|
|
401
|
+
account: bridgeAddress
|
|
402
|
+
});
|
|
403
|
+
if (!hash) {
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
signedTransactions.push({
|
|
407
|
+
...transaction,
|
|
408
|
+
txHash: hash
|
|
409
|
+
});
|
|
410
|
+
if (txIndex === transactions.length - 1 || !hash) {
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
const transactionReceipt = await waitForTransactionReceipt(
|
|
414
|
+
config,
|
|
415
|
+
{
|
|
416
|
+
confirmations: 1,
|
|
417
|
+
hash
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
console.info({
|
|
421
|
+
transactionReceipt,
|
|
422
|
+
hash
|
|
423
|
+
});
|
|
424
|
+
break;
|
|
397
425
|
case types_chainType.ChainType.sol:
|
|
398
426
|
if (!transaction.instructions || !transaction.feePayer) {
|
|
399
427
|
break;
|
|
400
428
|
}
|
|
401
|
-
txHash = await solana.signTransaction({
|
|
429
|
+
const txHash = await solana.signTransaction({
|
|
402
430
|
feePayer: transaction.feePayer,
|
|
403
431
|
instructions: transaction.instructions
|
|
404
432
|
});
|
|
@@ -410,16 +438,20 @@ const BridgeForm = ({
|
|
|
410
438
|
txHash
|
|
411
439
|
});
|
|
412
440
|
break;
|
|
413
|
-
case types_chainType.ChainType.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
441
|
+
case types_chainType.ChainType.btc:
|
|
442
|
+
if (!transaction.bitcoinParams) {
|
|
443
|
+
console.error("No bitcoin params");
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
console.log({
|
|
447
|
+
transaction
|
|
419
448
|
});
|
|
449
|
+
const psbt = await bitcoin.signTransaction(
|
|
450
|
+
transaction.bitcoinParams
|
|
451
|
+
);
|
|
420
452
|
signedTransactions.push({
|
|
421
453
|
...transaction,
|
|
422
|
-
txHash
|
|
454
|
+
txHash: psbt
|
|
423
455
|
});
|
|
424
456
|
break;
|
|
425
457
|
default:
|
|
@@ -430,17 +462,6 @@ const BridgeForm = ({
|
|
|
430
462
|
setSigningTransactionsCount(
|
|
431
463
|
() => transactions.length - 1 - txIndex
|
|
432
464
|
);
|
|
433
|
-
if (txIndex === transactions.length - 1 || !txHash || (selectedChainOption == null ? void 0 : selectedChainOption.chainType) !== types_chainType.ChainType.evm) {
|
|
434
|
-
continue;
|
|
435
|
-
}
|
|
436
|
-
const transactionReceipt = await waitForTransactionReceipt(config, {
|
|
437
|
-
confirmations: 1,
|
|
438
|
-
hash: txHash
|
|
439
|
-
});
|
|
440
|
-
console.info({
|
|
441
|
-
transactionReceipt,
|
|
442
|
-
hash: txHash
|
|
443
|
-
});
|
|
444
465
|
} catch (e) {
|
|
445
466
|
reactToastify.toast.dismiss();
|
|
446
467
|
reactToastify.toast.error("Transaction aborted");
|
|
@@ -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-C-yCGDYA.mjs";
|
|
45
45
|
function deepEqual(a, b) {
|
|
46
46
|
if (a === b)
|
|
47
47
|
return true;
|
|
@@ -161,7 +161,7 @@ const BridgeForm = ({
|
|
|
161
161
|
(chain) => chain.chainId.toString() === mvxChainId.toString()
|
|
162
162
|
);
|
|
163
163
|
}, [chainId, chains]);
|
|
164
|
-
const { evm, solana } = useSignTransaction();
|
|
164
|
+
const { evm, solana, bitcoin } = useSignTransaction();
|
|
165
165
|
const sendTransactions = useSendTransactions();
|
|
166
166
|
const {
|
|
167
167
|
mutate: getRate,
|
|
@@ -388,14 +388,42 @@ const BridgeForm = ({
|
|
|
388
388
|
let txIndex = -1;
|
|
389
389
|
for (const transaction of transactions) {
|
|
390
390
|
++txIndex;
|
|
391
|
-
let txHash;
|
|
392
391
|
try {
|
|
393
392
|
switch (selectedChainOption == null ? void 0 : selectedChainOption.chainType) {
|
|
393
|
+
case ChainType.evm:
|
|
394
|
+
const hash = await evm.signTransaction({
|
|
395
|
+
...transaction,
|
|
396
|
+
value: BigInt(transaction.value),
|
|
397
|
+
gas: BigInt(transaction.gasLimit),
|
|
398
|
+
account: bridgeAddress
|
|
399
|
+
});
|
|
400
|
+
if (!hash) {
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
signedTransactions.push({
|
|
404
|
+
...transaction,
|
|
405
|
+
txHash: hash
|
|
406
|
+
});
|
|
407
|
+
if (txIndex === transactions.length - 1 || !hash) {
|
|
408
|
+
break;
|
|
409
|
+
}
|
|
410
|
+
const transactionReceipt = await waitForTransactionReceipt(
|
|
411
|
+
config,
|
|
412
|
+
{
|
|
413
|
+
confirmations: 1,
|
|
414
|
+
hash
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
console.info({
|
|
418
|
+
transactionReceipt,
|
|
419
|
+
hash
|
|
420
|
+
});
|
|
421
|
+
break;
|
|
394
422
|
case ChainType.sol:
|
|
395
423
|
if (!transaction.instructions || !transaction.feePayer) {
|
|
396
424
|
break;
|
|
397
425
|
}
|
|
398
|
-
txHash = await solana.signTransaction({
|
|
426
|
+
const txHash = await solana.signTransaction({
|
|
399
427
|
feePayer: transaction.feePayer,
|
|
400
428
|
instructions: transaction.instructions
|
|
401
429
|
});
|
|
@@ -407,16 +435,20 @@ const BridgeForm = ({
|
|
|
407
435
|
txHash
|
|
408
436
|
});
|
|
409
437
|
break;
|
|
410
|
-
case ChainType.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
438
|
+
case ChainType.btc:
|
|
439
|
+
if (!transaction.bitcoinParams) {
|
|
440
|
+
console.error("No bitcoin params");
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
console.log({
|
|
444
|
+
transaction
|
|
416
445
|
});
|
|
446
|
+
const psbt = await bitcoin.signTransaction(
|
|
447
|
+
transaction.bitcoinParams
|
|
448
|
+
);
|
|
417
449
|
signedTransactions.push({
|
|
418
450
|
...transaction,
|
|
419
|
-
txHash
|
|
451
|
+
txHash: psbt
|
|
420
452
|
});
|
|
421
453
|
break;
|
|
422
454
|
default:
|
|
@@ -427,17 +459,6 @@ const BridgeForm = ({
|
|
|
427
459
|
setSigningTransactionsCount(
|
|
428
460
|
() => transactions.length - 1 - txIndex
|
|
429
461
|
);
|
|
430
|
-
if (txIndex === transactions.length - 1 || !txHash || (selectedChainOption == null ? void 0 : selectedChainOption.chainType) !== ChainType.evm) {
|
|
431
|
-
continue;
|
|
432
|
-
}
|
|
433
|
-
const transactionReceipt = await waitForTransactionReceipt(config, {
|
|
434
|
-
confirmations: 1,
|
|
435
|
-
hash: txHash
|
|
436
|
-
});
|
|
437
|
-
console.info({
|
|
438
|
-
transactionReceipt,
|
|
439
|
-
hash: txHash
|
|
440
|
-
});
|
|
441
462
|
} catch (e) {
|
|
442
463
|
toast.dismiss();
|
|
443
464
|
toast.error("Transaction aborted");
|
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-DtAB8tpU.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-C-yCGDYA.mjs";
|
|
7
7
|
import { BridgeFormikValuesEnum, useBridgeFormik } from "./useBridgeFormik.mjs";
|
|
8
8
|
import { useDebounce } from "./useDebounce.mjs";
|
|
9
9
|
import { useFetchBridgeData } from "./useFetchBridgeData.mjs";
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
require("@reown/appkit/react");
|
|
5
5
|
require("@solana/web3.js");
|
|
6
|
+
require("axios");
|
|
6
7
|
require("react");
|
|
7
8
|
require("./useGetChainId.js");
|
|
9
|
+
require("../../types/chainType.js");
|
|
8
10
|
require("../context/useWeb3App.js");
|
|
9
11
|
require("@tanstack/react-query");
|
|
10
|
-
require("axios");
|
|
11
12
|
require("../queries/useGetChains.query.js");
|
|
12
13
|
require("yup");
|
|
13
14
|
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
14
15
|
require("../../bignumber-B8vjg9qn.js");
|
|
15
16
|
require("wagmi");
|
|
16
|
-
const reactjs_hooks_useBalances = require("../../useBalances-
|
|
17
|
+
const reactjs_hooks_useBalances = require("../../useBalances-DtAB8tpU.js");
|
|
17
18
|
require("formik");
|
|
18
19
|
require("../constants/index.js");
|
|
19
20
|
require("@reown/appkit-adapter-solana/react");
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import "@reown/appkit/react";
|
|
2
2
|
import "@solana/web3.js";
|
|
3
|
+
import "axios";
|
|
3
4
|
import "react";
|
|
4
5
|
import "./useGetChainId.mjs";
|
|
6
|
+
import "../../types/chainType.mjs";
|
|
5
7
|
import "../context/useWeb3App.mjs";
|
|
6
8
|
import "@tanstack/react-query";
|
|
7
|
-
import "axios";
|
|
8
9
|
import "../queries/useGetChains.query.mjs";
|
|
9
10
|
import "yup";
|
|
10
11
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
11
12
|
import "../../bignumber-CKZkoo0g.mjs";
|
|
12
13
|
import "wagmi";
|
|
13
|
-
import { u } from "../../useBalances-
|
|
14
|
+
import { u } from "../../useBalances-C-yCGDYA.mjs";
|
|
14
15
|
import "formik";
|
|
15
16
|
import "../constants/index.mjs";
|
|
16
17
|
import "@reown/appkit-adapter-solana/react";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ServerTransactionInstruction } from '../../types';
|
|
2
2
|
import { Provider } from '@reown/appkit-adapter-solana/react';
|
|
3
|
+
import { BitcoinConnector } from '@reown/appkit-adapter-bitcoin';
|
|
3
4
|
|
|
4
5
|
export declare const useSignTransaction: () => {
|
|
5
6
|
evm: {
|
|
@@ -79,4 +80,16 @@ export declare const useSignTransaction: () => {
|
|
|
79
80
|
connection: import('@solana/web3.js').Connection | undefined;
|
|
80
81
|
walletProvider: Provider;
|
|
81
82
|
};
|
|
83
|
+
bitcoin: {
|
|
84
|
+
signTransaction: (params: {
|
|
85
|
+
psbt: string;
|
|
86
|
+
signInputs: {
|
|
87
|
+
address: string;
|
|
88
|
+
index: number;
|
|
89
|
+
sighashTypes: number[];
|
|
90
|
+
}[];
|
|
91
|
+
broadcast: boolean;
|
|
92
|
+
}) => Promise<string>;
|
|
93
|
+
walletProvider: BitcoinConnector;
|
|
94
|
+
};
|
|
82
95
|
};
|
|
@@ -12,11 +12,12 @@ const useSignTransaction = () => {
|
|
|
12
12
|
...rest
|
|
13
13
|
} = wagmi.useSendTransaction();
|
|
14
14
|
const { connection } = react.useAppKitConnection();
|
|
15
|
-
const { walletProvider } = react$1.useAppKitProvider("solana");
|
|
16
|
-
|
|
15
|
+
const { walletProvider: solWalletProvider } = react$1.useAppKitProvider("solana");
|
|
16
|
+
const { walletProvider: btcWalletProvider } = react$1.useAppKitProvider("bip122");
|
|
17
|
+
const signTransactionSolanaTransaction = async ({
|
|
17
18
|
feePayer,
|
|
18
19
|
instructions
|
|
19
|
-
}) {
|
|
20
|
+
}) => {
|
|
20
21
|
for (const instruction of instructions) {
|
|
21
22
|
const instructionData = Buffer.from(instruction.data);
|
|
22
23
|
const sender = new web3_js.PublicKey(instruction.keys[0].pubkey);
|
|
@@ -34,9 +35,17 @@ const useSignTransaction = () => {
|
|
|
34
35
|
if (connection) {
|
|
35
36
|
transaction.recentBlockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
|
|
36
37
|
}
|
|
37
|
-
return await
|
|
38
|
+
return await solWalletProvider.signAndSendTransaction(transaction);
|
|
38
39
|
}
|
|
39
|
-
}
|
|
40
|
+
};
|
|
41
|
+
const signPSBT = async (params) => {
|
|
42
|
+
if (!btcWalletProvider) {
|
|
43
|
+
throw Error("user is disconnected");
|
|
44
|
+
}
|
|
45
|
+
params.signInputs = [];
|
|
46
|
+
const signature = await btcWalletProvider.signPSBT(params);
|
|
47
|
+
return signature.psbt;
|
|
48
|
+
};
|
|
40
49
|
return {
|
|
41
50
|
evm: {
|
|
42
51
|
hash,
|
|
@@ -46,7 +55,11 @@ const useSignTransaction = () => {
|
|
|
46
55
|
solana: {
|
|
47
56
|
signTransaction: signTransactionSolanaTransaction,
|
|
48
57
|
connection,
|
|
49
|
-
walletProvider
|
|
58
|
+
walletProvider: solWalletProvider
|
|
59
|
+
},
|
|
60
|
+
bitcoin: {
|
|
61
|
+
signTransaction: signPSBT,
|
|
62
|
+
walletProvider: btcWalletProvider
|
|
50
63
|
}
|
|
51
64
|
};
|
|
52
65
|
};
|
|
@@ -9,11 +9,12 @@ const useSignTransaction = () => {
|
|
|
9
9
|
...rest
|
|
10
10
|
} = useSendTransaction();
|
|
11
11
|
const { connection } = useAppKitConnection();
|
|
12
|
-
const { walletProvider } = useAppKitProvider("solana");
|
|
13
|
-
|
|
12
|
+
const { walletProvider: solWalletProvider } = useAppKitProvider("solana");
|
|
13
|
+
const { walletProvider: btcWalletProvider } = useAppKitProvider("bip122");
|
|
14
|
+
const signTransactionSolanaTransaction = async ({
|
|
14
15
|
feePayer,
|
|
15
16
|
instructions
|
|
16
|
-
}) {
|
|
17
|
+
}) => {
|
|
17
18
|
for (const instruction of instructions) {
|
|
18
19
|
const instructionData = Buffer.from(instruction.data);
|
|
19
20
|
const sender = new PublicKey(instruction.keys[0].pubkey);
|
|
@@ -31,9 +32,17 @@ const useSignTransaction = () => {
|
|
|
31
32
|
if (connection) {
|
|
32
33
|
transaction.recentBlockhash = (await connection.getLatestBlockhash("confirmed")).blockhash;
|
|
33
34
|
}
|
|
34
|
-
return await
|
|
35
|
+
return await solWalletProvider.signAndSendTransaction(transaction);
|
|
35
36
|
}
|
|
36
|
-
}
|
|
37
|
+
};
|
|
38
|
+
const signPSBT = async (params) => {
|
|
39
|
+
if (!btcWalletProvider) {
|
|
40
|
+
throw Error("user is disconnected");
|
|
41
|
+
}
|
|
42
|
+
params.signInputs = [];
|
|
43
|
+
const signature = await btcWalletProvider.signPSBT(params);
|
|
44
|
+
return signature.psbt;
|
|
45
|
+
};
|
|
37
46
|
return {
|
|
38
47
|
evm: {
|
|
39
48
|
hash,
|
|
@@ -43,7 +52,11 @@ const useSignTransaction = () => {
|
|
|
43
52
|
solana: {
|
|
44
53
|
signTransaction: signTransactionSolanaTransaction,
|
|
45
54
|
connection,
|
|
46
|
-
walletProvider
|
|
55
|
+
walletProvider: solWalletProvider
|
|
56
|
+
},
|
|
57
|
+
bitcoin: {
|
|
58
|
+
signTransaction: signPSBT,
|
|
59
|
+
walletProvider: btcWalletProvider
|
|
47
60
|
}
|
|
48
61
|
};
|
|
49
62
|
};
|
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-DtAB8tpU.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-C-yCGDYA.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-DtAB8tpU.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-C-yCGDYA.mjs";
|
|
10
10
|
import "formik";
|
|
11
11
|
import "axios";
|
|
12
12
|
import "../context/Web3AppProvider.mjs";
|
package/types/transaction.d.ts
CHANGED
|
@@ -26,6 +26,15 @@ export type ServerTransaction = {
|
|
|
26
26
|
signatures?: string[];
|
|
27
27
|
feePayer?: string;
|
|
28
28
|
instructions?: ServerTransactionInstruction[];
|
|
29
|
+
bitcoinParams?: {
|
|
30
|
+
psbt: string;
|
|
31
|
+
signInputs: {
|
|
32
|
+
address: string;
|
|
33
|
+
index: number;
|
|
34
|
+
sighashTypes: number[];
|
|
35
|
+
}[];
|
|
36
|
+
broadcast: boolean;
|
|
37
|
+
};
|
|
29
38
|
};
|
|
30
39
|
export type TransactionType = TransactionBase & {
|
|
31
40
|
account: `0x${string}`;
|
package/types/utxo.d.ts
ADDED
package/types/utxo.js
ADDED
package/types/utxo.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useAppKitAccount } from "@reown/appkit/react";
|
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import axios from "axios";
|
|
3
4
|
import { useMemo, useCallback } from "react";
|
|
4
5
|
import { useGetChainId } from "./reactjs/hooks/useGetChainId.mjs";
|
|
6
|
+
import { ChainType } from "./types/chainType.mjs";
|
|
5
7
|
import { useWeb3App } from "./reactjs/context/useWeb3App.mjs";
|
|
6
8
|
import "@tanstack/react-query";
|
|
7
|
-
import "axios";
|
|
8
9
|
import { useGetChainsQuery } from "./reactjs/queries/useGetChains.query.mjs";
|
|
9
10
|
import "yup";
|
|
10
11
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
@@ -180,26 +181,26 @@ const useBalances = () => {
|
|
|
180
181
|
const connection = new Connection(rpcUrl);
|
|
181
182
|
const publicKey = new PublicKey(addr);
|
|
182
183
|
const balance = await connection.getBalance(publicKey);
|
|
183
|
-
return
|
|
184
|
-
value: BigInt(balance.toString()),
|
|
185
|
-
decimals: 9,
|
|
186
|
-
formatted: (balance / 1e9).toString(),
|
|
187
|
-
symbol: "SOL"
|
|
188
|
-
};
|
|
184
|
+
return BigInt(balance.toString());
|
|
189
185
|
};
|
|
190
186
|
const getBtcBalance = async (rpcUrl) => {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
0
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
187
|
+
const url = `${rpcUrl}utxo/${address}`;
|
|
188
|
+
try {
|
|
189
|
+
const { data } = await axios.get(url);
|
|
190
|
+
const utxos = data || [];
|
|
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);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
throw new Error(`Error fetching UTXOs from Trezor: ${error}`);
|
|
203
|
+
}
|
|
203
204
|
};
|
|
204
205
|
const fetchBalances = useCallback(
|
|
205
206
|
async ({ tokens }) => {
|
|
@@ -212,29 +213,30 @@ const useBalances = () => {
|
|
|
212
213
|
};
|
|
213
214
|
}
|
|
214
215
|
try {
|
|
215
|
-
let balance;
|
|
216
|
+
let balance = BigInt(0);
|
|
216
217
|
switch (activeChain == null ? void 0 : activeChain.chainType) {
|
|
217
|
-
case
|
|
218
|
-
balance = await getBalance(config, {
|
|
218
|
+
case ChainType.evm:
|
|
219
|
+
balance = (await getBalance(config, {
|
|
219
220
|
address,
|
|
220
221
|
chainId: Number(chainId),
|
|
221
222
|
// omit passing the token for fetching the native currency balance
|
|
222
223
|
token: token.isNative ? void 0 : token.address
|
|
223
|
-
});
|
|
224
|
+
})).value;
|
|
224
225
|
break;
|
|
225
|
-
case
|
|
226
|
+
case ChainType.sol:
|
|
226
227
|
if (!(activeChain == null ? void 0 : activeChain.rpc)) {
|
|
227
228
|
throw new Error(`RPC URL not found for chain ID: ${chainId}`);
|
|
228
229
|
}
|
|
229
230
|
balance = await getSolBalance(activeChain == null ? void 0 : activeChain.rpc, address);
|
|
230
231
|
break;
|
|
231
|
-
case
|
|
232
|
+
case ChainType.btc:
|
|
232
233
|
if (!(activeChain == null ? void 0 : activeChain.rpc)) {
|
|
233
234
|
throw new Error(`RPC URL not found for chain ID: ${chainId}`);
|
|
234
235
|
}
|
|
235
236
|
balance = await getBtcBalance(activeChain == null ? void 0 : activeChain.rpc);
|
|
236
237
|
break;
|
|
237
|
-
case
|
|
238
|
+
case ChainType.mvx:
|
|
239
|
+
break;
|
|
238
240
|
default:
|
|
239
241
|
throw new Error(
|
|
240
242
|
`Unsupported chain type: ${activeChain == null ? void 0 : activeChain.chainType}`
|
|
@@ -242,7 +244,7 @@ const useBalances = () => {
|
|
|
242
244
|
}
|
|
243
245
|
return {
|
|
244
246
|
tokenId: token.address,
|
|
245
|
-
balance: balance.
|
|
247
|
+
balance: balance == null ? void 0 : balance.toString()
|
|
246
248
|
};
|
|
247
249
|
} catch (error) {
|
|
248
250
|
console.warn("Error fetching balance for: ", token.address, error);
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
const react = require("@reown/appkit/react");
|
|
4
4
|
const web3_js = require("@solana/web3.js");
|
|
5
|
+
const axios = require("axios");
|
|
5
6
|
const React = require("react");
|
|
6
7
|
const reactjs_hooks_useGetChainId = require("./reactjs/hooks/useGetChainId.js");
|
|
8
|
+
const types_chainType = require("./types/chainType.js");
|
|
7
9
|
const reactjs_context_useWeb3App = require("./reactjs/context/useWeb3App.js");
|
|
8
10
|
require("@tanstack/react-query");
|
|
9
|
-
require("axios");
|
|
10
11
|
const reactjs_queries_useGetChains_query = require("./reactjs/queries/useGetChains.query.js");
|
|
11
12
|
require("yup");
|
|
12
13
|
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
@@ -182,26 +183,26 @@ const useBalances = () => {
|
|
|
182
183
|
const connection = new web3_js.Connection(rpcUrl);
|
|
183
184
|
const publicKey = new web3_js.PublicKey(addr);
|
|
184
185
|
const balance = await connection.getBalance(publicKey);
|
|
185
|
-
return
|
|
186
|
-
value: BigInt(balance.toString()),
|
|
187
|
-
decimals: 9,
|
|
188
|
-
formatted: (balance / 1e9).toString(),
|
|
189
|
-
symbol: "SOL"
|
|
190
|
-
};
|
|
186
|
+
return BigInt(balance.toString());
|
|
191
187
|
};
|
|
192
188
|
const getBtcBalance = async (rpcUrl) => {
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
0
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
189
|
+
const url = `${rpcUrl}utxo/${address}`;
|
|
190
|
+
try {
|
|
191
|
+
const { data } = await axios.get(url);
|
|
192
|
+
const utxos = data || [];
|
|
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);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
throw new Error(`Error fetching UTXOs from Trezor: ${error}`);
|
|
205
|
+
}
|
|
205
206
|
};
|
|
206
207
|
const fetchBalances = React.useCallback(
|
|
207
208
|
async ({ tokens }) => {
|
|
@@ -214,29 +215,30 @@ const useBalances = () => {
|
|
|
214
215
|
};
|
|
215
216
|
}
|
|
216
217
|
try {
|
|
217
|
-
let balance;
|
|
218
|
+
let balance = BigInt(0);
|
|
218
219
|
switch (activeChain == null ? void 0 : activeChain.chainType) {
|
|
219
|
-
case
|
|
220
|
-
balance = await getBalance(config, {
|
|
220
|
+
case types_chainType.ChainType.evm:
|
|
221
|
+
balance = (await getBalance(config, {
|
|
221
222
|
address,
|
|
222
223
|
chainId: Number(chainId),
|
|
223
224
|
// omit passing the token for fetching the native currency balance
|
|
224
225
|
token: token.isNative ? void 0 : token.address
|
|
225
|
-
});
|
|
226
|
+
})).value;
|
|
226
227
|
break;
|
|
227
|
-
case
|
|
228
|
+
case types_chainType.ChainType.sol:
|
|
228
229
|
if (!(activeChain == null ? void 0 : activeChain.rpc)) {
|
|
229
230
|
throw new Error(`RPC URL not found for chain ID: ${chainId}`);
|
|
230
231
|
}
|
|
231
232
|
balance = await getSolBalance(activeChain == null ? void 0 : activeChain.rpc, address);
|
|
232
233
|
break;
|
|
233
|
-
case
|
|
234
|
+
case types_chainType.ChainType.btc:
|
|
234
235
|
if (!(activeChain == null ? void 0 : activeChain.rpc)) {
|
|
235
236
|
throw new Error(`RPC URL not found for chain ID: ${chainId}`);
|
|
236
237
|
}
|
|
237
238
|
balance = await getBtcBalance(activeChain == null ? void 0 : activeChain.rpc);
|
|
238
239
|
break;
|
|
239
|
-
case
|
|
240
|
+
case types_chainType.ChainType.mvx:
|
|
241
|
+
break;
|
|
240
242
|
default:
|
|
241
243
|
throw new Error(
|
|
242
244
|
`Unsupported chain type: ${activeChain == null ? void 0 : activeChain.chainType}`
|
|
@@ -244,7 +246,7 @@ const useBalances = () => {
|
|
|
244
246
|
}
|
|
245
247
|
return {
|
|
246
248
|
tokenId: token.address,
|
|
247
|
-
balance: balance.
|
|
249
|
+
balance: balance == null ? void 0 : balance.toString()
|
|
248
250
|
};
|
|
249
251
|
} catch (error) {
|
|
250
252
|
console.warn("Error fetching balance for: ", token.address, error);
|