@@ -10,7 +10,7 @@ import { Token } from "../types";
1010import { useGetHasAllowance , useNetwork } from "./hooks" ;
1111import { ordersStore } from "../store" ;
1212import { useSrcAmount } from "./lib" ;
13- import { Order , OrderStatus } from "@orbs-network/twap-sdk" ;
13+ import { Order , OrderStatus , getAllOrders , getOrderById } from "@orbs-network/twap-sdk" ;
1414import { amountBNV2 } from "../utils" ;
1515
1616export const useMinNativeTokenBalance = ( minNativeTokenBalance ?: string ) => {
@@ -152,6 +152,23 @@ const useOrderHistoryKey = () => {
152152 return [ QueryKeys . GET_ORDER_HISTORY , account , config . exchangeAddress , config . chainId ] ;
153153} ;
154154
155+ export const useOrderQuery = ( orderId ?: number ) => {
156+ const chainId = useTwapContext ( ) . config . chainId ;
157+ return useQuery (
158+ [ "useOrderQuery" , chainId , chainId ] ,
159+ async ( { signal } ) => {
160+ if ( ! orderId ) return null ;
161+ const result = await getOrderById ( { orderId : 79202 , chainId : 56 , signal } ) ;
162+ console . log ( { result } ) ;
163+
164+ return result ;
165+ } ,
166+ {
167+ enabled : ! ! orderId && ! ! chainId ,
168+ } ,
169+ ) ;
170+ } ;
171+
155172const useUpdateOrderStatusToCanceled = ( ) => {
156173 const QUERY_KEY = useOrderHistoryKey ( ) ;
157174 const queryClient = useQueryClient ( ) ;
@@ -171,13 +188,14 @@ const useUpdateOrderStatusToCanceled = () => {
171188} ;
172189
173190export const useAllOrders = ( ) => {
174- const { state , config, account , twapSDK } = useTwapContext ( ) ;
191+ const { config } = useTwapContext ( ) ;
175192 return useInfiniteQuery (
176193 [ "all orders" , config . chainId ] ,
177194 async ( { signal, pageParam = 0 } ) => {
178195 let result : Order [ ] = [ ] ;
179196 try {
180- result = await twapSDK . getAllOrders ( { signal, page : pageParam , limit : 5 } ) ;
197+ result = await getAllOrders ( { signal, page : pageParam , limit : 5 , chainId : config . chainId } ) ;
198+ console . log ( { result } ) ;
181199 } catch ( error ) {
182200 console . log ( { error } ) ;
183201 }
0 commit comments