Skip to content

Commit

Permalink
Update expand name to be clear it is just market (#14)
Browse files Browse the repository at this point in the history
* Update expand name to be clear it is just market

* fmt
  • Loading branch information
brittcyr authored Aug 26, 2024
1 parent b735660 commit f608335
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
11 changes: 6 additions & 5 deletions programs/manifest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ pub mod validation;

use program::{
batch_update::process_batch_update, claim_seat::process_claim_seat,
create_market::process_create_market, deposit::process_deposit, expand::process_expand,
global_add_trader::process_global_add_trader, global_claim_seat::process_global_claim_seat,
global_create::process_global_create, global_deposit::process_global_deposit, process_swap,
withdraw::process_withdraw, ManifestInstruction,
create_market::process_create_market, deposit::process_deposit,
expand_market::process_expand_market, global_add_trader::process_global_add_trader,
global_claim_seat::process_global_claim_seat, global_create::process_global_create,
global_deposit::process_global_deposit, process_swap, withdraw::process_withdraw,
ManifestInstruction,
};
use solana_program::{
account_info::AccountInfo, declare_id, entrypoint::ProgramResult, program_error::ProgramError,
Expand Down Expand Up @@ -71,7 +72,7 @@ pub fn process_instruction(
process_swap(program_id, accounts, data)?;
}
ManifestInstruction::Expand => {
process_expand(program_id, accounts, data)?;
process_expand_market(program_id, accounts, data)?;
}
ManifestInstruction::BatchUpdate => {
process_batch_update(program_id, accounts, data)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use solana_program::{
system_program,
};

pub fn expand_instruction(market: &Pubkey, payer: &Pubkey) -> Instruction {
pub fn expand_market_instruction(market: &Pubkey, payer: &Pubkey) -> Instruction {
Instruction {
program_id: crate::id(),
accounts: vec![
Expand Down
4 changes: 2 additions & 2 deletions programs/manifest/src/program/instruction_builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod batch_update_instruction;
pub mod claim_seat_instruction;
pub mod create_market_instructions;
pub mod deposit_instruction;
pub mod expand_instruction;
pub mod expand_market_instruction;
pub mod global_add_trader_instruction;
pub mod global_claim_seat_instruction;
pub mod global_create_instruction;
Expand All @@ -14,7 +14,7 @@ pub use batch_update_instruction::*;
pub use claim_seat_instruction::*;
pub use create_market_instructions::*;
pub use deposit_instruction::*;
pub use expand_instruction::*;
pub use expand_market_instruction::*;
pub use global_add_trader_instruction::*;
pub use global_claim_seat_instruction::*;
pub use global_create_instruction::*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};

use crate::validation::loaders::ExpandContext;
use crate::validation::loaders::ExpandMarketContext;

use super::shared::expand_market_if_needed;

pub(crate) fn process_expand(
pub(crate) fn process_expand_market(
_program_id: &Pubkey,
accounts: &[AccountInfo],
_data: &[u8],
) -> ProgramResult {
let expand_context: ExpandContext = ExpandContext::load(accounts)?;
let ExpandContext {
let expand_market_context: ExpandMarketContext = ExpandMarketContext::load(accounts)?;
let ExpandMarketContext {
market,
payer,
system_program,
} = expand_context;
} = expand_market_context;

expand_market_if_needed(&payer, &market, &system_program)?;

Expand Down
2 changes: 1 addition & 1 deletion programs/manifest/src/program/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub mod batch_update;
pub mod claim_seat;
pub mod create_market;
pub mod deposit;
pub mod expand;
pub mod expand_market;
pub mod global_add_trader;
pub mod global_claim_seat;
pub mod global_create;
Expand Down
8 changes: 3 additions & 5 deletions programs/manifest/src/validation/loaders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,14 @@ impl<'a, 'info> ClaimSeatContext<'a, 'info> {
}
}

// TODO: rename to ExpandMarketContext to be clear that this only expands
// market, does not work for expanding global.
/// ExpandContext account infos
pub(crate) struct ExpandContext<'a, 'info> {
/// ExpandMarketContext account infos
pub(crate) struct ExpandMarketContext<'a, 'info> {
pub payer: Signer<'a, 'info>,
pub market: ManifestAccountInfo<'a, 'info, MarketFixed>,
pub system_program: Program<'a, 'info>,
}

impl<'a, 'info> ExpandContext<'a, 'info> {
impl<'a, 'info> ExpandMarketContext<'a, 'info> {
pub fn load(accounts: &'a [AccountInfo<'info>]) -> Result<Self, ProgramError> {
let account_iter: &mut Iter<AccountInfo<'info>> = &mut accounts.iter();

Expand Down
4 changes: 2 additions & 2 deletions programs/wrapper/src/processors/claim_seat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{cell::RefMut, mem::size_of};

use hypertree::{get_mut_helper, DataIndex, FreeList, TreeReadOperations, NIL};
use manifest::{
program::{claim_seat_instruction, expand_instruction, get_mut_dynamic_account},
program::{claim_seat_instruction, expand_market_instruction, get_mut_dynamic_account},
state::{MarketFixed, MarketRefMut},
validation::ManifestAccountInfo,
};
Expand Down Expand Up @@ -42,7 +42,7 @@ pub(crate) fn process_claim_seat(

// Call the Expand CPI
invoke(
&expand_instruction(market.key, payer.key),
&expand_market_instruction(market.key, payer.key),
&[
manifest_program.info.clone(),
owner.info.clone(),
Expand Down

0 comments on commit f608335

Please sign in to comment.