forked from samuelvanderwaal/metaboss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopt.rs
414 lines (361 loc) · 11.8 KB
/
opt.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "Metaboss", about = "Metaplex NFT 'Swiss Army Knife' tool.")]
pub struct Opt {
/// RPC endpoint url to override using the Solana config or the hard-coded default
#[structopt(short, long, global = true)]
pub rpc: Option<String>,
/// Timeout to override default value of 60 seconds
#[structopt(short, long, global = true, default_value = "90")]
pub timeout: u64,
/// Log level
#[structopt(short, long, global = true, default_value = "warn")]
pub log_level: String,
#[structopt(subcommand)]
pub cmd: Command,
}
#[derive(Debug, StructOpt)]
pub enum Command {
/// Burn token
#[structopt(name = "burn")]
Burn {
#[structopt(subcommand)]
burn_subcommands: BurnSubcommands,
},
/// Decode on-chain data into JSON format
#[structopt(name = "decode")]
Decode {
#[structopt(subcommand)]
decode_subcommands: DecodeSubcommands,
},
/// Derive PDAs for various account types
Derive {
#[structopt(subcommand)]
derive_subcommands: DeriveSubcommands,
},
/// Mint new NFTs from JSON files
#[structopt(name = "mint")]
Mint {
#[structopt(subcommand)]
mint_subcommands: MintSubcommands,
},
/// Update various aspects of NFTs
#[structopt(name = "update")]
Update {
#[structopt(subcommand)]
update_subcommands: UpdateSubcommands,
},
/// Set non-Data struct values for a NFT
#[structopt(name = "set")]
Set {
#[structopt(subcommand)]
set_subcommands: SetSubcommands,
},
/// Sign metadata for an unverified creator
#[structopt(name = "sign")]
Sign {
#[structopt(subcommand)]
sign_subcommands: SignSubcommands,
},
/// Get snapshots of various blockchain states
#[structopt(name = "snapshot")]
Snapshot {
#[structopt(subcommand)]
snapshot_subcommands: SnapshotSubcommands,
},
/// Withdraw
Withdraw {
#[structopt(subcommand)]
withdraw_subcommands: WithdrawSubcommands,
},
}
#[derive(Debug, StructOpt)]
pub enum BurnSubcommands {
#[structopt(name = "one")]
One {
/// Path to the authority & funder keypair file
#[structopt(short, long)]
keypair: String,
/// Token mint account
#[structopt(short, long)]
account: String,
},
}
#[derive(Debug, StructOpt)]
pub enum DecodeSubcommands {
/// Decode a mint account's metadata
#[structopt(name = "mint")]
Mint {
/// Single mint account to decode
#[structopt(short, long)]
account: Option<String>,
/// Use this to write the full metadata struct to the output
#[structopt(long)]
full: bool,
/// Path to JSON file containing a list of mint accounts to decode
#[structopt(short, long)]
list_file: Option<String>,
/// Path to directory to save output files.
#[structopt(short, long, default_value = ".")]
output: String,
},
}
#[derive(Debug, StructOpt)]
pub enum DeriveSubcommands {
/// Derive generic PDA from seeds and program id
#[structopt(name = "pda")]
Pda {
/// Seeds to derive PDA from
seeds: String,
/// Program id to derive PDA from
program_id: String,
},
/// Derive Metadata PDA
#[structopt(name = "metadata")]
Metadata { mint_account: String },
/// Derive Edition PDA
#[structopt(name = "edition")]
Edition { mint_account: String },
/// Derive CMV2 PDA
#[structopt(name = "cmv2-creator")]
CMV2Creator { candy_machine_id: String },
}
#[derive(Debug, StructOpt)]
pub enum MintSubcommands {
/// Mint a single NFT from a JSON file
#[structopt(name = "one")]
One {
/// Path to the update_authority keypair file
#[structopt(short, long)]
keypair: String,
/// Receiving address, if different from update authority.
#[structopt(short, long)]
receiver: Option<String>,
/// On-chain formatted metadata for the new NFT
#[structopt(short = "d", long)]
nft_data_file: Option<String>,
/// Link to external metadata to use to create the NFT
#[structopt(short = "u", long)]
external_metadata_uri: Option<String>,
/// Mint the NFT with immutable data fields
#[structopt(short, long)]
immutable: bool,
/// Mint the NFT with primary_sale_happened set to true
#[structopt(short, long)]
primary_sale_happened: bool,
},
#[structopt(name = "list")]
/// Mint a list of NFTs from a directory of JSON files
List {
/// Path to the update_authority keypair file
#[structopt(short, long)]
keypair: String,
/// Receiving address, if different from update authority
#[structopt(short, long)]
receiver: Option<String>,
/// Directory of on-chain formatted metadata files for the new NFTs
#[structopt(short = "d", long)]
nft_data_dir: Option<String>,
/// List of external metadata links to use to create the NFTs
#[structopt(short = "u", long)]
external_metadata_uris: Option<String>,
/// Mint the NFTs with immutable data fields
#[structopt(short, long)]
immutable: bool,
/// Mint the NFTs with primary_sale_happened set to true
#[structopt(short, long)]
primary_sale_happened: bool,
},
}
#[derive(Debug, StructOpt)]
pub enum SetSubcommands {
/// Set primary sale happened to true
#[structopt(name = "primary-sale-happened")]
PrimarySaleHappened {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Mint account of corresponding metadata to update
#[structopt(short, long)]
account: String,
},
/// Set update authority to a new account
#[structopt(name = "update-authority")]
UpdateAuthority {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Mint account of corresponding metadata to update
#[structopt(short, long)]
account: String,
/// New update authority address
#[structopt(short = "u", long)]
new_update_authority: String,
},
/// Set update authority on multiple accounts to a new account
#[structopt(name = "update-authority-all")]
UpdateAuthorityAll {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Path to JSON mint accounts file
#[structopt(short = "a", long)]
mint_accounts_file: String,
/// New update authority address
#[structopt(short = "u", long)]
new_update_authority: String,
},
/// Set is-mutable to false, preventing any future updates to the NFT
#[structopt(name = "immutable")]
Immutable {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Mint account of corresponding metadata to update
#[structopt(short, long)]
mint_account: String,
},
ImmutableAll {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Path to JSON mint accounts file
#[structopt(short, long)]
mint_accounts_file: String,
},
}
#[derive(Debug, StructOpt)]
pub enum SignSubcommands {
/// Sign the metadata for a single mint account
#[structopt(name = "one")]
One {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Mint account to sign
#[structopt(short, long)]
account: String,
},
/// Sign all metadata from a JSON list or for a given candy machine id
#[structopt(name = "all")]
All {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Candy Machine ID to filter accounts by
#[structopt(short, long)]
candy_machine_id: Option<String>,
/// Candy machine v2 id
#[structopt(long = "v2")]
v2: bool,
/// Path to JSON file with list of mint accounts to sign
#[structopt(short, long)]
mint_accounts_file: Option<String>,
},
}
#[derive(Debug, StructOpt)]
pub enum SnapshotSubcommands {
/// Snapshot all current holders of NFTs by candy_machine_id or update_authority
#[structopt(name = "holders")]
Holders {
/// Update authority to filter accounts by.
#[structopt(short, long)]
update_authority: Option<String>,
/// Candy Machine ID to filter accounts by.
#[structopt(short, long)]
candy_machine_id: Option<String>,
/// Candy machine v2 id
#[structopt(long = "v2")]
v2: bool,
/// Path to directory to save output files.
#[structopt(short, long, default_value = ".")]
output: String,
},
///Snapshot all candy machine config and state accounts for a given update_authority
#[structopt(name = "cm-accounts")]
CMAccounts {
/// Update authority to filter accounts by.
#[structopt(short, long)]
update_authority: String,
/// Path to directory to save output files.
#[structopt(short, long, default_value = ".")]
output: String,
},
/// Snapshot all mint accounts for a given candy machine id or update authority
#[structopt(name = "mints")]
Mints {
/// Candy Machine ID to filter accounts by
#[structopt(short, long)]
candy_machine_id: Option<String>,
/// Update authority to filter accounts by.
#[structopt(short, long)]
update_authority: Option<String>,
/// Candy machine v2 id
#[structopt(long = "v2")]
v2: bool,
/// Path to directory to save output file
#[structopt(short, long, default_value = ".")]
output: String,
},
}
#[derive(Debug, StructOpt)]
pub enum UpdateSubcommands {
/// Update the data struct on a NFT
#[structopt(name = "data")]
Data {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Mint account of corresponding metadata to update
#[structopt(short, long)]
account: String,
/// Path to JSON file containing new data
#[structopt(short, long)]
new_data_file: String,
},
/// Update the data struct on a list of NFTs
#[structopt(name = "data-all")]
DataAll {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Path to directory containing JSON files with new data
#[structopt(short, long)]
data_dir: String,
},
/// Update the metadata URI, keeping the rest of the data the same
#[structopt(name = "uri")]
Uri {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// Mint account of corresponding metadata to update
#[structopt(short, long)]
account: String,
/// New uri
#[structopt(short = "u", long)]
new_uri: String,
},
/// Update the metadata URI on a list of mint accounts
#[structopt(name = "uri-all")]
UriAll {
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
/// JSON file with list of mint accounts and new URIs
#[structopt(short = "u", long)]
json_file: String,
},
}
#[derive(Debug, StructOpt)]
pub enum WithdrawSubcommands {
/// Withdraw funds from a candy machine v2
#[structopt(name = "cm-v2")]
CMV2 {
/// Candy Machine V2 ID
candy_machine_id: String,
/// Path to the creator's keypair file
#[structopt(short, long)]
keypair: String,
},
}