mirror of
https://github.com/oceanprotocol/ocean-subgraph.git
synced 2024-12-02 05:57:29 +01:00
Removing Pool example queries and adding new examples (#493)
This commit is contained in:
parent
1289a085bb
commit
cedd082749
159
README.md
159
README.md
@ -37,51 +37,15 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
|||||||
|
|
||||||
## ⛵ Example Queries
|
## ⛵ Example Queries
|
||||||
|
|
||||||
**All pools**
|
|
||||||
|
|
||||||
```graphql
|
|
||||||
{
|
|
||||||
pools(orderBy: baseTokenLiquidity, orderDirection: desc) {
|
|
||||||
id
|
|
||||||
datatoken {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
baseTokenLiquidity
|
|
||||||
datatokenLiquidity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**Pools with the highest liquidity**
|
|
||||||
|
|
||||||
```graphql
|
|
||||||
{
|
|
||||||
pools(where: {datatokenLiquidity_gte: 1}, orderBy: baseTokenLiquidity, orderDirection: desc, first: 15) {
|
|
||||||
id
|
|
||||||
datatoken {
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
}
|
|
||||||
baseTokenLiquidity
|
|
||||||
datatokenLiquidity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
**All Data NFTs**
|
**All Data NFTs**
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
{
|
{
|
||||||
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
|
nfts(orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
|
||||||
id,
|
id
|
||||||
symbol,
|
symbol
|
||||||
name,
|
name
|
||||||
creator,
|
creator
|
||||||
createdTimestamp
|
createdTimestamp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,93 +53,66 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
|
|||||||
|
|
||||||
> Note: 1000 is the maximum number of items the subgraph can return.
|
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||||
|
|
||||||
**All Datatokens**
|
**Total Orders for Each User**
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
{
|
{
|
||||||
tokens(where: {isDatatoken: true}, orderBy: createdTimestamp, orderDirection: desc, first: 1000) {
|
users(first: 1000) {
|
||||||
id
|
id
|
||||||
symbol
|
totalOrders
|
||||||
name
|
|
||||||
address
|
|
||||||
holderCount
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**All pool transactions for a given user**
|
**Total Orders for All Users**
|
||||||
|
|
||||||
```graphql
|
```graphql
|
||||||
{
|
{
|
||||||
poolTransactions(
|
users(first: 1000) {
|
||||||
orderBy: timestamp
|
id
|
||||||
orderDirection: desc
|
totalOrders
|
||||||
where: { user: $user }
|
|
||||||
first: 1000
|
|
||||||
) {
|
|
||||||
baseToken {
|
|
||||||
symbol
|
|
||||||
address
|
|
||||||
}
|
|
||||||
baseTokenValue
|
|
||||||
datatoken {
|
|
||||||
symbol
|
|
||||||
address
|
|
||||||
}
|
|
||||||
datatokenValue
|
|
||||||
type
|
|
||||||
tx
|
|
||||||
timestamp
|
|
||||||
pool {
|
|
||||||
datatoken {
|
|
||||||
id
|
|
||||||
}
|
|
||||||
id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||||
|
|
||||||
|
**Total Orders for a Specific User**
|
||||||
|
|
||||||
|
```graphql
|
||||||
|
{
|
||||||
|
user(id: $user) {
|
||||||
|
id
|
||||||
|
totalOrders
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note: all ETH addresses like `$user` in above example need to be passed as a lowercase string.
|
> 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**
|
**All Orders**
|
||||||
|
|
||||||
```graphql
|
```
|
||||||
{
|
{
|
||||||
poolTransactions(
|
orders(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
|
||||||
orderBy: timestamp
|
amount
|
||||||
orderDirection: desc
|
datatoken {
|
||||||
where: { pool: $pool, user: $user }
|
id
|
||||||
first: 1000
|
}
|
||||||
) {
|
consumer {
|
||||||
baseToken {
|
id
|
||||||
symbol
|
}
|
||||||
address
|
payer {
|
||||||
}
|
id
|
||||||
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.
|
> Note: 1000 is the maximum number of items the subgraph can return.
|
||||||
|
|
||||||
## 🏊 Development on Barge
|
## 🏊 Development on Barge
|
||||||
|
|
||||||
|
|
||||||
1. Clone [barge](https://github.com/oceanprotocol/barge) and run it in another terminal:
|
1. Clone [barge](https://github.com/oceanprotocol/barge) and run it in another terminal:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -194,12 +131,14 @@ cd ocean-subgraph
|
|||||||
npm i
|
npm i
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Let the components know where to pickup the smart contract addresses.
|
3. Let the components know where to pickup the smart contract addresses.
|
||||||
|
|
||||||
```
|
```
|
||||||
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Generate the subgraphs
|
4. Generate the subgraphs
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
node ./scripts/generatenetworkssubgraphs.js barge
|
node ./scripts/generatenetworkssubgraphs.js barge
|
||||||
npm run codegen
|
npm run codegen
|
||||||
@ -219,10 +158,8 @@ npm run deploy:local
|
|||||||
|
|
||||||
You now have a local graph-node running on http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
|
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
|
## 🏊 Deploying graphs for live networks
|
||||||
|
|
||||||
|
|
||||||
1. Clone the repo and install dependencies:
|
1. Clone the repo and install dependencies:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -232,16 +169,16 @@ npm i
|
|||||||
```
|
```
|
||||||
|
|
||||||
2. Generate & deploy on rinkeby
|
2. Generate & deploy on rinkeby
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run quickstart:rinkeby
|
npm run quickstart:rinkeby
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## 🔍 Testing
|
## 🔍 Testing
|
||||||
|
|
||||||
- Please note: the `npm run test` command is currently not working due to [this issue](https://github.com/graphprotocol/graph-ts/issues/113).
|
- Please note: the `npm run test` command is currently not working due to [this issue](https://github.com/graphprotocol/graph-ts/issues/113).
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
```Bash
|
```Bash
|
||||||
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
|
||||||
@ -262,8 +199,8 @@ npm run format
|
|||||||
|
|
||||||
## 🛳 Releases
|
## 🛳 Releases
|
||||||
|
|
||||||
Releases are managed semi-automatically. They are always manually triggered from a developer's
|
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
|
machine with release scripts. From a clean `main` branch you can run the release task bumping
|
||||||
the version accordingly based on semantic versioning:
|
the version accordingly based on semantic versioning:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -310,7 +247,7 @@ You can edit the event handler code and then run `npm run deploy:local`, with so
|
|||||||
- Running deploy will fail if the code has no changes
|
- Running deploy will fail if the code has no changes
|
||||||
- Sometimes deploy will fail no matter what, in this case:
|
- Sometimes deploy will fail no matter what, in this case:
|
||||||
- Stop the docker-compose run (`docker-compose down` or Ctrl+C)
|
- Stop the docker-compose run (`docker-compose down` or Ctrl+C)
|
||||||
This should stop the graph-node, ipfs and postgres containers
|
This should stop the graph-node, ipfs and postgres containers
|
||||||
- Delete the `ipfs` and `postgres` folders in `/docker/data` (`rm -rf ./docker/data/*`)
|
- 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 `docker-compose up` to restart graph-node, ipfs and postgres
|
||||||
- Run `npm run create:local` to create the ocean-subgraph
|
- Run `npm run create:local` to create the ocean-subgraph
|
||||||
|
Loading…
x
Reference in New Issue
Block a user