essential_types/lib.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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#![forbid(unsafe_code)]
#![deny(missing_docs)]
//! # Common types for Essential Chain.
use ::serde::{Deserialize, Serialize};
use core::time::Duration;
#[cfg(feature = "schema")]
use schemars::JsonSchema;
use solution::Solution;
pub mod contract;
pub mod convert;
pub mod fmt;
pub mod predicate;
pub mod serde;
pub mod solution;
/// Constraint code serialized as json.
pub type ConstraintBytecode = Vec<u8>;
/// State read code serialized as json.
pub type StateReadBytecode = Vec<u8>;
/// Single unit of data.
pub type Word = i64;
/// Key for data.
pub type Key = Vec<Word>;
/// The data at a key.
pub type Value = Vec<Word>;
/// Hash encoded as a 32 byte array.
pub type Hash = [u8; 32];
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
/// Recoverable ECDSA signature over some data.
pub struct Signature(
/// Compact signature
pub [u8; 64],
/// ID used for public key recovery
pub u8,
);
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
/// Content address of a predicate or contract.
pub struct ContentAddress(pub Hash);
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
/// Address of a predicate.
pub struct PredicateAddress {
/// Content address of the contract with which this predicate was deployed.
///
/// This is equal to `essential_hash::content_addr(predicate_addresses)`,
/// where `predicate_addresses` is a `&[ContentAddress]` sorted by the
/// `ContentAddress` `Ord` implementation.
pub contract: ContentAddress,
/// Content address of the predicate.
///
/// This is equal to `essential_hash::content_addr(predicate)` where `predicate`
/// is a [`&Predicate`][predicate::Predicate].
pub predicate: ContentAddress,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
/// A protocol block.
pub struct Block {
/// The block number.
pub number: Word,
/// The timestamp of the block.
pub timestamp: Duration,
/// The solutions in the the block.
pub solutions: Vec<Solution>,
}