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:
parent
cfe20e305a
commit
138a6bf75a
@ -13,14 +13,16 @@ squid-js v2.0.0 only works against:
|
|||||||
- Events Handler v0.4.4+
|
- Events Handler v0.4.4+
|
||||||
- Keeper Contracts v0.13.2+
|
- Keeper Contracts v0.13.2+
|
||||||
|
|
||||||
### Service index removal from `ocean.assets.order`
|
### Service index removal from `ocean.assets.order` & `ocean.assets.consume`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// old
|
// old
|
||||||
const agreementId = await ocean.assets.order(did, service.index, account)
|
const agreementId = await ocean.assets.order(did, service.index, account)
|
||||||
|
const path = await ocean.assets.consume(agreementId, did, service.index, account, folder)
|
||||||
|
|
||||||
// NEW
|
// NEW
|
||||||
const agreementId = await ocean.assets.order(did, account)
|
const agreementId = await ocean.assets.order(did, account)
|
||||||
|
const path = await ocean.assets.consume(agreementId, did, account, folder)
|
||||||
```
|
```
|
||||||
|
|
||||||
## v0.8.3 → v1.0.0
|
## v0.8.3 → v1.0.0
|
||||||
|
@ -156,13 +156,10 @@ describe('Consume Asset', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should consume and store the assets', async () => {
|
it('should consume and store the assets', async () => {
|
||||||
const accessService = ddo.findServiceByType('access')
|
|
||||||
|
|
||||||
const folder = '/tmp/ocean/squid-js-1'
|
const folder = '/tmp/ocean/squid-js-1'
|
||||||
const path = await ocean.assets.consume(
|
const path = await ocean.assets.consume(
|
||||||
serviceAgreementSignatureResult.agreementId,
|
serviceAgreementSignatureResult.agreementId,
|
||||||
ddo.id,
|
ddo.id,
|
||||||
accessService.index,
|
|
||||||
consumer,
|
consumer,
|
||||||
folder
|
folder
|
||||||
)
|
)
|
||||||
@ -183,13 +180,10 @@ describe('Consume Asset', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should consume and store one asset', async () => {
|
it('should consume and store one asset', async () => {
|
||||||
const accessService = ddo.findServiceByType('access')
|
|
||||||
|
|
||||||
const folder = '/tmp/ocean/squid-js-2'
|
const folder = '/tmp/ocean/squid-js-2'
|
||||||
const path = await ocean.assets.consume(
|
const path = await ocean.assets.consume(
|
||||||
serviceAgreementSignatureResult.agreementId,
|
serviceAgreementSignatureResult.agreementId,
|
||||||
ddo.id,
|
ddo.id,
|
||||||
accessService.index,
|
|
||||||
consumer,
|
consumer,
|
||||||
folder,
|
folder,
|
||||||
1
|
1
|
||||||
|
@ -67,16 +67,8 @@ describe('Consume Asset (Brizo)', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should consume and store the assets', async () => {
|
it('should consume and store the assets', async () => {
|
||||||
const accessService = ddo.findServiceByType('access')
|
|
||||||
|
|
||||||
const folder = '/tmp/ocean/squid-js'
|
const folder = '/tmp/ocean/squid-js'
|
||||||
const path = await ocean.assets.consume(
|
const path = await ocean.assets.consume(agreementId, ddo.id, consumer, folder)
|
||||||
agreementId,
|
|
||||||
ddo.id,
|
|
||||||
accessService.index,
|
|
||||||
consumer,
|
|
||||||
folder
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.include(path, folder, 'The storage path is not correct.')
|
assert.include(path, folder, 'The storage path is not correct.')
|
||||||
|
|
||||||
|
@ -62,16 +62,8 @@ xdescribe('Consume Asset (Large size)', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should consume and store the assets', async () => {
|
it('should consume and store the assets', async () => {
|
||||||
const accessService = ddo.findServiceByType('access')
|
|
||||||
|
|
||||||
const folder = '/tmp/ocean/squid-js'
|
const folder = '/tmp/ocean/squid-js'
|
||||||
const path = await ocean.assets.consume(
|
const path = await ocean.assets.consume(agreementId, ddo.id, consumer, folder)
|
||||||
agreementId,
|
|
||||||
ddo.id,
|
|
||||||
accessService.index,
|
|
||||||
consumer,
|
|
||||||
folder
|
|
||||||
)
|
|
||||||
|
|
||||||
assert.include(path, folder, 'The storage path is not correct.')
|
assert.include(path, folder, 'The storage path is not correct.')
|
||||||
|
|
||||||
|
@ -194,7 +194,6 @@ export class OceanAssets extends Instantiable {
|
|||||||
public async consume(
|
public async consume(
|
||||||
agreementId: string,
|
agreementId: string,
|
||||||
did: string,
|
did: string,
|
||||||
serviceIndex: number,
|
|
||||||
consumerAccount: Account,
|
consumerAccount: Account,
|
||||||
resultPath: string,
|
resultPath: string,
|
||||||
index?: number,
|
index?: number,
|
||||||
@ -205,7 +204,6 @@ export class OceanAssets extends Instantiable {
|
|||||||
public async consume(
|
public async consume(
|
||||||
agreementId: string,
|
agreementId: string,
|
||||||
did: string,
|
did: string,
|
||||||
serviceIndex: number,
|
|
||||||
consumerAccount: Account,
|
consumerAccount: Account,
|
||||||
resultPath?: undefined | null,
|
resultPath?: undefined | null,
|
||||||
index?: number,
|
index?: number,
|
||||||
@ -215,7 +213,6 @@ export class OceanAssets extends Instantiable {
|
|||||||
public async consume(
|
public async consume(
|
||||||
agreementId: string,
|
agreementId: string,
|
||||||
did: string,
|
did: string,
|
||||||
serviceIndex: number,
|
|
||||||
consumerAccount: Account,
|
consumerAccount: Account,
|
||||||
resultPath?: string,
|
resultPath?: string,
|
||||||
index: number = -1,
|
index: number = -1,
|
||||||
@ -223,8 +220,7 @@ export class OceanAssets extends Instantiable {
|
|||||||
): Promise<string | true> {
|
): Promise<string | true> {
|
||||||
const ddo = await this.resolve(did)
|
const ddo = await this.resolve(did)
|
||||||
const { attributes } = ddo.findServiceByType('metadata')
|
const { attributes } = ddo.findServiceByType('metadata')
|
||||||
|
const accessService = ddo.findServiceByType('access')
|
||||||
const accessService = ddo.findServiceById(serviceIndex)
|
|
||||||
|
|
||||||
const { files } = attributes.main
|
const { files } = attributes.main
|
||||||
|
|
||||||
@ -239,7 +235,7 @@ export class OceanAssets extends Instantiable {
|
|||||||
this.logger.log('Consuming files')
|
this.logger.log('Consuming files')
|
||||||
|
|
||||||
resultPath = resultPath
|
resultPath = resultPath
|
||||||
? `${resultPath}/datafile.${ddo.shortId()}.${serviceIndex}/`
|
? `${resultPath}/datafile.${ddo.shortId()}.${accessService.index}/`
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
if (!useSecretStore) {
|
if (!useSecretStore) {
|
||||||
|
Loading…
Reference in New Issue
Block a user