Skip to content

Commit

Permalink
added dry run apis
Browse files Browse the repository at this point in the history
  • Loading branch information
asiniscalchi committed Feb 6, 2025
1 parent 782f39d commit 7ed7e5c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-s
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
xcm-simulator = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }
xcm-runtime-apis = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409", default-features = false }

# (native)
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2409" }
Expand Down
2 changes: 2 additions & 0 deletions runtime/laos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ polkadot-parachain-primitives = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-runtime-apis = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
Expand Down Expand Up @@ -188,6 +189,7 @@ std = [
"sp-genesis-builder/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm-runtime-apis/std",
"xcm/std",
"substrate-wasm-builder",
# Frontier
Expand Down
13 changes: 13 additions & 0 deletions runtime/laos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub mod types;
mod weights;

pub use configs::laos_evolution::REVERT_BYTECODE;
use configs::xcm_config;
use core::marker::PhantomData;
use fp_rpc::TransactionStatus;
use frame_support::{
Expand Down Expand Up @@ -58,6 +59,8 @@ use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::{VersionedLocation, VersionedXcm};
use xcm_runtime_apis::dry_run::{CallDryRunEffects, Error as XcmDryRunApiError, XcmDryRunEffects};

/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
Expand Down Expand Up @@ -635,4 +638,14 @@ impl_runtime_apis! {
Default::default()
}
}

impl xcm_runtime_apis::dry_run::DryRunApi<Block, RuntimeCall, RuntimeEvent, OriginCaller> for Runtime {
fn dry_run_call(origin: OriginCaller, call: RuntimeCall) -> Result<CallDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_call::<Runtime, xcm_config::XcmRouter, OriginCaller, RuntimeCall>(origin, call)
}

fn dry_run_xcm(origin_location: VersionedLocation, xcm: VersionedXcm<RuntimeCall>) -> Result<XcmDryRunEffects<RuntimeEvent>, XcmDryRunApiError> {
PolkadotXcm::dry_run_xcm::<Runtime, xcm_config::XcmRouter, RuntimeCall, xcm_config::XcmConfig>(origin_location, xcm)
}
}
}

0 comments on commit 7ed7e5c

Please sign in to comment.