mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Unify error enums in substrate and ethereum clients with thiserror (#1094)
* Unify error enums in substrate and ethereum clients with `thiserror` Related to https://github.com/paritytech/parity-bridges-common/issues/857 * Add license pre-amble * rustfmt * Fix spelling
This commit is contained in:
committed by
Bastian Köcher
parent
7b4f1c2236
commit
5842968273
@@ -97,7 +97,7 @@ impl CliChain for Kusama {
|
||||
|
||||
fn encode_message(
|
||||
_message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
Err("Sending messages from Kusama is not yet supported.".into())
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
anyhow::bail!("Sending messages from Kusama is not yet supported.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +256,7 @@ pub async fn run(
|
||||
futures::future::pending(),
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Add standalone metrics for the Kusama -> Polkadot messages loop.
|
||||
|
||||
@@ -23,6 +23,7 @@ use crate::cli::{
|
||||
send_message::{self, DispatchFeePayment},
|
||||
CliChain,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use bp_message_dispatch::{CallOrigin, MessagePayload};
|
||||
use codec::Decode;
|
||||
use frame_support::weights::{DispatchInfo, GetDispatchInfo, Weight};
|
||||
@@ -87,10 +88,10 @@ impl CliChain for Millau {
|
||||
// TODO [#854|#843] support multiple bridges?
|
||||
fn encode_message(
|
||||
message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
match message {
|
||||
encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0)
|
||||
.map_err(|e| format!("Failed to decode Millau's MessagePayload: {:?}", e)),
|
||||
.map_err(|e| anyhow!("Failed to decode Millau's MessagePayload: {:?}", e)),
|
||||
encode_message::MessagePayload::Call { mut call, mut sender } => {
|
||||
type Source = Millau;
|
||||
type Target = relay_rialto_client::Rialto;
|
||||
@@ -102,7 +103,7 @@ impl CliChain for Millau {
|
||||
&mut call,
|
||||
bridge::MILLAU_TO_RIALTO_INDEX,
|
||||
);
|
||||
let call = Target::encode_call(&call).map_err(|e| e.to_string())?;
|
||||
let call = Target::encode_call(&call)?;
|
||||
let weight = call.get_dispatch_info().weight;
|
||||
|
||||
Ok(send_message::message_payload(
|
||||
|
||||
@@ -250,6 +250,7 @@ pub async fn run(
|
||||
futures::future::pending(),
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Add standalone metrics for the Millau -> Rialto messages loop.
|
||||
|
||||
@@ -97,7 +97,7 @@ impl CliChain for Polkadot {
|
||||
|
||||
fn encode_message(
|
||||
_message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
Err("Sending messages from Polkadot is not yet supported.".into())
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
anyhow::bail!("Sending messages from Polkadot is not yet supported.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,6 +255,7 @@ pub async fn run(
|
||||
futures::future::pending(),
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Add standalone metrics for the Polkadot -> Kusama messages loop.
|
||||
|
||||
@@ -23,6 +23,7 @@ use crate::cli::{
|
||||
send_message::{self, DispatchFeePayment},
|
||||
CliChain,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use bp_message_dispatch::{CallOrigin, MessagePayload};
|
||||
use codec::Decode;
|
||||
use frame_support::weights::{DispatchInfo, GetDispatchInfo, Weight};
|
||||
@@ -86,10 +87,10 @@ impl CliChain for Rialto {
|
||||
|
||||
fn encode_message(
|
||||
message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
match message {
|
||||
encode_message::MessagePayload::Raw { data } => MessagePayload::decode(&mut &*data.0)
|
||||
.map_err(|e| format!("Failed to decode Rialto's MessagePayload: {:?}", e)),
|
||||
.map_err(|e| anyhow!("Failed to decode Rialto's MessagePayload: {:?}", e)),
|
||||
encode_message::MessagePayload::Call { mut call, mut sender } => {
|
||||
type Source = Rialto;
|
||||
type Target = relay_millau_client::Millau;
|
||||
@@ -101,7 +102,7 @@ impl CliChain for Rialto {
|
||||
&mut call,
|
||||
bridge::RIALTO_TO_MILLAU_INDEX,
|
||||
);
|
||||
let call = Target::encode_call(&call).map_err(|e| e.to_string())?;
|
||||
let call = Target::encode_call(&call)?;
|
||||
let weight = call.get_dispatch_info().weight;
|
||||
|
||||
Ok(send_message::message_payload(
|
||||
|
||||
@@ -249,6 +249,7 @@ pub async fn run(
|
||||
futures::future::pending(),
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Add standalone metrics for the Rialto -> Millau messages loop.
|
||||
|
||||
@@ -76,7 +76,7 @@ impl CliChain for RialtoParachain {
|
||||
|
||||
fn encode_message(
|
||||
_message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
Err("Not supported".into())
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
anyhow::bail!("Not supported")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use anyhow::anyhow;
|
||||
use codec::Decode;
|
||||
use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight};
|
||||
use relay_rococo_client::Rococo;
|
||||
@@ -94,7 +95,7 @@ impl CliChain for Rococo {
|
||||
|
||||
fn encode_message(
|
||||
_message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
Err("Sending messages from Rococo is not yet supported.".into())
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
Err(anyhow!("Sending messages from Rococo is not yet supported."))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ pub async fn run(
|
||||
futures::future::pending(),
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Add standalone metrics for the Rococo -> Wococo messages loop.
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! Westend chain specification for CLI.
|
||||
|
||||
use crate::cli::{encode_message, CliChain};
|
||||
use anyhow::anyhow;
|
||||
use frame_support::weights::Weight;
|
||||
use relay_westend_client::Westend;
|
||||
use sp_version::RuntimeVersion;
|
||||
@@ -37,7 +38,7 @@ impl CliChain for Westend {
|
||||
|
||||
fn encode_message(
|
||||
_message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
Err("Sending messages from Westend is not yet supported.".into())
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
Err(anyhow!("Sending messages from Westend is not yet supported."))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use anyhow::anyhow;
|
||||
use codec::Decode;
|
||||
use frame_support::weights::{DispatchClass, DispatchInfo, Pays, Weight};
|
||||
use relay_wococo_client::Wococo;
|
||||
@@ -88,7 +89,7 @@ impl CliChain for Wococo {
|
||||
|
||||
fn encode_message(
|
||||
_message: encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String> {
|
||||
Err("Sending messages from Wococo is not yet supported.".into())
|
||||
) -> anyhow::Result<Self::MessagePayload> {
|
||||
Err(anyhow!("Sending messages from Wococo is not yet supported."))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,6 +252,7 @@ pub async fn run(
|
||||
futures::future::pending(),
|
||||
)
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
}
|
||||
|
||||
/// Add standalone metrics for the Wococo -> Rococo messages loop.
|
||||
|
||||
@@ -257,7 +257,7 @@ pub trait CliChain: relay_substrate_client::Chain {
|
||||
/// Construct message payload to be sent over the bridge.
|
||||
fn encode_message(
|
||||
message: crate::cli::encode_message::MessagePayload,
|
||||
) -> Result<Self::MessagePayload, String>;
|
||||
) -> anyhow::Result<Self::MessagePayload>;
|
||||
|
||||
/// Maximal extrinsic weight (from the runtime).
|
||||
fn max_extrinsic_weight() -> Weight;
|
||||
|
||||
@@ -141,6 +141,7 @@ impl ResubmitTransactions {
|
||||
)
|
||||
})
|
||||
.await
|
||||
.map_err(Into::into)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user