chia_sdk_driver/primitives/vault/
vault_launcher.rs

1use chia_puzzle_types::{EveProof, Proof};
2use chia_sdk_types::Conditions;
3use clvm_traits::ToClvm;
4use clvm_utils::TreeHash;
5use clvmr::Allocator;
6
7use crate::{DriverError, Launcher, SpendContext, VaultInfo};
8
9use super::Vault;
10
11impl Launcher {
12    pub fn mint_vault<M>(
13        self,
14        ctx: &mut SpendContext,
15        custody_hash: TreeHash,
16        memos: M,
17    ) -> Result<(Conditions, Vault), DriverError>
18    where
19        M: ToClvm<Allocator>,
20    {
21        let launcher_coin = self.coin();
22        let (conditions, coin) = self.spend(ctx, custody_hash.into(), memos)?;
23        let vault = Vault::new(
24            coin,
25            Proof::Eve(EveProof {
26                parent_parent_coin_info: launcher_coin.parent_coin_info,
27                parent_amount: launcher_coin.amount,
28            }),
29            VaultInfo::new(launcher_coin.coin_id(), custody_hash),
30        );
31        Ok((conditions, vault))
32    }
33}