-
Notifications
You must be signed in to change notification settings - Fork 15
refactor(ensapi): apply operation result pattern #1545
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
base: feat/ensnode-result-type
Are you sure you want to change the base?
Changes from all commits
e80b9f4
56aa797
902d556
412e722
02fbeb3
ac5bb11
1cd4b10
a649edd
d6575b5
1246ce7
2d86cc2
6565097
159d210
fe3ffcc
8ea9155
229d8d8
35fa0b7
50b5e18
f5d75f7
d4261da
59f3700
9b46b51
3c4b632
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,19 +153,12 @@ export function DisplayRegistrarActionsPanel({ | |
| <CardContent className="max-sm:p-3 max-sm:pt-0 flex flex-col gap-4"> | ||
| <p>The Registrar Actions API on the connected ENSNode instance is not available yet.</p> | ||
| <p> | ||
| The Registrar Actions API will be available once the omnichain indexing status reaches | ||
| one of the following: | ||
| The Registrar Actions API will be available once the omnichain indexing status becomes{" "} | ||
| <Badge variant="secondary"> | ||
| {formatOmnichainIndexingStatus(registrarActions.supportedIndexingStatusId)} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried that our client-code is interpreting this value as a strict enum, rather than as an arbitrary string. It's super important we put a high priority on these distinctions. |
||
| </Badge> | ||
| . | ||
lightwalker-eth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </p> | ||
|
|
||
| <ul> | ||
| {registrarActions.supportedIndexingStatusIds.map((supportedStatusId) => ( | ||
| <li className="inline" key={supportedStatusId}> | ||
| <Badge variant="secondary"> | ||
| {formatOmnichainIndexingStatus(supportedStatusId)} | ||
| </Badge>{" "} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </CardContent> | ||
| <CardFooter className="gap-6"> | ||
| <Button asChild> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { NamedRegistrarAction, OmnichainIndexingStatusId } from "@ensnode/ensnode-sdk"; | ||
| import { NamedRegistrarAction, OmnichainIndexingStatusIds } from "@ensnode/ensnode-sdk"; | ||
|
|
||
| export const StatefulFetchStatusIds = { | ||
| /** | ||
|
|
@@ -61,7 +61,9 @@ export interface StatefulFetchRegistrarActionsUnsupported { | |
| */ | ||
| export interface StatefulFetchRegistrarActionsNotReady { | ||
| fetchStatus: typeof StatefulFetchStatusIds.NotReady; | ||
| supportedIndexingStatusIds: ReadonlyArray<OmnichainIndexingStatusId>; | ||
| supportedIndexingStatusId: | ||
| | typeof OmnichainIndexingStatusIds.Completed | ||
| | typeof OmnichainIndexingStatusIds.Following; | ||
|
Comment on lines
+64
to
+66
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There can be just one supported indexing status at a time.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggest to define a new type in the indexing status file for the idea of an "indexing status end state" that would be a type union of completed and following. We should document how these are "end states" because once indexing reaches one of these statuses, it will continue in that status forever. Then you can reference that newly defined type union here and anywhere else where it is relevant. |
||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import { useENSNodeConfig, useRegistrarActions } from "@ensnode/ensnode-react"; | ||
| import { | ||
| getChainIndexingConfigTypeId, | ||
| IndexingStatusResponseCodes, | ||
| RegistrarActionsOrders, | ||
| RegistrarActionsResponseCodes, | ||
|
|
@@ -27,7 +28,7 @@ const { | |
| hasEnsIndexerConfigSupport, | ||
| hasIndexingStatusSupport, | ||
| requiredPlugins, | ||
| supportedIndexingStatusIds, | ||
| getSupportedIndexingStatus, | ||
| } = registrarActionsPrerequisites; | ||
|
|
||
| /** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A key goal of our work here is to fully remove the need for the whole "use stateful registrar actions" concept. We should just have a "use registrar actions" that makes a single stateless API request. The client can then appropriately handle errors associated with insufficient indexing status or a config that won't support the API request. |
||
|
|
@@ -51,10 +52,12 @@ export function useStatefulRegistrarActions({ | |
| ) { | ||
| const { ensIndexerPublicConfig } = ensNodeConfigQuery.data; | ||
| const { omnichainSnapshot } = indexingStatusQuery.data.realtimeProjection.snapshot; | ||
| const chains = Array.from(omnichainSnapshot.chains.values()); | ||
| const configTypeId = getChainIndexingConfigTypeId(chains); | ||
|
|
||
| isRegistrarActionsApiSupported = | ||
| hasEnsIndexerConfigSupport(ensIndexerPublicConfig) && | ||
| hasIndexingStatusSupport(omnichainSnapshot.omnichainStatus); | ||
| hasIndexingStatusSupport(configTypeId, omnichainSnapshot.omnichainStatus); | ||
| } | ||
|
|
||
| // Note: ENSNode Registrar Actions API is available only in certain cases. | ||
|
|
@@ -101,12 +104,14 @@ export function useStatefulRegistrarActions({ | |
| } | ||
|
|
||
| const { omnichainSnapshot } = indexingStatusQuery.data.realtimeProjection.snapshot; | ||
| const chains = Array.from(omnichainSnapshot.chains.values()); | ||
| const configTypeId = getChainIndexingConfigTypeId(chains); | ||
|
|
||
| // fetching is temporarily not possible due to indexing status being not advanced enough | ||
| if (!hasIndexingStatusSupport(omnichainSnapshot.omnichainStatus)) { | ||
| if (!hasIndexingStatusSupport(configTypeId, omnichainSnapshot.omnichainStatus)) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking indexing status support now requires providing the chains configuration type ID. |
||
| return { | ||
| fetchStatus: StatefulFetchStatusIds.NotReady, | ||
| supportedIndexingStatusIds, | ||
| supportedIndexingStatusId: getSupportedIndexingStatus(configTypeId), | ||
lightwalker-eth marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } satisfies StatefulFetchRegistrarActionsNotReady; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.