mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
allow customProvider on publish
This commit is contained in:
parent
587c9f9b09
commit
f75e45500c
@ -379,12 +379,13 @@ export class Assets extends Instantiable {
|
||||
creator: Account,
|
||||
cost: string,
|
||||
datePublished: string,
|
||||
timeout = 0
|
||||
timeout = 0,
|
||||
customProvider?: string
|
||||
): Promise<ServiceAccess> {
|
||||
return {
|
||||
type: 'access',
|
||||
index: 2,
|
||||
serviceEndpoint: this.ocean.provider.getConsumeEndpoint(),
|
||||
serviceEndpoint: customProvider || this.ocean.provider.getConsumeEndpoint(),
|
||||
attributes: {
|
||||
main: {
|
||||
creator: creator.getId(),
|
||||
|
@ -279,14 +279,15 @@ export class Compute extends Instantiable {
|
||||
datePublished: string,
|
||||
providerAttributes: any,
|
||||
computePrivacy?: ServiceComputePrivacy,
|
||||
timeout?: number
|
||||
timeout?: number,
|
||||
customProvider?: string
|
||||
): ServiceCompute {
|
||||
const name = 'dataAssetComputingService'
|
||||
if (!timeout) timeout = 3600
|
||||
const service = {
|
||||
type: 'compute',
|
||||
index: 3,
|
||||
serviceEndpoint: this.ocean.provider.getComputeEndpoint(),
|
||||
serviceEndpoint: customProvider || this.ocean.provider.getComputeEndpoint(),
|
||||
attributes: {
|
||||
main: {
|
||||
name,
|
||||
|
@ -283,4 +283,22 @@ export class Provider extends Instantiable {
|
||||
public getDownloadEndpoint(): string {
|
||||
return `${this.url}${apiPath}/download`
|
||||
}
|
||||
|
||||
public async isValidProvider(url: string): Promise<boolean> {
|
||||
const fetch = this.ocean.utils.fetch.get(url)
|
||||
await fetch
|
||||
.then((response: Response) => {
|
||||
if (response.ok) {
|
||||
const params = response.json()
|
||||
if (params) return true
|
||||
}
|
||||
return false
|
||||
})
|
||||
.catch((error: Error) => {
|
||||
this.logger.error('Error validating provider')
|
||||
this.logger.error(error.message)
|
||||
return false
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user