datalayer_driver/
types.rs

1pub use crate::xch_server_coin::XchServerCoin;
2use crate::DataStore;
3use chia::bls::{PublicKey, SecretKey};
4pub use chia::protocol::*;
5pub use chia::puzzles::{EveProof, LineageProof, Proof};
6use chia_wallet_sdk::coinset::CoinRecord;
7
8pub struct SimulatorPuzzle {
9    pub puzzle_hash: Bytes32,
10    pub puzzle_reveal: Program,
11}
12
13pub struct BlsPair {
14    pub sk: SecretKey,
15    pub pk: PublicKey,
16    pub puzzle_hash: Bytes32,
17}
18
19#[derive(Clone, Debug)]
20pub struct SuccessResponse {
21    pub coin_spends: Vec<CoinSpend>,
22    pub new_datastore: DataStore,
23}
24
25pub struct UnspentCoinsResponse {
26    pub coins: Vec<Coin>,
27    pub last_height: u32,
28    pub last_header_hash: Bytes32,
29}
30
31impl From<UnspentCoinStates> for UnspentCoinsResponse {
32    fn from(unspent_coin_states: UnspentCoinStates) -> Self {
33        Self {
34            coins: unspent_coin_states
35                .coin_states
36                .into_iter()
37                .map(|cs| cs.coin)
38                .collect(),
39            last_height: unspent_coin_states.last_height,
40            last_header_hash: unspent_coin_states.last_header_hash,
41        }
42    }
43}
44
45pub struct UnspentCoinStates {
46    pub coin_states: Vec<CoinState>,
47    pub last_height: u32,
48    pub last_header_hash: Bytes32,
49}
50pub fn coin_records_to_states(coin_records: Vec<CoinRecord>) -> Vec<CoinState> {
51    coin_records
52        .into_iter()
53        .map(|coin_record| CoinState {
54            coin: coin_record.coin,
55            spent_height: Some(coin_record.spent_block_index),
56            created_height: Some(coin_record.confirmed_block_index),
57        })
58        .collect()
59}