diff --git a/src/services/Provider.ts b/src/services/Provider.ts index 1224ac138..a5449ffd3 100644 --- a/src/services/Provider.ts +++ b/src/services/Provider.ts @@ -238,13 +238,16 @@ export class Provider { } } - /** Get Compute Environments - * @return {Promise} 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 { + ): Promise<{ [chainId: number]: ComputeEnvironment[] }> { const providerEndpoints = await this.getEndpoints(providerUri) const serviceEndpoints = await this.getServiceEndpoints( providerUri, @@ -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')