Fixing code

This commit is contained in:
Jordan Prince 2021-08-12 19:30:36 -05:00
parent d13e2a98c7
commit b4f5b4b29b
3 changed files with 20 additions and 19 deletions

View File

@ -154,7 +154,7 @@ pub enum MetaplexInstruction {
/// 20. `[]` Safety deposit config pda of ['metaplex', program id, auction manager, safety deposit] /// 20. `[]` Safety deposit config pda of ['metaplex', program id, auction manager, safety deposit]
/// This account will only get used AND BE REQUIRED in the event this is an AuctionManagerV2 /// This account will only get used AND BE REQUIRED in the event this is an AuctionManagerV2
/// 21. `[]` Auction extended (pda relative to auction of ['auction', program id, vault key, 'extended']) /// 21. `[]` Auction extended (pda relative to auction of ['auction', program id, vault key, 'extended'])
DeprecatedRedeemBid, RedeemBid,
/// Note: This requires that auction manager be in a Running state. /// Note: This requires that auction manager be in a Running state.
/// ///

View File

@ -2,10 +2,9 @@ use {
crate::{ crate::{
error::MetaplexError, error::MetaplexError,
instruction::EndAuctionArgs as MetaplexEndAuctionArgs, instruction::EndAuctionArgs as MetaplexEndAuctionArgs,
state::{AuctionManager, AuctionManagerStatus, Store, PREFIX}, state::{get_auction_manager, AuctionManagerStatus, Store, PREFIX},
utils::{assert_authority_correct, assert_owned_by}, utils::{assert_authority_correct, assert_owned_by},
}, },
borsh::BorshSerialize,
solana_program::{ solana_program::{
account_info::{next_account_info, AccountInfo}, account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult, entrypoint::ProgramResult,
@ -49,7 +48,7 @@ pub fn process_end_auction(
args: MetaplexEndAuctionArgs, args: MetaplexEndAuctionArgs,
) -> ProgramResult { ) -> ProgramResult {
let account_info_iter = &mut accounts.iter(); let account_info_iter = &mut accounts.iter();
let auction_manager_info = next_account_info(account_info_iter)?; let mut auction_manager_info = next_account_info(account_info_iter)?;
let auction_info = next_account_info(account_info_iter)?; let auction_info = next_account_info(account_info_iter)?;
let auction_data_extended_info = next_account_info(account_info_iter)?; let auction_data_extended_info = next_account_info(account_info_iter)?;
let authority_info = next_account_info(account_info_iter)?; let authority_info = next_account_info(account_info_iter)?;
@ -57,7 +56,7 @@ pub fn process_end_auction(
let auction_program_info = next_account_info(account_info_iter)?; let auction_program_info = next_account_info(account_info_iter)?;
let clock_info = next_account_info(account_info_iter)?; let clock_info = next_account_info(account_info_iter)?;
let mut auction_manager = AuctionManager::from_account_info(auction_manager_info)?; let mut auction_manager = get_auction_manager(auction_manager_info)?;
let auction = AuctionData::from_account_info(auction_info)?; let auction = AuctionData::from_account_info(auction_info)?;
let auction_data_extended = AuctionDataExtended::from_account_info(auction_data_extended_info)?; let auction_data_extended = AuctionDataExtended::from_account_info(auction_data_extended_info)?;
let store = Store::from_account_info(store_info)?; let store = Store::from_account_info(store_info)?;
@ -66,16 +65,16 @@ pub fn process_end_auction(
return Err(MetaplexError::AuctionAuthorityMismatch.into()); return Err(MetaplexError::AuctionAuthorityMismatch.into());
} }
assert_authority_correct(&auction_manager, authority_info)?; assert_authority_correct(&auction_manager.authority(), authority_info)?;
assert_owned_by(auction_info, &store.auction_program)?; assert_owned_by(auction_info, &store.auction_program)?;
assert_owned_by(auction_manager_info, program_id)?; assert_owned_by(auction_manager_info, program_id)?;
assert_owned_by(store_info, program_id)?; assert_owned_by(store_info, program_id)?;
if auction_manager.store != *store_info.key { if auction_manager.store() != *store_info.key {
return Err(MetaplexError::AuctionManagerStoreMismatch.into()); return Err(MetaplexError::AuctionManagerStoreMismatch.into());
} }
if auction_manager.auction != *auction_info.key { if auction_manager.auction() != *auction_info.key {
return Err(MetaplexError::AuctionManagerAuctionMismatch.into()); return Err(MetaplexError::AuctionManagerAuctionMismatch.into());
} }
@ -83,15 +82,16 @@ pub fn process_end_auction(
return Err(MetaplexError::AuctionManagerAuctionProgramMismatch.into()); return Err(MetaplexError::AuctionManagerAuctionProgramMismatch.into());
} }
if auction_manager.state.status != AuctionManagerStatus::Validated { if auction_manager.status() != AuctionManagerStatus::Validated {
return Err(MetaplexError::AuctionManagerMustBeValidated.into()); return Err(MetaplexError::AuctionManagerMustBeValidated.into());
} }
let seeds = &[PREFIX.as_bytes(), &auction_manager.auction.as_ref()]; let auction_key = auction_manager.auction();
let seeds = &[PREFIX.as_bytes(), &auction_key.as_ref()];
let (_, bump_seed) = Pubkey::find_program_address(seeds, &program_id); let (_, bump_seed) = Pubkey::find_program_address(seeds, &program_id);
let authority_seeds = &[ let authority_seeds = &[
PREFIX.as_bytes(), PREFIX.as_bytes(),
&auction_manager.auction.as_ref(), &auction_key.as_ref(),
&[bump_seed], &[bump_seed],
]; ];
@ -100,7 +100,7 @@ pub fn process_end_auction(
auction_manager_info.clone(), auction_manager_info.clone(),
auction_info.clone(), auction_info.clone(),
clock_info.clone(), clock_info.clone(),
auction_manager.vault, auction_manager.vault(),
args.reveal, args.reveal,
authority_seeds, authority_seeds,
)?; )?;
@ -108,17 +108,17 @@ pub fn process_end_auction(
if auction_data_extended.instant_sale_price.is_some() { if auction_data_extended.instant_sale_price.is_some() {
match auction.bid_state { match auction.bid_state {
BidState::EnglishAuction { .. } => { BidState::EnglishAuction { .. } => {
auction_manager.state.status = AuctionManagerStatus::Disbursing; auction_manager.set_status(AuctionManagerStatus::Disbursing);
} }
BidState::OpenEdition { .. } => { BidState::OpenEdition { .. } => {
auction_manager.state.status = AuctionManagerStatus::Finished; auction_manager.set_status(AuctionManagerStatus::Finished);
} }
} }
} else { } else {
auction_manager.state.status = AuctionManagerStatus::Disbursing; auction_manager.set_status(AuctionManagerStatus::Disbursing);
} }
auction_manager.serialize(&mut *auction_manager_info.data.borrow_mut())?; auction_manager.save(&mut auction_manager_info)?;
Ok(()) Ok(())
} }

View File

@ -271,7 +271,7 @@ pub fn process_redeem_participation_bid<'a>(
}); });
auction_extended_info = None; auction_extended_info = None;
} else { } else {
v2_accounts = Some(V2Accounts { let v2_accounts_base = V2Accounts {
prize_tracking_ticket_info: next_account_info(account_info_iter)?, prize_tracking_ticket_info: next_account_info(account_info_iter)?,
new_metadata_account_info: next_account_info(account_info_iter)?, new_metadata_account_info: next_account_info(account_info_iter)?,
new_edition_account_info: next_account_info(account_info_iter)?, new_edition_account_info: next_account_info(account_info_iter)?,
@ -281,8 +281,9 @@ pub fn process_redeem_participation_bid<'a>(
mint_authority_info: next_account_info(account_info_iter)?, mint_authority_info: next_account_info(account_info_iter)?,
metadata_account_info: next_account_info(account_info_iter)?, metadata_account_info: next_account_info(account_info_iter)?,
auction_extended_info: next_account_info(account_info_iter)?, auction_extended_info: next_account_info(account_info_iter)?,
}); };
auction_extended_info = Some(v2_accounts.unwrap().auction_extended_info) auction_extended_info = Some(v2_accounts_base.auction_extended_info);
v2_accounts = Some(v2_accounts_base);
} }
let CommonRedeemReturn { let CommonRedeemReturn {