ergo_lib_wasm/
header.rs

1//! Block header with the current `spendingTransaction`, that can be predicted by a miner before it's formation
2use wasm_bindgen::prelude::*;
3
4extern crate derive_more;
5use derive_more::{From, Into};
6
7use crate::block_header::BlockHeader;
8
9/// Block header with the current `spendingTransaction`, that can be predicted
10/// by a miner before it's formation
11#[wasm_bindgen]
12#[derive(PartialEq, Eq, Debug, Clone, From, Into)]
13pub struct PreHeader(ergo_lib::ergo_chain_types::PreHeader);
14
15#[wasm_bindgen]
16impl PreHeader {
17    /// Create using data from block header
18    pub fn from_block_header(block_header: BlockHeader) -> Self {
19        let bh: ergo_lib::ergo_chain_types::Header = block_header.into();
20        let ph: ergo_lib::ergo_chain_types::PreHeader = bh.into();
21        ph.into()
22    }
23}