Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved TrustedQueryAPI signatures #6129

Merged
merged 9 commits into from
Oct 21, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,8 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1896,10 +1898,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool, xcm_runtime_apis::trusted_query::Error>;

bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! {
RuntimeCall, AccountId,
// Grandpa
Expand Down Expand Up @@ -1523,10 +1525,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ bridge_runtime_common::generate_bridge_reject_obsolete_headers_and_messages! {
BridgeRococoMessages
}

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1339,10 +1341,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1167,10 +1169,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ construct_runtime!(
}
);

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -881,10 +883,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ construct_runtime!(
}
);

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1150,10 +1152,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ construct_runtime!(
}
);

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1143,10 +1145,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
6 changes: 4 additions & 2 deletions cumulus/parachains/runtimes/people/people-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ construct_runtime!(
}
);

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1061,10 +1063,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
6 changes: 4 additions & 2 deletions cumulus/parachains/runtimes/people/people-westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ construct_runtime!(
}
);

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1060,10 +1062,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
6 changes: 4 additions & 2 deletions cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,8 @@ construct_runtime!(
}
);

type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
frame_benchmarking::define_benchmarks!(
Expand Down Expand Up @@ -1145,10 +1147,10 @@ impl_runtime_apis! {
}

impl xcm_runtime_apis::trusted_query::TrustedQueryApi<Block> for Runtime {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_reserve(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_reserve(asset, location)
}
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> Result<bool, xcm_runtime_apis::trusted_query::Error> {
fn is_trusted_teleporter(asset: VersionedAsset, location: VersionedLocation) -> XcmTrustedQueryResult {
PolkadotXcm::is_trusted_teleporter(asset, location)
}
}
Expand Down
36 changes: 36 additions & 0 deletions prdoc/pr_6129.prdoc
Original file line number Diff line number Diff line change
@@ -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<bool, xcm_runtime_apis::trusted_query::Error>` to a typed one:
`type XcmTrustedQueryResult = Result<bool, xcm_runtime_apis::trusted_query::Error>`
acatangiu marked this conversation as resolved.
Show resolved Hide resolved

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
Loading