@0xslots/sdk 0.2.0

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.
package/dist/index.js ADDED
@@ -0,0 +1,449 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ import gql from 'graphql-tag';
3
+
4
+ // src/client.ts
5
+ var GetSlotPurchasesDocument = gql`
6
+ query GetSlotPurchases($first: Int = 100, $skip: Int = 0, $orderBy: SlotPurchase_orderBy, $orderDirection: OrderDirection, $where: SlotPurchase_filter) {
7
+ slotPurchases(
8
+ first: $first
9
+ skip: $skip
10
+ orderBy: $orderBy
11
+ orderDirection: $orderDirection
12
+ where: $where
13
+ ) {
14
+ id
15
+ slot {
16
+ id
17
+ slotId
18
+ land {
19
+ id
20
+ }
21
+ }
22
+ newOccupant
23
+ previousOccupant
24
+ timestamp
25
+ blockNumber
26
+ tx
27
+ }
28
+ }
29
+ `;
30
+ var GetLandOpenedEventsDocument = gql`
31
+ query GetLandOpenedEvents($first: Int = 100, $orderBy: LandOpenedEvent_orderBy, $orderDirection: OrderDirection) {
32
+ landOpenedEvents(
33
+ first: $first
34
+ orderBy: $orderBy
35
+ orderDirection: $orderDirection
36
+ ) {
37
+ id
38
+ land {
39
+ id
40
+ }
41
+ account
42
+ timestamp
43
+ blockNumber
44
+ tx
45
+ }
46
+ }
47
+ `;
48
+ var GetSlotCreatedEventsDocument = gql`
49
+ query GetSlotCreatedEvents($landId: Bytes!, $first: Int = 100) {
50
+ slotCreatedEvents(
51
+ where: {land: $landId}
52
+ first: $first
53
+ orderBy: timestamp
54
+ orderDirection: desc
55
+ ) {
56
+ id
57
+ slot {
58
+ id
59
+ slotId
60
+ }
61
+ land
62
+ slotId
63
+ currency
64
+ basePrice
65
+ price
66
+ taxPercentage
67
+ timestamp
68
+ blockNumber
69
+ tx
70
+ }
71
+ }
72
+ `;
73
+ var GetFlowChangesDocument = gql`
74
+ query GetFlowChanges($first: Int = 100, $where: FlowChange_filter) {
75
+ flowChanges(
76
+ first: $first
77
+ where: $where
78
+ orderBy: timestamp
79
+ orderDirection: desc
80
+ ) {
81
+ id
82
+ from
83
+ to
84
+ oldRate
85
+ newRate
86
+ operation
87
+ timestamp
88
+ blockNumber
89
+ tx
90
+ }
91
+ }
92
+ `;
93
+ var GetHubDocument = gql`
94
+ query GetHub($id: ID!) {
95
+ hub(id: $id) {
96
+ id
97
+ protocolFeeBps
98
+ protocolFeeRecipient
99
+ slotPrice
100
+ defaultCurrency {
101
+ id
102
+ name
103
+ symbol
104
+ decimals
105
+ }
106
+ defaultSlotCount
107
+ defaultPrice
108
+ defaultTaxPercentage
109
+ defaultMaxTaxPercentage
110
+ defaultMinTaxUpdatePeriod
111
+ defaultModule
112
+ }
113
+ }
114
+ `;
115
+ var GetAllowedModulesDocument = gql`
116
+ query GetAllowedModules($hubId: String!) {
117
+ modules(where: {hub: $hubId, allowed: true}) {
118
+ id
119
+ name
120
+ version
121
+ allowed
122
+ }
123
+ }
124
+ `;
125
+ var GetAllowedCurrenciesDocument = gql`
126
+ query GetAllowedCurrencies($hubId: String!) {
127
+ currencies(where: {hub: $hubId, allowed: true}) {
128
+ id
129
+ name
130
+ symbol
131
+ decimals
132
+ underlyingToken
133
+ underlyingName
134
+ underlyingSymbol
135
+ underlyingDecimals
136
+ }
137
+ }
138
+ `;
139
+ var GetLandsDocument = gql`
140
+ query GetLands($first: Int = 100, $skip: Int = 0, $orderBy: Land_orderBy, $orderDirection: OrderDirection) {
141
+ lands(
142
+ first: $first
143
+ skip: $skip
144
+ orderBy: $orderBy
145
+ orderDirection: $orderDirection
146
+ ) {
147
+ id
148
+ owner
149
+ hub {
150
+ id
151
+ }
152
+ createdAt
153
+ createdTx
154
+ }
155
+ }
156
+ `;
157
+ var GetLandDocument = gql`
158
+ query GetLand($id: ID!) {
159
+ land(id: $id) {
160
+ id
161
+ owner
162
+ hub {
163
+ id
164
+ }
165
+ createdAt
166
+ createdTx
167
+ slots {
168
+ id
169
+ slotId
170
+ occupant
171
+ currency
172
+ price
173
+ taxPercentage
174
+ active
175
+ }
176
+ }
177
+ }
178
+ `;
179
+ var GetLandsByOwnerDocument = gql`
180
+ query GetLandsByOwner($owner: Bytes!, $first: Int = 100) {
181
+ lands(where: {owner: $owner}, first: $first) {
182
+ id
183
+ owner
184
+ createdAt
185
+ createdTx
186
+ }
187
+ }
188
+ `;
189
+ var GetSlotsDocument = gql`
190
+ query GetSlots($first: Int = 100, $skip: Int = 0, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $where: Slot_filter) {
191
+ slots(
192
+ first: $first
193
+ skip: $skip
194
+ orderBy: $orderBy
195
+ orderDirection: $orderDirection
196
+ where: $where
197
+ ) {
198
+ id
199
+ land {
200
+ id
201
+ owner
202
+ }
203
+ slotId
204
+ occupant
205
+ currency
206
+ basePrice
207
+ price
208
+ taxPercentage
209
+ maxTaxPercentage
210
+ minTaxUpdatePeriod
211
+ module
212
+ active
213
+ createdAt
214
+ updatedAt
215
+ }
216
+ }
217
+ `;
218
+ var GetSlotDocument = gql`
219
+ query GetSlot($id: ID!) {
220
+ slot(id: $id) {
221
+ id
222
+ land {
223
+ id
224
+ owner
225
+ }
226
+ slotId
227
+ occupant
228
+ currency
229
+ basePrice
230
+ price
231
+ taxPercentage
232
+ maxTaxPercentage
233
+ minTaxUpdatePeriod
234
+ module
235
+ active
236
+ createdAt
237
+ updatedAt
238
+ priceHistory(orderBy: timestamp, orderDirection: desc, first: 10) {
239
+ id
240
+ oldPrice
241
+ newPrice
242
+ timestamp
243
+ tx
244
+ }
245
+ taxUpdates(orderBy: timestamp, orderDirection: desc, first: 10) {
246
+ id
247
+ kind
248
+ oldPercentage
249
+ newPercentage
250
+ confirmableAt
251
+ timestamp
252
+ tx
253
+ }
254
+ }
255
+ }
256
+ `;
257
+ var GetSlotsByOccupantDocument = gql`
258
+ query GetSlotsByOccupant($occupant: Bytes!, $first: Int = 100) {
259
+ slots(where: {occupant: $occupant, active: true}, first: $first) {
260
+ id
261
+ land {
262
+ id
263
+ }
264
+ slotId
265
+ occupant
266
+ price
267
+ taxPercentage
268
+ active
269
+ }
270
+ }
271
+ `;
272
+ var GetAvailableSlotsDocument = gql`
273
+ query GetAvailableSlots($first: Int = 100, $skip: Int = 0) {
274
+ slots(
275
+ where: {occupant: null, active: true}
276
+ first: $first
277
+ skip: $skip
278
+ orderBy: price
279
+ orderDirection: asc
280
+ ) {
281
+ id
282
+ land {
283
+ id
284
+ owner
285
+ }
286
+ slotId
287
+ currency
288
+ price
289
+ taxPercentage
290
+ }
291
+ }
292
+ `;
293
+ var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
294
+ function getSdk(client, withWrapper = defaultWrapper) {
295
+ return {
296
+ GetSlotPurchases(variables, requestHeaders, signal) {
297
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotPurchasesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotPurchases", "query", variables);
298
+ },
299
+ GetLandOpenedEvents(variables, requestHeaders, signal) {
300
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetLandOpenedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetLandOpenedEvents", "query", variables);
301
+ },
302
+ GetSlotCreatedEvents(variables, requestHeaders, signal) {
303
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotCreatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotCreatedEvents", "query", variables);
304
+ },
305
+ GetFlowChanges(variables, requestHeaders, signal) {
306
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetFlowChangesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetFlowChanges", "query", variables);
307
+ },
308
+ GetHub(variables, requestHeaders, signal) {
309
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetHubDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetHub", "query", variables);
310
+ },
311
+ GetAllowedModules(variables, requestHeaders, signal) {
312
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAllowedModulesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAllowedModules", "query", variables);
313
+ },
314
+ GetAllowedCurrencies(variables, requestHeaders, signal) {
315
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAllowedCurrenciesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAllowedCurrencies", "query", variables);
316
+ },
317
+ GetLands(variables, requestHeaders, signal) {
318
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetLandsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetLands", "query", variables);
319
+ },
320
+ GetLand(variables, requestHeaders, signal) {
321
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetLandDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetLand", "query", variables);
322
+ },
323
+ GetLandsByOwner(variables, requestHeaders, signal) {
324
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetLandsByOwnerDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetLandsByOwner", "query", variables);
325
+ },
326
+ GetSlots(variables, requestHeaders, signal) {
327
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlots", "query", variables);
328
+ },
329
+ GetSlot(variables, requestHeaders, signal) {
330
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlot", "query", variables);
331
+ },
332
+ GetSlotsByOccupant(variables, requestHeaders, signal) {
333
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsByOccupantDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotsByOccupant", "query", variables);
334
+ },
335
+ GetAvailableSlots(variables, requestHeaders, signal) {
336
+ return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAvailableSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAvailableSlots", "query", variables);
337
+ }
338
+ };
339
+ }
340
+
341
+ // src/client.ts
342
+ var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
343
+ SlotsChain2[SlotsChain2["BASE_SEPOLIA"] = 84532] = "BASE_SEPOLIA";
344
+ return SlotsChain2;
345
+ })(SlotsChain || {});
346
+ var SUBGRAPH_URLS = {
347
+ [84532 /* BASE_SEPOLIA */]: "https://api.studio.thegraph.com/query/958/0-x-slots-base-sepolia/version/latest"
348
+ };
349
+ var SlotsClient = class {
350
+ /**
351
+ * Create a new SlotsClient instance
352
+ *
353
+ * @param config - Client configuration
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * import { SlotsClient, SlotsChain } from '@0xslots/sdk';
358
+ *
359
+ * const client = new SlotsClient({
360
+ * chainId: SlotsChain.BASE_SEPOLIA,
361
+ * });
362
+ *
363
+ * const hub = await client.getHub({ id: '0x...' });
364
+ * ```
365
+ */
366
+ constructor(config) {
367
+ this.chainId = config.chainId;
368
+ const url = config.subgraphUrl || SUBGRAPH_URLS[config.chainId];
369
+ if (!url) {
370
+ throw new Error(`No subgraph URL configured for chain ${config.chainId}`);
371
+ }
372
+ this.client = new GraphQLClient(url, {
373
+ headers: config.headers
374
+ });
375
+ this.sdk = getSdk(this.client);
376
+ }
377
+ /**
378
+ * Get the current chain ID
379
+ */
380
+ getChainId() {
381
+ return this.chainId;
382
+ }
383
+ /**
384
+ * Get the underlying GraphQL client
385
+ */
386
+ getClient() {
387
+ return this.client;
388
+ }
389
+ /**
390
+ * Get the generated SDK with all typed query methods
391
+ */
392
+ getSdk() {
393
+ return this.sdk;
394
+ }
395
+ // Convenience methods that proxy to the SDK
396
+ // Hub queries
397
+ getHub(...args) {
398
+ return this.sdk.GetHub(...args);
399
+ }
400
+ getAllowedModules(...args) {
401
+ return this.sdk.GetAllowedModules(...args);
402
+ }
403
+ getAllowedCurrencies(...args) {
404
+ return this.sdk.GetAllowedCurrencies(...args);
405
+ }
406
+ // Land queries
407
+ getLands(...args) {
408
+ return this.sdk.GetLands(...args);
409
+ }
410
+ getLand(...args) {
411
+ return this.sdk.GetLand(...args);
412
+ }
413
+ getLandsByOwner(...args) {
414
+ return this.sdk.GetLandsByOwner(...args);
415
+ }
416
+ // Slot queries
417
+ getSlots(...args) {
418
+ return this.sdk.GetSlots(...args);
419
+ }
420
+ getSlot(...args) {
421
+ return this.sdk.GetSlot(...args);
422
+ }
423
+ getSlotsByOccupant(...args) {
424
+ return this.sdk.GetSlotsByOccupant(...args);
425
+ }
426
+ getAvailableSlots(...args) {
427
+ return this.sdk.GetAvailableSlots(...args);
428
+ }
429
+ // Event queries
430
+ getSlotPurchases(...args) {
431
+ return this.sdk.GetSlotPurchases(...args);
432
+ }
433
+ getLandOpenedEvents(...args) {
434
+ return this.sdk.GetLandOpenedEvents(...args);
435
+ }
436
+ getSlotCreatedEvents(...args) {
437
+ return this.sdk.GetSlotCreatedEvents(...args);
438
+ }
439
+ getFlowChanges(...args) {
440
+ return this.sdk.GetFlowChanges(...args);
441
+ }
442
+ };
443
+ function createSlotsClient(config) {
444
+ return new SlotsClient(config);
445
+ }
446
+
447
+ export { GetAllowedCurrenciesDocument, GetAllowedModulesDocument, GetAvailableSlotsDocument, GetFlowChangesDocument, GetHubDocument, GetLandDocument, GetLandOpenedEventsDocument, GetLandsByOwnerDocument, GetLandsDocument, GetSlotCreatedEventsDocument, GetSlotDocument, GetSlotPurchasesDocument, GetSlotsByOccupantDocument, GetSlotsDocument, SUBGRAPH_URLS, SlotsChain, SlotsClient, createSlotsClient, getSdk };
448
+ //# sourceMappingURL=index.js.map
449
+ //# sourceMappingURL=index.js.map