Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2e22b79
dont use String for creating connections
krzysztofziobro Dec 27, 2022
20aafa6
do not wrap client
krzysztofziobro Dec 27, 2022
1f10b03
wip
krzysztofziobro Dec 28, 2022
2f5cda9
should work as old one
krzysztofziobro Dec 28, 2022
f5b769f
hide connection
krzysztofziobro Dec 28, 2022
44a4e9a
hide the rest
krzysztofziobro Dec 28, 2022
1472fd7
Don not hide clone
krzysztofziobro Dec 28, 2022
40225ca
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Dec 29, 2022
168ce19
bump
krzysztofziobro Dec 29, 2022
0247e81
wip
krzysztofziobro Dec 30, 2022
4c1a6eb
wrap client
krzysztofziobro Dec 30, 2022
e41d124
rename client
krzysztofziobro Dec 30, 2022
7968aea
add Clone
krzysztofziobro Dec 30, 2022
9a979f6
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Dec 30, 2022
50d7071
more general adder
krzysztofziobro Dec 30, 2022
dba9561
Add AsSigned
krzysztofziobro Dec 30, 2022
d700129
add impls for references
krzysztofziobro Dec 30, 2022
e45f361
wip
krzysztofziobro Jan 2, 2023
e6839b8
change TreasurySudoApi
krzysztofziobro Jan 2, 2023
8ec4625
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Jan 2, 2023
3bf05d5
add methods to SignedConnectionApi
krzysztofziobro Jan 2, 2023
6b259b2
Merge branch 'A0-1613-improve-connection' of github.com:Cardinal-Cryp…
krzysztofziobro Jan 2, 2023
23d5a58
remove unnecessary casts
krzysztofziobro Jan 2, 2023
5600e11
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Jan 2, 2023
b7ad771
review part 1
krzysztofziobro Jan 2, 2023
d156320
Merge branch 'A0-1613-improve-connection' of github.com:Cardinal-Cryp…
krzysztofziobro Jan 2, 2023
ef5625d
review part 2
krzysztofziobro Jan 2, 2023
af4d737
Make AsConnection visible only in crate
krzysztofziobro Jan 3, 2023
d15be1b
Merge branch 'main' into A0-1613-improve-connection
krzysztofziobro Jan 3, 2023
70db49a
Remove unnecessary dependencies on ConnectionApi
krzysztofziobro Jan 4, 2023
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
rename client
  • Loading branch information
krzysztofziobro committed Dec 30, 2022
commit e41d124e8454fdd6260bf21c0d8a2406dcaa232b
26 changes: 13 additions & 13 deletions aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,7 @@ use subxt::{
SubstrateConfig,
};

use crate::{api, sp_weights::weight_v2::Weight, BlockHash, Call, Client, KeyPair, TxStatus};

#[derive(Clone)]
pub struct Connection {
client: Client,
}

impl Connection {
pub(crate) fn as_client(&self) -> &Client {
&self.client
}
}
use crate::{api, sp_weights::weight_v2::Weight, BlockHash, Call, KeyPair, SubxtClient, TxStatus};

const DEFAULT_RETRIES: u32 = 10;
const RETRY_WAIT_SECS: u64 = 1;
Expand All @@ -34,7 +23,7 @@ pub async fn create_connection(address: &str) -> Connection {

async fn create_connection_with_retries(address: &str, mut retries: u32) -> Connection {
loop {
let client = Client::from_url(&address).await;
let client = SubxtClient::from_url(&address).await;
match (retries, client) {
(_, Ok(client)) => return Connection { client },
(0, Err(e)) => panic!("{:?}", e),
Expand Down Expand Up @@ -71,6 +60,11 @@ pub trait ConnectionExt: AsConnection {
async fn rpc_call<R: Decode>(&self, func_name: String, params: RpcParams) -> anyhow::Result<R>;
}

#[derive(Clone)]
pub struct Connection {
client: SubxtClient,
}

pub struct SignedConnection {
connection: Connection,
signer: KeyPair,
Expand Down Expand Up @@ -171,6 +165,12 @@ impl<C: AsConnection> ConnectionExt for C {
}
}

impl Connection {
pub(crate) fn as_client(&self) -> &SubxtClient {
&self.client
}
}

impl SignedConnection {
pub async fn new(address: &str, signer: KeyPair) -> Self {
Self::from_connection(create_connection(address).await, signer)
Expand Down
2 changes: 1 addition & 1 deletion aleph-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub type KeyPair = PairSigner<AlephConfig, sr25519::Pair>;
pub type AccountId = subxt::ext::sp_core::crypto::AccountId32;
pub type BlockHash = H256;

pub(crate) type Client = OnlineClient<AlephConfig>;
pub(crate) type SubxtClient = OnlineClient<AlephConfig>;

pub use connections::{
create_connection, AsConnection, Connection, ConnectionExt, RootConnection, SignedConnection,
Expand Down