feat(xcm): support json schema (for CosmWasm VM support) (#1454)

# Description

- What does this PR do? Allows to generate JSON schema for subset of XCM
in std builds
- Why are these changes needed? To support XCM messages in CosmWasm
contracts which require Schemars to generate contract clients
- How were these changes implemented and what do they affect? We will
use schema feature flag to build XCM pallet with JSON schema enabled

# Checklist

- [x] My PR includes a detailed description as outlined in the
"Description" section above
- [x] My PR follows the [labeling requirements](CONTRIBUTING.md#Process)
of this project (at minimum one label for `T`
  required)
- [x] I have made corresponding changes to the documentation (if
applicable)
- [x] I have added tests that prove my fix is effective or that my
feature works (if applicable)
- [x] If this PR alters any external APIs or interfaces used by
Polkadot, the corresponding Polkadot PR is ready as well
  as the corresponding Cumulus PR (optional)
This commit is contained in:
dzmitry-lahoda
2023-12-07 16:40:16 +00:00
committed by GitHub
parent 1a4ab64bcb
commit 95c3ee10bc
13 changed files with 86 additions and 3 deletions
Generated
+40 -2
View File
@@ -1521,13 +1521,14 @@ dependencies = [
[[package]] [[package]]
name = "bounded-collections" name = "bounded-collections"
version = "0.1.8" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" checksum = "ca548b6163b872067dc5eb82fd130c56881435e30367d2073594a3d9744120dd"
dependencies = [ dependencies = [
"log", "log",
"parity-scale-codec", "parity-scale-codec",
"scale-info", "scale-info",
"schemars",
"serde", "serde",
] ]
@@ -16344,6 +16345,30 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "schemars"
version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161"
dependencies = [
"dyn-clone",
"schemars_derive",
"serde",
"serde_json",
]
[[package]]
name = "schemars_derive"
version = "0.8.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737"
dependencies = [
"proc-macro2",
"quote",
"serde_derive_internals",
"syn 1.0.109",
]
[[package]] [[package]]
name = "schnellru" name = "schnellru"
version = "0.2.1" version = "0.2.1"
@@ -16614,6 +16639,17 @@ dependencies = [
"syn 2.0.39", "syn 2.0.39",
] ]
[[package]]
name = "serde_derive_internals"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "serde_fmt" name = "serde_fmt"
version = "1.0.3" version = "1.0.3"
@@ -18117,6 +18153,7 @@ dependencies = [
"bounded-collections", "bounded-collections",
"parity-scale-codec", "parity-scale-codec",
"scale-info", "scale-info",
"schemars",
"serde", "serde",
"smallvec", "smallvec",
"sp-arithmetic", "sp-arithmetic",
@@ -18353,6 +18390,7 @@ dependencies = [
"log", "log",
"parity-scale-codec", "parity-scale-codec",
"scale-info", "scale-info",
"schemars",
"serde", "serde",
"sp-io", "sp-io",
"sp-weights", "sp-weights",
+3 -1
View File
@@ -7,7 +7,7 @@ edition.workspace = true
license.workspace = true license.workspace = true
[dependencies] [dependencies]
bounded-collections = { version = "0.1.8", default-features = false, features = ["serde"] } bounded-collections = { version = "0.1.9", default-features = false, features = ["serde"] }
derivative = { version = "2.2.0", default-features = false, features = ["use_core"] } derivative = { version = "2.2.0", default-features = false, features = ["use_core"] }
impl-trait-for-tuples = "0.2.2" impl-trait-for-tuples = "0.2.2"
log = { version = "0.4.17", default-features = false } log = { version = "0.4.17", default-features = false }
@@ -15,6 +15,7 @@ parity-scale-codec = { version = "3.6.1", default-features = false, features = [
scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] } scale-info = { version = "2.10.0", default-features = false, features = ["derive", "serde"] }
sp-weights = { path = "../../substrate/primitives/weights", default-features = false, features = ["serde"] } sp-weights = { path = "../../substrate/primitives/weights", default-features = false, features = ["serde"] }
serde = { version = "1.0.193", default-features = false, features = ["alloc", "derive"] } serde = { version = "1.0.193", default-features = false, features = ["alloc", "derive"] }
schemars = { version = "0.8.13", default-features = true, optional = true }
xcm-procedural = { path = "procedural" } xcm-procedural = { path = "procedural" }
environmental = { version = "1.1.4", default-features = false } environmental = { version = "1.1.4", default-features = false }
@@ -35,3 +36,4 @@ std = [
"serde/std", "serde/std",
"sp-weights/std", "sp-weights/std",
] ]
json-schema = ["bounded-collections/json-schema", "dep:schemars", "sp-weights/json-schema"]
+1
View File
@@ -25,6 +25,7 @@ use parity_scale_codec::{Decode, DecodeLimit, Encode};
#[codec(decode_bound())] #[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(T))] #[scale_info(bounds(), skip_type_params(T))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct DoubleEncoded<T> { pub struct DoubleEncoded<T> {
encoded: Vec<u8>, encoded: Vec<u8>,
#[codec(skip)] #[codec(skip)]
+1
View File
@@ -82,6 +82,7 @@ pub use traits::{Error, ExecuteXcm, GetWeight, Outcome, Result, SendError, SendR
/// Basically just the XCM (more general) version of `ParachainDispatchOrigin`. /// Basically just the XCM (more general) version of `ParachainDispatchOrigin`.
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum OriginKind { pub enum OriginKind {
/// Origin should just be the native dispatch origin representation for the sender in the /// Origin should just be the native dispatch origin representation for the sender in the
/// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin /// local runtime framework. For Cumulus/Frame chains this is the `Parachain` or `Relay` origin
+4
View File
@@ -49,6 +49,7 @@ use serde::{Deserialize, Serialize};
Serialize, Serialize,
Deserialize, Deserialize,
)] )]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum NetworkId { pub enum NetworkId {
/// Network specified by the first 32 bytes of its genesis block. /// Network specified by the first 32 bytes of its genesis block.
@@ -119,6 +120,7 @@ impl TryFrom<OldNetworkId> for NetworkId {
Serialize, Serialize,
Deserialize, Deserialize,
)] )]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum BodyId { pub enum BodyId {
/// The only body in its context. /// The only body in its context.
@@ -190,6 +192,7 @@ impl TryFrom<OldBodyId> for BodyId {
Serialize, Serialize,
Deserialize, Deserialize,
)] )]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum BodyPart { pub enum BodyPart {
/// The body's declaration, under whatever means it decides. /// The body's declaration, under whatever means it decides.
@@ -266,6 +269,7 @@ impl TryFrom<OldBodyPart> for BodyPart {
Serialize, Serialize,
Deserialize, Deserialize,
)] )]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum Junction { pub enum Junction {
/// An indexed parachain belonging to and operated by the context. /// An indexed parachain belonging to and operated by the context.
+1
View File
@@ -44,6 +44,7 @@ pub(crate) const MAX_JUNCTIONS: usize = 8;
serde::Serialize, serde::Serialize,
serde::Deserialize, serde::Deserialize,
)] )]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum Junctions { pub enum Junctions {
/// The interpreting consensus system. /// The interpreting consensus system.
+10
View File
@@ -69,6 +69,7 @@ pub type QueryId = u64;
#[codec(encode_bound())] #[codec(encode_bound())]
#[scale_info(bounds(), skip_type_params(Call))] #[scale_info(bounds(), skip_type_params(Call))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct Xcm<Call>(pub Vec<Instruction<Call>>); pub struct Xcm<Call>(pub Vec<Instruction<Call>>);
/// The maximal number of instructions in an XCM before decoding fails. /// The maximal number of instructions in an XCM before decoding fails.
@@ -232,15 +233,19 @@ pub mod prelude {
} }
parameter_types! { parameter_types! {
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub MaxPalletNameLen: u32 = 48; pub MaxPalletNameLen: u32 = 48;
/// Maximum size of the encoded error code coming from a `Dispatch` result, used for /// Maximum size of the encoded error code coming from a `Dispatch` result, used for
/// `MaybeErrorCode`. This is not (yet) enforced, so it's just an indication of expectation. /// `MaybeErrorCode`. This is not (yet) enforced, so it's just an indication of expectation.
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub MaxDispatchErrorLen: u32 = 128; pub MaxDispatchErrorLen: u32 = 128;
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub MaxPalletsInfo: u32 = 64; pub MaxPalletsInfo: u32 = 64;
} }
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct PalletInfo { pub struct PalletInfo {
#[codec(compact)] #[codec(compact)]
pub index: u32, pub index: u32,
@@ -272,6 +277,7 @@ impl PalletInfo {
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum MaybeErrorCode { pub enum MaybeErrorCode {
Success, Success,
Error(BoundedVec<u8, MaxDispatchErrorLen>), Error(BoundedVec<u8, MaxDispatchErrorLen>),
@@ -296,6 +302,7 @@ impl Default for MaybeErrorCode {
/// Response data to a query. /// Response data to a query.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo, MaxEncodedLen)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum Response { pub enum Response {
/// No response. Serves as a neutral default. /// No response. Serves as a neutral default.
Null, Null,
@@ -320,6 +327,7 @@ impl Default for Response {
/// Information regarding the composition of a query response. /// Information regarding the composition of a query response.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct QueryResponseInfo { pub struct QueryResponseInfo {
/// The destination to which the query response message should be send. /// The destination to which the query response message should be send.
pub destination: MultiLocation, pub destination: MultiLocation,
@@ -333,6 +341,7 @@ pub struct QueryResponseInfo {
/// An optional weight limit. /// An optional weight limit.
#[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)] #[derive(Clone, Eq, PartialEq, Encode, Decode, Debug, TypeInfo)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum WeightLimit { pub enum WeightLimit {
/// No weight limit imposed. /// No weight limit imposed.
Unlimited, Unlimited,
@@ -417,6 +426,7 @@ impl XcmContext {
#[codec(decode_bound())] #[codec(decode_bound())]
#[scale_info(bounds(), skip_type_params(Call))] #[scale_info(bounds(), skip_type_params(Call))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum Instruction<Call> { pub enum Instruction<Call> {
/// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding /// Withdraw asset(s) (`assets`) from the ownership of `origin` and place them into the Holding
/// Register. /// Register.
+8
View File
@@ -47,6 +47,7 @@ use scale_info::TypeInfo;
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug, TypeInfo, MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum AssetInstance { pub enum AssetInstance {
/// Undefined - used if the non-fungible asset class has only one instance. /// Undefined - used if the non-fungible asset class has only one instance.
@@ -243,6 +244,7 @@ impl TryFrom<AssetInstance> for u128 {
/// instance. /// instance.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum Fungibility { pub enum Fungibility {
/// A fungible asset; we record a number of units, as a `u128` in the inner item. /// A fungible asset; we record a number of units, as a `u128` in the inner item.
@@ -313,6 +315,7 @@ impl TryFrom<OldFungibility> for Fungibility {
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum WildFungibility { pub enum WildFungibility {
/// The asset is fungible. /// The asset is fungible.
@@ -337,6 +340,7 @@ impl TryFrom<OldWildFungibility> for WildFungibility {
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
)] )]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum AssetId { pub enum AssetId {
/// A specific location identifying an asset. /// A specific location identifying an asset.
@@ -412,6 +416,7 @@ impl AssetId {
/// Either an amount of a single fungible asset, or a single well-identified non-fungible asset. /// Either an amount of a single fungible asset, or a single well-identified non-fungible asset.
#[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub struct MultiAsset { pub struct MultiAsset {
/// The overall asset identity (aka *class*, in the case of a non-fungible). /// The overall asset identity (aka *class*, in the case of a non-fungible).
@@ -510,6 +515,7 @@ impl TryFrom<OldMultiAsset> for MultiAsset {
/// - The number of items should grow no larger than `MAX_ITEMS_IN_MULTIASSETS`. /// - The number of items should grow no larger than `MAX_ITEMS_IN_MULTIASSETS`.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, Default)] #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, TypeInfo, Default)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub struct MultiAssets(Vec<MultiAsset>); pub struct MultiAssets(Vec<MultiAsset>);
@@ -710,6 +716,7 @@ impl MultiAssets {
/// A wildcard representing a set of assets. /// A wildcard representing a set of assets.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum WildMultiAsset { pub enum WildMultiAsset {
/// All assets in Holding. /// All assets in Holding.
@@ -823,6 +830,7 @@ impl<A: Into<AssetId>, B: Into<WildFungibility>> From<(A, B)> for WildMultiAsset
/// `MultiAsset` collection, defined either by a number of `MultiAssets` or a single wildcard. /// `MultiAsset` collection, defined either by a number of `MultiAssets` or a single wildcard.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)] #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
pub enum MultiAssetFilter { pub enum MultiAssetFilter {
/// Specify the filter as being everything contained by the given `MultiAssets` inner. /// Specify the filter as being everything contained by the given `MultiAssets` inner.
+1
View File
@@ -66,6 +66,7 @@ use scale_info::TypeInfo;
serde::Serialize, serde::Serialize,
serde::Deserialize, serde::Deserialize,
)] )]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct MultiLocation { pub struct MultiLocation {
/// The number of parent junctions at the beginning of this `MultiLocation`. /// The number of parent junctions at the beginning of this `MultiLocation`.
pub parents: u8, pub parents: u8,
+1
View File
@@ -30,6 +30,7 @@ use super::*;
/// they will retain the same index over time. /// they will retain the same index over time.
#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)] #[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, Debug, TypeInfo)]
#[scale_info(replace_segment("staging_xcm", "xcm"))] #[scale_info(replace_segment("staging_xcm", "xcm"))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub enum Error { pub enum Error {
// Errors that happen due to instructions being executed. These alone are defined in the // Errors that happen due to instructions being executed. These alone are defined in the
// XCM specification. // XCM specification.
+10
View File
@@ -0,0 +1,10 @@
title: Support XCM as part of Cosmos CosmWasm contract messages
doc:
- audience: Runtime Dev
description: |
Made XCM JSON schema behind flag, bumped bounded-collection so to ensure it has that flag too.
crates:
- name: staging-xcm
- name: sp-weights
+5
View File
@@ -21,6 +21,7 @@ smallvec = "1.11.0"
sp-arithmetic = { path = "../arithmetic", default-features = false } sp-arithmetic = { path = "../arithmetic", default-features = false }
sp-debug-derive = { path = "../debug-derive", default-features = false } sp-debug-derive = { path = "../debug-derive", default-features = false }
sp-std = { path = "../std", default-features = false } sp-std = { path = "../std", default-features = false }
schemars = { version = "0.8.3", default-features = false, optional = true }
[features] [features]
default = ["std"] default = ["std"]
@@ -44,3 +45,7 @@ serde = [
"scale-info/serde", "scale-info/serde",
"sp-arithmetic/serde", "sp-arithmetic/serde",
] ]
json-schema = [
"dep:schemars",
]
@@ -23,6 +23,7 @@ use super::*;
#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Eq, PartialEq, Copy, Clone, Debug, Default)] #[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Eq, PartialEq, Copy, Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct Weight { pub struct Weight {
#[codec(compact)] #[codec(compact)]
/// The weight of computational time used based on some reference hardware. /// The weight of computational time used based on some reference hardware.