Skip to content

Commit be23d0a

Browse files
authored
Introduce basic contenthash support & improve tracing & README (#76)
1 parent 928b2d1 commit be23d0a

File tree

14 files changed

+445
-6
lines changed

14 files changed

+445
-6
lines changed

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,55 @@ cd worker && pnpm dev
108108
```
109109

110110
For more information on running the worker locally, please see [running Cloudflare Workers locally](#run-the-worker-locally).
111+
112+
## Features
113+
114+
Here is a short summary of the features provided by the Enstate API including limitations.
115+
116+
### Avatar & Header Images
117+
118+
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.
119+
120+
You can also directly access the avatar image of a user by using the `/i/{name}` and `/h/{name}` endpoints.
121+
122+
### Contenthash
123+
124+
Currently **limited implementation**. Only supports `ipfs`.
125+
TODO add support for `ipns`, `swarm`, `arweave`, `onion`, `onion3`, `skynet`
126+
127+
### Common Records
128+
129+
For each profile we look up the following records:
130+
You can customize the records you want to query by adjusting the `PROFILE_RECORDS` environment variable.
131+
Scoping down the size of this list can drastically improve the performance of your requests.
132+
133+
| Record Type | Description |
134+
| ----------------------------- | ----------------------- |
135+
| `description` | Description |
136+
| `url` | URL to the profile |
137+
| `name` | Name of the profile |
138+
| `mail` | Email address |
139+
| `email` | Email address |
140+
| `avatar` | URL to the avatar |
141+
| `header` | URL to the header image |
142+
| `display` | Display name |
143+
| `location` | Location |
144+
| `timezone` | Timezone |
145+
| `language` | Language |
146+
| `pronouns` | Pronouns |
147+
| `com.github` | GitHub username |
148+
| `org.matrix` | Matrix username |
149+
| `com.twitter` | Twitter username |
150+
| `com.discord` | Discord username |
151+
| `social.bsky` | Bsky username |
152+
| `io.keybase` | Keybase username |
153+
| `org.telegram` | Telegram username |
154+
| `social.mastodon` | Mastodon username |
155+
| `network.dm3.profile` | DM3 profile |
156+
| `network.dm3.deliveryService` | DM3 delivery service |
157+
158+
### Multichain Support
159+
160+
By default we query profiles for an vast array of chains.
161+
You can customize the chains you want to query by adjusting the `MULTICOIN_CHAINS` environment variable.
162+
Forcing it to only chains of interest can drastically improve the performance of your requests.

server/Cargo.lock

+82
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ rustls = "0.23"
6969
digest = "0.10.7"
7070
ciborium = "0.2.1"
7171
utoipa = "4.2.0"
72+
cid = "0.11.1"

server/src/models/profile.rs

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::collections::BTreeMap;
33
use enstate_shared::core::Profile;
44
use utoipa::ToSchema;
55

6+
pub struct CommonRecords(pub BTreeMap<String, String>);
67
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)]
78
pub struct ENSProfile {
89
// Name
@@ -17,7 +18,11 @@ pub struct ENSProfile {
1718
// Preferred Capitalization of Name
1819
#[schema(example = "LuC.eTh")]
1920
pub display: String,
21+
// Content Hash
22+
#[schema(example = "ipfs://bafybeidnycldkehcy6xixzqg72vad6pitav4lk5np3ev6tr6titlkvfpvi")]
23+
pub contenthash: Option<String>,
2024
// Records
25+
#[schema(example = "{\"world\":\"hello\"}")]
2126
pub records: BTreeMap<String, String>,
2227
// Addresses on different chains
2328
pub chains: BTreeMap<String, String>,
@@ -38,6 +43,7 @@ impl From<Profile> for ENSProfile {
3843
address: profile.address.map(|a| a.to_string()),
3944
avatar: profile.avatar,
4045
display: profile.display,
46+
contenthash: profile.contenthash,
4147
records: profile.records,
4248
chains: profile.chains,
4349
fresh: profile.fresh,

shared/Cargo.lock

+81
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ wasm-bindgen-futures = "0.4.36"
4646
wasm-bindgen = { version = "0.2.86", features = ["serde-serialize"] }
4747
web-sys = { version = "0.3.63", features = ["console"] }
4848
utoipa = "4.2.0"
49+
cid = "0.11.1"
4950

5051
[dev-dependencies]
5152
tokio = { version = "1", features = ["full"] }

shared/src/core/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ pub struct Profile {
3535
pub header: Option<String>,
3636
// Preferred Capitalization of Name
3737
pub display: String,
38+
// Content Hash
39+
#[serde(skip_serializing_if = "Option::is_none")]
40+
pub contenthash: Option<String>,
3841
// Records
3942
pub records: BTreeMap<String, String>,
4043
// Addresses on different chains

0 commit comments

Comments
 (0)