subxt_core/client.rs
1// Copyright 2019-2024 Parity Technologies (UK) Ltd.
2// This file is dual-licensed as Apache-2.0 or GPL-3.0.
3// see LICENSE for license details.
4
5//! A couple of client types that we use elsewhere.
6
7use crate::{
8 config::{Config, HashFor},
9 metadata::Metadata,
10};
11use derive_where::derive_where;
12
13/// This provides access to some relevant client state in transaction extensions,
14/// and is just a combination of some of the available properties.
15#[derive_where(Clone, Debug)]
16pub struct ClientState<C: Config> {
17 /// Genesis hash.
18 pub genesis_hash: HashFor<C>,
19 /// Runtime version.
20 pub runtime_version: RuntimeVersion,
21 /// Metadata.
22 pub metadata: Metadata,
23}
24
25/// Runtime version information needed to submit transactions.
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub struct RuntimeVersion {
28 /// Version of the runtime specification. A full-node will not attempt to use its native
29 /// runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`,
30 /// `spec_version` and `authoring_version` are the same between Wasm and native.
31 pub spec_version: u32,
32 /// All existing dispatches are fully compatible when this number doesn't change. If this
33 /// number changes, then `spec_version` must change, also.
34 ///
35 /// This number must change when an existing dispatchable (module ID, dispatch ID) is changed,
36 /// either through an alteration in its user-level semantics, a parameter
37 /// added/removed/changed, a dispatchable being removed, a module being removed, or a
38 /// dispatchable/module changing its index.
39 ///
40 /// It need *not* change when a new module is added or when a dispatchable is added.
41 pub transaction_version: u32,
42}