@multiversx/sdk-dapp-liquidity 1.1.0-alpha.44 → 1.1.0-alpha.45
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
|
@@ -141,6 +141,7 @@ const BridgeForm = ({
|
|
|
141
141
|
const initializedInitialTokensRef = React.useRef(false);
|
|
142
142
|
const [isTokenSelectorVisible, setIsTokenSelectorVisible] = React.useState(false);
|
|
143
143
|
const [pendingSigning, setPendingSigning] = React.useState(false);
|
|
144
|
+
const [forceRefetchRate, setForceRefetchRate] = React.useState(1);
|
|
144
145
|
const [siginingTransactionsCount, setSigningTransactionsCount] = React.useState(0);
|
|
145
146
|
const account = reactjs_hooks_useAccount.useAccount();
|
|
146
147
|
const { switchNetwork } = react.useAppKitNetwork();
|
|
@@ -569,6 +570,7 @@ const BridgeForm = ({
|
|
|
569
570
|
toChainId: mvxChainId,
|
|
570
571
|
secondToken,
|
|
571
572
|
secondAmount,
|
|
573
|
+
setForceRefetchRate,
|
|
572
574
|
onSubmit
|
|
573
575
|
});
|
|
574
576
|
const hasError = Boolean(
|
|
@@ -586,7 +588,7 @@ const BridgeForm = ({
|
|
|
586
588
|
fetchRateDebounced(firstAmount);
|
|
587
589
|
}, 60 * 1e3);
|
|
588
590
|
return () => clearInterval(fetchRateInterval);
|
|
589
|
-
}, [firstAmount, fetchRateDebounced]);
|
|
591
|
+
}, [firstAmount, forceRefetchRate, fetchRateDebounced]);
|
|
590
592
|
React.useEffect(() => {
|
|
591
593
|
if (!(rate == null ? void 0 : rate.amountOut)) {
|
|
592
594
|
return;
|
|
@@ -138,6 +138,7 @@ const BridgeForm = ({
|
|
|
138
138
|
const initializedInitialTokensRef = useRef(false);
|
|
139
139
|
const [isTokenSelectorVisible, setIsTokenSelectorVisible] = useState(false);
|
|
140
140
|
const [pendingSigning, setPendingSigning] = useState(false);
|
|
141
|
+
const [forceRefetchRate, setForceRefetchRate] = useState(1);
|
|
141
142
|
const [siginingTransactionsCount, setSigningTransactionsCount] = useState(0);
|
|
142
143
|
const account = useAccount();
|
|
143
144
|
const { switchNetwork } = useAppKitNetwork();
|
|
@@ -566,6 +567,7 @@ const BridgeForm = ({
|
|
|
566
567
|
toChainId: mvxChainId,
|
|
567
568
|
secondToken,
|
|
568
569
|
secondAmount,
|
|
570
|
+
setForceRefetchRate,
|
|
569
571
|
onSubmit
|
|
570
572
|
});
|
|
571
573
|
const hasError = Boolean(
|
|
@@ -583,7 +585,7 @@ const BridgeForm = ({
|
|
|
583
585
|
fetchRateDebounced(firstAmount);
|
|
584
586
|
}, 60 * 1e3);
|
|
585
587
|
return () => clearInterval(fetchRateInterval);
|
|
586
|
-
}, [firstAmount, fetchRateDebounced]);
|
|
588
|
+
}, [firstAmount, forceRefetchRate, fetchRateDebounced]);
|
|
587
589
|
useEffect(() => {
|
|
588
590
|
if (!(rate == null ? void 0 : rate.amountOut)) {
|
|
589
591
|
return;
|
|
@@ -19,7 +19,7 @@ export interface TradeFormikValuesType {
|
|
|
19
19
|
fromChainId?: string;
|
|
20
20
|
toChainId?: string;
|
|
21
21
|
}
|
|
22
|
-
export declare const useBridgeFormik: ({ mvxAccountAddress, firstToken, firstAmount, secondToken, secondAmount, fromChainId, toChainId, rate, onSubmit }: {
|
|
22
|
+
export declare const useBridgeFormik: ({ mvxAccountAddress, firstToken, firstAmount, secondToken, secondAmount, fromChainId, toChainId, setForceRefetchRate, rate, onSubmit }: {
|
|
23
23
|
mvxAccountAddress?: string;
|
|
24
24
|
firstAmount?: string;
|
|
25
25
|
secondAmount?: string;
|
|
@@ -27,6 +27,7 @@ export declare const useBridgeFormik: ({ mvxAccountAddress, firstToken, firstAmo
|
|
|
27
27
|
toChainId?: string;
|
|
28
28
|
firstToken?: TokenType;
|
|
29
29
|
secondToken?: TokenType;
|
|
30
|
+
setForceRefetchRate?: (value: (previous: number) => number) => void;
|
|
30
31
|
rate?: RateRequestResponse;
|
|
31
32
|
onSubmit: ({ transactions, provider }: {
|
|
32
33
|
transactions: ServerTransaction[];
|
|
@@ -28,6 +28,7 @@ const useBridgeFormik = ({
|
|
|
28
28
|
secondAmount,
|
|
29
29
|
fromChainId,
|
|
30
30
|
toChainId,
|
|
31
|
+
setForceRefetchRate,
|
|
31
32
|
rate,
|
|
32
33
|
onSubmit
|
|
33
34
|
}) => {
|
|
@@ -52,34 +53,40 @@ const useBridgeFormik = ({
|
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
55
|
pendingSigningRef.current = true;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
56
|
+
try {
|
|
57
|
+
const { data } = await api_confirmRate.confirmRate({
|
|
58
|
+
url: helpers_getApiURL.getApiURL(),
|
|
59
|
+
nativeAuthToken: nativeAuthToken ?? "",
|
|
60
|
+
body: {
|
|
61
|
+
tokenIn: ((_a = values.firstToken) == null ? void 0 : _a.address) ?? "",
|
|
62
|
+
amountIn: (firstAmount == null ? void 0 : firstAmount.toString()) ?? "",
|
|
63
|
+
fromChainId: values.fromChainId ?? "",
|
|
64
|
+
tokenOut: ((_b = values.secondToken) == null ? void 0 : _b.address) ?? "",
|
|
65
|
+
toChainId: values.toChainId ?? "",
|
|
66
|
+
amountOut: (secondAmount == null ? void 0 : secondAmount.toString()) ?? "",
|
|
67
|
+
sender: account.address ?? "",
|
|
68
|
+
receiver: mvxAccountAddress ?? "",
|
|
69
|
+
fee: (rate == null ? void 0 : rate.fee) ?? "0",
|
|
70
|
+
provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None,
|
|
71
|
+
orderId: (rate == null ? void 0 : rate.orderId) ?? ""
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const transactions = data;
|
|
75
|
+
if (!transactions || transactions.length === 0) {
|
|
76
|
+
pendingSigningRef.current = false;
|
|
77
|
+
return;
|
|
70
78
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
resetSwapForm();
|
|
80
|
+
onSubmit({
|
|
81
|
+
transactions,
|
|
82
|
+
provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error("Error confirming rate:", error);
|
|
86
|
+
setForceRefetchRate == null ? void 0 : setForceRefetchRate((prevState) => prevState + 1);
|
|
87
|
+
} finally {
|
|
74
88
|
pendingSigningRef.current = false;
|
|
75
|
-
return;
|
|
76
89
|
}
|
|
77
|
-
resetSwapForm();
|
|
78
|
-
onSubmit({
|
|
79
|
-
transactions,
|
|
80
|
-
provider: (rate == null ? void 0 : rate.provider) ?? types_providerType.ProviderType.None
|
|
81
|
-
});
|
|
82
|
-
pendingSigningRef.current = false;
|
|
83
90
|
};
|
|
84
91
|
const formik$1 = formik.useFormik({
|
|
85
92
|
initialValues,
|
|
@@ -25,6 +25,7 @@ const useBridgeFormik = ({
|
|
|
25
25
|
secondAmount,
|
|
26
26
|
fromChainId,
|
|
27
27
|
toChainId,
|
|
28
|
+
setForceRefetchRate,
|
|
28
29
|
rate,
|
|
29
30
|
onSubmit
|
|
30
31
|
}) => {
|
|
@@ -49,34 +50,40 @@ const useBridgeFormik = ({
|
|
|
49
50
|
return;
|
|
50
51
|
}
|
|
51
52
|
pendingSigningRef.current = true;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
try {
|
|
54
|
+
const { data } = await confirmRate({
|
|
55
|
+
url: getApiURL(),
|
|
56
|
+
nativeAuthToken: nativeAuthToken ?? "",
|
|
57
|
+
body: {
|
|
58
|
+
tokenIn: ((_a = values.firstToken) == null ? void 0 : _a.address) ?? "",
|
|
59
|
+
amountIn: (firstAmount == null ? void 0 : firstAmount.toString()) ?? "",
|
|
60
|
+
fromChainId: values.fromChainId ?? "",
|
|
61
|
+
tokenOut: ((_b = values.secondToken) == null ? void 0 : _b.address) ?? "",
|
|
62
|
+
toChainId: values.toChainId ?? "",
|
|
63
|
+
amountOut: (secondAmount == null ? void 0 : secondAmount.toString()) ?? "",
|
|
64
|
+
sender: account.address ?? "",
|
|
65
|
+
receiver: mvxAccountAddress ?? "",
|
|
66
|
+
fee: (rate == null ? void 0 : rate.fee) ?? "0",
|
|
67
|
+
provider: (rate == null ? void 0 : rate.provider) ?? ProviderType.None,
|
|
68
|
+
orderId: (rate == null ? void 0 : rate.orderId) ?? ""
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const transactions = data;
|
|
72
|
+
if (!transactions || transactions.length === 0) {
|
|
73
|
+
pendingSigningRef.current = false;
|
|
74
|
+
return;
|
|
67
75
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
resetSwapForm();
|
|
77
|
+
onSubmit({
|
|
78
|
+
transactions,
|
|
79
|
+
provider: (rate == null ? void 0 : rate.provider) ?? ProviderType.None
|
|
80
|
+
});
|
|
81
|
+
} catch (error) {
|
|
82
|
+
console.error("Error confirming rate:", error);
|
|
83
|
+
setForceRefetchRate == null ? void 0 : setForceRefetchRate((prevState) => prevState + 1);
|
|
84
|
+
} finally {
|
|
71
85
|
pendingSigningRef.current = false;
|
|
72
|
-
return;
|
|
73
86
|
}
|
|
74
|
-
resetSwapForm();
|
|
75
|
-
onSubmit({
|
|
76
|
-
transactions,
|
|
77
|
-
provider: (rate == null ? void 0 : rate.provider) ?? ProviderType.None
|
|
78
|
-
});
|
|
79
|
-
pendingSigningRef.current = false;
|
|
80
87
|
};
|
|
81
88
|
const formik = useFormik({
|
|
82
89
|
initialValues,
|