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
impl Genesis
Sourcepub fn to_operation(&self, contract_id: ContractId) -> Operation
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.
Sourcepub fn opid(&self, contract_id: ContractId) -> Opid
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<'de> Deserialize<'de> for Genesis
impl<'de> Deserialize<'de> for Genesis
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Genesis, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Genesis, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Genesis
impl Serialize for Genesis
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl StrictDecode for Genesis
impl StrictDecode for Genesis
fn strict_decode(reader: &mut impl TypedRead) -> Result<Genesis, DecodeError>
fn strict_read(reader: impl ReadRaw) -> Result<Self, DecodeError>
Source§impl StrictDumb for Genesis
impl StrictDumb for Genesis
fn strict_dumb() -> Genesis
Source§impl StrictEncode for Genesis
impl StrictEncode for Genesis
fn strict_encode<W>(&self, writer: W) -> Result<W, Error>where
W: TypedWrite,
fn strict_write(&self, writer: impl WriteRaw) -> Result<(), Error>
Source§impl StrictStruct for Genesis
impl StrictStruct for Genesis
const ALL_FIELDS: &'static [&'static str]
fn strict_check_fields()
fn strict_type_info() -> TypeInfo<Self>
Source§impl StrictType for Genesis
impl StrictType for Genesis
const STRICT_LIB_NAME: &'static str = LIB_NAME_ULTRASONIC
fn strict_name() -> Option<TypeName>
impl Eq for Genesis
impl StrictProduct 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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.