3ebc29a74d
* Adding providerFee to Order in the schema * Adding ProviderFee to subgraph.template.yaml * Creating order utils * Saving providerFee as a string * Saving providerFee as an array of all previous provider fees * Creating test for providerFee * Removing arrary from providerFee * Updating or Creating OrderResue provider fee * lint:fix * Creating additional tests for testing providerFees on Order and reuseOrder * lint:fix * Updating JSON string notation * Fixing first test * fixing second test: testing provider fees after calling reuseOrder on a using a previous txId * added providerFeeValidUntil Co-authored-by: mihaisc <mihai@oceanprotocol.com> |
||
---|---|---|
.github | ||
.vscode | ||
abis | ||
docker | ||
scripts | ||
src/mappings | ||
test/integration | ||
.docignore | ||
.dockerignore | ||
.eslintignore | ||
.eslintrc | ||
.gitignore | ||
.nvmrc | ||
.prettierignore | ||
.prettierrc | ||
CHANGELOG.md | ||
docker-entrypoint.sh | ||
Dockerfile | ||
LICENSE | ||
package-lock.json | ||
package.json | ||
README.md | ||
schema.graphql | ||
subgraph.template.yaml | ||
tsconfig.json |
ocean-subgraph
🦀 Ocean Protocol Subgraph
- 🏄 Get Started
- ⛵ Example Queries
- 🏊 Development on barge
- 🏊 Deploying graphs for live networks
- 🔍 Testing
- ✨ Code Style
- 🛳 Releases
- ⬆️ Deployment
- 🏛 License
🏄 Get Started
This subgraph is deployed under /subgraphs/name/oceanprotocol/ocean-subgraph/
namespace for all networks the Ocean Protocol contracts are deployed to:
- v4.subgraph.ropsten.oceanprotocol.com
- v4.subgraph.rinkeby.oceanprotocol.com
- v4.subgraph.mumbai.oceanprotocol.com
- v4.subgraph.moonbase.oceanprotocol.com
⛵ Example Queries
All pools
{
pools(orderBy: baseTokenLiquidity, orderDirection: desc) {
id
datatoken {
address
}
baseToken {
symbol
}
baseTokenLiquidity
datatokenLiquidity
}
}
Pools with the highest liquidity
{
pools(where: {datatokenLiquidity_gte: 1}, orderBy: baseTokenLiquidity, orderDirection: desc, first: 15) {
id
datatoken {
address
}
baseToken {
symbol
}
baseTokenLiquidity
datatokenLiquidity
}
}
All Data NFTs
{
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
id,
symbol,
name,
creator,
createdTimestamp
}
}
Note: 1000 is the maximum number of items the subgraph can return.
All Datatokens
{
tokens(where: {isDatatoken: true}, orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
id
symbol
name
address
holderCount
}
}
All pool transactions for a given user
{
poolTransactions(
orderBy: timestamp
orderDirection: desc
where: { user: $user }
first: 1000
) {
baseToken {
symbol
address
}
baseTokenValue
datatoken {
symbol
address
}
datatokenValue
type
tx
timestamp
pool {
datatoken {
id
}
id
}
}
}
Note: all ETH addresses like
$user
in above example need to be passed as a lowercase string.
All pool transactions for a given user in an individual pool
{
poolTransactions(
orderBy: timestamp
orderDirection: desc
where: { pool: $pool, user: $user }
first: 1000
) {
baseToken {
symbol
address
}
baseTokenValue
datatoken {
symbol
address
}
datatokenValue
type
tx
timestamp
pool {
datatoken {
id
}
id
}
}
}
Note: all ETH addresses like
$pool
and$user
in above example need to be passed as a lowercase string.
🏊 Development on Barge
- Clone barge and run it in another terminal:
git clone https://github.com/oceanprotocol/barge.git
cd barge
./start_ocean.sh --with-thegraph
If you have cloned Barge previously, make sure you are using the latest version by running git pull
.
- Switch back to your main terminal and clone the repo and install dependencies:
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
- Let the components know where to pickup the smart contract addresses.
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
- Generate the subgraphs
node ./scripts/generatenetworkssubgraphs.js barge
npm run codegen
- To deploy a subgraph use:
npm run create:local-barge npm run deploy:local-barge
npm run create:local
npm run deploy:local
- Alternatively, if you want to get the sub-graph quickly running on barge, you can run
npm run quickstart:barge
which combines steps 4-5 above.
You now have a local graph-node running on http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
🏊 Deploying graphs for live networks
- Clone the repo and install dependencies:
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
- Generate & deploy on rinkeby
npm run quickstart:rinkeby
🔍 Testing
- Please note: the
npm run test
command is currently not working due to this issue.
To run the integration tests locally, first start up barge by following the instructions above, then run the following terminal commands from the ocean-subgraph folder:
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
npm run test-integration
✨ 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
andpostgres
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
- Stop the docker-compose run (
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)) 2022 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.