From f42ffb6addc7a1cbc42a1c6acebbd0f9d03912d3 Mon Sep 17 00:00:00 2001 From: Hammad-Mubeen Date: Thu, 14 Apr 2022 20:39:49 +0500 Subject: [PATCH] liquidityagainstuserandpair endpoint updated and tested --- routes/pairroutes.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/routes/pairroutes.js b/routes/pairroutes.js index 62b7d3d2..8a79c78a 100644 --- a/routes/pairroutes.js +++ b/routes/pairroutes.js @@ -3,6 +3,7 @@ var express = require("express"); const { createFalse } = require("typescript"); var router = express.Router(); var pair = require("../JsClients/PAIR/test/installed.ts"); +var AllcontractsData = require("../models/allcontractsData"); router .route("/liquidityagainstuserandpair") @@ -21,8 +22,16 @@ router message: "pairid not found in request body", }); } - - let liquidity = await pair.balanceOf(req.body.pairid, req.body.to); + let data = await AllcontractsData.findOne({ + packageHash: req.body.pairid, + }); + if (data == null) { + return res.status(400).json({ + success: false, + message: "pair not found against this package hash ", + }); + } + let liquidity = await pair.balanceOf(data.contractHash, req.body.to); return res.status(200).json({ success: true, message: