Skip to content

Commit

Permalink
feat(xcm): support json schema (for CosmWasm VM support) (paritytech#…
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
dzmitry-lahoda authored Dec 7, 2023
1 parent 07f6eb6 commit 110e140
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions substrate/primitives/weights/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ smallvec = "1.11.0"
sp-arithmetic = { path = "../arithmetic", default-features = false }
sp-debug-derive = { path = "../debug-derive", default-features = false }
sp-std = { path = "../std", default-features = false }
schemars = { version = "0.8.3", default-features = false, optional = true }

[features]
default = ["std"]
Expand All @@ -44,3 +45,7 @@ serde = [
"scale-info/serde",
"sp-arithmetic/serde",
]

json-schema = [
"dep:schemars",
]
1 change: 1 addition & 0 deletions substrate/primitives/weights/src/weight_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use super::*;

#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Eq, PartialEq, Copy, Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
pub struct Weight {
#[codec(compact)]
/// The weight of computational time used based on some reference hardware.
Expand Down

0 comments on commit 110e140

Please sign in to comment.