This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
forked from Uniswap/v2-subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
token balance_of endpoint implemented
- Loading branch information
1 parent
379f38b
commit 56e41e4
Showing
4 changed files
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require("dotenv").config(); | ||
var express = require("express"); | ||
var router = express.Router(); | ||
var erc20 = require("../JsClients/ERC20/test/installed.ts"); | ||
|
||
router | ||
.route("/balanceagainstuser") | ||
.post(async function (req, res, next) { | ||
try { | ||
|
||
if (!req.body.contractHash) { | ||
return res.status(400).json({ | ||
success: false, | ||
message: "contractHash not found in request body", | ||
}); | ||
} | ||
|
||
if (!req.body.user) { | ||
return res.status(400).json({ | ||
success: false, | ||
message: "user not found in request body", | ||
}); | ||
} | ||
|
||
let balance = await erc20.balanceOf(req.body.contractHash,req.body.user); | ||
return res.status(200).json({ | ||
success: true, | ||
message: | ||
"Balance has been found against this user against passed token ", | ||
balance:balance, | ||
}); | ||
} catch (error) { | ||
console.log("error (try-catch) : " + error); | ||
return res.status(500).json({ | ||
success: false, | ||
err: error, | ||
}); | ||
} | ||
}); | ||
|
||
module.exports = router; |