essential_types/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3//! # Common types for Essential Chain.
4
5use ::serde::{Deserialize, Serialize};
6#[doc(inline)]
7pub use contract::Contract;
8#[doc(inline)]
9pub use predicate::{Predicate, Program};
10#[cfg(feature = "schema")]
11use schemars::JsonSchema;
12#[doc(inline)]
13pub use solution::{Solution, SolutionIndex, SolutionSet};
14
15pub mod contract;
16pub mod convert;
17pub mod fmt;
18pub mod predicate;
19pub mod serde;
20pub mod solution;
21
22/// Essential ASM encoded as bytes.
23pub type Bytecode = Vec<u8>;
24
25/// Single unit of data.
26pub type Word = i64;
27
28/// Key for data.
29pub type Key = Vec<Word>;
30
31/// The data at a key.
32pub type Value = Vec<Word>;
33
34/// Hash encoded as a 32 byte array.
35pub type Hash = [u8; 32];
36
37#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
38/// Recoverable ECDSA signature over some data.
39pub struct Signature(
40    /// Compact signature
41    pub [u8; 64],
42    /// ID used for public key recovery
43    pub u8,
44);
45
46#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
47#[cfg_attr(feature = "schema", derive(JsonSchema))]
48/// Content address of a predicate or contract.
49pub struct ContentAddress(pub Hash);
50
51#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
52#[cfg_attr(feature = "schema", derive(JsonSchema))]
53/// Address of a predicate.
54pub struct PredicateAddress {
55    /// Content address of the contract with which this predicate was deployed.
56    ///
57    /// This is equal to `essential_hash::content_addr(predicate_addresses)`,
58    /// where `predicate_addresses` is a `&[ContentAddress]` sorted by the
59    /// `ContentAddress` `Ord` implementation.
60    pub contract: ContentAddress,
61    /// Content address of the predicate.
62    ///
63    /// This is equal to `essential_hash::content_addr(predicate)` where `predicate`
64    /// is a [`&Predicate`][predicate::Predicate].
65    pub predicate: ContentAddress,
66}