-
Notifications
You must be signed in to change notification settings - Fork 605
Clusters Feature Integration #2816
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: main
Are you sure you want to change the base?
Conversation
…user is searching for a cluster name vs a evm address
tive chain count
s.isEnabled to top of the function and utilizes select function of useQuery in useAp iQuery
…date imports and test
…n addressMetadataSchema sub-schema
return { | ||
...clusterQuery, | ||
data: clusterQuery.data || [], | ||
isError: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain the reasoning behind why the isError
flag should always be false
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cloning the entire query object here doesn't seem like a good idea to me in terms of memory usage. I just want to ensure that it is truly necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isError: false UI reason
In SearchBarSuggest, when query.isError
is true, it displays "Something went wrong. Try refreshing the page or come back later."
For better UX where cluster service outages don't break the search experience, cluster search failures show "No results found" while regular search failures show the error message. This behavior is tested and intentional (see test line 415 in useSearchWithClusters.test.tsx
).
query object cloning
The UseQueryResult
interface has many properties (data, isError, isFetching, refetch, etc.) and needs to return an object matching useQuickSearchQuery
's interface since SearchBar.tsx uses them interchangeably.
The cloning preserves all other properties the UI depends on while overriding specific ones for cluster behavior. Memory impact should be minimal since it's a shallow spread of lightweight React Query metadata objects, only for cluster searches.
…while keeping search optimization
… and updates vie wport to narrow test case
Description and Related Issue(s)
This PR introduces Clusters Universal Name Service integration into the Blockscout explorer. Clusters is a cross-chain identity service that allows users to track multiple wallets across various networks under a single unified name (like
vitalik/
orfoobar/
).This optional integration adds a new Clusters directory, Clusters leaderboard, individual cluster details page, and search capability. The feature follows established patterns for optional service and includes proper env handling.
Proposed Changes
Environment Variables:
NEXT_PUBLIC_CLUSTERS_API_HOST
- for Clusters API endpointNEXT_PUBLIC_CLUSTERS_CDN_URL
- for Clusters CDN assetsconfigs/envs/.env.jest
andconfigs/envs/.env.localhost
deploy/tools/envs-validator/schema.ts
deploy/values/
Documentation and Configuration:
docs/ENVS.md
jest.config.ts
and added test mocksjest/mocks/
andjest/setupAfterEnv.ts
API Configuration and Types:
clustersApi
configuration inconfigs/app/apis.ts
with optional Clusters API integrationlib/api/services/clusters.ts
for Clusters API service layerconfigs/app/features/clusters.ts
lib/api/resources.ts
andlib/api/types.ts
TypeScript Types and Stubs:
types/api/clusters.ts
stubs/clusters.ts
types/api/search.ts
Core Library and Utilities:
lib/clusters/
directory with utilities for action bar, page utils, and input detectionlib/hooks/
:useAddressClusters.ts
- for address specific cluster datauseClusterPagination.ts
- for cluster pagination logicuseClusterSearch.ts
- for cluster search functionalityuseClustersData.ts
- for main clusters data fetchinguseQueryParams.ts
- for URL query parameter handlinglib/hooks/useNavItems.tsx
lib/metadata/
andlib/mixpanel/
Testing and QA:
lib/clusters/
utilities - action bar, page utils, input detectionuseAddressClusters
,useClusterPagination
,useClusterSearch
,useClustersData
useSearchWithClusters
ClustersEntity
Pages and Routing:
pages/clusters/index.tsx
- main clusters directory pagepages/clusters/[name].tsx
- individual cluster details pageui/pages/Clusters.tsx
- clusters directory page componentui/pages/Cluster.tsx
- individual cluster page componentnextjs/nextjs-routes.d.ts
UI Components:
ui/clusters/
:ClustersActionBar.tsx
- search and filter controlsClustersDirectoryTable.tsx
andClustersDirectoryTableItem.tsx
- directory viewsClustersDirectoryListItem.tsx
- directory list itemClustersLeaderboardTable.tsx
andClustersLeaderboardTableItem.tsx
- leaderboard viewsClustersLeaderboardListItem.tsx
- leaderboard list itemsui/cluster/
:ClusterDetails.tsx
- main cluster detail componentui/address/clusters/
:AddressClusters.tsx
- clusters tab for address pagesui/shared/ClusterIcon.tsx
- cluster icon componentui/shared/entities/clusters/ClustersEntity.tsx
- cluster entity displaySearch and Navigation Integration:
ui/snippets/searchBar/SearchBarSuggest/SearchBarSuggestCluster.tsx
ui/snippets/searchBar/useSearchWithClusters.tsx
ui/shared/search/utils.ts
ui/snippets/navigation/NavLinkIcon.tsx
SearchBar.tsx
,SearchBarInput.tsx
,SearchBarSuggest.tsx
,SearchBarSuggestItem.tsx
Assets and Icons:
icons/clusters.svg
for cluster-specific logo usepublic/icons/name.d.ts
Breaking or Incompatible Changes
None. This is an additive feature that introduces optional clusters functionality. Existing installations will continue to work unchanged, and the new feature can be optionally enabled by setting the NEXT_PUBLIC_CLUSTERS_API_HOST environment variable.
Additional Information
5 minute Loom video displaying the Clusters feature - https://www.loom.com/share/6278c920204249b398a6f227b1cb701d?sid=5b7d6a88-b13e-4002-8fab-0c531ac92090
Checklist for PR author