diff --git a/Cargo.lock b/Cargo.lock index f2b19a1c7..bb315db2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8747,6 +8747,7 @@ dependencies = [ "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-metadata-ir", "sp-offchain", "sp-runtime", "sp-session", @@ -13802,6 +13803,7 @@ dependencies = [ "sp-genesis-builder", "sp-inherents", "sp-io", + "sp-metadata-ir", "sp-offchain", "sp-runtime", "sp-session", diff --git a/Cargo.toml b/Cargo.toml index 7d155d834..2b43d0d93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -169,6 +169,7 @@ sp-core = { git = "https://github.com/parityt sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } +sp-metadata-ir = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" } diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 603a39fd9..570e6f900 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -59,6 +59,7 @@ sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } sp-inherents = { workspace = true } +sp-metadata-ir = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } @@ -241,6 +242,7 @@ std = [ "sp-core/std", "sp-genesis-builder/std", "sp-inherents/std", + "sp-metadata-ir/std", "sp-offchain/std", "sp-runtime/std", "sp-session/std", diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 37efef068..a88a685a5 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -54,6 +54,7 @@ mod migrations; pub use migrations::RuntimeMigrations; mod parachain; mod runtime_apis; +use runtime_apis::_InternalImplRuntimeApis; pub use runtime_apis::{api, RuntimeApi}; mod system; use sp_version::RuntimeVersion; diff --git a/runtimes/peregrine/src/runtime_apis.rs b/runtimes/peregrine/src/runtime_apis.rs index f9604f322..804f2a5e7 100644 --- a/runtimes/peregrine/src/runtime_apis.rs +++ b/runtimes/peregrine/src/runtime_apis.rs @@ -16,6 +16,7 @@ use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use sp_api::impl_runtime_apis; use sp_core::OpaqueMetadata; use sp_inherents::{CheckInherentsResult, InherentData}; +use sp_metadata_ir::RuntimeApiMetadataIR; use sp_runtime::{ traits::{Block as BlockT, TryConvert}, ApplyExtrinsicResult, KeyTypeId, @@ -53,6 +54,22 @@ use crate::{ // `impl_runtime_apis` is private. pub(crate) const RUNTIME_API_VERSION: ApisVec = RUNTIME_API_VERSIONS; +// Workaround for runtime API impls not exposed in metadata if implemented in a +// different file than the runtime's `lib.rs`. Related issue (subxt) -> https://github.com/paritytech/subxt/issues/1873. +pub(crate) trait _InternalImplRuntimeApis { + fn runtime_metadata(&self) -> Vec; +} + +impl _InternalImplRuntimeApis for T +where + T: InternalImplRuntimeApis, +{ + #[inline(always)] + fn runtime_metadata(&self) -> Vec { + ::runtime_metadata(self) + } +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index 6e4c6fe5a..55a89d797 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -59,6 +59,7 @@ sp-block-builder = { workspace = true } sp-consensus-aura = { workspace = true } sp-core = { workspace = true } sp-inherents = { workspace = true } +sp-metadata-ir = { workspace = true } sp-offchain = { workspace = true } sp-runtime = { workspace = true } sp-session = { workspace = true } @@ -240,6 +241,7 @@ std = [ "sp-core/std", "sp-genesis-builder/std", "sp-inherents/std", + "sp-metadata-ir/std", "sp-offchain/std", "sp-runtime/std", "sp-session/std", diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 76821171d..18b00b4ff 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -54,6 +54,7 @@ mod migrations; pub use migrations::RuntimeMigrations; mod parachain; mod runtime_apis; +use runtime_apis::_InternalImplRuntimeApis; pub use runtime_apis::{api, RuntimeApi}; mod system; use sp_version::RuntimeVersion; diff --git a/runtimes/spiritnet/src/runtime_apis.rs b/runtimes/spiritnet/src/runtime_apis.rs index f9604f322..804f2a5e7 100644 --- a/runtimes/spiritnet/src/runtime_apis.rs +++ b/runtimes/spiritnet/src/runtime_apis.rs @@ -16,6 +16,7 @@ use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; use sp_api::impl_runtime_apis; use sp_core::OpaqueMetadata; use sp_inherents::{CheckInherentsResult, InherentData}; +use sp_metadata_ir::RuntimeApiMetadataIR; use sp_runtime::{ traits::{Block as BlockT, TryConvert}, ApplyExtrinsicResult, KeyTypeId, @@ -53,6 +54,22 @@ use crate::{ // `impl_runtime_apis` is private. pub(crate) const RUNTIME_API_VERSION: ApisVec = RUNTIME_API_VERSIONS; +// Workaround for runtime API impls not exposed in metadata if implemented in a +// different file than the runtime's `lib.rs`. Related issue (subxt) -> https://github.com/paritytech/subxt/issues/1873. +pub(crate) trait _InternalImplRuntimeApis { + fn runtime_metadata(&self) -> Vec; +} + +impl _InternalImplRuntimeApis for T +where + T: InternalImplRuntimeApis, +{ + #[inline(always)] + fn runtime_metadata(&self) -> Vec { + ::runtime_metadata(self) + } +} + impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion {