squarefi-bff-api-module 1.36.26 → 1.36.27

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.
@@ -1,13 +1,32 @@
1
- import { API } from '../api/types/types';
2
- type CalcData = API.Orders.V2.Calc.Response & {
1
+ type CalcResult = {
2
+ from_currency: string;
3
+ to_currency: string;
4
+ from_amount: number;
5
+ result_amount: number;
6
+ rate: number;
7
+ fees: number;
8
+ comission: number;
9
+ network_fee: number;
10
+ transaction_fee: number;
11
+ from_symbol: string;
12
+ };
13
+ type CalcData = CalcResult & {
3
14
  is_subtract: boolean;
4
15
  is_reverse: boolean;
5
16
  };
6
- export type OrderCalcHandlerProps = Omit<API.Orders.V2.Calc.Request, 'order_type'>;
17
+ export type OrderCalcHandlerProps = {
18
+ from_currency_id: string;
19
+ to_currency_id: string;
20
+ amount: number;
21
+ is_reverse: boolean;
22
+ is_subtract: boolean;
23
+ to_address?: string;
24
+ signal?: AbortSignal;
25
+ };
7
26
  export type UseOrderCalcProps = {
8
27
  from_currency_id: string | null | undefined;
9
28
  to_currency_id: string | null | undefined;
10
- calcHandler: (props: OrderCalcHandlerProps) => Promise<API.Orders.V2.Calc.Response>;
29
+ calcHandler: (props: OrderCalcHandlerProps) => Promise<CalcResult>;
11
30
  disableCalculation?: boolean;
12
31
  to_address?: string;
13
32
  };
@@ -1,7 +1,6 @@
1
1
  import debounce from 'lodash.debounce';
2
2
  import { useEffect, useRef, useState } from 'react';
3
- export const useOrderCalc = (props) => {
4
- const { from_currency_id, to_currency_id, calcHandler, disableCalculation, to_address } = props;
3
+ export const useOrderCalc = ({ from_currency_id, to_currency_id, calcHandler, disableCalculation, to_address, }) => {
5
4
  const [sellingAmount, setSellingAmount] = useState(0);
6
5
  const [buyingAmount, setBuyingAmount] = useState(0);
7
6
  const [calcData, setCalcData] = useState(null);
@@ -49,7 +48,16 @@ export const useOrderCalc = (props) => {
49
48
  is_reverse ? setIsSellingValuePending(true) : setIsBuyingValuePending(true);
50
49
  const data = await calcHandler(calcParams);
51
50
  setCalcData({
52
- ...data,
51
+ from_currency: data.from_currency,
52
+ to_currency: data.to_currency,
53
+ from_amount: data.from_amount,
54
+ result_amount: data.result_amount,
55
+ rate: data.rate,
56
+ fees: data.fees,
57
+ comission: data.comission,
58
+ network_fee: data.network_fee,
59
+ transaction_fee: data.transaction_fee,
60
+ from_symbol: data.from_symbol,
53
61
  is_reverse,
54
62
  is_subtract,
55
63
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.36.26",
3
+ "version": "1.36.27",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",