-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathensnode-info.tsx
More file actions
629 lines (589 loc) · 22.1 KB
/
ensnode-info.tsx
File metadata and controls
629 lines (589 loc) · 22.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
/**
* This file describes UI components presenting information about
* ENSNode's public configuration.
*/
"use client";
import { ChainIcon, getChainName } from "@namehash/namehash-ui";
import { History, Replace } from "lucide-react";
import { Fragment, ReactNode } from "react";
import { useENSNodeConfig } from "@ensnode/ensnode-react";
import { type ENSApiPublicConfig, getENSRootChainId } from "@ensnode/ensnode-sdk";
import { ErrorInfo, type ErrorInfoProps } from "@/components/error-info";
import { ENSApiIcon } from "@/components/icons/ensnode-apps/ensapi-icon";
import { ENSDbIcon } from "@/components/icons/ensnode-apps/ensdb-icon";
import { ENSIndexerIcon } from "@/components/icons/ensnode-apps/ensindexer-icon";
import { ENSNodeIcon } from "@/components/icons/ensnode-apps/ensnode-icon";
import { ENSRainbowIcon } from "@/components/icons/ensnode-apps/ensrainbow-icon";
import { IconGraphNetwork } from "@/components/icons/graph-network";
import { HealIcon } from "@/components/icons/HealIcon";
import { IndexAdditionalRecordsIcon } from "@/components/icons/IndexAdditionalRecordsIcon";
import { ExternalLinkWithIcon } from "@/components/link";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
import {
InfoCard,
InfoCardConnector,
InfoCardFeature,
InfoCardFeatures,
InfoCardItem,
InfoCardItems,
} from "../shared/info-card";
/**
* Reusable ENSNode card wrapper that provides consistent header and accepts children content
*/
export interface ENSNodeCardProps {
children: ReactNode;
}
export function ENSNodeCard({ children }: ENSNodeCardProps) {
const cardContentStyles = "flex flex-col gap-4 max-sm:p-3";
return (
<Card className="w-full">
<CardHeader>
<CardTitle className="flex items-center gap-2 text-xl">
<ENSNodeIcon width={28} height={28} />
<span>ENSNode</span>
</CardTitle>
</CardHeader>
<CardContent className={cn(cardContentStyles, "max-sm:pt-0")}>{children}</CardContent>
</Card>
);
}
/**
* Loading skeleton content for ENSNodeCard
*/
function ENSNodeCardLoadingSkeleton() {
const cardContentStyles = "flex flex-col gap-4 max-sm:p-3";
return (
<div className={cn(cardContentStyles, "max-sm:gap-3 max-sm:p-0 gap-0")}>
{["ENSApi", "ENSDb", "ENSIndexer", "ENSRainbow"].map((app, index) => (
<Fragment key={`${app}-loading`}>
{index !== 0 && <InfoCardConnector />}
<Card className="animate-pulse">
<CardHeader className="max-sm:p-3">
<div className="h-6 bg-muted rounded-sm w-1/3" />
</CardHeader>
<CardContent className="space-y-3 max-sm:p-3 max-sm:pt-0">
<div className="space-y-2">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-4 w-32" />
</div>
<div className="space-y-2">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-4 w-32" />
</div>
</CardContent>
</Card>
</Fragment>
))}
</div>
);
}
/**
* Props for ENSNodeConfigCardDisplay - display component that accepts props for testing/mocking
*/
export interface ENSNodeConfigCardDisplayProps {
ensApiPublicConfig: ENSApiPublicConfig;
}
/**
* Display component that receives props - used for reusable/mockable presentation
*/
export function ENSNodeConfigCardDisplay({ ensApiPublicConfig }: ENSNodeConfigCardDisplayProps) {
return (
<ENSNodeCard>
<ENSNodeConfigCardContent ensApiPublicConfig={ensApiPublicConfig} />
</ENSNodeCard>
);
}
/**
* Props for ENSNodeConfigInfoView - internal component that accepts props for testing/mocking
*/
export interface ENSNodeConfigInfoViewProps {
ensApiPublicConfig?: ENSApiPublicConfig;
error?: ErrorInfoProps;
isLoading?: boolean;
}
/**
* Internal view component that accepts props - used by both the main component and mock pages
*/
export function ENSNodeConfigInfoView({
ensApiPublicConfig,
error,
isLoading = false,
}: ENSNodeConfigInfoViewProps) {
if (error) {
return <ErrorInfo title={error.title} description={error.description} />;
}
// Show ENSNode card - shell with skeleton while loading, or content when ready
if (isLoading || !ensApiPublicConfig) {
return (
<ENSNodeCard>
<ENSNodeCardLoadingSkeleton />
</ENSNodeCard>
);
}
return <ENSNodeConfigCardDisplay ensApiPublicConfig={ensApiPublicConfig} />;
}
/**
* ENSNodeConfigInfo component - fetches and displays ENSNode configuration data
*/
export function ENSNodeConfigInfo() {
const ensNodeConfigQuery = useENSNodeConfig();
return (
<ENSNodeConfigInfoView
ensApiPublicConfig={ensNodeConfigQuery.isSuccess ? ensNodeConfigQuery.data : undefined}
error={
ensNodeConfigQuery.isError
? {
title: "ENSNodeConfigInfo Error",
description: ensNodeConfigQuery.error.message,
}
: undefined
}
isLoading={ensNodeConfigQuery.isPending}
/>
);
}
function ENSNodeConfigCardContent({
ensApiPublicConfig,
}: {
ensApiPublicConfig: ENSApiPublicConfig;
}) {
const cardItemValueStyles = "text-sm leading-6 font-normal text-black";
const { ensIndexerPublicConfig } = ensApiPublicConfig;
const healReverseAddressesActivated = !ensIndexerPublicConfig.isSubgraphCompatible;
const indexAdditionalRecordsActivated = !ensIndexerPublicConfig.isSubgraphCompatible;
const replaceUnnormalizedLabelsActivated = !ensIndexerPublicConfig.isSubgraphCompatible;
const subgraphCompatibilityActivated = ensIndexerPublicConfig.isSubgraphCompatible;
const healReverseAddressesDescription = healReverseAddressesActivated ? (
<p>Subnames of addr.reverse will all be known (healed) labels.</p>
) : (
<p>Subnames of addr.reverse will generally be unknown labels.</p>
);
const indexAdditionalRecordsDescription = indexAdditionalRecordsActivated ? (
<p>
The keys and values of all onchain resolver records will be indexed across all indexed chains.
</p>
) : (
<p>
Only the keys (generally none of the values) of onchain resolver records will be indexed
across all indexed chains.
</p>
);
const replaceUnnormalizedLabelsDescription = replaceUnnormalizedLabelsActivated ? (
<p>
All labels and names that ENSIndexer stores in ENSDb will meet the strong guarantees of
"Interpreted Labels" and "Interpreted Names". Therefore apps integrating with this ENSNode
don't need to worry about receiving unnormalized labels from ENSNode that are not encoded
labelhashes.{" "}
<ExternalLinkWithIcon href="https://ensnode.io/docs/reference/terminology#interpreted-label">
Learn more.
</ExternalLinkWithIcon>
</p>
) : (
<p>
All labels and names that ENSIndexer stores in ENSDb will meet the loose guarantees of
"Subgraph Interpreted Labels" and "Subgraph Interpreted Names". Therefore apps integrating
with this ENSNode need to worry about receiving unnormalized labels and names from ENSNode.
</p>
);
const subgraphCompatibilityDescription = subgraphCompatibilityActivated ? (
<p>
ENSIndexer is operating in a subgraph-compatible way. It will use subgraph-compatible IDs for
entities and events and limit indexing behavior to subgraph indexing semantics.
</p>
) : (
<p>
ENSIndexer has activated feature enhancements and/or plugins that provide key benefits but are
not fully backwards compatible with the ENS Subgraph.
</p>
);
const healReverseAddressesFeature = (
<InfoCardFeature
label="Heal Reverse Addresses"
key="ENSIndexer Heal Reverse Addresses feature"
description={healReverseAddressesDescription}
icon={<HealIcon width={15} height={15} className="shrink-0" />}
/>
);
const indexAdditionalRecordsFeature = (
<InfoCardFeature
label="Index Additional Resolver Records"
key="ENSIndexer Index Additional Resolver Records feature"
description={indexAdditionalRecordsDescription}
icon={<IndexAdditionalRecordsIcon width={15} height={15} className="shrink-0" />}
/>
);
const replaceUnnormalizedLabelsFeature = (
<InfoCardFeature
label="Replace Unnormalized Labels"
key="ENSIndexer Replace Unnormalized Labels feature"
description={replaceUnnormalizedLabelsDescription}
icon={<Replace width={15} height={15} stroke="#3F3F46" className="shrink-0" />}
/>
);
const subgraphCompatabilityFeature = (
<InfoCardFeature
label="Subgraph Compatibility"
key="ENSIndexer Subgraph Compatibility feature"
description={subgraphCompatibilityDescription}
icon={<IconGraphNetwork width={15} height={15} className="text-[#3F3F46] shrink-0" />}
/>
);
const ensIndexerFeatures = [
{
isActivated: healReverseAddressesActivated,
feature: healReverseAddressesFeature,
},
{
isActivated: indexAdditionalRecordsActivated,
feature: indexAdditionalRecordsFeature,
},
{
isActivated: replaceUnnormalizedLabelsActivated,
feature: replaceUnnormalizedLabelsFeature,
},
{
isActivated: subgraphCompatibilityActivated,
feature: subgraphCompatabilityFeature,
},
];
const ensRootChainId = getENSRootChainId(ensIndexerPublicConfig.namespace);
return (
<div className="relative">
{/*ENSApi*/}
<InfoCard
name="ENSApi"
icon={<ENSApiIcon width={24} height={24} />}
version={
<p className="text-sm leading-normal font-normal text-muted-foreground">
v{ensApiPublicConfig.versionInfo.ensApi}
</p>
}
docsLink={new URL("https://ensnode.io/ensapi")}
>
<InfoCardItems>
<InfoCardItem label="Database" value={<p className={cardItemValueStyles}>Postgres</p>} />
<InfoCardItem
label="Database Schema"
value={
<p className={cardItemValueStyles}>{ensIndexerPublicConfig.databaseSchemaName}</p>
}
additionalInfo={
<p>ENSApi reads indexed data from tables within this Postgres database schema.</p>
}
/>
<InfoCardItem
label="ENS Namespace"
value={<p className={cardItemValueStyles}>{ensIndexerPublicConfig.namespace}</p>}
additionalInfo={<p>The ENS namespace that ENSApi is operating in the context of.</p>}
/>
<InfoCardItem
label="RPC Config"
value={
<div className="flex flex-row flex-nowrap max-sm:flex-wrap justify-start items-start gap-3 pt-1">
<Tooltip>
<TooltipTrigger className="cursor-default">
<ChainIcon chainId={ensRootChainId} />
</TooltipTrigger>
<TooltipContent
side="top"
className="bg-gray-50 text-sm text-black text-center shadow-md outline-hidden w-fit"
>
{getChainName(ensRootChainId)}
</TooltipContent>
</Tooltip>
</div>
}
additionalInfo={
<p>
This ENS Root Chain RPC is used to power the Resolution API, in situations where
Protocol Acceleration is not possible.
</p>
}
/>
<InfoCardItem
label="ens-normalize.js"
value={
<p className={cardItemValueStyles}>{ensApiPublicConfig.versionInfo.ensNormalize}</p>
}
additionalInfo={
<p>
Version of the{" "}
<ExternalLinkWithIcon
href={`https://www.npmjs.com/package/@adraffy/ens-normalize/v/${ensApiPublicConfig.versionInfo.ensNormalize}`}
>
@adraffy/ens-normalize
</ExternalLinkWithIcon>{" "}
package used for ENS name normalization.
</p>
}
/>
</InfoCardItems>
<InfoCardFeatures activated={ensApiPublicConfig.theGraphFallback.canFallback}>
<InfoCardFeature
label="Subgraph API Fallback"
description={
ensApiPublicConfig.theGraphFallback.canFallback ? (
<p>
ENSApi's Subgraph API (/subgraph) will automatically fallback to The Graph if the
connected ENSIndexer is not sufficiently "realtime".
</p>
) : (
<p>
ENSApi's Subgraph API (/subgraph) will NOT fallback to The Graph if the connected
ENSIndexer is not sufficiently "realtime". {(() => {
switch (ensApiPublicConfig.theGraphFallback.reason) {
case "not-subgraph-compatible":
return "The connected ENSIndexer is not Subgraph Compatible.";
case "no-api-key":
return "No API key for The Graph is configured.";
case "no-subgraph-url":
return "The Graph does not provide an ENS Subgraph for the configured ENS Namespace.";
default:
return null;
}
})()}
</p>
)
}
icon={<History width={15} height={15} className="shrink-0" />}
/>
</InfoCardFeatures>
</InfoCard>
<InfoCardConnector />
{/*ENSDb*/}
<InfoCard
name="ENSDb"
icon={<ENSDbIcon width={24} height={24} />}
version={
<p className="text-sm leading-normal font-normal text-muted-foreground">
v{ensIndexerPublicConfig.versionInfo.ensDb}
</p>
}
docsLink={new URL("https://ensnode.io/ensdb")}
>
<InfoCardItems>
<InfoCardItem label="Database" value={<p className={cardItemValueStyles}>Postgres</p>} />
<InfoCardItem
label="Database Schema"
value={
<p className={cardItemValueStyles}>{ensIndexerPublicConfig.databaseSchemaName}</p>
}
additionalInfo={
<p>ENSIndexer writes indexed data to tables within this Postgres database schema.</p>
}
/>
</InfoCardItems>
</InfoCard>
<InfoCardConnector />
{/*ENSIndexer*/}
<InfoCard
name="ENSIndexer"
icon={<ENSIndexerIcon width={24} height={24} />}
version={
<p className="text-sm leading-normal font-normal text-muted-foreground">
v{ensIndexerPublicConfig.versionInfo.ensIndexer}
</p>
}
docsLink={new URL("https://ensnode.io/ensindexer")}
>
<InfoCardItems>
<InfoCardItem label="Database" value={<p className={cardItemValueStyles}>Postgres</p>} />
<InfoCardItem
label="Database Schema"
value={
<p className={cardItemValueStyles}>{ensIndexerPublicConfig.databaseSchemaName}</p>
}
additionalInfo={
<p>ENSIndexer writes indexed data to tables within this Postgres database schema.</p>
}
/>
<InfoCardItem
label="ENS Namespace"
value={<p className={cardItemValueStyles}>{ensIndexerPublicConfig.namespace}</p>}
additionalInfo={
<p>The ENS namespace that ENSIndexer is operating in the context of.</p>
}
/>
<InfoCardItem
label="Indexed Chains"
value={
<div className="flex flex-row flex-nowrap max-sm:flex-wrap justify-start items-start gap-3 pt-1">
{Array.from(ensIndexerPublicConfig.indexedChainIds).map((chainId) => (
<Tooltip key={`indexed-chain-#${chainId}`}>
<TooltipTrigger className="cursor-default">
<ChainIcon chainId={chainId} />
</TooltipTrigger>
<TooltipContent
side="top"
className="bg-gray-50 text-sm text-black text-center shadow-md outline-hidden w-fit"
>
{getChainName(chainId)}
</TooltipContent>
</Tooltip>
))}
</div>
}
/>
<InfoCardItem
label="Node.js"
value={
<p className={cardItemValueStyles}>{ensIndexerPublicConfig.versionInfo.nodejs}</p>
}
additionalInfo={
<p>
Version of the{" "}
<ExternalLinkWithIcon
href={`https://nodejs.org/en/download/archive/v${ensIndexerPublicConfig.versionInfo.nodejs}`}
>
Node.js
</ExternalLinkWithIcon>{" "}
runtime.
</p>
}
/>
<InfoCardItem
label="Ponder"
value={
<p className={cardItemValueStyles}>{ensIndexerPublicConfig.versionInfo.ponder}</p>
}
additionalInfo={
<p>
Version of the{" "}
<ExternalLinkWithIcon
href={`https://www.npmjs.com/package/ponder/v/${ensIndexerPublicConfig.versionInfo.ponder}`}
>
ponder
</ExternalLinkWithIcon>{" "}
package used for indexing onchain data.
</p>
}
/>
<InfoCardItem
label="ens-normalize.js"
value={
<p className={cardItemValueStyles}>
{ensIndexerPublicConfig.versionInfo.ensNormalize}
</p>
}
additionalInfo={
<p>
Version of the{" "}
<ExternalLinkWithIcon
href={`https://www.npmjs.com/package/@adraffy/ens-normalize/v/${ensIndexerPublicConfig.versionInfo.ensNormalize}`}
>
@adraffy/ens-normalize
</ExternalLinkWithIcon>{" "}
package used for ENS name normalization.
</p>
}
/>
<InfoCardItem
label="Plugins"
value={
<div className="w-full flex flex-row flex-nowrap max-[1100px]:flex-wrap justify-start items-start gap-1 pt-1">
{ensIndexerPublicConfig.plugins.map((plugin) => (
<span
key={`${plugin}-plugin-badge`}
className="flex justify-start items-start py-0.5 px-2.5 rounded-full bg-secondary text-sm leading-normal font-semibold text-black cursor-default whitespace-nowrap"
>
{plugin}
</span>
))}
</div>
}
/>
</InfoCardItems>
<InfoCardFeatures activated={true}>
{ensIndexerFeatures
.filter((feature) => feature.isActivated)
.map((feature) => feature.feature)}
</InfoCardFeatures>
<InfoCardFeatures activated={false}>
{ensIndexerFeatures
.filter((feature) => !feature.isActivated)
.map((feature) => feature.feature)}
</InfoCardFeatures>
<InfoCardItems>
<InfoCardItem
label="Client LabelSet"
value={
<ul className={cardItemValueStyles}>
<li>
{ensIndexerPublicConfig.labelSet.labelSetId}:
{ensIndexerPublicConfig.labelSet.labelSetVersion}
</li>
</ul>
}
additionalInfo={
<p>
The "fully pinned" labelset id and version used for deterministic healing of unknown
labels across time. The label set version may be equal to or less than the highest
label set version offered by the connected ENSRainbow server.{" "}
<ExternalLinkWithIcon
href={`https://ensnode.io/ensrainbow/concepts/label-sets-and-versioning#client-behavior`}
>
Learn more.
</ExternalLinkWithIcon>
</p>
}
/>
</InfoCardItems>
</InfoCard>
<InfoCardConnector />
{/*ENSRainbow*/}
<InfoCard
name="ENSRainbow"
icon={<ENSRainbowIcon width={24} height={24} />}
version={
<p className="text-sm leading-normal font-normal text-muted-foreground">
v{ensIndexerPublicConfig.ensRainbowPublicConfig.version}
</p>
}
docsLink={new URL("https://ensnode.io/ensrainbow")}
>
<InfoCardItems>
<InfoCardItem
label="Server LabelSet"
value={
<p className={cardItemValueStyles}>
{ensIndexerPublicConfig.ensRainbowPublicConfig.labelSet.labelSetId}:
{ensIndexerPublicConfig.ensRainbowPublicConfig.labelSet.highestLabelSetVersion}
</p>
}
additionalInfo={
<p>
The labelset id and highest labelset version offered by the ENSRainbow server.{" "}
<ExternalLinkWithIcon
href={`https://ensnode.io/ensrainbow/concepts/label-sets-and-versioning`}
>
Learn more.
</ExternalLinkWithIcon>
</p>
}
/>
<InfoCardItem
label="Records Count"
value={
<p className={cardItemValueStyles}>
{ensIndexerPublicConfig.ensRainbowPublicConfig.recordsCount.toLocaleString()}
</p>
}
additionalInfo={
<p>
The total number of Rainbow Records.{" "}
<ExternalLinkWithIcon
href={`https://ensnode.io/ensrainbow/concepts/glossary#rainbow-record`}
>
Learn more.
</ExternalLinkWithIcon>
</p>
}
/>
</InfoCardItems>
</InfoCard>
</div>
);
}