1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use anyhow::Result;
use async_trait::async_trait;
use cnidarium::StateWrite;
use cnidarium_component::ActionHandler;

use crate::{component::StateWriteExt as _, CommunityPoolDeposit};

#[async_trait]
impl ActionHandler for CommunityPoolDeposit {
    type CheckStatelessContext = ();
    async fn check_stateless(&self, _context: ()) -> Result<()> {
        // Any deposit into the Community Pool is valid.
        Ok(())
    }

    async fn check_and_execute<S: StateWrite>(&self, mut state: S) -> Result<()> {
        state.community_pool_deposit(self.value).await
    }
}