1
1
use crate :: { config:: Config , sort:: UnsupportedAccount } ;
2
2
use console:: Emoji ;
3
3
use serde:: { Deserialize , Serialize , Serializer } ;
4
- use solana_account_decoder:: parse_token:: {
5
- UiAccountState , UiMint , UiMultisig , UiTokenAccount , UiTokenAmount ,
4
+ use solana_account_decoder:: {
5
+ parse_token:: { UiAccountState , UiMint , UiMultisig , UiTokenAccount , UiTokenAmount } ,
6
+ parse_token_extension:: { UiExtension , UiMintCloseAuthority } ,
6
7
} ;
7
8
use solana_cli_output:: { display:: writeln_name_value, OutputFormat , QuietDisplay , VerboseDisplay } ;
8
9
use std:: fmt:: { self , Display } ;
@@ -162,15 +163,16 @@ impl fmt::Display for CliMultisig {
162
163
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
163
164
let m = self . multisig . num_required_signers ;
164
165
let n = self . multisig . num_valid_signers ;
166
+
165
167
writeln ! ( f) ?;
166
- writeln_name_value ( f, "Type: " , "Multisig " ) ?;
167
- writeln_name_value ( f, "Address:" , & self . address ) ?;
168
- writeln_name_value ( f, "Program:" , & self . program_id ) ?;
169
- writeln_name_value ( f, "M/N:" , & format ! ( "{}/{}" , m, n) ) ?;
170
- writeln_name_value ( f, "Signers:" , " " ) ?;
168
+ writeln_name_value ( f, "SPL Token Multisig " , " " ) ?;
169
+ writeln_name_value ( f, " Address:" , & self . address ) ?;
170
+ writeln_name_value ( f, " Program:" , & self . program_id ) ?;
171
+ writeln_name_value ( f, " M/N:" , & format ! ( "{}/{}" , m, n) ) ?;
172
+ writeln_name_value ( f, " Signers:" , " " ) ?;
171
173
let width = if n >= 9 { 4 } else { 3 } ;
172
174
for i in 0 ..n as usize {
173
- let title = format ! ( "{1:>0$}:" , width, i + 1 ) ;
175
+ let title = format ! ( " {1:>0$}:" , width, i + 1 ) ;
174
176
let pubkey = & self . multisig . signers [ i] ;
175
177
writeln_name_value ( f, & title, pubkey) ?;
176
178
}
@@ -195,21 +197,21 @@ impl VerboseDisplay for CliTokenAccount {}
195
197
impl fmt:: Display for CliTokenAccount {
196
198
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
197
199
writeln ! ( f) ?;
198
- writeln_name_value ( f, "Type: " , "Account " ) ?;
200
+ writeln_name_value ( f, "SPL Token Account " , " " ) ?;
199
201
if self . is_associated {
200
- writeln_name_value ( f, "Address:" , & self . address ) ?;
202
+ writeln_name_value ( f, " Address:" , & self . address ) ?;
201
203
} else {
202
- writeln_name_value ( f, "Address:" , & format ! ( "{} (Aux*)" , self . address) ) ?;
204
+ writeln_name_value ( f, " Address:" , & format ! ( "{} (Aux*)" , self . address) ) ?;
203
205
}
204
- writeln_name_value ( f, "Program:" , & self . program_id ) ?;
206
+ writeln_name_value ( f, " Program:" , & self . program_id ) ?;
205
207
writeln_name_value (
206
208
f,
207
- "Balance:" ,
209
+ " Balance:" ,
208
210
& self . account . token_amount . real_number_string_trimmed ( ) ,
209
211
) ?;
210
212
writeln_name_value (
211
213
f,
212
- "Decimals:" ,
214
+ " Decimals:" ,
213
215
if self . decimals . is_some ( ) {
214
216
self . decimals . unwrap ( ) . to_string ( )
215
217
} else {
@@ -226,29 +228,38 @@ impl fmt::Display for CliTokenAccount {
226
228
""
227
229
}
228
230
) ;
229
- writeln_name_value ( f, "Mint:" , & mint) ?;
230
- writeln_name_value ( f, "Owner:" , & self . account . owner ) ?;
231
- writeln_name_value ( f, "State:" , & format ! ( "{:?}" , self . account. state) ) ?;
231
+ writeln_name_value ( f, " Mint:" , & mint) ?;
232
+ writeln_name_value ( f, " Owner:" , & self . account . owner ) ?;
233
+ writeln_name_value ( f, " State:" , & format ! ( "{:?}" , self . account. state) ) ?;
232
234
if let Some ( delegate) = & self . account . delegate {
233
- writeln ! ( f, "Delegation:" ) ?;
234
- writeln_name_value ( f, " Delegate:" , delegate) ?;
235
+ writeln ! ( f, " Delegation:" ) ?;
236
+ writeln_name_value ( f, " Delegate:" , delegate) ?;
235
237
let allowance = self . account . delegated_amount . as_ref ( ) . unwrap ( ) ;
236
- writeln_name_value ( f, " Allowance:" , & allowance. real_number_string_trimmed ( ) ) ?;
238
+ writeln_name_value ( f, " Allowance:" , & allowance. real_number_string_trimmed ( ) ) ?;
237
239
} else {
238
- writeln_name_value ( f, "Delegation:" , "" ) ?;
240
+ writeln_name_value ( f, " Delegation:" , "" ) ?;
239
241
}
240
242
writeln_name_value (
241
243
f,
242
- "Close authority:" ,
244
+ " Close authority:" ,
243
245
self . account
244
246
. close_authority
245
247
. as_ref ( )
246
248
. unwrap_or ( & String :: new ( ) ) ,
247
249
) ?;
250
+
251
+ if !self . account . extensions . is_empty ( ) {
252
+ writeln_name_value ( f, "Extensions" , " " ) ?;
253
+ for extension in & self . account . extensions {
254
+ display_ui_extension ( f, extension) ?;
255
+ }
256
+ }
257
+
248
258
if !self . is_associated {
249
259
writeln ! ( f) ?;
250
260
writeln ! ( f, "* Please run `spl-token gc` to clean up Aux accounts" ) ?;
251
261
}
262
+
252
263
Ok ( ( ) )
253
264
}
254
265
}
@@ -268,24 +279,33 @@ impl VerboseDisplay for CliMint {}
268
279
impl fmt:: Display for CliMint {
269
280
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
270
281
writeln ! ( f) ?;
271
- writeln_name_value ( f, "Type:" , "Mint" ) ?;
272
- writeln_name_value ( f, "Address:" , & self . address ) ?;
273
- writeln_name_value ( f, "Program:" , & self . program_id ) ?;
274
- writeln_name_value ( f, "Supply:" , & self . mint . supply ) ?;
275
- writeln_name_value ( f, "Decimals:" , & self . mint . decimals . to_string ( ) ) ?;
282
+ writeln_name_value ( f, "SPL Token Mint" , " " ) ?;
283
+
284
+ writeln_name_value ( f, " Address:" , & self . address ) ?;
285
+ writeln_name_value ( f, " Program:" , & self . program_id ) ?;
286
+ writeln_name_value ( f, " Supply:" , & self . mint . supply ) ?;
287
+ writeln_name_value ( f, " Decimals:" , & self . mint . decimals . to_string ( ) ) ?;
276
288
writeln_name_value (
277
289
f,
278
- "Mint authority:" ,
290
+ " Mint authority:" ,
279
291
self . mint . mint_authority . as_ref ( ) . unwrap_or ( & String :: new ( ) ) ,
280
292
) ?;
281
293
writeln_name_value (
282
294
f,
283
- "Freeze authority:" ,
295
+ " Freeze authority:" ,
284
296
self . mint
285
297
. freeze_authority
286
298
. as_ref ( )
287
299
. unwrap_or ( & String :: new ( ) ) ,
288
300
) ?;
301
+
302
+ if !self . mint . extensions . is_empty ( ) {
303
+ writeln_name_value ( f, "Extensions" , " " ) ?;
304
+ for extension in & self . mint . extensions {
305
+ display_ui_extension ( f, extension) ?;
306
+ }
307
+ }
308
+
289
309
Ok ( ( ) )
290
310
}
291
311
}
@@ -456,6 +476,20 @@ impl fmt::Display for CliTokenAccounts {
456
476
}
457
477
}
458
478
479
+ fn display_ui_extension ( f : & mut fmt:: Formatter , ui_extension : & UiExtension ) -> fmt:: Result {
480
+ match ui_extension {
481
+ UiExtension :: MintCloseAuthority ( UiMintCloseAuthority { close_authority } ) => {
482
+ writeln_name_value (
483
+ f,
484
+ " Close authority:" ,
485
+ close_authority. as_ref ( ) . unwrap_or ( & String :: new ( ) ) ,
486
+ )
487
+ }
488
+ UiExtension :: ImmutableOwner => writeln_name_value ( f, " Immutable owner:" , "Enabled" ) ,
489
+ _ => unimplemented ! ( ) ,
490
+ }
491
+ }
492
+
459
493
fn flattened < S : Serializer > (
460
494
vec : & [ Vec < CliTokenAccount > ] ,
461
495
serializer : S ,
0 commit comments