chik_sdk_types/puzzles/
revocation.rs1use std::borrow::Cow;
2
3use chik_protocol::Bytes32;
4use chik_puzzles::{REVOCATION_LAYER, REVOCATION_LAYER_HASH};
5use klvm_traits::{FromKlvm, ToKlvm};
6use klvm_utils::TreeHash;
7
8use crate::Mod;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, ToKlvm, FromKlvm)]
11#[klvm(curry)]
12pub struct RevocationArgs {
13 pub mod_hash: Bytes32,
14 pub hidden_puzzle_hash: Bytes32,
15 pub inner_puzzle_hash: Bytes32,
16}
17
18impl RevocationArgs {
19 pub fn new(hidden_puzzle_hash: Bytes32, inner_puzzle_hash: Bytes32) -> Self {
20 Self {
21 mod_hash: REVOCATION_LAYER_HASH.into(),
22 hidden_puzzle_hash,
23 inner_puzzle_hash,
24 }
25 }
26}
27
28impl Mod for RevocationArgs {
29 fn mod_reveal() -> Cow<'static, [u8]> {
30 Cow::Borrowed(&REVOCATION_LAYER)
31 }
32
33 fn mod_hash() -> TreeHash {
34 TreeHash::new(REVOCATION_LAYER_HASH)
35 }
36}
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq, ToKlvm, FromKlvm)]
39#[klvm(list)]
40pub struct RevocationSolution<P, S> {
41 pub hidden: bool,
42 pub puzzle: P,
43 pub solution: S,
44}
45
46impl<P, S> RevocationSolution<P, S> {
47 pub fn new(hidden: bool, puzzle: P, solution: S) -> Self {
48 Self {
49 hidden,
50 puzzle,
51 solution,
52 }
53 }
54}