@@ -37,145 +37,82 @@ This subgraph is deployed under `/subgraphs/name/oceanprotocol/ocean-subgraph/`
37
37
38
38
## ⛵ Example Queries
39
39
40
- ** All pools **
40
+ ** All Data NFTs **
41
41
42
42
``` graphql
43
43
{
44
- pools (orderBy : baseTokenLiquidity , orderDirection : desc ) {
44
+ nfts (orderBy : createdTimestamp , orderDirection : desc , first : 1000 ) {
45
45
id
46
- datatoken {
47
- address
48
- }
49
- baseToken {
50
- symbol
51
- }
52
- baseTokenLiquidity
53
- datatokenLiquidity
46
+ symbol
47
+ name
48
+ creator
49
+ createdTimestamp
54
50
}
55
51
}
56
52
```
57
53
58
- ** Pools with the highest liquidity**
54
+ > Note: 1000 is the maximum number of items the subgraph can return.
55
+
56
+ ** Total Orders for Each User**
59
57
60
58
``` graphql
61
59
{
62
- pools ( where : { datatokenLiquidity_gte : 1 }, orderBy : baseTokenLiquidity , orderDirection : desc , first : 15 ) {
60
+ users ( first : 1000 ) {
63
61
id
64
- datatoken {
65
- address
66
- }
67
- baseToken {
68
- symbol
69
- }
70
- baseTokenLiquidity
71
- datatokenLiquidity
62
+ totalOrders
72
63
}
73
64
}
74
65
```
75
66
76
- ** All Data NFTs **
67
+ ** Total Orders for All Users **
77
68
78
69
``` graphql
79
70
{
80
- nfts (orderBy : createdTimestamp , orderDirection : desc , first : 1000 ){
81
- id ,
82
- symbol ,
83
- name ,
84
- creator ,
85
- createdTimestamp
71
+ users (first : 1000 ) {
72
+ id
73
+ totalOrders
86
74
}
87
75
}
88
76
```
89
77
90
78
> Note: 1000 is the maximum number of items the subgraph can return.
91
79
92
- ** All Datatokens **
80
+ ** Total Orders for a Specific User **
93
81
94
82
``` graphql
95
83
{
96
- tokens ( where : { isDatatoken : true }, orderBy : createdTimestamp , orderDirection : desc , first : 1000 ) {
84
+ user ( id : $user ) {
97
85
id
98
- symbol
99
- name
100
- address
101
- holderCount
86
+ totalOrders
102
87
}
103
88
}
104
89
```
105
90
106
- ** All pool transactions for a given user**
107
-
108
- ``` graphql
109
- {
110
- poolTransactions (
111
- orderBy : timestamp
112
- orderDirection : desc
113
- where : { user : $user }
114
- first : 1000
115
- ) {
116
- baseToken {
117
- symbol
118
- address
119
- }
120
- baseTokenValue
121
- datatoken {
122
- symbol
123
- address
124
- }
125
- datatokenValue
126
- type
127
- tx
128
- timestamp
129
- pool {
130
- datatoken {
131
- id
132
- }
133
- id
134
- }
135
- }
136
- }
137
- ```
138
-
139
91
> Note: all ETH addresses like ` $user ` in above example need to be passed as a lowercase string.
140
92
141
- ** All pool transactions for a given user in an individual pool **
93
+ ** All Orders **
142
94
143
- ``` graphql
95
+ ```
144
96
{
145
- poolTransactions (
146
- orderBy : timestamp
147
- orderDirection : desc
148
- where : { pool : $pool , user : $user }
149
- first : 1000
150
- ) {
151
- baseToken {
152
- symbol
153
- address
154
- }
155
- baseTokenValue
156
- datatoken {
157
- symbol
158
- address
159
- }
160
- datatokenValue
161
- type
162
- tx
163
- timestamp
164
- pool {
165
- datatoken {
166
- id
167
- }
168
- id
169
- }
97
+ orders(orderBy: createdTimestamp, orderDirection: desc, first: 1000){
98
+ amount
99
+ datatoken {
100
+ id
101
+ }
102
+ consumer {
103
+ id
104
+ }
105
+ payer {
106
+ id
170
107
}
171
108
}
109
+ }
172
110
```
173
111
174
- > Note: all ETH addresses like ` $pool ` and ` $user ` in above example need to be passed as a lowercase string .
112
+ > Note: 1000 is the maximum number of items the subgraph can return .
175
113
176
114
## 🏊 Development on Barge
177
115
178
-
179
116
1 . Clone [ barge] ( https://github.com/oceanprotocol/barge ) and run it in another terminal:
180
117
181
118
``` bash
@@ -194,12 +131,14 @@ cd ocean-subgraph
194
131
npm i
195
132
```
196
133
197
- 3 . Let the components know where to pickup the smart contract addresses.
134
+ 3 . Let the components know where to pickup the smart contract addresses.
135
+
198
136
```
199
137
export ADDRESS_FILE="${HOME}/.ocean/ocean-contracts/artifacts/address.json"
200
138
```
201
139
202
140
4 . Generate the subgraphs
141
+
203
142
``` bash
204
143
node ./scripts/generatenetworkssubgraphs.js barge
205
144
npm run codegen
@@ -219,10 +158,8 @@ npm run deploy:local
219
158
220
159
You now have a local graph-node running on http://127.0.0.1:9000/subgraphs/name/oceanprotocol/ocean-subgraph/graphql
221
160
222
-
223
161
## 🏊 Deploying graphs for live networks
224
162
225
-
226
163
1 . Clone the repo and install dependencies:
227
164
228
165
``` bash
@@ -232,16 +169,16 @@ npm i
232
169
```
233
170
234
171
2 . Generate & deploy on rinkeby
172
+
235
173
``` bash
236
174
npm run quickstart:rinkeby
237
175
```
238
176
239
-
240
177
## 🔍 Testing
241
178
242
179
- Please note: the ` npm run test ` command is currently not working due to [ this issue] ( https://github.com/graphprotocol/graph-ts/issues/113 ) .
243
180
244
- 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:
181
+ 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:
245
182
246
183
``` Bash
247
184
export ADDRESS_FILE=" ${HOME} /.ocean/ocean-contracts/artifacts/address.json"
@@ -262,8 +199,8 @@ npm run format
262
199
263
200
## 🛳 Releases
264
201
265
- Releases are managed semi-automatically. They are always manually triggered from a developer's
266
- machine with release scripts. From a clean ` main ` branch you can run the release task bumping
202
+ Releases are managed semi-automatically. They are always manually triggered from a developer's
203
+ machine with release scripts. From a clean ` main ` branch you can run the release task bumping
267
204
the version accordingly based on semantic versioning:
268
205
269
206
``` bash
@@ -310,7 +247,7 @@ You can edit the event handler code and then run `npm run deploy:local`, with so
310
247
- Running deploy will fail if the code has no changes
311
248
- Sometimes deploy will fail no matter what, in this case:
312
249
- Stop the docker-compose run (` docker-compose down ` or Ctrl+C)
313
- This should stop the graph-node, ipfs and postgres containers
250
+ This should stop the graph-node, ipfs and postgres containers
314
251
- Delete the ` ipfs ` and ` postgres ` folders in ` /docker/data ` (` rm -rf ./docker/data/* ` )
315
252
- Run ` docker-compose up ` to restart graph-node, ipfs and postgres
316
253
- Run ` npm run create:local ` to create the ocean-subgraph
0 commit comments