6
6
solana_program:: pubkey:: Pubkey ,
7
7
solana_zk_token_sdk:: zk_token_elgamal:: pod:: ElGamalPubkey ,
8
8
} ,
9
+ spl_token_metadata_interface:: state:: TokenMetadata ,
9
10
} ;
10
11
11
12
#[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
@@ -24,15 +25,21 @@ pub enum UiExtension {
24
25
InterestBearingConfig ( UiInterestBearingConfig ) ,
25
26
CpiGuard ( UiCpiGuard ) ,
26
27
PermanentDelegate ( UiPermanentDelegate ) ,
27
- UnparseableExtension ,
28
28
NonTransferableAccount ,
29
+ ConfidentialTransferFeeConfig ( UiConfidentialTransferFeeConfig ) ,
30
+ ConfidentialTransferFeeAmount ( UiConfidentialTransferFeeAmount ) ,
31
+ TransferHook ( UiTransferHook ) ,
32
+ TransferHookAccount ( UiTransferHookAccount ) ,
33
+ MetadataPointer ( UiMetadataPointer ) ,
34
+ TokenMetadata ( UiTokenMetadata ) ,
35
+ UnparseableExtension ,
29
36
}
30
37
31
38
pub fn parse_extension < S : BaseState > (
32
39
extension_type : & ExtensionType ,
33
40
account : & StateWithExtensions < S > ,
34
41
) -> UiExtension {
35
- match & extension_type {
42
+ match extension_type {
36
43
ExtensionType :: Uninitialized => UiExtension :: Uninitialized ,
37
44
ExtensionType :: TransferFeeConfig => account
38
45
. get_extension :: < extension:: transfer_fee:: TransferFeeConfig > ( )
@@ -50,10 +57,18 @@ pub fn parse_extension<S: BaseState>(
50
57
. get_extension :: < extension:: confidential_transfer:: ConfidentialTransferMint > ( )
51
58
. map ( |& extension| UiExtension :: ConfidentialTransferMint ( extension. into ( ) ) )
52
59
. unwrap_or ( UiExtension :: UnparseableExtension ) ,
60
+ ExtensionType :: ConfidentialTransferFeeConfig => account
61
+ . get_extension :: < extension:: confidential_transfer_fee:: ConfidentialTransferFeeConfig > ( )
62
+ . map ( |& extension| UiExtension :: ConfidentialTransferFeeConfig ( extension. into ( ) ) )
63
+ . unwrap_or ( UiExtension :: UnparseableExtension ) ,
53
64
ExtensionType :: ConfidentialTransferAccount => account
54
65
. get_extension :: < extension:: confidential_transfer:: ConfidentialTransferAccount > ( )
55
66
. map ( |& extension| UiExtension :: ConfidentialTransferAccount ( extension. into ( ) ) )
56
67
. unwrap_or ( UiExtension :: UnparseableExtension ) ,
68
+ ExtensionType :: ConfidentialTransferFeeAmount => account
69
+ . get_extension :: < extension:: confidential_transfer_fee:: ConfidentialTransferFeeAmount > ( )
70
+ . map ( |& extension| UiExtension :: ConfidentialTransferFeeAmount ( extension. into ( ) ) )
71
+ . unwrap_or ( UiExtension :: UnparseableExtension ) ,
57
72
ExtensionType :: DefaultAccountState => account
58
73
. get_extension :: < extension:: default_account_state:: DefaultAccountState > ( )
59
74
. map ( |& extension| UiExtension :: DefaultAccountState ( extension. into ( ) ) )
@@ -77,6 +92,22 @@ pub fn parse_extension<S: BaseState>(
77
92
. map ( |& extension| UiExtension :: PermanentDelegate ( extension. into ( ) ) )
78
93
. unwrap_or ( UiExtension :: UnparseableExtension ) ,
79
94
ExtensionType :: NonTransferableAccount => UiExtension :: NonTransferableAccount ,
95
+ ExtensionType :: MetadataPointer => account
96
+ . get_extension :: < extension:: metadata_pointer:: MetadataPointer > ( )
97
+ . map ( |& extension| UiExtension :: MetadataPointer ( extension. into ( ) ) )
98
+ . unwrap_or ( UiExtension :: UnparseableExtension ) ,
99
+ ExtensionType :: TokenMetadata => account
100
+ . get_variable_len_extension :: < TokenMetadata > ( )
101
+ . map ( |extension| UiExtension :: TokenMetadata ( extension. into ( ) ) )
102
+ . unwrap_or ( UiExtension :: UnparseableExtension ) ,
103
+ ExtensionType :: TransferHook => account
104
+ . get_extension :: < extension:: transfer_hook:: TransferHook > ( )
105
+ . map ( |& extension| UiExtension :: TransferHook ( extension. into ( ) ) )
106
+ . unwrap_or ( UiExtension :: UnparseableExtension ) ,
107
+ ExtensionType :: TransferHookAccount => account
108
+ . get_extension :: < extension:: transfer_hook:: TransferHookAccount > ( )
109
+ . map ( |& extension| UiExtension :: TransferHookAccount ( extension. into ( ) ) )
110
+ . unwrap_or ( UiExtension :: UnparseableExtension ) ,
80
111
}
81
112
}
82
113
@@ -251,9 +282,7 @@ impl From<extension::permanent_delegate::PermanentDelegate> for UiPermanentDeleg
251
282
pub struct UiConfidentialTransferMint {
252
283
pub authority : Option < String > ,
253
284
pub auto_approve_new_accounts : bool ,
254
- pub auditor_encryption_pubkey : Option < String > ,
255
- pub withdraw_withheld_authority_encryption_pubkey : Option < String > ,
256
- pub withheld_amount : String ,
285
+ pub auditor_elgamal_pubkey : Option < String > ,
257
286
}
258
287
259
288
impl From < extension:: confidential_transfer:: ConfidentialTransferMint >
@@ -263,19 +292,44 @@ impl From<extension::confidential_transfer::ConfidentialTransferMint>
263
292
confidential_transfer_mint : extension:: confidential_transfer:: ConfidentialTransferMint ,
264
293
) -> Self {
265
294
let authority: Option < Pubkey > = confidential_transfer_mint. authority . into ( ) ;
266
- let auditor_encryption_pubkey: Option < ElGamalPubkey > =
267
- confidential_transfer_mint. auditor_encryption_pubkey . into ( ) ;
268
- let withdraw_withheld_authority_encryption_pubkey: Option < ElGamalPubkey > =
269
- confidential_transfer_mint
270
- . withdraw_withheld_authority_encryption_pubkey
271
- . into ( ) ;
295
+ let auditor_elgamal_pubkey: Option < ElGamalPubkey > =
296
+ confidential_transfer_mint. auditor_elgamal_pubkey . into ( ) ;
272
297
Self {
273
298
authority : authority. map ( |pubkey| pubkey. to_string ( ) ) ,
274
299
auto_approve_new_accounts : confidential_transfer_mint. auto_approve_new_accounts . into ( ) ,
275
- auditor_encryption_pubkey : auditor_encryption_pubkey. map ( |pubkey| pubkey. to_string ( ) ) ,
276
- withdraw_withheld_authority_encryption_pubkey :
277
- withdraw_withheld_authority_encryption_pubkey. map ( |pubkey| pubkey. to_string ( ) ) ,
278
- withheld_amount : format ! ( "{}" , confidential_transfer_mint. withheld_amount) ,
300
+ auditor_elgamal_pubkey : auditor_elgamal_pubkey. map ( |pubkey| pubkey. to_string ( ) ) ,
301
+ }
302
+ }
303
+ }
304
+
305
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
306
+ #[ serde( rename_all = "camelCase" ) ]
307
+ pub struct UiConfidentialTransferFeeConfig {
308
+ pub authority : Option < String > ,
309
+ pub withdraw_withheld_authority_elgamal_pubkey : Option < String > ,
310
+ pub harvest_to_mint_enabled : bool ,
311
+ pub withheld_amount : String ,
312
+ }
313
+
314
+ impl From < extension:: confidential_transfer_fee:: ConfidentialTransferFeeConfig >
315
+ for UiConfidentialTransferFeeConfig
316
+ {
317
+ fn from (
318
+ confidential_transfer_fee_config : extension:: confidential_transfer_fee:: ConfidentialTransferFeeConfig ,
319
+ ) -> Self {
320
+ let authority: Option < Pubkey > = confidential_transfer_fee_config. authority . into ( ) ;
321
+ let withdraw_withheld_authority_elgamal_pubkey: Option < ElGamalPubkey > =
322
+ confidential_transfer_fee_config
323
+ . withdraw_withheld_authority_elgamal_pubkey
324
+ . into ( ) ;
325
+ Self {
326
+ authority : authority. map ( |pubkey| pubkey. to_string ( ) ) ,
327
+ withdraw_withheld_authority_elgamal_pubkey : withdraw_withheld_authority_elgamal_pubkey
328
+ . map ( |pubkey| pubkey. to_string ( ) ) ,
329
+ harvest_to_mint_enabled : confidential_transfer_fee_config
330
+ . harvest_to_mint_enabled
331
+ . into ( ) ,
332
+ withheld_amount : format ! ( "{}" , confidential_transfer_fee_config. withheld_amount) ,
279
333
}
280
334
}
281
335
}
@@ -284,7 +338,7 @@ impl From<extension::confidential_transfer::ConfidentialTransferMint>
284
338
#[ serde( rename_all = "camelCase" ) ]
285
339
pub struct UiConfidentialTransferAccount {
286
340
pub approved : bool ,
287
- pub encryption_pubkey : String ,
341
+ pub elgamal_pubkey : String ,
288
342
pub pending_balance_lo : String ,
289
343
pub pending_balance_hi : String ,
290
344
pub available_balance : String ,
@@ -295,7 +349,6 @@ pub struct UiConfidentialTransferAccount {
295
349
pub maximum_pending_balance_credit_counter : u64 ,
296
350
pub expected_pending_balance_credit_counter : u64 ,
297
351
pub actual_pending_balance_credit_counter : u64 ,
298
- pub withheld_amount : String ,
299
352
}
300
353
301
354
impl From < extension:: confidential_transfer:: ConfidentialTransferAccount >
@@ -306,7 +359,7 @@ impl From<extension::confidential_transfer::ConfidentialTransferAccount>
306
359
) -> Self {
307
360
Self {
308
361
approved : confidential_transfer_account. approved . into ( ) ,
309
- encryption_pubkey : format ! ( "{}" , confidential_transfer_account. encryption_pubkey ) ,
362
+ elgamal_pubkey : format ! ( "{}" , confidential_transfer_account. elgamal_pubkey ) ,
310
363
pending_balance_lo : format ! ( "{}" , confidential_transfer_account. pending_balance_lo) ,
311
364
pending_balance_hi : format ! ( "{}" , confidential_transfer_account. pending_balance_hi) ,
312
365
available_balance : format ! ( "{}" , confidential_transfer_account. available_balance) ,
@@ -332,7 +385,99 @@ impl From<extension::confidential_transfer::ConfidentialTransferAccount>
332
385
actual_pending_balance_credit_counter : confidential_transfer_account
333
386
. actual_pending_balance_credit_counter
334
387
. into ( ) ,
335
- withheld_amount : format ! ( "{}" , confidential_transfer_account. withheld_amount) ,
388
+ }
389
+ }
390
+ }
391
+
392
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
393
+ #[ serde( rename_all = "camelCase" ) ]
394
+ pub struct UiConfidentialTransferFeeAmount {
395
+ pub withheld_amount : String ,
396
+ }
397
+
398
+ impl From < extension:: confidential_transfer_fee:: ConfidentialTransferFeeAmount >
399
+ for UiConfidentialTransferFeeAmount
400
+ {
401
+ fn from (
402
+ confidential_transfer_fee_amount : extension:: confidential_transfer_fee:: ConfidentialTransferFeeAmount ,
403
+ ) -> Self {
404
+ Self {
405
+ withheld_amount : format ! ( "{}" , confidential_transfer_fee_amount. withheld_amount) ,
406
+ }
407
+ }
408
+ }
409
+
410
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
411
+ #[ serde( rename_all = "camelCase" ) ]
412
+ pub struct UiMetadataPointer {
413
+ pub authority : Option < String > ,
414
+ pub metadata_address : Option < String > ,
415
+ }
416
+
417
+ impl From < extension:: metadata_pointer:: MetadataPointer > for UiMetadataPointer {
418
+ fn from ( metadata_pointer : extension:: metadata_pointer:: MetadataPointer ) -> Self {
419
+ let authority: Option < Pubkey > = metadata_pointer. authority . into ( ) ;
420
+ let metadata_address: Option < Pubkey > = metadata_pointer. metadata_address . into ( ) ;
421
+ Self {
422
+ authority : authority. map ( |pubkey| pubkey. to_string ( ) ) ,
423
+ metadata_address : metadata_address. map ( |pubkey| pubkey. to_string ( ) ) ,
424
+ }
425
+ }
426
+ }
427
+
428
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
429
+ #[ serde( rename_all = "camelCase" ) ]
430
+ pub struct UiTokenMetadata {
431
+ pub update_authority : Option < String > ,
432
+ pub mint : String ,
433
+ pub name : String ,
434
+ pub symbol : String ,
435
+ pub uri : String ,
436
+ pub additional_metadata : Vec < ( String , String ) > ,
437
+ }
438
+
439
+ impl From < TokenMetadata > for UiTokenMetadata {
440
+ fn from ( token_metadata : TokenMetadata ) -> Self {
441
+ let update_authority: Option < Pubkey > = token_metadata. update_authority . into ( ) ;
442
+ Self {
443
+ update_authority : update_authority. map ( |pubkey| pubkey. to_string ( ) ) ,
444
+ mint : token_metadata. mint . to_string ( ) ,
445
+ name : token_metadata. name ,
446
+ symbol : token_metadata. symbol ,
447
+ uri : token_metadata. uri ,
448
+ additional_metadata : token_metadata. additional_metadata ,
449
+ }
450
+ }
451
+ }
452
+
453
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
454
+ #[ serde( rename_all = "camelCase" ) ]
455
+ pub struct UiTransferHook {
456
+ pub authority : Option < String > ,
457
+ pub program_id : Option < String > ,
458
+ }
459
+
460
+ impl From < extension:: transfer_hook:: TransferHook > for UiTransferHook {
461
+ fn from ( transfer_hook : extension:: transfer_hook:: TransferHook ) -> Self {
462
+ let authority: Option < Pubkey > = transfer_hook. authority . into ( ) ;
463
+ let program_id: Option < Pubkey > = transfer_hook. program_id . into ( ) ;
464
+ Self {
465
+ authority : authority. map ( |pubkey| pubkey. to_string ( ) ) ,
466
+ program_id : program_id. map ( |pubkey| pubkey. to_string ( ) ) ,
467
+ }
468
+ }
469
+ }
470
+
471
+ #[ derive( Debug , Serialize , Deserialize , PartialEq , Eq ) ]
472
+ #[ serde( rename_all = "camelCase" ) ]
473
+ pub struct UiTransferHookAccount {
474
+ pub transferring : bool ,
475
+ }
476
+
477
+ impl From < extension:: transfer_hook:: TransferHookAccount > for UiTransferHookAccount {
478
+ fn from ( transfer_hook : extension:: transfer_hook:: TransferHookAccount ) -> Self {
479
+ Self {
480
+ transferring : transfer_hook. transferring . into ( ) ,
336
481
}
337
482
}
338
483
}
0 commit comments