1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

remove index parameter from ocean.assets.consume()

This commit is contained in:
Matthias Kretschmann 2020-01-28 15:36:25 +01:00
parent cfe20e305a
commit 138a6bf75a
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 7 additions and 31 deletions

View File

@ -13,14 +13,16 @@ squid-js v2.0.0 only works against:
- Events Handler v0.4.4+
- Keeper Contracts v0.13.2+
### Service index removal from `ocean.assets.order`
### Service index removal from `ocean.assets.order` & `ocean.assets.consume`
```js
// old
const agreementId = await ocean.assets.order(did, service.index, account)
const path = await ocean.assets.consume(agreementId, did, service.index, account, folder)
// NEW
const agreementId = await ocean.assets.order(did, account)
const path = await ocean.assets.consume(agreementId, did, account, folder)
```
## v0.8.3 → v1.0.0

View File

@ -156,13 +156,10 @@ describe('Consume Asset', () => {
})
it('should consume and store the assets', async () => {
const accessService = ddo.findServiceByType('access')
const folder = '/tmp/ocean/squid-js-1'
const path = await ocean.assets.consume(
serviceAgreementSignatureResult.agreementId,
ddo.id,
accessService.index,
consumer,
folder
)
@ -183,13 +180,10 @@ describe('Consume Asset', () => {
})
it('should consume and store one asset', async () => {
const accessService = ddo.findServiceByType('access')
const folder = '/tmp/ocean/squid-js-2'
const path = await ocean.assets.consume(
serviceAgreementSignatureResult.agreementId,
ddo.id,
accessService.index,
consumer,
folder,
1

View File

@ -67,16 +67,8 @@ describe('Consume Asset (Brizo)', () => {
})
it('should consume and store the assets', async () => {
const accessService = ddo.findServiceByType('access')
const folder = '/tmp/ocean/squid-js'
const path = await ocean.assets.consume(
agreementId,
ddo.id,
accessService.index,
consumer,
folder
)
const path = await ocean.assets.consume(agreementId, ddo.id, consumer, folder)
assert.include(path, folder, 'The storage path is not correct.')

View File

@ -62,16 +62,8 @@ xdescribe('Consume Asset (Large size)', () => {
})
it('should consume and store the assets', async () => {
const accessService = ddo.findServiceByType('access')
const folder = '/tmp/ocean/squid-js'
const path = await ocean.assets.consume(
agreementId,
ddo.id,
accessService.index,
consumer,
folder
)
const path = await ocean.assets.consume(agreementId, ddo.id, consumer, folder)
assert.include(path, folder, 'The storage path is not correct.')

View File

@ -194,7 +194,6 @@ export class OceanAssets extends Instantiable {
public async consume(
agreementId: string,
did: string,
serviceIndex: number,
consumerAccount: Account,
resultPath: string,
index?: number,
@ -205,7 +204,6 @@ export class OceanAssets extends Instantiable {
public async consume(
agreementId: string,
did: string,
serviceIndex: number,
consumerAccount: Account,
resultPath?: undefined | null,
index?: number,
@ -215,7 +213,6 @@ export class OceanAssets extends Instantiable {
public async consume(
agreementId: string,
did: string,
serviceIndex: number,
consumerAccount: Account,
resultPath?: string,
index: number = -1,
@ -223,8 +220,7 @@ export class OceanAssets extends Instantiable {
): Promise<string | true> {
const ddo = await this.resolve(did)
const { attributes } = ddo.findServiceByType('metadata')
const accessService = ddo.findServiceById(serviceIndex)
const accessService = ddo.findServiceByType('access')
const { files } = attributes.main
@ -239,7 +235,7 @@ export class OceanAssets extends Instantiable {
this.logger.log('Consuming files')
resultPath = resultPath
? `${resultPath}/datafile.${ddo.shortId()}.${serviceIndex}/`
? `${resultPath}/datafile.${ddo.shortId()}.${accessService.index}/`
: undefined
if (!useSecretStore) {