mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
Remove CliChain::KeyPair (#1741)
This commit is contained in:
committed by
Bastian Köcher
parent
03425b33ae
commit
4a10ccb118
@@ -54,6 +54,4 @@ impl CliEncodeMessage for Millau {
|
|||||||
|
|
||||||
impl CliChain for Millau {
|
impl CliChain for Millau {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(millau_runtime::VERSION);
|
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(millau_runtime::VERSION);
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,4 @@ impl CliEncodeMessage for Rialto {
|
|||||||
|
|
||||||
impl CliChain for Rialto {
|
impl CliChain for Rialto {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_runtime::VERSION);
|
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_runtime::VERSION);
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,4 @@ impl CliEncodeMessage for RialtoParachain {
|
|||||||
|
|
||||||
impl CliChain for RialtoParachain {
|
impl CliChain for RialtoParachain {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_parachain_runtime::VERSION);
|
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_parachain_runtime::VERSION);
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,8 @@ use sp_version::RuntimeVersion;
|
|||||||
|
|
||||||
impl CliChain for Rococo {
|
impl CliChain for Rococo {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CliChain for BridgeHubRococo {
|
impl CliChain for BridgeHubRococo {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,12 +22,8 @@ use sp_version::RuntimeVersion;
|
|||||||
|
|
||||||
impl CliChain for Westend {
|
impl CliChain for Westend {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CliChain for Westmint {
|
impl CliChain for Westmint {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,8 @@ use sp_version::RuntimeVersion;
|
|||||||
|
|
||||||
impl CliChain for Wococo {
|
impl CliChain for Wococo {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CliChain for BridgeHubWococo {
|
impl CliChain for BridgeHubWococo {
|
||||||
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
|
||||||
|
|
||||||
type KeyPair = sp_core::sr25519::Pair;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,7 @@
|
|||||||
use crate::cli::CliChain;
|
use crate::cli::CliChain;
|
||||||
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
|
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
|
||||||
use parachains_relay::ParachainsPipeline;
|
use parachains_relay::ParachainsPipeline;
|
||||||
use relay_substrate_client::{
|
use relay_substrate_client::{Chain, ChainWithTransactions, Parachain, RelayChain};
|
||||||
AccountKeyPairOf, Chain, ChainWithTransactions, Parachain, RelayChain,
|
|
||||||
};
|
|
||||||
use strum::{EnumString, EnumVariantNames};
|
use strum::{EnumString, EnumVariantNames};
|
||||||
use substrate_relay_helper::{
|
use substrate_relay_helper::{
|
||||||
finality::SubstrateFinalitySyncPipeline, messages_lane::SubstrateMessageLane,
|
finality::SubstrateFinalitySyncPipeline, messages_lane::SubstrateMessageLane,
|
||||||
@@ -63,7 +61,7 @@ pub trait CliBridgeBase: Sized {
|
|||||||
/// The source chain.
|
/// The source chain.
|
||||||
type Source: Chain + CliChain;
|
type Source: Chain + CliChain;
|
||||||
/// The target chain.
|
/// The target chain.
|
||||||
type Target: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Target>>;
|
type Target: ChainWithTransactions + CliChain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bridge representation that can be used from the CLI for relaying headers
|
/// Bridge representation that can be used from the CLI for relaying headers
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use relay_substrate_client::{AccountKeyPairOf, ChainWithTransactions};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use strum::{EnumString, EnumVariantNames};
|
use strum::{EnumString, EnumVariantNames};
|
||||||
|
|
||||||
@@ -134,16 +135,16 @@ pub trait TransactionParamsProvider {
|
|||||||
/// Returns `true` if transaction parameters are defined by this provider.
|
/// Returns `true` if transaction parameters are defined by this provider.
|
||||||
fn is_defined(&self) -> bool;
|
fn is_defined(&self) -> bool;
|
||||||
/// Returns transaction parameters.
|
/// Returns transaction parameters.
|
||||||
fn transaction_params<Chain: CliChain>(
|
fn transaction_params<Chain: ChainWithTransactions>(
|
||||||
&self,
|
&self,
|
||||||
) -> anyhow::Result<TransactionParams<Chain::KeyPair>>;
|
) -> anyhow::Result<TransactionParams<AccountKeyPairOf<Chain>>>;
|
||||||
|
|
||||||
/// Returns transaction parameters, defined by `self` provider or, if they're not defined,
|
/// Returns transaction parameters, defined by `self` provider or, if they're not defined,
|
||||||
/// defined by `other` provider.
|
/// defined by `other` provider.
|
||||||
fn transaction_params_or<Chain: CliChain, T: TransactionParamsProvider>(
|
fn transaction_params_or<Chain: ChainWithTransactions, T: TransactionParamsProvider>(
|
||||||
&self,
|
&self,
|
||||||
other: &T,
|
other: &T,
|
||||||
) -> anyhow::Result<TransactionParams<Chain::KeyPair>> {
|
) -> anyhow::Result<TransactionParams<AccountKeyPairOf<Chain>>> {
|
||||||
if self.is_defined() {
|
if self.is_defined() {
|
||||||
self.transaction_params::<Chain>()
|
self.transaction_params::<Chain>()
|
||||||
} else {
|
} else {
|
||||||
@@ -201,7 +202,7 @@ macro_rules! declare_chain_signing_params_cli_schema {
|
|||||||
|
|
||||||
/// Parse signing params into chain-specific KeyPair.
|
/// Parse signing params into chain-specific KeyPair.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn to_keypair<Chain: CliChain>(&self) -> anyhow::Result<Chain::KeyPair> {
|
pub fn to_keypair<Chain: ChainWithTransactions>(&self) -> anyhow::Result<AccountKeyPairOf<Chain>> {
|
||||||
let suri = match (self.[<$chain_prefix _signer>].as_ref(), self.[<$chain_prefix _signer_file>].as_ref()) {
|
let suri = match (self.[<$chain_prefix _signer>].as_ref(), self.[<$chain_prefix _signer_file>].as_ref()) {
|
||||||
(Some(suri), _) => suri.to_owned(),
|
(Some(suri), _) => suri.to_owned(),
|
||||||
(None, Some(suri_file)) => std::fs::read_to_string(suri_file)
|
(None, Some(suri_file)) => std::fs::read_to_string(suri_file)
|
||||||
@@ -234,7 +235,7 @@ macro_rules! declare_chain_signing_params_cli_schema {
|
|||||||
|
|
||||||
use sp_core::crypto::Pair;
|
use sp_core::crypto::Pair;
|
||||||
|
|
||||||
Chain::KeyPair::from_string(
|
AccountKeyPairOf::<Chain>::from_string(
|
||||||
&suri,
|
&suri,
|
||||||
suri_password.as_deref()
|
suri_password.as_deref()
|
||||||
).map_err(|e| anyhow::format_err!("{:?}", e))
|
).map_err(|e| anyhow::format_err!("{:?}", e))
|
||||||
@@ -247,7 +248,7 @@ macro_rules! declare_chain_signing_params_cli_schema {
|
|||||||
self.[<$chain_prefix _signer>].is_some() || self.[<$chain_prefix _signer_file>].is_some()
|
self.[<$chain_prefix _signer>].is_some() || self.[<$chain_prefix _signer_file>].is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transaction_params<Chain: CliChain>(&self) -> anyhow::Result<TransactionParams<Chain::KeyPair>> {
|
fn transaction_params<Chain: ChainWithTransactions>(&self) -> anyhow::Result<TransactionParams<AccountKeyPairOf<Chain>>> {
|
||||||
Ok(TransactionParams {
|
Ok(TransactionParams {
|
||||||
mortality: self.transactions_mortality()?,
|
mortality: self.transactions_mortality()?,
|
||||||
signer: self.to_keypair::<Chain>()?,
|
signer: self.to_keypair::<Chain>()?,
|
||||||
|
|||||||
@@ -194,11 +194,6 @@ pub trait CliChain: relay_substrate_client::Chain {
|
|||||||
///
|
///
|
||||||
/// can be `None` if relay is not going to submit transactions to that chain.
|
/// can be `None` if relay is not going to submit transactions to that chain.
|
||||||
const RUNTIME_VERSION: Option<sp_version::RuntimeVersion>;
|
const RUNTIME_VERSION: Option<sp_version::RuntimeVersion>;
|
||||||
|
|
||||||
/// Crypto KeyPair type used to send messages.
|
|
||||||
///
|
|
||||||
/// In case of chains supporting multiple cryptos, pick one used by the CLI.
|
|
||||||
type KeyPair: sp_core::crypto::Pair;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lane id.
|
/// Lane id.
|
||||||
|
|||||||
@@ -227,9 +227,9 @@ trait Full2WayBridgeBase: Sized + Send + Sync {
|
|||||||
/// The CLI params for the bridge.
|
/// The CLI params for the bridge.
|
||||||
type Params;
|
type Params;
|
||||||
/// The left relay chain.
|
/// The left relay chain.
|
||||||
type Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Left>>;
|
type Left: ChainWithTransactions + CliChain;
|
||||||
/// The right destination chain (it can be a relay or a parachain).
|
/// The right destination chain (it can be a relay or a parachain).
|
||||||
type Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Right>>;
|
type Right: ChainWithTransactions + CliChain;
|
||||||
|
|
||||||
/// Reference to common relay parameters.
|
/// Reference to common relay parameters.
|
||||||
fn common(&self) -> &Full2WayBridgeCommonParams<Self::Left, Self::Right>;
|
fn common(&self) -> &Full2WayBridgeCommonParams<Self::Left, Self::Right>;
|
||||||
@@ -259,13 +259,9 @@ where
|
|||||||
type Base: Full2WayBridgeBase<Left = Self::Left, Right = Self::Right>;
|
type Base: Full2WayBridgeBase<Left = Self::Left, Right = Self::Right>;
|
||||||
|
|
||||||
/// The left relay chain.
|
/// The left relay chain.
|
||||||
type Left: ChainWithTransactions
|
type Left: ChainWithTransactions + ChainWithBalances + CliChain;
|
||||||
+ ChainWithBalances
|
|
||||||
+ CliChain<KeyPair = AccountKeyPairOf<Self::Left>>;
|
|
||||||
/// The right relay chain.
|
/// The right relay chain.
|
||||||
type Right: ChainWithTransactions
|
type Right: ChainWithTransactions + ChainWithBalances + CliChain;
|
||||||
+ ChainWithBalances
|
|
||||||
+ CliChain<KeyPair = AccountKeyPairOf<Self::Right>>;
|
|
||||||
|
|
||||||
/// Left to Right bridge.
|
/// Left to Right bridge.
|
||||||
type L2R: MessagesCliBridge<Source = Self::Left, Target = Self::Right>;
|
type L2R: MessagesCliBridge<Source = Self::Left, Target = Self::Right>;
|
||||||
|
|||||||
+4
-10
@@ -116,9 +116,9 @@ macro_rules! declare_parachain_to_parachain_bridge_schema {
|
|||||||
|
|
||||||
impl [<$left_parachain $right_parachain HeadersAndMessages>] {
|
impl [<$left_parachain $right_parachain HeadersAndMessages>] {
|
||||||
async fn into_bridge<
|
async fn into_bridge<
|
||||||
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>> + Parachain,
|
Left: ChainWithTransactions + CliChain + Parachain,
|
||||||
LeftRelay: CliChain,
|
LeftRelay: CliChain,
|
||||||
Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>> + Parachain,
|
Right: ChainWithTransactions + CliChain + Parachain,
|
||||||
RightRelay: CliChain,
|
RightRelay: CliChain,
|
||||||
L2R: CliBridgeBase<Source = Left, Target = Right>
|
L2R: CliBridgeBase<Source = Left, Target = Right>
|
||||||
+ MessagesCliBridge
|
+ MessagesCliBridge
|
||||||
@@ -168,14 +168,8 @@ macro_rules! declare_parachain_to_parachain_bridge_schema {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<
|
impl<
|
||||||
Left: Chain<Hash = ParaHash>
|
Left: Chain<Hash = ParaHash> + ChainWithTransactions + CliChain + Parachain,
|
||||||
+ ChainWithTransactions
|
Right: Chain<Hash = ParaHash> + ChainWithTransactions + CliChain + Parachain,
|
||||||
+ CliChain<KeyPair = AccountKeyPairOf<Left>>
|
|
||||||
+ Parachain,
|
|
||||||
Right: Chain<Hash = ParaHash>
|
|
||||||
+ ChainWithTransactions
|
|
||||||
+ CliChain<KeyPair = AccountKeyPairOf<Right>>
|
|
||||||
+ Parachain,
|
|
||||||
LeftRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
|
LeftRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
|
||||||
+ CliChain,
|
+ CliChain,
|
||||||
RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
|
RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
|
||||||
|
|||||||
+4
-7
@@ -107,8 +107,8 @@ macro_rules! declare_relay_to_parachain_bridge_schema {
|
|||||||
|
|
||||||
impl [<$left_chain $right_parachain HeadersAndMessages>] {
|
impl [<$left_chain $right_parachain HeadersAndMessages>] {
|
||||||
async fn into_bridge<
|
async fn into_bridge<
|
||||||
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>,
|
Left: ChainWithTransactions + CliChain,
|
||||||
Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>> + Parachain,
|
Right: ChainWithTransactions + CliChain + Parachain,
|
||||||
RightRelay: CliChain,
|
RightRelay: CliChain,
|
||||||
L2R: CliBridgeBase<Source = Left, Target = Right> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
|
L2R: CliBridgeBase<Source = Left, Target = Right> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
|
||||||
R2L: CliBridgeBase<Source = Right, Target = Left>
|
R2L: CliBridgeBase<Source = Right, Target = Left>
|
||||||
@@ -156,11 +156,8 @@ macro_rules! declare_relay_to_parachain_bridge_schema {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<
|
impl<
|
||||||
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>,
|
Left: ChainWithTransactions + CliChain,
|
||||||
Right: Chain<Hash = ParaHash>
|
Right: Chain<Hash = ParaHash> + ChainWithTransactions + CliChain + Parachain,
|
||||||
+ ChainWithTransactions
|
|
||||||
+ CliChain<KeyPair = AccountKeyPairOf<Right>>
|
|
||||||
+ Parachain,
|
|
||||||
RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
|
RightRelay: Chain<BlockNumber = RelayBlockNumber, Hash = RelayBlockHash, Hasher = RelayBlockHasher>
|
||||||
+ CliChain,
|
+ CliChain,
|
||||||
L2R: CliBridgeBase<Source = Left, Target = Right>
|
L2R: CliBridgeBase<Source = Left, Target = Right>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ macro_rules! declare_relay_to_relay_bridge_schema {
|
|||||||
|
|
||||||
impl [<$left_chain $right_chain HeadersAndMessages>] {
|
impl [<$left_chain $right_chain HeadersAndMessages>] {
|
||||||
async fn into_bridge<
|
async fn into_bridge<
|
||||||
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>,
|
Left: ChainWithTransactions + CliChain,
|
||||||
Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>>,
|
Right: ChainWithTransactions + CliChain,
|
||||||
L2R: CliBridgeBase<Source = Left, Target = Right> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
|
L2R: CliBridgeBase<Source = Left, Target = Right> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
|
||||||
R2L: CliBridgeBase<Source = Right, Target = Left> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
|
R2L: CliBridgeBase<Source = Right, Target = Left> + MessagesCliBridge + RelayToRelayHeadersCliBridge,
|
||||||
>(
|
>(
|
||||||
@@ -114,8 +114,8 @@ macro_rules! declare_relay_to_relay_bridge_schema {
|
|||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<
|
impl<
|
||||||
Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Left>>,
|
Left: ChainWithTransactions + CliChain,
|
||||||
Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Right>>,
|
Right: ChainWithTransactions + CliChain,
|
||||||
L2R: CliBridgeBase<Source = Left, Target = Right>
|
L2R: CliBridgeBase<Source = Left, Target = Right>
|
||||||
+ MessagesCliBridge
|
+ MessagesCliBridge
|
||||||
+ RelayToRelayHeadersCliBridge,
|
+ RelayToRelayHeadersCliBridge,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ pub struct RelayMessages {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
trait MessagesRelayer: MessagesCliBridge
|
trait MessagesRelayer: MessagesCliBridge
|
||||||
where
|
where
|
||||||
Self::Source: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Source>>,
|
Self::Source: ChainWithTransactions + CliChain,
|
||||||
AccountIdOf<Self::Source>: From<<AccountKeyPairOf<Self::Source> as Pair>::Public>,
|
AccountIdOf<Self::Source>: From<<AccountKeyPairOf<Self::Source> as Pair>::Public>,
|
||||||
AccountIdOf<Self::Target>: From<<AccountKeyPairOf<Self::Target> as Pair>::Public>,
|
AccountIdOf<Self::Target>: From<<AccountKeyPairOf<Self::Target> as Pair>::Public>,
|
||||||
BalanceOf<Self::Source>: TryFrom<BalanceOf<Self::Target>>,
|
BalanceOf<Self::Source>: TryFrom<BalanceOf<Self::Target>>,
|
||||||
|
|||||||
@@ -57,10 +57,7 @@ pub struct SendMessage {
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
trait MessageSender: MessagesCliBridge
|
trait MessageSender: MessagesCliBridge
|
||||||
where
|
where
|
||||||
Self::Source: ChainBase<Index = u32>
|
Self::Source: ChainBase<Index = u32> + ChainWithTransactions + CliChain + CliEncodeMessage,
|
||||||
+ ChainWithTransactions
|
|
||||||
+ CliChain<KeyPair = AccountKeyPairOf<Self::Source>>
|
|
||||||
+ CliEncodeMessage,
|
|
||||||
<Self::Source as ChainBase>::Balance: Display + From<u64> + Into<u128>,
|
<Self::Source as ChainBase>::Balance: Display + From<u64> + Into<u128>,
|
||||||
<Self::Source as Chain>::Call: Sync,
|
<Self::Source as Chain>::Call: Sync,
|
||||||
<Self::Source as ChainWithTransactions>::SignedTransaction: Sync,
|
<Self::Source as ChainWithTransactions>::SignedTransaction: Sync,
|
||||||
|
|||||||
Reference in New Issue
Block a user