@0xslots/sdk 0.9.2 → 0.10.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/chunk-KRJINGNH.js +1582 -0
- package/dist/chunk-KRJINGNH.js.map +1 -0
- package/dist/client-BtZNzXuf.d.ts +4554 -0
- package/dist/index.d.ts +5 -4161
- package/dist/index.js +1 -1576
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +100 -0
- package/dist/react.js +320 -0
- package/dist/react.js.map +1 -0
- package/package.json +27 -5
|
@@ -0,0 +1,1582 @@
|
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
import { metadataModuleAbi, getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts';
|
|
3
|
+
import { gql as gql$1, GraphQLClient } from 'graphql-request';
|
|
4
|
+
import { encodeFunctionData, erc20Abi } from 'viem';
|
|
5
|
+
|
|
6
|
+
// src/generated/graphql.ts
|
|
7
|
+
var AccountFieldsFragmentDoc = gql`
|
|
8
|
+
fragment AccountFields on Account {
|
|
9
|
+
id
|
|
10
|
+
type
|
|
11
|
+
slotCount
|
|
12
|
+
occupiedCount
|
|
13
|
+
slotsAsRecipient {
|
|
14
|
+
id
|
|
15
|
+
}
|
|
16
|
+
slotsAsOccupant {
|
|
17
|
+
id
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
var CurrencyFieldsFragmentDoc = gql`
|
|
22
|
+
fragment CurrencyFields on Currency {
|
|
23
|
+
id
|
|
24
|
+
name
|
|
25
|
+
symbol
|
|
26
|
+
decimals
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
var MetadataSlotFieldsFragmentDoc = gql`
|
|
30
|
+
fragment MetadataSlotFields on MetadataSlot {
|
|
31
|
+
id
|
|
32
|
+
uri
|
|
33
|
+
rawJson
|
|
34
|
+
adType
|
|
35
|
+
updatedBy
|
|
36
|
+
updateCount
|
|
37
|
+
createdAt
|
|
38
|
+
createdTx
|
|
39
|
+
updatedAt
|
|
40
|
+
updatedTx
|
|
41
|
+
slot {
|
|
42
|
+
id
|
|
43
|
+
recipient
|
|
44
|
+
occupant
|
|
45
|
+
price
|
|
46
|
+
deposit
|
|
47
|
+
currency {
|
|
48
|
+
id
|
|
49
|
+
symbol
|
|
50
|
+
decimals
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
var SlotFieldsFragmentDoc = gql`
|
|
56
|
+
fragment SlotFields on Slot {
|
|
57
|
+
id
|
|
58
|
+
recipient
|
|
59
|
+
recipientAccount {
|
|
60
|
+
id
|
|
61
|
+
type
|
|
62
|
+
slotCount
|
|
63
|
+
occupiedCount
|
|
64
|
+
}
|
|
65
|
+
currency {
|
|
66
|
+
id
|
|
67
|
+
name
|
|
68
|
+
symbol
|
|
69
|
+
decimals
|
|
70
|
+
}
|
|
71
|
+
manager
|
|
72
|
+
mutableTax
|
|
73
|
+
mutableModule
|
|
74
|
+
taxPercentage
|
|
75
|
+
module {
|
|
76
|
+
id
|
|
77
|
+
verified
|
|
78
|
+
name
|
|
79
|
+
version
|
|
80
|
+
}
|
|
81
|
+
occupant
|
|
82
|
+
occupantAccount {
|
|
83
|
+
id
|
|
84
|
+
type
|
|
85
|
+
slotCount
|
|
86
|
+
occupiedCount
|
|
87
|
+
}
|
|
88
|
+
price
|
|
89
|
+
deposit
|
|
90
|
+
collectedTax
|
|
91
|
+
totalCollected
|
|
92
|
+
liquidationBountyBps
|
|
93
|
+
minDepositSeconds
|
|
94
|
+
createdAt
|
|
95
|
+
createdTx
|
|
96
|
+
updatedAt
|
|
97
|
+
}
|
|
98
|
+
`;
|
|
99
|
+
var GetAccountDocument = gql`
|
|
100
|
+
query GetAccount($id: ID!, $block: Block_height) {
|
|
101
|
+
account(id: $id, block: $block) {
|
|
102
|
+
...AccountFields
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
${AccountFieldsFragmentDoc}`;
|
|
106
|
+
var GetAccountsDocument = gql`
|
|
107
|
+
query GetAccounts($first: Int!, $skip: Int, $orderBy: Account_orderBy, $orderDirection: OrderDirection, $where: Account_filter, $block: Block_height) {
|
|
108
|
+
accounts(
|
|
109
|
+
first: $first
|
|
110
|
+
skip: $skip
|
|
111
|
+
orderBy: $orderBy
|
|
112
|
+
orderDirection: $orderDirection
|
|
113
|
+
where: $where
|
|
114
|
+
block: $block
|
|
115
|
+
) {
|
|
116
|
+
...AccountFields
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
${AccountFieldsFragmentDoc}`;
|
|
120
|
+
var GetSlotDeployedEventsDocument = gql`
|
|
121
|
+
query GetSlotDeployedEvents($first: Int!, $skip: Int, $orderBy: SlotDeployedEvent_orderBy, $orderDirection: OrderDirection, $where: SlotDeployedEvent_filter, $block: Block_height) {
|
|
122
|
+
slotDeployedEvents(
|
|
123
|
+
first: $first
|
|
124
|
+
skip: $skip
|
|
125
|
+
orderBy: $orderBy
|
|
126
|
+
orderDirection: $orderDirection
|
|
127
|
+
where: $where
|
|
128
|
+
block: $block
|
|
129
|
+
) {
|
|
130
|
+
id
|
|
131
|
+
slot {
|
|
132
|
+
id
|
|
133
|
+
}
|
|
134
|
+
recipient
|
|
135
|
+
currency {
|
|
136
|
+
...CurrencyFields
|
|
137
|
+
}
|
|
138
|
+
manager
|
|
139
|
+
mutableTax
|
|
140
|
+
mutableModule
|
|
141
|
+
taxPercentage
|
|
142
|
+
module
|
|
143
|
+
liquidationBountyBps
|
|
144
|
+
minDepositSeconds
|
|
145
|
+
deployer
|
|
146
|
+
timestamp
|
|
147
|
+
blockNumber
|
|
148
|
+
tx
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
152
|
+
var GetRecentEventsDocument = gql`
|
|
153
|
+
query GetRecentEvents($first: Int!, $skip: Int) {
|
|
154
|
+
slotDeployedEvents(
|
|
155
|
+
first: $first
|
|
156
|
+
skip: $skip
|
|
157
|
+
orderBy: timestamp
|
|
158
|
+
orderDirection: desc
|
|
159
|
+
) {
|
|
160
|
+
id
|
|
161
|
+
slot {
|
|
162
|
+
id
|
|
163
|
+
}
|
|
164
|
+
recipient
|
|
165
|
+
currency {
|
|
166
|
+
...CurrencyFields
|
|
167
|
+
}
|
|
168
|
+
deployer
|
|
169
|
+
timestamp
|
|
170
|
+
tx
|
|
171
|
+
}
|
|
172
|
+
boughtEvents(
|
|
173
|
+
first: $first
|
|
174
|
+
skip: $skip
|
|
175
|
+
orderBy: timestamp
|
|
176
|
+
orderDirection: desc
|
|
177
|
+
) {
|
|
178
|
+
id
|
|
179
|
+
slot {
|
|
180
|
+
id
|
|
181
|
+
}
|
|
182
|
+
currency {
|
|
183
|
+
...CurrencyFields
|
|
184
|
+
}
|
|
185
|
+
buyer
|
|
186
|
+
previousOccupant
|
|
187
|
+
price
|
|
188
|
+
selfAssessedPrice
|
|
189
|
+
deposit
|
|
190
|
+
timestamp
|
|
191
|
+
tx
|
|
192
|
+
}
|
|
193
|
+
releasedEvents(
|
|
194
|
+
first: $first
|
|
195
|
+
skip: $skip
|
|
196
|
+
orderBy: timestamp
|
|
197
|
+
orderDirection: desc
|
|
198
|
+
) {
|
|
199
|
+
id
|
|
200
|
+
slot {
|
|
201
|
+
id
|
|
202
|
+
}
|
|
203
|
+
currency {
|
|
204
|
+
...CurrencyFields
|
|
205
|
+
}
|
|
206
|
+
occupant
|
|
207
|
+
refund
|
|
208
|
+
timestamp
|
|
209
|
+
tx
|
|
210
|
+
}
|
|
211
|
+
liquidatedEvents(
|
|
212
|
+
first: $first
|
|
213
|
+
skip: $skip
|
|
214
|
+
orderBy: timestamp
|
|
215
|
+
orderDirection: desc
|
|
216
|
+
) {
|
|
217
|
+
id
|
|
218
|
+
slot {
|
|
219
|
+
id
|
|
220
|
+
}
|
|
221
|
+
currency {
|
|
222
|
+
...CurrencyFields
|
|
223
|
+
}
|
|
224
|
+
liquidator
|
|
225
|
+
occupant
|
|
226
|
+
bounty
|
|
227
|
+
timestamp
|
|
228
|
+
tx
|
|
229
|
+
}
|
|
230
|
+
priceUpdatedEvents(
|
|
231
|
+
first: $first
|
|
232
|
+
skip: $skip
|
|
233
|
+
orderBy: timestamp
|
|
234
|
+
orderDirection: desc
|
|
235
|
+
) {
|
|
236
|
+
id
|
|
237
|
+
slot {
|
|
238
|
+
id
|
|
239
|
+
}
|
|
240
|
+
currency {
|
|
241
|
+
...CurrencyFields
|
|
242
|
+
}
|
|
243
|
+
oldPrice
|
|
244
|
+
newPrice
|
|
245
|
+
timestamp
|
|
246
|
+
tx
|
|
247
|
+
}
|
|
248
|
+
depositedEvents(
|
|
249
|
+
first: $first
|
|
250
|
+
skip: $skip
|
|
251
|
+
orderBy: timestamp
|
|
252
|
+
orderDirection: desc
|
|
253
|
+
) {
|
|
254
|
+
id
|
|
255
|
+
slot {
|
|
256
|
+
id
|
|
257
|
+
}
|
|
258
|
+
currency {
|
|
259
|
+
...CurrencyFields
|
|
260
|
+
}
|
|
261
|
+
depositor
|
|
262
|
+
amount
|
|
263
|
+
timestamp
|
|
264
|
+
tx
|
|
265
|
+
}
|
|
266
|
+
withdrawnEvents(
|
|
267
|
+
first: $first
|
|
268
|
+
skip: $skip
|
|
269
|
+
orderBy: timestamp
|
|
270
|
+
orderDirection: desc
|
|
271
|
+
) {
|
|
272
|
+
id
|
|
273
|
+
slot {
|
|
274
|
+
id
|
|
275
|
+
}
|
|
276
|
+
currency {
|
|
277
|
+
...CurrencyFields
|
|
278
|
+
}
|
|
279
|
+
occupant
|
|
280
|
+
amount
|
|
281
|
+
timestamp
|
|
282
|
+
tx
|
|
283
|
+
}
|
|
284
|
+
taxCollectedEvents(
|
|
285
|
+
first: $first
|
|
286
|
+
skip: $skip
|
|
287
|
+
orderBy: timestamp
|
|
288
|
+
orderDirection: desc
|
|
289
|
+
) {
|
|
290
|
+
id
|
|
291
|
+
slot {
|
|
292
|
+
id
|
|
293
|
+
}
|
|
294
|
+
currency {
|
|
295
|
+
...CurrencyFields
|
|
296
|
+
}
|
|
297
|
+
recipient
|
|
298
|
+
amount
|
|
299
|
+
timestamp
|
|
300
|
+
tx
|
|
301
|
+
}
|
|
302
|
+
taxUpdateProposedEvents(
|
|
303
|
+
first: $first
|
|
304
|
+
skip: $skip
|
|
305
|
+
orderBy: timestamp
|
|
306
|
+
orderDirection: desc
|
|
307
|
+
) {
|
|
308
|
+
id
|
|
309
|
+
slot {
|
|
310
|
+
id
|
|
311
|
+
}
|
|
312
|
+
newPercentage
|
|
313
|
+
timestamp
|
|
314
|
+
tx
|
|
315
|
+
}
|
|
316
|
+
moduleUpdateProposedEvents(
|
|
317
|
+
first: $first
|
|
318
|
+
skip: $skip
|
|
319
|
+
orderBy: timestamp
|
|
320
|
+
orderDirection: desc
|
|
321
|
+
) {
|
|
322
|
+
id
|
|
323
|
+
slot {
|
|
324
|
+
id
|
|
325
|
+
}
|
|
326
|
+
newModule
|
|
327
|
+
timestamp
|
|
328
|
+
tx
|
|
329
|
+
}
|
|
330
|
+
pendingUpdateCancelledEvents(
|
|
331
|
+
first: $first
|
|
332
|
+
skip: $skip
|
|
333
|
+
orderBy: timestamp
|
|
334
|
+
orderDirection: desc
|
|
335
|
+
) {
|
|
336
|
+
id
|
|
337
|
+
slot {
|
|
338
|
+
id
|
|
339
|
+
}
|
|
340
|
+
timestamp
|
|
341
|
+
tx
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
345
|
+
var GetBoughtEventsDocument = gql`
|
|
346
|
+
query GetBoughtEvents($first: Int!, $skip: Int, $orderBy: BoughtEvent_orderBy, $orderDirection: OrderDirection, $where: BoughtEvent_filter, $block: Block_height) {
|
|
347
|
+
boughtEvents(
|
|
348
|
+
first: $first
|
|
349
|
+
skip: $skip
|
|
350
|
+
orderBy: $orderBy
|
|
351
|
+
orderDirection: $orderDirection
|
|
352
|
+
where: $where
|
|
353
|
+
block: $block
|
|
354
|
+
) {
|
|
355
|
+
id
|
|
356
|
+
slot {
|
|
357
|
+
id
|
|
358
|
+
}
|
|
359
|
+
currency {
|
|
360
|
+
...CurrencyFields
|
|
361
|
+
}
|
|
362
|
+
buyer
|
|
363
|
+
previousOccupant
|
|
364
|
+
price
|
|
365
|
+
deposit
|
|
366
|
+
selfAssessedPrice
|
|
367
|
+
timestamp
|
|
368
|
+
blockNumber
|
|
369
|
+
tx
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
373
|
+
var GetReleasedEventsDocument = gql`
|
|
374
|
+
query GetReleasedEvents($first: Int!, $skip: Int, $orderBy: ReleasedEvent_orderBy, $orderDirection: OrderDirection, $where: ReleasedEvent_filter, $block: Block_height) {
|
|
375
|
+
releasedEvents(
|
|
376
|
+
first: $first
|
|
377
|
+
skip: $skip
|
|
378
|
+
orderBy: $orderBy
|
|
379
|
+
orderDirection: $orderDirection
|
|
380
|
+
where: $where
|
|
381
|
+
block: $block
|
|
382
|
+
) {
|
|
383
|
+
id
|
|
384
|
+
slot {
|
|
385
|
+
id
|
|
386
|
+
}
|
|
387
|
+
currency {
|
|
388
|
+
...CurrencyFields
|
|
389
|
+
}
|
|
390
|
+
occupant
|
|
391
|
+
refund
|
|
392
|
+
timestamp
|
|
393
|
+
blockNumber
|
|
394
|
+
tx
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
398
|
+
var GetLiquidatedEventsDocument = gql`
|
|
399
|
+
query GetLiquidatedEvents($first: Int!, $skip: Int, $orderBy: LiquidatedEvent_orderBy, $orderDirection: OrderDirection, $where: LiquidatedEvent_filter, $block: Block_height) {
|
|
400
|
+
liquidatedEvents(
|
|
401
|
+
first: $first
|
|
402
|
+
skip: $skip
|
|
403
|
+
orderBy: $orderBy
|
|
404
|
+
orderDirection: $orderDirection
|
|
405
|
+
where: $where
|
|
406
|
+
block: $block
|
|
407
|
+
) {
|
|
408
|
+
id
|
|
409
|
+
slot {
|
|
410
|
+
id
|
|
411
|
+
}
|
|
412
|
+
currency {
|
|
413
|
+
...CurrencyFields
|
|
414
|
+
}
|
|
415
|
+
liquidator
|
|
416
|
+
occupant
|
|
417
|
+
bounty
|
|
418
|
+
timestamp
|
|
419
|
+
blockNumber
|
|
420
|
+
tx
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
424
|
+
var GetSettledEventsDocument = gql`
|
|
425
|
+
query GetSettledEvents($first: Int!, $skip: Int, $orderBy: SettledEvent_orderBy, $orderDirection: OrderDirection, $where: SettledEvent_filter, $block: Block_height) {
|
|
426
|
+
settledEvents(
|
|
427
|
+
first: $first
|
|
428
|
+
skip: $skip
|
|
429
|
+
orderBy: $orderBy
|
|
430
|
+
orderDirection: $orderDirection
|
|
431
|
+
where: $where
|
|
432
|
+
block: $block
|
|
433
|
+
) {
|
|
434
|
+
id
|
|
435
|
+
slot {
|
|
436
|
+
id
|
|
437
|
+
}
|
|
438
|
+
currency {
|
|
439
|
+
...CurrencyFields
|
|
440
|
+
}
|
|
441
|
+
taxOwed
|
|
442
|
+
taxPaid
|
|
443
|
+
depositRemaining
|
|
444
|
+
timestamp
|
|
445
|
+
blockNumber
|
|
446
|
+
tx
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
450
|
+
var GetTaxCollectedEventsDocument = gql`
|
|
451
|
+
query GetTaxCollectedEvents($first: Int!, $skip: Int, $orderBy: TaxCollectedEvent_orderBy, $orderDirection: OrderDirection, $where: TaxCollectedEvent_filter, $block: Block_height) {
|
|
452
|
+
taxCollectedEvents(
|
|
453
|
+
first: $first
|
|
454
|
+
skip: $skip
|
|
455
|
+
orderBy: $orderBy
|
|
456
|
+
orderDirection: $orderDirection
|
|
457
|
+
where: $where
|
|
458
|
+
block: $block
|
|
459
|
+
) {
|
|
460
|
+
id
|
|
461
|
+
slot {
|
|
462
|
+
id
|
|
463
|
+
}
|
|
464
|
+
currency {
|
|
465
|
+
...CurrencyFields
|
|
466
|
+
}
|
|
467
|
+
recipient
|
|
468
|
+
amount
|
|
469
|
+
timestamp
|
|
470
|
+
blockNumber
|
|
471
|
+
tx
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
475
|
+
var GetDepositedEventsDocument = gql`
|
|
476
|
+
query GetDepositedEvents($first: Int!, $skip: Int, $orderBy: DepositedEvent_orderBy, $orderDirection: OrderDirection, $where: DepositedEvent_filter, $block: Block_height) {
|
|
477
|
+
depositedEvents(
|
|
478
|
+
first: $first
|
|
479
|
+
skip: $skip
|
|
480
|
+
orderBy: $orderBy
|
|
481
|
+
orderDirection: $orderDirection
|
|
482
|
+
where: $where
|
|
483
|
+
block: $block
|
|
484
|
+
) {
|
|
485
|
+
id
|
|
486
|
+
slot {
|
|
487
|
+
id
|
|
488
|
+
}
|
|
489
|
+
currency {
|
|
490
|
+
...CurrencyFields
|
|
491
|
+
}
|
|
492
|
+
depositor
|
|
493
|
+
amount
|
|
494
|
+
timestamp
|
|
495
|
+
blockNumber
|
|
496
|
+
tx
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
500
|
+
var GetWithdrawnEventsDocument = gql`
|
|
501
|
+
query GetWithdrawnEvents($first: Int!, $skip: Int, $orderBy: WithdrawnEvent_orderBy, $orderDirection: OrderDirection, $where: WithdrawnEvent_filter, $block: Block_height) {
|
|
502
|
+
withdrawnEvents(
|
|
503
|
+
first: $first
|
|
504
|
+
skip: $skip
|
|
505
|
+
orderBy: $orderBy
|
|
506
|
+
orderDirection: $orderDirection
|
|
507
|
+
where: $where
|
|
508
|
+
block: $block
|
|
509
|
+
) {
|
|
510
|
+
id
|
|
511
|
+
slot {
|
|
512
|
+
id
|
|
513
|
+
}
|
|
514
|
+
currency {
|
|
515
|
+
...CurrencyFields
|
|
516
|
+
}
|
|
517
|
+
occupant
|
|
518
|
+
amount
|
|
519
|
+
timestamp
|
|
520
|
+
blockNumber
|
|
521
|
+
tx
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
525
|
+
var GetPriceUpdatedEventsDocument = gql`
|
|
526
|
+
query GetPriceUpdatedEvents($first: Int!, $skip: Int, $orderBy: PriceUpdatedEvent_orderBy, $orderDirection: OrderDirection, $where: PriceUpdatedEvent_filter, $block: Block_height) {
|
|
527
|
+
priceUpdatedEvents(
|
|
528
|
+
first: $first
|
|
529
|
+
skip: $skip
|
|
530
|
+
orderBy: $orderBy
|
|
531
|
+
orderDirection: $orderDirection
|
|
532
|
+
where: $where
|
|
533
|
+
block: $block
|
|
534
|
+
) {
|
|
535
|
+
id
|
|
536
|
+
slot {
|
|
537
|
+
id
|
|
538
|
+
}
|
|
539
|
+
currency {
|
|
540
|
+
...CurrencyFields
|
|
541
|
+
}
|
|
542
|
+
oldPrice
|
|
543
|
+
newPrice
|
|
544
|
+
timestamp
|
|
545
|
+
blockNumber
|
|
546
|
+
tx
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
550
|
+
var GetSlotActivityDocument = gql`
|
|
551
|
+
query GetSlotActivity($slotId: String!, $first: Int!, $skip: Int) {
|
|
552
|
+
boughtEvents(
|
|
553
|
+
first: $first
|
|
554
|
+
skip: $skip
|
|
555
|
+
orderBy: timestamp
|
|
556
|
+
orderDirection: desc
|
|
557
|
+
where: {slot: $slotId}
|
|
558
|
+
) {
|
|
559
|
+
id
|
|
560
|
+
currency {
|
|
561
|
+
...CurrencyFields
|
|
562
|
+
}
|
|
563
|
+
buyer
|
|
564
|
+
previousOccupant
|
|
565
|
+
price
|
|
566
|
+
selfAssessedPrice
|
|
567
|
+
deposit
|
|
568
|
+
timestamp
|
|
569
|
+
tx
|
|
570
|
+
}
|
|
571
|
+
releasedEvents(
|
|
572
|
+
first: $first
|
|
573
|
+
skip: $skip
|
|
574
|
+
orderBy: timestamp
|
|
575
|
+
orderDirection: desc
|
|
576
|
+
where: {slot: $slotId}
|
|
577
|
+
) {
|
|
578
|
+
id
|
|
579
|
+
currency {
|
|
580
|
+
...CurrencyFields
|
|
581
|
+
}
|
|
582
|
+
occupant
|
|
583
|
+
refund
|
|
584
|
+
timestamp
|
|
585
|
+
tx
|
|
586
|
+
}
|
|
587
|
+
liquidatedEvents(
|
|
588
|
+
first: $first
|
|
589
|
+
skip: $skip
|
|
590
|
+
orderBy: timestamp
|
|
591
|
+
orderDirection: desc
|
|
592
|
+
where: {slot: $slotId}
|
|
593
|
+
) {
|
|
594
|
+
id
|
|
595
|
+
currency {
|
|
596
|
+
...CurrencyFields
|
|
597
|
+
}
|
|
598
|
+
liquidator
|
|
599
|
+
occupant
|
|
600
|
+
bounty
|
|
601
|
+
timestamp
|
|
602
|
+
tx
|
|
603
|
+
}
|
|
604
|
+
priceUpdatedEvents(
|
|
605
|
+
first: $first
|
|
606
|
+
skip: $skip
|
|
607
|
+
orderBy: timestamp
|
|
608
|
+
orderDirection: desc
|
|
609
|
+
where: {slot: $slotId}
|
|
610
|
+
) {
|
|
611
|
+
id
|
|
612
|
+
currency {
|
|
613
|
+
...CurrencyFields
|
|
614
|
+
}
|
|
615
|
+
oldPrice
|
|
616
|
+
newPrice
|
|
617
|
+
timestamp
|
|
618
|
+
tx
|
|
619
|
+
}
|
|
620
|
+
depositedEvents(
|
|
621
|
+
first: $first
|
|
622
|
+
skip: $skip
|
|
623
|
+
orderBy: timestamp
|
|
624
|
+
orderDirection: desc
|
|
625
|
+
where: {slot: $slotId}
|
|
626
|
+
) {
|
|
627
|
+
id
|
|
628
|
+
currency {
|
|
629
|
+
...CurrencyFields
|
|
630
|
+
}
|
|
631
|
+
depositor
|
|
632
|
+
amount
|
|
633
|
+
timestamp
|
|
634
|
+
tx
|
|
635
|
+
}
|
|
636
|
+
withdrawnEvents(
|
|
637
|
+
first: $first
|
|
638
|
+
skip: $skip
|
|
639
|
+
orderBy: timestamp
|
|
640
|
+
orderDirection: desc
|
|
641
|
+
where: {slot: $slotId}
|
|
642
|
+
) {
|
|
643
|
+
id
|
|
644
|
+
currency {
|
|
645
|
+
...CurrencyFields
|
|
646
|
+
}
|
|
647
|
+
occupant
|
|
648
|
+
amount
|
|
649
|
+
timestamp
|
|
650
|
+
tx
|
|
651
|
+
}
|
|
652
|
+
taxCollectedEvents(
|
|
653
|
+
first: $first
|
|
654
|
+
skip: $skip
|
|
655
|
+
orderBy: timestamp
|
|
656
|
+
orderDirection: desc
|
|
657
|
+
where: {slot: $slotId}
|
|
658
|
+
) {
|
|
659
|
+
id
|
|
660
|
+
currency {
|
|
661
|
+
...CurrencyFields
|
|
662
|
+
}
|
|
663
|
+
recipient
|
|
664
|
+
amount
|
|
665
|
+
timestamp
|
|
666
|
+
tx
|
|
667
|
+
}
|
|
668
|
+
taxUpdateProposedEvents(
|
|
669
|
+
first: $first
|
|
670
|
+
skip: $skip
|
|
671
|
+
orderBy: timestamp
|
|
672
|
+
orderDirection: desc
|
|
673
|
+
where: {slot: $slotId}
|
|
674
|
+
) {
|
|
675
|
+
id
|
|
676
|
+
newPercentage
|
|
677
|
+
timestamp
|
|
678
|
+
tx
|
|
679
|
+
}
|
|
680
|
+
moduleUpdateProposedEvents(
|
|
681
|
+
first: $first
|
|
682
|
+
skip: $skip
|
|
683
|
+
orderBy: timestamp
|
|
684
|
+
orderDirection: desc
|
|
685
|
+
where: {slot: $slotId}
|
|
686
|
+
) {
|
|
687
|
+
id
|
|
688
|
+
newModule
|
|
689
|
+
timestamp
|
|
690
|
+
tx
|
|
691
|
+
}
|
|
692
|
+
pendingUpdateCancelledEvents(
|
|
693
|
+
first: $first
|
|
694
|
+
skip: $skip
|
|
695
|
+
orderBy: timestamp
|
|
696
|
+
orderDirection: desc
|
|
697
|
+
where: {slot: $slotId}
|
|
698
|
+
) {
|
|
699
|
+
id
|
|
700
|
+
timestamp
|
|
701
|
+
tx
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
705
|
+
var GetFactoryDocument = gql`
|
|
706
|
+
query GetFactory {
|
|
707
|
+
factories(first: 1) {
|
|
708
|
+
id
|
|
709
|
+
slotCount
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
`;
|
|
713
|
+
var GetModulesDocument = gql`
|
|
714
|
+
query GetModules($first: Int!) {
|
|
715
|
+
modules(first: $first) {
|
|
716
|
+
id
|
|
717
|
+
verified
|
|
718
|
+
name
|
|
719
|
+
version
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
`;
|
|
723
|
+
var GetMetadataSlotsDocument = gql`
|
|
724
|
+
query GetMetadataSlots($first: Int = 100, $skip: Int = 0, $orderBy: MetadataSlot_orderBy = updatedAt, $orderDirection: OrderDirection = desc) {
|
|
725
|
+
metadataSlots(
|
|
726
|
+
first: $first
|
|
727
|
+
skip: $skip
|
|
728
|
+
orderBy: $orderBy
|
|
729
|
+
orderDirection: $orderDirection
|
|
730
|
+
) {
|
|
731
|
+
...MetadataSlotFields
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
${MetadataSlotFieldsFragmentDoc}`;
|
|
735
|
+
var GetMetadataSlotDocument = gql`
|
|
736
|
+
query GetMetadataSlot($id: ID!) {
|
|
737
|
+
metadataSlot(id: $id) {
|
|
738
|
+
...MetadataSlotFields
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
${MetadataSlotFieldsFragmentDoc}`;
|
|
742
|
+
var GetMetadataSlotsByRecipientDocument = gql`
|
|
743
|
+
query GetMetadataSlotsByRecipient($recipient: Bytes!, $first: Int = 100) {
|
|
744
|
+
metadataSlots(
|
|
745
|
+
first: $first
|
|
746
|
+
where: {slot_: {recipient: $recipient}}
|
|
747
|
+
orderBy: updatedAt
|
|
748
|
+
orderDirection: desc
|
|
749
|
+
) {
|
|
750
|
+
...MetadataSlotFields
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
${MetadataSlotFieldsFragmentDoc}`;
|
|
754
|
+
var GetMetadataUpdatedEventsDocument = gql`
|
|
755
|
+
query GetMetadataUpdatedEvents($slot: String, $first: Int = 50, $orderBy: MetadataUpdatedEvent_orderBy = timestamp, $orderDirection: OrderDirection = desc) {
|
|
756
|
+
metadataUpdatedEvents(
|
|
757
|
+
first: $first
|
|
758
|
+
where: {slot: $slot}
|
|
759
|
+
orderBy: $orderBy
|
|
760
|
+
orderDirection: $orderDirection
|
|
761
|
+
) {
|
|
762
|
+
id
|
|
763
|
+
slot {
|
|
764
|
+
id
|
|
765
|
+
}
|
|
766
|
+
author {
|
|
767
|
+
id
|
|
768
|
+
type
|
|
769
|
+
}
|
|
770
|
+
uri
|
|
771
|
+
rawJson
|
|
772
|
+
adType
|
|
773
|
+
timestamp
|
|
774
|
+
blockNumber
|
|
775
|
+
tx
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
`;
|
|
779
|
+
var GetSlotsDocument = gql`
|
|
780
|
+
query GetSlots($first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $where: Slot_filter, $block: Block_height) {
|
|
781
|
+
slots(
|
|
782
|
+
first: $first
|
|
783
|
+
skip: $skip
|
|
784
|
+
orderBy: $orderBy
|
|
785
|
+
orderDirection: $orderDirection
|
|
786
|
+
where: $where
|
|
787
|
+
block: $block
|
|
788
|
+
) {
|
|
789
|
+
...SlotFields
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
${SlotFieldsFragmentDoc}`;
|
|
793
|
+
var GetSlotDocument = gql`
|
|
794
|
+
query GetSlot($id: ID!, $block: Block_height) {
|
|
795
|
+
slot(id: $id, block: $block) {
|
|
796
|
+
...SlotFields
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
${SlotFieldsFragmentDoc}`;
|
|
800
|
+
var GetSlotsByRecipientDocument = gql`
|
|
801
|
+
query GetSlotsByRecipient($recipient: Bytes!, $first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $block: Block_height) {
|
|
802
|
+
slots(
|
|
803
|
+
first: $first
|
|
804
|
+
skip: $skip
|
|
805
|
+
orderBy: $orderBy
|
|
806
|
+
orderDirection: $orderDirection
|
|
807
|
+
where: {recipient: $recipient}
|
|
808
|
+
block: $block
|
|
809
|
+
) {
|
|
810
|
+
...SlotFields
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
${SlotFieldsFragmentDoc}`;
|
|
814
|
+
var GetSlotsByOccupantDocument = gql`
|
|
815
|
+
query GetSlotsByOccupant($occupant: Bytes!, $first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $block: Block_height) {
|
|
816
|
+
slots(
|
|
817
|
+
first: $first
|
|
818
|
+
skip: $skip
|
|
819
|
+
orderBy: $orderBy
|
|
820
|
+
orderDirection: $orderDirection
|
|
821
|
+
where: {occupant: $occupant}
|
|
822
|
+
block: $block
|
|
823
|
+
) {
|
|
824
|
+
...SlotFields
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
${SlotFieldsFragmentDoc}`;
|
|
828
|
+
var defaultWrapper = (action, _operationName, _operationType, _variables) => action();
|
|
829
|
+
function getSdk(client, withWrapper = defaultWrapper) {
|
|
830
|
+
return {
|
|
831
|
+
GetAccount(variables, requestHeaders, signal) {
|
|
832
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAccountDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAccount", "query", variables);
|
|
833
|
+
},
|
|
834
|
+
GetAccounts(variables, requestHeaders, signal) {
|
|
835
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAccountsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAccounts", "query", variables);
|
|
836
|
+
},
|
|
837
|
+
GetSlotDeployedEvents(variables, requestHeaders, signal) {
|
|
838
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotDeployedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotDeployedEvents", "query", variables);
|
|
839
|
+
},
|
|
840
|
+
GetRecentEvents(variables, requestHeaders, signal) {
|
|
841
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetRecentEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetRecentEvents", "query", variables);
|
|
842
|
+
},
|
|
843
|
+
GetBoughtEvents(variables, requestHeaders, signal) {
|
|
844
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetBoughtEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetBoughtEvents", "query", variables);
|
|
845
|
+
},
|
|
846
|
+
GetReleasedEvents(variables, requestHeaders, signal) {
|
|
847
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetReleasedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetReleasedEvents", "query", variables);
|
|
848
|
+
},
|
|
849
|
+
GetLiquidatedEvents(variables, requestHeaders, signal) {
|
|
850
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetLiquidatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetLiquidatedEvents", "query", variables);
|
|
851
|
+
},
|
|
852
|
+
GetSettledEvents(variables, requestHeaders, signal) {
|
|
853
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSettledEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSettledEvents", "query", variables);
|
|
854
|
+
},
|
|
855
|
+
GetTaxCollectedEvents(variables, requestHeaders, signal) {
|
|
856
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetTaxCollectedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetTaxCollectedEvents", "query", variables);
|
|
857
|
+
},
|
|
858
|
+
GetDepositedEvents(variables, requestHeaders, signal) {
|
|
859
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetDepositedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetDepositedEvents", "query", variables);
|
|
860
|
+
},
|
|
861
|
+
GetWithdrawnEvents(variables, requestHeaders, signal) {
|
|
862
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetWithdrawnEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetWithdrawnEvents", "query", variables);
|
|
863
|
+
},
|
|
864
|
+
GetPriceUpdatedEvents(variables, requestHeaders, signal) {
|
|
865
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetPriceUpdatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetPriceUpdatedEvents", "query", variables);
|
|
866
|
+
},
|
|
867
|
+
GetSlotActivity(variables, requestHeaders, signal) {
|
|
868
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotActivityDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotActivity", "query", variables);
|
|
869
|
+
},
|
|
870
|
+
GetFactory(variables, requestHeaders, signal) {
|
|
871
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetFactoryDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetFactory", "query", variables);
|
|
872
|
+
},
|
|
873
|
+
GetModules(variables, requestHeaders, signal) {
|
|
874
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetModulesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetModules", "query", variables);
|
|
875
|
+
},
|
|
876
|
+
GetMetadataSlots(variables, requestHeaders, signal) {
|
|
877
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlots", "query", variables);
|
|
878
|
+
},
|
|
879
|
+
GetMetadataSlot(variables, requestHeaders, signal) {
|
|
880
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlot", "query", variables);
|
|
881
|
+
},
|
|
882
|
+
GetMetadataSlotsByRecipient(variables, requestHeaders, signal) {
|
|
883
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsByRecipientDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlotsByRecipient", "query", variables);
|
|
884
|
+
},
|
|
885
|
+
GetMetadataUpdatedEvents(variables, requestHeaders, signal) {
|
|
886
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataUpdatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataUpdatedEvents", "query", variables);
|
|
887
|
+
},
|
|
888
|
+
GetSlots(variables, requestHeaders, signal) {
|
|
889
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlots", "query", variables);
|
|
890
|
+
},
|
|
891
|
+
GetSlot(variables, requestHeaders, signal) {
|
|
892
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlot", "query", variables);
|
|
893
|
+
},
|
|
894
|
+
GetSlotsByRecipient(variables, requestHeaders, signal) {
|
|
895
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsByRecipientDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotsByRecipient", "query", variables);
|
|
896
|
+
},
|
|
897
|
+
GetSlotsByOccupant(variables, requestHeaders, signal) {
|
|
898
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsByOccupantDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotsByOccupant", "query", variables);
|
|
899
|
+
}
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// src/errors.ts
|
|
904
|
+
var SlotsError = class extends Error {
|
|
905
|
+
constructor(operation, cause) {
|
|
906
|
+
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
907
|
+
super(`${operation}: ${msg}`);
|
|
908
|
+
this.operation = operation;
|
|
909
|
+
this.name = "SlotsError";
|
|
910
|
+
this.cause = cause;
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
var EXPECTED_MODULE_NAME = "MetadataModule";
|
|
914
|
+
var MetadataModuleClient = class {
|
|
915
|
+
constructor(opts) {
|
|
916
|
+
this.sdk = opts.sdk;
|
|
917
|
+
this._publicClient = opts.publicClient;
|
|
918
|
+
this._walletClient = opts.walletClient;
|
|
919
|
+
}
|
|
920
|
+
get wallet() {
|
|
921
|
+
if (!this._walletClient)
|
|
922
|
+
throw new SlotsError("metadata", "No walletClient provided");
|
|
923
|
+
return this._walletClient;
|
|
924
|
+
}
|
|
925
|
+
get account() {
|
|
926
|
+
const account = this.wallet.account;
|
|
927
|
+
if (!account)
|
|
928
|
+
throw new SlotsError("metadata", "WalletClient must have an account");
|
|
929
|
+
return account.address;
|
|
930
|
+
}
|
|
931
|
+
get chain() {
|
|
932
|
+
const chain = this.wallet.chain;
|
|
933
|
+
if (!chain)
|
|
934
|
+
throw new SlotsError("metadata", "WalletClient must have a chain");
|
|
935
|
+
return chain;
|
|
936
|
+
}
|
|
937
|
+
get publicClient() {
|
|
938
|
+
if (!this._publicClient)
|
|
939
|
+
throw new SlotsError("metadata", "No publicClient provided");
|
|
940
|
+
return this._publicClient;
|
|
941
|
+
}
|
|
942
|
+
async query(operation, fn) {
|
|
943
|
+
try {
|
|
944
|
+
return await fn();
|
|
945
|
+
} catch (error) {
|
|
946
|
+
throw new SlotsError(operation, error);
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Verify that a given address is a MetadataModule by calling `name()` on-chain.
|
|
951
|
+
* @param moduleAddress - The module contract address to verify
|
|
952
|
+
* @throws SlotsError if the contract doesn't return the expected name
|
|
953
|
+
*/
|
|
954
|
+
async verifyModule(moduleAddress) {
|
|
955
|
+
const name = await this.publicClient.readContract({
|
|
956
|
+
address: moduleAddress,
|
|
957
|
+
abi: metadataModuleAbi,
|
|
958
|
+
functionName: "name"
|
|
959
|
+
});
|
|
960
|
+
if (name !== EXPECTED_MODULE_NAME) {
|
|
961
|
+
throw new SlotsError(
|
|
962
|
+
"metadata",
|
|
963
|
+
`Contract at ${moduleAddress} is not a MetadataModule (name: "${name}")`
|
|
964
|
+
);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
968
|
+
// READ — Subgraph
|
|
969
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
970
|
+
/** Get all slots with metadata, ordered by most recently updated. */
|
|
971
|
+
getSlots(...args) {
|
|
972
|
+
return this.query(
|
|
973
|
+
"metadata.getSlots",
|
|
974
|
+
() => this.sdk.GetMetadataSlots(...args)
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
/** Get a single metadata slot by slot address. */
|
|
978
|
+
getSlot(...args) {
|
|
979
|
+
return this.query(
|
|
980
|
+
"metadata.getSlot",
|
|
981
|
+
() => this.sdk.GetMetadataSlot(...args)
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
/** Get all metadata slots for a given recipient. */
|
|
985
|
+
getSlotsByRecipient(...args) {
|
|
986
|
+
return this.query(
|
|
987
|
+
"metadata.getSlotsByRecipient",
|
|
988
|
+
() => this.sdk.GetMetadataSlotsByRecipient(...args)
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
/** Get metadata update history for a slot. */
|
|
992
|
+
getUpdateHistory(...args) {
|
|
993
|
+
return this.query(
|
|
994
|
+
"metadata.getUpdateHistory",
|
|
995
|
+
() => this.sdk.GetMetadataUpdatedEvents(...args)
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
999
|
+
// READ — RPC
|
|
1000
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1001
|
+
/**
|
|
1002
|
+
* Read the current URI for a slot directly from chain (bypasses subgraph).
|
|
1003
|
+
* @param moduleAddress - The MetadataModule contract address (from the slot's on-chain module field)
|
|
1004
|
+
* @param slot - The slot contract address
|
|
1005
|
+
*/
|
|
1006
|
+
async getURI(moduleAddress, slot) {
|
|
1007
|
+
return this.query(
|
|
1008
|
+
"metadata.getURI",
|
|
1009
|
+
() => this.publicClient.readContract({
|
|
1010
|
+
address: moduleAddress,
|
|
1011
|
+
abi: metadataModuleAbi,
|
|
1012
|
+
functionName: "tokenURI",
|
|
1013
|
+
args: [slot]
|
|
1014
|
+
})
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1018
|
+
// WRITE
|
|
1019
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1020
|
+
/**
|
|
1021
|
+
* Update the metadata URI for a slot. Only callable by the current occupant.
|
|
1022
|
+
* Verifies on-chain that the address is a MetadataModule before writing.
|
|
1023
|
+
* @param moduleAddress - The MetadataModule contract address (from the slot's on-chain module field)
|
|
1024
|
+
* @param slot - The slot contract address
|
|
1025
|
+
* @param uri - The new URI (e.g. ipfs://..., https://...)
|
|
1026
|
+
* @returns Transaction hash
|
|
1027
|
+
*/
|
|
1028
|
+
async updateMetadata(moduleAddress, slot, uri) {
|
|
1029
|
+
await this.verifyModule(moduleAddress);
|
|
1030
|
+
return this.wallet.writeContract({
|
|
1031
|
+
address: moduleAddress,
|
|
1032
|
+
abi: metadataModuleAbi,
|
|
1033
|
+
functionName: "updateMetadata",
|
|
1034
|
+
args: [slot, uri],
|
|
1035
|
+
account: this.account,
|
|
1036
|
+
chain: this.chain
|
|
1037
|
+
});
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
var META_QUERY = gql$1`
|
|
1041
|
+
query GetMeta {
|
|
1042
|
+
_meta {
|
|
1043
|
+
block {
|
|
1044
|
+
number
|
|
1045
|
+
hash
|
|
1046
|
+
timestamp
|
|
1047
|
+
}
|
|
1048
|
+
hasIndexingErrors
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
`;
|
|
1052
|
+
var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
|
|
1053
|
+
SlotsChain2[SlotsChain2["BASE"] = 8453] = "BASE";
|
|
1054
|
+
SlotsChain2[SlotsChain2["BASE_SEPOLIA"] = 84532] = "BASE_SEPOLIA";
|
|
1055
|
+
SlotsChain2[SlotsChain2["ARBITRUM"] = 42161] = "ARBITRUM";
|
|
1056
|
+
return SlotsChain2;
|
|
1057
|
+
})(SlotsChain || {});
|
|
1058
|
+
var SUBGRAPH_URLS = {
|
|
1059
|
+
[84532 /* BASE_SEPOLIA */]: "https://gateway.thegraph.com/api/subgraphs/id/Z361DLoMdPh9WAopH7shJP8WoXYAB9XeKrLUCTYjdZR",
|
|
1060
|
+
[8453 /* BASE */]: "https://gateway.thegraph.com/api/subgraphs/id/4sZrdv1SFzN4KzE9jiWDRuUyM4CnCrmvQ54Rv1s65qUq",
|
|
1061
|
+
[42161 /* ARBITRUM */]: "https://api.studio.thegraph.com/query/958/0-x-slots-arb/version/latest"
|
|
1062
|
+
};
|
|
1063
|
+
var SlotsClient = class {
|
|
1064
|
+
constructor(config) {
|
|
1065
|
+
this.chainId = config.chainId;
|
|
1066
|
+
this._publicClient = config.publicClient;
|
|
1067
|
+
this.walletClient = config.walletClient;
|
|
1068
|
+
this._factory = config.factoryAddress ?? getSlotsHubAddress(config.chainId);
|
|
1069
|
+
const url = config.subgraphUrl || SUBGRAPH_URLS[config.chainId];
|
|
1070
|
+
if (!url) throw new Error(`No subgraph URL for chain ${config.chainId}`);
|
|
1071
|
+
const headers = { ...config.headers };
|
|
1072
|
+
if (config.subgraphApiKey) {
|
|
1073
|
+
headers["Authorization"] = `Bearer ${config.subgraphApiKey}`;
|
|
1074
|
+
}
|
|
1075
|
+
this.gqlClient = new GraphQLClient(url, { headers });
|
|
1076
|
+
this.sdk = getSdk(this.gqlClient);
|
|
1077
|
+
this.modules = {
|
|
1078
|
+
metadata: new MetadataModuleClient({
|
|
1079
|
+
sdk: this.sdk,
|
|
1080
|
+
publicClient: config.publicClient,
|
|
1081
|
+
walletClient: config.walletClient
|
|
1082
|
+
})
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
// ─── Accessors ──────────────────────────────────────────────────────────────
|
|
1086
|
+
/** Returns the chain ID this client was configured for. */
|
|
1087
|
+
getChainId() {
|
|
1088
|
+
return this.chainId;
|
|
1089
|
+
}
|
|
1090
|
+
/** Returns the underlying GraphQL client (for advanced usage). */
|
|
1091
|
+
getClient() {
|
|
1092
|
+
return this.gqlClient;
|
|
1093
|
+
}
|
|
1094
|
+
/** Returns the generated GraphQL SDK (for queries not wrapped by this client). */
|
|
1095
|
+
getSdk() {
|
|
1096
|
+
return this.sdk;
|
|
1097
|
+
}
|
|
1098
|
+
get publicClient() {
|
|
1099
|
+
if (!this._publicClient) throw new Error("No publicClient provided");
|
|
1100
|
+
return this._publicClient;
|
|
1101
|
+
}
|
|
1102
|
+
get factory() {
|
|
1103
|
+
if (!this._factory) throw new Error("No factoryAddress provided");
|
|
1104
|
+
return this._factory;
|
|
1105
|
+
}
|
|
1106
|
+
get wallet() {
|
|
1107
|
+
if (!this.walletClient) throw new Error("No walletClient provided");
|
|
1108
|
+
return this.walletClient;
|
|
1109
|
+
}
|
|
1110
|
+
get account() {
|
|
1111
|
+
const account = this.wallet.account;
|
|
1112
|
+
if (!account) throw new Error("WalletClient must have an account");
|
|
1113
|
+
return account.address;
|
|
1114
|
+
}
|
|
1115
|
+
get chain() {
|
|
1116
|
+
const chain = this.wallet.chain;
|
|
1117
|
+
if (!chain) throw new Error("WalletClient must have a chain");
|
|
1118
|
+
return chain;
|
|
1119
|
+
}
|
|
1120
|
+
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
1121
|
+
assertPositive(value, name) {
|
|
1122
|
+
if (value <= 0n) throw new SlotsError(name, `${name} must be > 0`);
|
|
1123
|
+
}
|
|
1124
|
+
async query(operation, fn) {
|
|
1125
|
+
try {
|
|
1126
|
+
return await fn();
|
|
1127
|
+
} catch (error) {
|
|
1128
|
+
throw new SlotsError(operation, error);
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1132
|
+
// READ — Subgraph Queries
|
|
1133
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1134
|
+
// Slot queries
|
|
1135
|
+
/** Fetch a paginated list of slots. */
|
|
1136
|
+
getSlots(...args) {
|
|
1137
|
+
return this.query("getSlots", () => this.sdk.GetSlots(...args));
|
|
1138
|
+
}
|
|
1139
|
+
/** Fetch a single slot by its address. */
|
|
1140
|
+
getSlot(...args) {
|
|
1141
|
+
return this.query("getSlot", () => this.sdk.GetSlot(...args));
|
|
1142
|
+
}
|
|
1143
|
+
/** Fetch all slots owned by a given recipient address. */
|
|
1144
|
+
getSlotsByRecipient(...args) {
|
|
1145
|
+
return this.query("getSlotsByRecipient", () => this.sdk.GetSlotsByRecipient(...args));
|
|
1146
|
+
}
|
|
1147
|
+
/** Fetch all slots currently occupied by a given address. */
|
|
1148
|
+
getSlotsByOccupant(...args) {
|
|
1149
|
+
return this.query("getSlotsByOccupant", () => this.sdk.GetSlotsByOccupant(...args));
|
|
1150
|
+
}
|
|
1151
|
+
// Factory queries
|
|
1152
|
+
/** Fetch factory configuration. */
|
|
1153
|
+
getFactory() {
|
|
1154
|
+
return this.query("getFactory", () => this.sdk.GetFactory());
|
|
1155
|
+
}
|
|
1156
|
+
/** Fetch registered modules. */
|
|
1157
|
+
getModules(...args) {
|
|
1158
|
+
return this.query("getModules", () => this.sdk.GetModules(...args));
|
|
1159
|
+
}
|
|
1160
|
+
// Event queries
|
|
1161
|
+
/** Fetch slot deployed events with optional filters. */
|
|
1162
|
+
getSlotDeployedEvents(...args) {
|
|
1163
|
+
return this.query("getSlotDeployedEvents", () => this.sdk.GetSlotDeployedEvents(...args));
|
|
1164
|
+
}
|
|
1165
|
+
/** Fetch bought events with optional filters. */
|
|
1166
|
+
getBoughtEvents(...args) {
|
|
1167
|
+
return this.query("getBoughtEvents", () => this.sdk.GetBoughtEvents(...args));
|
|
1168
|
+
}
|
|
1169
|
+
/** Fetch settled events with optional filters. */
|
|
1170
|
+
getSettledEvents(...args) {
|
|
1171
|
+
return this.query("getSettledEvents", () => this.sdk.GetSettledEvents(...args));
|
|
1172
|
+
}
|
|
1173
|
+
/** Fetch tax-collected events with optional filters. */
|
|
1174
|
+
getTaxCollectedEvents(...args) {
|
|
1175
|
+
return this.query("getTaxCollectedEvents", () => this.sdk.GetTaxCollectedEvents(...args));
|
|
1176
|
+
}
|
|
1177
|
+
/** Fetch all activity for a specific slot (all event types). */
|
|
1178
|
+
getSlotActivity(...args) {
|
|
1179
|
+
return this.query("getSlotActivity", () => this.sdk.GetSlotActivity(...args));
|
|
1180
|
+
}
|
|
1181
|
+
/** Fetch the most recent events across all slots. */
|
|
1182
|
+
getRecentEvents(...args) {
|
|
1183
|
+
return this.query("getRecentEvents", () => this.sdk.GetRecentEvents(...args));
|
|
1184
|
+
}
|
|
1185
|
+
// Account queries
|
|
1186
|
+
/** Fetch a single account by address. */
|
|
1187
|
+
getAccount(...args) {
|
|
1188
|
+
return this.query("getAccount", () => this.sdk.GetAccount(...args));
|
|
1189
|
+
}
|
|
1190
|
+
/** Fetch a paginated list of accounts. */
|
|
1191
|
+
getAccounts(...args) {
|
|
1192
|
+
return this.query("getAccounts", () => this.sdk.GetAccounts(...args));
|
|
1193
|
+
}
|
|
1194
|
+
// Individual event queries
|
|
1195
|
+
/** Fetch released events with optional filters. */
|
|
1196
|
+
getReleasedEvents(...args) {
|
|
1197
|
+
return this.query("getReleasedEvents", () => this.sdk.GetReleasedEvents(...args));
|
|
1198
|
+
}
|
|
1199
|
+
/** Fetch liquidated events with optional filters. */
|
|
1200
|
+
getLiquidatedEvents(...args) {
|
|
1201
|
+
return this.query("getLiquidatedEvents", () => this.sdk.GetLiquidatedEvents(...args));
|
|
1202
|
+
}
|
|
1203
|
+
/** Fetch deposited events with optional filters. */
|
|
1204
|
+
getDepositedEvents(...args) {
|
|
1205
|
+
return this.query("getDepositedEvents", () => this.sdk.GetDepositedEvents(...args));
|
|
1206
|
+
}
|
|
1207
|
+
/** Fetch withdrawn events with optional filters. */
|
|
1208
|
+
getWithdrawnEvents(...args) {
|
|
1209
|
+
return this.query("getWithdrawnEvents", () => this.sdk.GetWithdrawnEvents(...args));
|
|
1210
|
+
}
|
|
1211
|
+
/** Fetch price-updated events with optional filters. */
|
|
1212
|
+
getPriceUpdatedEvents(...args) {
|
|
1213
|
+
return this.query("getPriceUpdatedEvents", () => this.sdk.GetPriceUpdatedEvents(...args));
|
|
1214
|
+
}
|
|
1215
|
+
// Meta
|
|
1216
|
+
/** Fetch subgraph indexing metadata (latest block, indexing errors). */
|
|
1217
|
+
getMeta() {
|
|
1218
|
+
return this.query("getMeta", () => this.gqlClient.request(META_QUERY));
|
|
1219
|
+
}
|
|
1220
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1221
|
+
// READ — On-chain (RPC)
|
|
1222
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1223
|
+
/**
|
|
1224
|
+
* Read full slot info from on-chain (RPC, not subgraph).
|
|
1225
|
+
* @param slot - Slot contract address.
|
|
1226
|
+
* @returns On-chain slot info tuple.
|
|
1227
|
+
* @throws {SlotsError} If the RPC call fails.
|
|
1228
|
+
*/
|
|
1229
|
+
getSlotInfo(slot) {
|
|
1230
|
+
return this.query(
|
|
1231
|
+
"getSlotInfo",
|
|
1232
|
+
() => this.publicClient.readContract({
|
|
1233
|
+
address: slot,
|
|
1234
|
+
abi: slotAbi,
|
|
1235
|
+
functionName: "getSlotInfo"
|
|
1236
|
+
})
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1240
|
+
// WRITE — Factory Functions
|
|
1241
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1242
|
+
/**
|
|
1243
|
+
* Deploy a new slot via the factory contract.
|
|
1244
|
+
* @param params - Slot creation parameters (recipient, currency, config, initParams).
|
|
1245
|
+
* @returns Transaction hash.
|
|
1246
|
+
*/
|
|
1247
|
+
async createSlot(params) {
|
|
1248
|
+
return this.wallet.writeContract({
|
|
1249
|
+
address: this.factory,
|
|
1250
|
+
abi: slotFactoryAbi,
|
|
1251
|
+
functionName: "createSlot",
|
|
1252
|
+
args: [params.recipient, params.currency, params.config, params.initParams],
|
|
1253
|
+
account: this.account,
|
|
1254
|
+
chain: this.chain
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Deploy multiple identical slots in a single transaction via the factory contract.
|
|
1259
|
+
* @param params - Slot creation parameters including count.
|
|
1260
|
+
* @returns Transaction hash.
|
|
1261
|
+
*/
|
|
1262
|
+
async createSlots(params) {
|
|
1263
|
+
return this.wallet.writeContract({
|
|
1264
|
+
address: this.factory,
|
|
1265
|
+
abi: slotFactoryAbi,
|
|
1266
|
+
functionName: "createSlots",
|
|
1267
|
+
args: [params.recipient, params.currency, params.config, params.initParams, params.count],
|
|
1268
|
+
account: this.account,
|
|
1269
|
+
chain: this.chain
|
|
1270
|
+
});
|
|
1271
|
+
}
|
|
1272
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1273
|
+
// WRITE — Slot Functions
|
|
1274
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1275
|
+
/**
|
|
1276
|
+
* Buy a slot (or force-buy an occupied one). Handles ERC-20 approval automatically.
|
|
1277
|
+
* @param params - Buy parameters (slot address, deposit amount, self-assessed price).
|
|
1278
|
+
* @returns Transaction hash.
|
|
1279
|
+
* @throws {SlotsError} If depositAmount or selfAssessedPrice is not positive, or the transaction fails.
|
|
1280
|
+
*/
|
|
1281
|
+
async buy(params) {
|
|
1282
|
+
this.assertPositive(params.depositAmount, "depositAmount");
|
|
1283
|
+
this.assertPositive(params.selfAssessedPrice, "selfAssessedPrice");
|
|
1284
|
+
return this.withAllowance(params.slot, params.depositAmount, {
|
|
1285
|
+
to: params.slot,
|
|
1286
|
+
abi: slotAbi,
|
|
1287
|
+
functionName: "buy",
|
|
1288
|
+
args: [params.depositAmount, params.selfAssessedPrice]
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Self-assess a new price for an occupied slot (occupant only).
|
|
1293
|
+
* @param slot - The slot contract address.
|
|
1294
|
+
* @param newPrice - The new self-assessed price (can be 0).
|
|
1295
|
+
* @returns Transaction hash.
|
|
1296
|
+
*/
|
|
1297
|
+
async selfAssess(slot, newPrice) {
|
|
1298
|
+
return this.wallet.writeContract({
|
|
1299
|
+
address: slot,
|
|
1300
|
+
abi: slotAbi,
|
|
1301
|
+
functionName: "selfAssess",
|
|
1302
|
+
args: [newPrice],
|
|
1303
|
+
account: this.account,
|
|
1304
|
+
chain: this.chain
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Top up deposit on a slot (occupant only). Handles ERC-20 approval automatically.
|
|
1309
|
+
* @param slot - The slot contract address.
|
|
1310
|
+
* @param amount - The amount to deposit (must be > 0).
|
|
1311
|
+
* @returns Transaction hash.
|
|
1312
|
+
* @throws {SlotsError} If amount is not positive, or the transaction fails.
|
|
1313
|
+
*/
|
|
1314
|
+
async topUp(slot, amount) {
|
|
1315
|
+
this.assertPositive(amount, "amount");
|
|
1316
|
+
return this.withAllowance(slot, amount, {
|
|
1317
|
+
to: slot,
|
|
1318
|
+
abi: slotAbi,
|
|
1319
|
+
functionName: "topUp",
|
|
1320
|
+
args: [amount]
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Withdraw from deposit (occupant only). Cannot go below minimum deposit.
|
|
1325
|
+
* @param slot - The slot contract address.
|
|
1326
|
+
* @param amount - The amount to withdraw (must be > 0).
|
|
1327
|
+
* @returns Transaction hash.
|
|
1328
|
+
* @throws {SlotsError} If amount is not positive, or the transaction fails.
|
|
1329
|
+
*/
|
|
1330
|
+
async withdraw(slot, amount) {
|
|
1331
|
+
this.assertPositive(amount, "amount");
|
|
1332
|
+
return this.wallet.writeContract({
|
|
1333
|
+
address: slot,
|
|
1334
|
+
abi: slotAbi,
|
|
1335
|
+
functionName: "withdraw",
|
|
1336
|
+
args: [amount],
|
|
1337
|
+
account: this.account,
|
|
1338
|
+
chain: this.chain
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Release a slot (occupant only). Returns remaining deposit to the occupant.
|
|
1343
|
+
* @param slot - The slot contract address.
|
|
1344
|
+
* @returns Transaction hash.
|
|
1345
|
+
*/
|
|
1346
|
+
async release(slot) {
|
|
1347
|
+
return this.wallet.writeContract({
|
|
1348
|
+
address: slot,
|
|
1349
|
+
abi: slotAbi,
|
|
1350
|
+
functionName: "release",
|
|
1351
|
+
account: this.account,
|
|
1352
|
+
chain: this.chain
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
/**
|
|
1356
|
+
* Collect accumulated tax (permissionless).
|
|
1357
|
+
* @param slot - The slot contract address.
|
|
1358
|
+
* @returns Transaction hash.
|
|
1359
|
+
*/
|
|
1360
|
+
async collect(slot) {
|
|
1361
|
+
return this.wallet.writeContract({
|
|
1362
|
+
address: slot,
|
|
1363
|
+
abi: slotAbi,
|
|
1364
|
+
functionName: "collect",
|
|
1365
|
+
account: this.account,
|
|
1366
|
+
chain: this.chain
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Liquidate an insolvent slot (permissionless). Caller receives bounty.
|
|
1371
|
+
* @param slot - The slot contract address.
|
|
1372
|
+
* @returns Transaction hash.
|
|
1373
|
+
*/
|
|
1374
|
+
async liquidate(slot) {
|
|
1375
|
+
return this.wallet.writeContract({
|
|
1376
|
+
address: slot,
|
|
1377
|
+
abi: slotAbi,
|
|
1378
|
+
functionName: "liquidate",
|
|
1379
|
+
account: this.account,
|
|
1380
|
+
chain: this.chain
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1384
|
+
// WRITE — Manager Functions
|
|
1385
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1386
|
+
/**
|
|
1387
|
+
* Propose a tax rate update (manager only, slot must have mutableTax).
|
|
1388
|
+
* @param slot - The slot contract address.
|
|
1389
|
+
* @param newPct - The new tax percentage.
|
|
1390
|
+
* @returns Transaction hash.
|
|
1391
|
+
*/
|
|
1392
|
+
async proposeTaxUpdate(slot, newPct) {
|
|
1393
|
+
return this.wallet.writeContract({
|
|
1394
|
+
address: slot,
|
|
1395
|
+
abi: slotAbi,
|
|
1396
|
+
functionName: "proposeTaxUpdate",
|
|
1397
|
+
args: [newPct],
|
|
1398
|
+
account: this.account,
|
|
1399
|
+
chain: this.chain
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Propose a module update (manager only, slot must have mutableModule).
|
|
1404
|
+
* @param slot - The slot contract address.
|
|
1405
|
+
* @param newModule - The new module contract address.
|
|
1406
|
+
* @returns Transaction hash.
|
|
1407
|
+
*/
|
|
1408
|
+
async proposeModuleUpdate(slot, newModule) {
|
|
1409
|
+
return this.wallet.writeContract({
|
|
1410
|
+
address: slot,
|
|
1411
|
+
abi: slotAbi,
|
|
1412
|
+
functionName: "proposeModuleUpdate",
|
|
1413
|
+
args: [newModule],
|
|
1414
|
+
account: this.account,
|
|
1415
|
+
chain: this.chain
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
/**
|
|
1419
|
+
* Cancel pending updates (manager only).
|
|
1420
|
+
* @param slot - The slot contract address.
|
|
1421
|
+
* @returns Transaction hash.
|
|
1422
|
+
*/
|
|
1423
|
+
async cancelPendingUpdates(slot) {
|
|
1424
|
+
return this.wallet.writeContract({
|
|
1425
|
+
address: slot,
|
|
1426
|
+
abi: slotAbi,
|
|
1427
|
+
functionName: "cancelPendingUpdates",
|
|
1428
|
+
account: this.account,
|
|
1429
|
+
chain: this.chain
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* Set liquidation bounty bps (manager only).
|
|
1434
|
+
* @param slot - The slot contract address.
|
|
1435
|
+
* @param newBps - The new bounty in basis points (0-10000).
|
|
1436
|
+
* @returns Transaction hash.
|
|
1437
|
+
* @throws {SlotsError} If newBps is outside 0-10000, or the transaction fails.
|
|
1438
|
+
*/
|
|
1439
|
+
async setLiquidationBounty(slot, newBps) {
|
|
1440
|
+
if (newBps < 0n || newBps > 10000n) throw new SlotsError("setLiquidationBounty", "newBps must be 0-10000");
|
|
1441
|
+
return this.wallet.writeContract({
|
|
1442
|
+
address: slot,
|
|
1443
|
+
abi: slotAbi,
|
|
1444
|
+
functionName: "setLiquidationBounty",
|
|
1445
|
+
args: [newBps],
|
|
1446
|
+
account: this.account,
|
|
1447
|
+
chain: this.chain
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1451
|
+
// WRITE — Multicall
|
|
1452
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1453
|
+
/**
|
|
1454
|
+
* Batch multiple slot calls into one transaction via multicall.
|
|
1455
|
+
* @param slot - The slot contract address.
|
|
1456
|
+
* @param calls - Array of function calls to batch.
|
|
1457
|
+
* @returns Transaction hash.
|
|
1458
|
+
* @throws {SlotsError} If calls array is empty, or the transaction fails.
|
|
1459
|
+
*/
|
|
1460
|
+
async multicall(slot, calls) {
|
|
1461
|
+
if (calls.length === 0) throw new SlotsError("multicall", "calls array must not be empty");
|
|
1462
|
+
const data = calls.map(
|
|
1463
|
+
(call) => encodeFunctionData({
|
|
1464
|
+
abi: slotAbi,
|
|
1465
|
+
functionName: call.functionName,
|
|
1466
|
+
args: call.args
|
|
1467
|
+
})
|
|
1468
|
+
);
|
|
1469
|
+
return this.wallet.writeContract({
|
|
1470
|
+
address: slot,
|
|
1471
|
+
abi: slotAbi,
|
|
1472
|
+
functionName: "multicall",
|
|
1473
|
+
args: [data],
|
|
1474
|
+
account: this.account,
|
|
1475
|
+
chain: this.chain
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
// ─── Internals ──────────────────────────────────────────────────────────────
|
|
1479
|
+
/** Check if wallet supports atomic batch calls (EIP-5792). */
|
|
1480
|
+
async supportsAtomicBatch() {
|
|
1481
|
+
if (this._atomicSupport !== void 0) return this._atomicSupport;
|
|
1482
|
+
try {
|
|
1483
|
+
const capabilities = await this.wallet.getCapabilities?.();
|
|
1484
|
+
if (!capabilities) {
|
|
1485
|
+
this._atomicSupport = false;
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
const chainId = this.chain.id;
|
|
1489
|
+
const chainCaps = capabilities[chainId] || capabilities[`0x${chainId.toString(16)}`];
|
|
1490
|
+
const atomic = chainCaps?.atomicBatch ?? chainCaps?.atomic;
|
|
1491
|
+
const status = atomic && typeof atomic === "object" && "status" in atomic ? atomic.status : void 0;
|
|
1492
|
+
this._atomicSupport = status === "supported" || status === "ready";
|
|
1493
|
+
} catch {
|
|
1494
|
+
this._atomicSupport = false;
|
|
1495
|
+
}
|
|
1496
|
+
return this._atomicSupport;
|
|
1497
|
+
}
|
|
1498
|
+
/** Poll EIP-5792 getCallsStatus until the batch settles, then return a tx hash. */
|
|
1499
|
+
async pollBatchReceipt(id) {
|
|
1500
|
+
const MAX_ATTEMPTS = 60;
|
|
1501
|
+
const INTERVAL = 1500;
|
|
1502
|
+
for (let i = 0; i < MAX_ATTEMPTS; i++) {
|
|
1503
|
+
const result = await this.wallet.getCallsStatus({ id });
|
|
1504
|
+
if (result.status === "success") {
|
|
1505
|
+
const receipts = result.receipts ?? [];
|
|
1506
|
+
return receipts[receipts.length - 1]?.transactionHash ?? id;
|
|
1507
|
+
}
|
|
1508
|
+
if (result.status === "failure") {
|
|
1509
|
+
throw new Error("Batch transaction reverted");
|
|
1510
|
+
}
|
|
1511
|
+
await new Promise((r) => setTimeout(r, INTERVAL));
|
|
1512
|
+
}
|
|
1513
|
+
throw new Error("Batch transaction timed out");
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Execute a contract call that needs ERC-20 allowance.
|
|
1517
|
+
* If wallet supports atomic batch (EIP-5792): sends approve + action as one atomic call.
|
|
1518
|
+
* Otherwise: chains approve tx (if needed) then action tx.
|
|
1519
|
+
*/
|
|
1520
|
+
async withAllowance(spender, amount, call) {
|
|
1521
|
+
const currency = await this.publicClient.readContract({
|
|
1522
|
+
address: spender,
|
|
1523
|
+
abi: slotAbi,
|
|
1524
|
+
functionName: "currency"
|
|
1525
|
+
});
|
|
1526
|
+
const allowance = await this.publicClient.readContract({
|
|
1527
|
+
address: currency,
|
|
1528
|
+
abi: erc20Abi,
|
|
1529
|
+
functionName: "allowance",
|
|
1530
|
+
args: [this.account, spender]
|
|
1531
|
+
});
|
|
1532
|
+
const needsApproval = allowance < amount;
|
|
1533
|
+
if (needsApproval && await this.supportsAtomicBatch()) {
|
|
1534
|
+
const approveData = encodeFunctionData({
|
|
1535
|
+
abi: erc20Abi,
|
|
1536
|
+
functionName: "approve",
|
|
1537
|
+
args: [spender, amount]
|
|
1538
|
+
});
|
|
1539
|
+
const actionData = encodeFunctionData({
|
|
1540
|
+
abi: call.abi,
|
|
1541
|
+
functionName: call.functionName,
|
|
1542
|
+
args: call.args
|
|
1543
|
+
});
|
|
1544
|
+
const id = await this.wallet.sendCalls({
|
|
1545
|
+
account: this.account,
|
|
1546
|
+
chain: this.chain,
|
|
1547
|
+
calls: [
|
|
1548
|
+
{ to: currency, data: approveData },
|
|
1549
|
+
{ to: call.to, data: actionData }
|
|
1550
|
+
]
|
|
1551
|
+
});
|
|
1552
|
+
const txHash = await this.pollBatchReceipt(id);
|
|
1553
|
+
return txHash;
|
|
1554
|
+
}
|
|
1555
|
+
if (needsApproval) {
|
|
1556
|
+
const hash = await this.wallet.writeContract({
|
|
1557
|
+
address: currency,
|
|
1558
|
+
abi: erc20Abi,
|
|
1559
|
+
functionName: "approve",
|
|
1560
|
+
args: [spender, amount],
|
|
1561
|
+
account: this.account,
|
|
1562
|
+
chain: this.chain
|
|
1563
|
+
});
|
|
1564
|
+
await this.publicClient.waitForTransactionReceipt({ hash });
|
|
1565
|
+
}
|
|
1566
|
+
return this.wallet.writeContract({
|
|
1567
|
+
address: call.to,
|
|
1568
|
+
abi: call.abi,
|
|
1569
|
+
functionName: call.functionName,
|
|
1570
|
+
args: call.args,
|
|
1571
|
+
account: this.account,
|
|
1572
|
+
chain: this.chain
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
};
|
|
1576
|
+
function createSlotsClient(config) {
|
|
1577
|
+
return new SlotsClient(config);
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
export { AccountFieldsFragmentDoc, CurrencyFieldsFragmentDoc, GetAccountDocument, GetAccountsDocument, GetBoughtEventsDocument, GetDepositedEventsDocument, GetFactoryDocument, GetLiquidatedEventsDocument, GetMetadataSlotDocument, GetMetadataSlotsByRecipientDocument, GetMetadataSlotsDocument, GetMetadataUpdatedEventsDocument, GetModulesDocument, GetPriceUpdatedEventsDocument, GetRecentEventsDocument, GetReleasedEventsDocument, GetSettledEventsDocument, GetSlotActivityDocument, GetSlotDeployedEventsDocument, GetSlotDocument, GetSlotsByOccupantDocument, GetSlotsByRecipientDocument, GetSlotsDocument, GetTaxCollectedEventsDocument, GetWithdrawnEventsDocument, MetadataModuleClient, MetadataSlotFieldsFragmentDoc, SUBGRAPH_URLS, SlotFieldsFragmentDoc, SlotsChain, SlotsClient, SlotsError, createSlotsClient, getSdk };
|
|
1581
|
+
//# sourceMappingURL=chunk-KRJINGNH.js.map
|
|
1582
|
+
//# sourceMappingURL=chunk-KRJINGNH.js.map
|