-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(auction-house): bump versions to anchor 0.24.2 * refactor(auction-house): add auctioneer module; refactor bid * refactor(auction-house): add cancel & deposit modules * refactor(auction-house): add execute_sale mod; refactor receipts * refactor(auction-house): add sell & withdraw mods * test(auction-house): refactor tests for auctioneer * refactor(auction-house): box various accounts to reduce stack size * style(auction-house): update Anchor CHECK comments * fix(auction-house): add better rent checks to auction_bid_logic * fix(auction-house): add shortfall check for rent migration to execute_sale logic * fix(auction-house): apply sec fix and test from GHSA-27g6-cw44-x825 * chore(auction-house): bump version to match master * chore(auction-house) remove redundant test file * refactor(auction-house) remove update auctioneer handler; fix some naming * refactor(auction-house): rename auctioneer items
- Loading branch information
1 parent
3f5b7ee
commit 1363c4a
Showing
29 changed files
with
7,612 additions
and
2,407 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use anchor_lang::prelude::*; | ||
|
||
use crate::{constants::*, errors::AuctionHouseError, AuctionHouse, Auctioneer, AuthorityScope}; | ||
|
||
/// Accounts for the [`delegate_auctioneer` handler](auction_house/fn.delegate_auctioneer.html). | ||
#[derive(Accounts)] | ||
pub struct DelegateAuctioneer<'info> { | ||
// Auction House instance PDA account. | ||
#[account(mut, seeds=[PREFIX.as_bytes(), auction_house.creator.as_ref(), auction_house.treasury_mint.as_ref()], bump=auction_house.bump, has_one=authority)] | ||
pub auction_house: Account<'info, AuctionHouse>, | ||
|
||
#[account(mut)] | ||
pub authority: Signer<'info>, | ||
|
||
/// CHECK: The auction house authority can set this to whatever external address they wish. | ||
/// The auctioneer program PDA running this auction. | ||
pub auctioneer_authority: UncheckedAccount<'info>, | ||
|
||
/// The auctioneer PDA owned by Auction House storing scopes. | ||
#[account(init, payer = authority, space = AUCTIONEER_SIZE, seeds = [AUCTIONEER.as_bytes(), auction_house.key().as_ref(), auctioneer_authority.key().as_ref()], bump)] | ||
pub ah_auctioneer_pda: Account<'info, Auctioneer>, | ||
|
||
pub system_program: Program<'info, System>, | ||
} | ||
|
||
pub fn delegate_auctioneer<'info>( | ||
ctx: Context<'_, '_, '_, 'info, DelegateAuctioneer<'info>>, | ||
scopes: Box<Vec<AuthorityScope>>, | ||
) -> Result<()> { | ||
if scopes.len() > MAX_NUM_SCOPES { | ||
return Err(AuctionHouseError::TooManyScopes.into()); | ||
} | ||
|
||
let auction_house = &mut ctx.accounts.auction_house; | ||
auction_house.has_auctioneer = true; | ||
auction_house.auctioneer_pda_bump = *ctx | ||
.bumps | ||
.get("ah_auctioneer_pda") | ||
.ok_or(AuctionHouseError::BumpSeedNotInHashMap)?; | ||
|
||
let auctioneer = &mut ctx.accounts.ah_auctioneer_pda; | ||
auctioneer.auctioneer_authority = ctx.accounts.auctioneer_authority.key(); | ||
auctioneer.auction_house = ctx.accounts.auction_house.key(); | ||
|
||
// Set all scopes false and then update as true the ones passed into the handler. | ||
auctioneer.scopes = [false; 7]; | ||
for scope in *scopes { | ||
auctioneer.scopes[scope as usize] = true; | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod delegate; | ||
pub use delegate::*; |
Oops, something went wrong.