@@ -12,14 +12,15 @@ import {
1212 type ServiceProvider ,
1313} from '@/schemas/provider-schema'
1414import type { FetchProvidersOptions , ProviderFilter } from '@/types/providers'
15+ import { getCheckActivityUrl } from '@/utils/provider-urls'
1516
1617import { VERSION_FETCH_CONCURRENCY } from './constants'
1718import {
1819 fetchApprovedProviderIds ,
1920 fetchProviderById ,
2021 fetchProvidersBulk ,
2122} from './contract'
22- import type { ProviderWithoutSoftwareVersion } from './types'
23+ import type { BaseProviderData } from './types'
2324import { fetchSoftwareVersion } from './version'
2425
2526/**
@@ -34,7 +35,7 @@ async function fetchProvidersByFilter(
3435 PublicClient
3536 >
3637 } ,
37- ) : Promise < ProviderWithoutSoftwareVersion [ ] > {
38+ ) : Promise < BaseProviderData [ ] > {
3839 const { storageView, serviceRegistry } = contracts
3940
4041 // Fetch approved provider IDs for marking providers
@@ -70,31 +71,33 @@ async function fetchProvidersByFilter(
7071
7172 const providers = await Promise . all ( providerPromises )
7273 return providers . filter (
73- ( provider ) : provider is ProviderWithoutSoftwareVersion =>
74- provider !== null ,
74+ ( provider ) : provider is BaseProviderData => provider !== null ,
7575 )
7676 }
7777
7878 throw new Error ( `Invalid filter type: ${ filter } ` )
7979}
8080
8181/**
82- * Enrich providers with software version information
82+ * Enrich providers with additional information ( software version and check activity URL)
8383 */
84- async function enrichProvidersWithVersions (
85- providers : ProviderWithoutSoftwareVersion [ ] ,
84+ async function enrichProviders (
85+ providers : BaseProviderData [ ] ,
86+ network : Network ,
8687) : Promise < ServiceProvider [ ] > {
87- const providersWithVersions : Array <
88- ProviderWithoutSoftwareVersion & { softwareVersion ?: string }
89- > = [ ]
88+ const providersWithVersions : ServiceProvider [ ] = [ ]
9089
9190 // Process providers in batches
9291 for ( let i = 0 ; i < providers . length ; i += VERSION_FETCH_CONCURRENCY ) {
9392 const batch = providers . slice ( i , i + VERSION_FETCH_CONCURRENCY )
9493 const batchResults = await Promise . all (
9594 batch . map ( async ( provider ) => {
9695 const softwareVersion = await fetchSoftwareVersion ( provider . serviceUrl )
97- return { ...provider , softwareVersion }
96+ const checkActivityUrl = getCheckActivityUrl (
97+ network ,
98+ provider . payeeAddress ,
99+ )
100+ return { ...provider , softwareVersion, checkActivityUrl }
98101 } ) ,
99102 )
100103 providersWithVersions . push ( ...batchResults )
@@ -178,6 +181,6 @@ export async function fetchProviders(
178181 serviceRegistry,
179182 } )
180183
181- // Enrich with software versions
182- return enrichProvidersWithVersions ( fetchedProviders )
184+ // Enrich with additional information
185+ return enrichProviders ( fetchedProviders , network )
183186}
0 commit comments