Skip to content

Commit

Permalink
Suggestions (#442)
Browse files Browse the repository at this point in the history
Co-authored-by: kwrobel.eth <[email protected]>
  • Loading branch information
lightwalker-eth and djstrong authored Oct 21, 2024
1 parent 471753f commit 57e7ea2
Show file tree
Hide file tree
Showing 13 changed files with 117 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- "packages/**"
- "!packages/nameguard-python/**"

concurrency: ${{ github.workflow }}-${{ github.ref }}

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/typescript-packages-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
- staging
paths:
- "packages/**"
- "!packages/nameguard-python/**"
pull_request:
branches:
- main
- staging
paths:
- "packages/**"
- "!packages/nameguard-python/**"

env:
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }}
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ The NameKit monorepo contains multiple packages and apps.
</picture>
</td>
<td>
<a href="api">nameguard</a>
<a href="packages/nameguard-python/">nameguard</a>
</td>
<td>Identify and prevent malicious use of ENS names.</td>
<td>
Expand Down Expand Up @@ -382,6 +382,21 @@ The NameKit monorepo contains multiple packages and apps.
<a href="https://nameguard.io">Preview</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!-- adding spaces to make GitHub stop breaking header for this column across multiple lines -->
</td>
</tr>
<tr>
<td>
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://img.shields.io/badge/lambda-444444?logo=awslambda&logoColor=white">
<img src="https://img.shields.io/badge/lambda-444444?logo=awslambda&logoColor=white" alt="AWS Lambda" width="auto" height="17">
</picture>
</td>
<td>
<a href="apps/api.nameguard.io/">api.nameguard.io</a>
</td>
<td>AWS Lambda deployment of the NameGuard API</td>
<td>
<a href="https://api.nameguard.io">Preview</a>
</td>
</tr>
<tr>
<td>
<picture>
Expand Down
78 changes: 7 additions & 71 deletions apps/api.nameguard.io/README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,24 @@
# NameGuard Python

