penumbra_sdk_community_pool/component/action_handler/
community_pool_output.rs

1use anyhow::Result;
2use async_trait::async_trait;
3use cnidarium::StateWrite;
4use cnidarium_component::ActionHandler;
5use penumbra_sdk_sct::CommitmentSource;
6use penumbra_sdk_shielded_pool::component::NoteManager;
7
8use crate::CommunityPoolOutput;
9
10#[async_trait]
11impl ActionHandler for CommunityPoolOutput {
12    type CheckStatelessContext = ();
13    async fn check_stateless(&self, _context: ()) -> Result<()> {
14        // Any output from the Community Pool is valid (it's just a transparent output).
15        Ok(())
16    }
17
18    async fn check_and_execute<S: StateWrite>(&self, mut state: S) -> Result<()> {
19        // Executing a Community Pool output is just minting a note to the recipient of the output.
20        state
21            .mint_note(
22                self.value,
23                &self.address,
24                CommitmentSource::CommunityPoolOutput,
25            )
26            .await
27    }
28}