|
61 | 61 | },
|
62 | 62 | state::{Account, AccountState, Mint, Multisig},
|
63 | 63 | },
|
64 |
| - spl_token_group_interface::state::TokenGroup, |
| 64 | + spl_token_group_interface::state::{TokenGroup, TokenGroupMember}, |
65 | 65 | spl_token_metadata_interface::state::{Field, TokenMetadata},
|
66 | 66 | std::{
|
67 | 67 | fmt, io,
|
@@ -3801,4 +3801,58 @@ where
|
3801 | 3801 | )
|
3802 | 3802 | .await
|
3803 | 3803 | }
|
| 3804 | + |
| 3805 | + /// Initialize a token-group member on a mint |
| 3806 | + pub async fn token_group_initialize_member<S: Signers>( |
| 3807 | + &self, |
| 3808 | + mint_authority: &Pubkey, |
| 3809 | + group_mint: &Pubkey, |
| 3810 | + group_update_authority: &Pubkey, |
| 3811 | + signing_keypairs: &S, |
| 3812 | + ) -> TokenResult<T::Output> { |
| 3813 | + self.process_ixs( |
| 3814 | + &[spl_token_group_interface::instruction::initialize_member( |
| 3815 | + &self.program_id, |
| 3816 | + &self.pubkey, |
| 3817 | + &self.pubkey, |
| 3818 | + mint_authority, |
| 3819 | + group_mint, |
| 3820 | + group_update_authority, |
| 3821 | + )], |
| 3822 | + signing_keypairs, |
| 3823 | + ) |
| 3824 | + .await |
| 3825 | + } |
| 3826 | + |
| 3827 | + /// Initialize a token-group member on a mint |
| 3828 | + #[allow(clippy::too_many_arguments)] |
| 3829 | + pub async fn token_group_initialize_member_with_rent_transfer<S: Signers>( |
| 3830 | + &self, |
| 3831 | + payer: &Pubkey, |
| 3832 | + mint_authority: &Pubkey, |
| 3833 | + group_mint: &Pubkey, |
| 3834 | + group_update_authority: &Pubkey, |
| 3835 | + signing_keypairs: &S, |
| 3836 | + ) -> TokenResult<T::Output> { |
| 3837 | + let additional_lamports = self |
| 3838 | + .get_additional_rent_for_fixed_len_extension::<TokenGroupMember>() |
| 3839 | + .await?; |
| 3840 | + let mut instructions = vec![]; |
| 3841 | + if additional_lamports > 0 { |
| 3842 | + instructions.push(system_instruction::transfer( |
| 3843 | + payer, |
| 3844 | + &self.pubkey, |
| 3845 | + additional_lamports, |
| 3846 | + )); |
| 3847 | + } |
| 3848 | + instructions.push(spl_token_group_interface::instruction::initialize_member( |
| 3849 | + &self.program_id, |
| 3850 | + &self.pubkey, |
| 3851 | + &self.pubkey, |
| 3852 | + mint_authority, |
| 3853 | + group_mint, |
| 3854 | + group_update_authority, |
| 3855 | + )); |
| 3856 | + self.process_ixs(&instructions, signing_keypairs).await |
| 3857 | + } |
3804 | 3858 | }
|
0 commit comments