![Tests](https://github.com/namehash/namekit/actions/workflows/ci_api.yml/badge.svg?branch=main)
![Coverage](coverage_badge.svg)
![Deploy](https://github.com/namehash/namekit/actions/workflows/nameguard-api-lambda-deploy.yml/badge.svg?branch=main)

This repository contains the NameGuard AWS Lambda deployment.
## Architecture Summary

## Getting Started
This app provides an AWS Lambda wrapper of the NameGuard Python library that is available on [PyPI](https://pypi.org/project/nameguard/).

### Using the public API
The NameGuard Python library contains an embedded webserver of its own.

NameGuard is hosted at <https://api.nameguard.io>
Please see details of how to configure environment variables, or making example requests in the [NameGuard Python library](/packages/nameguard-python/).

You can make a basic request to the API like this:
## Automated Deployments

```bash
curl https://api.nameguard.io/inspect-name/mainnet/nick.eth
```

The API documentation is available at <https://api.nameguard.io/redoc> or <https://api.nameguard.io/docs>.

### Running your own NameGuard instance

#### Env variables
The following environment variables should be set for the [automated deployment script](/.github/workflows/nameguard-api-lambda-deploy.yml) (in addition to the environment variables required by nameguard-python).

```bash
AWS_ROLE - AWS Role used by GitHub actions to create the CloudFormation infrastructure for deploying NameGuard as an AWS Lambda and pushing the latest build image to AWS ECR.
SLACK_WEBHOOK_URL - Slack webhook url used by GitHub actions to send notifications of deployment success or failure to the dev team's slack channel.
```
#### Installing the library
NameGuard is available as a Python library on [PyPI](https://pypi.org/project/nameguard/). You can install it with `pip`:
```bash
pip install nameguard
```
#### Setting Provider URIs
NameGuard uses the specified Provider endpoint (e.g. Alchemy, Infura, your own Ethereum node, etc...) for `secure-primary-name/`. Provider endpoints have to be set by environment variables, e.g.:
```bash
export PROVIDER_URI_MAINNET=https://eth-mainnet.g.alchemy.com/v2/[YOUR_ALCHEMY_API_KEY]
export PROVIDER_URI_SEPOLIA=https://eth-sepolia.g.alchemy.com/v2/[YOUR_ALCHEMY_API_KEY]
export ALCHEMY_URI_MAINNET=https://eth-mainnet.g.alchemy.com/v2/[YOUR_ALCHEMY_API_KEY]
export ALCHEMY_URI_SEPOLIA=https://eth-sepolia.g.alchemy.com/v2/[YOUR_ALCHEMY_API_KEY]
export ENS_SUBGRAPH_URL_MAINNET="https://gateway-arbitrum.network.thegraph.com/api/[YOUR_SUBGRAPH_API_KEY]/subgraphs/id/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH"
export ENS_SUBGRAPH_URL_SEPOLIA="https://gateway-arbitrum.network.thegraph.com/api/[YOUR_SUBGRAPH_API_KEY]/subgraphs/id/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV"
```
#### Starting the web server
A FastAPI application is included in the `nameguard.web_api` module. The default installation from PyPI does not include an ASGI server, so you will need to install one separately. For example, to install [uvicorn](https://www.uvicorn.org):
```bash
pip install 'uvicorn[standard]'
```
You can start the web server with:
```bash
uvicorn nameguard.web_api:app
```
Make an example request:
```bash
curl -d '{"name":"nick.eth", "network_name": "mainnet"}' -H "Content-Type: application/json" -X POST http://localhost:8000/inspect-name
# {
# "rating": "pass",
# "risk_count": 0,
# "highest_risk": null,
# "name": "nick.eth",
# "namehash": "0x05a67c0ee82964c4f7394cdd47fee7f4d9503a23c09c38341779ea012afe6e00",
# "normalization": "normalized",
# "checks": [...],
# "labels": [...],
# "canonical_name": "nick.eth",
# "title": "Looks Good",
# "subtitle": "All security checks passed!",
# "beautiful_name": "nick.eth"
# }
```
## License
Licensed under the MIT License, Copyright © 2023-present [NameHash Labs](https://namehashlabs.org).
Expand Down
4 changes: 2 additions & 2 deletions apps/api.nameguard.io/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/namehash/namekit.git",
"directory": "api"
"directory": "apps/api.nameguard.io"
},
"homepage": "https://github.com/namehash/namekit/tree/main/api",
"homepage": "https://github.com/namehash/namekit/tree/main/apps/api.nameguard.io",
"keywords": [
"ENS",
"NameKit",
Expand Down
4 changes: 2 additions & 2 deletions apps/docs.nameguard.io/self-hosting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ git clone https://github.com/namehash/namekit
Then install the dependencies using `poetry`:

```bash
cd nameguard
cd packages/nameguard-python
poetry install
```

You can now run the tests for all checks outlined in the [specification](/specification). From the root of the project, run the following command:

```bash
pytest ./api/tests/
pytest ./packages/nameguard-python/tests/
```
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const devElements: ListSectionElement[] = [
<GithubIconDevelopers />
</DeveloperSectionIconWrapper>
),
link: "https://github.com/namehash/namekit/tree/main/api",
link: "https://github.com/namehash/namekit/tree/main/packages/nameguard-python",
},
{
header: (
Expand Down Expand Up @@ -206,7 +206,7 @@ const devElements: ListSectionElement[] = [
<GearWheelIcon />
</DeveloperSectionIconWrapper>
),
link: "https://github.com/namehash/namekit/blob/main/api/serverless.yml",
link: "https://github.com/namehash/namekit/blob/main/apps/api.nameguard.io",
},
{
header: (
Expand Down
4 changes: 2 additions & 2 deletions apps/nameguard.io/src/components/organisms/RoadMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function RoadMap() {
Build{" "}
<a
className="text-black underline sm:underline-offset-[4px] sm:transition-all sm:duration-200 sm:hover:underline-offset-[2px]"
href="https://github.com/namehash/namekit/tree/main/api"
href="https://github.com/namehash/namekit/tree/main/packages/nameguard-python"
target="_blank"
rel="noopener noreferrer"
>
Expand Down Expand Up @@ -141,7 +141,7 @@ export function RoadMap() {
Made it easy for anyone to{" "}
<a
className="text-black underline sm:underline-offset-[4px] sm:transition-all sm:duration-200 sm:hover:underline-offset-[2px]"
href="https://github.com/namehash/namekit/blob/main/api/serverless.yml"
href="https://github.com/namehash/namekit/blob/main/apps/api.nameguard.io"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
109 changes: 0 additions & 109 deletions nameguard.md

This file was deleted.

Loading

0 comments on commit 57e7ea2

Please sign in to comment.