-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reverse back to PodOption for delegate
- Loading branch information
1 parent
6c8be6c
commit 85198a6
Showing
8 changed files
with
45 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::state::{Market, OpenOrdersAccount, OpenOrdersAccountFixed}; | ||
use crate::state::OpenOrdersAccountFixed; | ||
|
||
#[derive(Accounts)] | ||
pub struct SetDelegate<'info> { | ||
#[account( | ||
mut, | ||
has_one = market, | ||
has_one = owner, | ||
)] | ||
pub open_orders_account: AccountLoader<'info, OpenOrdersAccountFixed>, | ||
#[account(mut)] | ||
pub owner: Signer<'info>, | ||
#[account()] | ||
/// CHECK: | ||
pub delegate_account: Option<UncheckedAccount<'info>>, | ||
#[account(mut)] | ||
pub market: AccountLoader<'info, Market>, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::accounts_ix::*; | ||
use crate::error::*; | ||
use crate::pod_option::PodOption; | ||
use crate::state::*; | ||
|
||
pub fn set_delegate(ctx: Context<SetDelegate>, limit: u8) -> Result<()> { | ||
pub fn set_delegate(ctx: Context<SetDelegate>) -> Result<()> { | ||
let mut account = ctx.accounts.open_orders_account.load_full_mut()?; | ||
|
||
account.delegate = if let Some(delegate) = ctx.accounts.delegate_account { | ||
delegate; | ||
let delegate_account: PodOption<Pubkey> = ctx | ||
.accounts | ||
.delegate_account | ||
.as_ref() | ||
.map(|account| account.key()) | ||
.into(); | ||
|
||
account.fixed.delegate = delegate_account; | ||
|
||
} else { | ||
ctx.accounts.owner.key() | ||
}; | ||
Ok(()) | ||
} |
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