quarry_operator/instructions/
delegate_create_quarry_v2.rs1use crate::*;
2
3pub fn handler(ctx: Context<DelegateCreateQuarryV2>) -> Result<()> {
5 let operator = &ctx.accounts.with_delegate.operator;
6 let signer_seeds: &[&[&[u8]]] = &[gen_operator_signer_seeds!(operator)];
7 quarry_mine::cpi::create_quarry_v2(CpiContext::new_with_signer(
8 ctx.accounts
9 .with_delegate
10 .quarry_mine_program
11 .to_account_info(),
12 quarry_mine::cpi::accounts::CreateQuarryV2 {
13 quarry: ctx.accounts.quarry.to_account_info(),
14 auth: ctx.accounts.with_delegate.to_auth_accounts(),
15 token_mint: ctx.accounts.token_mint.to_account_info(),
16 payer: ctx.accounts.payer.to_account_info(),
17 system_program: ctx.accounts.system_program.to_account_info(),
18 },
19 signer_seeds,
20 ))?;
21 Ok(())
22}
23
24#[derive(Accounts)]
26pub struct DelegateCreateQuarryV2<'info> {
27 pub with_delegate: WithDelegate<'info>,
29
30 #[account(mut)]
32 pub quarry: SystemAccount<'info>,
33
34 pub token_mint: Box<Account<'info, anchor_spl::token::Mint>>,
36
37 #[account(mut)]
39 pub payer: Signer<'info>,
40
41 pub system_program: Program<'info, System>,
43}
44
45impl<'info> Validate<'info> for DelegateCreateQuarryV2<'info> {
46 fn validate(&self) -> Result<()> {
47 assert_keys_eq!(
48 self.with_delegate.operator.quarry_creator,
49 self.with_delegate.delegate,
50 Unauthorized
51 );
52 self.with_delegate.validate()?;
53 Ok(())
54 }
55}