Skip to content

resolveProviderLocations

resolveProviderLocations(client, options): Promise<OutputType>

Defined in: packages/synapse-core/src/warm-storage/resolve-provider-locations.ts:70

Resolve the location to store on for each of a set of specific providers.

Reads the providers from the registry, so they do not need to be approved, and the client’s data sets with getPdpDataSets once, then selects with selectProviders and providerId for each provider. Each location is the provider’s best metadata-matching data set, or a new-dataset location when none matches.

This function does NOT ping the providers.

Parameter Type Description
client Client<Transport, Chain> The client to use to read the providers and data sets.
options OptionsType resolveProviderLocations.OptionsType

Promise<OutputType>

The resolved locations resolveProviderLocations.OutputType

import { resolveProviderLocations } from '@filoz/synapse-core/warm-storage'
import { createPublicClient, http } from 'viem'
import { calibration } from '@filoz/synapse-core/chains'

const client = createPublicClient({
  chain: calibration,
  transport: http(),
})

const [first, second] = await resolveProviderLocations(client, {
  address: '0x1234567890123456789012345678901234567890',
  providerIds: [1n, 2n],
  metadata: { source: 'my-app' },
})

console.log(first.dataSetId ?? 'new data set', second.dataSetId ?? 'new data set')

Errors resolveProviderLocations.ErrorType. Throws PDPProviderUnavailableError for the first provider that does not exist or has no active PDP product.