1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00
This commit is contained in:
arsenyjin 2020-06-18 11:45:44 +02:00
parent b1c134df20
commit 9efbe00ba3
2 changed files with 15 additions and 10 deletions

View File

@ -176,12 +176,15 @@ export class Assets extends Instantiable {
public async download( public async download(
dtAddress: string, dtAddress: string,
serviceEndpoint: string, serviceEndpoint: string,
txId: string,
account: string account: string
): Promise<string> { ): Promise<string> {
let consumeUrl = serviceEndpoint let consumeUrl = serviceEndpoint
// consumeUrl += `&consumerAddress=${account}` consumeUrl += `?`
// consumeUrl += `&serviceAgreementId=${dtAddress}` consumeUrl += `consumerAddress=${account}`
consumeUrl += `&tokenAddress=${dtAddress}`
consumeUrl += `&transferTxId=${txId}`
let serviceConnector = new WebServiceConnector(this.logger) let serviceConnector = new WebServiceConnector(this.logger)

View File

@ -20,6 +20,7 @@ describe('Simple flow', () => {
let contracts let contracts
let datatoken let datatoken
let tokenAddress let tokenAddress
let transactionId
let tokenAmount = 100 let tokenAmount = 100
let transferAmount = 1 let transferAmount = 1
@ -38,21 +39,22 @@ describe('Simple flow', () => {
it('Alice publishes a dataset', async () => { it('Alice publishes a dataset', async () => {
// Alice creates a Datatoken // Alice creates a Datatoken
datatoken = new DataTokens(contracts.factoryAddress, factoryABI, datatokensABI, web3) datatoken = new DataTokens(contracts.factoryAddress, factoryABI, datatokensABI, web3)
tokenAddress = await datatoken.create(config.providerUri, alice) tokenAddress = await datatoken.create(blob, alice)
}) })
it('Alice mints 100 tokens', async () => { it('Alice mints 100 tokens', async () => {
datatoken.mint(tokenAddress, alice, tokenAmount) await datatoken.mint(tokenAddress, alice, tokenAmount)
}) })
it('Alice transfers 1 token to Bob', async () => { it('Alice transfers 1 token to Bob', async () => {
datatoken.transfer(tokenAddress, bob, tokenAmount, alice) const ts = await datatoken.transfer(tokenAddress, bob, tokenAmount, alice)
transactionId = ts['transactionHash']
}) })
it('Bob consumes dataset', async () => { it('Bob consumes dataset', async () => {
const config = new Config() const config = new Config()
let ocean = await Ocean.getInstance(config) let ocean = await Ocean.getInstance(config)
ocean.assets.download(tokenAddress, blob, bob) await ocean.assets.download(tokenAddress, blob, bob, transactionId)
}) })
}) })
}) })