File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed
extension/permissioned_burn
extension/permissioned_burn Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
33use {
44 crate :: extension:: { Extension , ExtensionType } ,
55 bytemuck:: { Pod , Zeroable } ,
6- solana_pubkey :: Pubkey ,
6+ spl_pod :: optional_keys :: OptionalNonZeroPubkey
77} ;
88
99/// Instruction types for the permissioned burn extension
@@ -16,7 +16,7 @@ pub mod instruction;
1616#[ repr( C ) ]
1717pub struct PermissionedBurnConfig {
1818 /// Authority that is required for burning
19- pub authority : Pubkey ,
19+ pub authority : OptionalNonZeroPubkey ,
2020}
2121
2222impl Extension for PermissionedBurnConfig {
Original file line number Diff line number Diff line change @@ -1160,6 +1160,8 @@ pub enum AuthorityType {
11601160 ScaledUiAmount ,
11611161 /// Authority to pause or resume minting / transferring / burning
11621162 Pause ,
1163+ /// Authority to perform a permissioned token burn
1164+ PermissionedBurn ,
11631165}
11641166
11651167impl AuthorityType {
@@ -1182,6 +1184,7 @@ impl AuthorityType {
11821184 AuthorityType :: GroupMemberPointer => 14 ,
11831185 AuthorityType :: ScaledUiAmount => 15 ,
11841186 AuthorityType :: Pause => 16 ,
1187+ AuthorityType :: PermissionedBurn => 17 ,
11851188 }
11861189 }
11871190
@@ -1205,6 +1208,7 @@ impl AuthorityType {
12051208 14 => Ok ( AuthorityType :: GroupMemberPointer ) ,
12061209 15 => Ok ( AuthorityType :: ScaledUiAmount ) ,
12071210 16 => Ok ( AuthorityType :: Pause ) ,
1211+ 17 => Ok ( AuthorityType :: PermissionedBurn ) ,
12081212 _ => Err ( TokenError :: InvalidInstruction . into ( ) ) ,
12091213 }
12101214 }
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ fn process_initialize(
2828 let mut mint = PodStateWithExtensionsMut :: < PodMint > :: unpack_uninitialized ( & mut mint_data) ?;
2929
3030 let extension = mint. init_extension :: < PermissionedBurnConfig > ( true ) ?;
31- extension. authority = * authority;
31+ extension. authority = Some ( * authority) . try_into ( ) ? ;
3232
3333 Ok ( ( ) )
3434}
Original file line number Diff line number Diff line change @@ -967,6 +967,19 @@ impl Processor {
967967 ) ?;
968968 extension. authority = new_authority. try_into ( ) ?;
969969 }
970+ AuthorityType :: PermissionedBurn => {
971+ let extension = mint. get_extension_mut :: < PermissionedBurnConfig > ( ) ?;
972+ let maybe_authority: Option < Pubkey > = extension. authority . into ( ) ;
973+ let authority = maybe_authority. ok_or ( TokenError :: AuthorityTypeNotSupported ) ?;
974+ Self :: validate_owner (
975+ program_id,
976+ & authority,
977+ authority_info,
978+ authority_info_data_len,
979+ account_info_iter. as_slice ( ) ,
980+ ) ?;
981+ extension. authority = new_authority. try_into ( ) ?;
982+ }
970983 _ => {
971984 return Err ( TokenError :: AuthorityTypeNotSupported . into ( ) ) ;
972985 }
@@ -1118,7 +1131,8 @@ impl Processor {
11181131 return Err ( ProgramError :: MissingRequiredSignature ) ;
11191132 }
11201133
1121- if * approver_ai. key != ext. authority {
1134+ let maybe_burn_authority: Option < Pubkey > = ext. authority . into ( ) ;
1135+ if Some ( * approver_ai. key ) != maybe_burn_authority {
11221136 return Err ( ProgramError :: InvalidAccountData ) ;
11231137 }
11241138 }
You can’t perform that action at this time.
0 commit comments