@rareprotocol/rare-cli 0.2.2 → 0.4.1

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/client.js ADDED
@@ -0,0 +1,3439 @@
1
+ // src/sdk/client.ts
2
+ import {
3
+ erc20Abi,
4
+ parseEther,
5
+ parseEventLogs,
6
+ maxUint256
7
+ } from "viem";
8
+
9
+ // src/contracts/addresses.ts
10
+ import { sepolia, mainnet, base, baseSepolia } from "viem/chains";
11
+ var supportedChains = [
12
+ "mainnet",
13
+ "sepolia",
14
+ "base",
15
+ "base-sepolia"
16
+ ];
17
+ var viemChains = {
18
+ mainnet,
19
+ sepolia,
20
+ base,
21
+ "base-sepolia": baseSepolia
22
+ };
23
+ var chainIds = {
24
+ mainnet: 1,
25
+ sepolia: 11155111,
26
+ base: 8453,
27
+ "base-sepolia": 84532
28
+ };
29
+ var contractAddresses = {
30
+ sepolia: {
31
+ factory: "0x3c7526a0975156299ceef369b8ff3c01cc670523",
32
+ auction: "0xC8Edc7049b233641ad3723D6C60019D1c8771612"
33
+ },
34
+ mainnet: {
35
+ factory: "0xAe8E375a268Ed6442bEaC66C6254d6De5AeD4aB1",
36
+ auction: "0x6D7c44773C52D396F43c2D511B81aa168E9a7a42"
37
+ },
38
+ base: {
39
+ factory: "0xf776204233bfb52ba0ddff24810cbdbf3dbf94dd",
40
+ auction: "0x51c36ffb05e17ed80ee5c02fa83d7677c5613de2"
41
+ },
42
+ "base-sepolia": {
43
+ factory: "0x2b181ae0f1aea6fed75591b04991b1a3f9868d51",
44
+ auction: "0x1f0c946f0ee87acb268d50ede6c9b4d010af65d2"
45
+ }
46
+ };
47
+ var ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
48
+ var currencyAddresses = {
49
+ eth: {
50
+ mainnet: ETH_ADDRESS,
51
+ sepolia: ETH_ADDRESS,
52
+ base: ETH_ADDRESS,
53
+ "base-sepolia": ETH_ADDRESS
54
+ },
55
+ rare: {
56
+ mainnet: "0xba5BDe662c17e2aDFF1075610382B9B691296350",
57
+ sepolia: "0x197FaeF3f59eC80113e773Bb6206a17d183F97CB",
58
+ base: "0x691077c8e8de54ea84efd454630439f99bd8c92f",
59
+ "base-sepolia": "0x8b21bC8571d11F7AdB705ad8F6f6BD1deb79cE01"
60
+ },
61
+ usdc: {
62
+ mainnet: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
63
+ sepolia: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
64
+ base: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
65
+ "base-sepolia": "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
66
+ }
67
+ };
68
+ var currencyNames = Object.keys(currencyAddresses);
69
+ function getContractAddresses(chain) {
70
+ const addresses = contractAddresses[chain];
71
+ if (!addresses) {
72
+ throw new Error(
73
+ `RARE Protocol contracts are not deployed on "${chain}". Supported chains: ${Object.keys(contractAddresses).join(", ")}`
74
+ );
75
+ }
76
+ return addresses;
77
+ }
78
+ function isSupportedChain(value) {
79
+ return supportedChains.includes(value);
80
+ }
81
+
82
+ // src/contracts/abis/factory.ts
83
+ var factoryAbi = [
84
+ {
85
+ "type": "constructor",
86
+ "inputs": [
87
+ {
88
+ "name": "_sovereignBatchMintImplementation",
89
+ "type": "address",
90
+ "internalType": "address"
91
+ }
92
+ ],
93
+ "stateMutability": "nonpayable"
94
+ },
95
+ {
96
+ "type": "function",
97
+ "name": "createSovereignBatchMint",
98
+ "inputs": [
99
+ {
100
+ "name": "_name",
101
+ "type": "string",
102
+ "internalType": "string"
103
+ },
104
+ {
105
+ "name": "_symbol",
106
+ "type": "string",
107
+ "internalType": "string"
108
+ }
109
+ ],
110
+ "outputs": [
111
+ {
112
+ "name": "",
113
+ "type": "address",
114
+ "internalType": "address"
115
+ }
116
+ ],
117
+ "stateMutability": "nonpayable"
118
+ },
119
+ {
120
+ "type": "function",
121
+ "name": "createSovereignBatchMint",
122
+ "inputs": [
123
+ {
124
+ "name": "_name",
125
+ "type": "string",
126
+ "internalType": "string"
127
+ },
128
+ {
129
+ "name": "_symbol",
130
+ "type": "string",
131
+ "internalType": "string"
132
+ },
133
+ {
134
+ "name": "_maxTokens",
135
+ "type": "uint256",
136
+ "internalType": "uint256"
137
+ }
138
+ ],
139
+ "outputs": [
140
+ {
141
+ "name": "",
142
+ "type": "address",
143
+ "internalType": "address"
144
+ }
145
+ ],
146
+ "stateMutability": "nonpayable"
147
+ },
148
+ {
149
+ "type": "function",
150
+ "name": "owner",
151
+ "inputs": [],
152
+ "outputs": [
153
+ {
154
+ "name": "",
155
+ "type": "address",
156
+ "internalType": "address"
157
+ }
158
+ ],
159
+ "stateMutability": "view"
160
+ },
161
+ {
162
+ "type": "function",
163
+ "name": "renounceOwnership",
164
+ "inputs": [],
165
+ "outputs": [],
166
+ "stateMutability": "nonpayable"
167
+ },
168
+ {
169
+ "type": "function",
170
+ "name": "setSovereignBatchMint",
171
+ "inputs": [
172
+ {
173
+ "name": "_sovereignNFT",
174
+ "type": "address",
175
+ "internalType": "address"
176
+ }
177
+ ],
178
+ "outputs": [],
179
+ "stateMutability": "nonpayable"
180
+ },
181
+ {
182
+ "type": "function",
183
+ "name": "sovereignNFT",
184
+ "inputs": [],
185
+ "outputs": [
186
+ {
187
+ "name": "",
188
+ "type": "address",
189
+ "internalType": "address"
190
+ }
191
+ ],
192
+ "stateMutability": "view"
193
+ },
194
+ {
195
+ "type": "function",
196
+ "name": "transferOwnership",
197
+ "inputs": [
198
+ {
199
+ "name": "newOwner",
200
+ "type": "address",
201
+ "internalType": "address"
202
+ }
203
+ ],
204
+ "outputs": [],
205
+ "stateMutability": "nonpayable"
206
+ },
207
+ {
208
+ "type": "event",
209
+ "name": "OwnershipTransferred",
210
+ "inputs": [
211
+ {
212
+ "name": "previousOwner",
213
+ "type": "address",
214
+ "indexed": true,
215
+ "internalType": "address"
216
+ },
217
+ {
218
+ "name": "newOwner",
219
+ "type": "address",
220
+ "indexed": true,
221
+ "internalType": "address"
222
+ }
223
+ ],
224
+ "anonymous": false
225
+ },
226
+ {
227
+ "type": "event",
228
+ "name": "SovereignBatchMintCreated",
229
+ "inputs": [
230
+ {
231
+ "name": "contractAddress",
232
+ "type": "address",
233
+ "indexed": true,
234
+ "internalType": "address"
235
+ },
236
+ {
237
+ "name": "owner",
238
+ "type": "address",
239
+ "indexed": true,
240
+ "internalType": "address"
241
+ }
242
+ ],
243
+ "anonymous": false
244
+ }
245
+ ];
246
+
247
+ // src/contracts/abis/token.ts
248
+ var tokenAbi = [
249
+ {
250
+ "anonymous": false,
251
+ "inputs": [
252
+ {
253
+ "indexed": true,
254
+ "internalType": "address",
255
+ "name": "owner",
256
+ "type": "address"
257
+ },
258
+ {
259
+ "indexed": true,
260
+ "internalType": "address",
261
+ "name": "approved",
262
+ "type": "address"
263
+ },
264
+ {
265
+ "indexed": true,
266
+ "internalType": "uint256",
267
+ "name": "tokenId",
268
+ "type": "uint256"
269
+ }
270
+ ],
271
+ "name": "Approval",
272
+ "type": "event"
273
+ },
274
+ {
275
+ "anonymous": false,
276
+ "inputs": [
277
+ {
278
+ "indexed": true,
279
+ "internalType": "address",
280
+ "name": "owner",
281
+ "type": "address"
282
+ },
283
+ {
284
+ "indexed": true,
285
+ "internalType": "address",
286
+ "name": "operator",
287
+ "type": "address"
288
+ },
289
+ {
290
+ "indexed": false,
291
+ "internalType": "bool",
292
+ "name": "approved",
293
+ "type": "bool"
294
+ }
295
+ ],
296
+ "name": "ApprovalForAll",
297
+ "type": "event"
298
+ },
299
+ {
300
+ "anonymous": false,
301
+ "inputs": [
302
+ {
303
+ "indexed": true,
304
+ "internalType": "uint256",
305
+ "name": "fromTokenId",
306
+ "type": "uint256"
307
+ },
308
+ {
309
+ "indexed": false,
310
+ "internalType": "uint256",
311
+ "name": "toTokenId",
312
+ "type": "uint256"
313
+ },
314
+ {
315
+ "indexed": true,
316
+ "internalType": "address",
317
+ "name": "fromAddress",
318
+ "type": "address"
319
+ },
320
+ {
321
+ "indexed": true,
322
+ "internalType": "address",
323
+ "name": "toAddress",
324
+ "type": "address"
325
+ }
326
+ ],
327
+ "name": "ConsecutiveTransfer",
328
+ "type": "event"
329
+ },
330
+ {
331
+ "anonymous": false,
332
+ "inputs": [
333
+ {
334
+ "indexed": true,
335
+ "internalType": "address",
336
+ "name": "user",
337
+ "type": "address"
338
+ }
339
+ ],
340
+ "name": "ContractDisabled",
341
+ "type": "event"
342
+ },
343
+ {
344
+ "anonymous": false,
345
+ "inputs": [
346
+ {
347
+ "indexed": true,
348
+ "internalType": "address",
349
+ "name": "previousOwner",
350
+ "type": "address"
351
+ },
352
+ {
353
+ "indexed": true,
354
+ "internalType": "address",
355
+ "name": "newOwner",
356
+ "type": "address"
357
+ }
358
+ ],
359
+ "name": "OwnershipTransferred",
360
+ "type": "event"
361
+ },
362
+ {
363
+ "anonymous": false,
364
+ "inputs": [
365
+ {
366
+ "indexed": true,
367
+ "internalType": "address",
368
+ "name": "from",
369
+ "type": "address"
370
+ },
371
+ {
372
+ "indexed": true,
373
+ "internalType": "address",
374
+ "name": "to",
375
+ "type": "address"
376
+ },
377
+ {
378
+ "indexed": true,
379
+ "internalType": "uint256",
380
+ "name": "tokenId",
381
+ "type": "uint256"
382
+ }
383
+ ],
384
+ "name": "Transfer",
385
+ "type": "event"
386
+ },
387
+ {
388
+ "inputs": [
389
+ {
390
+ "internalType": "string",
391
+ "name": "_uri",
392
+ "type": "string"
393
+ }
394
+ ],
395
+ "name": "addNewToken",
396
+ "outputs": [],
397
+ "stateMutability": "nonpayable",
398
+ "type": "function"
399
+ },
400
+ {
401
+ "inputs": [
402
+ {
403
+ "internalType": "address",
404
+ "name": "to",
405
+ "type": "address"
406
+ },
407
+ {
408
+ "internalType": "uint256",
409
+ "name": "tokenId",
410
+ "type": "uint256"
411
+ }
412
+ ],
413
+ "name": "approve",
414
+ "outputs": [],
415
+ "stateMutability": "nonpayable",
416
+ "type": "function"
417
+ },
418
+ {
419
+ "inputs": [
420
+ {
421
+ "internalType": "address",
422
+ "name": "owner",
423
+ "type": "address"
424
+ }
425
+ ],
426
+ "name": "balanceOf",
427
+ "outputs": [
428
+ {
429
+ "internalType": "uint256",
430
+ "name": "",
431
+ "type": "uint256"
432
+ }
433
+ ],
434
+ "stateMutability": "view",
435
+ "type": "function"
436
+ },
437
+ {
438
+ "inputs": [],
439
+ "name": "baseURI",
440
+ "outputs": [
441
+ {
442
+ "internalType": "string",
443
+ "name": "",
444
+ "type": "string"
445
+ }
446
+ ],
447
+ "stateMutability": "view",
448
+ "type": "function"
449
+ },
450
+ {
451
+ "inputs": [
452
+ {
453
+ "internalType": "string",
454
+ "name": "_baseURI",
455
+ "type": "string"
456
+ },
457
+ {
458
+ "internalType": "uint256",
459
+ "name": "_numberOfTokens",
460
+ "type": "uint256"
461
+ }
462
+ ],
463
+ "name": "batchMint",
464
+ "outputs": [],
465
+ "stateMutability": "nonpayable",
466
+ "type": "function"
467
+ },
468
+ {
469
+ "inputs": [
470
+ {
471
+ "internalType": "uint256",
472
+ "name": "_tokenId",
473
+ "type": "uint256"
474
+ }
475
+ ],
476
+ "name": "burn",
477
+ "outputs": [],
478
+ "stateMutability": "nonpayable",
479
+ "type": "function"
480
+ },
481
+ {
482
+ "inputs": [],
483
+ "name": "calcIERC721CreatorInterfaceId",
484
+ "outputs": [
485
+ {
486
+ "internalType": "bytes4",
487
+ "name": "",
488
+ "type": "bytes4"
489
+ }
490
+ ],
491
+ "stateMutability": "pure",
492
+ "type": "function"
493
+ },
494
+ {
495
+ "inputs": [],
496
+ "name": "defaultRoyaltyPercentage",
497
+ "outputs": [
498
+ {
499
+ "internalType": "uint256",
500
+ "name": "",
501
+ "type": "uint256"
502
+ }
503
+ ],
504
+ "stateMutability": "view",
505
+ "type": "function"
506
+ },
507
+ {
508
+ "inputs": [],
509
+ "name": "defaultRoyaltyReceiver",
510
+ "outputs": [
511
+ {
512
+ "internalType": "address",
513
+ "name": "",
514
+ "type": "address"
515
+ }
516
+ ],
517
+ "stateMutability": "view",
518
+ "type": "function"
519
+ },
520
+ {
521
+ "inputs": [
522
+ {
523
+ "internalType": "uint256",
524
+ "name": "_tokenId",
525
+ "type": "uint256"
526
+ }
527
+ ],
528
+ "name": "deleteToken",
529
+ "outputs": [],
530
+ "stateMutability": "nonpayable",
531
+ "type": "function"
532
+ },
533
+ {
534
+ "inputs": [],
535
+ "name": "disableContract",
536
+ "outputs": [],
537
+ "stateMutability": "nonpayable",
538
+ "type": "function"
539
+ },
540
+ {
541
+ "inputs": [],
542
+ "name": "disabled",
543
+ "outputs": [
544
+ {
545
+ "internalType": "bool",
546
+ "name": "",
547
+ "type": "bool"
548
+ }
549
+ ],
550
+ "stateMutability": "view",
551
+ "type": "function"
552
+ },
553
+ {
554
+ "inputs": [
555
+ {
556
+ "internalType": "uint256",
557
+ "name": "_tokenId",
558
+ "type": "uint256"
559
+ }
560
+ ],
561
+ "name": "getApproved",
562
+ "outputs": [
563
+ {
564
+ "internalType": "address",
565
+ "name": "",
566
+ "type": "address"
567
+ }
568
+ ],
569
+ "stateMutability": "view",
570
+ "type": "function"
571
+ },
572
+ {
573
+ "inputs": [
574
+ {
575
+ "internalType": "string",
576
+ "name": "_name",
577
+ "type": "string"
578
+ },
579
+ {
580
+ "internalType": "string",
581
+ "name": "_symbol",
582
+ "type": "string"
583
+ },
584
+ {
585
+ "internalType": "address",
586
+ "name": "_creator",
587
+ "type": "address"
588
+ },
589
+ {
590
+ "internalType": "uint256",
591
+ "name": "_maxTokens",
592
+ "type": "uint256"
593
+ }
594
+ ],
595
+ "name": "init",
596
+ "outputs": [],
597
+ "stateMutability": "nonpayable",
598
+ "type": "function"
599
+ },
600
+ {
601
+ "inputs": [
602
+ {
603
+ "internalType": "address",
604
+ "name": "owner",
605
+ "type": "address"
606
+ },
607
+ {
608
+ "internalType": "address",
609
+ "name": "operator",
610
+ "type": "address"
611
+ }
612
+ ],
613
+ "name": "isApprovedForAll",
614
+ "outputs": [
615
+ {
616
+ "internalType": "bool",
617
+ "name": "",
618
+ "type": "bool"
619
+ }
620
+ ],
621
+ "stateMutability": "view",
622
+ "type": "function"
623
+ },
624
+ {
625
+ "inputs": [],
626
+ "name": "maxTokens",
627
+ "outputs": [
628
+ {
629
+ "internalType": "uint256",
630
+ "name": "",
631
+ "type": "uint256"
632
+ }
633
+ ],
634
+ "stateMutability": "view",
635
+ "type": "function"
636
+ },
637
+ {
638
+ "inputs": [
639
+ {
640
+ "internalType": "string",
641
+ "name": "_uri",
642
+ "type": "string"
643
+ },
644
+ {
645
+ "internalType": "address",
646
+ "name": "_receiver",
647
+ "type": "address"
648
+ },
649
+ {
650
+ "internalType": "address",
651
+ "name": "_royaltyReceiver",
652
+ "type": "address"
653
+ }
654
+ ],
655
+ "name": "mintTo",
656
+ "outputs": [],
657
+ "stateMutability": "nonpayable",
658
+ "type": "function"
659
+ },
660
+ {
661
+ "inputs": [],
662
+ "name": "name",
663
+ "outputs": [
664
+ {
665
+ "internalType": "string",
666
+ "name": "",
667
+ "type": "string"
668
+ }
669
+ ],
670
+ "stateMutability": "view",
671
+ "type": "function"
672
+ },
673
+ {
674
+ "inputs": [],
675
+ "name": "owner",
676
+ "outputs": [
677
+ {
678
+ "internalType": "address",
679
+ "name": "",
680
+ "type": "address"
681
+ }
682
+ ],
683
+ "stateMutability": "view",
684
+ "type": "function"
685
+ },
686
+ {
687
+ "inputs": [
688
+ {
689
+ "internalType": "uint256",
690
+ "name": "_tokenId",
691
+ "type": "uint256"
692
+ }
693
+ ],
694
+ "name": "ownerOf",
695
+ "outputs": [
696
+ {
697
+ "internalType": "address",
698
+ "name": "",
699
+ "type": "address"
700
+ }
701
+ ],
702
+ "stateMutability": "view",
703
+ "type": "function"
704
+ },
705
+ {
706
+ "inputs": [],
707
+ "name": "renounceOwnership",
708
+ "outputs": [],
709
+ "stateMutability": "view",
710
+ "type": "function"
711
+ },
712
+ {
713
+ "inputs": [
714
+ {
715
+ "internalType": "uint256",
716
+ "name": "_tokenId",
717
+ "type": "uint256"
718
+ },
719
+ {
720
+ "internalType": "uint256",
721
+ "name": "_salePrice",
722
+ "type": "uint256"
723
+ }
724
+ ],
725
+ "name": "royaltyInfo",
726
+ "outputs": [
727
+ {
728
+ "internalType": "address",
729
+ "name": "receiver",
730
+ "type": "address"
731
+ },
732
+ {
733
+ "internalType": "uint256",
734
+ "name": "royaltyAmount",
735
+ "type": "uint256"
736
+ }
737
+ ],
738
+ "stateMutability": "view",
739
+ "type": "function"
740
+ },
741
+ {
742
+ "inputs": [
743
+ {
744
+ "internalType": "address",
745
+ "name": "from",
746
+ "type": "address"
747
+ },
748
+ {
749
+ "internalType": "address",
750
+ "name": "to",
751
+ "type": "address"
752
+ },
753
+ {
754
+ "internalType": "uint256",
755
+ "name": "tokenId",
756
+ "type": "uint256"
757
+ }
758
+ ],
759
+ "name": "safeTransferFrom",
760
+ "outputs": [],
761
+ "stateMutability": "nonpayable",
762
+ "type": "function"
763
+ },
764
+ {
765
+ "inputs": [
766
+ {
767
+ "internalType": "address",
768
+ "name": "from",
769
+ "type": "address"
770
+ },
771
+ {
772
+ "internalType": "address",
773
+ "name": "to",
774
+ "type": "address"
775
+ },
776
+ {
777
+ "internalType": "uint256",
778
+ "name": "tokenId",
779
+ "type": "uint256"
780
+ },
781
+ {
782
+ "internalType": "bytes",
783
+ "name": "_data",
784
+ "type": "bytes"
785
+ }
786
+ ],
787
+ "name": "safeTransferFrom",
788
+ "outputs": [],
789
+ "stateMutability": "nonpayable",
790
+ "type": "function"
791
+ },
792
+ {
793
+ "inputs": [
794
+ {
795
+ "internalType": "address",
796
+ "name": "operator",
797
+ "type": "address"
798
+ },
799
+ {
800
+ "internalType": "bool",
801
+ "name": "approved",
802
+ "type": "bool"
803
+ }
804
+ ],
805
+ "name": "setApprovalForAll",
806
+ "outputs": [],
807
+ "stateMutability": "nonpayable",
808
+ "type": "function"
809
+ },
810
+ {
811
+ "inputs": [
812
+ {
813
+ "internalType": "address",
814
+ "name": "_receiver",
815
+ "type": "address"
816
+ }
817
+ ],
818
+ "name": "setDefaultRoyaltyReceiver",
819
+ "outputs": [],
820
+ "stateMutability": "nonpayable",
821
+ "type": "function"
822
+ },
823
+ {
824
+ "inputs": [
825
+ {
826
+ "internalType": "address",
827
+ "name": "_receiver",
828
+ "type": "address"
829
+ },
830
+ {
831
+ "internalType": "uint256",
832
+ "name": "_tokenId",
833
+ "type": "uint256"
834
+ }
835
+ ],
836
+ "name": "setRoyaltyReceiverForToken",
837
+ "outputs": [],
838
+ "stateMutability": "nonpayable",
839
+ "type": "function"
840
+ },
841
+ {
842
+ "inputs": [
843
+ {
844
+ "internalType": "bytes4",
845
+ "name": "interfaceId",
846
+ "type": "bytes4"
847
+ }
848
+ ],
849
+ "name": "supportsInterface",
850
+ "outputs": [
851
+ {
852
+ "internalType": "bool",
853
+ "name": "",
854
+ "type": "bool"
855
+ }
856
+ ],
857
+ "stateMutability": "view",
858
+ "type": "function"
859
+ },
860
+ {
861
+ "inputs": [],
862
+ "name": "symbol",
863
+ "outputs": [
864
+ {
865
+ "internalType": "string",
866
+ "name": "",
867
+ "type": "string"
868
+ }
869
+ ],
870
+ "stateMutability": "view",
871
+ "type": "function"
872
+ },
873
+ {
874
+ "inputs": [
875
+ {
876
+ "internalType": "uint256",
877
+ "name": "index",
878
+ "type": "uint256"
879
+ }
880
+ ],
881
+ "name": "tokenByIndex",
882
+ "outputs": [
883
+ {
884
+ "internalType": "uint256",
885
+ "name": "",
886
+ "type": "uint256"
887
+ }
888
+ ],
889
+ "stateMutability": "view",
890
+ "type": "function"
891
+ },
892
+ {
893
+ "inputs": [
894
+ {
895
+ "internalType": "uint256",
896
+ "name": "",
897
+ "type": "uint256"
898
+ }
899
+ ],
900
+ "name": "tokenCreator",
901
+ "outputs": [
902
+ {
903
+ "internalType": "address payable",
904
+ "name": "",
905
+ "type": "address"
906
+ }
907
+ ],
908
+ "stateMutability": "view",
909
+ "type": "function"
910
+ },
911
+ {
912
+ "inputs": [
913
+ {
914
+ "internalType": "address",
915
+ "name": "owner",
916
+ "type": "address"
917
+ },
918
+ {
919
+ "internalType": "uint256",
920
+ "name": "index",
921
+ "type": "uint256"
922
+ }
923
+ ],
924
+ "name": "tokenOfOwnerByIndex",
925
+ "outputs": [
926
+ {
927
+ "internalType": "uint256",
928
+ "name": "",
929
+ "type": "uint256"
930
+ }
931
+ ],
932
+ "stateMutability": "view",
933
+ "type": "function"
934
+ },
935
+ {
936
+ "inputs": [
937
+ {
938
+ "internalType": "uint256",
939
+ "name": "_tokenId",
940
+ "type": "uint256"
941
+ }
942
+ ],
943
+ "name": "tokenURI",
944
+ "outputs": [
945
+ {
946
+ "internalType": "string",
947
+ "name": "",
948
+ "type": "string"
949
+ }
950
+ ],
951
+ "stateMutability": "view",
952
+ "type": "function"
953
+ },
954
+ {
955
+ "inputs": [],
956
+ "name": "totalSupply",
957
+ "outputs": [
958
+ {
959
+ "internalType": "uint256",
960
+ "name": "",
961
+ "type": "uint256"
962
+ }
963
+ ],
964
+ "stateMutability": "view",
965
+ "type": "function"
966
+ },
967
+ {
968
+ "inputs": [
969
+ {
970
+ "internalType": "address",
971
+ "name": "from",
972
+ "type": "address"
973
+ },
974
+ {
975
+ "internalType": "address",
976
+ "name": "to",
977
+ "type": "address"
978
+ },
979
+ {
980
+ "internalType": "uint256",
981
+ "name": "tokenId",
982
+ "type": "uint256"
983
+ }
984
+ ],
985
+ "name": "transferFrom",
986
+ "outputs": [],
987
+ "stateMutability": "nonpayable",
988
+ "type": "function"
989
+ },
990
+ {
991
+ "inputs": [
992
+ {
993
+ "internalType": "address",
994
+ "name": "",
995
+ "type": "address"
996
+ }
997
+ ],
998
+ "name": "transferOwnership",
999
+ "outputs": [],
1000
+ "stateMutability": "view",
1001
+ "type": "function"
1002
+ }
1003
+ ];
1004
+
1005
+ // src/contracts/abis/auction.ts
1006
+ var auctionAbi = [
1007
+ {
1008
+ "type": "function",
1009
+ "name": "COLDIE_AUCTION",
1010
+ "inputs": [],
1011
+ "outputs": [
1012
+ {
1013
+ "name": "",
1014
+ "type": "bytes32",
1015
+ "internalType": "bytes32"
1016
+ }
1017
+ ],
1018
+ "stateMutability": "view"
1019
+ },
1020
+ {
1021
+ "type": "function",
1022
+ "name": "NO_AUCTION",
1023
+ "inputs": [],
1024
+ "outputs": [
1025
+ {
1026
+ "name": "",
1027
+ "type": "bytes32",
1028
+ "internalType": "bytes32"
1029
+ }
1030
+ ],
1031
+ "stateMutability": "view"
1032
+ },
1033
+ {
1034
+ "type": "function",
1035
+ "name": "SCHEDULED_AUCTION",
1036
+ "inputs": [],
1037
+ "outputs": [
1038
+ {
1039
+ "name": "",
1040
+ "type": "bytes32",
1041
+ "internalType": "bytes32"
1042
+ }
1043
+ ],
1044
+ "stateMutability": "view"
1045
+ },
1046
+ {
1047
+ "type": "function",
1048
+ "name": "acceptOffer",
1049
+ "inputs": [
1050
+ {
1051
+ "name": "_originContract",
1052
+ "type": "address",
1053
+ "internalType": "address"
1054
+ },
1055
+ {
1056
+ "name": "_tokenId",
1057
+ "type": "uint256",
1058
+ "internalType": "uint256"
1059
+ },
1060
+ {
1061
+ "name": "_currencyAddress",
1062
+ "type": "address",
1063
+ "internalType": "address"
1064
+ },
1065
+ {
1066
+ "name": "_amount",
1067
+ "type": "uint256",
1068
+ "internalType": "uint256"
1069
+ },
1070
+ {
1071
+ "name": "_splitAddresses",
1072
+ "type": "address[]",
1073
+ "internalType": "address payable[]"
1074
+ },
1075
+ {
1076
+ "name": "_splitRatios",
1077
+ "type": "uint8[]",
1078
+ "internalType": "uint8[]"
1079
+ }
1080
+ ],
1081
+ "outputs": [],
1082
+ "stateMutability": "nonpayable"
1083
+ },
1084
+ {
1085
+ "type": "function",
1086
+ "name": "approvedTokenRegistry",
1087
+ "inputs": [],
1088
+ "outputs": [
1089
+ {
1090
+ "name": "",
1091
+ "type": "address",
1092
+ "internalType": "contract IApprovedTokenRegistry"
1093
+ }
1094
+ ],
1095
+ "stateMutability": "view"
1096
+ },
1097
+ {
1098
+ "type": "function",
1099
+ "name": "auctionBids",
1100
+ "inputs": [
1101
+ {
1102
+ "name": "",
1103
+ "type": "address",
1104
+ "internalType": "address"
1105
+ },
1106
+ {
1107
+ "name": "",
1108
+ "type": "uint256",
1109
+ "internalType": "uint256"
1110
+ }
1111
+ ],
1112
+ "outputs": [
1113
+ {
1114
+ "name": "bidder",
1115
+ "type": "address",
1116
+ "internalType": "address payable"
1117
+ },
1118
+ {
1119
+ "name": "currencyAddress",
1120
+ "type": "address",
1121
+ "internalType": "address"
1122
+ },
1123
+ {
1124
+ "name": "amount",
1125
+ "type": "uint256",
1126
+ "internalType": "uint256"
1127
+ },
1128
+ {
1129
+ "name": "marketplaceFee",
1130
+ "type": "uint8",
1131
+ "internalType": "uint8"
1132
+ }
1133
+ ],
1134
+ "stateMutability": "view"
1135
+ },
1136
+ {
1137
+ "type": "function",
1138
+ "name": "auctionLengthExtension",
1139
+ "inputs": [],
1140
+ "outputs": [
1141
+ {
1142
+ "name": "",
1143
+ "type": "uint256",
1144
+ "internalType": "uint256"
1145
+ }
1146
+ ],
1147
+ "stateMutability": "view"
1148
+ },
1149
+ {
1150
+ "type": "function",
1151
+ "name": "bid",
1152
+ "inputs": [
1153
+ {
1154
+ "name": "_originContract",
1155
+ "type": "address",
1156
+ "internalType": "address"
1157
+ },
1158
+ {
1159
+ "name": "_tokenId",
1160
+ "type": "uint256",
1161
+ "internalType": "uint256"
1162
+ },
1163
+ {
1164
+ "name": "_currencyAddress",
1165
+ "type": "address",
1166
+ "internalType": "address"
1167
+ },
1168
+ {
1169
+ "name": "_amount",
1170
+ "type": "uint256",
1171
+ "internalType": "uint256"
1172
+ }
1173
+ ],
1174
+ "outputs": [],
1175
+ "stateMutability": "payable"
1176
+ },
1177
+ {
1178
+ "type": "function",
1179
+ "name": "buy",
1180
+ "inputs": [
1181
+ {
1182
+ "name": "_originContract",
1183
+ "type": "address",
1184
+ "internalType": "address"
1185
+ },
1186
+ {
1187
+ "name": "_tokenId",
1188
+ "type": "uint256",
1189
+ "internalType": "uint256"
1190
+ },
1191
+ {
1192
+ "name": "_currencyAddress",
1193
+ "type": "address",
1194
+ "internalType": "address"
1195
+ },
1196
+ {
1197
+ "name": "_amount",
1198
+ "type": "uint256",
1199
+ "internalType": "uint256"
1200
+ }
1201
+ ],
1202
+ "outputs": [],
1203
+ "stateMutability": "payable"
1204
+ },
1205
+ {
1206
+ "type": "function",
1207
+ "name": "cancelAuction",
1208
+ "inputs": [
1209
+ {
1210
+ "name": "_originContract",
1211
+ "type": "address",
1212
+ "internalType": "address"
1213
+ },
1214
+ {
1215
+ "name": "_tokenId",
1216
+ "type": "uint256",
1217
+ "internalType": "uint256"
1218
+ }
1219
+ ],
1220
+ "outputs": [],
1221
+ "stateMutability": "nonpayable"
1222
+ },
1223
+ {
1224
+ "type": "function",
1225
+ "name": "cancelOffer",
1226
+ "inputs": [
1227
+ {
1228
+ "name": "_originContract",
1229
+ "type": "address",
1230
+ "internalType": "address"
1231
+ },
1232
+ {
1233
+ "name": "_tokenId",
1234
+ "type": "uint256",
1235
+ "internalType": "uint256"
1236
+ },
1237
+ {
1238
+ "name": "_currencyAddress",
1239
+ "type": "address",
1240
+ "internalType": "address"
1241
+ }
1242
+ ],
1243
+ "outputs": [],
1244
+ "stateMutability": "nonpayable"
1245
+ },
1246
+ {
1247
+ "type": "function",
1248
+ "name": "configureAuction",
1249
+ "inputs": [
1250
+ {
1251
+ "name": "_auctionType",
1252
+ "type": "bytes32",
1253
+ "internalType": "bytes32"
1254
+ },
1255
+ {
1256
+ "name": "_originContract",
1257
+ "type": "address",
1258
+ "internalType": "address"
1259
+ },
1260
+ {
1261
+ "name": "_tokenId",
1262
+ "type": "uint256",
1263
+ "internalType": "uint256"
1264
+ },
1265
+ {
1266
+ "name": "_startingAmount",
1267
+ "type": "uint256",
1268
+ "internalType": "uint256"
1269
+ },
1270
+ {
1271
+ "name": "_currencyAddress",
1272
+ "type": "address",
1273
+ "internalType": "address"
1274
+ },
1275
+ {
1276
+ "name": "_lengthOfAuction",
1277
+ "type": "uint256",
1278
+ "internalType": "uint256"
1279
+ },
1280
+ {
1281
+ "name": "_startTime",
1282
+ "type": "uint256",
1283
+ "internalType": "uint256"
1284
+ },
1285
+ {
1286
+ "name": "_splitAddresses",
1287
+ "type": "address[]",
1288
+ "internalType": "address payable[]"
1289
+ },
1290
+ {
1291
+ "name": "_splitRatios",
1292
+ "type": "uint8[]",
1293
+ "internalType": "uint8[]"
1294
+ }
1295
+ ],
1296
+ "outputs": [],
1297
+ "stateMutability": "nonpayable"
1298
+ },
1299
+ {
1300
+ "type": "function",
1301
+ "name": "convertOfferToAuction",
1302
+ "inputs": [
1303
+ {
1304
+ "name": "_originContract",
1305
+ "type": "address",
1306
+ "internalType": "address"
1307
+ },
1308
+ {
1309
+ "name": "_tokenId",
1310
+ "type": "uint256",
1311
+ "internalType": "uint256"
1312
+ },
1313
+ {
1314
+ "name": "_currencyAddress",
1315
+ "type": "address",
1316
+ "internalType": "address"
1317
+ },
1318
+ {
1319
+ "name": "_amount",
1320
+ "type": "uint256",
1321
+ "internalType": "uint256"
1322
+ },
1323
+ {
1324
+ "name": "_lengthOfAuction",
1325
+ "type": "uint256",
1326
+ "internalType": "uint256"
1327
+ },
1328
+ {
1329
+ "name": "_splitAddresses",
1330
+ "type": "address[]",
1331
+ "internalType": "address payable[]"
1332
+ },
1333
+ {
1334
+ "name": "_splitRatios",
1335
+ "type": "uint8[]",
1336
+ "internalType": "uint8[]"
1337
+ }
1338
+ ],
1339
+ "outputs": [],
1340
+ "stateMutability": "nonpayable"
1341
+ },
1342
+ {
1343
+ "type": "function",
1344
+ "name": "getAuctionDetails",
1345
+ "inputs": [
1346
+ {
1347
+ "name": "_originContract",
1348
+ "type": "address",
1349
+ "internalType": "address"
1350
+ },
1351
+ {
1352
+ "name": "_tokenId",
1353
+ "type": "uint256",
1354
+ "internalType": "uint256"
1355
+ }
1356
+ ],
1357
+ "outputs": [
1358
+ {
1359
+ "name": "",
1360
+ "type": "address",
1361
+ "internalType": "address"
1362
+ },
1363
+ {
1364
+ "name": "",
1365
+ "type": "uint256",
1366
+ "internalType": "uint256"
1367
+ },
1368
+ {
1369
+ "name": "",
1370
+ "type": "uint256",
1371
+ "internalType": "uint256"
1372
+ },
1373
+ {
1374
+ "name": "",
1375
+ "type": "uint256",
1376
+ "internalType": "uint256"
1377
+ },
1378
+ {
1379
+ "name": "",
1380
+ "type": "address",
1381
+ "internalType": "address"
1382
+ },
1383
+ {
1384
+ "name": "",
1385
+ "type": "uint256",
1386
+ "internalType": "uint256"
1387
+ },
1388
+ {
1389
+ "name": "",
1390
+ "type": "bytes32",
1391
+ "internalType": "bytes32"
1392
+ },
1393
+ {
1394
+ "name": "",
1395
+ "type": "address[]",
1396
+ "internalType": "address payable[]"
1397
+ },
1398
+ {
1399
+ "name": "",
1400
+ "type": "uint8[]",
1401
+ "internalType": "uint8[]"
1402
+ }
1403
+ ],
1404
+ "stateMutability": "view"
1405
+ },
1406
+ {
1407
+ "type": "function",
1408
+ "name": "getSalePrice",
1409
+ "inputs": [
1410
+ {
1411
+ "name": "_originContract",
1412
+ "type": "address",
1413
+ "internalType": "address"
1414
+ },
1415
+ {
1416
+ "name": "_tokenId",
1417
+ "type": "uint256",
1418
+ "internalType": "uint256"
1419
+ },
1420
+ {
1421
+ "name": "_target",
1422
+ "type": "address",
1423
+ "internalType": "address"
1424
+ }
1425
+ ],
1426
+ "outputs": [
1427
+ {
1428
+ "name": "",
1429
+ "type": "address",
1430
+ "internalType": "address"
1431
+ },
1432
+ {
1433
+ "name": "",
1434
+ "type": "address",
1435
+ "internalType": "address"
1436
+ },
1437
+ {
1438
+ "name": "",
1439
+ "type": "uint256",
1440
+ "internalType": "uint256"
1441
+ },
1442
+ {
1443
+ "name": "",
1444
+ "type": "address[]",
1445
+ "internalType": "address payable[]"
1446
+ },
1447
+ {
1448
+ "name": "",
1449
+ "type": "uint8[]",
1450
+ "internalType": "uint8[]"
1451
+ }
1452
+ ],
1453
+ "stateMutability": "view"
1454
+ },
1455
+ {
1456
+ "type": "function",
1457
+ "name": "initialize",
1458
+ "inputs": [
1459
+ {
1460
+ "name": "_marketplaceSettings",
1461
+ "type": "address",
1462
+ "internalType": "address"
1463
+ },
1464
+ {
1465
+ "name": "_royaltyRegistry",
1466
+ "type": "address",
1467
+ "internalType": "address"
1468
+ },
1469
+ {
1470
+ "name": "_royaltyEngine",
1471
+ "type": "address",
1472
+ "internalType": "address"
1473
+ },
1474
+ {
1475
+ "name": "_superRareMarketplace",
1476
+ "type": "address",
1477
+ "internalType": "address"
1478
+ },
1479
+ {
1480
+ "name": "_superRareAuctionHouse",
1481
+ "type": "address",
1482
+ "internalType": "address"
1483
+ },
1484
+ {
1485
+ "name": "_spaceOperatorRegistry",
1486
+ "type": "address",
1487
+ "internalType": "address"
1488
+ },
1489
+ {
1490
+ "name": "_approvedTokenRegistry",
1491
+ "type": "address",
1492
+ "internalType": "address"
1493
+ },
1494
+ {
1495
+ "name": "_payments",
1496
+ "type": "address",
1497
+ "internalType": "address"
1498
+ },
1499
+ {
1500
+ "name": "_stakingRegistry",
1501
+ "type": "address",
1502
+ "internalType": "address"
1503
+ },
1504
+ {
1505
+ "name": "_networkBeneficiary",
1506
+ "type": "address",
1507
+ "internalType": "address"
1508
+ }
1509
+ ],
1510
+ "outputs": [],
1511
+ "stateMutability": "nonpayable"
1512
+ },
1513
+ {
1514
+ "type": "function",
1515
+ "name": "marketplaceSettings",
1516
+ "inputs": [],
1517
+ "outputs": [
1518
+ {
1519
+ "name": "",
1520
+ "type": "address",
1521
+ "internalType": "contract IMarketplaceSettings"
1522
+ }
1523
+ ],
1524
+ "stateMutability": "view"
1525
+ },
1526
+ {
1527
+ "type": "function",
1528
+ "name": "maxAuctionLength",
1529
+ "inputs": [],
1530
+ "outputs": [
1531
+ {
1532
+ "name": "",
1533
+ "type": "uint256",
1534
+ "internalType": "uint256"
1535
+ }
1536
+ ],
1537
+ "stateMutability": "view"
1538
+ },
1539
+ {
1540
+ "type": "function",
1541
+ "name": "minimumBidIncreasePercentage",
1542
+ "inputs": [],
1543
+ "outputs": [
1544
+ {
1545
+ "name": "",
1546
+ "type": "uint8",
1547
+ "internalType": "uint8"
1548
+ }
1549
+ ],
1550
+ "stateMutability": "view"
1551
+ },
1552
+ {
1553
+ "type": "function",
1554
+ "name": "networkBeneficiary",
1555
+ "inputs": [],
1556
+ "outputs": [
1557
+ {
1558
+ "name": "",
1559
+ "type": "address",
1560
+ "internalType": "address"
1561
+ }
1562
+ ],
1563
+ "stateMutability": "view"
1564
+ },
1565
+ {
1566
+ "type": "function",
1567
+ "name": "offer",
1568
+ "inputs": [
1569
+ {
1570
+ "name": "_originContract",
1571
+ "type": "address",
1572
+ "internalType": "address"
1573
+ },
1574
+ {
1575
+ "name": "_tokenId",
1576
+ "type": "uint256",
1577
+ "internalType": "uint256"
1578
+ },
1579
+ {
1580
+ "name": "_currencyAddress",
1581
+ "type": "address",
1582
+ "internalType": "address"
1583
+ },
1584
+ {
1585
+ "name": "_amount",
1586
+ "type": "uint256",
1587
+ "internalType": "uint256"
1588
+ },
1589
+ {
1590
+ "name": "_convertible",
1591
+ "type": "bool",
1592
+ "internalType": "bool"
1593
+ }
1594
+ ],
1595
+ "outputs": [],
1596
+ "stateMutability": "payable"
1597
+ },
1598
+ {
1599
+ "type": "function",
1600
+ "name": "offerCancelationDelay",
1601
+ "inputs": [],
1602
+ "outputs": [
1603
+ {
1604
+ "name": "",
1605
+ "type": "uint256",
1606
+ "internalType": "uint256"
1607
+ }
1608
+ ],
1609
+ "stateMutability": "view"
1610
+ },
1611
+ {
1612
+ "type": "function",
1613
+ "name": "owner",
1614
+ "inputs": [],
1615
+ "outputs": [
1616
+ {
1617
+ "name": "",
1618
+ "type": "address",
1619
+ "internalType": "address"
1620
+ }
1621
+ ],
1622
+ "stateMutability": "view"
1623
+ },
1624
+ {
1625
+ "type": "function",
1626
+ "name": "payments",
1627
+ "inputs": [],
1628
+ "outputs": [
1629
+ {
1630
+ "name": "",
1631
+ "type": "address",
1632
+ "internalType": "contract IPayments"
1633
+ }
1634
+ ],
1635
+ "stateMutability": "view"
1636
+ },
1637
+ {
1638
+ "type": "function",
1639
+ "name": "removeSalePrice",
1640
+ "inputs": [
1641
+ {
1642
+ "name": "_originContract",
1643
+ "type": "address",
1644
+ "internalType": "address"
1645
+ },
1646
+ {
1647
+ "name": "_tokenId",
1648
+ "type": "uint256",
1649
+ "internalType": "uint256"
1650
+ },
1651
+ {
1652
+ "name": "_target",
1653
+ "type": "address",
1654
+ "internalType": "address"
1655
+ }
1656
+ ],
1657
+ "outputs": [],
1658
+ "stateMutability": "nonpayable"
1659
+ },
1660
+ {
1661
+ "type": "function",
1662
+ "name": "renounceOwnership",
1663
+ "inputs": [],
1664
+ "outputs": [],
1665
+ "stateMutability": "nonpayable"
1666
+ },
1667
+ {
1668
+ "type": "function",
1669
+ "name": "royaltyEngine",
1670
+ "inputs": [],
1671
+ "outputs": [
1672
+ {
1673
+ "name": "",
1674
+ "type": "address",
1675
+ "internalType": "contract IRoyaltyEngineV1"
1676
+ }
1677
+ ],
1678
+ "stateMutability": "view"
1679
+ },
1680
+ {
1681
+ "type": "function",
1682
+ "name": "royaltyRegistry",
1683
+ "inputs": [],
1684
+ "outputs": [
1685
+ {
1686
+ "name": "",
1687
+ "type": "address",
1688
+ "internalType": "contract IRoyaltyRegistry"
1689
+ }
1690
+ ],
1691
+ "stateMutability": "view"
1692
+ },
1693
+ {
1694
+ "type": "function",
1695
+ "name": "setApprovedTokenRegistry",
1696
+ "inputs": [
1697
+ {
1698
+ "name": "_approvedTokenRegistry",
1699
+ "type": "address",
1700
+ "internalType": "address"
1701
+ }
1702
+ ],
1703
+ "outputs": [],
1704
+ "stateMutability": "nonpayable"
1705
+ },
1706
+ {
1707
+ "type": "function",
1708
+ "name": "setAuctionLengthExtension",
1709
+ "inputs": [
1710
+ {
1711
+ "name": "_auctionLengthExtension",
1712
+ "type": "uint256",
1713
+ "internalType": "uint256"
1714
+ }
1715
+ ],
1716
+ "outputs": [],
1717
+ "stateMutability": "nonpayable"
1718
+ },
1719
+ {
1720
+ "type": "function",
1721
+ "name": "setMarketplaceSettings",
1722
+ "inputs": [
1723
+ {
1724
+ "name": "_marketplaceSettings",
1725
+ "type": "address",
1726
+ "internalType": "address"
1727
+ }
1728
+ ],
1729
+ "outputs": [],
1730
+ "stateMutability": "nonpayable"
1731
+ },
1732
+ {
1733
+ "type": "function",
1734
+ "name": "setMaxAuctionLength",
1735
+ "inputs": [
1736
+ {
1737
+ "name": "_maxAuctionLength",
1738
+ "type": "uint8",
1739
+ "internalType": "uint8"
1740
+ }
1741
+ ],
1742
+ "outputs": [],
1743
+ "stateMutability": "nonpayable"
1744
+ },
1745
+ {
1746
+ "type": "function",
1747
+ "name": "setMinimumBidIncreasePercentage",
1748
+ "inputs": [
1749
+ {
1750
+ "name": "_minimumBidIncreasePercentage",
1751
+ "type": "uint8",
1752
+ "internalType": "uint8"
1753
+ }
1754
+ ],
1755
+ "outputs": [],
1756
+ "stateMutability": "nonpayable"
1757
+ },
1758
+ {
1759
+ "type": "function",
1760
+ "name": "setNetworkBeneficiary",
1761
+ "inputs": [
1762
+ {
1763
+ "name": "_networkBeneficiary",
1764
+ "type": "address",
1765
+ "internalType": "address"
1766
+ }
1767
+ ],
1768
+ "outputs": [],
1769
+ "stateMutability": "nonpayable"
1770
+ },
1771
+ {
1772
+ "type": "function",
1773
+ "name": "setOfferCancelationDelay",
1774
+ "inputs": [
1775
+ {
1776
+ "name": "_offerCancelationDelay",
1777
+ "type": "uint256",
1778
+ "internalType": "uint256"
1779
+ }
1780
+ ],
1781
+ "outputs": [],
1782
+ "stateMutability": "nonpayable"
1783
+ },
1784
+ {
1785
+ "type": "function",
1786
+ "name": "setPayments",
1787
+ "inputs": [
1788
+ {
1789
+ "name": "_payments",
1790
+ "type": "address",
1791
+ "internalType": "address"
1792
+ }
1793
+ ],
1794
+ "outputs": [],
1795
+ "stateMutability": "nonpayable"
1796
+ },
1797
+ {
1798
+ "type": "function",
1799
+ "name": "setRoyaltyEngine",
1800
+ "inputs": [
1801
+ {
1802
+ "name": "_royaltyEngine",
1803
+ "type": "address",
1804
+ "internalType": "address"
1805
+ }
1806
+ ],
1807
+ "outputs": [],
1808
+ "stateMutability": "nonpayable"
1809
+ },
1810
+ {
1811
+ "type": "function",
1812
+ "name": "setRoyaltyRegistry",
1813
+ "inputs": [
1814
+ {
1815
+ "name": "_royaltyRegistry",
1816
+ "type": "address",
1817
+ "internalType": "address"
1818
+ }
1819
+ ],
1820
+ "outputs": [],
1821
+ "stateMutability": "nonpayable"
1822
+ },
1823
+ {
1824
+ "type": "function",
1825
+ "name": "setSalePrice",
1826
+ "inputs": [
1827
+ {
1828
+ "name": "_originContract",
1829
+ "type": "address",
1830
+ "internalType": "address"
1831
+ },
1832
+ {
1833
+ "name": "_tokenId",
1834
+ "type": "uint256",
1835
+ "internalType": "uint256"
1836
+ },
1837
+ {
1838
+ "name": "_currencyAddress",
1839
+ "type": "address",
1840
+ "internalType": "address"
1841
+ },
1842
+ {
1843
+ "name": "_listPrice",
1844
+ "type": "uint256",
1845
+ "internalType": "uint256"
1846
+ },
1847
+ {
1848
+ "name": "_target",
1849
+ "type": "address",
1850
+ "internalType": "address"
1851
+ },
1852
+ {
1853
+ "name": "_splitAddresses",
1854
+ "type": "address[]",
1855
+ "internalType": "address payable[]"
1856
+ },
1857
+ {
1858
+ "name": "_splitRatios",
1859
+ "type": "uint8[]",
1860
+ "internalType": "uint8[]"
1861
+ }
1862
+ ],
1863
+ "outputs": [],
1864
+ "stateMutability": "nonpayable"
1865
+ },
1866
+ {
1867
+ "type": "function",
1868
+ "name": "setSpaceOperatorRegistry",
1869
+ "inputs": [
1870
+ {
1871
+ "name": "_spaceOperatorRegistry",
1872
+ "type": "address",
1873
+ "internalType": "address"
1874
+ }
1875
+ ],
1876
+ "outputs": [],
1877
+ "stateMutability": "nonpayable"
1878
+ },
1879
+ {
1880
+ "type": "function",
1881
+ "name": "setStakingRegistry",
1882
+ "inputs": [
1883
+ {
1884
+ "name": "_stakingRegistry",
1885
+ "type": "address",
1886
+ "internalType": "address"
1887
+ }
1888
+ ],
1889
+ "outputs": [],
1890
+ "stateMutability": "nonpayable"
1891
+ },
1892
+ {
1893
+ "type": "function",
1894
+ "name": "setSuperRareAuctionHouse",
1895
+ "inputs": [
1896
+ {
1897
+ "name": "_superRareAuctionHouse",
1898
+ "type": "address",
1899
+ "internalType": "address"
1900
+ }
1901
+ ],
1902
+ "outputs": [],
1903
+ "stateMutability": "nonpayable"
1904
+ },
1905
+ {
1906
+ "type": "function",
1907
+ "name": "setSuperRareMarketplace",
1908
+ "inputs": [
1909
+ {
1910
+ "name": "_superRareMarketplace",
1911
+ "type": "address",
1912
+ "internalType": "address"
1913
+ }
1914
+ ],
1915
+ "outputs": [],
1916
+ "stateMutability": "nonpayable"
1917
+ },
1918
+ {
1919
+ "type": "function",
1920
+ "name": "settleAuction",
1921
+ "inputs": [
1922
+ {
1923
+ "name": "_originContract",
1924
+ "type": "address",
1925
+ "internalType": "address"
1926
+ },
1927
+ {
1928
+ "name": "_tokenId",
1929
+ "type": "uint256",
1930
+ "internalType": "uint256"
1931
+ }
1932
+ ],
1933
+ "outputs": [],
1934
+ "stateMutability": "nonpayable"
1935
+ },
1936
+ {
1937
+ "type": "function",
1938
+ "name": "spaceOperatorRegistry",
1939
+ "inputs": [],
1940
+ "outputs": [
1941
+ {
1942
+ "name": "",
1943
+ "type": "address",
1944
+ "internalType": "contract ISpaceOperatorRegistry"
1945
+ }
1946
+ ],
1947
+ "stateMutability": "view"
1948
+ },
1949
+ {
1950
+ "type": "function",
1951
+ "name": "stakingRegistry",
1952
+ "inputs": [],
1953
+ "outputs": [
1954
+ {
1955
+ "name": "",
1956
+ "type": "address",
1957
+ "internalType": "address"
1958
+ }
1959
+ ],
1960
+ "stateMutability": "view"
1961
+ },
1962
+ {
1963
+ "type": "function",
1964
+ "name": "superRareAuctionHouse",
1965
+ "inputs": [],
1966
+ "outputs": [
1967
+ {
1968
+ "name": "",
1969
+ "type": "address",
1970
+ "internalType": "address"
1971
+ }
1972
+ ],
1973
+ "stateMutability": "view"
1974
+ },
1975
+ {
1976
+ "type": "function",
1977
+ "name": "superRareMarketplace",
1978
+ "inputs": [],
1979
+ "outputs": [
1980
+ {
1981
+ "name": "",
1982
+ "type": "address",
1983
+ "internalType": "address"
1984
+ }
1985
+ ],
1986
+ "stateMutability": "view"
1987
+ },
1988
+ {
1989
+ "type": "function",
1990
+ "name": "tokenAuctions",
1991
+ "inputs": [
1992
+ {
1993
+ "name": "",
1994
+ "type": "address",
1995
+ "internalType": "address"
1996
+ },
1997
+ {
1998
+ "name": "",
1999
+ "type": "uint256",
2000
+ "internalType": "uint256"
2001
+ }
2002
+ ],
2003
+ "outputs": [
2004
+ {
2005
+ "name": "auctionCreator",
2006
+ "type": "address",
2007
+ "internalType": "address payable"
2008
+ },
2009
+ {
2010
+ "name": "creationBlock",
2011
+ "type": "uint256",
2012
+ "internalType": "uint256"
2013
+ },
2014
+ {
2015
+ "name": "startingTime",
2016
+ "type": "uint256",
2017
+ "internalType": "uint256"
2018
+ },
2019
+ {
2020
+ "name": "lengthOfAuction",
2021
+ "type": "uint256",
2022
+ "internalType": "uint256"
2023
+ },
2024
+ {
2025
+ "name": "currencyAddress",
2026
+ "type": "address",
2027
+ "internalType": "address"
2028
+ },
2029
+ {
2030
+ "name": "minimumBid",
2031
+ "type": "uint256",
2032
+ "internalType": "uint256"
2033
+ },
2034
+ {
2035
+ "name": "auctionType",
2036
+ "type": "bytes32",
2037
+ "internalType": "bytes32"
2038
+ }
2039
+ ],
2040
+ "stateMutability": "view"
2041
+ },
2042
+ {
2043
+ "type": "function",
2044
+ "name": "tokenCurrentOffers",
2045
+ "inputs": [
2046
+ {
2047
+ "name": "",
2048
+ "type": "address",
2049
+ "internalType": "address"
2050
+ },
2051
+ {
2052
+ "name": "",
2053
+ "type": "uint256",
2054
+ "internalType": "uint256"
2055
+ },
2056
+ {
2057
+ "name": "",
2058
+ "type": "address",
2059
+ "internalType": "address"
2060
+ }
2061
+ ],
2062
+ "outputs": [
2063
+ {
2064
+ "name": "buyer",
2065
+ "type": "address",
2066
+ "internalType": "address payable"
2067
+ },
2068
+ {
2069
+ "name": "amount",
2070
+ "type": "uint256",
2071
+ "internalType": "uint256"
2072
+ },
2073
+ {
2074
+ "name": "timestamp",
2075
+ "type": "uint256",
2076
+ "internalType": "uint256"
2077
+ },
2078
+ {
2079
+ "name": "marketplaceFee",
2080
+ "type": "uint8",
2081
+ "internalType": "uint8"
2082
+ },
2083
+ {
2084
+ "name": "convertible",
2085
+ "type": "bool",
2086
+ "internalType": "bool"
2087
+ }
2088
+ ],
2089
+ "stateMutability": "view"
2090
+ },
2091
+ {
2092
+ "type": "function",
2093
+ "name": "tokenSalePrices",
2094
+ "inputs": [
2095
+ {
2096
+ "name": "",
2097
+ "type": "address",
2098
+ "internalType": "address"
2099
+ },
2100
+ {
2101
+ "name": "",
2102
+ "type": "uint256",
2103
+ "internalType": "uint256"
2104
+ },
2105
+ {
2106
+ "name": "",
2107
+ "type": "address",
2108
+ "internalType": "address"
2109
+ }
2110
+ ],
2111
+ "outputs": [
2112
+ {
2113
+ "name": "seller",
2114
+ "type": "address",
2115
+ "internalType": "address payable"
2116
+ },
2117
+ {
2118
+ "name": "currencyAddress",
2119
+ "type": "address",
2120
+ "internalType": "address"
2121
+ },
2122
+ {
2123
+ "name": "amount",
2124
+ "type": "uint256",
2125
+ "internalType": "uint256"
2126
+ }
2127
+ ],
2128
+ "stateMutability": "view"
2129
+ },
2130
+ {
2131
+ "type": "function",
2132
+ "name": "transferOwnership",
2133
+ "inputs": [
2134
+ {
2135
+ "name": "newOwner",
2136
+ "type": "address",
2137
+ "internalType": "address"
2138
+ }
2139
+ ],
2140
+ "outputs": [],
2141
+ "stateMutability": "nonpayable"
2142
+ },
2143
+ {
2144
+ "type": "event",
2145
+ "name": "AcceptOffer",
2146
+ "inputs": [
2147
+ {
2148
+ "name": "_originContract",
2149
+ "type": "address",
2150
+ "indexed": true,
2151
+ "internalType": "address"
2152
+ },
2153
+ {
2154
+ "name": "_bidder",
2155
+ "type": "address",
2156
+ "indexed": true,
2157
+ "internalType": "address"
2158
+ },
2159
+ {
2160
+ "name": "_seller",
2161
+ "type": "address",
2162
+ "indexed": true,
2163
+ "internalType": "address"
2164
+ },
2165
+ {
2166
+ "name": "_currencyAddress",
2167
+ "type": "address",
2168
+ "indexed": false,
2169
+ "internalType": "address"
2170
+ },
2171
+ {
2172
+ "name": "_amount",
2173
+ "type": "uint256",
2174
+ "indexed": false,
2175
+ "internalType": "uint256"
2176
+ },
2177
+ {
2178
+ "name": "_tokenId",
2179
+ "type": "uint256",
2180
+ "indexed": false,
2181
+ "internalType": "uint256"
2182
+ },
2183
+ {
2184
+ "name": "_splitAddresses",
2185
+ "type": "address[]",
2186
+ "indexed": false,
2187
+ "internalType": "address payable[]"
2188
+ },
2189
+ {
2190
+ "name": "_splitRatios",
2191
+ "type": "uint8[]",
2192
+ "indexed": false,
2193
+ "internalType": "uint8[]"
2194
+ }
2195
+ ],
2196
+ "anonymous": false
2197
+ },
2198
+ {
2199
+ "type": "event",
2200
+ "name": "AuctionBid",
2201
+ "inputs": [
2202
+ {
2203
+ "name": "_contractAddress",
2204
+ "type": "address",
2205
+ "indexed": true,
2206
+ "internalType": "address"
2207
+ },
2208
+ {
2209
+ "name": "_bidder",
2210
+ "type": "address",
2211
+ "indexed": true,
2212
+ "internalType": "address"
2213
+ },
2214
+ {
2215
+ "name": "_tokenId",
2216
+ "type": "uint256",
2217
+ "indexed": true,
2218
+ "internalType": "uint256"
2219
+ },
2220
+ {
2221
+ "name": "_currencyAddress",
2222
+ "type": "address",
2223
+ "indexed": false,
2224
+ "internalType": "address"
2225
+ },
2226
+ {
2227
+ "name": "_amount",
2228
+ "type": "uint256",
2229
+ "indexed": false,
2230
+ "internalType": "uint256"
2231
+ },
2232
+ {
2233
+ "name": "_startedAuction",
2234
+ "type": "bool",
2235
+ "indexed": false,
2236
+ "internalType": "bool"
2237
+ },
2238
+ {
2239
+ "name": "_newAuctionLength",
2240
+ "type": "uint256",
2241
+ "indexed": false,
2242
+ "internalType": "uint256"
2243
+ },
2244
+ {
2245
+ "name": "_previousBidder",
2246
+ "type": "address",
2247
+ "indexed": false,
2248
+ "internalType": "address"
2249
+ }
2250
+ ],
2251
+ "anonymous": false
2252
+ },
2253
+ {
2254
+ "type": "event",
2255
+ "name": "AuctionSettled",
2256
+ "inputs": [
2257
+ {
2258
+ "name": "_contractAddress",
2259
+ "type": "address",
2260
+ "indexed": true,
2261
+ "internalType": "address"
2262
+ },
2263
+ {
2264
+ "name": "_bidder",
2265
+ "type": "address",
2266
+ "indexed": true,
2267
+ "internalType": "address"
2268
+ },
2269
+ {
2270
+ "name": "_seller",
2271
+ "type": "address",
2272
+ "indexed": false,
2273
+ "internalType": "address"
2274
+ },
2275
+ {
2276
+ "name": "_tokenId",
2277
+ "type": "uint256",
2278
+ "indexed": true,
2279
+ "internalType": "uint256"
2280
+ },
2281
+ {
2282
+ "name": "_currencyAddress",
2283
+ "type": "address",
2284
+ "indexed": false,
2285
+ "internalType": "address"
2286
+ },
2287
+ {
2288
+ "name": "_amount",
2289
+ "type": "uint256",
2290
+ "indexed": false,
2291
+ "internalType": "uint256"
2292
+ }
2293
+ ],
2294
+ "anonymous": false
2295
+ },
2296
+ {
2297
+ "type": "event",
2298
+ "name": "CancelAuction",
2299
+ "inputs": [
2300
+ {
2301
+ "name": "_contractAddress",
2302
+ "type": "address",
2303
+ "indexed": true,
2304
+ "internalType": "address"
2305
+ },
2306
+ {
2307
+ "name": "_tokenId",
2308
+ "type": "uint256",
2309
+ "indexed": true,
2310
+ "internalType": "uint256"
2311
+ },
2312
+ {
2313
+ "name": "_auctionCreator",
2314
+ "type": "address",
2315
+ "indexed": true,
2316
+ "internalType": "address"
2317
+ }
2318
+ ],
2319
+ "anonymous": false
2320
+ },
2321
+ {
2322
+ "type": "event",
2323
+ "name": "CancelOffer",
2324
+ "inputs": [
2325
+ {
2326
+ "name": "_originContract",
2327
+ "type": "address",
2328
+ "indexed": true,
2329
+ "internalType": "address"
2330
+ },
2331
+ {
2332
+ "name": "_bidder",
2333
+ "type": "address",
2334
+ "indexed": true,
2335
+ "internalType": "address"
2336
+ },
2337
+ {
2338
+ "name": "_currencyAddress",
2339
+ "type": "address",
2340
+ "indexed": true,
2341
+ "internalType": "address"
2342
+ },
2343
+ {
2344
+ "name": "_amount",
2345
+ "type": "uint256",
2346
+ "indexed": false,
2347
+ "internalType": "uint256"
2348
+ },
2349
+ {
2350
+ "name": "_tokenId",
2351
+ "type": "uint256",
2352
+ "indexed": false,
2353
+ "internalType": "uint256"
2354
+ }
2355
+ ],
2356
+ "anonymous": false
2357
+ },
2358
+ {
2359
+ "type": "event",
2360
+ "name": "Initialized",
2361
+ "inputs": [
2362
+ {
2363
+ "name": "version",
2364
+ "type": "uint8",
2365
+ "indexed": false,
2366
+ "internalType": "uint8"
2367
+ }
2368
+ ],
2369
+ "anonymous": false
2370
+ },
2371
+ {
2372
+ "type": "event",
2373
+ "name": "NewAuction",
2374
+ "inputs": [
2375
+ {
2376
+ "name": "_contractAddress",
2377
+ "type": "address",
2378
+ "indexed": true,
2379
+ "internalType": "address"
2380
+ },
2381
+ {
2382
+ "name": "_tokenId",
2383
+ "type": "uint256",
2384
+ "indexed": true,
2385
+ "internalType": "uint256"
2386
+ },
2387
+ {
2388
+ "name": "_auctionCreator",
2389
+ "type": "address",
2390
+ "indexed": true,
2391
+ "internalType": "address"
2392
+ },
2393
+ {
2394
+ "name": "_currencyAddress",
2395
+ "type": "address",
2396
+ "indexed": false,
2397
+ "internalType": "address"
2398
+ },
2399
+ {
2400
+ "name": "_startingTime",
2401
+ "type": "uint256",
2402
+ "indexed": false,
2403
+ "internalType": "uint256"
2404
+ },
2405
+ {
2406
+ "name": "_minimumBid",
2407
+ "type": "uint256",
2408
+ "indexed": false,
2409
+ "internalType": "uint256"
2410
+ },
2411
+ {
2412
+ "name": "_lengthOfAuction",
2413
+ "type": "uint256",
2414
+ "indexed": false,
2415
+ "internalType": "uint256"
2416
+ }
2417
+ ],
2418
+ "anonymous": false
2419
+ },
2420
+ {
2421
+ "type": "event",
2422
+ "name": "OfferPlaced",
2423
+ "inputs": [
2424
+ {
2425
+ "name": "_originContract",
2426
+ "type": "address",
2427
+ "indexed": true,
2428
+ "internalType": "address"
2429
+ },
2430
+ {
2431
+ "name": "_bidder",
2432
+ "type": "address",
2433
+ "indexed": true,
2434
+ "internalType": "address"
2435
+ },
2436
+ {
2437
+ "name": "_currencyAddress",
2438
+ "type": "address",
2439
+ "indexed": true,
2440
+ "internalType": "address"
2441
+ },
2442
+ {
2443
+ "name": "_amount",
2444
+ "type": "uint256",
2445
+ "indexed": false,
2446
+ "internalType": "uint256"
2447
+ },
2448
+ {
2449
+ "name": "_tokenId",
2450
+ "type": "uint256",
2451
+ "indexed": false,
2452
+ "internalType": "uint256"
2453
+ },
2454
+ {
2455
+ "name": "_convertible",
2456
+ "type": "bool",
2457
+ "indexed": false,
2458
+ "internalType": "bool"
2459
+ }
2460
+ ],
2461
+ "anonymous": false
2462
+ },
2463
+ {
2464
+ "type": "event",
2465
+ "name": "OwnershipTransferred",
2466
+ "inputs": [
2467
+ {
2468
+ "name": "previousOwner",
2469
+ "type": "address",
2470
+ "indexed": true,
2471
+ "internalType": "address"
2472
+ },
2473
+ {
2474
+ "name": "newOwner",
2475
+ "type": "address",
2476
+ "indexed": true,
2477
+ "internalType": "address"
2478
+ }
2479
+ ],
2480
+ "anonymous": false
2481
+ },
2482
+ {
2483
+ "type": "event",
2484
+ "name": "SetSalePrice",
2485
+ "inputs": [
2486
+ {
2487
+ "name": "_originContract",
2488
+ "type": "address",
2489
+ "indexed": true,
2490
+ "internalType": "address"
2491
+ },
2492
+ {
2493
+ "name": "_currencyAddress",
2494
+ "type": "address",
2495
+ "indexed": true,
2496
+ "internalType": "address"
2497
+ },
2498
+ {
2499
+ "name": "_target",
2500
+ "type": "address",
2501
+ "indexed": false,
2502
+ "internalType": "address"
2503
+ },
2504
+ {
2505
+ "name": "_amount",
2506
+ "type": "uint256",
2507
+ "indexed": false,
2508
+ "internalType": "uint256"
2509
+ },
2510
+ {
2511
+ "name": "_tokenId",
2512
+ "type": "uint256",
2513
+ "indexed": false,
2514
+ "internalType": "uint256"
2515
+ },
2516
+ {
2517
+ "name": "_splitRecipients",
2518
+ "type": "address[]",
2519
+ "indexed": false,
2520
+ "internalType": "address payable[]"
2521
+ },
2522
+ {
2523
+ "name": "_splitRatios",
2524
+ "type": "uint8[]",
2525
+ "indexed": false,
2526
+ "internalType": "uint8[]"
2527
+ }
2528
+ ],
2529
+ "anonymous": false
2530
+ },
2531
+ {
2532
+ "type": "event",
2533
+ "name": "Sold",
2534
+ "inputs": [
2535
+ {
2536
+ "name": "_originContract",
2537
+ "type": "address",
2538
+ "indexed": true,
2539
+ "internalType": "address"
2540
+ },
2541
+ {
2542
+ "name": "_buyer",
2543
+ "type": "address",
2544
+ "indexed": true,
2545
+ "internalType": "address"
2546
+ },
2547
+ {
2548
+ "name": "_seller",
2549
+ "type": "address",
2550
+ "indexed": true,
2551
+ "internalType": "address"
2552
+ },
2553
+ {
2554
+ "name": "_currencyAddress",
2555
+ "type": "address",
2556
+ "indexed": false,
2557
+ "internalType": "address"
2558
+ },
2559
+ {
2560
+ "name": "_amount",
2561
+ "type": "uint256",
2562
+ "indexed": false,
2563
+ "internalType": "uint256"
2564
+ },
2565
+ {
2566
+ "name": "_tokenId",
2567
+ "type": "uint256",
2568
+ "indexed": false,
2569
+ "internalType": "uint256"
2570
+ }
2571
+ ],
2572
+ "anonymous": false
2573
+ }
2574
+ ];
2575
+
2576
+ // src/sdk/api.ts
2577
+ import { isAddress } from "viem";
2578
+ var API_BASE_URL = "https://api.superrare.org";
2579
+ var MIME_TYPES = {
2580
+ ".png": "image/png",
2581
+ ".jpg": "image/jpeg",
2582
+ ".jpeg": "image/jpeg",
2583
+ ".gif": "image/gif",
2584
+ ".webp": "image/webp",
2585
+ ".svg": "image/svg+xml",
2586
+ ".mp4": "video/mp4",
2587
+ ".mov": "video/quicktime",
2588
+ ".webm": "video/webm",
2589
+ ".glb": "model/gltf-binary",
2590
+ ".gltf": "model/gltf+json",
2591
+ ".html": "text/html"
2592
+ };
2593
+ function inferMimeType(filename) {
2594
+ const extIndex = filename.lastIndexOf(".");
2595
+ const ext = extIndex === -1 ? "" : filename.slice(extIndex).toLowerCase();
2596
+ return MIME_TYPES[ext] ?? "application/octet-stream";
2597
+ }
2598
+ function normalizeFilename(filename) {
2599
+ const normalized = filename.replaceAll("\\", "/");
2600
+ const lastSeparator = normalized.lastIndexOf("/");
2601
+ return lastSeparator === -1 ? normalized : normalized.slice(lastSeparator + 1);
2602
+ }
2603
+ function assertPositiveInteger(value, fieldName) {
2604
+ if (!Number.isInteger(value) || value <= 0) {
2605
+ throw new Error(`${fieldName} must be a positive integer`);
2606
+ }
2607
+ }
2608
+ function assertEvmAddress(value, fieldName) {
2609
+ if (!isAddress(value)) {
2610
+ throw new Error(`${fieldName} must be a valid EVM address`);
2611
+ }
2612
+ }
2613
+ function parseDimensions(dimensions) {
2614
+ if (!dimensions) return void 0;
2615
+ const [w, h] = dimensions.split("x");
2616
+ if (!w || !h) return void 0;
2617
+ const width = Number.parseInt(w, 10);
2618
+ const height = Number.parseInt(h, 10);
2619
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
2620
+ return void 0;
2621
+ }
2622
+ return { width, height };
2623
+ }
2624
+ async function apiPost(path, payload) {
2625
+ const url = `${API_BASE_URL}${path}`;
2626
+ const response = await fetch(url, {
2627
+ method: "POST",
2628
+ headers: { "Content-Type": "application/json" },
2629
+ body: JSON.stringify(payload)
2630
+ });
2631
+ const text = await response.text();
2632
+ const json = text ? JSON.parse(text) : {};
2633
+ if (!response.ok) {
2634
+ const message = json.error ?? text;
2635
+ throw new Error(`API error ${response.status} on ${path}: ${String(message)}`);
2636
+ }
2637
+ return json;
2638
+ }
2639
+ async function uploadParts(fileBuffer, partSize, presignedUrls) {
2640
+ const parts = [];
2641
+ for (let i = 0; i < presignedUrls.length; i++) {
2642
+ const start = i * partSize;
2643
+ const end = start + partSize;
2644
+ const partBuffer = fileBuffer.subarray(start, end);
2645
+ const response = await fetch(presignedUrls[i], {
2646
+ method: "PUT",
2647
+ body: new Uint8Array(partBuffer)
2648
+ });
2649
+ if (response.status !== 200 && response.status !== 204) {
2650
+ throw new Error(`Part ${i + 1} upload failed with status ${response.status}`);
2651
+ }
2652
+ const etag = response.headers.get("etag");
2653
+ if (!etag) {
2654
+ throw new Error(`Missing etag header for part ${i + 1}`);
2655
+ }
2656
+ parts.push({ ETag: etag, PartNumber: i + 1 });
2657
+ }
2658
+ return parts;
2659
+ }
2660
+ async function uploadMedia(buffer, filename) {
2661
+ const fileSize = buffer.byteLength;
2662
+ const safeFilename = normalizeFilename(filename);
2663
+ const mimeType = inferMimeType(safeFilename);
2664
+ const init = await apiPost("/api/nft/media-upload-url", {
2665
+ fileSize,
2666
+ filename: safeFilename
2667
+ });
2668
+ const parts = await uploadParts(buffer, init.partSize, init.presignedUrls);
2669
+ const complete = await apiPost("/api/nft/media-upload-complete", {
2670
+ key: init.key,
2671
+ uploadId: init.uploadId,
2672
+ bucket: init.bucket,
2673
+ parts
2674
+ });
2675
+ const generated = await apiPost("/api/nft/media-generate", {
2676
+ uri: complete.ipfsUrl,
2677
+ mimeType
2678
+ });
2679
+ const dimensions = parseDimensions(generated.media.dimensions);
2680
+ return {
2681
+ url: generated.media.uri,
2682
+ mimeType: generated.media.mimeType,
2683
+ size: generated.media.size ?? fileSize,
2684
+ ...dimensions ? { dimensions } : {}
2685
+ };
2686
+ }
2687
+ async function pinMetadata(opts) {
2688
+ const nftMedia = {
2689
+ image: opts.image
2690
+ };
2691
+ if (opts.video) {
2692
+ nftMedia.video = opts.video;
2693
+ }
2694
+ const payload = {
2695
+ name: opts.name,
2696
+ description: opts.description,
2697
+ nftMedia,
2698
+ tags: opts.tags ?? []
2699
+ };
2700
+ if (opts.attributes && opts.attributes.length > 0) {
2701
+ payload.attributes = opts.attributes;
2702
+ }
2703
+ const result = await apiPost("/api/nft/metadata", payload);
2704
+ return result.ipfsUrl;
2705
+ }
2706
+ async function importErc721(opts) {
2707
+ assertPositiveInteger(opts.chainId, "chainId");
2708
+ assertEvmAddress(opts.contract, "contract");
2709
+ assertEvmAddress(opts.owner, "owner");
2710
+ const result = await apiPost("/api/nft/import-erc721", {
2711
+ chainId: opts.chainId,
2712
+ contractAddress: opts.contract.toLowerCase(),
2713
+ ownerAddress: opts.owner.toLowerCase()
2714
+ });
2715
+ if (result.ok !== true) {
2716
+ throw new Error("Unexpected response from /api/nft/import-erc721");
2717
+ }
2718
+ }
2719
+ async function searchPost(path, payload) {
2720
+ return apiPost(path, payload);
2721
+ }
2722
+ async function searchNfts(params = {}) {
2723
+ return searchPost("/api/search/nfts", {
2724
+ query: params.query ?? "",
2725
+ take: params.take ?? 24,
2726
+ cursor: params.cursor ?? 0,
2727
+ sortBy: params.sortBy ?? "RECENT_ACTIVITY_DESC",
2728
+ ownerAddresses: params.ownerAddresses ?? [],
2729
+ creatorAddresses: params.creatorAddresses ?? [],
2730
+ collectionIds: params.collectionIds ?? [],
2731
+ contractAddresses: params.contractAddresses ?? [],
2732
+ ...params.auctionStates ? { auctionStates: params.auctionStates } : {},
2733
+ ...params.chainIds ? { chainIds: params.chainIds } : {}
2734
+ });
2735
+ }
2736
+ async function searchCollections(params = {}) {
2737
+ return searchPost("/api/search/collections", {
2738
+ query: params.query ?? "",
2739
+ take: params.take ?? 24,
2740
+ cursor: params.cursor ?? 0,
2741
+ sortBy: params.sortBy ?? "NEWEST",
2742
+ ownerAddresses: params.ownerAddresses ?? []
2743
+ });
2744
+ }
2745
+
2746
+ // src/sdk/client.ts
2747
+ var ETH_ADDRESS2 = "0x0000000000000000000000000000000000000000";
2748
+ var approvalAbi = [
2749
+ {
2750
+ inputs: [{ name: "owner", type: "address" }, { name: "operator", type: "address" }],
2751
+ name: "isApprovedForAll",
2752
+ outputs: [{ name: "", type: "bool" }],
2753
+ stateMutability: "view",
2754
+ type: "function"
2755
+ },
2756
+ {
2757
+ inputs: [{ name: "operator", type: "address" }, { name: "approved", type: "bool" }],
2758
+ name: "setApprovalForAll",
2759
+ outputs: [],
2760
+ stateMutability: "nonpayable",
2761
+ type: "function"
2762
+ }
2763
+ ];
2764
+ var marketplaceSettingsAbi = [
2765
+ {
2766
+ inputs: [{ name: "_amount", type: "uint256" }],
2767
+ name: "calculateMarketplaceFee",
2768
+ outputs: [{ name: "", type: "uint256" }],
2769
+ stateMutability: "view",
2770
+ type: "function"
2771
+ }
2772
+ ];
2773
+ function resolveChainFromPublicClient(publicClient) {
2774
+ const chainId = publicClient.chain?.id;
2775
+ if (!chainId) {
2776
+ throw new Error("Unable to resolve chain from publicClient.chain.id. Create your public client with an explicit chain.");
2777
+ }
2778
+ for (const [chain, id] of Object.entries(chainIds)) {
2779
+ if (id === chainId) {
2780
+ return chain;
2781
+ }
2782
+ }
2783
+ throw new Error(`Unsupported chain id: ${chainId}. Supported chain ids: ${Object.values(chainIds).join(", ")}`);
2784
+ }
2785
+ function requireWallet(config) {
2786
+ if (!config.walletClient) {
2787
+ throw new Error("walletClient is required for write operations.");
2788
+ }
2789
+ const walletAccount = config.walletClient.account;
2790
+ if (config.account) {
2791
+ if (walletAccount && walletAccount.address.toLowerCase() === config.account.toLowerCase()) {
2792
+ return {
2793
+ walletClient: config.walletClient,
2794
+ account: walletAccount,
2795
+ accountAddress: walletAccount.address
2796
+ };
2797
+ }
2798
+ return {
2799
+ walletClient: config.walletClient,
2800
+ account: config.account,
2801
+ accountAddress: config.account
2802
+ };
2803
+ }
2804
+ if (!walletAccount) {
2805
+ throw new Error("No account available for write operations. Pass config.account or provide walletClient with an account.");
2806
+ }
2807
+ return {
2808
+ walletClient: config.walletClient,
2809
+ account: walletAccount,
2810
+ accountAddress: walletAccount.address
2811
+ };
2812
+ }
2813
+ function toInteger(value, field) {
2814
+ if (typeof value === "bigint") return value;
2815
+ if (typeof value === "number") {
2816
+ if (!Number.isFinite(value) || !Number.isInteger(value)) {
2817
+ throw new Error(`${field} must be an integer.`);
2818
+ }
2819
+ return BigInt(value);
2820
+ }
2821
+ try {
2822
+ return BigInt(value);
2823
+ } catch {
2824
+ throw new Error(`${field} must be an integer.`);
2825
+ }
2826
+ }
2827
+ function toWei(value) {
2828
+ if (typeof value === "bigint") {
2829
+ return value;
2830
+ }
2831
+ return parseEther(String(value));
2832
+ }
2833
+ function createRareClient(config) {
2834
+ const { publicClient } = config;
2835
+ const chain = resolveChainFromPublicClient(publicClient);
2836
+ const chainId = chainIds[chain];
2837
+ const addresses = getContractAddresses(chain);
2838
+ return {
2839
+ chain,
2840
+ chainId,
2841
+ contracts: {
2842
+ factory: addresses.factory,
2843
+ auction: addresses.auction
2844
+ },
2845
+ deploy: {
2846
+ async erc721(params) {
2847
+ const { walletClient, account } = requireWallet(config);
2848
+ let txHash;
2849
+ if (params.maxTokens !== void 0) {
2850
+ txHash = await walletClient.writeContract({
2851
+ address: addresses.factory,
2852
+ abi: factoryAbi,
2853
+ functionName: "createSovereignBatchMint",
2854
+ args: [params.name, params.symbol, toInteger(params.maxTokens, "maxTokens")],
2855
+ account,
2856
+ chain: void 0
2857
+ });
2858
+ } else {
2859
+ txHash = await walletClient.writeContract({
2860
+ address: addresses.factory,
2861
+ abi: factoryAbi,
2862
+ functionName: "createSovereignBatchMint",
2863
+ args: [params.name, params.symbol],
2864
+ account,
2865
+ chain: void 0
2866
+ });
2867
+ }
2868
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
2869
+ const logs = parseEventLogs({
2870
+ abi: factoryAbi,
2871
+ logs: receipt.logs,
2872
+ eventName: "SovereignBatchMintCreated"
2873
+ });
2874
+ return {
2875
+ txHash,
2876
+ receipt,
2877
+ contract: logs[0]?.args.contractAddress
2878
+ };
2879
+ }
2880
+ },
2881
+ mint: {
2882
+ async mintTo(params) {
2883
+ const { walletClient, account, accountAddress } = requireWallet(config);
2884
+ const useMintTo = Boolean(params.to || params.royaltyReceiver);
2885
+ let txHash;
2886
+ if (useMintTo) {
2887
+ const receiver = params.to ?? accountAddress;
2888
+ const royaltyReceiver = params.royaltyReceiver ?? accountAddress;
2889
+ txHash = await walletClient.writeContract({
2890
+ address: params.contract,
2891
+ abi: tokenAbi,
2892
+ functionName: "mintTo",
2893
+ args: [params.tokenUri, receiver, royaltyReceiver],
2894
+ account,
2895
+ chain: void 0
2896
+ });
2897
+ } else {
2898
+ txHash = await walletClient.writeContract({
2899
+ address: params.contract,
2900
+ abi: tokenAbi,
2901
+ functionName: "addNewToken",
2902
+ args: [params.tokenUri],
2903
+ account,
2904
+ chain: void 0
2905
+ });
2906
+ }
2907
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
2908
+ const logs = parseEventLogs({
2909
+ abi: tokenAbi,
2910
+ logs: receipt.logs,
2911
+ eventName: "Transfer"
2912
+ });
2913
+ return {
2914
+ txHash,
2915
+ receipt,
2916
+ tokenId: logs[0]?.args.tokenId
2917
+ };
2918
+ }
2919
+ },
2920
+ auction: {
2921
+ async create(params) {
2922
+ const { walletClient, account, accountAddress } = requireWallet(config);
2923
+ const nftAddress = params.contract;
2924
+ const currency = params.currency ?? ETH_ADDRESS2;
2925
+ const tokenId = toInteger(params.tokenId, "tokenId");
2926
+ const startingPrice = toWei(params.startingPrice);
2927
+ const duration = toInteger(params.duration, "duration");
2928
+ const splitAddresses = params.splitAddresses ?? [accountAddress];
2929
+ const splitRatios = params.splitRatios ?? [100];
2930
+ let approvalTxHash;
2931
+ if (params.autoApprove !== false) {
2932
+ const isApproved = await publicClient.readContract({
2933
+ address: nftAddress,
2934
+ abi: approvalAbi,
2935
+ functionName: "isApprovedForAll",
2936
+ args: [accountAddress, addresses.auction]
2937
+ });
2938
+ if (!isApproved) {
2939
+ approvalTxHash = await walletClient.writeContract({
2940
+ address: nftAddress,
2941
+ abi: approvalAbi,
2942
+ functionName: "setApprovalForAll",
2943
+ args: [addresses.auction, true],
2944
+ account,
2945
+ chain: void 0
2946
+ });
2947
+ await publicClient.waitForTransactionReceipt({ hash: approvalTxHash });
2948
+ }
2949
+ }
2950
+ const auctionType = await publicClient.readContract({
2951
+ address: addresses.auction,
2952
+ abi: auctionAbi,
2953
+ functionName: "COLDIE_AUCTION"
2954
+ });
2955
+ const txHash = await walletClient.writeContract({
2956
+ address: addresses.auction,
2957
+ abi: auctionAbi,
2958
+ functionName: "configureAuction",
2959
+ args: [
2960
+ auctionType,
2961
+ nftAddress,
2962
+ tokenId,
2963
+ startingPrice,
2964
+ currency,
2965
+ duration,
2966
+ 0n,
2967
+ splitAddresses,
2968
+ splitRatios
2969
+ ],
2970
+ account,
2971
+ chain: void 0
2972
+ });
2973
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
2974
+ return {
2975
+ txHash,
2976
+ receipt,
2977
+ approvalTxHash
2978
+ };
2979
+ },
2980
+ async bid(params) {
2981
+ const { walletClient, account, accountAddress } = requireWallet(config);
2982
+ const currency = params.currency ?? ETH_ADDRESS2;
2983
+ const amount = toWei(params.amount);
2984
+ const isEth = currency === ETH_ADDRESS2;
2985
+ let value = 0n;
2986
+ if (isEth) {
2987
+ const settingsAddress = await publicClient.readContract({
2988
+ address: addresses.auction,
2989
+ abi: auctionAbi,
2990
+ functionName: "marketplaceSettings"
2991
+ });
2992
+ const fee = await publicClient.readContract({
2993
+ address: settingsAddress,
2994
+ abi: marketplaceSettingsAbi,
2995
+ functionName: "calculateMarketplaceFee",
2996
+ args: [amount]
2997
+ });
2998
+ value = amount + fee;
2999
+ } else {
3000
+ try {
3001
+ const allowance = await publicClient.readContract({
3002
+ address: currency,
3003
+ abi: erc20Abi,
3004
+ functionName: "allowance",
3005
+ args: [accountAddress, addresses.auction]
3006
+ });
3007
+ if (BigInt(allowance) < amount) {
3008
+ const approveTx = await walletClient.writeContract({
3009
+ address: currency,
3010
+ abi: erc20Abi,
3011
+ functionName: "approve",
3012
+ args: [addresses.auction, maxUint256],
3013
+ account,
3014
+ chain: void 0
3015
+ });
3016
+ await publicClient.waitForTransactionReceipt({ hash: approveTx });
3017
+ }
3018
+ } catch {
3019
+ const approveTx = await walletClient.writeContract({
3020
+ address: currency,
3021
+ abi: erc20Abi,
3022
+ functionName: "approve",
3023
+ args: [addresses.auction, maxUint256],
3024
+ account,
3025
+ chain: void 0
3026
+ });
3027
+ await publicClient.waitForTransactionReceipt({ hash: approveTx });
3028
+ }
3029
+ }
3030
+ const txHash = await walletClient.writeContract({
3031
+ address: addresses.auction,
3032
+ abi: auctionAbi,
3033
+ functionName: "bid",
3034
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), currency, amount],
3035
+ account,
3036
+ chain: void 0,
3037
+ value
3038
+ });
3039
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3040
+ return { txHash, receipt };
3041
+ },
3042
+ async settle(params) {
3043
+ const { walletClient, account } = requireWallet(config);
3044
+ const txHash = await walletClient.writeContract({
3045
+ address: addresses.auction,
3046
+ abi: auctionAbi,
3047
+ functionName: "settleAuction",
3048
+ args: [params.contract, toInteger(params.tokenId, "tokenId")],
3049
+ account,
3050
+ chain: void 0
3051
+ });
3052
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3053
+ return { txHash, receipt };
3054
+ },
3055
+ async cancel(params) {
3056
+ const { walletClient, account } = requireWallet(config);
3057
+ const txHash = await walletClient.writeContract({
3058
+ address: addresses.auction,
3059
+ abi: auctionAbi,
3060
+ functionName: "cancelAuction",
3061
+ args: [params.contract, toInteger(params.tokenId, "tokenId")],
3062
+ account,
3063
+ chain: void 0
3064
+ });
3065
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3066
+ return { txHash, receipt };
3067
+ },
3068
+ async getStatus(params) {
3069
+ const result = await publicClient.readContract({
3070
+ address: addresses.auction,
3071
+ abi: auctionAbi,
3072
+ functionName: "getAuctionDetails",
3073
+ args: [params.contract, toInteger(params.tokenId, "tokenId")]
3074
+ });
3075
+ const [
3076
+ seller,
3077
+ creationBlock,
3078
+ startingTime,
3079
+ lengthOfAuction,
3080
+ currency,
3081
+ minimumBid,
3082
+ auctionType,
3083
+ splitAddresses,
3084
+ splitRatios
3085
+ ] = result;
3086
+ const started = startingTime > 0n;
3087
+ const endTime = started ? startingTime + lengthOfAuction : null;
3088
+ const now = BigInt(Math.floor(Date.now() / 1e3));
3089
+ let status = "PENDING";
3090
+ if (started) {
3091
+ status = endTime !== null && now >= endTime ? "ENDED" : "RUNNING";
3092
+ }
3093
+ return {
3094
+ seller,
3095
+ creationBlock,
3096
+ startingTime,
3097
+ lengthOfAuction,
3098
+ currency,
3099
+ minimumBid,
3100
+ auctionType,
3101
+ splitAddresses: [...splitAddresses],
3102
+ splitRatios: [...splitRatios],
3103
+ isEth: currency === ETH_ADDRESS2,
3104
+ started,
3105
+ endTime,
3106
+ status
3107
+ };
3108
+ }
3109
+ },
3110
+ offer: {
3111
+ async create(params) {
3112
+ const { walletClient, account, accountAddress } = requireWallet(config);
3113
+ const currency = params.currency ?? ETH_ADDRESS2;
3114
+ const amount = toWei(params.amount);
3115
+ const isEth = currency === ETH_ADDRESS2;
3116
+ const convertible = params.convertible ?? false;
3117
+ let value = 0n;
3118
+ if (isEth) {
3119
+ const settingsAddress = await publicClient.readContract({
3120
+ address: addresses.auction,
3121
+ abi: auctionAbi,
3122
+ functionName: "marketplaceSettings"
3123
+ });
3124
+ const fee = await publicClient.readContract({
3125
+ address: settingsAddress,
3126
+ abi: marketplaceSettingsAbi,
3127
+ functionName: "calculateMarketplaceFee",
3128
+ args: [amount]
3129
+ });
3130
+ value = amount + fee;
3131
+ } else {
3132
+ try {
3133
+ const allowance = await publicClient.readContract({
3134
+ address: currency,
3135
+ abi: erc20Abi,
3136
+ functionName: "allowance",
3137
+ args: [accountAddress, addresses.auction]
3138
+ });
3139
+ if (BigInt(allowance) < amount) {
3140
+ const approveTx = await walletClient.writeContract({
3141
+ address: currency,
3142
+ abi: erc20Abi,
3143
+ functionName: "approve",
3144
+ args: [addresses.auction, maxUint256],
3145
+ account,
3146
+ chain: void 0
3147
+ });
3148
+ await publicClient.waitForTransactionReceipt({ hash: approveTx });
3149
+ }
3150
+ } catch {
3151
+ const approveTx = await walletClient.writeContract({
3152
+ address: currency,
3153
+ abi: erc20Abi,
3154
+ functionName: "approve",
3155
+ args: [addresses.auction, maxUint256],
3156
+ account,
3157
+ chain: void 0
3158
+ });
3159
+ await publicClient.waitForTransactionReceipt({ hash: approveTx });
3160
+ }
3161
+ }
3162
+ const txHash = await walletClient.writeContract({
3163
+ address: addresses.auction,
3164
+ abi: auctionAbi,
3165
+ functionName: "offer",
3166
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), currency, amount, convertible],
3167
+ account,
3168
+ chain: void 0,
3169
+ value
3170
+ });
3171
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3172
+ return { txHash, receipt };
3173
+ },
3174
+ async cancel(params) {
3175
+ const { walletClient, account } = requireWallet(config);
3176
+ const currency = params.currency ?? ETH_ADDRESS2;
3177
+ const txHash = await walletClient.writeContract({
3178
+ address: addresses.auction,
3179
+ abi: auctionAbi,
3180
+ functionName: "cancelOffer",
3181
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), currency],
3182
+ account,
3183
+ chain: void 0
3184
+ });
3185
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3186
+ return { txHash, receipt };
3187
+ },
3188
+ async accept(params) {
3189
+ const { walletClient, account, accountAddress } = requireWallet(config);
3190
+ const currency = params.currency ?? ETH_ADDRESS2;
3191
+ const amount = toWei(params.amount);
3192
+ const splitAddresses = params.splitAddresses ?? [accountAddress];
3193
+ const splitRatios = params.splitRatios ?? [100];
3194
+ const txHash = await walletClient.writeContract({
3195
+ address: addresses.auction,
3196
+ abi: auctionAbi,
3197
+ functionName: "acceptOffer",
3198
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), currency, amount, splitAddresses, splitRatios],
3199
+ account,
3200
+ chain: void 0
3201
+ });
3202
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3203
+ return { txHash, receipt };
3204
+ },
3205
+ async getStatus(params) {
3206
+ const currency = params.currency ?? ETH_ADDRESS2;
3207
+ const [buyer, amount, timestamp, marketplaceFee, convertible] = await publicClient.readContract({
3208
+ address: addresses.auction,
3209
+ abi: auctionAbi,
3210
+ functionName: "tokenCurrentOffers",
3211
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), currency]
3212
+ });
3213
+ const hasOffer = amount > 0n;
3214
+ return { buyer, amount, timestamp, marketplaceFee, convertible, hasOffer };
3215
+ }
3216
+ },
3217
+ listing: {
3218
+ async create(params) {
3219
+ const { walletClient, account, accountAddress } = requireWallet(config);
3220
+ const currency = params.currency ?? ETH_ADDRESS2;
3221
+ const price = toWei(params.price);
3222
+ const target = params.target ?? ETH_ADDRESS2;
3223
+ const splitAddresses = params.splitAddresses ?? [accountAddress];
3224
+ const splitRatios = params.splitRatios ?? [100];
3225
+ const nftAddress = params.contract;
3226
+ let approvalTxHash;
3227
+ if (params.autoApprove !== false) {
3228
+ const isApproved = await publicClient.readContract({
3229
+ address: nftAddress,
3230
+ abi: approvalAbi,
3231
+ functionName: "isApprovedForAll",
3232
+ args: [accountAddress, addresses.auction]
3233
+ });
3234
+ if (!isApproved) {
3235
+ approvalTxHash = await walletClient.writeContract({
3236
+ address: nftAddress,
3237
+ abi: approvalAbi,
3238
+ functionName: "setApprovalForAll",
3239
+ args: [addresses.auction, true],
3240
+ account,
3241
+ chain: void 0
3242
+ });
3243
+ await publicClient.waitForTransactionReceipt({ hash: approvalTxHash });
3244
+ }
3245
+ }
3246
+ const txHash = await walletClient.writeContract({
3247
+ address: addresses.auction,
3248
+ abi: auctionAbi,
3249
+ functionName: "setSalePrice",
3250
+ args: [nftAddress, toInteger(params.tokenId, "tokenId"), currency, price, target, splitAddresses, splitRatios],
3251
+ account,
3252
+ chain: void 0
3253
+ });
3254
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3255
+ return { txHash, receipt, approvalTxHash };
3256
+ },
3257
+ async cancel(params) {
3258
+ const { walletClient, account } = requireWallet(config);
3259
+ const target = params.target ?? ETH_ADDRESS2;
3260
+ const txHash = await walletClient.writeContract({
3261
+ address: addresses.auction,
3262
+ abi: auctionAbi,
3263
+ functionName: "removeSalePrice",
3264
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), target],
3265
+ account,
3266
+ chain: void 0
3267
+ });
3268
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3269
+ return { txHash, receipt };
3270
+ },
3271
+ async buy(params) {
3272
+ const { walletClient, account, accountAddress } = requireWallet(config);
3273
+ const currency = params.currency ?? ETH_ADDRESS2;
3274
+ const amount = toWei(params.amount);
3275
+ const isEth = currency === ETH_ADDRESS2;
3276
+ let value = 0n;
3277
+ if (isEth) {
3278
+ const settingsAddress = await publicClient.readContract({
3279
+ address: addresses.auction,
3280
+ abi: auctionAbi,
3281
+ functionName: "marketplaceSettings"
3282
+ });
3283
+ const fee = await publicClient.readContract({
3284
+ address: settingsAddress,
3285
+ abi: marketplaceSettingsAbi,
3286
+ functionName: "calculateMarketplaceFee",
3287
+ args: [amount]
3288
+ });
3289
+ value = amount + fee;
3290
+ } else {
3291
+ try {
3292
+ const allowance = await publicClient.readContract({
3293
+ address: currency,
3294
+ abi: erc20Abi,
3295
+ functionName: "allowance",
3296
+ args: [accountAddress, addresses.auction]
3297
+ });
3298
+ if (BigInt(allowance) < amount) {
3299
+ const approveTx = await walletClient.writeContract({
3300
+ address: currency,
3301
+ abi: erc20Abi,
3302
+ functionName: "approve",
3303
+ args: [addresses.auction, maxUint256],
3304
+ account,
3305
+ chain: void 0
3306
+ });
3307
+ await publicClient.waitForTransactionReceipt({ hash: approveTx });
3308
+ }
3309
+ } catch {
3310
+ const approveTx = await walletClient.writeContract({
3311
+ address: currency,
3312
+ abi: erc20Abi,
3313
+ functionName: "approve",
3314
+ args: [addresses.auction, maxUint256],
3315
+ account,
3316
+ chain: void 0
3317
+ });
3318
+ await publicClient.waitForTransactionReceipt({ hash: approveTx });
3319
+ }
3320
+ }
3321
+ const txHash = await walletClient.writeContract({
3322
+ address: addresses.auction,
3323
+ abi: auctionAbi,
3324
+ functionName: "buy",
3325
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), currency, amount],
3326
+ account,
3327
+ chain: void 0,
3328
+ value
3329
+ });
3330
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
3331
+ return { txHash, receipt };
3332
+ },
3333
+ async getStatus(params) {
3334
+ const target = params.target ?? ETH_ADDRESS2;
3335
+ const [seller, currencyAddress, amount] = await publicClient.readContract({
3336
+ address: addresses.auction,
3337
+ abi: auctionAbi,
3338
+ functionName: "tokenSalePrices",
3339
+ args: [params.contract, toInteger(params.tokenId, "tokenId"), target]
3340
+ });
3341
+ const hasListing = amount > 0n;
3342
+ const isEth = currencyAddress === ETH_ADDRESS2;
3343
+ return { seller, currencyAddress, amount, hasListing, isEth };
3344
+ }
3345
+ },
3346
+ search: {
3347
+ async nfts(params = {}) {
3348
+ const requestParams = params.chainIds ? params : { ...params, chainIds: [chainId] };
3349
+ return searchNfts(requestParams);
3350
+ },
3351
+ async collections(params = {}) {
3352
+ return searchCollections(params);
3353
+ }
3354
+ },
3355
+ media: {
3356
+ async upload(buffer, filename) {
3357
+ return uploadMedia(buffer, filename);
3358
+ },
3359
+ async pinMetadata(opts) {
3360
+ return pinMetadata(opts);
3361
+ }
3362
+ },
3363
+ import: {
3364
+ async erc721(params) {
3365
+ const owner = params.owner ?? config.account ?? config.walletClient?.account?.address;
3366
+ if (!owner) {
3367
+ throw new Error("No owner available for import. Pass params.owner or provide config.account/walletClient with an account.");
3368
+ }
3369
+ await importErc721({
3370
+ chainId,
3371
+ contract: params.contract,
3372
+ owner
3373
+ });
3374
+ }
3375
+ },
3376
+ token: {
3377
+ async getContractInfo(params) {
3378
+ const [name, symbol, totalSupply] = await Promise.all([
3379
+ publicClient.readContract({
3380
+ address: params.contract,
3381
+ abi: tokenAbi,
3382
+ functionName: "name"
3383
+ }),
3384
+ publicClient.readContract({
3385
+ address: params.contract,
3386
+ abi: tokenAbi,
3387
+ functionName: "symbol"
3388
+ }),
3389
+ publicClient.readContract({
3390
+ address: params.contract,
3391
+ abi: tokenAbi,
3392
+ functionName: "totalSupply"
3393
+ })
3394
+ ]);
3395
+ return {
3396
+ contract: params.contract,
3397
+ chain,
3398
+ name,
3399
+ symbol,
3400
+ totalSupply
3401
+ };
3402
+ },
3403
+ async getTokenInfo(params) {
3404
+ const tokenId = toInteger(params.tokenId, "tokenId");
3405
+ const [owner, tokenUri] = await Promise.all([
3406
+ publicClient.readContract({
3407
+ address: params.contract,
3408
+ abi: tokenAbi,
3409
+ functionName: "ownerOf",
3410
+ args: [tokenId]
3411
+ }),
3412
+ publicClient.readContract({
3413
+ address: params.contract,
3414
+ abi: tokenAbi,
3415
+ functionName: "tokenURI",
3416
+ args: [tokenId]
3417
+ })
3418
+ ]);
3419
+ return {
3420
+ contract: params.contract,
3421
+ tokenId,
3422
+ owner,
3423
+ tokenUri
3424
+ };
3425
+ }
3426
+ }
3427
+ };
3428
+ }
3429
+ export {
3430
+ auctionAbi,
3431
+ chainIds,
3432
+ contractAddresses,
3433
+ createRareClient,
3434
+ factoryAbi,
3435
+ getContractAddresses,
3436
+ isSupportedChain,
3437
+ tokenAbi,
3438
+ viemChains
3439
+ };