From 9d73c530b8573745ad8b743abd04ac4f9116e2c9 Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Thu, 29 Apr 2021 15:35:07 +0200 Subject: [PATCH] Implement null weight trader (#2957) --- xcm/src/v0/traits.rs | 1 + xcm/xcm-executor/src/traits/weight.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/xcm/src/v0/traits.rs b/xcm/src/v0/traits.rs index 8734bb6c7f95..f0df7db03e61 100644 --- a/xcm/src/v0/traits.rs +++ b/xcm/src/v0/traits.rs @@ -25,6 +25,7 @@ use super::{MultiLocation, Xcm}; pub enum Error { Undefined, Overflow, + /// The operation is intentionally unsupported. Unimplemented, UnhandledXcmVersion, UnhandledXcmMessage, diff --git a/xcm/xcm-executor/src/traits/weight.rs b/xcm/xcm-executor/src/traits/weight.rs index 1d6d5eeec447..5fd896309097 100644 --- a/xcm/xcm-executor/src/traits/weight.rs +++ b/xcm/xcm-executor/src/traits/weight.rs @@ -61,3 +61,10 @@ pub trait WeightTrader: Sized { /// Default implementation refunds nothing. fn refund_weight(&mut self, _weight: Weight) -> MultiAsset { MultiAsset::None } } + +impl WeightTrader for () { + fn new() -> Self { () } + fn buy_weight(&mut self, _: Weight, _: Assets) -> Result { + Err(Error::Unimplemented) + } +}