diff --git a/runtime/common/Cargo.toml b/runtime/common/Cargo.toml index 35d8529295..7fd4b90c5c 100644 --- a/runtime/common/Cargo.toml +++ b/runtime/common/Cargo.toml @@ -160,6 +160,7 @@ runtime-benchmarks = [ "pallet-xcm/runtime-benchmarks", "pallet-moonbeam-lazy-migrations/runtime-benchmarks", "moonbeam-xcm-benchmarks/runtime-benchmarks", + "xcm-runtime-apis/runtime-benchmarks", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index f2997e6e6c..bec70b2017 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -765,6 +765,42 @@ macro_rules! impl_runtime_apis_plus_common { } } + impl xcm_runtime_apis::dry_run::DryRunApi for Runtime { + fn dry_run_call( + origin: OriginCaller, + call: RuntimeCall + ) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_call::< + Runtime, + xcm_config::XcmRouter, + OriginCaller, + RuntimeCall>(origin, call) + } + + fn dry_run_xcm( + origin_location: VersionedLocation, + xcm: VersionedXcm + ) -> Result, XcmDryRunApiError> { + PolkadotXcm::dry_run_xcm::< + Runtime, + xcm_config::XcmRouter, + RuntimeCall, + xcm_config::XcmExecutorConfig>(origin_location, xcm) + } + } + + impl xcm_runtime_apis::conversions::LocationToAccountApi for Runtime { + fn convert_location(location: VersionedLocation) -> Result< + AccountId, + xcm_runtime_apis::conversions::Error + > { + xcm_runtime_apis::conversions::LocationToAccountHelper::< + AccountId, + xcm_config::LocationToAccountId, + >::convert_location(location) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { diff --git a/runtime/moonbase/Cargo.toml b/runtime/moonbase/Cargo.toml index 4127271ddb..160d5387f0 100644 --- a/runtime/moonbase/Cargo.toml +++ b/runtime/moonbase/Cargo.toml @@ -395,6 +395,7 @@ runtime-benchmarks = [ "session-keys-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", + "xcm-runtime-apis/runtime-benchmarks", ] try-runtime = [ diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 7b9bca4585..797ec5c203 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -120,7 +120,13 @@ use sp_std::{ use sp_version::NativeVersion; use sp_version::RuntimeVersion; use xcm::{VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}; -use xcm_runtime_apis::fees::Error as XcmPaymentApiError; +//use xcm_runtime_apis::fees::Error as XcmPaymentApiError; + +//use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError; +use xcm_runtime_apis::{ + dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, + fees::Error as XcmPaymentApiError, +}; use smallvec::smallvec; use sp_runtime::serde::{Deserialize, Serialize}; diff --git a/runtime/moonbeam/Cargo.toml b/runtime/moonbeam/Cargo.toml index 4a34f57b12..c52ea28aeb 100644 --- a/runtime/moonbeam/Cargo.toml +++ b/runtime/moonbeam/Cargo.toml @@ -379,6 +379,7 @@ runtime-benchmarks = [ "session-keys-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", + "xcm-runtime-apis/runtime-benchmarks", ] try-runtime = [ diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs index 4154f2367d..6a288e88e0 100644 --- a/runtime/moonbeam/src/lib.rs +++ b/runtime/moonbeam/src/lib.rs @@ -99,7 +99,13 @@ use sp_runtime::{ }; use sp_std::{convert::TryFrom, prelude::*}; use xcm::{VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}; -use xcm_runtime_apis::fees::Error as XcmPaymentApiError; +//use xcm_runtime_apis::fees::Error as XcmPaymentApiError; + +//use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError; +use xcm_runtime_apis::{ + dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, + fees::Error as XcmPaymentApiError, +}; #[cfg(feature = "std")] use sp_version::NativeVersion; diff --git a/runtime/moonriver/Cargo.toml b/runtime/moonriver/Cargo.toml index 8676640689..1347ed8ca9 100644 --- a/runtime/moonriver/Cargo.toml +++ b/runtime/moonriver/Cargo.toml @@ -384,6 +384,7 @@ runtime-benchmarks = [ "session-keys-primitives/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", + "xcm-runtime-apis/runtime-benchmarks", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs index 5467a3ee85..3059791b05 100644 --- a/runtime/moonriver/src/lib.rs +++ b/runtime/moonriver/src/lib.rs @@ -99,7 +99,13 @@ use sp_runtime::{ }; use sp_std::{convert::TryFrom, prelude::*}; use xcm::{VersionedAssetId, VersionedAssets, VersionedLocation, VersionedXcm}; -use xcm_runtime_apis::fees::Error as XcmPaymentApiError; +//use xcm_runtime_apis::fees::Error as XcmPaymentApiError; + +//use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError; +use xcm_runtime_apis::{ + dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects}, + fees::Error as XcmPaymentApiError, +}; use smallvec::smallvec; #[cfg(feature = "std")]