1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
squid-js/README.md

144 lines
4.2 KiB
Markdown
Raw Normal View History

2018-09-03 10:34:14 +02:00
[![banner](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png)](https://oceanprotocol.com)
2018-09-06 10:01:57 +02:00
# squid-js
2018-09-03 10:34:14 +02:00
2018-09-07 14:38:42 +02:00
> 🦑 JavaScript client library for Ocean Protocol
2018-09-03 10:34:14 +02:00
> [oceanprotocol.com](https://oceanprotocol.com)
[![npm](https://img.shields.io/npm/v/@oceanprotocol/squid.svg)](https://www.npmjs.com/package/@oceanprotocol/squid)
2018-09-06 10:01:57 +02:00
[![Travis (.com)](https://img.shields.io/travis/com/oceanprotocol/squid-js.svg)](https://travis-ci.com/oceanprotocol/squid-js)
[![GitHub contributors](https://img.shields.io/github/contributors/oceanprotocol/squid-js.svg)](https://github.com/oceanprotocol/squid-js/graphs/contributors)
2018-09-10 11:47:02 +02:00
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8508313231b44b0997ec84898cd6f9db)](https://app.codacy.com/app/ocean-protocol/squid-js?utm_source=github.com&utm_medium=referral&utm_content=oceanprotocol/squid-js&utm_campaign=Badge_Grade_Settings)
2018-09-10 10:24:14 +02:00
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
[![Greenkeeper badge](https://badges.greenkeeper.io/oceanprotocol/squid-js.svg)](https://greenkeeper.io/)
2018-09-03 10:34:14 +02:00
---
2018-09-06 10:01:57 +02:00
**🐲🦑 THERE BE DRAGONS AND SQUIDS. This is in alpha state and you can expect running into problems. If you run into them, please open up [a new issue](https://github.com/oceanprotocol/squid-js/issues). 🦑🐲**
2018-09-03 10:34:14 +02:00
---
## Table of Contents
- [Get started](#get-started)
2018-11-20 15:50:02 +01:00
- [Examples](#examples)
- [Development](#development)
- [Production build](#production-build)
- [npm releases](#npm-releases)
2018-09-03 10:56:38 +02:00
- [License](#license)
2018-09-03 10:34:14 +02:00
---
## Get started
Start by adding the package to your dependencies:
```bash
2018-10-18 17:36:55 +02:00
npm i @oceanprotocol/squid --save
```
The package exposes `Ocean` and `Logger` which you can import in your code like this:
```js
// ES6
import { Ocean, Logger } from '@oceanprotocol/squid'
// ES2015
const { Ocean, Logger } = require('@oceanprotocol/squid')
```
2018-10-30 12:09:51 +01:00
You can then connect to a running [Keeper](https://github.com/oceanprotocol/keeper-contracts) & [Aquarius](https://github.com/oceanprotocol/aquarius) instance, e.g.:
```js
2018-11-20 15:50:02 +01:00
const ocean: Ocean = await Ocean.getInstance({
// the node of the blockchain to connect to, could also be infura
2018-11-09 11:20:47 +01:00
nodeUri: "http://localhost:8545",
2018-11-20 15:50:02 +01:00
// the uri of aquarius
2018-11-09 11:20:47 +01:00
aquariusUri: "http://localhost:5000",
2018-11-20 15:50:02 +01:00
// the uri of brizo
brizoUri: "http://localhost:8030",
// the uri to the parity node you want to use for encryption and decryption
2018-11-09 11:20:47 +01:00
parityUri: "http://localhost:9545",
2018-11-20 15:50:02 +01:00
// the uri of the secret store that holds the keys
secretStoreUri: "http://localhost:12001",
// the threshold of nodes from the secre store that have to agree to the decrypt
threshold: 0,
// the password for the account (in the local parity node) used to sign messages for secret store
2018-11-27 13:58:06 +01:00
password: "you password",
2018-11-20 15:50:02 +01:00
// the address of the account (in the local parity node) used to sign messages for secret store
2018-11-09 11:20:47 +01:00
address: "0xed243adfb84a6626eba46178ccb567481c6e655d",
2018-10-30 12:09:51 +01:00
})
```
2018-11-20 15:50:02 +01:00
### Examples
* [Examples](/src/examples/squid)
* [Tuna](https://github.com/oceanprotocol/tuna/examples/squid)
## Development
2018-09-06 17:37:11 +02:00
To start development you need to:
```bash
2018-09-03 10:51:02 +02:00
npm i
npm start
```
2018-11-20 15:50:02 +01:00
### Test
2018-09-06 17:37:11 +02:00
2018-11-20 15:50:02 +01:00
To start unit tests you need to:
```bash
2018-11-20 15:50:02 +01:00
ganache-cli &
npm run test
2018-09-03 10:51:02 +02:00
```
2018-11-20 15:50:02 +01:00
or to watch for changes
2018-09-06 17:44:17 +02:00
```bash
2018-11-20 15:50:02 +01:00
ganache-cli &
npm run test:watch
2018-09-06 17:44:17 +02:00
```
2018-11-20 15:50:02 +01:00
to create code coverage
2018-09-06 17:44:17 +02:00
```bash
2018-11-20 15:50:02 +01:00
ganache-cli &
npm run test:cover
2018-09-06 17:44:17 +02:00
```
2018-11-20 15:50:02 +01:00
This will start a watcher for changes of the code.
2018-09-06 17:44:17 +02:00
2018-11-20 15:50:02 +01:00
### Production build
2018-09-06 17:44:17 +02:00
```bash
2018-11-20 15:50:02 +01:00
npm run build
2018-09-06 17:44:17 +02:00
```
2018-11-20 15:50:02 +01:00
### npm releases
For a new **patch release**, execute on the machine where you're logged into your npm account:
2018-09-06 17:44:17 +02:00
```bash
2018-11-20 15:50:02 +01:00
./bumpversion path
2018-09-06 17:44:17 +02:00
```
2018-11-20 15:50:02 +01:00
git tag with the latest version and `git push`
2018-09-03 10:34:14 +02:00
## License
```
Copyright 2018 Ocean Protocol Foundation Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
2018-09-06 17:44:17 +02:00
limitations under the License.