mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
artifacts path fix
This commit is contained in:
parent
68217cf682
commit
ffad644d73
@ -5,6 +5,7 @@ This batteries-included flow includes metadata, multiple services for one datato
|
|||||||
It focuses on Alice's experience as a publisher, and Bob's experience as a buyer & consumer. The rest are services used by Alice and Bob.
|
It focuses on Alice's experience as a publisher, and Bob's experience as a buyer & consumer. The rest are services used by Alice and Bob.
|
||||||
|
|
||||||
Here's the steps.
|
Here's the steps.
|
||||||
|
|
||||||
1. Initialize services
|
1. Initialize services
|
||||||
1. Alice publishes assets for data services (= publishes a datatoken contract and metadata)
|
1. Alice publishes assets for data services (= publishes a datatoken contract and metadata)
|
||||||
1. Alice mints 100 tokens
|
1. Alice mints 100 tokens
|
||||||
@ -18,6 +19,7 @@ Let's go through each step.
|
|||||||
## 0. Installation
|
## 0. Installation
|
||||||
|
|
||||||
If you haven't installed yet:
|
If you haven't installed yet:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i @oceanprotocol/lib
|
npm i @oceanprotocol/lib
|
||||||
```
|
```
|
||||||
@ -38,14 +40,15 @@ export PROVIDER_VERSION=phase2
|
|||||||
## 2. Alice publishes assets for data services (= publishes a datatoken contract)
|
## 2. Alice publishes assets for data services (= publishes a datatoken contract)
|
||||||
|
|
||||||
1. Create DataToken
|
1. Create DataToken
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
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 { Ocean } from '../../src/ocean/Ocean'
|
||||||
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')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
// Alice's config
|
// Alice's config
|
||||||
const config = {
|
const config = {
|
||||||
@ -69,8 +72,8 @@ const data = { t: 1, url: ocean.config.metadataStoreUri }
|
|||||||
const blob = JSON.stringify(data)
|
const blob = JSON.stringify(data)
|
||||||
|
|
||||||
const dataTokenAddress = await datatoken.create(blob, alice.getId())
|
const dataTokenAddress = await datatoken.create(blob, alice.getId())
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Publish asset(s)
|
2. Publish asset(s)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
@ -127,10 +130,10 @@ await datatoken.approve(
|
|||||||
```
|
```
|
||||||
|
|
||||||
## 5. Marketplace posts asset for sale
|
## 5. Marketplace posts asset for sale
|
||||||
|
|
||||||
Now, you're the marketplace:)
|
Now, you're the marketplace:)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
|
||||||
// Market's config
|
// Market's config
|
||||||
const marketOcean = await Ocean.getInstance(config)
|
const marketOcean = await Ocean.getInstance(config)
|
||||||
const marketplace = (await ocean.accounts.list())[1]
|
const marketplace = (await ocean.accounts.list())[1]
|
||||||
@ -145,16 +148,18 @@ assert(accessService.attributes.main.cost * price === 200)
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// Not shown: in marketplace GUI, Bob uses Stripe to send USD to marketplace (or other methods / currencies).
|
// Not shown: in marketplace GUI, Bob uses Stripe to send USD to marketplace (or other methods / currencies).
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 7. Bob uses a service he just purchased (download)
|
## 7. Bob uses a service he just purchased (download)
|
||||||
|
|
||||||
Now, you're Bob:)
|
Now, you're Bob:)
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const accessService = await ocean.assets.getServiceByType(asset.id, 'access')
|
const accessService = await ocean.assets.getServiceByType(asset.id, 'access')
|
||||||
const bob = (await ocean.accounts.list())[2]
|
const bob = (await ocean.accounts.list())[2]
|
||||||
await ocean.assets.order(ddo.id, accessService.type, bob.getId()).then(async (res: string) => {
|
await ocean.assets
|
||||||
|
.order(ddo.id, accessService.type, bob.getId())
|
||||||
|
.then(async (res: string) => {
|
||||||
res = JSON.parse(res)
|
res = JSON.parse(res)
|
||||||
return await datatoken.transfer(
|
return await datatoken.transfer(
|
||||||
res['dataToken'],
|
res['dataToken'],
|
||||||
@ -162,7 +167,8 @@ await ocean.assets.order(ddo.id, accessService.type, bob.getId()).then(async (re
|
|||||||
res['numTokens'],
|
res['numTokens'],
|
||||||
res['from']
|
res['from']
|
||||||
)
|
)
|
||||||
}).then(async (tx) => {
|
})
|
||||||
|
.then(async (tx) => {
|
||||||
await ocean.assets.download(
|
await ocean.assets.download(
|
||||||
ddo.id,
|
ddo.id,
|
||||||
tx.transactionHash,
|
tx.transactionHash,
|
||||||
@ -171,5 +177,4 @@ await ocean.assets.order(ddo.id, accessService.type, bob.getId()).then(async (re
|
|||||||
'~/my-datasets'
|
'~/my-datasets'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
```
|
```
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -880,9 +880,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@oceanprotocol/contracts": {
|
"@oceanprotocol/contracts": {
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.3.3.tgz",
|
"resolved": "https://registry.npmjs.org/@oceanprotocol/contracts/-/contracts-0.3.4.tgz",
|
||||||
"integrity": "sha512-ZQ5RHQWp6xkmATt7Sl12LhnH4dovewgKPX1gGeZoDSyFcmpjMDngtJpDns8jMsaclU61tPScw7K/EmxS1ydiCg=="
|
"integrity": "sha512-fSiWoFs9ewdnsvb81ylu7So66dzftcC2AH8ZhAXxeszK9h9WYSEV+TNoflujuHjQ+f3hnIbhBubyZI0JP24AdQ=="
|
||||||
},
|
},
|
||||||
"@octokit/auth-token": {
|
"@octokit/auth-token": {
|
||||||
"version": "2.4.2",
|
"version": "2.4.2",
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ethereum-navigator/navigator": "^0.5.0",
|
"@ethereum-navigator/navigator": "^0.5.0",
|
||||||
"@oceanprotocol/contracts": "0.3.3",
|
"@oceanprotocol/contracts": "^0.3.4",
|
||||||
"bignumber.js": "^9.0.0",
|
"bignumber.js": "^9.0.0",
|
||||||
"decimal.js": "^10.2.0",
|
"decimal.js": "^10.2.0",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// import * as jsonFactoryABI from './artifacts/SFactory.json'
|
// import * as jsonFactoryABI from './artifacts/SFactory.json'
|
||||||
// import * as jsonPoolABI from './artifacts/SPool.json'
|
// import * as jsonPoolABI from './artifacts/SPool.json'
|
||||||
import * as jsonFactoryABI from '@oceanprotocol/contracts/artifacts/development/SFactory.json'
|
import * as jsonFactoryABI from '@oceanprotocol/contracts/artifacts/SFactory.json'
|
||||||
import * as jsonPoolABI from '@oceanprotocol/contracts/artifacts/development/SPool.json'
|
import * as jsonPoolABI from '@oceanprotocol/contracts/artifacts/SPool.json'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
|
|
||||||
const Decimal = require('decimal.js')
|
const Decimal = require('decimal.js')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const defaultFactoryABI = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const defaultFactoryABI = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const defaultDatatokensABI = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const defaultDatatokensABI = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a interface to DataTokens
|
* Provides a interface to DataTokens
|
||||||
|
@ -6,8 +6,8 @@ import { assert } from 'console'
|
|||||||
import { ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
|
import { ServiceComputePrivacy } from '../../src/ddo/interfaces/Service'
|
||||||
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')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
describe('Compute flow', () => {
|
describe('Compute flow', () => {
|
||||||
let owner
|
let owner
|
||||||
|
@ -6,8 +6,8 @@ import { assert } from 'console'
|
|||||||
|
|
||||||
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')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
describe('Marketplace flow', () => {
|
describe('Marketplace flow', () => {
|
||||||
let owner
|
let owner
|
||||||
|
@ -3,8 +3,8 @@ import { DataTokens } from '../../src/datatokens/Datatokens'
|
|||||||
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const web3 = new Web3('wss://rinkeby.infura.io/ws/v3/357f2fe737db4304bd2f7285c5602d0d')
|
const web3 = new Web3('wss://rinkeby.infura.io/ws/v3/357f2fe737db4304bd2f7285c5602d0d')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
describe('Rinkeby test', () => {
|
describe('Rinkeby test', () => {
|
||||||
// let account
|
// let account
|
||||||
|
@ -5,8 +5,8 @@ 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')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
describe('Simple flow', () => {
|
describe('Simple flow', () => {
|
||||||
let owner
|
let owner
|
||||||
|
@ -3,8 +3,8 @@ import { TestContractHandler } from '../TestContractHandler'
|
|||||||
import { DataTokens } from '../../src/datatokens/Datatokens'
|
import { DataTokens } from '../../src/datatokens/Datatokens'
|
||||||
|
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
const web3 = new Web3('http://127.0.0.1:8545')
|
const web3 = new Web3('http://127.0.0.1:8545')
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@ import { OceanPool } from '../../../src/balancer/OceanPool'
|
|||||||
|
|
||||||
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')
|
||||||
const factory = require('@oceanprotocol/contracts/artifacts/development/DTFactory.json')
|
const factory = require('@oceanprotocol/contracts/artifacts/DTFactory.json')
|
||||||
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/development/DataTokenTemplate.json')
|
const datatokensTemplate = require('@oceanprotocol/contracts/artifacts/DataTokenTemplate.json')
|
||||||
|
|
||||||
// this will be replaced by our SFactory/SPool
|
// this will be replaced by our SFactory/SPool
|
||||||
const OceanPoolFactory = require('@oceanprotocol/contracts/artifacts/development/SFactory.json')
|
const OceanPoolFactory = require('@oceanprotocol/contracts/artifacts/SFactory.json')
|
||||||
const OceanSPool = require('@oceanprotocol/contracts/artifacts/development/SPool.json')
|
const OceanSPool = require('@oceanprotocol/contracts/artifacts/SPool.json')
|
||||||
|
|
||||||
describe('Balancer flow', () => {
|
describe('Balancer flow', () => {
|
||||||
let oceanTokenAddress
|
let oceanTokenAddress
|
||||||
|
Loading…
x
Reference in New Issue
Block a user