mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Fixed modifications.
This commit is contained in:
parent
687fd743c6
commit
1715679bf8
@ -48,7 +48,6 @@
|
|||||||
"lzma": "^2.3.2",
|
"lzma": "^2.3.2",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"save-file": "^2.3.1",
|
"save-file": "^2.3.1",
|
||||||
"test": "^0.6.0",
|
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"web3": "^1.3.0",
|
"web3": "^1.3.0",
|
||||||
"web3-eth-contract": "^1.3.0"
|
"web3-eth-contract": "^1.3.0"
|
||||||
|
@ -10,7 +10,7 @@ import { Response } from 'node-fetch'
|
|||||||
import { DDO } from '../ddo/DDO'
|
import { DDO } from '../ddo/DDO'
|
||||||
import DID from '../ocean/DID'
|
import DID from '../ocean/DID'
|
||||||
|
|
||||||
export interface EndpointInformation {
|
export interface ServiceEndpoint {
|
||||||
serviceName: string
|
serviceName: string
|
||||||
method: string
|
method: string
|
||||||
urlPath: string
|
urlPath: string
|
||||||
@ -25,7 +25,7 @@ export interface EndpointInformation {
|
|||||||
export class Provider extends Instantiable {
|
export class Provider extends Instantiable {
|
||||||
public nonce: string
|
public nonce: string
|
||||||
private baseUrl: string
|
private baseUrl: string
|
||||||
public servicesEndpoints: any
|
public servicesEndpoints: ServiceEndpoint[]
|
||||||
public providerAddress: string
|
public providerAddress: string
|
||||||
/**
|
/**
|
||||||
* Returns the instance of Provider.
|
* Returns the instance of Provider.
|
||||||
@ -49,13 +49,19 @@ export class Provider extends Instantiable {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getServiceEndpoints(): Promise<EndpointInformation[]> {
|
/**
|
||||||
const serviceEndpoints: EndpointInformation[] = []
|
* Returns the service endpoints that exist
|
||||||
|
* in provider.
|
||||||
|
* @return {Promise<ServiceEndpoint[]>}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public async getServiceEndpoints(): Promise<ServiceEndpoint[]> {
|
||||||
|
const serviceEndpoints: ServiceEndpoint[] = []
|
||||||
try {
|
try {
|
||||||
const result = await (await this.ocean.utils.fetch.get(this.url)).json()
|
const result = await (await this.ocean.utils.fetch.get(this.url)).json()
|
||||||
this.providerAddress = result['provider-address']
|
this.providerAddress = result['provider-address']
|
||||||
for (const i in result.serviceEndpoints) {
|
for (const i in result.serviceEndpoints) {
|
||||||
const endpoint: EndpointInformation = {
|
const endpoint: ServiceEndpoint = {
|
||||||
serviceName: i,
|
serviceName: i,
|
||||||
method: result.serviceEndpoints[i][0],
|
method: result.serviceEndpoints[i][0],
|
||||||
urlPath: this.url + result.serviceEndpoints[i][1]
|
urlPath: this.url + result.serviceEndpoints[i][1]
|
||||||
@ -70,11 +76,11 @@ export class Provider extends Instantiable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEndpointURL(serviceName: string): EndpointInformation {
|
public getEndpointURL(serviceName: string): ServiceEndpoint {
|
||||||
if (!this.servicesEndpoints) return null
|
if (!this.servicesEndpoints) return null
|
||||||
return this.servicesEndpoints.find(
|
return this.servicesEndpoints.find(
|
||||||
(s) => s.serviceName === serviceName
|
(s) => s.serviceName === serviceName
|
||||||
) as EndpointInformation
|
) as ServiceEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createSignature(account: Account, agreementId: string): Promise<string> {
|
public async createSignature(account: Account, agreementId: string): Promise<string> {
|
||||||
@ -340,40 +346,39 @@ export class Provider extends Instantiable {
|
|||||||
return `${this.url}`
|
return `${this.url}`
|
||||||
}
|
}
|
||||||
|
|
||||||
public getInitializeEndpoint(): EndpointInformation {
|
public getInitializeEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('initialize')
|
return this.getEndpointURL('initialize')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNonceEndpoint(): EndpointInformation {
|
public getNonceEndpoint(): ServiceEndpoint {
|
||||||
// Output: NONCE: [Object object]
|
|
||||||
return this.getEndpointURL('nonce')
|
return this.getEndpointURL('nonce')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEncryptEndpoint(): EndpointInformation {
|
public getEncryptEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('encrypt')
|
return this.getEndpointURL('encrypt')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFileinfoEndpoint(): EndpointInformation {
|
public getFileinfoEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('fileinfo')
|
return this.getEndpointURL('fileinfo')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getComputeStatusEndpoint(): EndpointInformation {
|
public getComputeStatusEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('computeStatus')
|
return this.getEndpointURL('computeStatus')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getComputeStartEndpoint(): EndpointInformation {
|
public getComputeStartEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('computeStart')
|
return this.getEndpointURL('computeStart')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getComputeStopEndpoint(): EndpointInformation {
|
public getComputeStopEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('computeStop')
|
return this.getEndpointURL('computeStop')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getComputeDeleteEndpoint(): EndpointInformation {
|
public getComputeDeleteEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('computeDelete')
|
return this.getEndpointURL('computeDelete')
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDownloadEndpoint(): EndpointInformation {
|
public getDownloadEndpoint(): ServiceEndpoint {
|
||||||
return this.getEndpointURL('download')
|
return this.getEndpointURL('download')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user