diff --git a/MIGRATION.md b/MIGRATION.md index ca4fb33..5b579b1 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -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 diff --git a/integration/ocean/ConsumeAsset.test.ts b/integration/ocean/ConsumeAsset.test.ts index 9e4c679..6d92fcf 100644 --- a/integration/ocean/ConsumeAsset.test.ts +++ b/integration/ocean/ConsumeAsset.test.ts @@ -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 diff --git a/integration/ocean/ConsumeAssetBrizo.test.ts b/integration/ocean/ConsumeAssetBrizo.test.ts index b1269b8..b150dfd 100644 --- a/integration/ocean/ConsumeAssetBrizo.test.ts +++ b/integration/ocean/ConsumeAssetBrizo.test.ts @@ -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.') diff --git a/integration/ocean/ConsumeBigAsset.test.ts b/integration/ocean/ConsumeBigAsset.test.ts index c6059cd..181ac43 100644 --- a/integration/ocean/ConsumeBigAsset.test.ts +++ b/integration/ocean/ConsumeBigAsset.test.ts @@ -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.') diff --git a/src/ocean/OceanAssets.ts b/src/ocean/OceanAssets.ts index 9109c02..e8d2723 100644 --- a/src/ocean/OceanAssets.ts +++ b/src/ocean/OceanAssets.ts @@ -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 { 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) {