chia_sdk_driver/primitives/nft/
did_owner.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use chia_protocol::Bytes32;
use clvm_utils::ToTreeHash;

use crate::DidInfo;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct DidOwner {
    pub did_id: Bytes32,
    pub inner_puzzle_hash: Bytes32,
}

impl DidOwner {
    pub fn new(did_id: Bytes32, inner_puzzle_hash: Bytes32) -> Self {
        Self {
            did_id,
            inner_puzzle_hash,
        }
    }

    pub fn from_did_info<M>(did_info: &DidInfo<M>) -> Self
    where
        M: ToTreeHash,
    {
        Self {
            did_id: did_info.launcher_id,
            inner_puzzle_hash: did_info.inner_puzzle_hash().into(),
        }
    }
}