gmsol_store/instructions/
config.rs1use crate::states::{Amount, Factor};
2use anchor_lang::prelude::*;
3
4use crate::{states::Store, utils::internal};
5
6#[derive(Accounts)]
8pub struct InsertConfig<'info> {
9 #[account(mut)]
11 pub authority: Signer<'info>,
12 #[account(mut)]
14 pub store: AccountLoader<'info, Store>,
15}
16
17impl<'info> internal::Authentication<'info> for InsertConfig<'info> {
18 fn authority(&self) -> &Signer<'info> {
19 &self.authority
20 }
21
22 fn store(&self) -> &AccountLoader<'info, Store> {
23 &self.store
24 }
25}
26
27pub(crate) fn unchecked_insert_amount(
29 ctx: Context<InsertConfig>,
30 key: &str,
31 amount: Amount,
32) -> Result<()> {
33 *ctx.accounts.store.load_mut()?.get_amount_mut(key)? = amount;
34 Ok(())
35}
36
37pub(crate) fn unchecked_insert_factor(
43 ctx: Context<InsertConfig>,
44 key: &str,
45 factor: Factor,
46) -> Result<()> {
47 *ctx.accounts.store.load_mut()?.get_factor_mut(key)? = factor;
48 Ok(())
49}
50
51pub(crate) fn unchecked_insert_address(
53 ctx: Context<InsertConfig>,
54 key: &str,
55 address: Pubkey,
56) -> Result<()> {
57 *ctx.accounts.store.load_mut()?.get_address_mut(key)? = address;
58 Ok(())
59}