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,
|
creator: Account,
|
||||||
cost: string,
|
cost: string,
|
||||||
datePublished: string,
|
datePublished: string,
|
||||||
timeout = 0
|
timeout = 0,
|
||||||
|
customProvider?: string
|
||||||
): Promise<ServiceAccess> {
|
): Promise<ServiceAccess> {
|
||||||
return {
|
return {
|
||||||
type: 'access',
|
type: 'access',
|
||||||
index: 2,
|
index: 2,
|
||||||
serviceEndpoint: this.ocean.provider.getConsumeEndpoint(),
|
serviceEndpoint: customProvider || this.ocean.provider.getConsumeEndpoint(),
|
||||||
attributes: {
|
attributes: {
|
||||||
main: {
|
main: {
|
||||||
creator: creator.getId(),
|
creator: creator.getId(),
|
||||||
|
@ -279,14 +279,15 @@ export class Compute extends Instantiable {
|
|||||||
datePublished: string,
|
datePublished: string,
|
||||||
providerAttributes: any,
|
providerAttributes: any,
|
||||||
computePrivacy?: ServiceComputePrivacy,
|
computePrivacy?: ServiceComputePrivacy,
|
||||||
timeout?: number
|
timeout?: number,
|
||||||
|
customProvider?: string
|
||||||
): ServiceCompute {
|
): ServiceCompute {
|
||||||
const name = 'dataAssetComputingService'
|
const name = 'dataAssetComputingService'
|
||||||
if (!timeout) timeout = 3600
|
if (!timeout) timeout = 3600
|
||||||
const service = {
|
const service = {
|
||||||
type: 'compute',
|
type: 'compute',
|
||||||
index: 3,
|
index: 3,
|
||||||
serviceEndpoint: this.ocean.provider.getComputeEndpoint(),
|
serviceEndpoint: customProvider || this.ocean.provider.getComputeEndpoint(),
|
||||||
attributes: {
|
attributes: {
|
||||||
main: {
|
main: {
|
||||||
name,
|
name,
|
||||||
|
@ -283,4 +283,22 @@ export class Provider extends Instantiable {
|
|||||||
public getDownloadEndpoint(): string {
|
public getDownloadEndpoint(): string {
|
||||||
return `${this.url}${apiPath}/download`
|
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