squarefi-bff-api-module 1.24.16 → 1.24.17

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.
@@ -1303,7 +1303,7 @@ export declare namespace API {
1303
1303
  namespace WITHDRAWAL_CRYPTO {
1304
1304
  type Request = {
1305
1305
  amount: number;
1306
- is_subsctract: boolean;
1306
+ is_subtract: boolean;
1307
1307
  wallet_uuid: string;
1308
1308
  crypto_uuid: string;
1309
1309
  to_address: string;
@@ -1425,8 +1425,8 @@ export declare namespace API {
1425
1425
  from_currency_id: string;
1426
1426
  to_currency_id: string;
1427
1427
  amount: number;
1428
- is_reverse?: boolean;
1429
- is_subsctract?: boolean;
1428
+ is_reverse: boolean;
1429
+ is_subtract: boolean;
1430
1430
  signal?: AbortSignal;
1431
1431
  }
1432
1432
  export interface WithdrawCryptoRequest extends CommonRequestParams {
@@ -1466,7 +1466,7 @@ export declare namespace API {
1466
1466
  to_wallet_uuid: string;
1467
1467
  amount: number;
1468
1468
  request_id: string;
1469
- is_subsctract?: boolean;
1469
+ is_subtract?: boolean;
1470
1470
  is_reverse?: boolean;
1471
1471
  }
1472
1472
  type Response = null;
@@ -1479,7 +1479,7 @@ export declare namespace API {
1479
1479
  wallet_id: string;
1480
1480
  from_currency_id: string;
1481
1481
  to_currency_id: string;
1482
- is_subsctract?: boolean;
1482
+ is_subtract?: boolean;
1483
1483
  is_reverse?: boolean;
1484
1484
  }
1485
1485
  interface Response {
@@ -1515,7 +1515,7 @@ export declare namespace API {
1515
1515
  wallet_id: string;
1516
1516
  from_currency_id: string;
1517
1517
  to_currency_id: string;
1518
- is_subsctract?: boolean;
1518
+ is_subtract?: boolean;
1519
1519
  is_reverse?: boolean;
1520
1520
  }
1521
1521
  interface Response {
@@ -1551,7 +1551,7 @@ export declare namespace API {
1551
1551
  wallet_id: string;
1552
1552
  from_currency_id: string;
1553
1553
  to_currency_id: string;
1554
- is_subsctract?: boolean;
1554
+ is_subtract?: boolean;
1555
1555
  is_reverse?: boolean;
1556
1556
  }
1557
1557
  interface Response {
@@ -1589,7 +1589,7 @@ export declare namespace API {
1589
1589
  to_currency_id: string;
1590
1590
  refference?: string;
1591
1591
  note?: string;
1592
- is_subsctract?: boolean;
1592
+ is_subtract?: boolean;
1593
1593
  is_reverse?: boolean;
1594
1594
  }
1595
1595
  interface Response {
@@ -1627,7 +1627,7 @@ export declare namespace API {
1627
1627
  to_currency_id: string;
1628
1628
  refference?: string;
1629
1629
  note?: string;
1630
- is_subsctract?: boolean;
1630
+ is_subtract?: boolean;
1631
1631
  is_reverse?: boolean;
1632
1632
  }
1633
1633
  interface Response {
@@ -1665,7 +1665,7 @@ export declare namespace API {
1665
1665
  to_currency_id: string;
1666
1666
  refference?: string;
1667
1667
  note?: string;
1668
- is_subsctract?: boolean;
1668
+ is_subtract?: boolean;
1669
1669
  is_reverse?: boolean;
1670
1670
  }
1671
1671
  interface Response {
@@ -1701,7 +1701,7 @@ export declare namespace API {
1701
1701
  wallet_id: string;
1702
1702
  from_currency_id: string;
1703
1703
  to_currency_id: string;
1704
- is_subsctract?: boolean;
1704
+ is_subtract?: boolean;
1705
1705
  is_reverse?: boolean;
1706
1706
  }
1707
1707
  interface Response {
@@ -1738,7 +1738,7 @@ export declare namespace API {
1738
1738
  wallet_account_id: string;
1739
1739
  from_currency_id: string;
1740
1740
  note?: string;
1741
- is_subsctract?: boolean;
1741
+ is_subtract?: boolean;
1742
1742
  is_reverse?: boolean;
1743
1743
  }
1744
1744
  interface Response {
@@ -1777,7 +1777,7 @@ export declare namespace API {
1777
1777
  wallet_account_id: string;
1778
1778
  from_currency_id: string;
1779
1779
  note?: string;
1780
- is_subsctract?: boolean;
1780
+ is_subtract?: boolean;
1781
1781
  is_reverse?: boolean;
1782
1782
  }
1783
1783
  interface Response {
@@ -1816,7 +1816,7 @@ export declare namespace API {
1816
1816
  wallet_account_id: string;
1817
1817
  from_currency_id: string;
1818
1818
  note?: string;
1819
- is_subsctract?: boolean;
1819
+ is_subtract?: boolean;
1820
1820
  is_reverse?: boolean;
1821
1821
  }
1822
1822
  interface Response {
@@ -1854,7 +1854,7 @@ export declare namespace API {
1854
1854
  wallet_id: string;
1855
1855
  from_currency_id: string;
1856
1856
  to_currency_id: string;
1857
- is_subsctract?: boolean;
1857
+ is_subtract?: boolean;
1858
1858
  is_reverse?: boolean;
1859
1859
  }
1860
1860
  interface Response {
@@ -1,4 +1,8 @@
1
1
  import { API } from '../api/types/types';
2
+ type CalcData = API.Orders.V2.Calc.Response & {
3
+ is_subtract: boolean;
4
+ is_reverse: boolean;
5
+ };
2
6
  export type OrderCalcHandlerProps = Omit<API.Orders.V2.Calc.Request, 'order_type'>;
3
7
  export type UseOrderCalcProps = {
4
8
  from_currency_id: string | null | undefined;
@@ -8,7 +12,7 @@ export type UseOrderCalcProps = {
8
12
  to_address?: string;
9
13
  };
10
14
  export type UseOrderCalcData = {
11
- calcData: API.Orders.V2.Calc.Response | null;
15
+ calcData: CalcData | null;
12
16
  sellingAmount: number;
13
17
  setSellingAmount: (value: number) => void;
14
18
  buyingAmount: number;
@@ -18,3 +22,4 @@ export type UseOrderCalcData = {
18
22
  };
19
23
  export type UseOrderCalc = (props: UseOrderCalcProps) => UseOrderCalcData;
20
24
  export declare const useOrderCalc: UseOrderCalc;
25
+ export {};
@@ -36,7 +36,7 @@ const useOrderCalc = (props) => {
36
36
  abortControllerRef.current.abort();
37
37
  }
38
38
  };
39
- const updateCalculations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ is_reverse = false }) {
39
+ const updateCalculations = (_a) => __awaiter(void 0, [_a], void 0, function* ({ is_reverse, is_subtract }) {
40
40
  if (disableCalculation) {
41
41
  return;
42
42
  }
@@ -53,6 +53,7 @@ const useOrderCalc = (props) => {
53
53
  to_currency_id,
54
54
  amount: is_reverse ? buyingAmount : sellingAmount,
55
55
  is_reverse,
56
+ is_subtract,
56
57
  to_address,
57
58
  signal: abortControllerRef.current.signal,
58
59
  };
@@ -63,7 +64,8 @@ const useOrderCalc = (props) => {
63
64
  try {
64
65
  is_reverse ? setIsSellingValuePending(true) : setIsBuyingValuePending(true);
65
66
  const data = yield calcHandler(calcParams);
66
- setCalcData(data);
67
+ setCalcData(Object.assign(Object.assign({}, data), { is_reverse,
68
+ is_subtract }));
67
69
  setSellingAmount(data.from_amount);
68
70
  setBuyingAmount(data.result_amount);
69
71
  abortControllerRef.current = null;
@@ -84,20 +86,20 @@ const useOrderCalc = (props) => {
84
86
  });
85
87
  const onSellingValueUpdate = (0, lodash_debounce_1.default)((value) => {
86
88
  if (value !== (calcData === null || calcData === void 0 ? void 0 : calcData.from_amount) || isBuyingValuePending) {
87
- updateCalculations({ is_reverse: false });
89
+ updateCalculations({ is_reverse: false, is_subtract: true });
88
90
  }
89
91
  }, ((_a = abortControllerRef.current) === null || _a === void 0 ? void 0 : _a.signal) ? undefined : 1000);
90
92
  const onBuyingValueUpdate = (0, lodash_debounce_1.default)((value) => {
91
93
  if (value !== (calcData === null || calcData === void 0 ? void 0 : calcData.result_amount) || isSellingValuePending) {
92
- updateCalculations({ is_reverse: true });
94
+ updateCalculations({ is_reverse: true, is_subtract: false });
93
95
  }
94
96
  }, ((_b = abortControllerRef.current) === null || _b === void 0 ? void 0 : _b.signal) ? undefined : 1000);
95
97
  const onToAddressUpdate = (0, lodash_debounce_1.default)(() => {
96
- updateCalculations({ is_reverse: false });
98
+ updateCalculations({ is_reverse: false, is_subtract: true });
97
99
  }, ((_c = abortControllerRef.current) === null || _c === void 0 ? void 0 : _c.signal) ? undefined : 1000);
98
100
  (0, react_1.useEffect)(() => {
99
101
  abortCurrentCalculation();
100
- updateCalculations({ is_reverse: false });
102
+ updateCalculations({ is_reverse: false, is_subtract: true });
101
103
  }, [from_currency_id, to_currency_id]);
102
104
  (0, react_1.useEffect)(() => {
103
105
  abortCurrentCalculation();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.24.16",
3
+ "version": "1.24.17",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1509,7 +1509,7 @@ export namespace API {
1509
1509
  export namespace WITHDRAWAL_CRYPTO {
1510
1510
  export type Request = {
1511
1511
  amount: number;
1512
- is_subsctract: boolean;
1512
+ is_subtract: boolean;
1513
1513
  wallet_uuid: string;
1514
1514
  crypto_uuid: string;
1515
1515
  to_address: string;
@@ -1646,7 +1646,7 @@ export namespace API {
1646
1646
  // crypto_uuid: string;
1647
1647
  // fiat_uuid: string;
1648
1648
  // card_number: string;
1649
- // is_subsctract: boolean;
1649
+ // is_subtract: boolean;
1650
1650
  // }
1651
1651
  // export type Response = Item;
1652
1652
  // }
@@ -1676,7 +1676,7 @@ export namespace API {
1676
1676
  // wallet_uuid: string;
1677
1677
  // crypto_uuid: string;
1678
1678
  // card_id: string;
1679
- // is_subsctract: boolean;
1679
+ // is_subtract: boolean;
1680
1680
  // };
1681
1681
  // export interface Response {
1682
1682
  // id: number;
@@ -1702,7 +1702,7 @@ export namespace API {
1702
1702
  // wallet_uuid: string;
1703
1703
  // crypto_uuid: string;
1704
1704
  // fiat_account_id: string;
1705
- // is_subsctract: boolean;
1705
+ // is_subtract: boolean;
1706
1706
  // };
1707
1707
 
1708
1708
  // export interface Response {
@@ -1730,8 +1730,8 @@ export namespace API {
1730
1730
  from_currency_id: string;
1731
1731
  to_currency_id: string;
1732
1732
  amount: number;
1733
- is_reverse?: boolean;
1734
- is_subsctract?: boolean;
1733
+ is_reverse: boolean;
1734
+ is_subtract: boolean;
1735
1735
  signal?: AbortSignal;
1736
1736
  }
1737
1737
 
@@ -1778,7 +1778,7 @@ export namespace API {
1778
1778
  to_wallet_uuid: string;
1779
1779
  amount: number;
1780
1780
  request_id: string;
1781
- is_subsctract?: boolean;
1781
+ is_subtract?: boolean;
1782
1782
  is_reverse?: boolean;
1783
1783
  }
1784
1784
 
@@ -1793,7 +1793,7 @@ export namespace API {
1793
1793
  wallet_id: string;
1794
1794
  from_currency_id: string;
1795
1795
  to_currency_id: string;
1796
- is_subsctract?: boolean;
1796
+ is_subtract?: boolean;
1797
1797
  is_reverse?: boolean;
1798
1798
  }
1799
1799
 
@@ -1832,7 +1832,7 @@ export namespace API {
1832
1832
  wallet_id: string;
1833
1833
  from_currency_id: string;
1834
1834
  to_currency_id: string;
1835
- is_subsctract?: boolean;
1835
+ is_subtract?: boolean;
1836
1836
  is_reverse?: boolean;
1837
1837
  }
1838
1838
 
@@ -1871,7 +1871,7 @@ export namespace API {
1871
1871
  wallet_id: string;
1872
1872
  from_currency_id: string;
1873
1873
  to_currency_id: string;
1874
- is_subsctract?: boolean;
1874
+ is_subtract?: boolean;
1875
1875
  is_reverse?: boolean;
1876
1876
  }
1877
1877
 
@@ -1911,7 +1911,7 @@ export namespace API {
1911
1911
  to_currency_id: string;
1912
1912
  refference?: string;
1913
1913
  note?: string;
1914
- is_subsctract?: boolean;
1914
+ is_subtract?: boolean;
1915
1915
  is_reverse?: boolean;
1916
1916
  }
1917
1917
 
@@ -1951,7 +1951,7 @@ export namespace API {
1951
1951
  to_currency_id: string;
1952
1952
  refference?: string;
1953
1953
  note?: string;
1954
- is_subsctract?: boolean;
1954
+ is_subtract?: boolean;
1955
1955
  is_reverse?: boolean;
1956
1956
  }
1957
1957
 
@@ -1991,7 +1991,7 @@ export namespace API {
1991
1991
  to_currency_id: string;
1992
1992
  refference?: string;
1993
1993
  note?: string;
1994
- is_subsctract?: boolean;
1994
+ is_subtract?: boolean;
1995
1995
  is_reverse?: boolean;
1996
1996
  }
1997
1997
 
@@ -2028,7 +2028,7 @@ export namespace API {
2028
2028
  wallet_id: string;
2029
2029
  from_currency_id: string;
2030
2030
  to_currency_id: string;
2031
- is_subsctract?: boolean;
2031
+ is_subtract?: boolean;
2032
2032
  is_reverse?: boolean;
2033
2033
  }
2034
2034
 
@@ -2067,7 +2067,7 @@ export namespace API {
2067
2067
  wallet_account_id: string;
2068
2068
  from_currency_id: string;
2069
2069
  note?: string;
2070
- is_subsctract?: boolean;
2070
+ is_subtract?: boolean;
2071
2071
  is_reverse?: boolean;
2072
2072
  }
2073
2073
 
@@ -2107,7 +2107,7 @@ export namespace API {
2107
2107
  wallet_account_id: string;
2108
2108
  from_currency_id: string;
2109
2109
  note?: string;
2110
- is_subsctract?: boolean;
2110
+ is_subtract?: boolean;
2111
2111
  is_reverse?: boolean;
2112
2112
  }
2113
2113
 
@@ -2147,7 +2147,7 @@ export namespace API {
2147
2147
  wallet_account_id: string;
2148
2148
  from_currency_id: string;
2149
2149
  note?: string;
2150
- is_subsctract?: boolean;
2150
+ is_subtract?: boolean;
2151
2151
  is_reverse?: boolean;
2152
2152
  }
2153
2153
 
@@ -2186,7 +2186,7 @@ export namespace API {
2186
2186
  wallet_id: string;
2187
2187
  from_currency_id: string;
2188
2188
  to_currency_id: string;
2189
- is_subsctract?: boolean;
2189
+ is_subtract?: boolean;
2190
2190
  is_reverse?: boolean;
2191
2191
  }
2192
2192
 
@@ -2,8 +2,18 @@ import debounce from 'lodash.debounce';
2
2
  import { useEffect, useRef, useState } from 'react';
3
3
  import { API } from '../api/types/types';
4
4
 
5
+ type CalcData = API.Orders.V2.Calc.Response & {
6
+ is_subtract: boolean;
7
+ is_reverse: boolean;
8
+ };
9
+
5
10
  export type OrderCalcHandlerProps = Omit<API.Orders.V2.Calc.Request, 'order_type'>;
6
11
 
12
+ type UpdateCalculationsProps = {
13
+ is_reverse: boolean;
14
+ is_subtract: boolean;
15
+ };
16
+
7
17
  export type UseOrderCalcProps = {
8
18
  from_currency_id: string | null | undefined;
9
19
  to_currency_id: string | null | undefined;
@@ -13,7 +23,7 @@ export type UseOrderCalcProps = {
13
23
  };
14
24
 
15
25
  export type UseOrderCalcData = {
16
- calcData: API.Orders.V2.Calc.Response | null;
26
+ calcData: CalcData | null;
17
27
  sellingAmount: number;
18
28
  setSellingAmount: (value: number) => void;
19
29
  buyingAmount: number;
@@ -29,7 +39,7 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
29
39
 
30
40
  const [sellingAmount, setSellingAmount] = useState(0);
31
41
  const [buyingAmount, setBuyingAmount] = useState(0);
32
- const [calcData, setCalcData] = useState<API.Orders.V2.Calc.Response | null>(null);
42
+ const [calcData, setCalcData] = useState<CalcData | null>(null);
33
43
  const [isSellingValuePending, setIsSellingValuePending] = useState(false);
34
44
  const [isBuyingValuePending, setIsBuyingValuePending] = useState(false);
35
45
 
@@ -49,7 +59,7 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
49
59
  }
50
60
  };
51
61
 
52
- const updateCalculations = async ({ is_reverse = false }) => {
62
+ const updateCalculations = async ({ is_reverse, is_subtract }: UpdateCalculationsProps) => {
53
63
  if (disableCalculation) {
54
64
  return;
55
65
  }
@@ -70,6 +80,7 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
70
80
  to_currency_id,
71
81
  amount: is_reverse ? buyingAmount : sellingAmount,
72
82
  is_reverse,
83
+ is_subtract,
73
84
  to_address,
74
85
  signal: abortControllerRef.current.signal,
75
86
  };
@@ -82,7 +93,11 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
82
93
  try {
83
94
  is_reverse ? setIsSellingValuePending(true) : setIsBuyingValuePending(true);
84
95
  const data = await calcHandler(calcParams);
85
- setCalcData(data);
96
+ setCalcData({
97
+ ...data,
98
+ is_reverse,
99
+ is_subtract,
100
+ });
86
101
 
87
102
  setSellingAmount(data.from_amount);
88
103
 
@@ -109,7 +124,7 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
109
124
  const onSellingValueUpdate = debounce(
110
125
  (value: number) => {
111
126
  if (value !== calcData?.from_amount || isBuyingValuePending) {
112
- updateCalculations({ is_reverse: false });
127
+ updateCalculations({ is_reverse: false, is_subtract: true });
113
128
  }
114
129
  },
115
130
  abortControllerRef.current?.signal ? undefined : 1000
@@ -118,7 +133,7 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
118
133
  const onBuyingValueUpdate = debounce(
119
134
  (value: number) => {
120
135
  if (value !== calcData?.result_amount || isSellingValuePending) {
121
- updateCalculations({ is_reverse: true });
136
+ updateCalculations({ is_reverse: true, is_subtract: false });
122
137
  }
123
138
  },
124
139
  abortControllerRef.current?.signal ? undefined : 1000
@@ -126,14 +141,14 @@ export const useOrderCalc: UseOrderCalc = (props: UseOrderCalcProps) => {
126
141
 
127
142
  const onToAddressUpdate = debounce(
128
143
  () => {
129
- updateCalculations({ is_reverse: false });
144
+ updateCalculations({ is_reverse: false, is_subtract: true });
130
145
  },
131
146
  abortControllerRef.current?.signal ? undefined : 1000
132
147
  );
133
148
 
134
149
  useEffect(() => {
135
150
  abortCurrentCalculation();
136
- updateCalculations({ is_reverse: false });
151
+ updateCalculations({ is_reverse: false, is_subtract: true });
137
152
  }, [from_currency_id, to_currency_id]);
138
153
 
139
154
  useEffect(() => {