Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clone for KeyPair + removing pub(crate)
  • Loading branch information
krzysztofziobro committed Jan 20, 2023
commit ae01f0dee689bd5d03dad0dff13f186e98c17f8c
10 changes: 1 addition & 9 deletions aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Connection {
}

/// Any connection that is signed by some key.
#[derive(Clone)]
pub struct SignedConnection {
connection: Connection,
signer: KeyPair,
Expand Down Expand Up @@ -182,15 +183,6 @@ impl SudoCall for RootConnection {
}
}

impl Clone for SignedConnection {
fn clone(&self) -> Self {
SignedConnection {
connection: self.connection.clone(),
signer: KeyPair::new(self.signer.signer().clone()),
}
}
}

impl AsConnection for Connection {
fn as_connection(&self) -> &Connection {
self
Expand Down
16 changes: 11 additions & 5 deletions aleph-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,33 @@ pub type RawKeyPair = sr25519::Pair;
/// An alias for an account id type.
pub type AccountId = subxt::ext::sp_core::crypto::AccountId32;
/// An alias for a client type.
pub type Client = OnlineClient<AlephConfig>;
pub type SubxtClient = OnlineClient<AlephConfig>;
/// An alias for a hash type.
pub type BlockHash = H256;
/// An alias for a hash type.
pub type CodeHash = H256;

/// An alias for a configuration of live chain, e.g. block index type, hash type.
pub(crate) type AlephConfig = PolkadotConfig;
pub(crate) type ParamsBuilder = subxt::tx::PolkadotExtrinsicParamsBuilder<SubstrateConfig>;
pub(crate) type SubxtClient = OnlineClient<AlephConfig>;
type PairSigner = subxt::tx::PairSigner<AlephConfig, RawKeyPair>;

pub use connections::{
Connection, ConnectionApi, RootConnection, SignedConnection, SignedConnectionApi, SudoCall,
};

/// An alias for a configuration of live chain, e.g. block index type, hash type.
type AlephConfig = PolkadotConfig;
type ParamsBuilder = subxt::tx::PolkadotExtrinsicParamsBuilder<SubstrateConfig>;

/// Wrapped around subxt PairSigner
pub struct KeyPair {
inner: PairSigner,
}

impl Clone for KeyPair {
fn clone(&self) -> Self {
KeyPair::new(self.inner.signer().clone())
}
}

impl KeyPair {
/// Constructs a new KeyPair from RawKeyPair
pub fn new(keypair: RawKeyPair) -> Self {
Expand Down