-
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.
feat: [sc-25514] split NameGuard code into separate package / app (#414)
* move nameguard to packages * update workflows * update pnpm lock * fix path * fix path * update pnpm lock * update * increase Lambda timeout * increase timeout * fix image paths for pypi * rename workflow files * Apply updated file name to docs --------- Co-authored-by: djstrong <[email protected]> Co-authored-by: lightwalker.eth <[email protected]>
- Loading branch information
1 parent
9f15fdf
commit 17458b4
Showing
140 changed files
with
185 additions
and
79 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 |
---|---|---|
|
@@ -4,13 +4,13 @@ on: | |
branches: | ||
- main | ||
paths: | ||
- "api/**" | ||
- "packages/nameguard-python/**" | ||
pull_request: | ||
branches: | ||
- main | ||
- staging | ||
paths: | ||
- "api/**" | ||
- "packages/nameguard-python/**" | ||
|
||
env: | ||
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }} | ||
|
@@ -42,15 +42,15 @@ jobs: | |
cache: "poetry" | ||
|
||
- name: Install dependencies | ||
working-directory: ./api | ||
working-directory: ./packages/nameguard-python | ||
run: poetry install | ||
|
||
- name: Run tests mocked | ||
working-directory: ./api | ||
working-directory: ./packages/nameguard-python | ||
run: poetry run pytest -vv --durations=0 | ||
|
||
- name: Run tests | ||
working-directory: ./api | ||
working-directory: ./packages/nameguard-python | ||
run: MONKEYPATCH=0 poetry run pytest -vv --durations=0 | ||
|
||
add_badge: | ||
|
@@ -78,15 +78,15 @@ jobs: | |
cache: "poetry" | ||
|
||
- name: Install dependencies | ||
working-directory: ./api | ||
working-directory: ./packages/nameguard-python | ||
run: poetry install | ||
|
||
- name: Run tests mocked | ||
working-directory: ./api | ||
working-directory: ./packages/nameguard-python | ||
run: poetry run pytest -vv --durations=0 --cov-report term-missing --cov=./ | ||
|
||
- name: Generate coverage badge | ||
working-directory: ./api | ||
working-directory: ./packages/nameguard-python | ||
run: poetry run coverage-badge -fo coverage_badge.svg | ||
|
||
- name: Commit changes | ||
|
@@ -95,4 +95,4 @@ jobs: | |
author_name: github-actions | ||
author_email: [email protected] | ||
message: "Update coverage badge" | ||
add: "api/coverage_badge.svg" | ||
add: "packages/nameguard-python/coverage_badge.svg" |
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
File renamed without changes.
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,90 @@ | ||
# NameGuard Python | ||
|
||
![Tests](https://github.com/namehash/namekit/actions/workflows/ci_api.yml/badge.svg?branch=main) | ||
![Coverage](coverage_badge.svg) | ||
|
||
This repository contains the NameGuard AWS Lambda deployment. | ||
|
||
## Getting Started | ||
|
||
### Using the public API | ||
|
||
NameGuard is hosted at <https://api.nameguard.io> | ||
|
||
You can make a basic request to the API like this: | ||
|
||
```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 | ||
|
||
```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). | ||
See [LICENSE](./LICENSE) for more information. |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 NameHash | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.