-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solana: Add SPL multisig support (#568)
* `initialize_multisig` and `release_inbound_multisig_mint` to act as multisig variants of initialize and release_inbound_mint respectively * Add SPLMultisig `InterfaceAccount` wrapper * Refactor out common structs and function logic to avoid duplication * Update test to verify independent minting capability after transferring authority to multisig * Update IDL
- Loading branch information
Showing
10 changed files
with
979 additions
and
89 deletions.
There are no files selected for viewing
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
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
35 changes: 35 additions & 0 deletions
35
solana/programs/example-native-token-transfers/src/spl_multisig.rs
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use anchor_lang::{prelude::*, solana_program::program_pack::Pack, Ids, Owners}; | ||
use anchor_spl::token_interface::TokenInterface; | ||
use std::ops::Deref; | ||
|
||
/// Anchor does not have a SPL Multisig wrapper as a part of the token interface: | ||
/// https://docs.rs/anchor-spl/0.29.0/src/anchor_spl/token_interface.rs.html | ||
/// Thus, we have to write our own wrapper to use with `InterfaceAccount` | ||
#[derive(Clone, Debug, Default, PartialEq)] | ||
pub struct SplMultisig(spl_token_2022::state::Multisig); | ||
|
||
impl AccountDeserialize for SplMultisig { | ||
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> { | ||
Ok(SplMultisig(spl_token_2022::state::Multisig::unpack(buf)?)) | ||
} | ||
} | ||
|
||
impl AccountSerialize for SplMultisig {} | ||
|
||
impl Owners for SplMultisig { | ||
fn owners() -> &'static [Pubkey] { | ||
TokenInterface::ids() | ||
} | ||
} | ||
|
||
impl Deref for SplMultisig { | ||
type Target = spl_token_2022::state::Multisig; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
#[cfg(feature = "idl-build")] | ||
impl anchor_lang::IdlBuild for SplMultisig {} |
Oops, something went wrong.