@0xslots/sdk 0.6.0 → 0.7.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.d.ts +777 -109
- package/dist/index.js +296 -84
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts'
|
|
|
7
7
|
var AccountFieldsFragmentDoc = gql`
|
|
8
8
|
fragment AccountFields on Account {
|
|
9
9
|
id
|
|
10
|
+
type
|
|
10
11
|
slotCount
|
|
11
12
|
occupiedCount
|
|
12
13
|
slotsAsRecipient {
|
|
@@ -17,6 +18,14 @@ var AccountFieldsFragmentDoc = gql`
|
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
20
|
`;
|
|
21
|
+
var CurrencyFieldsFragmentDoc = gql`
|
|
22
|
+
fragment CurrencyFields on Currency {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
symbol
|
|
26
|
+
decimals
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
20
29
|
var SlotFieldsFragmentDoc = gql`
|
|
21
30
|
fragment SlotFields on Slot {
|
|
22
31
|
id
|
|
@@ -26,10 +35,12 @@ var SlotFieldsFragmentDoc = gql`
|
|
|
26
35
|
slotCount
|
|
27
36
|
occupiedCount
|
|
28
37
|
}
|
|
29
|
-
currency
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
currency {
|
|
39
|
+
id
|
|
40
|
+
name
|
|
41
|
+
symbol
|
|
42
|
+
decimals
|
|
43
|
+
}
|
|
33
44
|
manager
|
|
34
45
|
mutableTax
|
|
35
46
|
mutableModule
|
|
@@ -85,6 +96,9 @@ var GetRecentEventsDocument = gql`
|
|
|
85
96
|
slot {
|
|
86
97
|
id
|
|
87
98
|
}
|
|
99
|
+
currency {
|
|
100
|
+
...CurrencyFields
|
|
101
|
+
}
|
|
88
102
|
buyer
|
|
89
103
|
previousOccupant
|
|
90
104
|
price
|
|
@@ -98,6 +112,9 @@ var GetRecentEventsDocument = gql`
|
|
|
98
112
|
slot {
|
|
99
113
|
id
|
|
100
114
|
}
|
|
115
|
+
currency {
|
|
116
|
+
...CurrencyFields
|
|
117
|
+
}
|
|
101
118
|
occupant
|
|
102
119
|
refund
|
|
103
120
|
timestamp
|
|
@@ -108,6 +125,9 @@ var GetRecentEventsDocument = gql`
|
|
|
108
125
|
slot {
|
|
109
126
|
id
|
|
110
127
|
}
|
|
128
|
+
currency {
|
|
129
|
+
...CurrencyFields
|
|
130
|
+
}
|
|
111
131
|
liquidator
|
|
112
132
|
occupant
|
|
113
133
|
bounty
|
|
@@ -119,6 +139,9 @@ var GetRecentEventsDocument = gql`
|
|
|
119
139
|
slot {
|
|
120
140
|
id
|
|
121
141
|
}
|
|
142
|
+
currency {
|
|
143
|
+
...CurrencyFields
|
|
144
|
+
}
|
|
122
145
|
oldPrice
|
|
123
146
|
newPrice
|
|
124
147
|
timestamp
|
|
@@ -129,6 +152,9 @@ var GetRecentEventsDocument = gql`
|
|
|
129
152
|
slot {
|
|
130
153
|
id
|
|
131
154
|
}
|
|
155
|
+
currency {
|
|
156
|
+
...CurrencyFields
|
|
157
|
+
}
|
|
132
158
|
depositor
|
|
133
159
|
amount
|
|
134
160
|
timestamp
|
|
@@ -139,6 +165,9 @@ var GetRecentEventsDocument = gql`
|
|
|
139
165
|
slot {
|
|
140
166
|
id
|
|
141
167
|
}
|
|
168
|
+
currency {
|
|
169
|
+
...CurrencyFields
|
|
170
|
+
}
|
|
142
171
|
occupant
|
|
143
172
|
amount
|
|
144
173
|
timestamp
|
|
@@ -149,6 +178,9 @@ var GetRecentEventsDocument = gql`
|
|
|
149
178
|
slot {
|
|
150
179
|
id
|
|
151
180
|
}
|
|
181
|
+
currency {
|
|
182
|
+
...CurrencyFields
|
|
183
|
+
}
|
|
152
184
|
recipient
|
|
153
185
|
amount
|
|
154
186
|
timestamp
|
|
@@ -189,7 +221,7 @@ var GetRecentEventsDocument = gql`
|
|
|
189
221
|
tx
|
|
190
222
|
}
|
|
191
223
|
}
|
|
192
|
-
`;
|
|
224
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
193
225
|
var GetBoughtEventsDocument = gql`
|
|
194
226
|
query GetBoughtEvents($first: Int!, $skip: Int, $orderBy: BoughtEvent_orderBy, $orderDirection: OrderDirection, $where: BoughtEvent_filter, $block: Block_height) {
|
|
195
227
|
boughtEvents(
|
|
@@ -204,6 +236,9 @@ var GetBoughtEventsDocument = gql`
|
|
|
204
236
|
slot {
|
|
205
237
|
id
|
|
206
238
|
}
|
|
239
|
+
currency {
|
|
240
|
+
...CurrencyFields
|
|
241
|
+
}
|
|
207
242
|
buyer
|
|
208
243
|
previousOccupant
|
|
209
244
|
price
|
|
@@ -214,7 +249,7 @@ var GetBoughtEventsDocument = gql`
|
|
|
214
249
|
tx
|
|
215
250
|
}
|
|
216
251
|
}
|
|
217
|
-
`;
|
|
252
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
218
253
|
var GetReleasedEventsDocument = gql`
|
|
219
254
|
query GetReleasedEvents($first: Int!, $skip: Int, $orderBy: ReleasedEvent_orderBy, $orderDirection: OrderDirection, $where: ReleasedEvent_filter, $block: Block_height) {
|
|
220
255
|
releasedEvents(
|
|
@@ -229,6 +264,9 @@ var GetReleasedEventsDocument = gql`
|
|
|
229
264
|
slot {
|
|
230
265
|
id
|
|
231
266
|
}
|
|
267
|
+
currency {
|
|
268
|
+
...CurrencyFields
|
|
269
|
+
}
|
|
232
270
|
occupant
|
|
233
271
|
refund
|
|
234
272
|
timestamp
|
|
@@ -236,7 +274,7 @@ var GetReleasedEventsDocument = gql`
|
|
|
236
274
|
tx
|
|
237
275
|
}
|
|
238
276
|
}
|
|
239
|
-
`;
|
|
277
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
240
278
|
var GetLiquidatedEventsDocument = gql`
|
|
241
279
|
query GetLiquidatedEvents($first: Int!, $skip: Int, $orderBy: LiquidatedEvent_orderBy, $orderDirection: OrderDirection, $where: LiquidatedEvent_filter, $block: Block_height) {
|
|
242
280
|
liquidatedEvents(
|
|
@@ -251,6 +289,9 @@ var GetLiquidatedEventsDocument = gql`
|
|
|
251
289
|
slot {
|
|
252
290
|
id
|
|
253
291
|
}
|
|
292
|
+
currency {
|
|
293
|
+
...CurrencyFields
|
|
294
|
+
}
|
|
254
295
|
liquidator
|
|
255
296
|
occupant
|
|
256
297
|
bounty
|
|
@@ -259,7 +300,7 @@ var GetLiquidatedEventsDocument = gql`
|
|
|
259
300
|
tx
|
|
260
301
|
}
|
|
261
302
|
}
|
|
262
|
-
`;
|
|
303
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
263
304
|
var GetSettledEventsDocument = gql`
|
|
264
305
|
query GetSettledEvents($first: Int!, $skip: Int, $orderBy: SettledEvent_orderBy, $orderDirection: OrderDirection, $where: SettledEvent_filter, $block: Block_height) {
|
|
265
306
|
settledEvents(
|
|
@@ -274,6 +315,9 @@ var GetSettledEventsDocument = gql`
|
|
|
274
315
|
slot {
|
|
275
316
|
id
|
|
276
317
|
}
|
|
318
|
+
currency {
|
|
319
|
+
...CurrencyFields
|
|
320
|
+
}
|
|
277
321
|
taxOwed
|
|
278
322
|
taxPaid
|
|
279
323
|
depositRemaining
|
|
@@ -282,7 +326,7 @@ var GetSettledEventsDocument = gql`
|
|
|
282
326
|
tx
|
|
283
327
|
}
|
|
284
328
|
}
|
|
285
|
-
`;
|
|
329
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
286
330
|
var GetTaxCollectedEventsDocument = gql`
|
|
287
331
|
query GetTaxCollectedEvents($first: Int!, $skip: Int, $orderBy: TaxCollectedEvent_orderBy, $orderDirection: OrderDirection, $where: TaxCollectedEvent_filter, $block: Block_height) {
|
|
288
332
|
taxCollectedEvents(
|
|
@@ -297,6 +341,9 @@ var GetTaxCollectedEventsDocument = gql`
|
|
|
297
341
|
slot {
|
|
298
342
|
id
|
|
299
343
|
}
|
|
344
|
+
currency {
|
|
345
|
+
...CurrencyFields
|
|
346
|
+
}
|
|
300
347
|
recipient
|
|
301
348
|
amount
|
|
302
349
|
timestamp
|
|
@@ -304,7 +351,7 @@ var GetTaxCollectedEventsDocument = gql`
|
|
|
304
351
|
tx
|
|
305
352
|
}
|
|
306
353
|
}
|
|
307
|
-
`;
|
|
354
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
308
355
|
var GetDepositedEventsDocument = gql`
|
|
309
356
|
query GetDepositedEvents($first: Int!, $skip: Int, $orderBy: DepositedEvent_orderBy, $orderDirection: OrderDirection, $where: DepositedEvent_filter, $block: Block_height) {
|
|
310
357
|
depositedEvents(
|
|
@@ -319,6 +366,9 @@ var GetDepositedEventsDocument = gql`
|
|
|
319
366
|
slot {
|
|
320
367
|
id
|
|
321
368
|
}
|
|
369
|
+
currency {
|
|
370
|
+
...CurrencyFields
|
|
371
|
+
}
|
|
322
372
|
depositor
|
|
323
373
|
amount
|
|
324
374
|
timestamp
|
|
@@ -326,7 +376,7 @@ var GetDepositedEventsDocument = gql`
|
|
|
326
376
|
tx
|
|
327
377
|
}
|
|
328
378
|
}
|
|
329
|
-
`;
|
|
379
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
330
380
|
var GetWithdrawnEventsDocument = gql`
|
|
331
381
|
query GetWithdrawnEvents($first: Int!, $skip: Int, $orderBy: WithdrawnEvent_orderBy, $orderDirection: OrderDirection, $where: WithdrawnEvent_filter, $block: Block_height) {
|
|
332
382
|
withdrawnEvents(
|
|
@@ -341,6 +391,9 @@ var GetWithdrawnEventsDocument = gql`
|
|
|
341
391
|
slot {
|
|
342
392
|
id
|
|
343
393
|
}
|
|
394
|
+
currency {
|
|
395
|
+
...CurrencyFields
|
|
396
|
+
}
|
|
344
397
|
occupant
|
|
345
398
|
amount
|
|
346
399
|
timestamp
|
|
@@ -348,7 +401,7 @@ var GetWithdrawnEventsDocument = gql`
|
|
|
348
401
|
tx
|
|
349
402
|
}
|
|
350
403
|
}
|
|
351
|
-
`;
|
|
404
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
352
405
|
var GetPriceUpdatedEventsDocument = gql`
|
|
353
406
|
query GetPriceUpdatedEvents($first: Int!, $skip: Int, $orderBy: PriceUpdatedEvent_orderBy, $orderDirection: OrderDirection, $where: PriceUpdatedEvent_filter, $block: Block_height) {
|
|
354
407
|
priceUpdatedEvents(
|
|
@@ -363,6 +416,9 @@ var GetPriceUpdatedEventsDocument = gql`
|
|
|
363
416
|
slot {
|
|
364
417
|
id
|
|
365
418
|
}
|
|
419
|
+
currency {
|
|
420
|
+
...CurrencyFields
|
|
421
|
+
}
|
|
366
422
|
oldPrice
|
|
367
423
|
newPrice
|
|
368
424
|
timestamp
|
|
@@ -370,7 +426,7 @@ var GetPriceUpdatedEventsDocument = gql`
|
|
|
370
426
|
tx
|
|
371
427
|
}
|
|
372
428
|
}
|
|
373
|
-
`;
|
|
429
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
374
430
|
var GetSlotActivityDocument = gql`
|
|
375
431
|
query GetSlotActivity($slotId: String!, $first: Int!) {
|
|
376
432
|
boughtEvents(
|
|
@@ -380,6 +436,9 @@ var GetSlotActivityDocument = gql`
|
|
|
380
436
|
where: {slot: $slotId}
|
|
381
437
|
) {
|
|
382
438
|
id
|
|
439
|
+
currency {
|
|
440
|
+
...CurrencyFields
|
|
441
|
+
}
|
|
383
442
|
buyer
|
|
384
443
|
previousOccupant
|
|
385
444
|
price
|
|
@@ -395,6 +454,9 @@ var GetSlotActivityDocument = gql`
|
|
|
395
454
|
where: {slot: $slotId}
|
|
396
455
|
) {
|
|
397
456
|
id
|
|
457
|
+
currency {
|
|
458
|
+
...CurrencyFields
|
|
459
|
+
}
|
|
398
460
|
occupant
|
|
399
461
|
refund
|
|
400
462
|
timestamp
|
|
@@ -407,6 +469,9 @@ var GetSlotActivityDocument = gql`
|
|
|
407
469
|
where: {slot: $slotId}
|
|
408
470
|
) {
|
|
409
471
|
id
|
|
472
|
+
currency {
|
|
473
|
+
...CurrencyFields
|
|
474
|
+
}
|
|
410
475
|
liquidator
|
|
411
476
|
occupant
|
|
412
477
|
bounty
|
|
@@ -420,6 +485,9 @@ var GetSlotActivityDocument = gql`
|
|
|
420
485
|
where: {slot: $slotId}
|
|
421
486
|
) {
|
|
422
487
|
id
|
|
488
|
+
currency {
|
|
489
|
+
...CurrencyFields
|
|
490
|
+
}
|
|
423
491
|
oldPrice
|
|
424
492
|
newPrice
|
|
425
493
|
timestamp
|
|
@@ -432,6 +500,9 @@ var GetSlotActivityDocument = gql`
|
|
|
432
500
|
where: {slot: $slotId}
|
|
433
501
|
) {
|
|
434
502
|
id
|
|
503
|
+
currency {
|
|
504
|
+
...CurrencyFields
|
|
505
|
+
}
|
|
435
506
|
depositor
|
|
436
507
|
amount
|
|
437
508
|
timestamp
|
|
@@ -444,6 +515,9 @@ var GetSlotActivityDocument = gql`
|
|
|
444
515
|
where: {slot: $slotId}
|
|
445
516
|
) {
|
|
446
517
|
id
|
|
518
|
+
currency {
|
|
519
|
+
...CurrencyFields
|
|
520
|
+
}
|
|
447
521
|
occupant
|
|
448
522
|
amount
|
|
449
523
|
timestamp
|
|
@@ -456,6 +530,9 @@ var GetSlotActivityDocument = gql`
|
|
|
456
530
|
where: {slot: $slotId}
|
|
457
531
|
) {
|
|
458
532
|
id
|
|
533
|
+
currency {
|
|
534
|
+
...CurrencyFields
|
|
535
|
+
}
|
|
459
536
|
recipient
|
|
460
537
|
amount
|
|
461
538
|
timestamp
|
|
@@ -494,7 +571,7 @@ var GetSlotActivityDocument = gql`
|
|
|
494
571
|
tx
|
|
495
572
|
}
|
|
496
573
|
}
|
|
497
|
-
`;
|
|
574
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
498
575
|
var GetFactoryDocument = gql`
|
|
499
576
|
query GetFactory {
|
|
500
577
|
factories(first: 1) {
|
|
@@ -621,6 +698,19 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
621
698
|
}
|
|
622
699
|
};
|
|
623
700
|
}
|
|
701
|
+
|
|
702
|
+
// src/errors.ts
|
|
703
|
+
var SlotsError = class extends Error {
|
|
704
|
+
constructor(operation, cause) {
|
|
705
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
706
|
+
super(`${operation}: ${msg}`);
|
|
707
|
+
this.operation = operation;
|
|
708
|
+
this.name = "SlotsError";
|
|
709
|
+
this.cause = cause;
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
|
|
713
|
+
// src/client.ts
|
|
624
714
|
var META_QUERY = gql$1`
|
|
625
715
|
query GetMeta {
|
|
626
716
|
_meta {
|
|
@@ -654,12 +744,15 @@ var SlotsClient = class {
|
|
|
654
744
|
this.sdk = getSdk(this.gqlClient);
|
|
655
745
|
}
|
|
656
746
|
// ─── Accessors ──────────────────────────────────────────────────────────────
|
|
747
|
+
/** Returns the chain ID this client was configured for. */
|
|
657
748
|
getChainId() {
|
|
658
749
|
return this.chainId;
|
|
659
750
|
}
|
|
751
|
+
/** Returns the underlying GraphQL client (for advanced usage). */
|
|
660
752
|
getClient() {
|
|
661
753
|
return this.gqlClient;
|
|
662
754
|
}
|
|
755
|
+
/** Returns the generated GraphQL SDK (for queries not wrapped by this client). */
|
|
663
756
|
getSdk() {
|
|
664
757
|
return this.sdk;
|
|
665
758
|
}
|
|
@@ -680,111 +773,171 @@ var SlotsClient = class {
|
|
|
680
773
|
if (!account) throw new Error("WalletClient must have an account");
|
|
681
774
|
return account.address;
|
|
682
775
|
}
|
|
776
|
+
get chain() {
|
|
777
|
+
const chain = this.wallet.chain;
|
|
778
|
+
if (!chain) throw new Error("WalletClient must have a chain");
|
|
779
|
+
return chain;
|
|
780
|
+
}
|
|
781
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
782
|
+
assertPositive(value, name) {
|
|
783
|
+
if (value <= 0n) throw new SlotsError(name, `${name} must be > 0`);
|
|
784
|
+
}
|
|
785
|
+
async query(operation, fn) {
|
|
786
|
+
try {
|
|
787
|
+
return await fn();
|
|
788
|
+
} catch (error) {
|
|
789
|
+
throw new SlotsError(operation, error);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
683
792
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
684
793
|
// READ — Subgraph Queries
|
|
685
794
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
686
795
|
// Slot queries
|
|
796
|
+
/** Fetch a paginated list of slots. */
|
|
687
797
|
getSlots(...args) {
|
|
688
|
-
return this.sdk.GetSlots(...args);
|
|
798
|
+
return this.query("getSlots", () => this.sdk.GetSlots(...args));
|
|
689
799
|
}
|
|
800
|
+
/** Fetch a single slot by its address. */
|
|
690
801
|
getSlot(...args) {
|
|
691
|
-
return this.sdk.GetSlot(...args);
|
|
802
|
+
return this.query("getSlot", () => this.sdk.GetSlot(...args));
|
|
692
803
|
}
|
|
804
|
+
/** Fetch all slots owned by a given recipient address. */
|
|
693
805
|
getSlotsByRecipient(...args) {
|
|
694
|
-
return this.sdk.GetSlotsByRecipient(...args);
|
|
806
|
+
return this.query("getSlotsByRecipient", () => this.sdk.GetSlotsByRecipient(...args));
|
|
695
807
|
}
|
|
808
|
+
/** Fetch all slots currently occupied by a given address. */
|
|
696
809
|
getSlotsByOccupant(...args) {
|
|
697
|
-
return this.sdk.GetSlotsByOccupant(...args);
|
|
810
|
+
return this.query("getSlotsByOccupant", () => this.sdk.GetSlotsByOccupant(...args));
|
|
698
811
|
}
|
|
699
812
|
// Factory queries
|
|
813
|
+
/** Fetch factory configuration. */
|
|
700
814
|
getFactory() {
|
|
701
|
-
return this.sdk.GetFactory();
|
|
815
|
+
return this.query("getFactory", () => this.sdk.GetFactory());
|
|
702
816
|
}
|
|
817
|
+
/** Fetch registered modules. */
|
|
703
818
|
getModules(...args) {
|
|
704
|
-
return this.sdk.GetModules(...args);
|
|
819
|
+
return this.query("getModules", () => this.sdk.GetModules(...args));
|
|
705
820
|
}
|
|
706
821
|
// Event queries
|
|
822
|
+
/** Fetch bought events with optional filters. */
|
|
707
823
|
getBoughtEvents(...args) {
|
|
708
|
-
return this.sdk.GetBoughtEvents(...args);
|
|
824
|
+
return this.query("getBoughtEvents", () => this.sdk.GetBoughtEvents(...args));
|
|
709
825
|
}
|
|
826
|
+
/** Fetch settled events with optional filters. */
|
|
710
827
|
getSettledEvents(...args) {
|
|
711
|
-
return this.sdk.GetSettledEvents(...args);
|
|
828
|
+
return this.query("getSettledEvents", () => this.sdk.GetSettledEvents(...args));
|
|
712
829
|
}
|
|
830
|
+
/** Fetch tax-collected events with optional filters. */
|
|
713
831
|
getTaxCollectedEvents(...args) {
|
|
714
|
-
return this.sdk.GetTaxCollectedEvents(...args);
|
|
832
|
+
return this.query("getTaxCollectedEvents", () => this.sdk.GetTaxCollectedEvents(...args));
|
|
715
833
|
}
|
|
834
|
+
/** Fetch all activity for a specific slot (all event types). */
|
|
716
835
|
getSlotActivity(...args) {
|
|
717
|
-
return this.sdk.GetSlotActivity(...args);
|
|
836
|
+
return this.query("getSlotActivity", () => this.sdk.GetSlotActivity(...args));
|
|
718
837
|
}
|
|
838
|
+
/** Fetch the most recent events across all slots. */
|
|
719
839
|
getRecentEvents(...args) {
|
|
720
|
-
return this.sdk.GetRecentEvents(...args);
|
|
840
|
+
return this.query("getRecentEvents", () => this.sdk.GetRecentEvents(...args));
|
|
721
841
|
}
|
|
722
842
|
// Account queries
|
|
843
|
+
/** Fetch a single account by address. */
|
|
723
844
|
getAccount(...args) {
|
|
724
|
-
return this.sdk.GetAccount(...args);
|
|
845
|
+
return this.query("getAccount", () => this.sdk.GetAccount(...args));
|
|
725
846
|
}
|
|
847
|
+
/** Fetch a paginated list of accounts. */
|
|
726
848
|
getAccounts(...args) {
|
|
727
|
-
return this.sdk.GetAccounts(...args);
|
|
849
|
+
return this.query("getAccounts", () => this.sdk.GetAccounts(...args));
|
|
728
850
|
}
|
|
729
851
|
// Individual event queries
|
|
852
|
+
/** Fetch released events with optional filters. */
|
|
730
853
|
getReleasedEvents(...args) {
|
|
731
|
-
return this.sdk.GetReleasedEvents(...args);
|
|
854
|
+
return this.query("getReleasedEvents", () => this.sdk.GetReleasedEvents(...args));
|
|
732
855
|
}
|
|
856
|
+
/** Fetch liquidated events with optional filters. */
|
|
733
857
|
getLiquidatedEvents(...args) {
|
|
734
|
-
return this.sdk.GetLiquidatedEvents(...args);
|
|
858
|
+
return this.query("getLiquidatedEvents", () => this.sdk.GetLiquidatedEvents(...args));
|
|
735
859
|
}
|
|
860
|
+
/** Fetch deposited events with optional filters. */
|
|
736
861
|
getDepositedEvents(...args) {
|
|
737
|
-
return this.sdk.GetDepositedEvents(...args);
|
|
862
|
+
return this.query("getDepositedEvents", () => this.sdk.GetDepositedEvents(...args));
|
|
738
863
|
}
|
|
864
|
+
/** Fetch withdrawn events with optional filters. */
|
|
739
865
|
getWithdrawnEvents(...args) {
|
|
740
|
-
return this.sdk.GetWithdrawnEvents(...args);
|
|
866
|
+
return this.query("getWithdrawnEvents", () => this.sdk.GetWithdrawnEvents(...args));
|
|
741
867
|
}
|
|
868
|
+
/** Fetch price-updated events with optional filters. */
|
|
742
869
|
getPriceUpdatedEvents(...args) {
|
|
743
|
-
return this.sdk.GetPriceUpdatedEvents(...args);
|
|
870
|
+
return this.query("getPriceUpdatedEvents", () => this.sdk.GetPriceUpdatedEvents(...args));
|
|
744
871
|
}
|
|
745
872
|
// Meta
|
|
873
|
+
/** Fetch subgraph indexing metadata (latest block, indexing errors). */
|
|
746
874
|
getMeta() {
|
|
747
|
-
return this.gqlClient.request(META_QUERY);
|
|
875
|
+
return this.query("getMeta", () => this.gqlClient.request(META_QUERY));
|
|
748
876
|
}
|
|
749
877
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
750
878
|
// READ — On-chain (RPC)
|
|
751
879
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
752
|
-
/**
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
880
|
+
/**
|
|
881
|
+
* Read full slot info from on-chain (RPC, not subgraph).
|
|
882
|
+
* @param slot - Slot contract address.
|
|
883
|
+
* @returns On-chain slot info tuple.
|
|
884
|
+
* @throws {SlotsError} If the RPC call fails.
|
|
885
|
+
*/
|
|
886
|
+
getSlotInfo(slot) {
|
|
887
|
+
return this.query(
|
|
888
|
+
"getSlotInfo",
|
|
889
|
+
() => this.publicClient.readContract({
|
|
890
|
+
address: slot,
|
|
891
|
+
abi: slotAbi,
|
|
892
|
+
functionName: "getSlotInfo"
|
|
893
|
+
})
|
|
894
|
+
);
|
|
759
895
|
}
|
|
760
896
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
761
897
|
// WRITE — Factory Functions
|
|
762
898
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
899
|
+
/**
|
|
900
|
+
* Deploy a new slot via the factory contract.
|
|
901
|
+
* @param params - Slot creation parameters (recipient, currency, config, initParams).
|
|
902
|
+
* @returns Transaction hash.
|
|
903
|
+
*/
|
|
763
904
|
async createSlot(params) {
|
|
764
905
|
return this.wallet.writeContract({
|
|
765
906
|
address: this.factory,
|
|
766
907
|
abi: slotFactoryAbi,
|
|
767
908
|
functionName: "createSlot",
|
|
768
909
|
args: [params.recipient, params.currency, params.config, params.initParams],
|
|
769
|
-
account: this.
|
|
770
|
-
chain: this.
|
|
910
|
+
account: this.account,
|
|
911
|
+
chain: this.chain
|
|
771
912
|
});
|
|
772
913
|
}
|
|
914
|
+
/**
|
|
915
|
+
* Deploy multiple identical slots in a single transaction via the factory contract.
|
|
916
|
+
* @param params - Slot creation parameters including count.
|
|
917
|
+
* @returns Transaction hash.
|
|
918
|
+
*/
|
|
773
919
|
async createSlots(params) {
|
|
774
920
|
return this.wallet.writeContract({
|
|
775
921
|
address: this.factory,
|
|
776
922
|
abi: slotFactoryAbi,
|
|
777
923
|
functionName: "createSlots",
|
|
778
924
|
args: [params.recipient, params.currency, params.config, params.initParams, params.count],
|
|
779
|
-
account: this.
|
|
780
|
-
chain: this.
|
|
925
|
+
account: this.account,
|
|
926
|
+
chain: this.chain
|
|
781
927
|
});
|
|
782
928
|
}
|
|
783
929
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
784
930
|
// WRITE — Slot Functions
|
|
785
931
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
786
|
-
/**
|
|
932
|
+
/**
|
|
933
|
+
* Buy a slot (or force-buy an occupied one). Handles ERC-20 approval automatically.
|
|
934
|
+
* @param params - Buy parameters (slot address, deposit amount, self-assessed price).
|
|
935
|
+
* @returns Transaction hash.
|
|
936
|
+
* @throws {SlotsError} If depositAmount or selfAssessedPrice is not positive, or the transaction fails.
|
|
937
|
+
*/
|
|
787
938
|
async buy(params) {
|
|
939
|
+
this.assertPositive(params.depositAmount, "depositAmount");
|
|
940
|
+
this.assertPositive(params.selfAssessedPrice, "selfAssessedPrice");
|
|
788
941
|
return this.withAllowance(params.slot, params.depositAmount, {
|
|
789
942
|
to: params.slot,
|
|
790
943
|
abi: slotAbi,
|
|
@@ -792,19 +945,31 @@ var SlotsClient = class {
|
|
|
792
945
|
args: [params.depositAmount, params.selfAssessedPrice]
|
|
793
946
|
});
|
|
794
947
|
}
|
|
795
|
-
/**
|
|
948
|
+
/**
|
|
949
|
+
* Self-assess a new price for an occupied slot (occupant only).
|
|
950
|
+
* @param slot - The slot contract address.
|
|
951
|
+
* @param newPrice - The new self-assessed price (can be 0).
|
|
952
|
+
* @returns Transaction hash.
|
|
953
|
+
*/
|
|
796
954
|
async selfAssess(slot, newPrice) {
|
|
797
955
|
return this.wallet.writeContract({
|
|
798
956
|
address: slot,
|
|
799
957
|
abi: slotAbi,
|
|
800
958
|
functionName: "selfAssess",
|
|
801
959
|
args: [newPrice],
|
|
802
|
-
account: this.
|
|
803
|
-
chain: this.
|
|
960
|
+
account: this.account,
|
|
961
|
+
chain: this.chain
|
|
804
962
|
});
|
|
805
963
|
}
|
|
806
|
-
/**
|
|
964
|
+
/**
|
|
965
|
+
* Top up deposit on a slot (occupant only). Handles ERC-20 approval automatically.
|
|
966
|
+
* @param slot - The slot contract address.
|
|
967
|
+
* @param amount - The amount to deposit (must be > 0).
|
|
968
|
+
* @returns Transaction hash.
|
|
969
|
+
* @throws {SlotsError} If amount is not positive, or the transaction fails.
|
|
970
|
+
*/
|
|
807
971
|
async topUp(slot, amount) {
|
|
972
|
+
this.assertPositive(amount, "amount");
|
|
808
973
|
return this.withAllowance(slot, amount, {
|
|
809
974
|
to: slot,
|
|
810
975
|
abi: slotAbi,
|
|
@@ -812,98 +977,145 @@ var SlotsClient = class {
|
|
|
812
977
|
args: [amount]
|
|
813
978
|
});
|
|
814
979
|
}
|
|
815
|
-
/**
|
|
980
|
+
/**
|
|
981
|
+
* Withdraw from deposit (occupant only). Cannot go below minimum deposit.
|
|
982
|
+
* @param slot - The slot contract address.
|
|
983
|
+
* @param amount - The amount to withdraw (must be > 0).
|
|
984
|
+
* @returns Transaction hash.
|
|
985
|
+
* @throws {SlotsError} If amount is not positive, or the transaction fails.
|
|
986
|
+
*/
|
|
816
987
|
async withdraw(slot, amount) {
|
|
988
|
+
this.assertPositive(amount, "amount");
|
|
817
989
|
return this.wallet.writeContract({
|
|
818
990
|
address: slot,
|
|
819
991
|
abi: slotAbi,
|
|
820
992
|
functionName: "withdraw",
|
|
821
993
|
args: [amount],
|
|
822
|
-
account: this.
|
|
823
|
-
chain: this.
|
|
994
|
+
account: this.account,
|
|
995
|
+
chain: this.chain
|
|
824
996
|
});
|
|
825
997
|
}
|
|
826
|
-
/**
|
|
998
|
+
/**
|
|
999
|
+
* Release a slot (occupant only). Returns remaining deposit to the occupant.
|
|
1000
|
+
* @param slot - The slot contract address.
|
|
1001
|
+
* @returns Transaction hash.
|
|
1002
|
+
*/
|
|
827
1003
|
async release(slot) {
|
|
828
1004
|
return this.wallet.writeContract({
|
|
829
1005
|
address: slot,
|
|
830
1006
|
abi: slotAbi,
|
|
831
1007
|
functionName: "release",
|
|
832
|
-
account: this.
|
|
833
|
-
chain: this.
|
|
1008
|
+
account: this.account,
|
|
1009
|
+
chain: this.chain
|
|
834
1010
|
});
|
|
835
1011
|
}
|
|
836
|
-
/**
|
|
1012
|
+
/**
|
|
1013
|
+
* Collect accumulated tax (permissionless).
|
|
1014
|
+
* @param slot - The slot contract address.
|
|
1015
|
+
* @returns Transaction hash.
|
|
1016
|
+
*/
|
|
837
1017
|
async collect(slot) {
|
|
838
1018
|
return this.wallet.writeContract({
|
|
839
1019
|
address: slot,
|
|
840
1020
|
abi: slotAbi,
|
|
841
1021
|
functionName: "collect",
|
|
842
|
-
account: this.
|
|
843
|
-
chain: this.
|
|
1022
|
+
account: this.account,
|
|
1023
|
+
chain: this.chain
|
|
844
1024
|
});
|
|
845
1025
|
}
|
|
846
|
-
/**
|
|
1026
|
+
/**
|
|
1027
|
+
* Liquidate an insolvent slot (permissionless). Caller receives bounty.
|
|
1028
|
+
* @param slot - The slot contract address.
|
|
1029
|
+
* @returns Transaction hash.
|
|
1030
|
+
*/
|
|
847
1031
|
async liquidate(slot) {
|
|
848
1032
|
return this.wallet.writeContract({
|
|
849
1033
|
address: slot,
|
|
850
1034
|
abi: slotAbi,
|
|
851
1035
|
functionName: "liquidate",
|
|
852
|
-
account: this.
|
|
853
|
-
chain: this.
|
|
1036
|
+
account: this.account,
|
|
1037
|
+
chain: this.chain
|
|
854
1038
|
});
|
|
855
1039
|
}
|
|
856
1040
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
857
1041
|
// WRITE — Manager Functions
|
|
858
1042
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
859
|
-
/**
|
|
1043
|
+
/**
|
|
1044
|
+
* Propose a tax rate update (manager only, slot must have mutableTax).
|
|
1045
|
+
* @param slot - The slot contract address.
|
|
1046
|
+
* @param newPct - The new tax percentage.
|
|
1047
|
+
* @returns Transaction hash.
|
|
1048
|
+
*/
|
|
860
1049
|
async proposeTaxUpdate(slot, newPct) {
|
|
861
1050
|
return this.wallet.writeContract({
|
|
862
1051
|
address: slot,
|
|
863
1052
|
abi: slotAbi,
|
|
864
1053
|
functionName: "proposeTaxUpdate",
|
|
865
1054
|
args: [newPct],
|
|
866
|
-
account: this.
|
|
867
|
-
chain: this.
|
|
1055
|
+
account: this.account,
|
|
1056
|
+
chain: this.chain
|
|
868
1057
|
});
|
|
869
1058
|
}
|
|
870
|
-
/**
|
|
1059
|
+
/**
|
|
1060
|
+
* Propose a module update (manager only, slot must have mutableModule).
|
|
1061
|
+
* @param slot - The slot contract address.
|
|
1062
|
+
* @param newModule - The new module contract address.
|
|
1063
|
+
* @returns Transaction hash.
|
|
1064
|
+
*/
|
|
871
1065
|
async proposeModuleUpdate(slot, newModule) {
|
|
872
1066
|
return this.wallet.writeContract({
|
|
873
1067
|
address: slot,
|
|
874
1068
|
abi: slotAbi,
|
|
875
1069
|
functionName: "proposeModuleUpdate",
|
|
876
1070
|
args: [newModule],
|
|
877
|
-
account: this.
|
|
878
|
-
chain: this.
|
|
1071
|
+
account: this.account,
|
|
1072
|
+
chain: this.chain
|
|
879
1073
|
});
|
|
880
1074
|
}
|
|
881
|
-
/**
|
|
1075
|
+
/**
|
|
1076
|
+
* Cancel pending updates (manager only).
|
|
1077
|
+
* @param slot - The slot contract address.
|
|
1078
|
+
* @returns Transaction hash.
|
|
1079
|
+
*/
|
|
882
1080
|
async cancelPendingUpdates(slot) {
|
|
883
1081
|
return this.wallet.writeContract({
|
|
884
1082
|
address: slot,
|
|
885
1083
|
abi: slotAbi,
|
|
886
1084
|
functionName: "cancelPendingUpdates",
|
|
887
|
-
account: this.
|
|
888
|
-
chain: this.
|
|
1085
|
+
account: this.account,
|
|
1086
|
+
chain: this.chain
|
|
889
1087
|
});
|
|
890
1088
|
}
|
|
891
|
-
/**
|
|
1089
|
+
/**
|
|
1090
|
+
* Set liquidation bounty bps (manager only).
|
|
1091
|
+
* @param slot - The slot contract address.
|
|
1092
|
+
* @param newBps - The new bounty in basis points (0-10000).
|
|
1093
|
+
* @returns Transaction hash.
|
|
1094
|
+
* @throws {SlotsError} If newBps is outside 0-10000, or the transaction fails.
|
|
1095
|
+
*/
|
|
892
1096
|
async setLiquidationBounty(slot, newBps) {
|
|
1097
|
+
if (newBps < 0n || newBps > 10000n) throw new SlotsError("setLiquidationBounty", "newBps must be 0-10000");
|
|
893
1098
|
return this.wallet.writeContract({
|
|
894
1099
|
address: slot,
|
|
895
1100
|
abi: slotAbi,
|
|
896
1101
|
functionName: "setLiquidationBounty",
|
|
897
1102
|
args: [newBps],
|
|
898
|
-
account: this.
|
|
899
|
-
chain: this.
|
|
1103
|
+
account: this.account,
|
|
1104
|
+
chain: this.chain
|
|
900
1105
|
});
|
|
901
1106
|
}
|
|
902
1107
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
903
1108
|
// WRITE — Multicall
|
|
904
1109
|
// ═══════════════════════════════════════════════════════════════════════════
|
|
905
|
-
/**
|
|
1110
|
+
/**
|
|
1111
|
+
* Batch multiple slot calls into one transaction via multicall.
|
|
1112
|
+
* @param slot - The slot contract address.
|
|
1113
|
+
* @param calls - Array of function calls to batch.
|
|
1114
|
+
* @returns Transaction hash.
|
|
1115
|
+
* @throws {SlotsError} If calls array is empty, or the transaction fails.
|
|
1116
|
+
*/
|
|
906
1117
|
async multicall(slot, calls) {
|
|
1118
|
+
if (calls.length === 0) throw new SlotsError("multicall", "calls array must not be empty");
|
|
907
1119
|
const data = calls.map(
|
|
908
1120
|
(call) => encodeFunctionData({
|
|
909
1121
|
abi: slotAbi,
|
|
@@ -916,8 +1128,8 @@ var SlotsClient = class {
|
|
|
916
1128
|
abi: slotAbi,
|
|
917
1129
|
functionName: "multicall",
|
|
918
1130
|
args: [data],
|
|
919
|
-
account: this.
|
|
920
|
-
chain: this.
|
|
1131
|
+
account: this.account,
|
|
1132
|
+
chain: this.chain
|
|
921
1133
|
});
|
|
922
1134
|
}
|
|
923
1135
|
// ─── Internals ──────────────────────────────────────────────────────────────
|
|
@@ -930,7 +1142,7 @@ var SlotsClient = class {
|
|
|
930
1142
|
this._atomicSupport = false;
|
|
931
1143
|
return false;
|
|
932
1144
|
}
|
|
933
|
-
const chainId = this.
|
|
1145
|
+
const chainId = this.chain.id;
|
|
934
1146
|
const chainCaps = capabilities[chainId] || capabilities[`0x${chainId.toString(16)}`];
|
|
935
1147
|
const atomic = chainCaps?.atomicBatch ?? chainCaps?.atomic;
|
|
936
1148
|
const status = atomic && typeof atomic === "object" && "status" in atomic ? atomic.status : void 0;
|
|
@@ -987,8 +1199,8 @@ var SlotsClient = class {
|
|
|
987
1199
|
args: call.args
|
|
988
1200
|
});
|
|
989
1201
|
const id = await this.wallet.sendCalls({
|
|
990
|
-
account: this.
|
|
991
|
-
chain: this.
|
|
1202
|
+
account: this.account,
|
|
1203
|
+
chain: this.chain,
|
|
992
1204
|
calls: [
|
|
993
1205
|
{ to: currency, data: approveData },
|
|
994
1206
|
{ to: call.to, data: actionData }
|
|
@@ -1003,8 +1215,8 @@ var SlotsClient = class {
|
|
|
1003
1215
|
abi: erc20Abi,
|
|
1004
1216
|
functionName: "approve",
|
|
1005
1217
|
args: [spender, amount],
|
|
1006
|
-
account: this.
|
|
1007
|
-
chain: this.
|
|
1218
|
+
account: this.account,
|
|
1219
|
+
chain: this.chain
|
|
1008
1220
|
});
|
|
1009
1221
|
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
1010
1222
|
}
|
|
@@ -1013,8 +1225,8 @@ var SlotsClient = class {
|
|
|
1013
1225
|
abi: call.abi,
|
|
1014
1226
|
functionName: call.functionName,
|
|
1015
1227
|
args: call.args,
|
|
1016
|
-
account: this.
|
|
1017
|
-
chain: this.
|
|
1228
|
+
account: this.account,
|
|
1229
|
+
chain: this.chain
|
|
1018
1230
|
});
|
|
1019
1231
|
}
|
|
1020
1232
|
};
|
|
@@ -1022,6 +1234,6 @@ function createSlotsClient(config) {
|
|
|
1022
1234
|
return new SlotsClient(config);
|
|
1023
1235
|
}
|
|
1024
1236
|
|
|
1025
|
-
export { AccountFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, createSlotsClient, getSdk };
|
|
1237
|
+
export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk };
|
|
1026
1238
|
//# sourceMappingURL=index.js.map
|
|
1027
1239
|
//# sourceMappingURL=index.js.map
|