@codex-data/sdk 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +104 -0
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +32 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/resources/graphql.d.ts +7438 -0
  7. package/dist/resources/graphql.d.ts.map +1 -0
  8. package/dist/resources/graphql.js +1314 -0
  9. package/dist/resources/graphql.js.map +1 -0
  10. package/dist/resources/graphql.schema.json +50830 -0
  11. package/dist/resources/graphql.ts +7976 -0
  12. package/dist/resources/schema.graphql +10393 -0
  13. package/dist/sdk/Mutation.d.ts +14 -0
  14. package/dist/sdk/Mutation.d.ts.map +1 -0
  15. package/dist/sdk/Mutation.js +22 -0
  16. package/dist/sdk/Mutation.js.map +1 -0
  17. package/dist/sdk/Query.d.ts +22 -0
  18. package/dist/sdk/Query.d.ts.map +1 -0
  19. package/dist/sdk/Query.js +35 -0
  20. package/dist/sdk/Query.js.map +1 -0
  21. package/dist/sdk/Query.test.d.ts +2 -0
  22. package/dist/sdk/Query.test.d.ts.map +1 -0
  23. package/dist/sdk/Query.test.js +50 -0
  24. package/dist/sdk/Query.test.js.map +1 -0
  25. package/dist/sdk/Subscribe.d.ts +17 -0
  26. package/dist/sdk/Subscribe.d.ts.map +1 -0
  27. package/dist/sdk/Subscribe.js +28 -0
  28. package/dist/sdk/Subscribe.js.map +1 -0
  29. package/dist/sdk/generated/fragment-masking.d.ts +16 -0
  30. package/dist/sdk/generated/fragment-masking.d.ts.map +1 -0
  31. package/dist/sdk/generated/fragment-masking.js +23 -0
  32. package/dist/sdk/generated/fragment-masking.js.map +1 -0
  33. package/dist/sdk/generated/gql.d.ts +243 -0
  34. package/dist/sdk/generated/gql.d.ts.map +1 -0
  35. package/dist/sdk/generated/gql.js +70 -0
  36. package/dist/sdk/generated/gql.js.map +1 -0
  37. package/dist/sdk/generated/graphql.d.ts +11765 -0
  38. package/dist/sdk/generated/graphql.d.ts.map +1 -0
  39. package/dist/sdk/generated/graphql.js +1338 -0
  40. package/dist/sdk/generated/graphql.js.map +1 -0
  41. package/dist/sdk/generated/index.d.ts +3 -0
  42. package/dist/sdk/generated/index.d.ts.map +1 -0
  43. package/dist/sdk/generated/index.js +19 -0
  44. package/dist/sdk/generated/index.js.map +1 -0
  45. package/dist/sdk/index.d.ts +23 -0
  46. package/dist/sdk/index.d.ts.map +1 -0
  47. package/dist/sdk/index.js +76 -0
  48. package/dist/sdk/index.js.map +1 -0
  49. package/dist/sdk/index.test.d.ts +2 -0
  50. package/dist/sdk/index.test.d.ts.map +1 -0
  51. package/dist/sdk/index.test.js +78 -0
  52. package/dist/sdk/index.test.js.map +1 -0
  53. package/dist/sdk/invariant.d.ts +2 -0
  54. package/dist/sdk/invariant.d.ts.map +1 -0
  55. package/dist/sdk/invariant.js +31 -0
  56. package/dist/sdk/invariant.js.map +1 -0
  57. package/package.json +60 -0
  58. package/src/index.ts +2 -0
  59. package/src/resources/.keep +0 -0
  60. package/src/resources/graphql.schema.json +50830 -0
  61. package/src/resources/graphql.ts +7976 -0
  62. package/src/resources/schema.graphql +10393 -0
  63. package/src/sdk/Mutation.ts +15 -0
  64. package/src/sdk/Query.test.ts +40 -0
  65. package/src/sdk/Query.ts +65 -0
  66. package/src/sdk/Subscribe.ts +61 -0
  67. package/src/sdk/generated/fragment-masking.ts +66 -0
  68. package/src/sdk/generated/gql.ts +157 -0
  69. package/src/sdk/generated/graphql.ts +8215 -0
  70. package/src/sdk/generated/index.ts +2 -0
  71. package/src/sdk/graphql/CreateWebhooks.graphql +1145 -0
  72. package/src/sdk/graphql/DeleteWebhooks.graphql +5 -0
  73. package/src/sdk/graphql/FilterExchanges.graphql +23 -0
  74. package/src/sdk/graphql/FilterPairs.graphql +124 -0
  75. package/src/sdk/graphql/FilterTokens.graphql +129 -0
  76. package/src/sdk/graphql/GetBars.graphql +32 -0
  77. package/src/sdk/graphql/GetDetailedPairStats.graphql +941 -0
  78. package/src/sdk/graphql/GetNetworkStatus.graphql +7 -0
  79. package/src/sdk/graphql/GetNetworks.graphql +6 -0
  80. package/src/sdk/graphql/GetPairEvents.graphql +28 -0
  81. package/src/sdk/graphql/GetPrice.graphql +9 -0
  82. package/src/sdk/graphql/GetSparklines.graphql +10 -0
  83. package/src/sdk/graphql/GetSymbol.graphql +11 -0
  84. package/src/sdk/graphql/GetTokens.graphql +14 -0
  85. package/src/sdk/graphql/GetWebhooks.graphql +168 -0
  86. package/src/sdk/graphql/ListPairsForToken.graphql +105 -0
  87. package/src/sdk/graphql/ListTopTokens.graphql +48 -0
  88. package/src/sdk/graphql/OnBarsUpdated.graphql +183 -0
  89. package/src/sdk/graphql/OnDetailedStatsUpdated.graphql +324 -0
  90. package/src/sdk/graphql/OnEventsCreated.graphql +62 -0
  91. package/src/sdk/graphql/OnNftAssetsCreated.graphql +29 -0
  92. package/src/sdk/graphql/OnNftEventsCreated.graphql +83 -0
  93. package/src/sdk/graphql/OnPairMetadataUpdated.graphql +55 -0
  94. package/src/sdk/graphql/OnPriceUpdated.graphql +9 -0
  95. package/src/sdk/index.test.ts +78 -0
  96. package/src/sdk/index.ts +100 -0
  97. package/src/sdk/invariant.ts +34 -0
