Giter VIP home page Giter VIP logo

squid-js's Introduction

banner

Squid-js

๐Ÿฆ‘ JavaScript client library for Ocean Protocol oceanprotocol.com

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


๐Ÿฒ๐Ÿฆ‘ THERE COULD BE DRAGONS AND SQUIDS. If you run into problems, please open up a new issue. ๐Ÿฆ‘๐Ÿฒ



Get started

Start by adding the package to your dependencies:

npm i @oceanprotocol/squid

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 running Keeper, Aquarius, Brizo instances, 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'
})

For an overview of endpoint configurations making up various Ocean networks, please refer to .env.local.example from commons.

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/keeper.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

Code Style

Project follows eslint-config-oceanprotocol. For linting and auto-formatting you can use:

# lint all ts with eslint
npm run lint

# auto format all ts with prettier, taking all configs into account
npm run format

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.

squid-js's People

Contributors

h34d avatar pedro-vk avatar kremalicious avatar greenkeeper[bot] avatar jernejpregelj avatar diminator avatar ssallam avatar jcortejoso avatar ttmc avatar aaitor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.