🦀 Ocean Protocol Subgraph
Go to file
dependabot[bot] 42af9acbe0
Bump eslint-config-prettier from 7.2.0 to 8.0.0 (#37)
* Bump eslint-config-prettier from 7.2.0 to 8.0.0

Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 7.2.0 to 8.0.0.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v7.2.0...v8.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

* update ESLint config

* breaking eslint-config-prettier config merge, see https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md#version-800-2021-02-21

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2021-02-23 16:54:15 +01:00
.github Activate dependabot, build tweaks, green CI (#6) 2021-02-09 11:13:31 +01:00
abis project setup fixes (#1) 2020-12-11 11:37:09 +01:00
docker Activate dependabot, build tweaks, green CI (#6) 2021-02-09 11:13:31 +01:00
src Bump eslint-config-prettier from 7.2.0 to 8.0.0 (#37) 2021-02-23 16:54:15 +01:00
.eslintrc Bump eslint-config-prettier from 7.2.0 to 8.0.0 (#37) 2021-02-23 16:54:15 +01:00
.gitignore Activate dependabot, build tweaks, green CI (#6) 2021-02-09 11:13:31 +01:00
.prettierrc project setup fixes (#1) 2020-12-11 11:37:09 +01:00
CHANGELOG.md add changelog 2020-12-11 11:42:06 +01:00
LICENSE Initial commit 2020-11-19 08:15:23 +01:00
README.md dev instructions tweaks (#27) 2021-02-10 13:03:47 +01:00
package-lock.json Bump eslint-config-prettier from 7.2.0 to 8.0.0 (#37) 2021-02-23 16:54:15 +01:00
package.json Bump eslint-config-prettier from 7.2.0 to 8.0.0 (#37) 2021-02-23 16:54:15 +01:00
schema.graphql Activate dependabot, build tweaks, green CI (#6) 2021-02-09 11:13:31 +01:00
subgraph.polygon.yaml Update subgraph.polygon.yaml (#38) 2021-02-22 20:45:17 +02:00
subgraph.rinkeby.yaml add subgraph config for rinkeby and ropsten testnets, set ocean address based on detected network name 2021-01-20 09:35:53 +01:00
subgraph.ropsten.yaml add subgraph config for rinkeby and ropsten testnets, set ocean address based on detected network name 2021-01-20 09:35:53 +01:00
subgraph.yaml project setup fixes (#1) 2020-12-11 11:37:09 +01:00
tsconfig.json project setup fixes (#1) 2020-12-11 11:37:09 +01:00

README.md

banner

ocean-subgraph

🦀 Ocean Protocol Subgraph

Build Status js oceanprotocol

🏄 Get Started

This subgraph is deployed under /subgraphs/name/oceanprotocol/ocean-subgraph/ namespace for all networks the Ocean Protocol contracts are deployed to:

🧶 Example Queries

All pools

{
  pools(orderBy: oceanReserve, orderDirection: desc) {
    consumePrice
    datatokenReserve
    oceanReserve
    spotPrice
    swapFee
    transactionCount
  }
}

All datatokens

{
  datatokens(orderBy: createTime, orderDirection: desc) {
    address
    symbol
    name
    cap
    supply
    publisher
    holderCount
  }
}

All pool transactions for a given user

{
  poolTransactions(
    where: { userAddressStr: $userAddress }
    orderBy: timestamp
    orderDirection: desc
  ) {
    poolAddressStr
  }
}

Note: all ETH addresses like $userAddress in above example need to be passed in lowercase.

🦑 Development

First, clone the repo and install dependencies:

git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i

Developing and testing any change requires them to be deployed against a locally running graph-node and some other components running in Docker. Make sure you have Docker and Docker Compose installed on your machine, then prepare the Docker setup:

cd docker
./setup.sh

Then add your Infura key as environment variable with a .env file, and start everything up with Docker Compose:

# create .env and modify
cp .env.example .env

docker-compose --env-file .env up

The default network for development is set to Rinkeby. If you want to switch to another network you have to modify the docker/docker-compose.yml file within environment.ethereum.

You now have a local graph-node running and can start deploying your changes to it. To do so, follow the Deployment instructions.

Code Style

For linting and auto-formatting you can use from the root of the project:

# lint all js with eslint
npm run lint

# auto format all js & css with prettier, taking all configs into account
npm run format

🛳 Releases

Releases are managed semi-automatically. They are always manually triggered from a developer's machine with release scripts. From a clean main branch you can run the release task bumping the version accordingly based on semantic versioning:

npm run release

The task does 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

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

⬆️ Deployment

Do the following to deploy the ocean-subgraph to a graph-node running locally, pointed against mainnet:

npm run codegen

# deploy
npm run create:local
npm run deploy:local

To deploy a subgraph connected to Rinkeby or Ropsten test networks, use instead:

# Rinkeby
npm run create:local-rinkeby
npm run deploy:local-rinkeby

# Ropsten
npm run create:local-ropsten
npm run deploy:local-ropsten

You can edit the event handler code and then run npm run deploy:local, with some caveats:

  • Running deploy will fail if the code has no changes
  • Sometimes deploy will fail no matter what, in this case:
    • Stop the docker-compose run (docker-compose down or Ctrl+C) This should stop the graph-node, ipfs and postgres containers
    • Delete the ipfs and postgres folders in /docker/data (rm -rf ./docker/data/*)
    • Run docker-compose up to restart graph-node, ipfs and postgres
    • Run npm run create:local to create the ocean-subgraph
    • Run npm run deploy:local to deploy the ocean-subgraph

To deploy to one of the remote nodes run by Ocean, you can do port-forwarding and the above :local commands will work as is.

🏛 License

Copyright ((C)) 2021 Ocean Protocol Foundation

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.