Skip to content

Commit

Permalink
solana: Validate token_authority is multisig signer
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsriram committed Dec 14, 2024
1 parent e2c6d0c commit 2bd3584
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
2 changes: 2 additions & 0 deletions solana/programs/example-native-token-transfers/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub enum NTTError {
BitmapIndexOutOfBounds,
#[msg("NoRegisteredTransceivers")]
NoRegisteredTransceivers,
#[msg("InvalidMultisig")]
InvalidMultisig,
}

impl From<ScalingError> for NTTError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{
bitmap::Bitmap,
error::NTTError,
queue::{outbox::OutboxRateLimit, rate_limit::RateLimitState},
spl_multisig::SplMultisig,
};

#[derive(Accounts)]
Expand Down Expand Up @@ -117,8 +118,12 @@ pub struct InitializeMultisig<'info> {
)]
pub common: Initialize<'info>,

/// CHECK: multisig is mint authority
pub multisig: UncheckedAccount<'info>,
#[account(
constraint =
multisig.m == 1 && multisig.signers.contains(&common.token_authority.key())
@ NTTError::InvalidMultisig,
)]
pub multisig: InterfaceAccount<'info, SplMultisig>,
}

pub fn initialize_multisig(ctx: Context<InitializeMultisig>, args: InitializeArgs) -> Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
config::*,
error::NTTError,
queue::inbox::{InboxItem, ReleaseStatus},
spl_multisig::SplMultisig,
};

#[derive(Accounts)]
Expand Down Expand Up @@ -137,8 +138,12 @@ pub struct ReleaseInboundMintMultisig<'info> {
)]
common: ReleaseInbound<'info>,

/// CHECK: multisig account should be mint authority
pub multisig: UncheckedAccount<'info>,
#[account(
constraint =
multisig.m == 1 && multisig.signers.contains(&common.token_authority.key())
@ NTTError::InvalidMultisig,
)]
pub multisig: InterfaceAccount<'info, SplMultisig>,
}

pub fn release_inbound_mint_multisig<'info>(
Expand Down
5 changes: 5 additions & 0 deletions solana/ts/idl/3_0_0/json/example_native_token_transfers.json
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,11 @@
"code": 6023,
"name": "NoRegisteredTransceivers",
"msg": "NoRegisteredTransceivers"
},
{
"code": 6024,
"name": "InvalidMultisig",
"msg": "InvalidMultisig"
}
]
}
10 changes: 10 additions & 0 deletions solana/ts/idl/3_0_0/ts/example_native_token_transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,11 @@ export type ExampleNativeTokenTransfers = {
"code": 6023,
"name": "NoRegisteredTransceivers",
"msg": "NoRegisteredTransceivers"
},
{
"code": 6024,
"name": "InvalidMultisig",
"msg": "InvalidMultisig"
}
]
}
Expand Down Expand Up @@ -4381,6 +4386,11 @@ export const IDL: ExampleNativeTokenTransfers = {
"code": 6023,
"name": "NoRegisteredTransceivers",
"msg": "NoRegisteredTransceivers"
},
{
"code": 6024,
"name": "InvalidMultisig",
"msg": "InvalidMultisig"
}
]
}
Expand Down

0 comments on commit 2bd3584

Please sign in to comment.