@0xslots/sdk 0.8.0 → 0.8.3
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 +619 -36
- package/dist/index.js +316 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { gql as gql$1, GraphQLClient } from 'graphql-request';
|
|
2
2
|
import gql from 'graphql-tag';
|
|
3
3
|
import { encodeFunctionData, erc20Abi } from 'viem';
|
|
4
|
-
import { getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts';
|
|
4
|
+
import { getMetadataModuleAddress, metadataModuleAbi, getSlotsHubAddress, slotAbi, slotFactoryAbi } from '@0xslots/contracts';
|
|
5
5
|
|
|
6
6
|
// src/client.ts
|
|
7
7
|
var AccountFieldsFragmentDoc = gql`
|
|
@@ -26,6 +26,30 @@ var CurrencyFieldsFragmentDoc = gql`
|
|
|
26
26
|
decimals
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
|
+
var MetadataSlotFieldsFragmentDoc = gql`
|
|
30
|
+
fragment MetadataSlotFields on MetadataSlot {
|
|
31
|
+
id
|
|
32
|
+
uri
|
|
33
|
+
updatedBy
|
|
34
|
+
updateCount
|
|
35
|
+
createdAt
|
|
36
|
+
createdTx
|
|
37
|
+
updatedAt
|
|
38
|
+
updatedTx
|
|
39
|
+
slot {
|
|
40
|
+
id
|
|
41
|
+
recipient
|
|
42
|
+
occupant
|
|
43
|
+
price
|
|
44
|
+
deposit
|
|
45
|
+
currency {
|
|
46
|
+
id
|
|
47
|
+
symbol
|
|
48
|
+
decimals
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
`;
|
|
29
53
|
var SlotFieldsFragmentDoc = gql`
|
|
30
54
|
fragment SlotFields on Slot {
|
|
31
55
|
id
|
|
@@ -91,9 +115,64 @@ var GetAccountsDocument = gql`
|
|
|
91
115
|
}
|
|
92
116
|
}
|
|
93
117
|
${AccountFieldsFragmentDoc}`;
|
|
118
|
+
var GetSlotDeployedEventsDocument = gql`
|
|
119
|
+
query GetSlotDeployedEvents($first: Int!, $skip: Int, $orderBy: SlotDeployedEvent_orderBy, $orderDirection: OrderDirection, $where: SlotDeployedEvent_filter, $block: Block_height) {
|
|
120
|
+
slotDeployedEvents(
|
|
121
|
+
first: $first
|
|
122
|
+
skip: $skip
|
|
123
|
+
orderBy: $orderBy
|
|
124
|
+
orderDirection: $orderDirection
|
|
125
|
+
where: $where
|
|
126
|
+
block: $block
|
|
127
|
+
) {
|
|
128
|
+
id
|
|
129
|
+
slot {
|
|
130
|
+
id
|
|
131
|
+
}
|
|
132
|
+
recipient
|
|
133
|
+
currency {
|
|
134
|
+
...CurrencyFields
|
|
135
|
+
}
|
|
136
|
+
manager
|
|
137
|
+
mutableTax
|
|
138
|
+
mutableModule
|
|
139
|
+
taxPercentage
|
|
140
|
+
module
|
|
141
|
+
liquidationBountyBps
|
|
142
|
+
minDepositSeconds
|
|
143
|
+
deployer
|
|
144
|
+
timestamp
|
|
145
|
+
blockNumber
|
|
146
|
+
tx
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
${CurrencyFieldsFragmentDoc}`;
|
|
94
150
|
var GetRecentEventsDocument = gql`
|
|
95
|
-
query GetRecentEvents($first: Int
|
|
96
|
-
|
|
151
|
+
query GetRecentEvents($first: Int!, $skip: Int) {
|
|
152
|
+
slotDeployedEvents(
|
|
153
|
+
first: $first
|
|
154
|
+
skip: $skip
|
|
155
|
+
orderBy: timestamp
|
|
156
|
+
orderDirection: desc
|
|
157
|
+
) {
|
|
158
|
+
id
|
|
159
|
+
slot {
|
|
160
|
+
id
|
|
161
|
+
}
|
|
162
|
+
recipient
|
|
163
|
+
currency {
|
|
164
|
+
...CurrencyFields
|
|
165
|
+
}
|
|
166
|
+
deployer
|
|
167
|
+
timestamp
|
|
168
|
+
tx
|
|
169
|
+
}
|
|
170
|
+
boughtEvents(
|
|
171
|
+
first: $first
|
|
172
|
+
skip: $skip
|
|
173
|
+
orderBy: timestamp
|
|
174
|
+
orderDirection: desc
|
|
175
|
+
) {
|
|
97
176
|
id
|
|
98
177
|
slot {
|
|
99
178
|
id
|
|
@@ -109,7 +188,12 @@ var GetRecentEventsDocument = gql`
|
|
|
109
188
|
timestamp
|
|
110
189
|
tx
|
|
111
190
|
}
|
|
112
|
-
releasedEvents(
|
|
191
|
+
releasedEvents(
|
|
192
|
+
first: $first
|
|
193
|
+
skip: $skip
|
|
194
|
+
orderBy: timestamp
|
|
195
|
+
orderDirection: desc
|
|
196
|
+
) {
|
|
113
197
|
id
|
|
114
198
|
slot {
|
|
115
199
|
id
|
|
@@ -122,7 +206,12 @@ var GetRecentEventsDocument = gql`
|
|
|
122
206
|
timestamp
|
|
123
207
|
tx
|
|
124
208
|
}
|
|
125
|
-
liquidatedEvents(
|
|
209
|
+
liquidatedEvents(
|
|
210
|
+
first: $first
|
|
211
|
+
skip: $skip
|
|
212
|
+
orderBy: timestamp
|
|
213
|
+
orderDirection: desc
|
|
214
|
+
) {
|
|
126
215
|
id
|
|
127
216
|
slot {
|
|
128
217
|
id
|
|
@@ -136,7 +225,12 @@ var GetRecentEventsDocument = gql`
|
|
|
136
225
|
timestamp
|
|
137
226
|
tx
|
|
138
227
|
}
|
|
139
|
-
priceUpdatedEvents(
|
|
228
|
+
priceUpdatedEvents(
|
|
229
|
+
first: $first
|
|
230
|
+
skip: $skip
|
|
231
|
+
orderBy: timestamp
|
|
232
|
+
orderDirection: desc
|
|
233
|
+
) {
|
|
140
234
|
id
|
|
141
235
|
slot {
|
|
142
236
|
id
|
|
@@ -149,7 +243,12 @@ var GetRecentEventsDocument = gql`
|
|
|
149
243
|
timestamp
|
|
150
244
|
tx
|
|
151
245
|
}
|
|
152
|
-
depositedEvents(
|
|
246
|
+
depositedEvents(
|
|
247
|
+
first: $first
|
|
248
|
+
skip: $skip
|
|
249
|
+
orderBy: timestamp
|
|
250
|
+
orderDirection: desc
|
|
251
|
+
) {
|
|
153
252
|
id
|
|
154
253
|
slot {
|
|
155
254
|
id
|
|
@@ -162,7 +261,12 @@ var GetRecentEventsDocument = gql`
|
|
|
162
261
|
timestamp
|
|
163
262
|
tx
|
|
164
263
|
}
|
|
165
|
-
withdrawnEvents(
|
|
264
|
+
withdrawnEvents(
|
|
265
|
+
first: $first
|
|
266
|
+
skip: $skip
|
|
267
|
+
orderBy: timestamp
|
|
268
|
+
orderDirection: desc
|
|
269
|
+
) {
|
|
166
270
|
id
|
|
167
271
|
slot {
|
|
168
272
|
id
|
|
@@ -175,7 +279,12 @@ var GetRecentEventsDocument = gql`
|
|
|
175
279
|
timestamp
|
|
176
280
|
tx
|
|
177
281
|
}
|
|
178
|
-
taxCollectedEvents(
|
|
282
|
+
taxCollectedEvents(
|
|
283
|
+
first: $first
|
|
284
|
+
skip: $skip
|
|
285
|
+
orderBy: timestamp
|
|
286
|
+
orderDirection: desc
|
|
287
|
+
) {
|
|
179
288
|
id
|
|
180
289
|
slot {
|
|
181
290
|
id
|
|
@@ -188,7 +297,12 @@ var GetRecentEventsDocument = gql`
|
|
|
188
297
|
timestamp
|
|
189
298
|
tx
|
|
190
299
|
}
|
|
191
|
-
taxUpdateProposedEvents(
|
|
300
|
+
taxUpdateProposedEvents(
|
|
301
|
+
first: $first
|
|
302
|
+
skip: $skip
|
|
303
|
+
orderBy: timestamp
|
|
304
|
+
orderDirection: desc
|
|
305
|
+
) {
|
|
192
306
|
id
|
|
193
307
|
slot {
|
|
194
308
|
id
|
|
@@ -199,6 +313,7 @@ var GetRecentEventsDocument = gql`
|
|
|
199
313
|
}
|
|
200
314
|
moduleUpdateProposedEvents(
|
|
201
315
|
first: $first
|
|
316
|
+
skip: $skip
|
|
202
317
|
orderBy: timestamp
|
|
203
318
|
orderDirection: desc
|
|
204
319
|
) {
|
|
@@ -212,6 +327,7 @@ var GetRecentEventsDocument = gql`
|
|
|
212
327
|
}
|
|
213
328
|
pendingUpdateCancelledEvents(
|
|
214
329
|
first: $first
|
|
330
|
+
skip: $skip
|
|
215
331
|
orderBy: timestamp
|
|
216
332
|
orderDirection: desc
|
|
217
333
|
) {
|
|
@@ -430,9 +546,10 @@ var GetPriceUpdatedEventsDocument = gql`
|
|
|
430
546
|
}
|
|
431
547
|
${CurrencyFieldsFragmentDoc}`;
|
|
432
548
|
var GetSlotActivityDocument = gql`
|
|
433
|
-
query GetSlotActivity($slotId: String!, $first: Int
|
|
549
|
+
query GetSlotActivity($slotId: String!, $first: Int!, $skip: Int) {
|
|
434
550
|
boughtEvents(
|
|
435
551
|
first: $first
|
|
552
|
+
skip: $skip
|
|
436
553
|
orderBy: timestamp
|
|
437
554
|
orderDirection: desc
|
|
438
555
|
where: {slot: $slotId}
|
|
@@ -451,6 +568,7 @@ var GetSlotActivityDocument = gql`
|
|
|
451
568
|
}
|
|
452
569
|
releasedEvents(
|
|
453
570
|
first: $first
|
|
571
|
+
skip: $skip
|
|
454
572
|
orderBy: timestamp
|
|
455
573
|
orderDirection: desc
|
|
456
574
|
where: {slot: $slotId}
|
|
@@ -466,6 +584,7 @@ var GetSlotActivityDocument = gql`
|
|
|
466
584
|
}
|
|
467
585
|
liquidatedEvents(
|
|
468
586
|
first: $first
|
|
587
|
+
skip: $skip
|
|
469
588
|
orderBy: timestamp
|
|
470
589
|
orderDirection: desc
|
|
471
590
|
where: {slot: $slotId}
|
|
@@ -482,6 +601,7 @@ var GetSlotActivityDocument = gql`
|
|
|
482
601
|
}
|
|
483
602
|
priceUpdatedEvents(
|
|
484
603
|
first: $first
|
|
604
|
+
skip: $skip
|
|
485
605
|
orderBy: timestamp
|
|
486
606
|
orderDirection: desc
|
|
487
607
|
where: {slot: $slotId}
|
|
@@ -497,6 +617,7 @@ var GetSlotActivityDocument = gql`
|
|
|
497
617
|
}
|
|
498
618
|
depositedEvents(
|
|
499
619
|
first: $first
|
|
620
|
+
skip: $skip
|
|
500
621
|
orderBy: timestamp
|
|
501
622
|
orderDirection: desc
|
|
502
623
|
where: {slot: $slotId}
|
|
@@ -512,6 +633,7 @@ var GetSlotActivityDocument = gql`
|
|
|
512
633
|
}
|
|
513
634
|
withdrawnEvents(
|
|
514
635
|
first: $first
|
|
636
|
+
skip: $skip
|
|
515
637
|
orderBy: timestamp
|
|
516
638
|
orderDirection: desc
|
|
517
639
|
where: {slot: $slotId}
|
|
@@ -527,6 +649,7 @@ var GetSlotActivityDocument = gql`
|
|
|
527
649
|
}
|
|
528
650
|
taxCollectedEvents(
|
|
529
651
|
first: $first
|
|
652
|
+
skip: $skip
|
|
530
653
|
orderBy: timestamp
|
|
531
654
|
orderDirection: desc
|
|
532
655
|
where: {slot: $slotId}
|
|
@@ -542,6 +665,7 @@ var GetSlotActivityDocument = gql`
|
|
|
542
665
|
}
|
|
543
666
|
taxUpdateProposedEvents(
|
|
544
667
|
first: $first
|
|
668
|
+
skip: $skip
|
|
545
669
|
orderBy: timestamp
|
|
546
670
|
orderDirection: desc
|
|
547
671
|
where: {slot: $slotId}
|
|
@@ -553,6 +677,7 @@ var GetSlotActivityDocument = gql`
|
|
|
553
677
|
}
|
|
554
678
|
moduleUpdateProposedEvents(
|
|
555
679
|
first: $first
|
|
680
|
+
skip: $skip
|
|
556
681
|
orderBy: timestamp
|
|
557
682
|
orderDirection: desc
|
|
558
683
|
where: {slot: $slotId}
|
|
@@ -564,6 +689,7 @@ var GetSlotActivityDocument = gql`
|
|
|
564
689
|
}
|
|
565
690
|
pendingUpdateCancelledEvents(
|
|
566
691
|
first: $first
|
|
692
|
+
skip: $skip
|
|
567
693
|
orderBy: timestamp
|
|
568
694
|
orderDirection: desc
|
|
569
695
|
where: {slot: $slotId}
|
|
@@ -592,6 +718,56 @@ var GetModulesDocument = gql`
|
|
|
592
718
|
}
|
|
593
719
|
}
|
|
594
720
|
`;
|
|
721
|
+
var GetMetadataSlotsDocument = gql`
|
|
722
|
+
query GetMetadataSlots($first: Int = 100, $skip: Int = 0, $orderBy: MetadataSlot_orderBy = updatedAt, $orderDirection: OrderDirection = desc) {
|
|
723
|
+
metadataSlots(
|
|
724
|
+
first: $first
|
|
725
|
+
skip: $skip
|
|
726
|
+
orderBy: $orderBy
|
|
727
|
+
orderDirection: $orderDirection
|
|
728
|
+
) {
|
|
729
|
+
...MetadataSlotFields
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
${MetadataSlotFieldsFragmentDoc}`;
|
|
733
|
+
var GetMetadataSlotDocument = gql`
|
|
734
|
+
query GetMetadataSlot($id: ID!) {
|
|
735
|
+
metadataSlot(id: $id) {
|
|
736
|
+
...MetadataSlotFields
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
${MetadataSlotFieldsFragmentDoc}`;
|
|
740
|
+
var GetMetadataSlotsByRecipientDocument = gql`
|
|
741
|
+
query GetMetadataSlotsByRecipient($recipient: Bytes!, $first: Int = 100) {
|
|
742
|
+
metadataSlots(
|
|
743
|
+
first: $first
|
|
744
|
+
where: {slot_: {recipient: $recipient}}
|
|
745
|
+
orderBy: updatedAt
|
|
746
|
+
orderDirection: desc
|
|
747
|
+
) {
|
|
748
|
+
...MetadataSlotFields
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
${MetadataSlotFieldsFragmentDoc}`;
|
|
752
|
+
var GetMetadataUpdatedEventsDocument = gql`
|
|
753
|
+
query GetMetadataUpdatedEvents($slot: String, $first: Int = 50, $orderBy: MetadataUpdatedEvent_orderBy = timestamp, $orderDirection: OrderDirection = desc) {
|
|
754
|
+
metadataUpdatedEvents(
|
|
755
|
+
first: $first
|
|
756
|
+
where: {slot: $slot}
|
|
757
|
+
orderBy: $orderBy
|
|
758
|
+
orderDirection: $orderDirection
|
|
759
|
+
) {
|
|
760
|
+
id
|
|
761
|
+
slot {
|
|
762
|
+
id
|
|
763
|
+
}
|
|
764
|
+
uri
|
|
765
|
+
timestamp
|
|
766
|
+
blockNumber
|
|
767
|
+
tx
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
`;
|
|
595
771
|
var GetSlotsDocument = gql`
|
|
596
772
|
query GetSlots($first: Int!, $skip: Int, $orderBy: Slot_orderBy, $orderDirection: OrderDirection, $where: Slot_filter, $block: Block_height) {
|
|
597
773
|
slots(
|
|
@@ -650,6 +826,9 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
650
826
|
GetAccounts(variables, requestHeaders, signal) {
|
|
651
827
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetAccountsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetAccounts", "query", variables);
|
|
652
828
|
},
|
|
829
|
+
GetSlotDeployedEvents(variables, requestHeaders, signal) {
|
|
830
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotDeployedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlotDeployedEvents", "query", variables);
|
|
831
|
+
},
|
|
653
832
|
GetRecentEvents(variables, requestHeaders, signal) {
|
|
654
833
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetRecentEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetRecentEvents", "query", variables);
|
|
655
834
|
},
|
|
@@ -686,6 +865,18 @@ function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
686
865
|
GetModules(variables, requestHeaders, signal) {
|
|
687
866
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetModulesDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetModules", "query", variables);
|
|
688
867
|
},
|
|
868
|
+
GetMetadataSlots(variables, requestHeaders, signal) {
|
|
869
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlots", "query", variables);
|
|
870
|
+
},
|
|
871
|
+
GetMetadataSlot(variables, requestHeaders, signal) {
|
|
872
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlot", "query", variables);
|
|
873
|
+
},
|
|
874
|
+
GetMetadataSlotsByRecipient(variables, requestHeaders, signal) {
|
|
875
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataSlotsByRecipientDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataSlotsByRecipient", "query", variables);
|
|
876
|
+
},
|
|
877
|
+
GetMetadataUpdatedEvents(variables, requestHeaders, signal) {
|
|
878
|
+
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetMetadataUpdatedEventsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetMetadataUpdatedEvents", "query", variables);
|
|
879
|
+
},
|
|
689
880
|
GetSlots(variables, requestHeaders, signal) {
|
|
690
881
|
return withWrapper((wrappedRequestHeaders) => client.request({ document: GetSlotsDocument, variables, requestHeaders: { ...requestHeaders, ...wrappedRequestHeaders }, signal }), "GetSlots", "query", variables);
|
|
691
882
|
},
|
|
@@ -711,6 +902,101 @@ var SlotsError = class extends Error {
|
|
|
711
902
|
this.cause = cause;
|
|
712
903
|
}
|
|
713
904
|
};
|
|
905
|
+
var MetadataModuleClient = class {
|
|
906
|
+
constructor(opts) {
|
|
907
|
+
this.sdk = opts.sdk;
|
|
908
|
+
this.chainId = opts.chainId;
|
|
909
|
+
this._publicClient = opts.publicClient;
|
|
910
|
+
this._walletClient = opts.walletClient;
|
|
911
|
+
this._moduleAddress = opts.moduleAddress ?? getMetadataModuleAddress(opts.chainId);
|
|
912
|
+
}
|
|
913
|
+
get moduleAddress() {
|
|
914
|
+
if (!this._moduleAddress) throw new SlotsError("metadata", `No MetadataModule deployed on chain ${this.chainId}`);
|
|
915
|
+
return this._moduleAddress;
|
|
916
|
+
}
|
|
917
|
+
get wallet() {
|
|
918
|
+
if (!this._walletClient) throw new SlotsError("metadata", "No walletClient provided");
|
|
919
|
+
return this._walletClient;
|
|
920
|
+
}
|
|
921
|
+
get account() {
|
|
922
|
+
const account = this.wallet.account;
|
|
923
|
+
if (!account) throw new SlotsError("metadata", "WalletClient must have an account");
|
|
924
|
+
return account.address;
|
|
925
|
+
}
|
|
926
|
+
get chain() {
|
|
927
|
+
const chain = this.wallet.chain;
|
|
928
|
+
if (!chain) throw new SlotsError("metadata", "WalletClient must have a chain");
|
|
929
|
+
return chain;
|
|
930
|
+
}
|
|
931
|
+
get publicClient() {
|
|
932
|
+
if (!this._publicClient) throw new SlotsError("metadata", "No publicClient provided");
|
|
933
|
+
return this._publicClient;
|
|
934
|
+
}
|
|
935
|
+
async query(operation, fn) {
|
|
936
|
+
try {
|
|
937
|
+
return await fn();
|
|
938
|
+
} catch (error) {
|
|
939
|
+
throw new SlotsError(operation, error);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
943
|
+
// READ — Subgraph
|
|
944
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
945
|
+
/** Get all slots with metadata, ordered by most recently updated. */
|
|
946
|
+
getSlots(...args) {
|
|
947
|
+
return this.query("metadata.getSlots", () => this.sdk.GetMetadataSlots(...args));
|
|
948
|
+
}
|
|
949
|
+
/** Get a single metadata slot by slot address. */
|
|
950
|
+
getSlot(...args) {
|
|
951
|
+
return this.query("metadata.getSlot", () => this.sdk.GetMetadataSlot(...args));
|
|
952
|
+
}
|
|
953
|
+
/** Get all metadata slots for a given recipient. */
|
|
954
|
+
getSlotsByRecipient(...args) {
|
|
955
|
+
return this.query("metadata.getSlotsByRecipient", () => this.sdk.GetMetadataSlotsByRecipient(...args));
|
|
956
|
+
}
|
|
957
|
+
/** Get metadata update history for a slot. */
|
|
958
|
+
getUpdateHistory(...args) {
|
|
959
|
+
return this.query("metadata.getUpdateHistory", () => this.sdk.GetMetadataUpdatedEvents(...args));
|
|
960
|
+
}
|
|
961
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
962
|
+
// READ — RPC
|
|
963
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
964
|
+
/** Read the current URI for a slot directly from chain (bypasses subgraph). */
|
|
965
|
+
async getURI(slot) {
|
|
966
|
+
return this.query(
|
|
967
|
+
"metadata.getURI",
|
|
968
|
+
() => this.publicClient.readContract({
|
|
969
|
+
address: this.moduleAddress,
|
|
970
|
+
abi: metadataModuleAbi,
|
|
971
|
+
functionName: "tokenURI",
|
|
972
|
+
args: [slot]
|
|
973
|
+
})
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
977
|
+
// WRITE
|
|
978
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
979
|
+
/**
|
|
980
|
+
* Update the metadata URI for a slot. Only callable by the current occupant.
|
|
981
|
+
* @param slot - The slot contract address
|
|
982
|
+
* @param uri - The new URI (e.g. ipfs://..., https://...)
|
|
983
|
+
* @returns Transaction hash
|
|
984
|
+
*/
|
|
985
|
+
async updateMetadata(slot, uri) {
|
|
986
|
+
return this.wallet.writeContract({
|
|
987
|
+
address: this.moduleAddress,
|
|
988
|
+
abi: metadataModuleAbi,
|
|
989
|
+
functionName: "updateMetadata",
|
|
990
|
+
args: [slot, uri],
|
|
991
|
+
account: this.account,
|
|
992
|
+
chain: this.chain
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
/** Returns the MetadataModule contract address for the configured chain. */
|
|
996
|
+
getAddress() {
|
|
997
|
+
return this.moduleAddress;
|
|
998
|
+
}
|
|
999
|
+
};
|
|
714
1000
|
|
|
715
1001
|
// src/client.ts
|
|
716
1002
|
var META_QUERY = gql$1`
|
|
@@ -731,7 +1017,7 @@ var SlotsChain = /* @__PURE__ */ ((SlotsChain2) => {
|
|
|
731
1017
|
return SlotsChain2;
|
|
732
1018
|
})(SlotsChain || {});
|
|
733
1019
|
var SUBGRAPH_URLS = {
|
|
734
|
-
[84532 /* BASE_SEPOLIA */]: "https://
|
|
1020
|
+
[84532 /* BASE_SEPOLIA */]: "https://gateway.thegraph.com/api/subgraphs/id/Z361DLoMdPh9WAopH7shJP8WoXYAB9XeKrLUCTYjdZR",
|
|
735
1021
|
[42161 /* ARBITRUM */]: "https://api.studio.thegraph.com/query/958/0-x-slots-arb/version/latest"
|
|
736
1022
|
};
|
|
737
1023
|
var SlotsClient = class {
|
|
@@ -742,8 +1028,20 @@ var SlotsClient = class {
|
|
|
742
1028
|
this._factory = config.factoryAddress ?? getSlotsHubAddress(config.chainId);
|
|
743
1029
|
const url = config.subgraphUrl || SUBGRAPH_URLS[config.chainId];
|
|
744
1030
|
if (!url) throw new Error(`No subgraph URL for chain ${config.chainId}`);
|
|
745
|
-
|
|
1031
|
+
const headers = { ...config.headers };
|
|
1032
|
+
if (config.subgraphApiKey) {
|
|
1033
|
+
headers["Authorization"] = `Bearer ${config.subgraphApiKey}`;
|
|
1034
|
+
}
|
|
1035
|
+
this.gqlClient = new GraphQLClient(url, { headers });
|
|
746
1036
|
this.sdk = getSdk(this.gqlClient);
|
|
1037
|
+
this.modules = {
|
|
1038
|
+
metadata: new MetadataModuleClient({
|
|
1039
|
+
sdk: this.sdk,
|
|
1040
|
+
chainId: config.chainId,
|
|
1041
|
+
publicClient: config.publicClient,
|
|
1042
|
+
walletClient: config.walletClient
|
|
1043
|
+
})
|
|
1044
|
+
};
|
|
747
1045
|
}
|
|
748
1046
|
// ─── Accessors ──────────────────────────────────────────────────────────────
|
|
749
1047
|
/** Returns the chain ID this client was configured for. */
|
|
@@ -821,6 +1119,10 @@ var SlotsClient = class {
|
|
|
821
1119
|
return this.query("getModules", () => this.sdk.GetModules(...args));
|
|
822
1120
|
}
|
|
823
1121
|
// Event queries
|
|
1122
|
+
/** Fetch slot deployed events with optional filters. */
|
|
1123
|
+
getSlotDeployedEvents(...args) {
|
|
1124
|
+
return this.query("getSlotDeployedEvents", () => this.sdk.GetSlotDeployedEvents(...args));
|
|
1125
|
+
}
|
|
824
1126
|
/** Fetch bought events with optional filters. */
|
|
825
1127
|
getBoughtEvents(...args) {
|
|
826
1128
|
return this.query("getBoughtEvents", () => this.sdk.GetBoughtEvents(...args));
|
|
@@ -1236,6 +1538,6 @@ function createSlotsClient(config) {
|
|
|
1236
1538
|
return new SlotsClient(config);
|
|
1237
1539
|
}
|
|
1238
1540
|
|
|
1239
|
-
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 };
|
|
1541
|
+
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 };
|
|
1240
1542
|
//# sourceMappingURL=index.js.map
|
|
1241
1543
|
//# sourceMappingURL=index.js.map
|