mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add bob consumes
This commit is contained in:
parent
a6bccad3f1
commit
653dcf5dda
@ -176,34 +176,24 @@ export class Assets extends Instantiable {
|
|||||||
public async download(
|
public async download(
|
||||||
dtAddress: string,
|
dtAddress: string,
|
||||||
serviceEndpoint: string,
|
serviceEndpoint: string,
|
||||||
account: Account,
|
account: string
|
||||||
files: File[],
|
|
||||||
destination: string,
|
|
||||||
index: number = -1
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// const signature = await this.createSignature(account, agreementId)
|
|
||||||
const filesPromises = files
|
let consumeUrl = serviceEndpoint
|
||||||
.filter((_, i) => index === -1 || i === index)
|
consumeUrl += `&consumerAddress=${account}`
|
||||||
.map(async ({ index: i }) => {
|
consumeUrl += `&serviceAgreementId=${dtAddress}`
|
||||||
let consumeUrl = serviceEndpoint
|
|
||||||
consumeUrl += `?index=${i}`
|
|
||||||
consumeUrl += `&serviceAgreementId=${dtAddress}`
|
|
||||||
// consumeUrl += `&consumerAddress=${account.getId()}`
|
|
||||||
// consumeUrl += `&signature=${signature}`
|
|
||||||
|
|
||||||
let serviceConnector = new WebServiceConnector(this.logger)
|
let serviceConnector = new WebServiceConnector(this.logger)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: change to WebServiceConnector.ts
|
await serviceConnector.downloadFile(consumeUrl)
|
||||||
await serviceConnector.downloadFile(consumeUrl, destination, i)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.logger.error('Error consuming assets')
|
this.logger.error('Error consuming assets')
|
||||||
this.logger.error(e)
|
this.logger.error(e)
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
})
|
|
||||||
await Promise.all(filesPromises)
|
return serviceEndpoint
|
||||||
return destination
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import { assert } from 'chai'
|
import { assert } from 'chai'
|
||||||
import { TestContractHandler } from '../TestContractHandler'
|
import { TestContractHandler } from '../TestContractHandler'
|
||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
|
import { Ocean } from '../../src/ocean/Ocean'
|
||||||
|
import { Config } from '../../src/models/Config'
|
||||||
|
|
||||||
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const web3 = new Web3("http://127.0.0.1:8545")
|
const web3 = new Web3("http://127.0.0.1:8545")
|
||||||
@ -20,7 +23,7 @@ describe('Simple flow', () => {
|
|||||||
|
|
||||||
let tokenAmount = 100
|
let tokenAmount = 100
|
||||||
let transferAmount = 1
|
let transferAmount = 1
|
||||||
let blob = 'localhost:8030/api/v1/services'
|
let blob = 'https://localhost:8030/api/v1/services'
|
||||||
|
|
||||||
describe('#test', () => {
|
describe('#test', () => {
|
||||||
it('Initialize Ocean contracts v3', async () => {
|
it('Initialize Ocean contracts v3', async () => {
|
||||||
@ -52,7 +55,10 @@ describe('Simple flow', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('Bob consumes dataset', async () => {
|
it('Bob consumes dataset', async () => {
|
||||||
datatoken.transfer(tokenAddress, bob, tokenAmount, alice)
|
const config = new Config()
|
||||||
|
|
||||||
|
let ocean = await Ocean.getInstance(config)
|
||||||
|
ocean.assets.download(tokenAddress, blob, bob)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
Loading…
x
Reference in New Issue
Block a user