@multiversx/sdk-dapp-liquidity 1.1.0-alpha.47 → 1.1.0-alpha.49
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 +1 -1
- package/reactjs/components/AmountInput/AmountInput.d.ts +1 -1
- package/reactjs/components/BridgeForm/BridgeForm.js +12 -6
- package/reactjs/components/BridgeForm/BridgeForm.mjs +12 -6
- package/reactjs/hooks/useFetchTokens.js +1 -1
- package/reactjs/hooks/useFetchTokens.mjs +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { ChangeEvent, FocusEvent } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export declare const AmountInput: ({ inputName, inputValue, disabled, amountError, omitDisableClass, className, onBlur, onInputDebounceChange, onInputChange }: {
|
|
4
4
|
inputName: string;
|
|
5
|
-
inputValue
|
|
5
|
+
inputValue?: string;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
amountError?: string;
|
|
8
8
|
omitDisableClass?: boolean;
|
|
@@ -261,7 +261,7 @@ const BridgeForm = ({
|
|
|
261
261
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
262
262
|
const fetchRateDebounced = React.useCallback(
|
|
263
263
|
debounce(async (amount) => {
|
|
264
|
-
if (!amount || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !chainId) {
|
|
264
|
+
if (!amount || !Number(amount) || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !chainId) {
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
getRate({
|
|
@@ -584,6 +584,12 @@ const BridgeForm = ({
|
|
|
584
584
|
const hasError = Boolean(
|
|
585
585
|
firstAmountError || secondAmountError || fromChainError || rateValidationError
|
|
586
586
|
);
|
|
587
|
+
const amountErrorFirstInput = React.useMemo(() => {
|
|
588
|
+
return firstAmount !== "" ? rateValidationError ?? firstAmountError : void 0;
|
|
589
|
+
}, [firstAmountError, firstAmount, rateValidationError]);
|
|
590
|
+
const amountErrorSecondInput = React.useMemo(() => {
|
|
591
|
+
return secondAmount !== "" ? fromChainError ?? secondAmountError : void 0;
|
|
592
|
+
}, [fromChainError, secondAmountError, secondAmount]);
|
|
587
593
|
React.useEffect(() => {
|
|
588
594
|
if (!firstAmount) {
|
|
589
595
|
setSecondAmount("");
|
|
@@ -699,9 +705,9 @@ const BridgeForm = ({
|
|
|
699
705
|
reactjs_components_AmountInput_AmountInput.AmountInput,
|
|
700
706
|
{
|
|
701
707
|
inputName: "firstAmount",
|
|
702
|
-
inputValue: formik.values.firstAmount
|
|
703
|
-
amountError:
|
|
704
|
-
disabled:
|
|
708
|
+
inputValue: formik.values.firstAmount,
|
|
709
|
+
amountError: amountErrorFirstInput,
|
|
710
|
+
disabled: false,
|
|
705
711
|
onInputDebounceChange: handleOnChangeFirstAmount,
|
|
706
712
|
onInputChange: handleChange,
|
|
707
713
|
onBlur: handleBlur
|
|
@@ -757,8 +763,8 @@ const BridgeForm = ({
|
|
|
757
763
|
reactjs_components_AmountInput_AmountInput.AmountInput,
|
|
758
764
|
{
|
|
759
765
|
inputName: "secondAmount",
|
|
760
|
-
inputValue: formik.values.secondAmount
|
|
761
|
-
amountError:
|
|
766
|
+
inputValue: formik.values.secondAmount,
|
|
767
|
+
amountError: amountErrorSecondInput,
|
|
762
768
|
disabled: false,
|
|
763
769
|
onInputDebounceChange: handleOnChangeSecondAmount,
|
|
764
770
|
onInputChange: handleChange,
|
|
@@ -258,7 +258,7 @@ const BridgeForm = ({
|
|
|
258
258
|
const hasAmounts = firstAmount !== "" && secondAmount !== "";
|
|
259
259
|
const fetchRateDebounced = useCallback(
|
|
260
260
|
debounce(async (amount) => {
|
|
261
|
-
if (!amount || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !chainId) {
|
|
261
|
+
if (!amount || !Number(amount) || !account.address || !(firstToken == null ? void 0 : firstToken.address) || !(secondToken == null ? void 0 : secondToken.address) || !selectedChainOption || !chainId) {
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
264
|
getRate({
|
|
@@ -581,6 +581,12 @@ const BridgeForm = ({
|
|
|
581
581
|
const hasError = Boolean(
|
|
582
582
|
firstAmountError || secondAmountError || fromChainError || rateValidationError
|
|
583
583
|
);
|
|
584
|
+
const amountErrorFirstInput = useMemo(() => {
|
|
585
|
+
return firstAmount !== "" ? rateValidationError ?? firstAmountError : void 0;
|
|
586
|
+
}, [firstAmountError, firstAmount, rateValidationError]);
|
|
587
|
+
const amountErrorSecondInput = useMemo(() => {
|
|
588
|
+
return secondAmount !== "" ? fromChainError ?? secondAmountError : void 0;
|
|
589
|
+
}, [fromChainError, secondAmountError, secondAmount]);
|
|
584
590
|
useEffect(() => {
|
|
585
591
|
if (!firstAmount) {
|
|
586
592
|
setSecondAmount("");
|
|
@@ -696,9 +702,9 @@ const BridgeForm = ({
|
|
|
696
702
|
AmountInput,
|
|
697
703
|
{
|
|
698
704
|
inputName: "firstAmount",
|
|
699
|
-
inputValue: formik.values.firstAmount
|
|
700
|
-
amountError:
|
|
701
|
-
disabled:
|
|
705
|
+
inputValue: formik.values.firstAmount,
|
|
706
|
+
amountError: amountErrorFirstInput,
|
|
707
|
+
disabled: false,
|
|
702
708
|
onInputDebounceChange: handleOnChangeFirstAmount,
|
|
703
709
|
onInputChange: handleChange,
|
|
704
710
|
onBlur: handleBlur
|
|
@@ -754,8 +760,8 @@ const BridgeForm = ({
|
|
|
754
760
|
AmountInput,
|
|
755
761
|
{
|
|
756
762
|
inputName: "secondAmount",
|
|
757
|
-
inputValue: formik.values.secondAmount
|
|
758
|
-
amountError:
|
|
763
|
+
inputValue: formik.values.secondAmount,
|
|
764
|
+
amountError: amountErrorSecondInput,
|
|
759
765
|
disabled: false,
|
|
760
766
|
onInputDebounceChange: handleOnChangeSecondAmount,
|
|
761
767
|
onInputChange: handleChange,
|
|
@@ -69,7 +69,7 @@ const useFetchTokens = ({
|
|
|
69
69
|
const evmTokensWithBalances = React.useMemo(() => {
|
|
70
70
|
return evmTokens == null ? void 0 : evmTokens.map((token) => {
|
|
71
71
|
const foundToken = evmTokensBalances == null ? void 0 : evmTokensBalances.find(
|
|
72
|
-
(evmToken) => evmToken.address === token.address
|
|
72
|
+
(evmToken) => evmToken.address === token.address && evmToken.chainId === token.chainId
|
|
73
73
|
);
|
|
74
74
|
if (!foundToken) {
|
|
75
75
|
return {
|
|
@@ -66,7 +66,7 @@ const useFetchTokens = ({
|
|
|
66
66
|
const evmTokensWithBalances = useMemo(() => {
|
|
67
67
|
return evmTokens == null ? void 0 : evmTokens.map((token) => {
|
|
68
68
|
const foundToken = evmTokensBalances == null ? void 0 : evmTokensBalances.find(
|
|
69
|
-
(evmToken) => evmToken.address === token.address
|
|
69
|
+
(evmToken) => evmToken.address === token.address && evmToken.chainId === token.chainId
|
|
70
70
|
);
|
|
71
71
|
if (!foundToken) {
|
|
72
72
|
return {
|