-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mmm] deposit sell for T22 extension
- Loading branch information
Showing
8 changed files
with
123 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,41 @@ | ||
use solana_program::{account_info::AccountInfo, pubkey::Pubkey}; | ||
use spl_token_client | ||
use spl_token_2022::{ | ||
extension::{ | ||
group_member_pointer::GroupMemberPointer, BaseStateWithExtensions, StateWithExtensions, | ||
}, | ||
state::Mint as Token22Mint, | ||
}; | ||
use spl_token_group_interface::state::TokenGroupMember; | ||
|
||
use crate::state::{Allowlist, ALLOWLIST_KIND_GROUP}; | ||
|
||
use {crate::errors::MMMErrorCode, anchor_lang::prelude::*}; | ||
|
||
pub fn check_group_ext_for_mint(token_mint: &AccountInfo, allowlists: &[Allowlist]) -> Result<()> { | ||
if token_mint.data_is_empty() { | ||
return Err(MMMErrorCode::InvalidTokenMint.into()); | ||
} | ||
let borrowed_data = token_mint.data.borrow(); | ||
let mint_deserialized = StateWithExtensions::<Token22Mint>::unpack(&borrowed_data)?; | ||
if !mint_deserialized.base.is_initialized { | ||
return Err(MMMErrorCode::InvalidTokenMint.into()); | ||
} | ||
if let Ok(group_member_ptr) = mint_deserialized.get_extension::<GroupMemberPointer>() { | ||
if Some(*token_mint.key) != Option::<Pubkey>::from(group_member_ptr.member_address) { | ||
return Err(MMMErrorCode::InValidTokenExtension.into()); | ||
} | ||
} | ||
if let Ok(group_member) = mint_deserialized.get_extension::<TokenGroupMember>() { | ||
let group_address = allowlists | ||
.iter() | ||
.find(|allowlist| allowlist.kind == ALLOWLIST_KIND_GROUP) | ||
.map(|allowlist| allowlist.value); | ||
if Some(group_member.group) != group_address { | ||
return Err(MMMErrorCode::InValidTokenExtension.into()); | ||
} | ||
} else { | ||
return Err(MMMErrorCode::InValidTokenExtension.into()); | ||
} | ||
|
||
pub fn check_group_for_mint(mint_state: &AccountInfo, group_address: Pubkey) -> Result<()> { | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pub mod ext_sol_deposit_sell; | ||
pub mod ext_deposit_sell; | ||
|
||
pub use ext_sol_deposit_sell::*; | ||
pub use ext_deposit_sell::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters