Skip to content

Commit

Permalink
token 2022: add GroupMemberPointer extension
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Nov 20, 2023
1 parent 2b1c225 commit a62d81f
Show file tree
Hide file tree
Showing 9 changed files with 973 additions and 7 deletions.
53 changes: 50 additions & 3 deletions token/client/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ use {
self, account_info::WithheldTokensInfo, ConfidentialTransferFeeAmount,
ConfidentialTransferFeeConfig,
},
cpi_guard, default_account_state, group_pointer, interest_bearing_mint, memo_transfer,
metadata_pointer, transfer_fee, transfer_hook, BaseStateWithExtensions, Extension,
ExtensionType, StateWithExtensionsOwned,
cpi_guard, default_account_state, group_member_pointer, group_pointer,
interest_bearing_mint, memo_transfer, metadata_pointer, transfer_fee, transfer_hook,
BaseStateWithExtensions, Extension, ExtensionType, StateWithExtensionsOwned,
},
instruction, offchain,
proof::ProofLocation,
Expand Down Expand Up @@ -176,6 +176,12 @@ pub enum ExtensionInitializationParams {
authority: Option<Pubkey>,
group_address: Option<Pubkey>,
},
GroupMemberPointer {
authority: Option<Pubkey>,
group_update_authority: Pubkey,
group_address: Pubkey,
member_address: Option<Pubkey>,
},
}
impl ExtensionInitializationParams {
/// Get the extension type associated with the init params
Expand All @@ -194,6 +200,7 @@ impl ExtensionInitializationParams {
ExtensionType::ConfidentialTransferFeeConfig
}
Self::GroupPointer { .. } => ExtensionType::GroupPointer,
Self::GroupMemberPointer { .. } => ExtensionType::GroupMemberPointer,
}
}
/// Generate an appropriate initialization instruction for the given mint
Expand Down Expand Up @@ -294,6 +301,19 @@ impl ExtensionInitializationParams {
authority,
group_address,
),
Self::GroupMemberPointer {
authority,
group_update_authority,
group_address,
member_address,
} => group_member_pointer::instruction::initialize(
token_program_id,
mint,
authority,
&group_update_authority,
&group_address,
member_address,
),
}
}
}
Expand Down Expand Up @@ -1700,6 +1720,33 @@ where
.await
}

/// Update group member pointer address
pub async fn update_group_member_address<S: Signers>(
&self,
authority: &Pubkey,
group_update_authority: &Pubkey,
group_address: &Pubkey,
new_member_address: Option<Pubkey>,
signing_keypairs: &S,
) -> TokenResult<T::Output> {
let signing_pubkeys = signing_keypairs.pubkeys();
let multisig_signers = self.get_multisig_signers(authority, &signing_pubkeys);

self.process_ixs(
&[group_member_pointer::instruction::update(
&self.program_id,
self.get_address(),
authority,
group_update_authority,
&multisig_signers,
group_address,
new_member_address,
)?],
signing_keypairs,
)
.await
}

/// Update confidential transfer mint
pub async fn confidential_transfer_update_mint<S: Signers>(
&self,
Expand Down
Loading

0 comments on commit a62d81f

Please sign in to comment.