@multiversx/sdk-dapp-liquidity 1.1.0-alpha.24 → 1.1.0-alpha.26
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/package.json
CHANGED
|
@@ -5,6 +5,7 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
|
5
5
|
const faSpinner = require("@fortawesome/free-solid-svg-icons/faSpinner");
|
|
6
6
|
const reactFontawesome = require("@fortawesome/react-fontawesome");
|
|
7
7
|
const formatAmount = require("@multiversx/sdk-dapp-utils/out/helpers/formatAmount");
|
|
8
|
+
const react = require("@reown/appkit/react");
|
|
8
9
|
const debounce = require("lodash/debounce");
|
|
9
10
|
const React = require("react");
|
|
10
11
|
const reactToastify = require("react-toastify");
|
|
@@ -36,7 +37,6 @@ require("react-popper");
|
|
|
36
37
|
require("../base/MxTooltip/components/TooltipContainer/TooltipContainer.js");
|
|
37
38
|
const reactjs_components_BridgeHistory_BridgeHistory = require("../BridgeHistory/BridgeHistory.js");
|
|
38
39
|
const reactjs_components_Connect_BridgeConnectButton = require("../Connect/BridgeConnectButton.js");
|
|
39
|
-
require("@reown/appkit/react");
|
|
40
40
|
require("wagmi");
|
|
41
41
|
const reactjs_components_Connect_MvxConnectButton = require("../Connect/MvxConnectButton.js");
|
|
42
42
|
const reactjs_components_Connect_BridgeAccountDisplay = require("../Connect/BridgeAccountDisplay.js");
|
|
@@ -144,6 +144,7 @@ const BridgeForm = ({
|
|
|
144
144
|
const [pendingSigning, setPendingSigning] = React.useState(false);
|
|
145
145
|
const [siginingTransactionsCount, setSigningTransactionsCount] = React.useState(0);
|
|
146
146
|
const account = reactjs_hooks_useAccount.useAccount();
|
|
147
|
+
const { switchNetwork } = react.useAppKitNetwork();
|
|
147
148
|
const { config, options, supportedChains: sdkChains } = reactjs_context_useWeb3App.useWeb3App();
|
|
148
149
|
const chainId = reactjs_hooks_useGetChainId.useGetChainId();
|
|
149
150
|
const {
|
|
@@ -180,9 +181,9 @@ const BridgeForm = ({
|
|
|
180
181
|
} = reactjs_queries_useGetRate_mutation.useGetRateMutation();
|
|
181
182
|
const rateValidationError = ((_a = rateError == null ? void 0 : rateError.response) == null ? void 0 : _a.status) === 400 ? (_b = rateError == null ? void 0 : rateError.response) == null ? void 0 : _b.data.message : void 0;
|
|
182
183
|
const [firstToken, setFirstToken] = React.useState();
|
|
183
|
-
const [firstAmount, setFirstAmount] = React.useState("");
|
|
184
|
+
const [firstAmount, setFirstAmount] = React.useState(firstTokenAmount ?? "");
|
|
184
185
|
const [secondToken, setSecondToken] = React.useState();
|
|
185
|
-
const [secondAmount, setSecondAmount] = React.useState("");
|
|
186
|
+
const [secondAmount, setSecondAmount] = React.useState(secondTokenAmount ?? "");
|
|
186
187
|
const bridgeAddress = account.address;
|
|
187
188
|
const isAuthenticated = account.isConnected && Boolean(bridgeAddress);
|
|
188
189
|
const fromOptions = React.useMemo(
|
|
@@ -400,6 +401,12 @@ const BridgeForm = ({
|
|
|
400
401
|
updateUrlParams({
|
|
401
402
|
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
402
403
|
});
|
|
404
|
+
const selectedOptionChain = (sdkChains == null ? void 0 : sdkChains.find(
|
|
405
|
+
(chain) => chain.id.toString() === (firstOption == null ? void 0 : firstOption.chainId.toString())
|
|
406
|
+
)) ?? activeChain;
|
|
407
|
+
if (selectedOptionChain) {
|
|
408
|
+
switchNetwork(selectedOptionChain);
|
|
409
|
+
}
|
|
403
410
|
initializedFirstToken = true;
|
|
404
411
|
}
|
|
405
412
|
let initializedSecondToken = false;
|
|
@@ -619,11 +626,19 @@ const BridgeForm = ({
|
|
|
619
626
|
}, [mvxTokensWithBalances, secondToken == null ? void 0 : secondToken.address]);
|
|
620
627
|
React.useEffect(() => {
|
|
621
628
|
if (firstTokenAmount) {
|
|
629
|
+
formik.setFieldValue(
|
|
630
|
+
reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.firstAmount,
|
|
631
|
+
firstTokenAmount
|
|
632
|
+
);
|
|
622
633
|
handleOnChangeFirstAmount(firstTokenAmount);
|
|
623
634
|
}
|
|
624
|
-
}, [
|
|
635
|
+
}, []);
|
|
625
636
|
React.useEffect(() => {
|
|
626
637
|
if (secondTokenAmount) {
|
|
638
|
+
formik.setFieldValue(
|
|
639
|
+
reactjs_hooks_useBridgeFormik.BridgeFormikValuesEnum.secondAmount,
|
|
640
|
+
secondTokenAmount
|
|
641
|
+
);
|
|
627
642
|
handleOnChangeSecondAmount(secondTokenAmount);
|
|
628
643
|
}
|
|
629
644
|
}, [secondTokenAmount]);
|
|
@@ -2,6 +2,7 @@ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { faSpinner } from "@fortawesome/free-solid-svg-icons/faSpinner";
|
|
3
3
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import { formatAmount } from "@multiversx/sdk-dapp-utils/out/helpers/formatAmount";
|
|
5
|
+
import { useAppKitNetwork } from "@reown/appkit/react";
|
|
5
6
|
import debounce from "lodash/debounce";
|
|
6
7
|
import { useRef, useState, useMemo, useCallback, useEffect } from "react";
|
|
7
8
|
import { toast } from "react-toastify";
|
|
@@ -33,7 +34,6 @@ import "react-popper";
|
|
|
33
34
|
import "../base/MxTooltip/components/TooltipContainer/TooltipContainer.mjs";
|
|
34
35
|
import { BridgeHistory } from "../BridgeHistory/BridgeHistory.mjs";
|
|
35
36
|
import { BridgeConnectButton } from "../Connect/BridgeConnectButton.mjs";
|
|
36
|
-
import "@reown/appkit/react";
|
|
37
37
|
import "wagmi";
|
|
38
38
|
import { MvxConnectButton } from "../Connect/MvxConnectButton.mjs";
|
|
39
39
|
import { BridgeAccountDisplay } from "../Connect/BridgeAccountDisplay.mjs";
|
|
@@ -141,6 +141,7 @@ const BridgeForm = ({
|
|
|
141
141
|
const [pendingSigning, setPendingSigning] = useState(false);
|
|
142
142
|
const [siginingTransactionsCount, setSigningTransactionsCount] = useState(0);
|
|
143
143
|
const account = useAccount();
|
|
144
|
+
const { switchNetwork } = useAppKitNetwork();
|
|
144
145
|
const { config, options, supportedChains: sdkChains } = useWeb3App();
|
|
145
146
|
const chainId = useGetChainId();
|
|
146
147
|
const {
|
|
@@ -177,9 +178,9 @@ const BridgeForm = ({
|
|
|
177
178
|
} = useGetRateMutation();
|
|
178
179
|
const rateValidationError = ((_a = rateError == null ? void 0 : rateError.response) == null ? void 0 : _a.status) === 400 ? (_b = rateError == null ? void 0 : rateError.response) == null ? void 0 : _b.data.message : void 0;
|
|
179
180
|
const [firstToken, setFirstToken] = useState();
|
|
180
|
-
const [firstAmount, setFirstAmount] = useState("");
|
|
181
|
+
const [firstAmount, setFirstAmount] = useState(firstTokenAmount ?? "");
|
|
181
182
|
const [secondToken, setSecondToken] = useState();
|
|
182
|
-
const [secondAmount, setSecondAmount] = useState("");
|
|
183
|
+
const [secondAmount, setSecondAmount] = useState(secondTokenAmount ?? "");
|
|
183
184
|
const bridgeAddress = account.address;
|
|
184
185
|
const isAuthenticated = account.isConnected && Boolean(bridgeAddress);
|
|
185
186
|
const fromOptions = useMemo(
|
|
@@ -397,6 +398,12 @@ const BridgeForm = ({
|
|
|
397
398
|
updateUrlParams({
|
|
398
399
|
firstTokenId: firstOption == null ? void 0 : firstOption.address
|
|
399
400
|
});
|
|
401
|
+
const selectedOptionChain = (sdkChains == null ? void 0 : sdkChains.find(
|
|
402
|
+
(chain) => chain.id.toString() === (firstOption == null ? void 0 : firstOption.chainId.toString())
|
|
403
|
+
)) ?? activeChain;
|
|
404
|
+
if (selectedOptionChain) {
|
|
405
|
+
switchNetwork(selectedOptionChain);
|
|
406
|
+
}
|
|
400
407
|
initializedFirstToken = true;
|
|
401
408
|
}
|
|
402
409
|
let initializedSecondToken = false;
|
|
@@ -616,11 +623,19 @@ const BridgeForm = ({
|
|
|
616
623
|
}, [mvxTokensWithBalances, secondToken == null ? void 0 : secondToken.address]);
|
|
617
624
|
useEffect(() => {
|
|
618
625
|
if (firstTokenAmount) {
|
|
626
|
+
formik.setFieldValue(
|
|
627
|
+
BridgeFormikValuesEnum.firstAmount,
|
|
628
|
+
firstTokenAmount
|
|
629
|
+
);
|
|
619
630
|
handleOnChangeFirstAmount(firstTokenAmount);
|
|
620
631
|
}
|
|
621
|
-
}, [
|
|
632
|
+
}, []);
|
|
622
633
|
useEffect(() => {
|
|
623
634
|
if (secondTokenAmount) {
|
|
635
|
+
formik.setFieldValue(
|
|
636
|
+
BridgeFormikValuesEnum.secondAmount,
|
|
637
|
+
secondTokenAmount
|
|
638
|
+
);
|
|
624
639
|
handleOnChangeSecondAmount(secondTokenAmount);
|
|
625
640
|
}
|
|
626
641
|
}, [secondTokenAmount]);
|