@@ -0,0 +1,324 @@
1
+ subscription OnDetailedStatsUpdated($pairId: String, $tokenOfInterest: TokenOfInterest, $statsType: TokenPairStatisticsType) {
2
+ onDetailedStatsUpdated(pairId: $pairId, tokenOfInterest: $tokenOfInterest, statsType: $statsType) {
3
+ pairId
4
+ tokenOfInterest
5
+ statsType
6
+ stats_min5 {
7
+ windowSize
8
+ timestamp
9
+ endTimestamp
10
+ transactions {
11
+ change
12
+ currentValue
13
+ previousValue
14
+ buckets
15
+ }
16
+ volume {
17
+ change
18
+ currentValue
19
+ previousValue
20
+ buckets
21
+ }
22
+ buys {
23
+ change
24
+ currentValue
25
+ previousValue
26
+ buckets
27
+ }
28
+ sells {
29
+ change
30
+ currentValue
31
+ previousValue
32
+ buckets
33
+ }
34
+ buyers {
35
+ change
36
+ currentValue
37
+ previousValue
38
+ buckets
39
+ }
40
+ sellers {
41
+ change
42
+ currentValue
43
+ previousValue
44
+ buckets
45
+ }
46
+ traders {
47
+ change
48
+ currentValue
49
+ previousValue
50
+ buckets
51
+ }
52
+ buyVolume {
53
+ change
54
+ currentValue
55
+ previousValue
56
+ buckets
57
+ }
58
+ sellVolume {
59
+ change
60
+ currentValue
61
+ previousValue
62
+ buckets
63
+ }
64
+ buckets {
65
+ start
66
+ end
67
+ }
68
+
69
+ }
70
+ stats_hour1 {
71
+ windowSize
72
+ timestamp
73
+ endTimestamp
74
+ buckets {
75
+ start
76
+ end
77
+ }
78
+ transactions {
79
+ change
80
+ currentValue
81
+ previousValue
82
+ buckets
83
+ }
84
+ volume {
85
+ change
86
+ currentValue
87
+ previousValue
88
+ buckets
89
+ }
90
+ buys {
91
+ change
92
+ currentValue
93
+ previousValue
94
+ buckets
95
+ }
96
+ sells {
97
+ change
98
+ currentValue
99
+ previousValue
100
+ buckets
101
+ }
102
+ buyers {
103
+ change
104
+ currentValue
105
+ previousValue
106
+ buckets
107
+ }
108
+ sellers {
109
+ change
110
+ currentValue
111
+ previousValue
112
+ buckets
113
+ }
114
+ traders {
115
+ change
116
+ currentValue
117
+ previousValue
118
+ buckets
119
+ }
120
+ buyVolume {
121
+ change
122
+ currentValue
123
+ previousValue
124
+ buckets
125
+ }
126
+ sellVolume {
127
+ change
128
+ currentValue
129
+ previousValue
130
+ buckets
131
+ }
132
+ }
133
+ stats_hour4 {
134
+ windowSize
135
+ timestamp
136
+ endTimestamp
137
+ buckets {
138
+ start
139
+ end
140
+ }
141
+ transactions {
142
+ change
143
+ currentValue
144
+ previousValue
145
+ buckets
146
+ }
147
+ volume {
148
+ change
149
+ currentValue
150
+ previousValue
151
+ buckets
152
+ }
153
+ buys {
154
+ change
155
+ currentValue
156
+ previousValue
157
+ buckets
158
+ }
159
+ sells {
160
+ change
161
+ currentValue
162
+ previousValue
163
+ buckets
164
+ }
165
+ buyers {
166
+ change
167
+ currentValue
168
+ previousValue
169
+ buckets
170
+ }
171
+ sellers {
172
+ change
173
+ currentValue
174
+ previousValue
175
+ buckets
176
+ }
177
+ traders {
178
+ change
179
+ currentValue
180
+ previousValue
181
+ buckets
182
+ }
183
+ buyVolume {
184
+ change
185
+ currentValue
186
+ previousValue
187
+ buckets
188
+ }
189
+ sellVolume {
190
+ change
191
+ currentValue
192
+ previousValue
193
+ buckets
194
+ }
195
+
196
+ }
197
+ stats_hour12 {
198
+ windowSize
199
+ timestamp
200
+ endTimestamp
201
+ buckets {
202
+ start
203
+ end
204
+ }
205
+ transactions {
206
+ change
207
+ currentValue
208
+ previousValue
209
+ buckets
210
+ }
211
+ volume {
212
+ change
213
+ currentValue
214
+ previousValue
215
+ buckets
216
+ }
217
+ buys {
218
+ change
219
+ currentValue
220
+ previousValue
221
+ buckets
222
+ }
223
+ sells {
224
+ change
225
+ currentValue
226
+ previousValue
227
+ buckets
228
+ }
229
+ buyers {
230
+ change
231
+ currentValue
232
+ previousValue
233
+ buckets
234
+ }
235
+ sellers {
236
+ change
237
+ currentValue
238
+ previousValue
239
+ buckets
240
+ }
241
+ traders {
242
+ change
243
+ currentValue
244
+ previousValue
245
+ buckets
246
+ }
247
+ buyVolume {
248
+ change
249
+ currentValue
250
+ previousValue
251
+ buckets
252
+ }
253
+ sellVolume {
254
+ change
255
+ currentValue
256
+ previousValue
257
+ buckets
258
+ }
259
+ }
260
+ stats_day1 {
261
+ windowSize
262
+ timestamp
263
+ endTimestamp
264
+ buckets {
265
+ start
266
+ end
267
+ }
268
+ transactions {
269
+ change
270
+ currentValue
271
+ previousValue
272
+ buckets
273
+ }
274
+ volume {
275
+ change
276
+ currentValue
277
+ previousValue
278
+ buckets
279
+ }
280
+ buys {
281
+ change
282
+ currentValue
283
+ previousValue
284
+ buckets
285
+ }
286
+ sells {
287
+ change
288
+ currentValue
289
+ previousValue
290
+ buckets
291
+ }
292
+ buyers {
293
+ change
294
+ currentValue
295
+ previousValue
296
+ buckets
297
+ }
298
+ sellers {
299
+ change
300
+ currentValue
301
+ previousValue
302
+ buckets
303
+ }
304
+ traders {
305
+ change
306
+ currentValue
307
+ previousValue
308
+ buckets
309
+ }
310
+ buyVolume {
311
+ change
312
+ currentValue
313
+ previousValue
314
+ buckets
315
+ }
316
+ sellVolume {
317
+ change
318
+ currentValue
319
+ previousValue
320
+ buckets
321
+ }
322
+ }
323
+ }
324
+ }
@@ -0,0 +1,62 @@
1
+ subscription OnEventsCreated($id: String) {
2
+ onEventsCreated(id: $id) {
3
+ events {
4
+ address
5
+ baseTokenPrice
6
+ blockHash
7
+ blockNumber
8
+ eventDisplayType
9
+ eventType
10
+ logIndex
11
+ id
12
+ liquidityToken
13
+ maker
14
+ networkId
15
+ timestamp
16
+ token0SwapValueUsd
17
+ token0ValueBase
18
+ token1SwapValueUsd
19
+ token1ValueBase
20
+ transactionHash
21
+ transactionIndex
22
+ data {
23
+ ... on MintEventData {
24
+ amount0
25
+ amount1
26
+ amount0Shifted
27
+ amount1Shifted
28
+ tickLower
29
+ tickUpper
30
+ type
31
+ }
32
+ ... on BurnEventData {
33
+ amount0
34
+ amount1
35
+ amount0Shifted
36
+ amount1Shifted
37
+ tickLower
38
+ tickUpper
39
+ type
40
+ }
41
+ ... on SwapEventData {
42
+ amount0
43
+ amount0In
44
+ amount0Out
45
+ amount1
46
+ amount1In
47
+ amount1Out
48
+ amountNonLiquidityToken
49
+ priceBaseToken
50
+ priceBaseTokenTotal
51
+ priceUsd
52
+ priceUsdTotal
53
+ tick
54
+ type
55
+ }
56
+ }
57
+ }
58
+ address
59
+ id
60
+ networkId
61
+ }
62
+ }
@@ -0,0 +1,29 @@
1
+
2
+ subscription OnNftAssetsCreated($address: String, $networkId: Int, $tokenId: String) {
3
+ onNftAssetsCreated(address: $address, networkId: $networkId, tokenId: $tokenId) {
4
+ id
5
+ address
6
+ tokenId
7
+ networkId
8
+ media {
9
+ image
10
+ thumbSm
11
+ thumbLg
12
+ processed
13
+ }
14
+ name
15
+ description
16
+ originalImage
17
+ uri
18
+ attributes {
19
+ class
20
+ css
21
+ displayType
22
+ maxValue
23
+ name
24
+ value
25
+ valueType
26
+ }
27
+ quantity
28
+ }
29
+ }
@@ -0,0 +1,83 @@
1
+ subscription OnNftEventsCreated($address: String, $networkId: Int) {
2
+ onNftEventsCreated(address: $address, networkId: $networkId) {
3
+ address
4
+ networkId
5
+ id
6
+ events {
7
+ id
8
+ contractAddress
9
+ networkId
10
+ tokenId
11
+ maker
12
+ taker
13
+ totalTradePrice
14
+ individualTradePrice
15
+ paymentTokenAddress
16
+ totalPriceUsd
17
+ individualPriceUsd
18
+ totalPriceNetworkBaseToken
19
+ individualPriceNetworkBaseToken
20
+ eventType
21
+ exchangeAddress
22
+ sortKey
23
+ blockNumber
24
+ transactionIndex
25
+ logIndex
26
+ transactionHash
27
+ timestamp
28
+ numberOfTokens
29
+ aggregatorAddress
30
+ poolAddress
31
+ fillSource
32
+ priceError
33
+ tradeOffer {
34
+ ... on NftEventNftTradeItem {
35
+ address
36
+ amount
37
+ recipient
38
+ type
39
+ tokenId
40
+ }
41
+ ... on NftEventTokenTradeItem {
42
+ address
43
+ amount
44
+ recipient
45
+ type
46
+ isPrice
47
+ totalTradePrice
48
+ individualTradePrice
49
+ totalPriceUsd
50
+ individualPriceUsd
51
+ totalPriceNetworkBaseToken
52
+ individualPriceNetworkBaseToken
53
+ priceError
54
+ }
55
+ }
56
+ tradeReceived {
57
+ ... on NftEventNftTradeItem {
58
+ address
59
+ amount
60
+ recipient
61
+ type
62
+ tokenId
63
+
64
+ }
65
+ ... on NftEventTokenTradeItem {
66
+ address
67
+ amount
68
+ recipient
69
+ type
70
+ isPrice
71
+ totalTradePrice
72
+ individualTradePrice
73
+ totalPriceUsd
74
+ individualPriceUsd
75
+ totalPriceNetworkBaseToken
76
+ individualPriceNetworkBaseToken
77
+ priceError
78
+ }
79
+ }
80
+ orderDirection
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,55 @@
1
+ subscription OnPairMetadataUpdated($id: String, $quoteToken: QuoteToken) {
2
+ onPairMetadataUpdated(id: $id, quoteToken: $quoteToken) {
3
+ exchangeId
4
+ fee
5
+ highPrice1
6
+ highPrice1w
7
+ highPrice4
8
+ highPrice12
9
+ highPrice24
10
+ id
11
+ liquidity
12
+ liquidityToken
13
+ lowPrice1
14
+ lowPrice1w
15
+ lowPrice4
16
+ lowPrice12
17
+ lowPrice24
18
+ networkId
19
+ nonLiquidityToken
20
+ pairAddress
21
+ price
22
+ priceChange1
23
+ priceChange1w
24
+ priceChange4
25
+ priceChange5m
26
+ priceChange12
27
+ priceChange24
28
+ quoteToken
29
+ statsType
30
+ tickSpacing
31
+ token0 {
32
+ address
33
+ decimals
34
+ name
35
+ networkId
36
+ pooled
37
+ price
38
+ symbol
39
+ }
40
+ token1 {
41
+ address
42
+ decimals
43
+ name
44
+ networkId
45
+ pooled
46
+ price
47
+ symbol
48
+ }
49
+ volume1
50
+ volume1w
51
+ volume4
52
+ volume12
53
+ volume24
54
+ }
55
+ }
@@ -0,0 +1,9 @@
1
+ subscription OnPriceUpdated($address: String, $networkId: Int) {
2
+ onPriceUpdated(address: $address, networkId: $networkId) {
3
+ address
4
+ confidence
5
+ networkId
6
+ priceUsd
7
+ timestamp
8
+ }
9
+ }
@@ -0,0 +1,78 @@
1
+ import { DocumentNode } from "graphql";
2
+
3
+ import { Codex } from "./index";
4
+
5
+ const getNetworksDocument = {
6
+ kind: "Document",
7
+ definitions: [
8
+ {
9
+ kind: "OperationDefinition",
10
+ operation: "query",
11
+ name: { kind: "Name", value: "Networks" },
12
+ selectionSet: {
13
+ kind: "SelectionSet",
14
+ selections: [
15
+ {
16
+ kind: "Field",
17
+ name: { kind: "Name", value: "getNetworks" },
18
+ selectionSet: {
19
+ kind: "SelectionSet",
20
+ selections: [
21
+ { kind: "Field", name: { kind: "Name", value: "id" } },
22
+ { kind: "Field", name: { kind: "Name", value: "name" } },
23
+ ],
24
+ },
25
+ },
26
+ ],
27
+ },
28
+ },
29
+ ],
30
+ } as unknown as DocumentNode;
31
+
32
+ const getNetworksString = `query GetNetworks { getNetworks { id } }`;
33
+ const subscribePriceUpdatedString = `subscription onPriceUpdated($address: String!, $networkId: Int!) { onPriceUpdated(address: $address, networkId: $networkId) { address networkId priceUsd timestamp } }`;
34
+
35
+ describe("Codex", () => {
36
+ let sdk: Codex;
37
+ beforeEach(() => {
38
+ sdk = new Codex("dummy-key");
39
+ });
40
+
41
+ describe("query", () => {
42
+ it("send a fetch request with the correct params", async () => {
43
+ const fetchSpy = jest
44
+ .spyOn(sdk["client"], "request")
45
+ .mockResolvedValue({} as unknown);
46
+ await sdk.query(getNetworksDocument, {});
47
+ expect(fetchSpy).toHaveBeenCalledWith(getNetworksDocument, {});
48
+ });
49
+ });
50
+ describe("send", () => {
51
+ it("should return the results of the query", async () => {
52
+ const fetchSpy = jest
53
+ .spyOn(sdk["client"], "request")
54
+ .mockResolvedValue({} as unknown);
55
+ await sdk.send(getNetworksString, {});
56
+ expect(fetchSpy).toHaveBeenCalledWith(getNetworksString, {});
57
+ });
58
+ });
59
+ describe("subscribe", () => {
60
+ it("should return a cleanup function", () => {
61
+ const next = jest.fn(),
62
+ error = jest.fn(),
63
+ complete = jest.fn();
64
+ const sink = {
65
+ next,
66
+ error,
67
+ complete,
68
+ };
69
+ jest.spyOn(sdk["wsClient"], "subscribe").mockReturnValue(() => {});
70
+ const cleanup = sdk.subscribe(
71
+ subscribePriceUpdatedString,
72
+ { address: "0xtoken", networkId: 1 },
73
+ sink,
74
+ );
75
+ expect(typeof cleanup).toBe("function");
76
+ });
77
+ });
78
+ });