1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

fix initialize

This commit is contained in:
Ahmed Ali 2020-06-30 11:37:03 +02:00
parent 2219d183f6
commit f9c5b7bd49
3 changed files with 11 additions and 24 deletions

View File

@ -386,10 +386,8 @@ export class Assets extends Instantiable {
public async order(
did: string,
serviceType: string,
tokenAddress,
consumerAddress: string
): Promise<void> {
// provider.initialize
): Promise<string> {
const service = await this.getService(did, serviceType)
return await this.ocean.provider.initialize(
did,

View File

@ -69,7 +69,7 @@ export class Provider extends Instantiable {
serviceIndex: number,
serviceType: string,
consumerAddress: string
): Promise<any> {
): Promise<string> {
let DDO
try {
DDO = await this.ocean.assets.resolve(did)
@ -78,20 +78,16 @@ export class Provider extends Instantiable {
throw new Error('Failed to resolve DID')
}
const args = {
documentId: did,
serviceId: serviceIndex,
serviceType: serviceType,
tokenAddress: DDO.dataToken,
consumerAddress: consumerAddress
}
console.log(args)
let initializeUrl = this.getInitializeEndpoint()
initializeUrl += `?documentId=${did}`
initializeUrl += `&serviceId=${serviceIndex}`
initializeUrl += `&serviceType=${serviceType}`
initializeUrl += `&tokenAddress=${DDO.dataToken}`
initializeUrl += `&consumerAddress=${consumerAddress}`
try {
return await this.ocean.utils.fetch.post(
this.getInitializeEndpoint(),
decodeURI(JSON.stringify(args))
)
const response = await this.ocean.utils.fetch.get(initializeUrl)
return await response.text()
} catch (e) {
this.logger.error(e)
throw new Error('HTTP request failed')

View File

@ -159,14 +159,7 @@ describe('Marketplace flow', () => {
})
it('Bob consumes asset 1', async () => {
console.log(
await ocean.assets.order(
ddo.id,
accessService.type,
ddo.dataToken,
bob.getId()
)
)
console.log(await ocean.assets.order(ddo.id, accessService.type, bob.getId()))
// await ocean.assets.download(tokenAddress, accessService.serviceEndpoint, accessService.index, bob.getId(), '~/my-datasets')
})
})