Add AuthorityType variant to use for mint close-authority adjustment (#3111)
This commit is contained in:
parent
c616db83c4
commit
2491b29a1e
|
@ -67,7 +67,7 @@ async fn set_authority() {
|
||||||
.set_authority(
|
.set_authority(
|
||||||
token.get_address(),
|
token.get_address(),
|
||||||
Some(&new_authority.pubkey()),
|
Some(&new_authority.pubkey()),
|
||||||
instruction::AuthorityType::CloseAccount,
|
instruction::AuthorityType::CloseMint,
|
||||||
&wrong,
|
&wrong,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -87,7 +87,7 @@ async fn set_authority() {
|
||||||
.set_authority(
|
.set_authority(
|
||||||
token.get_address(),
|
token.get_address(),
|
||||||
Some(&new_authority.pubkey()),
|
Some(&new_authority.pubkey()),
|
||||||
instruction::AuthorityType::CloseAccount,
|
instruction::AuthorityType::CloseMint,
|
||||||
&close_authority,
|
&close_authority,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -104,7 +104,7 @@ async fn set_authority() {
|
||||||
.set_authority(
|
.set_authority(
|
||||||
token.get_address(),
|
token.get_address(),
|
||||||
None,
|
None,
|
||||||
instruction::AuthorityType::CloseAccount,
|
instruction::AuthorityType::CloseMint,
|
||||||
&new_authority,
|
&new_authority,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -118,7 +118,7 @@ async fn set_authority() {
|
||||||
.set_authority(
|
.set_authority(
|
||||||
token.get_address(),
|
token.get_address(),
|
||||||
Some(&close_authority.pubkey()),
|
Some(&close_authority.pubkey()),
|
||||||
instruction::AuthorityType::CloseAccount,
|
instruction::AuthorityType::CloseMint,
|
||||||
&new_authority,
|
&new_authority,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -187,7 +187,7 @@ async fn fail_without_extension() {
|
||||||
.set_authority(
|
.set_authority(
|
||||||
token.get_address(),
|
token.get_address(),
|
||||||
Some(&close_authority),
|
Some(&close_authority),
|
||||||
instruction::AuthorityType::CloseAccount,
|
instruction::AuthorityType::CloseMint,
|
||||||
&mint_authority,
|
&mint_authority,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -915,12 +915,14 @@ pub enum AuthorityType {
|
||||||
FreezeAccount,
|
FreezeAccount,
|
||||||
/// Owner of a given token account
|
/// Owner of a given token account
|
||||||
AccountOwner,
|
AccountOwner,
|
||||||
/// Authority to close a mint or token account
|
/// Authority to close a token account
|
||||||
CloseAccount,
|
CloseAccount,
|
||||||
/// Authority to set the transfer fee
|
/// Authority to set the transfer fee
|
||||||
TransferFeeConfig,
|
TransferFeeConfig,
|
||||||
/// Authority to withdraw withheld tokens from a mint
|
/// Authority to withdraw withheld tokens from a mint
|
||||||
WithheldWithdraw,
|
WithheldWithdraw,
|
||||||
|
/// Authority to close a mint account
|
||||||
|
CloseMint,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AuthorityType {
|
impl AuthorityType {
|
||||||
|
@ -932,6 +934,7 @@ impl AuthorityType {
|
||||||
AuthorityType::CloseAccount => 3,
|
AuthorityType::CloseAccount => 3,
|
||||||
AuthorityType::TransferFeeConfig => 4,
|
AuthorityType::TransferFeeConfig => 4,
|
||||||
AuthorityType::WithheldWithdraw => 5,
|
AuthorityType::WithheldWithdraw => 5,
|
||||||
|
AuthorityType::CloseMint => 6,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,6 +946,7 @@ impl AuthorityType {
|
||||||
3 => Ok(AuthorityType::CloseAccount),
|
3 => Ok(AuthorityType::CloseAccount),
|
||||||
4 => Ok(AuthorityType::TransferFeeConfig),
|
4 => Ok(AuthorityType::TransferFeeConfig),
|
||||||
5 => Ok(AuthorityType::WithheldWithdraw),
|
5 => Ok(AuthorityType::WithheldWithdraw),
|
||||||
|
6 => Ok(AuthorityType::CloseMint),
|
||||||
_ => Err(TokenError::InvalidInstruction.into()),
|
_ => Err(TokenError::InvalidInstruction.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,7 +610,7 @@ impl Processor {
|
||||||
mint.base.freeze_authority = new_authority;
|
mint.base.freeze_authority = new_authority;
|
||||||
mint.pack_base();
|
mint.pack_base();
|
||||||
}
|
}
|
||||||
AuthorityType::CloseAccount => {
|
AuthorityType::CloseMint => {
|
||||||
let extension = mint.get_extension_mut::<MintCloseAuthority>()?;
|
let extension = mint.get_extension_mut::<MintCloseAuthority>()?;
|
||||||
let maybe_close_authority: Option<Pubkey> = extension.close_authority.into();
|
let maybe_close_authority: Option<Pubkey> = extension.close_authority.into();
|
||||||
let close_authority =
|
let close_authority =
|
||||||
|
|
Loading…
Reference in New Issue