Struct Genesis

Source
pub struct Genesis {
    pub version: ReservedBytes<1>,
    pub codex_id: CodexId,
    pub call_id: u16,
    pub nonce: fe256,
    pub blank0: ReservedBytes<1>,
    pub blank1: ReservedBytes<2>,
    pub blank2: ReservedBytes<2>,
    pub destructible_out: Confined<Vec<StateCell>, amplify::::collection::confinement::SmallVec::{constant#0}, amplify::::collection::confinement::SmallVec::{constant#1}>,
    pub immutable_out: Confined<Vec<StateData>, amplify::::collection::confinement::SmallVec::{constant#0}, amplify::::collection::confinement::SmallVec::{constant#1}>,
}
Expand description

Contract genesis.

Contract always has a single genesis, which can be seen as a form of operation (see Genesis::to_operation). The difference between genesis and an operation lies in the fact that genesis is guaranteed to have no input. Other operations may also take no input; but genesis is the first contract operation probably having no input (otherwise being invalid), which contributes to the contract id (see ContractId).

Fields§

§version: ReservedBytes<1>

Genesis version.

§Future use

For now, the only supported version is one; thus, a ReservedBytes is used.

In the future, with more versions coming, this should be replaced with an enum, where the first byte will encode (with standard strict encoding) a version number as an enum variant. For instance,

pub enum Genesis {
    V0(GenesisV0),
    V1(GenesisV1)
}
pub struct GenesisV0 { /*...*/ }
pub struct GenesisV1 { /*...*/ }
§codex_id: CodexId

Codex id under which this genesis is created.

A usual operation contains at this place a contract id, which can’t be known at the time genesis is created (since the contract id depends on the genesis data itself).

This value is being replaced with the proper contract id inside Genesis::to_operation conversion.

§call_id: u16

Contract method this operation calls to.

§nonce: fe256

A nonce, which in genesis may be used to “mine” a vanity contract id.

§blank0: ReservedBytes<1>

Genesis doesn’t contain mn operation witness, but we have to put these reserved zero bytes (matching [StateValue:None]) in order to have Genesis serialized the same way as an Operation.

§blank1: ReservedBytes<2>

Genesis doesn’t contain input, but we have to put these reserved zero bytes (matching zero length inpyt) in order to have Genesis serialized the same way as an Operation.

§blank2: ReservedBytes<2>

Genesis doesn’t contain input, but we have to put these reserved zero bytes (matching zero length inpyt) in order to have Genesis serialized the same way as an Operation.

§destructible_out: Confined<Vec<StateCell>, amplify::::collection::confinement::SmallVec::{constant#0}, amplify::::collection::confinement::SmallVec::{constant#1}>

A list of the state for the new destructible memory cells which are created at the contract genesis (read-once, access-controlled).

The list may be empty.

§immutable_out: Confined<Vec<StateData>, amplify::::collection::confinement::SmallVec::{constant#0}, amplify::::collection::confinement::SmallVec::{constant#1}>

A list of the state for the new Immutable memory cells, which are created at the contract genesis (write-once, readable by all).

The list may be empty.

Implementations§

Source§

impl Genesis

Source

pub fn to_operation(&self, contract_id: ContractId) -> Operation

Converts genesis into an operation.

Used for verification when genesis and other operations must have the same form.

Source

pub fn opid(&self, contract_id: ContractId) -> Opid

Returns operation id for the genesis.

The genesis operation id is computed by converting genesis into an operation with Self::to_operation method and then computing the Opid for it.

The method call re-computed the id by hashing all the operation data, thus it is computationally-expensive, and the received value should be cached.

Trait Implementations§

Source§

impl Clone for Genesis

Source§

fn clone(&self) -> Genesis

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Genesis

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Genesis

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Genesis, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Genesis

Source§

fn eq(&self, other: &Genesis) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Genesis

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StrictDecode for Genesis

Source§

impl StrictDumb for Genesis

Source§

impl StrictEncode for Genesis

Source§

fn strict_encode<W>(&self, writer: W) -> Result<W, Error>
where W: TypedWrite,

Source§

fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>

Source§

impl StrictStruct for Genesis

Source§

impl StrictType for Genesis

Source§

const STRICT_LIB_NAME: &'static str = LIB_NAME_ULTRASONIC

Source§

fn strict_name() -> Option<TypeName>

Source§

impl Eq for Genesis

Source§

impl StrictProduct for Genesis

Source§

impl StructuralPartialEq for Genesis

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> VerifyEq for T
where T: Eq,

Source§

fn verify_eq(&self, other: &T) -> bool

Verifies commit-equivalence of two instances of the same type.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,