From ce457a91e1530df227086081597869409977ddc7 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) --- polkadot/xcm/src/v0/traits.rs | 1 + polkadot/xcm/xcm-executor/src/traits/weight.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/polkadot/xcm/src/v0/traits.rs b/polkadot/xcm/src/v0/traits.rs index 8734bb6c7f..f0df7db03e 100644 --- a/polkadot/xcm/src/v0/traits.rs +++ b/polkadot/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/polkadot/xcm/xcm-executor/src/traits/weight.rs b/polkadot/xcm/xcm-executor/src/traits/weight.rs index 1d6d5eeec4..5fd8963090 100644 --- a/polkadot/xcm/xcm-executor/src/traits/weight.rs +++ b/polkadot/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) + } +}