chia_sdk_driver/action_system/
spendable_asset.rs1use chia_protocol::{Bytes32, Coin};
2
3use crate::{Cat, Did, Nft, OptionContract};
4
5#[derive(Debug, Clone, Copy)]
6pub enum SpendableAsset {
7 Xch(Coin),
8 Cat(Cat),
9 Did(Did),
10 Nft(Nft),
11 Option(OptionContract),
12}
13
14impl SpendableAsset {
15 pub fn p2_puzzle_hash(&self) -> Bytes32 {
16 match self {
17 Self::Xch(coin) => coin.puzzle_hash,
18 Self::Cat(cat) => cat.info.p2_puzzle_hash,
19 Self::Did(did) => did.info.p2_puzzle_hash,
20 Self::Nft(nft) => nft.info.p2_puzzle_hash,
21 Self::Option(option) => option.info.p2_puzzle_hash,
22 }
23 }
24
25 pub fn coin(&self) -> Coin {
26 match self {
27 Self::Xch(coin) => *coin,
28 Self::Cat(cat) => cat.coin,
29 Self::Did(did) => did.coin,
30 Self::Nft(nft) => nft.coin,
31 Self::Option(option) => option.coin,
32 }
33 }
34}