🦀 Ocean Protocol Subgraph
This subgraph is deployed under /subgraphs/name/oceanprotocol/ocean-subgraph/ namespace for all networks the Ocean Protocol contracts are deployed to:
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.
Total Orders for Each User
{
users(first: 1000) {
id
totalOrders
}
}
Total Orders for All Users
{
users(first: 1000) {
id
totalOrders
}
}
Note: 1000 is the maximum number of items the subgraph can return.
Total Orders for a Specific User
{
user(id: $user) {
id
totalOrders
}
}
Note: all ETH addresses like
$userin above example need to be passed as a lowercase string.
All Orders
{
orders(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
amount
datatoken {
id
}
consumer {
id
}
payer {
id
}
}
}
Note: 1000 is the maximum number of items the subgraph can return.
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.
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
node ./scripts/generatenetworkssubgraphs.js barge
npm run codegen
npm run create:local-barge npm run deploy:local-barge
npm run create:local
npm run deploy:local
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
git clone https://github.com/oceanprotocol/ocean-subgraph/
cd ocean-subgraph
npm i
npm run quickstart:rinkeby
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
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 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:
package.json, package-lock.jsonFor the GitHub releases steps a GitHub personal access token, exported as GITHUB_TOKEN is required. Setup
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:
docker-compose down or Ctrl+C)
This should stop the graph-node, ipfs and postgres containersipfs and postgres folders in /docker/data (rm -rf ./docker/data/*)docker-compose up to restart graph-node, ipfs and postgresnpm run create:local to create the ocean-subgraphnpm run deploy:local to deploy the ocean-subgraphTo deploy to one of the remote nodes run by Ocean, you can do port-forwarding and the above
:localcommands will work as is.
Copyright ((C)) 2023 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.
Content type
Image
Digest
sha256:eaff89119…
Size
209.5 MB
Last updated
almost 3 years ago
docker pull oceanprotocol/subgraph