pub struct Genesis {
pub contract_id: Hash,
pub schema_id: Hash,
pub global_state: Vec<GlobalState>,
pub owned_state: Vec<OwnedState>,
pub metadata: Vec<Metadata>,
}Expand description
Contract genesis
The genesis is the root of every contract’s state history. It is referenced by the first transition and indirectly by all subsequent ones.
Fields§
§contract_id: HashUnique contract identifier (user-facing, e.g., “USDT-on-Bitcoin:1”)
schema_id: HashSchema identifier binding this genesis to a contract schema
global_state: Vec<GlobalState>Initial global state values
owned_state: Vec<OwnedState>Initial owned state assignments (e.g., initial token distribution)
metadata: Vec<Metadata>Genesis metadata (issuance date, issuer info, etc.)
Implementations§
Source§impl Genesis
impl Genesis
Sourcepub fn new(
contract_id: Hash,
schema_id: Hash,
global_state: Vec<GlobalState>,
owned_state: Vec<OwnedState>,
metadata: Vec<Metadata>,
) -> Self
pub fn new( contract_id: Hash, schema_id: Hash, global_state: Vec<GlobalState>, owned_state: Vec<OwnedState>, metadata: Vec<Metadata>, ) -> Self
Create new genesis
Sourcepub fn hash(&self) -> Hash
pub fn hash(&self) -> Hash
Compute the genesis hash
This hash serves as the root commitment for all subsequent transitions.
Sourcepub fn state_count(&self) -> usize
pub fn state_count(&self) -> usize
Get the total count of all state items
Sourcepub fn global_states_of(&self, type_id: u16) -> Vec<&GlobalState>
pub fn global_states_of(&self, type_id: u16) -> Vec<&GlobalState>
Find global states by type ID
Sourcepub fn owned_states_of(&self, type_id: u16) -> Vec<&OwnedState>
pub fn owned_states_of(&self, type_id: u16) -> Vec<&OwnedState>
Find owned states by type ID
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Genesis
impl<'de> Deserialize<'de> for Genesis
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Genesis
impl StructuralPartialEq for Genesis
Auto Trait Implementations§
impl Freeze for Genesis
impl RefUnwindSafe for Genesis
impl Send for Genesis
impl Sync for Genesis
impl Unpin for Genesis
impl UnsafeUnpin for Genesis
impl UnwindSafe for Genesis
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more