From 2491b29a1e9e1e815b14e2a8a196ae59609bbf74 Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 26 Apr 2022 09:55:15 -0400 Subject: [PATCH] Add AuthorityType variant to use for mint close-authority adjustment (#3111) --- token/program-2022-test/tests/mint_close_authority.rs | 10 +++++----- token/program-2022/src/instruction.rs | 6 +++++- token/program-2022/src/processor.rs | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/token/program-2022-test/tests/mint_close_authority.rs b/token/program-2022-test/tests/mint_close_authority.rs index 19966736..e9b02b79 100644 --- a/token/program-2022-test/tests/mint_close_authority.rs +++ b/token/program-2022-test/tests/mint_close_authority.rs @@ -67,7 +67,7 @@ async fn set_authority() { .set_authority( token.get_address(), Some(&new_authority.pubkey()), - instruction::AuthorityType::CloseAccount, + instruction::AuthorityType::CloseMint, &wrong, ) .await @@ -87,7 +87,7 @@ async fn set_authority() { .set_authority( token.get_address(), Some(&new_authority.pubkey()), - instruction::AuthorityType::CloseAccount, + instruction::AuthorityType::CloseMint, &close_authority, ) .await @@ -104,7 +104,7 @@ async fn set_authority() { .set_authority( token.get_address(), None, - instruction::AuthorityType::CloseAccount, + instruction::AuthorityType::CloseMint, &new_authority, ) .await @@ -118,7 +118,7 @@ async fn set_authority() { .set_authority( token.get_address(), Some(&close_authority.pubkey()), - instruction::AuthorityType::CloseAccount, + instruction::AuthorityType::CloseMint, &new_authority, ) .await @@ -187,7 +187,7 @@ async fn fail_without_extension() { .set_authority( token.get_address(), Some(&close_authority), - instruction::AuthorityType::CloseAccount, + instruction::AuthorityType::CloseMint, &mint_authority, ) .await diff --git a/token/program-2022/src/instruction.rs b/token/program-2022/src/instruction.rs index 2fd2e973..07e9bd44 100644 --- a/token/program-2022/src/instruction.rs +++ b/token/program-2022/src/instruction.rs @@ -915,12 +915,14 @@ pub enum AuthorityType { FreezeAccount, /// Owner of a given token account AccountOwner, - /// Authority to close a mint or token account + /// Authority to close a token account CloseAccount, /// Authority to set the transfer fee TransferFeeConfig, /// Authority to withdraw withheld tokens from a mint WithheldWithdraw, + /// Authority to close a mint account + CloseMint, } impl AuthorityType { @@ -932,6 +934,7 @@ impl AuthorityType { AuthorityType::CloseAccount => 3, AuthorityType::TransferFeeConfig => 4, AuthorityType::WithheldWithdraw => 5, + AuthorityType::CloseMint => 6, } } @@ -943,6 +946,7 @@ impl AuthorityType { 3 => Ok(AuthorityType::CloseAccount), 4 => Ok(AuthorityType::TransferFeeConfig), 5 => Ok(AuthorityType::WithheldWithdraw), + 6 => Ok(AuthorityType::CloseMint), _ => Err(TokenError::InvalidInstruction.into()), } } diff --git a/token/program-2022/src/processor.rs b/token/program-2022/src/processor.rs index 6b87f59f..8de78f80 100644 --- a/token/program-2022/src/processor.rs +++ b/token/program-2022/src/processor.rs @@ -610,7 +610,7 @@ impl Processor { mint.base.freeze_authority = new_authority; mint.pack_base(); } - AuthorityType::CloseAccount => { + AuthorityType::CloseMint => { let extension = mint.get_extension_mut::()?; let maybe_close_authority: Option = extension.close_authority.into(); let close_authority =