Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime {
    pub spec_version: u32,
    pub transaction_version: u32,
    pub ss58_format: u16,
    pub is_v15: bool,
    pub metadata_bytes: Vec<u8>,
    pub types: PortableRegistry,
    pub pallets: Vec<PalletInfo>,
    pub extrinsic: ExtrinsicInfo,
    pub apis: Vec<RuntimeApiInfo>,
    pub outer_event_type: Option<u32>,
    /* private fields */
}
Expand description

One runtime’s complete metadata view.

Fields§

§spec_version: u32§transaction_version: u32§ss58_format: u16§is_v15: bool§metadata_bytes: Vec<u8>

The raw MetadataVersioned blob this was parsed from (fed to the RFC-0078 digest without re-downloading).

§types: PortableRegistry§pallets: Vec<PalletInfo>§extrinsic: ExtrinsicInfo§apis: Vec<RuntimeApiInfo>§outer_event_type: Option<u32>

The outer RuntimeEvent enum type id (drives the flattened event shape).

Implementations§

Source§

impl Runtime

Source

pub fn decode_batch( &self, type_strings: &[String], datas: &[Vec<u8>], ) -> Result<Vec<Value>, CoreError>

Decode a batch of (type string, SCALE bytes) pairs. Consecutive duplicate type strings (the common case: one storage item’s page) resolve to a spec once.

Source

pub fn decode_map_page( &self, entry: &StorageInfo, raw_keys: &[Vec<u8>], raw_values: &[Vec<u8>], fixed: usize, ) -> Result<Vec<DecodedPair>, CoreError>

Decode one page of a storage map: recover the free key components from each full storage key (fixed leading params were part of the queried prefix) and decode each value.

Source

pub fn decode_map_changes( &self, entry: &StorageInfo, changes: &[(String, Option<String>)], fixed: usize, ) -> Result<Vec<DecodedPair>, CoreError>

Like Runtime::decode_map_page, but takes the raw state_queryStorageAt change tuples (0x-hex key/value strings; None values — keys deleted between the key listing and the value fetch — are skipped), so hex parsing also runs in the parallel section.

Source§

impl Runtime

Source

pub fn decode_spec( &self, spec: &TypeSpec, data: &[u8], strict: bool, ) -> Result<Value, CoreError>

Decode data as the given type spec; errors on trailing bytes when strict.

Source

