1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

consume flow

This commit is contained in:
Jernej Pregelj 2019-03-21 12:15:35 +01:00
parent 853b78e1d9
commit 4890d2f27b
2 changed files with 4 additions and 24 deletions

View File

@ -7,7 +7,7 @@ export const nodeHost = 'localhost'
export const nodePort = 8545
export const aquariusScheme = 'http'
export const aquariusHost = 'localhost'
export const aquariusHost = 'aquarius'
export const aquariusPort = 5000
export const brizoScheme = 'http'

View File

@ -31,29 +31,9 @@ export default class Details extends Component<DetailsProps, DetailsState> {
private purchaseAsset = async (ddo: any) => {
try {
const account = await this.context.ocean.getAccounts()
const service = ddo.findServiceByType('Access')
const serviceAgreementSignatureResult = await this.context.ocean.signServiceAgreement(
ddo.id,
service.serviceDefinitionId,
account[0]
)
await this.context.ocean.initializeServiceAgreement(
ddo.id,
service.serviceDefinitionId,
serviceAgreementSignatureResult.agreementId,
serviceAgreementSignatureResult.signature,
(files: any) => {
Logger.log('downloading files', files)
files.forEach((file: any) => {
const parsedUrl: any = queryString.parseUrl(file)
setTimeout(() => {
// eslint-disable-next-line
window.open(parsedUrl.query.url)
}, 100)
})
},
account[0]
)
const accessService = ddo.findServiceByType('Access')
const agreementId = await this.context.ocean.assets.order(ddo.id, accessService.serviceDefinitionId, account[0])
Logger.log('agreementId', agreementId)
} catch (e) {
Logger.log('error', e)
}