From e848355336e45df05ea9d019afffad09e0291938 Mon Sep 17 00:00:00 2001 From: Darwin <77340894+charmful0x@users.noreply.github.com> Date: Tue, 7 Mar 2023 16:36:50 +0100 Subject: [PATCH 1/4] feat: update contract address --- src/utils/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/constants.js b/src/utils/constants.js index dbbaabb..5e9c1e4 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -1 +1 @@ -export const ANS_CONTRACT_ADDRESS = `VGWeJLDLJ9ify3ezl9tW-9fhB0G-GIUd60FE-5Q-_VI`; +export const ANS_CONTRACT_ADDRESS = `EcSNZ9aaZkK7OngLqunLvDPp0CNc2JBVqwBRrFewZnU`; From 3c8868ae33c4d7218556821b407f2c162e7dfc15 Mon Sep 17 00:00:00 2001 From: Darwin Date: Sat, 8 Jul 2023 17:33:52 +0200 Subject: [PATCH 2/4] feat: `/find-user` endpoint --- src/api.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/api.js b/src/api.js index 0a4b8e9..73b50eb 100644 --- a/src/api.js +++ b/src/api.js @@ -133,6 +133,29 @@ app.get("/resolve-as-arpage/:query", async (req, res) => { } }); +app.get("/find-user/:domain", async (req, res) => { + try { + res.setHeader("Content-Type", "application/json"); + const { domain } = req.params; + const balances = await readContract(); + + const normalizedDomain = normalizeDomain(domain); + const user = balances.find( + (usr) => usr.ownedDomains.map((ans) => ans["domain"]).includes(domain) + ); + + res.send(user); + return; + } catch (error) { + console.log(error); + res.send({ + error: + "invalid query paramater. Provide a valid ANS domain", + }); + return; + } +}); + app.listen(port, async () => { console.log(`listening at PORT: ${port}`); }); From f7cdbae8ab0d89d873c5f3835a18aeb9bead5eae Mon Sep 17 00:00:00 2001 From: Darwin Date: Sat, 8 Jul 2023 17:34:31 +0200 Subject: [PATCH 3/4] docs: `/find-user` endpoint --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index bac8522..2ee2731 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,9 @@ - `parent_domain` : a valid ANS domain that issued subdomains. - `query` : a valid Arweave address or ANS subdomain (target). +### 3- `/find-user/:domain` + +- `domain` : a valid ANS domain (primary or owned) ## License This project is licensed under the [MIT License](./LICENSE) From 1748b1274507e61998b28c4604a0d25e30f409e1 Mon Sep 17 00:00:00 2001 From: Darwin Date: Sat, 8 Jul 2023 17:36:51 +0200 Subject: [PATCH 4/4] feat: v0.0.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 55f7ffa..b32f586 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ans-resolver", - "version": "0.0.3", + "version": "0.0.4", "description": "HTTP resolver for ANS domains", "main": "./src/api.js", "type": "module",