1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge pull request #113 from oceanprotocol/feature/integrate-barge

Feature/integrate barge
This commit is contained in:
Ahmed Ali 2020-06-26 21:42:57 +02:00 committed by GitHub
commit 1addf160eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 38 deletions

View File

@ -18,11 +18,18 @@ before_install:
before_script: before_script:
- ganache-cli > ganache-cli.log & - ganache-cli > ganache-cli.log &
- git clone https://github.com/oceanprotocol/barge
- cd barge
- git checkout v3
- bash -x start_ocean.sh 2>&1 > start_ocean.log &
- cd ..
- sleep 300
script: script:
- npm run lint - npm run lint
- npm run build - npm run build
- npm run test:cover - npm run test:cover
- npm run test:integration
notifications: notifications:
email: false email: false

View File

@ -3,7 +3,7 @@ import { Authentication } from './interfaces/Authentication'
import { Proof } from './interfaces/Proof' import { Proof } from './interfaces/Proof'
import { PublicKey } from './interfaces/PublicKey' import { PublicKey } from './interfaces/PublicKey'
import { Service, ServiceType } from './interfaces/Service' import { Service, ServiceType } from './interfaces/Service'
import Web3Provider from '../datatokens/Web3Provider' import Web3Provider from '../datatokens/Web3Provider'
/** /**
* DID Descriptor Object. * DID Descriptor Object.
* Contains all the data related to an asset. * Contains all the data related to an asset.
@ -41,7 +41,7 @@ export class DDO {
public updated: string public updated: string
public dtAddress: string public dataToken: string
public publicKey: PublicKey[] = [] public publicKey: PublicKey[] = []
@ -106,8 +106,7 @@ export class DDO {
this.id this.id
] ]
return Web3Provider return Web3Provider.getWeb3()
.getWeb3()
.utils.sha3(values.join('')) .utils.sha3(values.join(''))
.replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1') .replace(/^0x([a-f0-9]{64})(:!.+)?$/i, '0x$1')
} }

View File

@ -1,4 +1,4 @@
import { SearchQuery, QueryResult } from '../metadatastore/MetadataStore' import { SearchQuery } from '../metadatastore/MetadataStore'
import { DDO } from '../ddo/DDO' import { DDO } from '../ddo/DDO'
import { Metadata } from '../ddo/interfaces/Metadata' import { Metadata } from '../ddo/interfaces/Metadata'
import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/interfaces/Service' import { Service, ServiceAccess, ServiceComputePrivacy } from '../ddo/interfaces/Service'
@ -99,7 +99,7 @@ export class Assets extends Instantiable {
// create ddo itself // create ddo itself
const ddo: DDO = new DDO({ const ddo: DDO = new DDO({
id: did.getDid(), id: did.getDid(),
dtAddress: dtAddress, dataToken: dtAddress,
authentication: [ authentication: [
{ {
type: 'RsaSignatureAuthentication2018', type: 'RsaSignatureAuthentication2018',
@ -151,7 +151,6 @@ export class Assets extends Instantiable {
index: indexCount++ index: indexCount++
})) as Service[] })) as Service[]
}) })
this.logger.log('Generating proof') this.logger.log('Generating proof')
observer.next(CreateProgressStep.GeneratingProof) observer.next(CreateProgressStep.GeneratingProof)
await ddo.addProof(this.ocean, publisher.getId(), publisher.getPassword()) await ddo.addProof(this.ocean, publisher.getId(), publisher.getPassword())

View File

@ -3,7 +3,7 @@ import { DataTokens } from '../../src/datatokens/Datatokens'
import { Ocean } from '../../src/ocean/Ocean' import { Ocean } from '../../src/ocean/Ocean'
import config from './config' import config from './config'
// import Accounts from "../../src/ocean/Account" // import Accounts from "../../src/ocean/Account"
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')
@ -50,11 +50,10 @@ describe('Marketplace flow', () => {
marketplace = (await ocean.accounts.list())[3] marketplace = (await ocean.accounts.list())[3]
await contracts.deployContracts(owner.getId()) await contracts.deployContracts(owner.getId())
}) })
it('Alice publishes a datatoken contract', async () => { it('Alice publishes a datatoken contract', async () => {
datatoken = new DataTokens( datatoken = new DataTokens(
contracts.factoryAddress, contracts.factoryAddress,
factory.abi, factory.abi,
datatokensTemplate.abi, datatokensTemplate.abi,
@ -69,29 +68,26 @@ describe('Marketplace flow', () => {
main: { main: {
type: 'dataset', type: 'dataset',
name: 'test-dataset', name: 'test-dataset',
dateCreated: dateCreated: new Date(Date.now()).toISOString().split('.')[0] + 'Z', // remove milliseconds
new Date(Date.now())
.toISOString()
.split('.')[0] + 'Z', // remove milliseconds
author: 'oceanprotocol-team', author: 'oceanprotocol-team',
license: 'MIT', license: 'MIT',
files: [ files: [
{ {
url: 'https://raw.githubusercontent.com/tbertinmahieux/MSongsDB/master/Tasks_Demos/CoverSongs/shs_dataset_test.txt', url:
'https://raw.githubusercontent.com/tbertinmahieux/MSongsDB/master/Tasks_Demos/CoverSongs/shs_dataset_test.txt',
checksum: 'efb2c764274b745f5fc37f97c6b0e761', checksum: 'efb2c764274b745f5fc37f97c6b0e761',
contentLength: '4535431', contentLength: '4535431',
contentType: 'text/csv', contentType: 'text/csv',
encoding: 'UTF-8', encoding: 'UTF-8',
compression: 'zip' compression: 'zip'
} }
] ]
} }
} }
}) })
it('Alice publishes a dataset', async () => { it('Alice publishes a dataset', async () => {
ddo = await ocean.assets.create(asset, alice, [], tokenAddress) ddo = await ocean.assets.create(asset, alice, [], tokenAddress)
}) })
// it('Alice mints 100 tokens', async () => { // it('Alice mints 100 tokens', async () => {

View File

@ -11,10 +11,8 @@ describe('Rinkeby test', () => {
// let contracts // let contracts
// let datatoken // let datatoken
// let tokenAddress // let tokenAddress
// const tokenAmount = 100 // const tokenAmount = 100
// const blob = 'http://localhost:8030/api/v1/provider/services' // const blob = 'http://localhost:8030/api/v1/provider/services'
// describe('#test', () => { // describe('#test', () => {
// it('Initialize Ocean contracts v3', async () => { // it('Initialize Ocean contracts v3', async () => {
// contracts = new TestContractHandler( // contracts = new TestContractHandler(
@ -24,14 +22,11 @@ describe('Rinkeby test', () => {
// factory.bytecode, // factory.bytecode,
// web3 // web3
// ) // )
// const privateKey = 'PRIVATE_KEY' // const privateKey = 'PRIVATE_KEY'
// account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey) // account = web3.eth.accounts.privateKeyToAccount('0x' + privateKey)
// web3.eth.accounts.wallet.add(account) // web3.eth.accounts.wallet.add(account)
// await contracts.deployContracts(account.address) // await contracts.deployContracts(account.address)
// }) // })
// it('Publish a dataset', async () => { // it('Publish a dataset', async () => {
// datatoken = new DataTokens( // datatoken = new DataTokens(
// contracts.factoryAddress, // contracts.factoryAddress,
@ -39,10 +34,8 @@ describe('Rinkeby test', () => {
// datatokensTemplate.abi, // datatokensTemplate.abi,
// web3 // web3
// ) // )
// tokenAddress = await datatoken.create(blob, account.address) // tokenAddress = await datatoken.create(blob, account.address)
// }) // })
// it('Mint 100 tokens', async () => { // it('Mint 100 tokens', async () => {
// await datatoken.mint(tokenAddress, account.address, tokenAmount) // await datatoken.mint(tokenAddress, account.address, tokenAmount)
// }) // })

View File

@ -16,11 +16,9 @@ describe('Simple flow', () => {
// let datatoken // let datatoken
// let tokenAddress // let tokenAddress
// let transactionId // let transactionId
// const tokenAmount = 100 // const tokenAmount = 100
// const transferAmount = 1 // const transferAmount = 1
// const blob = 'http://localhost:8030/api/v1/provider/services' // const blob = 'http://localhost:8030/api/v1/provider/services'
// describe('#test', () => { // describe('#test', () => {
// it('Initialize Ocean contracts v3', async () => { // it('Initialize Ocean contracts v3', async () => {
// contracts = new TestContractHandler( // contracts = new TestContractHandler(
@ -36,7 +34,6 @@ describe('Simple flow', () => {
// bob = contracts.accounts[2] // bob = contracts.accounts[2]
// await contracts.deployContracts(owner) // await contracts.deployContracts(owner)
// }) // })
// it('Alice publishes a dataset', async () => { // it('Alice publishes a dataset', async () => {
// // Alice creates a Datatoken // // Alice creates a Datatoken
// datatoken = new DataTokens( // datatoken = new DataTokens(
@ -47,16 +44,13 @@ describe('Simple flow', () => {
// ) // )
// tokenAddress = await datatoken.create(blob, alice) // tokenAddress = await datatoken.create(blob, alice)
// }) // })
// it('Alice mints 100 tokens', async () => { // it('Alice mints 100 tokens', async () => {
// await 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 () => {
// const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice) // const ts = await datatoken.transfer(tokenAddress, bob, transferAmount, alice)
// transactionId = ts.transactionHash // transactionId = ts.transactionHash
// }) // })
// it('Bob consumes dataset', async () => { // it('Bob consumes dataset', async () => {
// const config = new Config() // const config = new Config()
// const ocean = await Ocean.getInstance(config) // const ocean = await Ocean.getInstance(config)

View File

@ -7,12 +7,9 @@ const Web3 = require('web3')
const web3 = new Web3('http://127.0.0.1:8545') const web3 = new Web3('http://127.0.0.1:8545')
export default { export default {
// metadataStoreUri: 'http://localhost:5000', metadataStoreUri: 'http://localhost:5000',
metadataStoreUri: 'https://aquarius.marketplace.dev-ocean.com', providerUri: 'http://localhost:8030',
providerUri: 'http://127.0.0.1:8030',
nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`, nodeUri: `http://localhost:${process.env.ETH_PORT || 8545}`,
parityUri: 'http://localhost:9545',
secretStoreUri: 'http://localhost:12001',
verbose: LogLevel.Error, verbose: LogLevel.Error,
web3Provider: web3 web3Provider: web3
} as Config } as Config