mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
order asset
This commit is contained in:
parent
2d2e41c7f3
commit
2219d183f6
@ -25,13 +25,6 @@ export enum CreateProgressStep {
|
||||
DdoStored
|
||||
}
|
||||
|
||||
export enum OrderProgressStep {
|
||||
CreatingAgreement,
|
||||
AgreementInitialized,
|
||||
LockingPayment,
|
||||
LockedPayment
|
||||
}
|
||||
|
||||
/**
|
||||
* Assets submodule of Ocean Protocol.
|
||||
*/
|
||||
@ -390,6 +383,22 @@ export class Assets extends Instantiable {
|
||||
}
|
||||
}
|
||||
|
||||
public async order(
|
||||
did: string,
|
||||
serviceType: string,
|
||||
tokenAddress,
|
||||
consumerAddress: string
|
||||
): Promise<void> {
|
||||
// provider.initialize
|
||||
const service = await this.getService(did, serviceType)
|
||||
return await this.ocean.provider.initialize(
|
||||
did,
|
||||
service.index,
|
||||
serviceType,
|
||||
consumerAddress
|
||||
)
|
||||
}
|
||||
|
||||
public async download(
|
||||
dtAddress: string,
|
||||
serviceEndpoint: string,
|
||||
@ -400,7 +409,7 @@ export class Assets extends Instantiable {
|
||||
consumeUrl += `?consumerAddress=${account}`
|
||||
consumeUrl += `&tokenAddress=${dtAddress}`
|
||||
consumeUrl += `&transferTxId=${txId}`
|
||||
|
||||
console.log(consumeUrl)
|
||||
const serviceConnector = new WebServiceConnector(this.logger)
|
||||
|
||||
try {
|
||||
|
@ -77,15 +77,15 @@ export class Provider extends Instantiable {
|
||||
this.logger.error(e)
|
||||
throw new Error('Failed to resolve DID')
|
||||
}
|
||||
const { dtAddress } = DDO
|
||||
|
||||
const args = {
|
||||
documentId: did,
|
||||
serviceId: serviceIndex,
|
||||
serviceType: serviceType,
|
||||
tokenAddress: dtAddress,
|
||||
tokenAddress: DDO.dataToken,
|
||||
consumerAddress: consumerAddress
|
||||
}
|
||||
console.log(args)
|
||||
|
||||
try {
|
||||
return await this.ocean.utils.fetch.post(
|
||||
|
@ -159,7 +159,15 @@ describe('Marketplace flow', () => {
|
||||
})
|
||||
|
||||
it('Bob consumes asset 1', async () => {
|
||||
await ocean.assets.download(ddo.did, accessService.index, bob.getId(), '~/my-datasets')
|
||||
console.log(
|
||||
await ocean.assets.order(
|
||||
ddo.id,
|
||||
accessService.type,
|
||||
ddo.dataToken,
|
||||
bob.getId()
|
||||
)
|
||||
)
|
||||
// await ocean.assets.download(tokenAddress, accessService.serviceEndpoint, accessService.index, bob.getId(), '~/my-datasets')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user