-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add check activity column to provider tables #213
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
Changes from 3 commits
615a7aa
7f8b3c4
9e11e01
d270a71
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 |
|---|---|---|
|
|
@@ -12,14 +12,15 @@ import { | |
| type ServiceProvider, | ||
| } from '@/schemas/provider-schema' | ||
| import type { FetchProvidersOptions, ProviderFilter } from '@/types/providers' | ||
| import { getCheckActivityUrl } from '@/utils/provider-urls' | ||
|
|
||
| import { VERSION_FETCH_CONCURRENCY } from './constants' | ||
| import { | ||
| fetchApprovedProviderIds, | ||
| fetchProviderById, | ||
| fetchProvidersBulk, | ||
| } from './contract' | ||
| import type { ProviderWithoutSoftwareVersion } from './types' | ||
| import type { BaseProviderData } from './types' | ||
| import { fetchSoftwareVersion } from './version' | ||
|
|
||
| /** | ||
|
|
@@ -34,7 +35,7 @@ async function fetchProvidersByFilter( | |
| PublicClient | ||
| > | ||
| }, | ||
| ): Promise<ProviderWithoutSoftwareVersion[]> { | ||
| ): Promise<BaseProviderData[]> { | ||
| const { storageView, serviceRegistry } = contracts | ||
|
|
||
| // Fetch approved provider IDs for marking providers | ||
|
|
@@ -70,22 +71,22 @@ async function fetchProvidersByFilter( | |
|
|
||
| const providers = await Promise.all(providerPromises) | ||
| return providers.filter( | ||
| (provider): provider is ProviderWithoutSoftwareVersion => | ||
| provider !== null, | ||
| (provider): provider is BaseProviderData => provider !== null, | ||
| ) | ||
| } | ||
|
|
||
| throw new Error(`Invalid filter type: ${filter}`) | ||
| } | ||
|
|
||
| /** | ||
| * Enrich providers with software version information | ||
| * Enrich providers with additional information (software version and check activity URL) | ||
| */ | ||
| async function enrichProvidersWithVersions( | ||
| providers: ProviderWithoutSoftwareVersion[], | ||
| async function enrichProviders( | ||
| providers: BaseProviderData[], | ||
| network: Network, | ||
| ): Promise<ServiceProvider[]> { | ||
| const providersWithVersions: Array< | ||
| ProviderWithoutSoftwareVersion & { softwareVersion?: string } | ||
| BaseProviderData & { softwareVersion?: string; checkActivityUrl?: string } | ||
silent-cipher marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| > = [] | ||
|
|
||
| // Process providers in batches | ||
|
|
@@ -94,7 +95,11 @@ async function enrichProvidersWithVersions( | |
| const batchResults = await Promise.all( | ||
| batch.map(async (provider) => { | ||
| const softwareVersion = await fetchSoftwareVersion(provider.serviceUrl) | ||
| return { ...provider, softwareVersion } | ||
| const checkActivityUrl = getCheckActivityUrl( | ||
| network, | ||
| provider.payeeAddress, | ||
| ) | ||
|
Comment on lines
+96
to
+99
|
||
| return { ...provider, softwareVersion, checkActivityUrl } | ||
| }), | ||
| ) | ||
| providersWithVersions.push(...batchResults) | ||
|
|
@@ -178,6 +183,6 @@ export async function fetchProviders( | |
| serviceRegistry, | ||
| }) | ||
|
|
||
| // Enrich with software versions | ||
| return enrichProvidersWithVersions(fetchedProviders) | ||
| // Enrich with additional information | ||
| return enrichProviders(fetchedProviders, network) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| import type { ServiceProvider } from '@/schemas/provider-schema' | ||
|
|
||
| /** | ||
| * Provider without software version (before version fetch) | ||
| * Base provider data from contract (before enrichment with software version and check activity URL) | ||
| */ | ||
| export type ProviderWithoutSoftwareVersion = Omit< | ||
| export type BaseProviderData = Omit< | ||
silent-cipher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ServiceProvider, | ||
| 'softwareVersion' | ||
| 'softwareVersion' | 'checkActivityUrl' | ||
| > | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import type { Address } from 'viem' | ||
|
|
||
| import type { Network } from '@/config/chains' | ||
| import { EXPLORERS } from '@/constants/external-services' | ||
|
|
||
| /** | ||
| * Constructs the check activity URL for a provider on PDP Scan | ||
| * | ||
| * @param network - The network (mainnet or calibration) | ||
| * @param payeeAddress - The provider's payee address | ||
| * @returns The full URL to view provider activity on PDP Scan | ||
| */ | ||
| export function getCheckActivityUrl( | ||
| network: Network, | ||
| payeeAddress: Address, | ||
| ): string { | ||
| return `${EXPLORERS.PDP_SCAN[network]}${payeeAddress}` | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.