Skip to content

Commit

Permalink
Add any allowlist type (#76)
Browse files Browse the repository at this point in the history
* add any allowlist type

* add comment
  • Loading branch information
madergaser authored Nov 23, 2023
1 parent f73f4ea commit 5ee63e0
Show file tree
Hide file tree
Showing 6 changed files with 3,038 additions and 2,806 deletions.
7 changes: 5 additions & 2 deletions programs/mmm/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ pub const ALLOWLIST_KIND_FVCA: u8 = 1;
pub const ALLOWLIST_KIND_MINT: u8 = 2;
pub const ALLOWLIST_KIND_MCC: u8 = 3;
pub const ALLOWLIST_KIND_METADATA: u8 = 4;
// ANY nft will pass the allowlist check, please make sure to use cosigner to check NFT validity
pub const ALLOWLIST_KIND_ANY: u8 = u8::MAX;

#[derive(Default, Copy, Clone, AnchorSerialize, AnchorDeserialize)]
pub struct Allowlist {
Expand All @@ -24,11 +26,12 @@ impl Allowlist {
// kind == 3: verified MCC
// kind == 4: metadata
// kind == 5,6,... will be supported in the future
// kind == 255: any
pub fn valid(&self) -> bool {
if self.kind > ALLOWLIST_KIND_METADATA {
if self.kind > ALLOWLIST_KIND_METADATA && self.kind != ALLOWLIST_KIND_ANY {
return false;
}
if self.kind != 0 {
if self.kind != 0 && self.kind != ALLOWLIST_KIND_ANY {
return self.value.ne(&Pubkey::default());
}
true
Expand Down
4 changes: 4 additions & 0 deletions programs/mmm/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ pub fn check_allowlists_for_mint(
for allowlist_val in allowlists.iter() {
match allowlist_val.kind {
ALLOWLIST_KIND_EMPTY => {}
ALLOWLIST_KIND_ANY => {
// any is a special case, we don't need to check anything else
return Ok(parsed_metadata);
}
ALLOWLIST_KIND_FVCA => {
if let Some(ref creators) = parsed_metadata.data.creators {
// TODO: can we make sure we only take master_edition here?
Expand Down
1 change: 1 addition & 0 deletions sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export enum AllowlistKind {
mint = 2,
mcc = 3,
metadata = 4,
any = 255,
}
Loading

0 comments on commit 5ee63e0

Please sign in to comment.