From 6aa15fef40a0c576a04a7647081de256bfea2128 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 18 Oct 2024 19:17:17 +0300 Subject: [PATCH 1/6] improved TrustedQueryAPI signatures --- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 6 ++++-- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 ++++-- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 6 ++++-- .../runtimes/collectives/collectives-westend/src/lib.rs | 6 ++++-- .../runtimes/contracts/contracts-rococo/src/lib.rs | 6 ++++-- .../parachains/runtimes/coretime/coretime-rococo/src/lib.rs | 6 ++++-- .../runtimes/coretime/coretime-westend/src/lib.rs | 6 ++++-- cumulus/parachains/runtimes/people/people-rococo/src/lib.rs | 6 ++++-- .../parachains/runtimes/people/people-westend/src/lib.rs | 6 ++++-- 9 files changed, 36 insertions(+), 18 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index 74e75ebb48901..c56c33d36a7e7 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1148,6 +1148,8 @@ pub type Executive = frame_executive::Executive< Migrations, >; +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1896,10 +1898,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index cafd2b33fa815..46638c1f4d835 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -618,6 +618,8 @@ pub type BridgeRococoBulletinMessages = BridgePolkadotBulletinMessages; /// Proper alias for bridge messages pallet used to bridge with the bulletin chain. pub type XcmOverRococoBulletin = XcmOverPolkadotBulletin; +type XcmTrustedQueryResult = Result; + bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { RuntimeCall, AccountId, // Grandpa @@ -1523,10 +1525,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index a18fc8accc9d9..e09c365f27dad 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -585,6 +585,8 @@ bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { BridgeRococoMessages } +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1339,10 +1341,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index b516c264e9183..1e387dd661a75 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -770,6 +770,8 @@ pub type Executive = frame_executive::Executive< Migrations, >; +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1167,10 +1169,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index 6f79780dc17b6..2eccb62b1b98b 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -430,6 +430,8 @@ construct_runtime!( } ); +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -881,10 +883,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index d34689deed66c..6b99994b92f91 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -628,6 +628,8 @@ construct_runtime!( } ); +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1150,10 +1152,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index c3516df9aa147..4277e1fedf0a2 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -620,6 +620,8 @@ construct_runtime!( } ); +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1143,10 +1145,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index b2883a2bbf93e..9ddd24e4e6b7c 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -574,6 +574,8 @@ construct_runtime!( } ); +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1061,10 +1063,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index f4f2c1ac22bc1..9105f8977b81d 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -573,6 +573,8 @@ construct_runtime!( } ); +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1060,10 +1062,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } From e5c1b8cf633b5bfdf17e77adbc72a99bc900cf46 Mon Sep 17 00:00:00 2001 From: ndk Date: Fri, 18 Oct 2024 19:29:24 +0300 Subject: [PATCH 2/6] Added PRdoc and a missing runtime --- .../runtimes/testing/penpal/src/lib.rs | 6 ++-- prdoc/pr_6129.prdoc | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 prdoc/pr_6129.prdoc diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index 917b3b04a764a..b71681c72dd76 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -803,6 +803,8 @@ construct_runtime!( } ); +type XcmTrustedQueryResult = Result; + #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1145,10 +1147,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/prdoc/pr_6129.prdoc b/prdoc/pr_6129.prdoc new file mode 100644 index 0000000000000..0ab4f55f1fc02 --- /dev/null +++ b/prdoc/pr_6129.prdoc @@ -0,0 +1,36 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: "Improved TrustedQueryAPI signatures." + +doc: + - audience: Runtime Dev + description: | + + + - audience: Runtime User + description: | + Changed returned type of API methods from `Result` to a typed one: + `type XcmTrustedQueryResult = Result` + +crates: + - name: asset-hub-westend-runtime + bump: patch + - name: bridge-hub-rococo-runtime + bump: patch + - name: bridge-hub-westend-runtime + bump: patch + - name: collectives-westend-runtime + bump: patch + - name: contracts-rococo-runtime + bump: patch + - name: coretime-rococo-runtime + bump: patch + - name: coretime-westend-runtime + bump: patch + - name: people-rococo-runtime + bump: patch + - name: people-westend-runtime + bump: patch + - name: penpal-runtime + bump: patch From d492e95c865d23f0db07ecf1b163436940edb113 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 10:45:19 +0300 Subject: [PATCH 3/6] moved XcmTrustedQueryResult type to API declaration --- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 6 ++---- .../runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs | 6 ++---- .../runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs | 6 ++---- .../runtimes/collectives/collectives-westend/src/lib.rs | 6 ++---- .../runtimes/contracts/contracts-rococo/src/lib.rs | 6 ++---- .../parachains/runtimes/coretime/coretime-rococo/src/lib.rs | 6 ++---- .../runtimes/coretime/coretime-westend/src/lib.rs | 6 ++---- cumulus/parachains/runtimes/people/people-rococo/src/lib.rs | 6 ++---- .../parachains/runtimes/people/people-westend/src/lib.rs | 6 ++---- cumulus/parachains/runtimes/testing/penpal/src/lib.rs | 6 ++---- polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs | 6 ++++-- 11 files changed, 24 insertions(+), 42 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index c56c33d36a7e7..81fa633f2ebc0 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1148,8 +1148,6 @@ pub type Executive = frame_executive::Executive< Migrations, >; -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1898,10 +1896,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs index 46638c1f4d835..c21c707f0af6f 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs @@ -618,8 +618,6 @@ pub type BridgeRococoBulletinMessages = BridgePolkadotBulletinMessages; /// Proper alias for bridge messages pallet used to bridge with the bulletin chain. pub type XcmOverRococoBulletin = XcmOverPolkadotBulletin; -type XcmTrustedQueryResult = Result; - bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { RuntimeCall, AccountId, // Grandpa @@ -1525,10 +1523,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs index e09c365f27dad..c86b045fc69eb 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/lib.rs @@ -585,8 +585,6 @@ bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! { BridgeRococoMessages } -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1341,10 +1339,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs index 1e387dd661a75..40642e62f0c55 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/lib.rs @@ -770,8 +770,6 @@ pub type Executive = frame_executive::Executive< Migrations, >; -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1169,10 +1167,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs index 2eccb62b1b98b..aa9704d8e1238 100644 --- a/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/contracts/contracts-rococo/src/lib.rs @@ -430,8 +430,6 @@ construct_runtime!( } ); -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -883,10 +881,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs index 6b99994b92f91..9eb3993fb9d47 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-rococo/src/lib.rs @@ -628,8 +628,6 @@ construct_runtime!( } ); -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1152,10 +1150,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs index 4277e1fedf0a2..2997c3de4f952 100644 --- a/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/coretime/coretime-westend/src/lib.rs @@ -620,8 +620,6 @@ construct_runtime!( } ); -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1145,10 +1143,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs index 9ddd24e4e6b7c..fff3118a7b5f1 100644 --- a/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-rococo/src/lib.rs @@ -574,8 +574,6 @@ construct_runtime!( } ); -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1063,10 +1061,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs index 9105f8977b81d..93c56b34c7a34 100644 --- a/cumulus/parachains/runtimes/people/people-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/people/people-westend/src/lib.rs @@ -573,8 +573,6 @@ construct_runtime!( } ); -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1062,10 +1060,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs index b71681c72dd76..f6b94dac9f431 100644 --- a/cumulus/parachains/runtimes/testing/penpal/src/lib.rs +++ b/cumulus/parachains/runtimes/testing/penpal/src/lib.rs @@ -803,8 +803,6 @@ construct_runtime!( } ); -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1147,10 +1145,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } diff --git a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs index a0c4416c8318b..7547571136eea 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs @@ -20,6 +20,8 @@ use codec::{Decode, Encode}; use frame_support::pallet_prelude::TypeInfo; use xcm::{VersionedAsset, VersionedLocation}; +pub type XcmTrustedQueryResult = Result; + sp_api::decl_runtime_apis! { // API for querying trusted reserves and trusted teleporters. pub trait TrustedQueryApi { @@ -28,13 +30,13 @@ sp_api::decl_runtime_apis! { /// # Arguments /// * `asset`: `VersionedAsset`. /// * `location`: `VersionedLocation`. - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result; + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult; /// Returns if the asset can be teleported to the location. /// /// # Arguments /// * `asset`: `VersionedAsset`. /// * `location`: `VersionedLocation`. - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result; + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult; } } From 168415da82315e52f91ed65c22876128ce248cd0 Mon Sep 17 00:00:00 2001 From: ndk Date: Mon, 21 Oct 2024 10:46:39 +0300 Subject: [PATCH 4/6] refactored AH-Rococo API --- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index eb3e26764f69a..4babcacaa12e7 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1098,8 +1098,6 @@ pub type Executive = frame_executive::Executive< Migrations, >; -type XcmTrustedQueryResult = Result; - #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( @@ -1802,10 +1800,10 @@ impl_runtime_apis! { } impl xcm_runtime_apis::trusted_query::TrustedQueryApi for Runtime { - fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_reserve(asset, location) } - fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult { + fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> xcm_runtime_apis::trusted_query::XcmTrustedQueryResult { PolkadotXcm::is_trusted_teleporter(asset, location) } } From a69905b9f6989bf0b49e9b78f86c004f5326e5fa Mon Sep 17 00:00:00 2001 From: Andrii Date: Mon, 21 Oct 2024 12:28:01 +0300 Subject: [PATCH 5/6] Documented XcmTrustedQueryResult public type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs index 7547571136eea..e75af54ad2fd4 100644 --- a/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs +++ b/polkadot/xcm/xcm-runtime-apis/src/trusted_query.rs @@ -20,6 +20,7 @@ use codec::{Decode, Encode}; use frame_support::pallet_prelude::TypeInfo; use xcm::{VersionedAsset, VersionedLocation}; +/// Result of [`TrustedQueryApi`] functions. pub type XcmTrustedQueryResult = Result; sp_api::decl_runtime_apis! { From 582f366bdfc581a8fb128465bd472d293c526517 Mon Sep 17 00:00:00 2001 From: Adrian Catangiu Date: Mon, 21 Oct 2024 16:01:58 +0300 Subject: [PATCH 6/6] Update prdoc/pr_6129.prdoc --- prdoc/pr_6129.prdoc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/prdoc/pr_6129.prdoc b/prdoc/pr_6129.prdoc index 0ab4f55f1fc02..61719c213e8d5 100644 --- a/prdoc/pr_6129.prdoc +++ b/prdoc/pr_6129.prdoc @@ -6,10 +6,6 @@ title: "Improved TrustedQueryAPI signatures." doc: - audience: Runtime Dev description: | - - - - audience: Runtime User - description: | Changed returned type of API methods from `Result` to a typed one: `type XcmTrustedQueryResult = Result`