Skip to content

Commit 221e4e8

Browse files
authored
Remove CliChain::KeyPair (#1741)
1 parent 3d9d290 commit 221e4e8

File tree

15 files changed

+28
-68
lines changed

15 files changed

+28
-68
lines changed

relays/bin-substrate/src/chains/millau.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,4 @@ impl CliEncodeMessage for Millau {
5454

5555
impl CliChain for Millau {
5656
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(millau_runtime::VERSION);
57-
58-
type KeyPair = sp_core::sr25519::Pair;
5957
}

relays/bin-substrate/src/chains/rialto.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,4 @@ impl CliEncodeMessage for Rialto {
4646

4747
impl CliChain for Rialto {
4848
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_runtime::VERSION);
49-
50-
type KeyPair = sp_core::sr25519::Pair;
5149
}

relays/bin-substrate/src/chains/rialto_parachain.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,4 @@ impl CliEncodeMessage for RialtoParachain {
4848

4949
impl CliChain for RialtoParachain {
5050
const RUNTIME_VERSION: Option<RuntimeVersion> = Some(rialto_parachain_runtime::VERSION);
51-
52-
type KeyPair = sp_core::sr25519::Pair;
5351
}

relays/bin-substrate/src/chains/rococo.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ use sp_version::RuntimeVersion;
2323

2424
impl CliChain for Rococo {
2525
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
26-
27-
type KeyPair = sp_core::sr25519::Pair;
2826
}
2927

3028
impl CliChain for BridgeHubRococo {
3129
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
32-
33-
type KeyPair = sp_core::sr25519::Pair;
3430
}

relays/bin-substrate/src/chains/westend.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ use sp_version::RuntimeVersion;
2222

2323
impl CliChain for Westend {
2424
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
25-
26-
type KeyPair = sp_core::sr25519::Pair;
2725
}
2826

2927
impl CliChain for Westmint {
3028
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
31-
32-
type KeyPair = sp_core::sr25519::Pair;
3329
}

relays/bin-substrate/src/chains/wococo.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ use sp_version::RuntimeVersion;
2323

2424
impl CliChain for Wococo {
2525
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
26-
27-
type KeyPair = sp_core::sr25519::Pair;
2826
}
2927

3028
impl CliChain for BridgeHubWococo {
3129
const RUNTIME_VERSION: Option<RuntimeVersion> = None;
32-
33-
type KeyPair = sp_core::sr25519::Pair;
3430
}

relays/bin-substrate/src/cli/bridge.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
use crate::cli::CliChain;
1818
use pallet_bridge_parachains::{RelayBlockHash, RelayBlockHasher, RelayBlockNumber};
1919
use parachains_relay::ParachainsPipeline;
20-
use relay_substrate_client::{
21-
AccountKeyPairOf, Chain, ChainWithTransactions, Parachain, RelayChain,
22-
};
20+
use relay_substrate_client::{Chain, ChainWithTransactions, Parachain, RelayChain};
2321
use strum::{EnumString, EnumVariantNames};
2422
use substrate_relay_helper::{
2523
finality::SubstrateFinalitySyncPipeline, messages_lane::SubstrateMessageLane,
@@ -63,7 +61,7 @@ pub trait CliBridgeBase: Sized {
6361
/// The source chain.
6462
type Source: Chain + CliChain;
6563
/// The target chain.
66-
type Target: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Target>>;
64+
type Target: ChainWithTransactions + CliChain;
6765
}
6866

6967
/// Bridge representation that can be used from the CLI for relaying headers

relays/bin-substrate/src/cli/chain_schema.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
1717

18+
use relay_substrate_client::{AccountKeyPairOf, ChainWithTransactions};
1819
use structopt::StructOpt;
1920
use strum::{EnumString, EnumVariantNames};
2021

@@ -134,16 +135,16 @@ pub trait TransactionParamsProvider {
134135
/// Returns `true` if transaction parameters are defined by this provider.
135136
fn is_defined(&self) -> bool;
136137
/// Returns transaction parameters.
137-
fn transaction_params<Chain: CliChain>(
138+
fn transaction_params<Chain: ChainWithTransactions>(
138139
&self,
139-
) -> anyhow::Result<TransactionParams<Chain::KeyPair>>;
140+
) -> anyhow::Result<TransactionParams<AccountKeyPairOf<Chain>>>;
140141

141142
/// Returns transaction parameters, defined by `self` provider or, if they're not defined,
142143
/// defined by `other` provider.
143-
fn transaction_params_or<Chain: CliChain, T: TransactionParamsProvider>(
144+
fn transaction_params_or<Chain: ChainWithTransactions, T: TransactionParamsProvider>(
144145
&self,
145146
other: &T,
146-
) -> anyhow::Result<TransactionParams<Chain::KeyPair>> {
147+
) -> anyhow::Result<TransactionParams<AccountKeyPairOf<Chain>>> {
147148
if self.is_defined() {
148149
self.transaction_params::<Chain>()
149150
} else {
@@ -201,7 +202,7 @@ macro_rules! declare_chain_signing_params_cli_schema {
201202

202203
/// Parse signing params into chain-specific KeyPair.
203204
#[allow(dead_code)]
204-
pub fn to_keypair<Chain: CliChain>(&self) -> anyhow::Result<Chain::KeyPair> {
205+
pub fn to_keypair<Chain: ChainWithTransactions>(&self) -> anyhow::Result<AccountKeyPairOf<Chain>> {
205206
let suri = match (self.[<$chain_prefix _signer>].as_ref(), self.[<$chain_prefix _signer_file>].as_ref()) {
206207
(Some(suri), _) => suri.to_owned(),
207208
(None, Some(suri_file)) => std::fs::read_to_string(suri_file)
@@ -234,7 +235,7 @@ macro_rules! declare_chain_signing_params_cli_schema {
234235

235236
use sp_core::crypto::Pair;
236237

237-
Chain::KeyPair::from_string(
238+
AccountKeyPairOf::<Chain>::from_string(
238239
&suri,
239240
suri_password.as_deref()
240241
).map_err(|e| anyhow::format_err!("{:?}", e))
@@ -247,7 +248,7 @@ macro_rules! declare_chain_signing_params_cli_schema {
247248
self.[<$chain_prefix _signer>].is_some() || self.[<$chain_prefix _signer_file>].is_some()
248249
}
249250

250-
fn transaction_params<Chain: CliChain>(&self) -> anyhow::Result<TransactionParams<Chain::KeyPair>> {
251+
fn transaction_params<Chain: ChainWithTransactions>(&self) -> anyhow::Result<TransactionParams<AccountKeyPairOf<Chain>>> {
251252
Ok(TransactionParams {
252253
mortality: self.transactions_mortality()?,
253254
signer: self.to_keypair::<Chain>()?,

relays/bin-substrate/src/cli/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,6 @@ pub trait CliChain: relay_substrate_client::Chain {
194194
///
195195
/// can be `None` if relay is not going to submit transactions to that chain.
196196
const RUNTIME_VERSION: Option<sp_version::RuntimeVersion>;
197-
198-
/// Crypto KeyPair type used to send messages.
199-
///
200-
/// In case of chains supporting multiple cryptos, pick one used by the CLI.
201-
type KeyPair: sp_core::crypto::Pair;
202197
}
203198

204199
/// Lane id.

relays/bin-substrate/src/cli/relay_headers_and_messages/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ trait Full2WayBridgeBase: Sized + Send + Sync {
227227
/// The CLI params for the bridge.
228228
type Params;
229229
/// The left relay chain.
230-
type Left: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Left>>;
230+
type Left: ChainWithTransactions + CliChain;
231231
/// The right destination chain (it can be a relay or a parachain).
232-
type Right: ChainWithTransactions + CliChain<KeyPair = AccountKeyPairOf<Self::Right>>;
232+
type Right: ChainWithTransactions + CliChain;
233233

234234
/// Reference to common relay parameters.
235235
fn common(&self) -> &Full2WayBridgeCommonParams<Self::Left, Self::Right>;
@@ -259,13 +259,9 @@ where
259259
type Base: Full2WayBridgeBase<Left = Self::Left, Right = Self::Right>;
260260

261261
/// The left relay chain.
262-
type Left: ChainWithTransactions
263-
+ ChainWithBalances
264-
+ CliChain<KeyPair = AccountKeyPairOf<Self::Left>>;
262+
type Left: ChainWithTransactions + ChainWithBalances + CliChain;
265263
/// The right relay chain.
266-
type Right: ChainWithTransactions
267-
+ ChainWithBalances
268-
+ CliChain<KeyPair = AccountKeyPairOf<Self::Right>>;
264+
type Right: ChainWithTransactions + ChainWithBalances + CliChain;
269265

270266
/// Left to Right bridge.
271267
type L2R: MessagesCliBridge<Source = Self::Left, Target = Self::Right>;

0 commit comments

Comments
 (0)