11use {
2- crate :: {
3- instructions:: { ExtensionDiscriminator , MAX_MULTISIG_SIGNERS } ,
4- UNINIT_ACCOUNT_REF , UNINIT_INSTRUCTION_ACCOUNT ,
5- } ,
6- core:: slice:: from_raw_parts,
2+ crate :: instructions:: { ExtensionDiscriminator , MAX_MULTISIG_SIGNERS } ,
3+ core:: { mem:: MaybeUninit , slice:: from_raw_parts} ,
74 solana_account_view:: AccountView ,
85 solana_address:: Address ,
96 solana_instruction_view:: {
@@ -34,7 +31,7 @@ pub struct SetTransferFee<'a, 'b, 'c> {
3431 pub authority : & ' a AccountView ,
3532
3633 /// Multisignature owner/delegate.
37- pub signers : & ' c [ & ' a AccountView ] ,
34+ pub multisig_signers : & ' c [ & ' a AccountView ] ,
3835
3936 /// Amount of transfer collected as fees, expressed as basis points of
4037 /// the transfer amount
@@ -60,7 +57,7 @@ impl<'a, 'b, 'c> SetTransferFee<'a, 'b, 'c> {
6057 transfer_fee_basis_points : u16 ,
6158 maximum_fee : u64 ,
6259 ) -> Self {
63- Self :: with_signers (
60+ Self :: with_multisig_signers (
6461 token_program,
6562 mint,
6663 authority,
@@ -73,18 +70,18 @@ impl<'a, 'b, 'c> SetTransferFee<'a, 'b, 'c> {
7370 /// Creates a new `SetTransferFee` instruction with a multisignature
7471 /// owner/delegate authority and signer accounts.
7572 #[ inline( always) ]
76- pub fn with_signers (
73+ pub fn with_multisig_signers (
7774 token_program : & ' b Address ,
7875 mint : & ' a AccountView ,
7976 authority : & ' a AccountView ,
8077 transfer_fee_basis_points : u16 ,
8178 maximum_fee : u64 ,
82- signers : & ' c [ & ' a AccountView ] ,
79+ multisig_signers : & ' c [ & ' a AccountView ] ,
8380 ) -> Self {
8481 Self {
8582 mint,
8683 authority,
87- signers ,
84+ multisig_signers ,
8885 transfer_fee_basis_points,
8986 maximum_fee,
9087 token_program,
@@ -98,56 +95,43 @@ impl<'a, 'b, 'c> SetTransferFee<'a, 'b, 'c> {
9895
9996 #[ inline( always) ]
10097 pub fn invoke_signed ( & self , signers : & [ Signer ] ) -> ProgramResult {
101- if self . signers . len ( ) > MAX_MULTISIG_SIGNERS {
98+ if self . multisig_signers . len ( ) > MAX_MULTISIG_SIGNERS {
10299 return Err ( ProgramError :: InvalidArgument ) ;
103100 }
104101
105- let expected_accounts = 2 + self . signers . len ( ) ;
102+ let expected_accounts = 2 + self . multisig_signers . len ( ) ;
106103
107104 // Instruction accounts.
108105
109- let mut instruction_accounts = [ UNINIT_INSTRUCTION_ACCOUNT ; 2 + MAX_MULTISIG_SIGNERS ] ;
110-
111- // SAFETY: The allocation is valid to the maximum number of accounts.
112- unsafe {
113- instruction_accounts
114- . get_unchecked_mut ( 0 )
115- . write ( InstructionAccount :: writable ( self . mint . address ( ) ) ) ;
116-
117- instruction_accounts
118- . get_unchecked_mut ( 1 )
119- . write ( InstructionAccount :: new (
120- self . authority . address ( ) ,
121- false ,
122- self . signers . is_empty ( ) ,
123- ) ) ;
124-
125- for ( instruction_account, signer) in instruction_accounts
126- . get_unchecked_mut ( 2 ..)
127- . iter_mut ( )
128- . zip ( self . signers . iter ( ) )
129- {
130- instruction_account. write ( InstructionAccount :: readonly_signer ( signer. address ( ) ) ) ;
131- }
106+ let mut instruction_accounts =
107+ [ const { MaybeUninit :: < InstructionAccount > :: uninit ( ) } ; 2 + MAX_MULTISIG_SIGNERS ] ;
108+
109+ instruction_accounts[ 0 ] . write ( InstructionAccount :: writable ( self . mint . address ( ) ) ) ;
110+
111+ instruction_accounts[ 1 ] . write ( InstructionAccount :: new (
112+ self . authority . address ( ) ,
113+ false ,
114+ self . multisig_signers . is_empty ( ) ,
115+ ) ) ;
116+
117+ for ( instruction_account, signer) in instruction_accounts[ 2 ..]
118+ . iter_mut ( )
119+ . zip ( self . multisig_signers . iter ( ) )
120+ {
121+ instruction_account. write ( InstructionAccount :: readonly_signer ( signer. address ( ) ) ) ;
132122 }
133123
134124 // Accounts.
135125
136- let mut accounts = [ UNINIT_ACCOUNT_REF ; 2 + MAX_MULTISIG_SIGNERS ] ;
126+ let mut accounts =
127+ [ const { MaybeUninit :: < & AccountView > :: uninit ( ) } ; 2 + MAX_MULTISIG_SIGNERS ] ;
137128
138- // SAFETY: The allocation is valid to the maximum number of accounts.
139- unsafe {
140- accounts. get_unchecked_mut ( 0 ) . write ( self . mint ) ;
129+ accounts[ 0 ] . write ( self . mint ) ;
141130
142- accounts. get_unchecked_mut ( 1 ) . write ( self . authority ) ;
131+ accounts[ 1 ] . write ( self . authority ) ;
143132
144- for ( account, signer) in accounts
145- . get_unchecked_mut ( 2 ..)
146- . iter_mut ( )
147- . zip ( self . signers . iter ( ) )
148- {
149- account. write ( * signer) ;
150- }
133+ for ( account, signer) in accounts[ 2 ..] . iter_mut ( ) . zip ( self . multisig_signers . iter ( ) ) {
134+ account. write ( * signer) ;
151135 }
152136
153137 invoke_signed_with_bounds :: < { 2 + MAX_MULTISIG_SIGNERS } > (
0 commit comments