pub fn decode_value( &self, spec: &TypeSpec, cursor: &mut Cursor<'_>, ) -> Result<Value, CoreError>

Source

pub fn decode_id( &self, id: u32, cursor: &mut Cursor<'_>, ) -> Result<Value, CoreError>

Decode one registry type. The special cases (paths with pinned renderings) come before the structural rules.

Source

pub fn decode_call_value( &self, cursor: &mut Cursor<'_>, ) -> Result<Value, CoreError>

The runtime’s outer Call in cyscale’s metadata-aware shape: {call_index, call_function, call_module, call_args: [{name, type, value}], call_hash}.

Source§

impl Runtime

Source

pub fn encode_spec( &self, spec: &TypeSpec, value: &Value, ) -> Result<Vec<u8>, CoreError>

Source

pub fn encode_value( &self, spec: &TypeSpec, value: &Value, out: &mut Vec<u8>, ) -> Result<(), CoreError>

Source

pub fn encode_id( &self, id: u32, value: &Value, out: &mut Vec<u8>, ) -> Result<(), CoreError>

Source

pub fn encode_era_value( &self, value: &Value, out: &mut Vec<u8>, ) -> Result<(), CoreError>

Era inputs: "00" (immortal), 0/None-like handled by caller, or {"period": N, "current": M} / {"period": N, "phase": P}.

Source

pub fn coerce_account_id(&self, value: &Value) -> Result<[u8; 32], CoreError>

Coerce the seam’s account-id inputs to raw key bytes: ss58 strings, 0x-hex strings, or raw 32 bytes.

Source

pub fn compose_call( &self, pallet: &str, function: &str, params: &Value, ) -> Result<Vec<u8>, CoreError>

Compose a call: (pallet, function, params) -> raw SCALE call bytes.

Param values may embed pre-composed calls as Value::Bytes (Sudo, batches, proxies); they splice in verbatim.

Source§

impl Runtime

Source

pub fn signature_payload_parts( &self, params: &TxParams, ) -> Result<(Vec<u8>, Vec<u8>), CoreError>

The signature payload split at its wire seams: (included_in_extrinsic, included_in_signed_data). Prepending the raw call bytes gives the exact unhashed payload; hardware signers that prove the runtime on-device need the parts separately.

Source

pub fn signature_payload( &self, call_data: &[u8], params: &TxParams, ) -> Result<Vec<u8>, CoreError>

The exact bytes a signer signs for the given raw call. Payloads longer than 256 bytes are blake2b-256 hashed, per the Substrate convention.

Source

pub fn encode_signed_extrinsic( &self, call_data: &[u8], public_key: [u8; 32], signature: &[u8], signature_version: u8, params: &TxParams, ) -> Result<(Vec<u8>, [u8; 32]), CoreError>

Assemble the full signed extrinsic; returns (bytes, hash).

The metadata-hash mode must match what the payload was signed with (the digest itself is implied data and never travels in the extrinsic — set params.metadata_hash accordingly).

Source

pub fn supports_mldsa_profile(&self, profile: u8) -> bool

Detect the explicit ML-DSA registration variant on the original call. Presence of HashedAccounts alone does not imply ML-DSA support.

Source

pub fn supports_mldsa_accounts(&self) -> bool

Source

pub fn decode_extrinsic( &self, data: &[u8], strict: bool, ) -> Result<Value, CoreError>

Decode one raw extrinsic into cyscale’s plain value dict: {extrinsic_hash, extrinsic_length, [address, signature, era, nonce, tip, mode,] call}.

Source§

impl Runtime

Source

pub fn storage_key( &self, entry: &StorageInfo, params: &[Value], ) -> Result<Vec<u8>, CoreError>

The full storage key for one item; params may be a partial prefix (for map iteration).

Source

pub fn decode_storage_key_params( &self, entry: &StorageInfo, key: &[u8], fixed: usize, ) -> Result<Vec<Value>, CoreError>

Recover the free map-key components from one full storage key.

fixed is how many leading params were fixed in the queried prefix; the remaining components decode from the key’s trailing bytes (reversible hashers only).

Source§

impl Runtime

Source

pub fn type_spec(&self, type_string: &str) -> Result<TypeSpec, CoreError>

Resolve a type string to a spec, preferring structural parses over the registry name map so Vec<u8> and Option<...> always mean the same thing regardless of which names this runtime’s registry produces.

Source§

impl Runtime

Source

pub fn parse( metadata_bytes: &[u8], spec_version: u32, transaction_version: u32, ss58_format: u16, ) -> Result<Self, CoreError>

Parse a raw MetadataVersioned blob (magic meta + version byte + V14/V15 payload — what state_getMetadata / Metadata_metadata_at_version return, unwrapped).

Source

pub fn pallet(&self, name: &str) -> Option<&PalletInfo>

Source

pub fn pallet_at(&self, index: u8) -> Option<&PalletInfo>

Source

pub fn storage_entry(&self, pallet: &str, name: &str) -> Option<&StorageInfo>

Source

pub fn constant(&self, pallet: &str, name: &str) -> Option<&ConstantInfo>

Source

pub fn type_id_of(&self, name: &str) -> Option<u32>

Source

pub fn type_name_of(&self, id: u32) -> Option<&str>

Source

pub fn resolve(&self, id: u32) -> Result<&Type<PortableForm>, CoreError>

Source

pub fn type_ident(&self, id: u32) -> String

A short, human-facing identity for a registry type: the last segment of its path (e.g. “TaoBalance”, “NetUid”, “AccountId32”), with Option’s payload kept (Option<Timepoint>). Path-less types render structurally: “u64”, “Vec”, “[u8; 32]”, “(u16, u16)”, “Compact”.

This is what the codegen IR carries per call parameter, so generated builders can surface newtype identity (a TaoBalance argument vs a bare u64) even though the wire encoding is the inner value.

Source

pub fn registry_json(&self) -> Result<String, CoreError>

The portable registry as JSON ({"types": [{"id", "type": {...}}]}).

For registry-walking tooling (the shape-corpus recorder); not a hot path.

Source

pub fn module_error( &self, module_index: u8, error_index: u8, ) -> Result<(String, Vec<String>), CoreError>

{"type": "Module", "name", "docs"} inputs for a dispatch module error.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> JsonSchemaMaybe for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

Source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more