mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-19 22:51:03 +00:00
Fixes
This commit is contained in:
@@ -422,9 +422,16 @@ mod tests {
|
|||||||
|
|
||||||
pub struct MockExec;
|
pub struct MockExec;
|
||||||
impl ExecuteXcm<Call> for 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(
|
fn execute_xcm_in_credit(
|
||||||
_origin: impl Into<MultiLocation>,
|
_origin: impl Into<MultiLocation>,
|
||||||
message: Xcm,
|
message: Xcm,
|
||||||
|
_hash: XcmHash,
|
||||||
weight_limit: Weight,
|
weight_limit: Weight,
|
||||||
_credit: Weight,
|
_credit: Weight,
|
||||||
) -> Outcome {
|
) -> Outcome {
|
||||||
@@ -442,6 +449,10 @@ mod tests {
|
|||||||
TRACE.with(|q| q.borrow_mut().push((message, o.clone())));
|
TRACE.with(|q| q.borrow_mut().push((message, o.clone())));
|
||||||
o
|
o
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn charge_fees(_location: impl Into<MultiLocation>, _fees: MultiAssets) -> XcmResult {
|
||||||
|
Err(XcmError::Unimplemented)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config for Test {
|
impl Config for Test {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ scale-info = { version = "2.0.0", default-features = false, features = ["derive"
|
|||||||
# Substrate
|
# Substrate
|
||||||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
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" }
|
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-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" }
|
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
|
# Substrate
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
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" }
|
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master" }
|
||||||
|
|
||||||
# Polkadot
|
# Polkadot
|
||||||
@@ -48,6 +48,7 @@ std = [
|
|||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"frame-system/std",
|
"frame-system/std",
|
||||||
"log/std",
|
"log/std",
|
||||||
|
"sp-io/std",
|
||||||
"sp-runtime/std",
|
"sp-runtime/std",
|
||||||
"sp-std/std",
|
"sp-std/std",
|
||||||
"xcm-executor/std",
|
"xcm-executor/std",
|
||||||
|
|||||||
@@ -1079,26 +1079,41 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
|
|||||||
|
|
||||||
/// Xcm sender for sending to a sibling parachain.
|
/// Xcm sender for sending to a sibling parachain.
|
||||||
impl<T: Config> SendXcm for Pallet<T> {
|
impl<T: Config> SendXcm for Pallet<T> {
|
||||||
fn send_xcm(dest: impl Into<MultiLocation>, msg: Xcm<()>) -> SendResult {
|
type Ticket = (ParaId, VersionedXcm<()>);
|
||||||
let dest = dest.into();
|
|
||||||
|
|
||||||
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.
|
// An HRMP message for a sibling parachain.
|
||||||
MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
|
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)?;
|
.map_err(|()| SendError::DestinationUnsupported)?;
|
||||||
let hash = T::Hashing::hash_of(&versioned_xcm);
|
Ok(((*id).into(), 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)
|
|
||||||
},
|
},
|
||||||
// Anything else is unhandled. This includes a message this is meant for us.
|
// 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