瀏覽代碼

chore: small opt fn set_authority (#3675)

nk_ysg 3 月之前
父節點
當前提交
73fc4835e0
共有 2 個文件被更改,包括 2 次插入12 次删除
  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.