mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
formatting
This commit is contained in:
parent
ffad644d73
commit
dcdd40bd2d
90
.eslintrc
90
.eslintrc
@ -1,49 +1,49 @@
|
|||||||
{
|
{
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"ecmaFeatures": {
|
"ecmaFeatures": {
|
||||||
"jsx": false
|
"jsx": false
|
||||||
},
|
|
||||||
"project": [
|
|
||||||
"./tsconfig.json",
|
|
||||||
"./test/unit/tsconfig.json",
|
|
||||||
"./test/integration/tsconfig.json"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"extends": [
|
"project": [
|
||||||
"oceanprotocol",
|
"./tsconfig.json",
|
||||||
"prettier/standard",
|
"./test/unit/tsconfig.json",
|
||||||
"plugin:prettier/recommended",
|
"./test/integration/tsconfig.json"
|
||||||
"plugin:@typescript-eslint/recommended",
|
]
|
||||||
"prettier/@typescript-eslint"
|
},
|
||||||
|
"extends": [
|
||||||
|
"oceanprotocol",
|
||||||
|
"prettier/standard",
|
||||||
|
"plugin:prettier/recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"prettier/@typescript-eslint"
|
||||||
|
],
|
||||||
|
"plugins": ["@typescript-eslint", "prettier"],
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/member-delimiter-style": [
|
||||||
|
"error",
|
||||||
|
{ "multiline": { "delimiter": "none" } }
|
||||||
],
|
],
|
||||||
"plugins": ["@typescript-eslint", "prettier"],
|
"@typescript-eslint/ban-ts-ignore": "off",
|
||||||
"rules": {
|
"@typescript-eslint/indent": "off",
|
||||||
"@typescript-eslint/member-delimiter-style": [
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
"error",
|
"@typescript-eslint/no-inferrable-types": "off",
|
||||||
{ "multiline": { "delimiter": "none" } }
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
],
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
"@typescript-eslint/ban-ts-ignore": "off",
|
"@typescript-eslint/explicit-member-accessibility": "off",
|
||||||
"@typescript-eslint/indent": "off",
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
"@typescript-eslint/no-use-before-define": "off",
|
||||||
"@typescript-eslint/no-inferrable-types": "off",
|
"@typescript-eslint/no-object-literal-type-assertion": "off",
|
||||||
"@typescript-eslint/no-non-null-assertion": "off",
|
"@typescript-eslint/no-parameter-properties": "off",
|
||||||
"@typescript-eslint/explicit-function-return-type": "off",
|
"no-empty": ["error", { "allowEmptyCatch": true }],
|
||||||
"@typescript-eslint/explicit-member-accessibility": "off",
|
"prefer-destructuring": ["warn"],
|
||||||
"@typescript-eslint/no-var-requires": "off",
|
"no-dupe-class-members": ["warn"],
|
||||||
"@typescript-eslint/no-use-before-define": "off",
|
"no-useless-constructor": ["warn"],
|
||||||
"@typescript-eslint/no-object-literal-type-assertion": "off",
|
"dot-notation": 0
|
||||||
"@typescript-eslint/no-parameter-properties": "off",
|
},
|
||||||
"no-empty": ["error", { "allowEmptyCatch": true }],
|
"env": {
|
||||||
"prefer-destructuring": ["warn"],
|
"es6": true,
|
||||||
"no-dupe-class-members": ["warn"],
|
"browser": true,
|
||||||
"no-useless-constructor": ["warn"],
|
"mocha": true
|
||||||
"dot-notation": 0
|
}
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"es6": true,
|
|
||||||
"browser": true,
|
|
||||||
"mocha": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ matrix:
|
|||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- npm install -g npm
|
- npm install -g npm
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- git clone https://github.com/oceanprotocol/barge
|
- git clone https://github.com/oceanprotocol/barge
|
||||||
- cd barge
|
- cd barge
|
||||||
|
19
README.md
19
README.md
@ -4,15 +4,16 @@
|
|||||||
|
|
||||||
<h1 align="center">Ocean-lib</h1>
|
<h1 align="center">Ocean-lib</h1>
|
||||||
|
|
||||||
`ocean-lib` is a Javascript library to privately & securely publish, exchange,
|
`ocean-lib` is a Javascript library to privately & securely publish, exchange,
|
||||||
and consume data. With it, you can:
|
and consume data. With it, you can:
|
||||||
* **Publish** data services: downloadable files, streaming data, or compute-to-data.
|
|
||||||
Ocean creates a new [ERC20](https://github.com/ethereum/EIPs/blob/7f4f0377730f5fc266824084188cc17cf246932e/EIPS/eip-20.md)
|
- **Publish** data services: downloadable files, streaming data, or compute-to-data.
|
||||||
data token for each data service or set of services.
|
Ocean creates a new [ERC20](https://github.com/ethereum/EIPs/blob/7f4f0377730f5fc266824084188cc17cf246932e/EIPS/eip-20.md)
|
||||||
* **Mint** data tokens for the service
|
data token for each data service or set of services.
|
||||||
* **Consume** data tokens, to access the service
|
- **Mint** data tokens for the service
|
||||||
* **Transfer** data tokens to another owner, and **all other ERC20 actions**
|
- **Consume** data tokens, to access the service
|
||||||
using [web3.js](https://web3js.readthedocs.io/en/v1.2.9/web3-eth-contract.html) etc.
|
- **Transfer** data tokens to another owner, and **all other ERC20 actions**
|
||||||
|
using [web3.js](https://web3js.readthedocs.io/en/v1.2.9/web3-eth-contract.html) etc.
|
||||||
|
|
||||||
`ocean-lib` is part of the [Ocean Protocol](https://oceanprotocol.com) toolset.
|
`ocean-lib` is part of the [Ocean Protocol](https://oceanprotocol.com) toolset.
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ This is in alpha state and you can expect running into problems. If you run into
|
|||||||
|
|
||||||
## Quick Install
|
## Quick Install
|
||||||
|
|
||||||
```npm i @oceanprotocol/lib```
|
`npm i @oceanprotocol/lib`
|
||||||
|
|
||||||
## Quickstart: Simple Flow
|
## Quickstart: Simple Flow
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
# ocean-lib
|
# ocean-lib
|
||||||
|
|
||||||
`ocean-lib-js` is a Javascript/Typescript library to privately & securely publish, exchange, and consume data. With it, you can:
|
`ocean-lib-js` is a Javascript/Typescript library to privately & securely publish, exchange, and consume data. With it, you can:
|
||||||
* **Publish** data services: static data, streaming data, or compute-to-data. Every data service gets its own [ERC20](https://github.com/ethereum/EIPs/blob/7f4f0377730f5fc266824084188cc17cf246932e/EIPS/eip-20.md) token.
|
|
||||||
* **Mint** data tokens for a given data service
|
- **Publish** data services: static data, streaming data, or compute-to-data. Every data service gets its own [ERC20](https://github.com/ethereum/EIPs/blob/7f4f0377730f5fc266824084188cc17cf246932e/EIPS/eip-20.md) token.
|
||||||
* **Transfer** data tokens to another owner
|
- **Mint** data tokens for a given data service
|
||||||
* **Consume** data tokens, to access the service
|
- **Transfer** data tokens to another owner
|
||||||
|
- **Consume** data tokens, to access the service
|
||||||
|
|
||||||
`ocean-lib-js` is part of the [Ocean Protocol](www.oceanprotocol.com) toolset.
|
`ocean-lib-js` is part of the [Ocean Protocol](www.oceanprotocol.com) toolset.
|
||||||
|
|
||||||
@ -14,6 +14,7 @@
|
|||||||
```
|
```
|
||||||
npm i --save @oceanprotocol/lib
|
npm i --save @oceanprotocol/lib
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -30,6 +31,7 @@ const { Ocean, Logger } = require('@oceanprotocol/lib')
|
|||||||
This section describes a flow with the simplest transfer of value, for static data.
|
This section describes a flow with the simplest transfer of value, for static data.
|
||||||
|
|
||||||
Here's the steps.
|
Here's the steps.
|
||||||
|
|
||||||
1. Alice publishes a dataset (= publishes a datatoken contract)
|
1. Alice publishes a dataset (= publishes a datatoken contract)
|
||||||
1. Alice mints 100 tokens
|
1. Alice mints 100 tokens
|
||||||
1. Alice transfers 1 token to Bob
|
1. Alice transfers 1 token to Bob
|
||||||
@ -37,17 +39,18 @@ Here's the steps.
|
|||||||
|
|
||||||
Let's go through each of these in detail.
|
Let's go through each of these in detail.
|
||||||
|
|
||||||
|
|
||||||
## 1. Alice publishes a dataset (= publishes a datatoken contract)
|
## 1. Alice publishes a dataset (= publishes a datatoken contract)
|
||||||
|
|
||||||
For now, you're Alice:) Let's proceed.
|
For now, you're Alice:) Let's proceed.
|
||||||
|
|
||||||
Run `ganache-cli` locally:
|
Run `ganache-cli` locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ganache-cli
|
ganache-cli
|
||||||
```
|
```
|
||||||
|
|
||||||
Then proceed in with your code:
|
Then proceed in with your code:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const tokenAmount = 100
|
const tokenAmount = 100
|
||||||
const transferAmount = 1
|
const transferAmount = 1
|
||||||
@ -56,10 +59,14 @@ const blob = 'http://localhost:8030/api/v1/provider/services'
|
|||||||
const alice = await ocean.accounts.list()[0]
|
const alice = await ocean.accounts.list()[0]
|
||||||
const bob = await ocean.accounts.list()[0]
|
const bob = await ocean.accounts.list()[0]
|
||||||
// create datatoken class
|
// create datatoken class
|
||||||
const datatoken = new DataTokens(contracts.factoryAddress, factoryABI, datatokensABI, web3)
|
const datatoken = new DataTokens(
|
||||||
|
contracts.factoryAddress,
|
||||||
|
factoryABI,
|
||||||
|
datatokensABI,
|
||||||
|
web3
|
||||||
|
)
|
||||||
// deploy datatoken
|
// deploy datatoken
|
||||||
const tokenAddress = await datatoken.create(blob, alice)
|
const tokenAddress = await datatoken.create(blob, alice)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2. Alice hosts the dataset
|
## 2. Alice hosts the dataset
|
||||||
@ -90,10 +97,8 @@ const transactionId = ts['transactionHash']
|
|||||||
|
|
||||||
Now, you are Bob :)
|
Now, you are Bob :)
|
||||||
|
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
const config = new Config()
|
||||||
const config = new Config()
|
|
||||||
const ocean = await Ocean.getInstance()
|
const ocean = await Ocean.getInstance()
|
||||||
|
|
||||||
await ocean.assets.download(tokenAddress, blob, transactionId, bob)
|
await ocean.assets.download(tokenAddress, blob, transactionId, bob)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user