Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce basic contenthash support & improve tracing & README #76

Merged
merged 7 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,55 @@ cd worker && pnpm dev
```

For more information on running the worker locally, please see [running Cloudflare Workers locally](#run-the-worker-locally).

## Features

Here is a short summary of the features provided by the Enstate API including limitations.

### Avatar & Header Images

An additional `avatar` field at the top level of the ENSProfile object is provided. This field is a URL to the avatar image, with optional gateway rewrites for IPFS and IPNS hashes.

You can also directly access the avatar image of a user by using the `/i/{name}` and `/h/{name}` endpoints.

### Contenthash

Currently **limited implementation**. Only supports `ipfs`.
TODO add support for `ipns`, `swarm`, `arweave`, `onion`, `onion3`, `skynet`

### Common Records

For each profile we look up the following records:
You can customize the records you want to query by adjusting the `PROFILE_RECORDS` environment variable.
Scoping down the size of this list can drastically improve the performance of your requests.

| Record Type | Description |
| ----------------------------- | ----------------------- |
| `description` | Description |
| `url` | URL to the profile |
| `name` | Name of the profile |
| `mail` | Email address |
| `email` | Email address |
| `avatar` | URL to the avatar |
| `header` | URL to the header image |
| `display` | Display name |
| `location` | Location |
| `timezone` | Timezone |
| `language` | Language |
| `pronouns` | Pronouns |
| `com.github` | GitHub username |
| `org.matrix` | Matrix username |
| `com.twitter` | Twitter username |
| `com.discord` | Discord username |
| `social.bsky` | Bsky username |
| `io.keybase` | Keybase username |
| `org.telegram` | Telegram username |
| `social.mastodon` | Mastodon username |
| `network.dm3.profile` | DM3 profile |
| `network.dm3.deliveryService` | DM3 delivery service |

### Multichain Support

By default we query profiles for an vast array of chains.
You can customize the chains you want to query by adjusting the `MULTICOIN_CHAINS` environment variable.
Forcing it to only chains of interest can drastically improve the performance of your requests.
82 changes: 82 additions & 0 deletions server/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ rustls = "0.23"
digest = "0.10.7"
ciborium = "0.2.1"
utoipa = "4.2.0"
cid = "0.11.1"
6 changes: 6 additions & 0 deletions server/src/models/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::BTreeMap;
use enstate_shared::core::Profile;
use utoipa::ToSchema;

pub struct CommonRecords(pub BTreeMap<String, String>);
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct ENSProfile {
// Name
Expand All @@ -17,7 +18,11 @@ pub struct ENSProfile {
// Preferred Capitalization of Name
#[schema(example = "LuC.eTh")]
pub display: String,
// Content Hash
#[schema(example = "ipfs://bafybeidnycldkehcy6xixzqg72vad6pitav4lk5np3ev6tr6titlkvfpvi")]
pub contenthash: Option<String>,
// Records
#[schema(example = "{\"world\":\"hello\"}")]
pub records: BTreeMap<String, String>,
// Addresses on different chains
pub chains: BTreeMap<String, String>,
Expand All @@ -38,6 +43,7 @@ impl From<Profile> for ENSProfile {
address: profile.address.map(|a| a.to_string()),
avatar: profile.avatar,
display: profile.display,
contenthash: profile.contenthash,
records: profile.records,
chains: profile.chains,
fresh: profile.fresh,
Expand Down
81 changes: 81 additions & 0 deletions shared/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ wasm-bindgen-futures = "0.4.36"
wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] }
web-sys = { version = "0.3.63", features = ["console"] }
utoipa = "4.2.0"
cid = "0.11.1"

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
Expand Down
3 changes: 3 additions & 0 deletions shared/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ pub struct Profile {
pub header: Option<String>,
// Preferred Capitalization of Name
pub display: String,
// Content Hash
#[serde(skip_serializing_if = "Option::is_none")]
pub contenthash: Option<String>,
// Records
pub records: BTreeMap<String, String>,
// Addresses on different chains
Expand Down
Loading
Loading