@multiversx/sdk-dapp-liquidity 1.1.0-alpha.33 → 1.1.0-alpha.34
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/api/checkAccount.d.ts +9 -0
- package/api/checkAccount.js +22 -0
- package/api/checkAccount.mjs +21 -0
- package/api/linkAccount.d.ts +10 -0
- package/api/linkAccount.js +32 -0
- package/api/linkAccount.mjs +31 -0
- package/dto/CheckAccount.dto.d.ts +4 -0
- package/dto/CheckAccount.dto.js +2 -0
- package/dto/CheckAccount.dto.mjs +1 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/reactjs/components/BridgeForm/BridgeForm.js +13 -4
- package/reactjs/components/BridgeForm/BridgeForm.mjs +13 -4
- package/reactjs/components/BridgeHistory/BridgeHistory.d.ts +2 -1
- package/reactjs/components/BridgeHistory/BridgeHistory.js +3 -1
- package/reactjs/components/BridgeHistory/BridgeHistory.mjs +3 -1
- package/reactjs/components/Connect/BridgeAccountDisplay.d.ts +2 -1
- package/reactjs/components/Connect/BridgeAccountDisplay.js +63 -2
- package/reactjs/components/Connect/BridgeAccountDisplay.mjs +63 -2
- package/reactjs/hooks/index.js +1 -1
- package/reactjs/hooks/index.mjs +1 -1
- package/reactjs/hooks/useBalances.d.ts +3 -1
- package/reactjs/hooks/useBalances.js +1 -1
- package/reactjs/hooks/useBalances.mjs +1 -1
- package/reactjs/hooks/useFetchBridgeData.d.ts +2 -1
- package/reactjs/hooks/useFetchBridgeData.js +4 -2
- package/reactjs/hooks/useFetchBridgeData.mjs +4 -2
- package/reactjs/hooks/useFetchTokens.d.ts +2 -1
- package/reactjs/hooks/useFetchTokens.js +4 -2
- package/reactjs/hooks/useFetchTokens.mjs +4 -2
- package/reactjs/hooks/useGenericSignMessage.d.ts +3 -0
- package/reactjs/hooks/useGenericSignMessage.js +42 -0
- package/reactjs/hooks/useGenericSignMessage.mjs +41 -0
- package/reactjs/index.js +1 -1
- package/reactjs/index.mjs +1 -1
- package/reactjs/queries/useCheckAccount.query.d.ts +5 -0
- package/reactjs/queries/useCheckAccount.query.js +51 -0
- package/reactjs/queries/useCheckAccount.query.mjs +50 -0
- package/reactjs/queries/useGetEvmTokensBalances.query.d.ts +2 -1
- package/reactjs/queries/useGetEvmTokensBalances.query.js +4 -3
- package/reactjs/queries/useGetEvmTokensBalances.query.mjs +4 -3
- package/reactjs/queries/useLinkAccount.mutation.d.ts +6 -0
- package/reactjs/queries/useLinkAccount.mutation.js +19 -0
- package/reactjs/queries/useLinkAccount.mutation.mjs +18 -0
- package/types/linkAccount.d.ts +6 -0
- package/types/linkAccount.js +2 -0
- package/types/linkAccount.mjs +1 -0
- package/{useBalances-BwQplEkY.js → useBalances-du_Oq1bB.js} +10 -3
- package/{useBalances-BWufkhuy.mjs → useBalances-z9SZjzmN.mjs} +10 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CheckAccountDto } from '../dto/CheckAccount.dto';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
|
|
4
|
+
export declare function checkAccount({ url, walletAddress, chainId, nativeAuthToken }: {
|
|
5
|
+
url: string;
|
|
6
|
+
walletAddress: string;
|
|
7
|
+
chainId: string;
|
|
8
|
+
nativeAuthToken?: string;
|
|
9
|
+
}): Promise<AxiosResponse<CheckAccountDto>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const axios = require("axios");
|
|
5
|
+
async function checkAccount({
|
|
6
|
+
url,
|
|
7
|
+
walletAddress,
|
|
8
|
+
chainId,
|
|
9
|
+
nativeAuthToken
|
|
10
|
+
}) {
|
|
11
|
+
const config = {
|
|
12
|
+
baseURL: url,
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return await axios.get(
|
|
18
|
+
`/user/checkAccount?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
19
|
+
config
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
exports.checkAccount = checkAccount;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
async function checkAccount({
|
|
3
|
+
url,
|
|
4
|
+
walletAddress,
|
|
5
|
+
chainId,
|
|
6
|
+
nativeAuthToken
|
|
7
|
+
}) {
|
|
8
|
+
const config = {
|
|
9
|
+
baseURL: url,
|
|
10
|
+
headers: {
|
|
11
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return await axios.get(
|
|
15
|
+
`/user/checkAccount?walletAddress=${walletAddress}&chainId=${chainId}`,
|
|
16
|
+
config
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
checkAccount
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LinkAccountRequestBody } from '../types/linkAccount';
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
|
|
4
|
+
interface LinkAccountProps {
|
|
5
|
+
url: string;
|
|
6
|
+
nativeAuthToken: string;
|
|
7
|
+
body: LinkAccountRequestBody;
|
|
8
|
+
}
|
|
9
|
+
export declare function linkAccount({ url, nativeAuthToken, body }: LinkAccountProps): Promise<AxiosResponse>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const axios = require("axios");
|
|
5
|
+
const helpers_decodeToken = require("../helpers/decodeToken.js");
|
|
6
|
+
async function linkAccount({
|
|
7
|
+
url,
|
|
8
|
+
nativeAuthToken,
|
|
9
|
+
body
|
|
10
|
+
}) {
|
|
11
|
+
var _a;
|
|
12
|
+
const config = {
|
|
13
|
+
baseURL: url,
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
if (!nativeAuthToken) {
|
|
19
|
+
(_a = config.headers) == null ? true : delete _a.Authorization;
|
|
20
|
+
}
|
|
21
|
+
const decodedToken = await helpers_decodeToken.decodeToken(nativeAuthToken);
|
|
22
|
+
config.headers = {
|
|
23
|
+
...config.headers,
|
|
24
|
+
origin: decodedToken == null ? void 0 : decodedToken.origin
|
|
25
|
+
};
|
|
26
|
+
return await axios.post(
|
|
27
|
+
`/user/linkAccount`,
|
|
28
|
+
body,
|
|
29
|
+
config
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
exports.linkAccount = linkAccount;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { decodeToken } from "../helpers/decodeToken.mjs";
|
|
3
|
+
async function linkAccount({
|
|
4
|
+
url,
|
|
5
|
+
nativeAuthToken,
|
|
6
|
+
body
|
|
7
|
+
}) {
|
|
8
|
+
var _a;
|
|
9
|
+
const config = {
|
|
10
|
+
baseURL: url,
|
|
11
|
+
headers: {
|
|
12
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
if (!nativeAuthToken) {
|
|
16
|
+
(_a = config.headers) == null ? true : delete _a.Authorization;
|
|
17
|
+
}
|
|
18
|
+
const decodedToken = await decodeToken(nativeAuthToken);
|
|
19
|
+
config.headers = {
|
|
20
|
+
...config.headers,
|
|
21
|
+
origin: decodedToken == null ? void 0 : decodedToken.origin
|
|
22
|
+
};
|
|
23
|
+
return await axios.post(
|
|
24
|
+
`/user/linkAccount`,
|
|
25
|
+
body,
|
|
26
|
+
config
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
linkAccount
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
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-du_Oq1bB.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-z9SZjzmN.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-du_Oq1bB.js");
|
|
48
48
|
function deepEqual(a, b) {
|
|
49
49
|
if (a === b)
|
|
50
50
|
return true;
|
|
@@ -158,7 +158,8 @@ const BridgeForm = ({
|
|
|
158
158
|
} = reactjs_hooks_useFetchBridgeData.useFetchBridgeData({
|
|
159
159
|
refetchTrigger,
|
|
160
160
|
mvxAddress,
|
|
161
|
-
mvxApiURL: options.mvxApiURL
|
|
161
|
+
mvxApiURL: options.mvxApiURL,
|
|
162
|
+
nativeAuthToken
|
|
162
163
|
});
|
|
163
164
|
const isTokensLoading = tokensLoading || isLoadingEvmTokensBalances || isLoadingMvxTokensBalances || isChainsLoading;
|
|
164
165
|
const activeChain = React.useMemo(() => {
|
|
@@ -659,7 +660,14 @@ const BridgeForm = ({
|
|
|
659
660
|
autoComplete: "off",
|
|
660
661
|
onSubmit: handleSubmit,
|
|
661
662
|
children: [
|
|
662
|
-
showHistory && /* @__PURE__ */ jsxRuntime.jsx(
|
|
663
|
+
showHistory && /* @__PURE__ */ jsxRuntime.jsx(
|
|
664
|
+
reactjs_components_BridgeHistory_BridgeHistory.BridgeHistory,
|
|
665
|
+
{
|
|
666
|
+
mvxAddress,
|
|
667
|
+
onClose: handleHistoryClose,
|
|
668
|
+
nativeAuthToken
|
|
669
|
+
}
|
|
670
|
+
),
|
|
663
671
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
664
672
|
reactjs_components_AmountCard_AmountCard.AmountCard,
|
|
665
673
|
{
|
|
@@ -677,7 +685,8 @@ const BridgeForm = ({
|
|
|
677
685
|
reactjs_components_Connect_BridgeAccountDisplay.BridgeAccountDisplay,
|
|
678
686
|
{
|
|
679
687
|
disabled: isPendingRate,
|
|
680
|
-
activeChain: selectedChainOption
|
|
688
|
+
activeChain: selectedChainOption,
|
|
689
|
+
nativeAuthToken
|
|
681
690
|
}
|
|
682
691
|
)
|
|
683
692
|
] }),
|
|
@@ -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-z9SZjzmN.mjs";
|
|
45
45
|
function deepEqual(a, b) {
|
|
46
46
|
if (a === b)
|
|
47
47
|
return true;
|
|
@@ -155,7 +155,8 @@ const BridgeForm = ({
|
|
|
155
155
|
} = useFetchBridgeData({
|
|
156
156
|
refetchTrigger,
|
|
157
157
|
mvxAddress,
|
|
158
|
-
mvxApiURL: options.mvxApiURL
|
|
158
|
+
mvxApiURL: options.mvxApiURL,
|
|
159
|
+
nativeAuthToken
|
|
159
160
|
});
|
|
160
161
|
const isTokensLoading = tokensLoading || isLoadingEvmTokensBalances || isLoadingMvxTokensBalances || isChainsLoading;
|
|
161
162
|
const activeChain = useMemo(() => {
|
|
@@ -656,7 +657,14 @@ const BridgeForm = ({
|
|
|
656
657
|
autoComplete: "off",
|
|
657
658
|
onSubmit: handleSubmit,
|
|
658
659
|
children: [
|
|
659
|
-
showHistory && /* @__PURE__ */ jsx(
|
|
660
|
+
showHistory && /* @__PURE__ */ jsx(
|
|
661
|
+
BridgeHistory,
|
|
662
|
+
{
|
|
663
|
+
mvxAddress,
|
|
664
|
+
onClose: handleHistoryClose,
|
|
665
|
+
nativeAuthToken
|
|
666
|
+
}
|
|
667
|
+
),
|
|
660
668
|
/* @__PURE__ */ jsxs(
|
|
661
669
|
AmountCard,
|
|
662
670
|
{
|
|
@@ -674,7 +682,8 @@ const BridgeForm = ({
|
|
|
674
682
|
BridgeAccountDisplay,
|
|
675
683
|
{
|
|
676
684
|
disabled: isPendingRate,
|
|
677
|
-
activeChain: selectedChainOption
|
|
685
|
+
activeChain: selectedChainOption,
|
|
686
|
+
nativeAuthToken
|
|
678
687
|
}
|
|
679
688
|
)
|
|
680
689
|
] }),
|
|
@@ -26,6 +26,7 @@ const reactjs_components_base_MxTooltip_MxTooltip = require("../base/MxTooltip/M
|
|
|
26
26
|
const ArrowUpRight = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e";
|
|
27
27
|
const BridgeHistory = ({
|
|
28
28
|
mvxAddress,
|
|
29
|
+
nativeAuthToken,
|
|
29
30
|
onClose
|
|
30
31
|
}) => {
|
|
31
32
|
const { options } = reactjs_context_useWeb3App.useWeb3App();
|
|
@@ -83,7 +84,8 @@ const BridgeHistory = ({
|
|
|
83
84
|
isChainsLoading
|
|
84
85
|
} = reactjs_hooks_useFetchBridgeData.useFetchBridgeData({
|
|
85
86
|
mvxAddress,
|
|
86
|
-
mvxApiURL: options.mvxApiURL
|
|
87
|
+
mvxApiURL: options.mvxApiURL,
|
|
88
|
+
nativeAuthToken
|
|
87
89
|
});
|
|
88
90
|
const tokensMap = React.useMemo(() => {
|
|
89
91
|
return [
|
|
@@ -23,6 +23,7 @@ import { MxTooltip } from "../base/MxTooltip/MxTooltip.mjs";
|
|
|
23
23
|
const ArrowUpRight = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M15%206V13C15%2013.5625%2014.5312%2014%2014%2014C13.4375%2014%2013%2013.5625%2013%2013V8.4375L6.6875%2014.7188C6.3125%2015.125%205.65625%2015.125%205.28125%2014.7188C4.875%2014.3438%204.875%2013.6875%205.28125%2013.3125L11.5625%207H7C6.4375%207%206%206.5625%206%206C6%205.46875%206.4375%205%207%205H14C14.5312%205%2015%205.46875%2015%206Z'%20fill='%23CDD0DB'/%3e%3c/svg%3e";
|
|
24
24
|
const BridgeHistory = ({
|
|
25
25
|
mvxAddress,
|
|
26
|
+
nativeAuthToken,
|
|
26
27
|
onClose
|
|
27
28
|
}) => {
|
|
28
29
|
const { options } = useWeb3App();
|
|
@@ -80,7 +81,8 @@ const BridgeHistory = ({
|
|
|
80
81
|
isChainsLoading
|
|
81
82
|
} = useFetchBridgeData({
|
|
82
83
|
mvxAddress,
|
|
83
|
-
mvxApiURL: options.mvxApiURL
|
|
84
|
+
mvxApiURL: options.mvxApiURL,
|
|
85
|
+
nativeAuthToken
|
|
84
86
|
});
|
|
85
87
|
const tokensMap = useMemo(() => {
|
|
86
88
|
return [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChainDTO } from '../../../dto/Chain.dto';
|
|
2
2
|
|
|
3
|
-
export declare const BridgeAccountDisplay: ({ activeChain, disabled }: {
|
|
3
|
+
export declare const BridgeAccountDisplay: ({ activeChain, nativeAuthToken, disabled }: {
|
|
4
4
|
activeChain?: ChainDTO;
|
|
5
|
+
nativeAuthToken?: string;
|
|
5
6
|
disabled: boolean;
|
|
6
7
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,28 +5,47 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const faPowerOff = require("@fortawesome/free-solid-svg-icons/faPowerOff");
|
|
6
6
|
const reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
7
7
|
const react = require("@reown/appkit/react");
|
|
8
|
+
const React = require("react");
|
|
9
|
+
const api_checkAccount = require("../../../api/checkAccount.js");
|
|
8
10
|
const reactjs_components_Connect_SwitchChainButton = require("./SwitchChainButton.js");
|
|
11
|
+
const helpers_getApiURL = require("../../../helpers/getApiURL.js");
|
|
12
|
+
require("yup");
|
|
13
|
+
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
14
|
+
require("../../../bignumber-B8vjg9qn.js");
|
|
9
15
|
const reactjs_hooks_useAccount = require("../../hooks/useAccount.js");
|
|
16
|
+
require("@solana/web3.js");
|
|
17
|
+
require("axios");
|
|
18
|
+
const reactjs_hooks_useGetChainId = require("../../hooks/useGetChainId.js");
|
|
19
|
+
require("../../context/Web3AppProvider.js");
|
|
20
|
+
require("@tanstack/react-query");
|
|
21
|
+
require("formik");
|
|
22
|
+
require("../../constants/index.js");
|
|
23
|
+
require("@reown/appkit-adapter-solana/react");
|
|
24
|
+
require("wagmi");
|
|
25
|
+
const reactjs_hooks_useGenericSignMessage = require("../../hooks/useGenericSignMessage.js");
|
|
26
|
+
const reactjs_queries_useLinkAccount_mutation = require("../../queries/useLinkAccount.mutation.js");
|
|
10
27
|
require("tailwind-merge");
|
|
11
28
|
require("../base/MxCard/MxCard.js");
|
|
12
29
|
const reactjs_components_base_MxLink_MxLink = require("../base/MxLink/MxLink.js");
|
|
13
30
|
require("../base/MxSearch/MxSearch.js");
|
|
14
31
|
require("@fortawesome/free-solid-svg-icons/faClose");
|
|
15
32
|
require("@headlessui/react");
|
|
16
|
-
require("react");
|
|
17
33
|
require("react-dom");
|
|
18
34
|
require("react-popper");
|
|
19
35
|
require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");
|
|
20
|
-
require("../../constants/index.js");
|
|
21
36
|
const reactjs_components_CopyButton_CopyButton = require("../CopyButton/CopyButton.js");
|
|
22
37
|
const reactjs_components_TrimAddress_TrimAddress = require("../TrimAddress/TrimAddress.js");
|
|
23
38
|
const BridgeAccountDisplay = ({
|
|
24
39
|
activeChain,
|
|
40
|
+
nativeAuthToken,
|
|
25
41
|
disabled
|
|
26
42
|
}) => {
|
|
27
43
|
var _a;
|
|
28
44
|
const account = reactjs_hooks_useAccount.useAccount();
|
|
29
45
|
const { disconnect } = react.useDisconnect();
|
|
46
|
+
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
47
|
+
const { signMessage } = reactjs_hooks_useGenericSignMessage.useGenericSignMessage();
|
|
48
|
+
const { mutateAsync: linkAccount } = reactjs_queries_useLinkAccount_mutation.useLinkAccountMutation();
|
|
30
49
|
const handleDisconnect = async (e) => {
|
|
31
50
|
try {
|
|
32
51
|
e.preventDefault();
|
|
@@ -35,6 +54,48 @@ const BridgeAccountDisplay = ({
|
|
|
35
54
|
console.error("Failed to disconnect:", error);
|
|
36
55
|
}
|
|
37
56
|
};
|
|
57
|
+
const validateOwnership = React.useCallback(async () => {
|
|
58
|
+
if (account.address && chainId) {
|
|
59
|
+
try {
|
|
60
|
+
const { data: ownership } = await api_checkAccount.checkAccount({
|
|
61
|
+
url: helpers_getApiURL.getApiURL(),
|
|
62
|
+
walletAddress: account.address,
|
|
63
|
+
chainId: chainId ? chainId.toString() : "",
|
|
64
|
+
nativeAuthToken
|
|
65
|
+
});
|
|
66
|
+
console.log("ownership", {
|
|
67
|
+
ownership,
|
|
68
|
+
accountAddress: account.address,
|
|
69
|
+
chainId: chainId ? chainId.toString() : ""
|
|
70
|
+
});
|
|
71
|
+
if (!(ownership == null ? void 0 : ownership.isLinked)) {
|
|
72
|
+
try {
|
|
73
|
+
const signature = await signMessage(
|
|
74
|
+
(ownership == null ? void 0 : ownership.signMessage) ?? "Missing message"
|
|
75
|
+
);
|
|
76
|
+
console.log("signature = ", signature);
|
|
77
|
+
await linkAccount({
|
|
78
|
+
nativeAuthToken: nativeAuthToken ?? "",
|
|
79
|
+
body: {
|
|
80
|
+
chainId: chainId ? chainId.toString() : "",
|
|
81
|
+
address: account.address,
|
|
82
|
+
signature,
|
|
83
|
+
message: (ownership == null ? void 0 : ownership.signMessage) ?? ""
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("Failed to link account:", error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error("Failed to check account:", error);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}, [account.address, chainId, nativeAuthToken]);
|
|
96
|
+
React.useEffect(() => {
|
|
97
|
+
validateOwnership();
|
|
98
|
+
}, [account.address]);
|
|
38
99
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
39
100
|
account.address && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
40
101
|
/* @__PURE__ */ jsxRuntime.jsx("img", { src: activeChain == null ? void 0 : activeChain.svgUrl, alt: "", className: "liq-w-6" }),
|
|
@@ -2,28 +2,47 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { faPowerOff } from "@fortawesome/free-solid-svg-icons/faPowerOff";
|
|
3
3
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { useDisconnect } from "@reown/appkit/react";
|
|
5
|
+
import { useCallback, useEffect } from "react";
|
|
6
|
+
import { checkAccount } from "../../../api/checkAccount.mjs";
|
|
5
7
|
import { SwitchChainButton } from "./SwitchChainButton.mjs";
|
|
8
|
+
import { getApiURL } from "../../../helpers/getApiURL.mjs";
|
|
9
|
+
import "yup";
|
|
10
|
+
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
11
|
+
import "../../../bignumber-CKZkoo0g.mjs";
|
|
6
12
|
import { useAccount } from "../../hooks/useAccount.mjs";
|
|
13
|
+
import "@solana/web3.js";
|
|
14
|
+
import "axios";
|
|
15
|
+
import { useGetChainId } from "../../hooks/useGetChainId.mjs";
|
|
16
|
+
import "../../context/Web3AppProvider.mjs";
|
|
17
|
+
import "@tanstack/react-query";
|
|
18
|
+
import "formik";
|
|
19
|
+
import "../../constants/index.mjs";
|
|
20
|
+
import "@reown/appkit-adapter-solana/react";
|
|
21
|
+
import "wagmi";
|
|
22
|
+
import { useGenericSignMessage } from "../../hooks/useGenericSignMessage.mjs";
|
|
23
|
+
import { useLinkAccountMutation } from "../../queries/useLinkAccount.mutation.mjs";
|
|
7
24
|
import "tailwind-merge";
|
|
8
25
|
import "../base/MxCard/MxCard.mjs";
|
|
9
26
|
import { MxLink } from "../base/MxLink/MxLink.mjs";
|
|
10
27
|
import "../base/MxSearch/MxSearch.mjs";
|
|
11
28
|
import "@fortawesome/free-solid-svg-icons/faClose";
|
|
12
29
|
import "@headlessui/react";
|
|
13
|
-
import "react";
|
|
14
30
|
import "react-dom";
|
|
15
31
|
import "react-popper";
|
|
16
32
|
import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
|
|
17
|
-
import "../../constants/index.mjs";
|
|
18
33
|
import { CopyButton } from "../CopyButton/CopyButton.mjs";
|
|
19
34
|
import { TrimAddress } from "../TrimAddress/TrimAddress.mjs";
|
|
20
35
|
const BridgeAccountDisplay = ({
|
|
21
36
|
activeChain,
|
|
37
|
+
nativeAuthToken,
|
|
22
38
|
disabled
|
|
23
39
|
}) => {
|
|
24
40
|
var _a;
|
|
25
41
|
const account = useAccount();
|
|
26
42
|
const { disconnect } = useDisconnect();
|
|
43
|
+
const chainId = useGetChainId();
|
|
44
|
+
const { signMessage } = useGenericSignMessage();
|
|
45
|
+
const { mutateAsync: linkAccount } = useLinkAccountMutation();
|
|
27
46
|
const handleDisconnect = async (e) => {
|
|
28
47
|
try {
|
|
29
48
|
e.preventDefault();
|
|
@@ -32,6 +51,48 @@ const BridgeAccountDisplay = ({
|
|
|
32
51
|
console.error("Failed to disconnect:", error);
|
|
33
52
|
}
|
|
34
53
|
};
|
|
54
|
+
const validateOwnership = useCallback(async () => {
|
|
55
|
+
if (account.address && chainId) {
|
|
56
|
+
try {
|
|
57
|
+
const { data: ownership } = await checkAccount({
|
|
58
|
+
url: getApiURL(),
|
|
59
|
+
walletAddress: account.address,
|
|
60
|
+
chainId: chainId ? chainId.toString() : "",
|
|
61
|
+
nativeAuthToken
|
|
62
|
+
});
|
|
63
|
+
console.log("ownership", {
|
|
64
|
+
ownership,
|
|
65
|
+
accountAddress: account.address,
|
|
66
|
+
chainId: chainId ? chainId.toString() : ""
|
|
67
|
+
});
|
|
68
|
+
if (!(ownership == null ? void 0 : ownership.isLinked)) {
|
|
69
|
+
try {
|
|
70
|
+
const signature = await signMessage(
|
|
71
|
+
(ownership == null ? void 0 : ownership.signMessage) ?? "Missing message"
|
|
72
|
+
);
|
|
73
|
+
console.log("signature = ", signature);
|
|
74
|
+
await linkAccount({
|
|
75
|
+
nativeAuthToken: nativeAuthToken ?? "",
|
|
76
|
+
body: {
|
|
77
|
+
chainId: chainId ? chainId.toString() : "",
|
|
78
|
+
address: account.address,
|
|
79
|
+
signature,
|
|
80
|
+
message: (ownership == null ? void 0 : ownership.signMessage) ?? ""
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error("Failed to link account:", error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.error("Failed to check account:", error);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}, [account.address, chainId, nativeAuthToken]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
validateOwnership();
|
|
95
|
+
}, [account.address]);
|
|
35
96
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
36
97
|
account.address && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
98
|
/* @__PURE__ */ jsx("img", { src: activeChain == null ? void 0 : activeChain.svgUrl, alt: "", className: "liq-w-6" }),
|
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-du_Oq1bB.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-z9SZjzmN.mjs";
|
|
7
7
|
import { BridgeFormikValuesEnum, useBridgeFormik } from "./useBridgeFormik.mjs";
|
|
8
8
|
import { useDebounce } from "./useDebounce.mjs";
|
|
9
9
|
import { useFetchBridgeData } from "./useFetchBridgeData.mjs";
|
|
@@ -15,7 +15,7 @@ require("yup");
|
|
|
15
15
|
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
16
16
|
require("../../bignumber-B8vjg9qn.js");
|
|
17
17
|
require("wagmi");
|
|
18
|
-
const reactjs_hooks_useBalances = require("../../useBalances-
|
|
18
|
+
const reactjs_hooks_useBalances = require("../../useBalances-du_Oq1bB.js");
|
|
19
19
|
require("formik");
|
|
20
20
|
require("../constants/index.js");
|
|
21
21
|
require("@reown/appkit-adapter-solana/react");
|
|
@@ -12,7 +12,7 @@ import "yup";
|
|
|
12
12
|
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
13
13
|
import "../../bignumber-CKZkoo0g.mjs";
|
|
14
14
|
import "wagmi";
|
|
15
|
-
import { u } from "../../useBalances-
|
|
15
|
+
import { u } from "../../useBalances-z9SZjzmN.mjs";
|
|
16
16
|
import "formik";
|
|
17
17
|
import "../constants/index.mjs";
|
|
18
18
|
import "@reown/appkit-adapter-solana/react";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const useFetchBridgeData: ({ refetchTrigger, mvxAddress, mvxApiURL }: {
|
|
1
|
+
export declare const useFetchBridgeData: ({ refetchTrigger, mvxAddress, mvxApiURL, nativeAuthToken }: {
|
|
2
2
|
refetchTrigger?: number;
|
|
3
3
|
mvxAddress?: string;
|
|
4
4
|
mvxApiURL: string;
|
|
5
|
+
nativeAuthToken?: string;
|
|
5
6
|
}) => {
|
|
6
7
|
isTokensError: boolean;
|
|
7
8
|
isTokensLoading: boolean;
|
|
@@ -6,7 +6,8 @@ const reactjs_queries_useGetChains_query = require("../queries/useGetChains.quer
|
|
|
6
6
|
const useFetchBridgeData = ({
|
|
7
7
|
refetchTrigger,
|
|
8
8
|
mvxAddress,
|
|
9
|
-
mvxApiURL
|
|
9
|
+
mvxApiURL,
|
|
10
|
+
nativeAuthToken
|
|
10
11
|
}) => {
|
|
11
12
|
const {
|
|
12
13
|
isTokensError,
|
|
@@ -21,7 +22,8 @@ const useFetchBridgeData = ({
|
|
|
21
22
|
} = reactjs_hooks_useFetchTokens.useFetchTokens({
|
|
22
23
|
mvxApiURL,
|
|
23
24
|
mvxAddress,
|
|
24
|
-
refetchTrigger
|
|
25
|
+
refetchTrigger,
|
|
26
|
+
nativeAuthToken
|
|
25
27
|
});
|
|
26
28
|
const {
|
|
27
29
|
data: chains,
|
|
@@ -3,7 +3,8 @@ import { useGetChainsQuery } from "../queries/useGetChains.query.mjs";
|
|
|
3
3
|
const useFetchBridgeData = ({
|
|
4
4
|
refetchTrigger,
|
|
5
5
|
mvxAddress,
|
|
6
|
-
mvxApiURL
|
|
6
|
+
mvxApiURL,
|
|
7
|
+
nativeAuthToken
|
|
7
8
|
}) => {
|
|
8
9
|
const {
|
|
9
10
|
isTokensError,
|
|
@@ -18,7 +19,8 @@ const useFetchBridgeData = ({
|
|
|
18
19
|
} = useFetchTokens({
|
|
19
20
|
mvxApiURL,
|
|
20
21
|
mvxAddress,
|
|
21
|
-
refetchTrigger
|
|
22
|
+
refetchTrigger,
|
|
23
|
+
nativeAuthToken
|
|
22
24
|
});
|
|
23
25
|
const {
|
|
24
26
|
data: chains,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const useFetchTokens: ({ mvxAddress, mvxApiURL, refetchTrigger }: {
|
|
1
|
+
export declare const useFetchTokens: ({ mvxAddress, mvxApiURL, refetchTrigger, nativeAuthToken }: {
|
|
2
2
|
mvxAddress?: string;
|
|
3
3
|
mvxApiURL: string;
|
|
4
4
|
refetchTrigger?: number;
|
|
5
|
+
nativeAuthToken?: string;
|
|
5
6
|
}) => {
|
|
6
7
|
isTokensLoading: boolean;
|
|
7
8
|
isTokensError: boolean;
|
|
@@ -11,7 +11,8 @@ const reactjs_queries_useGetMvxTokensBalances_query = require("../queries/useGet
|
|
|
11
11
|
const useFetchTokens = ({
|
|
12
12
|
mvxAddress,
|
|
13
13
|
mvxApiURL,
|
|
14
|
-
refetchTrigger
|
|
14
|
+
refetchTrigger,
|
|
15
|
+
nativeAuthToken
|
|
15
16
|
}) => {
|
|
16
17
|
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
17
18
|
const account = reactjs_hooks_useAccount.useAccount();
|
|
@@ -38,7 +39,8 @@ const useFetchTokens = ({
|
|
|
38
39
|
isError: isErrorEvmTokensBalances
|
|
39
40
|
} = reactjs_queries_useGetEvmTokensBalances_query.useGetEvmTokensBalancesQuery({
|
|
40
41
|
tokens: evmTokens ?? [],
|
|
41
|
-
chainId: chainId == null ? void 0 : chainId.toString()
|
|
42
|
+
chainId: chainId == null ? void 0 : chainId.toString(),
|
|
43
|
+
nativeAuthToken
|
|
42
44
|
});
|
|
43
45
|
const {
|
|
44
46
|
data: mvxTokensBalances,
|
|
@@ -8,7 +8,8 @@ import { useGetMvxTokensBalancesQuery, invalidateMvxTokensBalancesQuery } from "
|
|
|
8
8
|
const useFetchTokens = ({
|
|
9
9
|
mvxAddress,
|
|
10
10
|
mvxApiURL,
|
|
11
|
-
refetchTrigger
|
|
11
|
+
refetchTrigger,
|
|
12
|
+
nativeAuthToken
|
|
12
13
|
}) => {
|
|
13
14
|
const chainId = useGetChainId();
|
|
14
15
|
const account = useAccount();
|
|
@@ -35,7 +36,8 @@ const useFetchTokens = ({
|
|
|
35
36
|
isError: isErrorEvmTokensBalances
|
|
36
37
|
} = useGetEvmTokensBalancesQuery({
|
|
37
38
|
tokens: evmTokens ?? [],
|
|
38
|
-
chainId: chainId == null ? void 0 : chainId.toString()
|
|
39
|
+
chainId: chainId == null ? void 0 : chainId.toString(),
|
|
40
|
+
nativeAuthToken
|
|
39
41
|
});
|
|
40
42
|
const {
|
|
41
43
|
data: mvxTokensBalances,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react = require("@reown/appkit/react");
|
|
5
|
+
const wagmi = require("wagmi");
|
|
6
|
+
const reactjs_hooks_useAccount = require("./useAccount.js");
|
|
7
|
+
const useGenericSignMessage = () => {
|
|
8
|
+
const { caipNetwork } = react.useAppKitNetworkCore();
|
|
9
|
+
const { address, isConnected } = reactjs_hooks_useAccount.useAccount();
|
|
10
|
+
const { signMessageAsync } = wagmi.useSignMessage();
|
|
11
|
+
const { walletProvider: solWalletProvider } = react.useAppKitProvider("solana");
|
|
12
|
+
const { walletProvider: btcWalletProvider } = react.useAppKitProvider("bip122");
|
|
13
|
+
const signMessage = async (message) => {
|
|
14
|
+
if (!isConnected || !(caipNetwork == null ? void 0 : caipNetwork.chainNamespace)) {
|
|
15
|
+
throw new Error("Wallet not connected or chain namespace unavailable");
|
|
16
|
+
}
|
|
17
|
+
switch (caipNetwork == null ? void 0 : caipNetwork.chainNamespace) {
|
|
18
|
+
case "eip155": {
|
|
19
|
+
return await signMessageAsync({ message });
|
|
20
|
+
}
|
|
21
|
+
case "solana": {
|
|
22
|
+
const encodedMessage = Buffer.from(message);
|
|
23
|
+
const signature = await solWalletProvider.signMessage(encodedMessage);
|
|
24
|
+
return Buffer.from(signature).toString("hex");
|
|
25
|
+
}
|
|
26
|
+
case "bip122": {
|
|
27
|
+
return await btcWalletProvider.signMessage({
|
|
28
|
+
address: address ?? "",
|
|
29
|
+
message
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
default:
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Unsupported chain namespace: ${caipNetwork.chainNamespace}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
signMessage
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.useGenericSignMessage = useGenericSignMessage;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useAppKitNetworkCore, useAppKitProvider } from "@reown/appkit/react";
|
|
2
|
+
import { useSignMessage } from "wagmi";
|
|
3
|
+
import { useAccount } from "./useAccount.mjs";
|
|
4
|
+
const useGenericSignMessage = () => {
|
|
5
|
+
const { caipNetwork } = useAppKitNetworkCore();
|
|
6
|
+
const { address, isConnected } = useAccount();
|
|
7
|
+
const { signMessageAsync } = useSignMessage();
|
|
8
|
+
const { walletProvider: solWalletProvider } = useAppKitProvider("solana");
|
|
9
|
+
const { walletProvider: btcWalletProvider } = useAppKitProvider("bip122");
|
|
10
|
+
const signMessage = async (message) => {
|
|
11
|
+
if (!isConnected || !(caipNetwork == null ? void 0 : caipNetwork.chainNamespace)) {
|
|
12
|
+
throw new Error("Wallet not connected or chain namespace unavailable");
|
|
13
|
+
}
|
|
14
|
+
switch (caipNetwork == null ? void 0 : caipNetwork.chainNamespace) {
|
|
15
|
+
case "eip155": {
|
|
16
|
+
return await signMessageAsync({ message });
|
|
17
|
+
}
|
|
18
|
+
case "solana": {
|
|
19
|
+
const encodedMessage = Buffer.from(message);
|
|
20
|
+
const signature = await solWalletProvider.signMessage(encodedMessage);
|
|
21
|
+
return Buffer.from(signature).toString("hex");
|
|
22
|
+
}
|
|
23
|
+
case "bip122": {
|
|
24
|
+
return await btcWalletProvider.signMessage({
|
|
25
|
+
address: address ?? "",
|
|
26
|
+
message
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Unsupported chain namespace: ${caipNetwork.chainNamespace}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
signMessage
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
useGenericSignMessage
|
|
41
|
+
};
|
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-du_Oq1bB.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-z9SZjzmN.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";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react = require("@reown/appkit/react");
|
|
5
|
+
const reactQuery = require("@tanstack/react-query");
|
|
6
|
+
const api_checkAccount = require("../../api/checkAccount.js");
|
|
7
|
+
const helpers_getApiURL = require("../../helpers/getApiURL.js");
|
|
8
|
+
require("yup");
|
|
9
|
+
require("react");
|
|
10
|
+
require("@multiversx/sdk-dapp-utils/out/helpers/parseAmount");
|
|
11
|
+
require("../../bignumber-B8vjg9qn.js");
|
|
12
|
+
require("wagmi");
|
|
13
|
+
require("@solana/web3.js");
|
|
14
|
+
require("axios");
|
|
15
|
+
const reactjs_hooks_useGetChainId = require("../hooks/useGetChainId.js");
|
|
16
|
+
require("../context/Web3AppProvider.js");
|
|
17
|
+
require("formik");
|
|
18
|
+
require("../constants/index.js");
|
|
19
|
+
require("@reown/appkit-adapter-solana/react");
|
|
20
|
+
const useCheckAccountQuery = ({
|
|
21
|
+
nativeAuthToken
|
|
22
|
+
}) => {
|
|
23
|
+
const { address } = react.useAppKitAccount();
|
|
24
|
+
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
25
|
+
const queryFn = async () => {
|
|
26
|
+
try {
|
|
27
|
+
const { data } = await api_checkAccount.checkAccount({
|
|
28
|
+
url: helpers_getApiURL.getApiURL(),
|
|
29
|
+
walletAddress: address ?? "",
|
|
30
|
+
chainId: chainId ? chainId.toString() : "",
|
|
31
|
+
nativeAuthToken
|
|
32
|
+
});
|
|
33
|
+
return data;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const retry = (_failureCount, error) => {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = error.response) == null ? void 0 : _a.status) === 404;
|
|
41
|
+
};
|
|
42
|
+
return reactQuery.useQuery({
|
|
43
|
+
queryKey: ["check-account", address, chainId],
|
|
44
|
+
queryFn,
|
|
45
|
+
retry,
|
|
46
|
+
refetchOnWindowFocus: false,
|
|
47
|
+
gcTime: 5 * 60 * 1e3,
|
|
48
|
+
staleTime: 0
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.useCheckAccountQuery = useCheckAccountQuery;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useAppKitAccount } from "@reown/appkit/react";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { checkAccount } from "../../api/checkAccount.mjs";
|
|
4
|
+
import { getApiURL } from "../../helpers/getApiURL.mjs";
|
|
5
|
+
import "yup";
|
|
6
|
+
import "react";
|
|
7
|
+
import "@multiversx/sdk-dapp-utils/out/helpers/parseAmount";
|
|
8
|
+
import "../../bignumber-CKZkoo0g.mjs";
|
|
9
|
+
import "wagmi";
|
|
10
|
+
import "@solana/web3.js";
|
|
11
|
+
import "axios";
|
|
12
|
+
import { useGetChainId } from "../hooks/useGetChainId.mjs";
|
|
13
|
+
import "../context/Web3AppProvider.mjs";
|
|
14
|
+
import "formik";
|
|
15
|
+
import "../constants/index.mjs";
|
|
16
|
+
import "@reown/appkit-adapter-solana/react";
|
|
17
|
+
const useCheckAccountQuery = ({
|
|
18
|
+
nativeAuthToken
|
|
19
|
+
}) => {
|
|
20
|
+
const { address } = useAppKitAccount();
|
|
21
|
+
const chainId = useGetChainId();
|
|
22
|
+
const queryFn = async () => {
|
|
23
|
+
try {
|
|
24
|
+
const { data } = await checkAccount({
|
|
25
|
+
url: getApiURL(),
|
|
26
|
+
walletAddress: address ?? "",
|
|
27
|
+
chainId: chainId ? chainId.toString() : "",
|
|
28
|
+
nativeAuthToken
|
|
29
|
+
});
|
|
30
|
+
return data;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const retry = (_failureCount, error) => {
|
|
36
|
+
var _a;
|
|
37
|
+
return ((_a = error.response) == null ? void 0 : _a.status) === 404;
|
|
38
|
+
};
|
|
39
|
+
return useQuery({
|
|
40
|
+
queryKey: ["check-account", address, chainId],
|
|
41
|
+
queryFn,
|
|
42
|
+
retry,
|
|
43
|
+
refetchOnWindowFocus: false,
|
|
44
|
+
gcTime: 5 * 60 * 1e3,
|
|
45
|
+
staleTime: 0
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
useCheckAccountQuery
|
|
50
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { TokenType } from '../../types';
|
|
2
2
|
import { AxiosError } from 'axios';
|
|
3
3
|
|
|
4
|
-
export declare const useGetEvmTokensBalancesQuery: ({ tokens, chainId }: {
|
|
4
|
+
export declare const useGetEvmTokensBalancesQuery: ({ tokens, chainId, nativeAuthToken }: {
|
|
5
5
|
tokens: TokenType[];
|
|
6
6
|
chainId?: string;
|
|
7
|
+
nativeAuthToken?: string;
|
|
7
8
|
}) => import('@tanstack/react-query').UseQueryResult<{
|
|
8
9
|
balance: string;
|
|
9
10
|
chainId: string;
|
|
@@ -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-du_Oq1bB.js");
|
|
13
13
|
require("formik");
|
|
14
14
|
require("axios");
|
|
15
15
|
require("../context/Web3AppProvider.js");
|
|
@@ -18,10 +18,11 @@ require("@reown/appkit-adapter-solana/react");
|
|
|
18
18
|
require("@solana/web3.js");
|
|
19
19
|
const useGetEvmTokensBalancesQuery = ({
|
|
20
20
|
tokens,
|
|
21
|
-
chainId
|
|
21
|
+
chainId,
|
|
22
|
+
nativeAuthToken
|
|
22
23
|
}) => {
|
|
23
24
|
const { address } = react.useAppKitAccount();
|
|
24
|
-
const { fetchBalances } = reactjs_hooks_useBalances.useBalances();
|
|
25
|
+
const { fetchBalances } = reactjs_hooks_useBalances.useBalances({ nativeAuthToken });
|
|
25
26
|
const queryFn = async () => {
|
|
26
27
|
try {
|
|
27
28
|
if (!address) {
|
|
@@ -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-z9SZjzmN.mjs";
|
|
10
10
|
import "formik";
|
|
11
11
|
import "axios";
|
|
12
12
|
import "../context/Web3AppProvider.mjs";
|
|
@@ -15,10 +15,11 @@ import "@reown/appkit-adapter-solana/react";
|
|
|
15
15
|
import "@solana/web3.js";
|
|
16
16
|
const useGetEvmTokensBalancesQuery = ({
|
|
17
17
|
tokens,
|
|
18
|
-
chainId
|
|
18
|
+
chainId,
|
|
19
|
+
nativeAuthToken
|
|
19
20
|
}) => {
|
|
20
21
|
const { address } = useAppKitAccount();
|
|
21
|
-
const { fetchBalances } = useBalances();
|
|
22
|
+
const { fetchBalances } = useBalances({ nativeAuthToken });
|
|
22
23
|
const queryFn = async () => {
|
|
23
24
|
try {
|
|
24
25
|
if (!address) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const reactQuery = require("@tanstack/react-query");
|
|
5
|
+
const api_linkAccount = require("../../api/linkAccount.js");
|
|
6
|
+
const helpers_getApiURL = require("../../helpers/getApiURL.js");
|
|
7
|
+
const useLinkAccountMutation = () => {
|
|
8
|
+
const mutationFn = async (params) => {
|
|
9
|
+
const { data } = await api_linkAccount.linkAccount({
|
|
10
|
+
url: helpers_getApiURL.getApiURL(),
|
|
11
|
+
...params
|
|
12
|
+
});
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return reactQuery.useMutation({
|
|
16
|
+
mutationFn
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.useLinkAccountMutation = useLinkAccountMutation;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { linkAccount } from "../../api/linkAccount.mjs";
|
|
3
|
+
import { getApiURL } from "../../helpers/getApiURL.mjs";
|
|
4
|
+
const useLinkAccountMutation = () => {
|
|
5
|
+
const mutationFn = async (params) => {
|
|
6
|
+
const { data } = await linkAccount({
|
|
7
|
+
url: getApiURL(),
|
|
8
|
+
...params
|
|
9
|
+
});
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return useMutation({
|
|
13
|
+
mutationFn
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
useLinkAccountMutation
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -170,7 +170,9 @@ async function getTokenBalance(config, parameters) {
|
|
|
170
170
|
const formatted = viem.formatUnits(value ?? "0", getUnit(unit ?? decimals));
|
|
171
171
|
return { decimals, formatted, symbol, value };
|
|
172
172
|
}
|
|
173
|
-
const useBalances = (
|
|
173
|
+
const useBalances = ({
|
|
174
|
+
nativeAuthToken
|
|
175
|
+
}) => {
|
|
174
176
|
const { config } = reactjs_context_useWeb3App.useWeb3App();
|
|
175
177
|
const { address, isConnected } = react.useAppKitAccount();
|
|
176
178
|
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
@@ -196,9 +198,14 @@ const useBalances = () => {
|
|
|
196
198
|
return BigInt(balance.toString());
|
|
197
199
|
};
|
|
198
200
|
const getBtcBalance = async () => {
|
|
199
|
-
const url = `${helpers_getApiURL.getApiURL()}/user/balance/${address}`;
|
|
201
|
+
const url = `${helpers_getApiURL.getApiURL()}/user/balance/${address}?chainId=${activeChain == null ? void 0 : activeChain.chainId}`;
|
|
200
202
|
try {
|
|
201
|
-
const { data } = await axios.get(url
|
|
203
|
+
const { data } = await axios.get(url, {
|
|
204
|
+
baseURL: url,
|
|
205
|
+
headers: {
|
|
206
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
207
|
+
}
|
|
208
|
+
});
|
|
202
209
|
return BigInt(data.balance);
|
|
203
210
|
} catch (error) {
|
|
204
211
|
throw new Error(`Error fetching BTC balance: ${error}`);
|
|
@@ -168,7 +168,9 @@ async function getTokenBalance(config, parameters) {
|
|
|
168
168
|
const formatted = formatUnits(value ?? "0", getUnit(unit ?? decimals));
|
|
169
169
|
return { decimals, formatted, symbol, value };
|
|
170
170
|
}
|
|
171
|
-
const useBalances = (
|
|
171
|
+
const useBalances = ({
|
|
172
|
+
nativeAuthToken
|
|
173
|
+
}) => {
|
|
172
174
|
const { config } = useWeb3App();
|
|
173
175
|
const { address, isConnected } = useAppKitAccount();
|
|
174
176
|
const chainId = useGetChainId();
|
|
@@ -194,9 +196,14 @@ const useBalances = () => {
|
|
|
194
196
|
return BigInt(balance.toString());
|
|
195
197
|
};
|
|
196
198
|
const getBtcBalance = async () => {
|
|
197
|
-
const url = `${getApiURL()}/user/balance/${address}`;
|
|
199
|
+
const url = `${getApiURL()}/user/balance/${address}?chainId=${activeChain == null ? void 0 : activeChain.chainId}`;
|
|
198
200
|
try {
|
|
199
|
-
const { data } = await axios.get(url
|
|
201
|
+
const { data } = await axios.get(url, {
|
|
202
|
+
baseURL: url,
|
|
203
|
+
headers: {
|
|
204
|
+
Authorization: `Bearer ${nativeAuthToken}`
|
|
205
|
+
}
|
|
206
|
+
});
|
|
200
207
|
return BigInt(data.balance);
|
|
201
208
|
} catch (error) {
|
|
202
209
|
throw new Error(`Error fetching BTC balance: ${error}`);
|