Fetch order details for an user based on orderId and userOrderId
Orders are instructions which decide how trades should execute on a decentralized trading platform. The following snippet illustrates how we can query order data related to particular user account, based on a particular order Id.
You can directly copy paste this code on replit and see it in action.
Fetch orders associated to a user account based orderId and userOrderId
In the above case, we first get the particular userAccount based on Authority (user wallet), and then filter the order field to get the order of a particular orderId. Alternatively, we can also fetch orders based on userOrderId, just by filter the order using the userOrderId field, instead of the orderId field.
constmatchedOrder=currentUserDetails.orders.find( (order) =>order.userorderId == orderId ); //userOrderId to be taken as input from the user