mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 08:21:05 +00:00
Fixes
This commit is contained in:
@@ -422,9 +422,16 @@ mod tests {
|
||||
|
||||
pub struct MockExec;
|
||||
impl ExecuteXcm<Call> for MockExec {
|
||||
type Prepared = Weightless;
|
||||
|
||||
fn prepare(message: Xcm<()>) -> Result<Self::Prepared, Xcm<Call>> {
|
||||
Err(message)
|
||||
}
|
||||
|
||||
fn execute_xcm_in_credit(
|
||||
_origin: impl Into<MultiLocation>,
|
||||
message: Xcm,
|
||||
_hash: XcmHash,
|
||||
weight_limit: Weight,
|
||||
_credit: Weight,
|
||||
) -> Outcome {
|
||||
@@ -442,6 +449,10 @@ mod tests {
|
||||
TRACE.with(|q| q.borrow_mut().push((message, o.clone())));
|
||||
o
|
||||
}
|
||||
|
||||
fn charge_fees(_location: impl Into<MultiLocation>, _fees: MultiAssets) -> XcmResult {
|
||||
Err(XcmError::Unimplemented)
|
||||
}
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
|
||||
@@ -13,6 +13,7 @@ scale-info = { version = "2.0.0", default-features = false, features = ["derive"
|
||||
# Substrate
|
||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
@@ -30,7 +31,6 @@ frame-benchmarking = { default-features = false, optional = true, git = "https:/
|
||||
|
||||
# Substrate
|
||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||
|
||||
# Polkadot
|
||||
@@ -48,6 +48,7 @@ std = [
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"log/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"xcm-executor/std",
|
||||
|
||||
@@ -1079,26 +1079,41 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
|
||||
|
||||
/// Xcm sender for sending to a sibling parachain.
|
||||
impl<T: Config> SendXcm for Pallet<T> {
|
||||
fn send_xcm(dest: impl Into<MultiLocation>, msg: Xcm<()>) -> SendResult {
|
||||
let dest = dest.into();
|
||||
type Ticket = (ParaId, VersionedXcm<()>);
|
||||
|
||||
match &dest {
|
||||
fn validate(
|
||||
dest: &mut Option<MultiLocation>,
|
||||
msg: &mut Option<Xcm<()>>,
|
||||
) -> SendResult<(ParaId, VersionedXcm<()>)> {
|
||||
let d = dest.take().ok_or(SendError::MissingArgument)?;
|
||||
let xcm = msg.take().ok_or(SendError::MissingArgument)?;
|
||||
|
||||
match &d {
|
||||
// An HRMP message for a sibling parachain.
|
||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&dest, msg)
|
||||
let versioned_xcm = T::VersionWrapper::wrap_version(&d, xcm)
|
||||
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||
let hash = T::Hashing::hash_of(&versioned_xcm);
|
||||
Self::send_fragment(
|
||||
(*id).into(),
|
||||
XcmpMessageFormat::ConcatenatedVersionedXcm,
|
||||
versioned_xcm,
|
||||
)
|
||||
.map_err(|e| SendError::Transport(<&'static str>::from(e)))?;
|
||||
Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
|
||||
Ok(hash)
|
||||
Ok(((*id).into(), versioned_xcm))
|
||||
},
|
||||
// Anything else is unhandled. This includes a message this is meant for us.
|
||||
_ => Err(SendError::CannotReachDestination(dest, msg)),
|
||||
_ => {
|
||||
*dest = Some(d);
|
||||
Err(SendError::NotApplicable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn deliver((id, xcm): (ParaId, VersionedXcm<()>)) -> Result<XcmHash, SendError> {
|
||||
let hash = xcm.using_encoded(sp_io::hashing::blake2_256);
|
||||
|
||||
match Self::send_fragment(id, XcmpMessageFormat::ConcatenatedVersionedXcm, xcm) {
|
||||
Ok(_) => {
|
||||
Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
|
||||
Ok(hash)
|
||||
}
|
||||
Err(e) => {
|
||||
Err(SendError::Transport(<&'static str>::from(e)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user