mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
update get compute env return type (#1721)
This commit is contained in:
parent
15ac930e88
commit
59568d292e
@ -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,
|
||||
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user