@rareprotocol/rare-cli 0.1.0

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