Skip to content

Commit d55072a

Browse files
committed
Improve ENS Unigraph examples
1 parent af01c75 commit d55072a

6 files changed

Lines changed: 46 additions & 8 deletions

File tree

docs/ensnode.io/src/content/docs/docs/integrate/unigraph/examples/domain-events.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { exampleDomainEvents } from "@data/unigraph-examples/domain-events";
1414
Performing SQL queries on the ENS Unigraph requires that you have the `unigraph` plugin activated in your ENSNode instance. [Learn more](/docs/services/ensindexer/usage/configuration)
1515
:::
1616

17-
Fetch recent events for a Domain by its canonical name. This example joins the `events`, `domain_events`, and `domains` tables to retrieve domain events associated with the `vitalik.eth` name. See [Connect](/docs/integrate/unigraph/examples) for setup.
17+
Fetch recent events for a Domain by its canonical name. This example joins the `events`, `domain_events`, and `domains` tables to retrieve domain events associated with the `wrapnation.eth` name. See [Connect](/docs/integrate/unigraph/examples) for setup.
1818

1919
:::note[Canonical fields]
2020
Canonical fields are populated on every Domain reachable from the canonical root, across both ENSv1 and ENSv2 — query them uniformly without branching by `type`. In SQL, these columns are `canonical_name`, `canonical_path`, `canonical_node`, and `canonical_depth`; in `ensdb-sdk`, the corresponding fields are `canonicalName`, `canonicalPath`, `canonicalNode`, and `canonicalDepth`.

docs/ensnode.io/src/data/unigraph-examples/account-domains.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const exampleAccountDomains = {
1919
FROM "ensindexer_0".domains d
2020
WHERE d.canonical = true
2121
AND d.owner_id = '0xffffffffff52d316b7bd028358089bc8066b8f80'
22-
ORDER BY d.canonical_name
22+
ORDER BY d.__canonical_name_prefix ASC
2323
LIMIT 10;`,
2424
result: [
2525
{
@@ -119,7 +119,7 @@ const accountDomains = await ensDb
119119
eq(ensIndexerSchema.domain.canonical, true),
120120
),
121121
)
122-
.orderBy(asc(ensIndexerSchema.domain.canonicalName))
122+
.orderBy(asc(ensIndexerSchema.domain.__canonicalNamePrefix))
123123
.limit(limit);
124124
125125
console.log(accountDomains);`,

docs/ensnode.io/src/data/unigraph-examples/domains-fuzzy-search-by-name.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const exampleDomainsFuzzySearchByName = {
1616
similarity(canonical_name, 'reverse') as name_similarity,
1717
id
1818
FROM "ensindexer_0".domains
19-
WHERE __canonicalNamePrefix % 'reverse'
19+
WHERE __canonical_name_prefix % 'reverse'
2020
AND canonical = true
2121
ORDER BY name_similarity DESC
2222
LIMIT 5;
@@ -52,7 +52,7 @@ LIMIT 5;
5252
sdk: {
5353
codeSnippet: `import { and, eq, sql } from "drizzle-orm";
5454
55-
const q = "vitalik";
55+
const q = "reverse";
5656
const limit = 5;
5757
5858
const domains = await ensDb

docs/ensnode.io/src/data/unigraph-examples/subdomains-by-parent-name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ SELECT
2222
FROM "ensindexer_0".domains d
2323
JOIN parent p ON d.registry_id = p.subregistry_id
2424
WHERE d.canonical = true
25-
ORDER BY d.canonical_name
25+
ORDER BY d.__canonical_name_prefix ASC
2626
LIMIT 5;
2727
`,
2828
result: [
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
export const outputSource = (source: "V2 Sepolia" | "Alpha" | "Alpha Sepolia") =>
2-
`Output matches a point in time snapshot of ENSDb result from our "${source}" <a href="/docs/hosted-instances">Hosted ENSNode instance</a>. Live output depends on the configuration of your ENSNode instance and also changes that may have happened in ENS since this point in time snapshot example response was captured.`;
1+
export const EnsNodeInstances = {
2+
V2Sepolia: "V2 Sepolia",
3+
Alpha: "Alpha",
4+
AlphaSepolia: "Alpha Sepolia",
5+
Mainnet: "Mainnet",
6+
Sepolia: "Sepolia",
7+
} as const;
8+
9+
export type EnsNodeInstance = (typeof EnsNodeInstances)[keyof typeof EnsNodeInstances];
10+
11+
export const outputSource = (ensNodeInstance: EnsNodeInstance) =>
12+
`Output matches a point in time snapshot of ENSDb result from our <a href="${ensNodeInstanceDocUrl(ensNodeInstance)}">${ensNodeInstance} Hosted ENSNode instance</a>. Live output depends on the configuration of your ENSNode instance and also changes that may have happened in ENS since this point in time snapshot example response was captured.`;
13+
14+
const ensNodeInstanceDocUrl = (instance: EnsNodeInstance) => {
15+
const hostedInstancesPath = "/docs/hosted-instances#ensnode-";
16+
17+
switch (instance) {
18+
case EnsNodeInstances.V2Sepolia:
19+
return `${hostedInstancesPath}v2-sepolia`;
20+
case EnsNodeInstances.Alpha:
21+
return `${hostedInstancesPath}alpha`;
22+
case EnsNodeInstances.AlphaSepolia:
23+
return `${hostedInstancesPath}alpha-sepolia`;
24+
case EnsNodeInstances.Mainnet:
25+
return `${hostedInstancesPath}mainnet`;
26+
case EnsNodeInstances.Sepolia:
27+
return `${hostedInstancesPath}sepolia`;
28+
}
29+
};

docs/ensnode.io/src/styles/starlight.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,3 +928,14 @@ starlight-tabs ul[role="tablist"] {
928928
padding: 0.125rem 0.375rem;
929929
font-size: var(--sl-text-code-sm);
930930
}
931+
932+
.static-example p a {
933+
color: var(--sl-color-text-accent);
934+
text-decoration: underline;
935+
text-underline-offset: 4px;
936+
transition: text-underline-offset 0.2s ease-in-out;
937+
938+
&:hover {
939+
text-underline-offset: 2px;
940+
}
941+
}

0 commit comments

Comments
 (0)