// ...
#[derive(Accounts)]
pub struct MintWithIdentityDepository<'info> {
/// #1 Public call accessible to any user
pub user: Signer<'info>,
/// #2
#[account(mut)]
pub payer: Signer<'info>,
/// #3 The top level UXDProgram on chain account managing the redeemable mint
#[account(
mut,
seeds = [CONTROLLER_NAMESPACE],
bump = controller.load()?.bump,
has_one = redeemable_mint @UxdError::InvalidRedeemableMint
)]
pub controller: AccountLoader<'info, Controller>,
/// #4 UXDProgram on chain account bound to a Controller instance that represent the blank minting/redeeming
#[account(
mut,
seeds = [IDENTITY_DEPOSITORY_NAMESPACE],
bump = depository.load()?.bump,
)]
pub depository: AccountLoader<'info, IdentityDepository>,
/// #5
/// Token account holding the collateral from minting
#[account(
mut,
seeds = [IDENTITY_DEPOSITORY_COLLATERAL_NAMESPACE],
token::authority = depository,
token::mint = depository.load()?.collateral_mint,
bump = depository.load()?.collateral_vault_bump,
)]
pub collateral_vault: Box<Account<'info, TokenAccount>>,
/// #6 The redeemable mint managed by the `controller` instance
/// Tokens will be minted during this instruction
#[account(
mut,
seeds = [REDEEMABLE_MINT_NAMESPACE],
bump = controller.load()?.redeemable_mint_bump,
)]
pub redeemable_mint: Box<Account<'info, Mint>>,
/// #7 The `user`'s TA for the `depository` `collateral_mint`
/// Will be debited during this instruction
#[account(
mut,
constraint = user_collateral.mint == depository.load()?.collateral_mint @UxdError::InvalidCollateralMint,
constraint = &user_collateral.owner == user.key @UxdError::InvalidOwner,
)]
pub user_collateral: Box<Account<'info, TokenAccount>>,
/// #8 The `user`'s TA for the `controller`'s `redeemable_mint`
/// Will be credited during this instruction
#[account(
mut,
constraint = user_redeemable.mint == controller.load()?.redeemable_mint @UxdError::InvalidRedeemableMint,
constraint = &user_redeemable.owner == user.key @UxdError::InvalidOwner,
)]
pub user_redeemable: Box<Account<'info, TokenAccount>>,
/// #9
pub system_program: Program<'info, System>,
/// #10 Token Program
pub token_program: Program<'info, Token>,
}
// ...