Skip to content

Commit

Permalink
Add cosigner owner check (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
nothing0012 authored Jul 12, 2024
1 parent 3cec5e5 commit 87ee5d0
Show file tree
Hide file tree
Showing 27 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/admin/create_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct CreatePool<'info> {
#[account(mut)]
pub owner: Signer<'info>,
/// CHECK: the cosigner can be set as owner if you want optional cosigner
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
init,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/admin/set_shared_escrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub struct SetSharedEscrowArgs {
pub struct SetSharedEscrow<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/admin/sol_close_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use super::*;
pub struct SolClosePool<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/admin/update_allowlists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct UpdateAllowlistsArgs {
#[instruction(args:UpdateAllowlistsArgs)]
pub struct UpdateAllowlists<'info> {
#[account(mut)]
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
/// CHECK: Owner is only used for seed derivation. Cosigner has_one constraint is checked in the pool account.
pub owner: UncheckedAccount<'info>,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/admin/update_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct UpdatePoolArgs {
pub struct UpdatePool<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
pub struct ExtDepositeSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
pub struct ExtWithdrawSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct ExtSolFulfillBuy<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(mut)]
/// CHECK: we will check that the referral matches the pool's referral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct ExtSolFulfillSell<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
/// CHECK: we will check that the referral matches the pool's referral
#[account(mut)]
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/mip1/mip1_deposit_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{
pub struct Mip1DepositSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/mip1/mip1_withdraw_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use crate::{
pub struct Mip1WithdrawSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/mip1/sol_mip1_fulfill_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct SolMip1FulfillBuy<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(mut)]
/// CHECK: we will check that the referral matches the pool's referral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct SolMip1FulfillSell<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
/// CHECK: we will check that the referral matches the pool's referral
#[account(mut)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct MplCoreDepositSellArgs {
pub struct MplCoreDepositSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct MplCoreWithdrawSellArgs {
pub struct MplCoreWithdrawSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct SolMplCoreFulfillBuy<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(mut)]
/// CHECK: we will check that the referral matches the pool's referral
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct SolMplCoreFulfillSell<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
/// CHECK: we will check that the referral matches the pool's referral
#[account(mut)]
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/ocp/ocp_deposit_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
pub struct OcpDepositSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/ocp/ocp_withdraw_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{
pub struct OcpWithdrawSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/ocp/sol_ocp_fulfill_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct SolOcpFulfillBuy<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(mut)]
/// CHECK: we will check that the referral matches the pool's referral
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/ocp/sol_ocp_fulfill_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub struct SolOcpFulfillSell<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
/// CHECK: we will check that the referral matches the pool's referral
#[account(mut)]
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/vanilla/deposit_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct DepositSellArgs {
pub struct DepositSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/vanilla/sol_deposit_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct SolDepositBuyArgs {
pub struct SolDepositBuy<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/vanilla/sol_fulfill_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct SolFulfillBuy<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(mut)]
/// CHECK: we will check that the referral matches the pool's referral
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/vanilla/sol_fulfill_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct SolFulfillSell<'info> {
/// CHECK: we will check the owner field that matches the pool owner
#[account(mut)]
pub owner: UncheckedAccount<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
/// CHECK: we will check that the referral matches the pool's referral
#[account(mut)]
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/vanilla/sol_withdraw_buy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct SolWithdrawBuyArgs {
pub struct SolWithdrawBuy<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down
1 change: 1 addition & 0 deletions programs/mmm/src/instructions/vanilla/withdraw_sell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct WithdrawSellArgs {
pub struct WithdrawSell<'info> {
#[account(mut)]
pub owner: Signer<'info>,
#[account(constraint = owner.key() != cosigner.key() @ MMMErrorCode::InvalidCosigner)]
pub cosigner: Signer<'info>,
#[account(
mut,
Expand Down

0 comments on commit 87ee5d0

Please sign in to comment.