Skip to content

Commit

Permalink
update get compute env return type (#1721)
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdanfazakas authored May 3, 2023
1 parent 15ac930 commit 59568d2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/services/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,16 @@ export class Provider {
}
}

/** Get Compute Environments
* @return {Promise<ComputeEnvironment[]>} urlDetails
/**
* Returns compute environments from a provider.
* @param {string} providerUri - The URI of the provider.
* @param {AbortSignal} [signal] - An optional abort signal.
* @returns {Promise<{[chainId: number]: ComputeEnvironment[]}>} A promise that resolves with an object containing compute environments for each chain ID.
*/
public async getComputeEnvironments(
providerUri: string,
signal?: AbortSignal
): Promise<ComputeEnvironment[]> {
): Promise<{ [chainId: number]: ComputeEnvironment[] }> {
const providerEndpoints = await this.getEndpoints(providerUri)
const serviceEndpoints = await this.getServiceEndpoints(
providerUri,
Expand All @@ -258,8 +261,12 @@ export class Provider {
headers: { 'Content-Type': 'application/json' },
signal
})
const envs: ComputeEnvironment[] = await response.json()
return envs
const result = response.json()
if (Array.isArray(result)) {
const providerChain: number = providerEndpoints.chainId
return { [providerChain]: result }
}
return result
} catch (e) {
LoggerInstance.error(e)
throw new Error('HTTP request failed calling Provider')
Expand Down

0 comments on commit 59568d2

Please sign in to comment.