Skip to content

Commit

Permalink
Merge pull request #5 from decentldotland/dev
Browse files Browse the repository at this point in the history
feat: v0.0.4
  • Loading branch information
charmful0x authored Jul 8, 2023
2 parents 4dca5ce + 1748b12 commit 051cbb7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 23 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
2 changes: 1 addition & 1 deletion src/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const ANS_CONTRACT_ADDRESS = `VGWeJLDLJ9ify3ezl9tW-9fhB0G-GIUd60FE-5Q-_VI`;
export const ANS_CONTRACT_ADDRESS = `EcSNZ9aaZkK7OngLqunLvDPp0CNc2JBVqwBRrFewZnU`;

0 comments on commit 051cbb7

Please sign in to comment.