1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
🦑 JavaScript client library for Ocean Protocol
Go to file
2019-06-20 14:54:46 +00:00
.github Standardize contrib guidelines across public repos 2018-11-30 15:34:50 +01:00
integration Create Versions module. 2019-06-14 00:34:53 +02:00
plugins webpack package builder 2018-11-26 15:55:09 +01:00
scripts Improve how is get the version data of the squid. 2019-06-18 12:29:51 +02:00
src Improve how is get the version data of the squid. 2019-06-18 12:29:51 +02:00
test Improve token validation. 2019-05-31 20:41:24 +02:00
.editorconfig included .editorconfig #66 2019-01-07 17:40:04 +01:00
.gitignore Improve how is get the version data of the squid. 2019-06-18 12:29:51 +02:00
.npmignore added doc script 2018-10-10 11:46:02 +02:00
.travis.yml fixed component versions, document local testing 2019-06-12 14:27:13 +02:00
CHANGELOG.md setup release-it workflow 2019-06-20 01:10:32 +02:00
library.json bump required component versions 2019-06-12 11:54:29 +02:00
LICENSE Initial commit 2018-08-20 15:42:24 +02:00
package-lock.json chore(package): update lockfile package-lock.json 2019-06-20 14:54:46 +00:00
package.json fix(package): update @oceanprotocol/keeper-contracts to version 0.10.3 2019-06-20 14:54:41 +00:00
README.md setup release-it workflow 2019-06-20 01:10:32 +02:00
SQUID_INTERFACE.md correct link 2019-02-11 16:43:17 +01:00
tsconfig.json ts-node fix 2019-06-12 14:27:13 +02:00
tslint.json Fix linter errors. 2019-04-25 20:20:24 +02:00
webpack.common.js Add consume support for browsers. 2019-04-09 16:57:16 +02:00
webpack.config.js webpack package builder 2018-11-26 15:55:09 +01:00
webpack.development.js webpack package builder 2018-11-26 15:55:09 +01:00
webpack.parts.js use compiled typescript instead of ts-loader to generate minified versions 2018-11-28 12:12:58 +01:00
webpack.production.js webpack package builder 2018-11-26 15:55:09 +01:00

banner

squid-js

🦑 JavaScript client library for Ocean Protocol oceanprotocol.com

npm Travis (.com) GitHub contributors Codacy Badge js oceanprotocol Greenkeeper badge


🐲🦑 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. 🦑🐲



Get started

Start by adding the package to your dependencies:

npm i @oceanprotocol/squid --save

The package exposes Ocean and Logger which you can import in your code like this:

// ES6
import { Ocean, Logger } from '@oceanprotocol/squid'

// ES2015
const { Ocean, Logger } = require('@oceanprotocol/squid')

You can then connect to a running Keeper & Aquarius instance, e.g.:

const ocean: Ocean = await Ocean.getInstance({
    // the node of the blockchain to connect to, could also be infura
    nodeUri: "http://localhost:8545",
    // the uri of aquarius
    aquariusUri: "http://localhost:5000",
    // the uri of brizo
    brizoUri: "http://localhost:8030",
    // address that brizo uses
    brizoAddress: "0x00bd138abd70e2f00903268f3db08f2d25677c9e"
    // the uri to the parity node you want to use for encryption and decryption
    parityUri: "http://localhost:9545",
    // the uri of the secret store that holds the keys
    secretStoreUri: "http://localhost:12001"
})

Examples

You can see how squid-js is used on:

Documentation

Docs: squid-js API Reference →

Alternatively, you can generate the raw TypeDoc documentation locally by running:

# will output to ./doc folder
npm run doc

Development

To start development you need to:

npm i
npm start

Testing

Unit Tests

For unit tests, running ganache-cli is required before starting the tests:

npm i -g ganache-cli
ganache-cli

To start unit tests, run:

npm test

or to watch for changes:

npm run test:watch

to create code coverage information:

npm run test:cover

Integration Tests

Besides a running ganache-cli instance, a locally running Ocean network is required. To do so before running the tests, use Barge:

git clone https://github.com/oceanprotocol/barge
cd barge

./start_ocean.sh --latest --no-pleuston --local-spree-node

In another terminal window, run this script and export the seed phrase:

# copies the contract artifacts once the local Ocean network is up and running
./scripts/wait_for_migration_and_extract_keeper_artifacts.sh

# export Spree accounts seed phrase
export SEED_WORDS="taxi music thumb unique chat sand crew more leg another off lamp"

Once everything is up, run the integration tests:

npm run integration

to generate code coverage information during test, run:

npm run integration:cover

Production build

To create a production build:

npm run build

Releases

From a clean master branch you can run any release task doing the following:

  • bumps the project version in package.json, package-lock.json
  • auto-generates and updates the CHANGELOG.md file from commit messages
  • creates a Git tag
  • commits and pushes everything
  • creates a GitHub release with commit messages as description
  • Git tag push will trigger Travis to do a npm release

You can execute the script using arguments to bump the version accordingly:

  • To bump a patch version: npm run release
  • To bump a minor version: npm run release minor
  • To bump a major version: npm run release major

For the GitHub releases steps a GitHub personal access token, exported as GITHUB_TOKEN is required. Setup

License

Copyright 2019 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
limitations under the License.