Ver código fonte

chore: small opt fn set_authority (#3675)

nk_ysg 3 meses atrás
pai
commit
73fc4835e0
2 arquivos alterados com 2 adições e 12 exclusões
  1. 1 6
      spl/src/token.rs
  2. 1 6
      spl/src/token_2022.rs

+ 1 - 6
spl/src/token.rs

@@ -304,15 +304,10 @@ pub fn set_authority<'info>(
     authority_type: spl_token::instruction::AuthorityType,
     new_authority: Option<Pubkey>,
 ) -> Result<()> {
-    let mut spl_new_authority: Option<&Pubkey> = None;
-    if new_authority.is_some() {
-        spl_new_authority = new_authority.as_ref()
-    }
-
     let ix = spl_token::instruction::set_authority(
         &spl_token::ID,
         ctx.accounts.account_or_mint.key,
-        spl_new_authority,
+        new_authority.as_ref(),
         authority_type,
         ctx.accounts.current_authority.key,
         &[], // TODO: Support multisig signers.

+ 1 - 6
spl/src/token_2022.rs

@@ -341,15 +341,10 @@ pub fn set_authority<'info>(
     authority_type: spl_token_2022::instruction::AuthorityType,
     new_authority: Option<Pubkey>,
 ) -> Result<()> {
-    let mut spl_new_authority: Option<&Pubkey> = None;
-    if new_authority.is_some() {
-        spl_new_authority = new_authority.as_ref()
-    }
-
     let ix = spl_token_2022::instruction::set_authority(
         ctx.program.key,
         ctx.accounts.account_or_mint.key,
-        spl_new_authority,
+        new_authority.as_ref(),
         authority_type,
         ctx.accounts.current_authority.key,
         &[], // TODO: Support multisig signers.