squarefi-bff-api-module 1.36.30 → 1.36.31
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/dist/hooks/useCalc.d.ts +2 -0
- package/dist/hooks/useCalc.js +10 -1
- package/package.json +1 -1
package/dist/hooks/useCalc.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type UseOrderCalcProps = {
|
|
|
29
29
|
calcHandler: (props: OrderCalcHandlerProps) => Promise<CalcResult>;
|
|
30
30
|
disableCalculation?: boolean;
|
|
31
31
|
to_address?: string;
|
|
32
|
+
minSellAmount?: number | null;
|
|
33
|
+
maxSellAmount?: number | null;
|
|
32
34
|
};
|
|
33
35
|
export type UseOrderCalcData = {
|
|
34
36
|
calcData: CalcData | null;
|
package/dist/hooks/useCalc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import debounce from 'lodash.debounce';
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
|
-
export const useOrderCalc = ({ from_currency_id, to_currency_id, calcHandler, disableCalculation, to_address, }) => {
|
|
3
|
+
export const useOrderCalc = ({ from_currency_id, to_currency_id, calcHandler, disableCalculation, to_address, minSellAmount, maxSellAmount, }) => {
|
|
4
4
|
const [sellingAmount, setSellingAmount] = useState(0);
|
|
5
5
|
const [buyingAmount, setBuyingAmount] = useState(0);
|
|
6
6
|
const [calcData, setCalcData] = useState(null);
|
|
@@ -44,6 +44,15 @@ export const useOrderCalc = ({ from_currency_id, to_currency_id, calcHandler, di
|
|
|
44
44
|
resetOrderCalc();
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
+
// Skip the backend calc for a sell amount outside the allowed range: returning before the request (and
|
|
48
|
+
// before the pending flag is set) means no error is thrown, so no error toast reaches the user. Forward
|
|
49
|
+
// direction only — a reverse edit derives the sell amount server-side. calcData is left untouched so the
|
|
50
|
+
// caller's stale-guard still blocks submit until a valid amount.
|
|
51
|
+
if (!is_reverse &&
|
|
52
|
+
((minSellAmount != null && calcParams.amount < minSellAmount) ||
|
|
53
|
+
(maxSellAmount != null && calcParams.amount > maxSellAmount))) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
47
56
|
try {
|
|
48
57
|
is_reverse ? setIsSellingValuePending(true) : setIsBuyingValuePending(true);
|
|
49
58
|
const data = await calcHandler(calcParams);
|