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
wrap client
  • Loading branch information
krzysztofziobro committed Dec 30, 2022
commit 4c1a6eb830f0c742cfc5e36b93ff3f7c4b1b614c
12 changes: 10 additions & 2 deletions aleph-client/src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ impl<C: AsConnection> ConnectionExt for C {
at: Option<BlockHash>,
) -> Option<T::Target> {
info!(target: "aleph-client", "accessing storage at {}::{} at block {:?}", addrs.pallet_name(), addrs.entry_name(), at);
self.as_client()
self.as_connection()
.as_client()
.storage()
.fetch(addrs, at)
.await
Expand All @@ -159,7 +160,12 @@ impl<C: AsConnection> ConnectionExt for C {

async fn rpc_call<R: Decode>(&self, func_name: String, params: RpcParams) -> anyhow::Result<R> {
info!(target: "aleph-client", "submitting rpc call `{}`, with params {:?}", func_name, params);
let bytes: Bytes = self.as_client().rpc().request(&func_name, params).await?;
let bytes: Bytes = self
.as_connection()
.as_client()
.rpc()
.request(&func_name, params)
.await?;

Ok(R::decode(&mut bytes.as_ref())?)
}
Expand Down Expand Up @@ -198,6 +204,7 @@ impl SignedConnection {
}
let progress = self
.connection
.as_connection()
.as_client()
.tx()
.sign_and_submit_then_watch(&tx, &self.signer, params)
Expand Down Expand Up @@ -227,6 +234,7 @@ impl RootConnection {
let root_address = api::storage().sudo().key();

let root = match connection
.as_connection()
.as_client()
.storage()
.fetch(&root_address, None)
Expand Down
2 changes: 1 addition & 1 deletion aleph-client/src/pallets/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait AuthorRpc {
#[async_trait::async_trait]
impl<C: ConnectionExt> AuthorRpc for C {
async fn author_rotate_keys(&self) -> anyhow::Result<SessionKeys> {
let bytes = self.as_client().rpc().rotate_keys().await?;
let bytes = self.as_connection().as_client().rpc().rotate_keys().await?;
SessionKeys::decode(&mut bytes.0.as_slice()).map_err(|e| e.into())
}
}
3 changes: 2 additions & 1 deletion aleph-client/src/pallets/elections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl<C: ConnectionExt> ElectionsApi for C {

async fn get_session_period(&self) -> anyhow::Result<u32> {
let addrs = api::constants().elections().session_period();
self.as_client()
self.as_connection()
.as_client()
.constants()
.at(&addrs)
.map_err(|e| e.into())
Expand Down
6 changes: 4 additions & 2 deletions aleph-client/src/pallets/staking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ impl<C: ConnectionExt> StakingApi for C {

async fn get_session_per_era(&self) -> anyhow::Result<u32> {
let addrs = api::constants().staking().sessions_per_era();
self.as_client()
self.as_connection()
.as_client()
.constants()
.at(&addrs)
.map_err(|e| e.into())
Expand Down Expand Up @@ -306,7 +307,8 @@ impl<C: ConnectionExt> StakingRawApi for C {
let key_addrs = api::storage().staking().eras_stakers_root();
let mut key = key_addrs.to_root_bytes();
StorageMapKey::new(era, StorageHasher::Twox64Concat).to_bytes(&mut key);
self.as_client()
self.as_connection()
.as_client()
.storage()
.fetch_keys(&key, 10, None, at)
.await
Expand Down
9 changes: 6 additions & 3 deletions aleph-client/src/utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ impl<C: ConnectionExt> BlocksApi for C {

async fn get_block_hash(&self, block: BlockNumber) -> anyhow::Result<Option<BlockHash>> {
info!(target: "aleph-client", "querying block hash for number #{}", block);
self.as_client()
self.as_connection()
.as_client()
.rpc()
.block_hash(Some(block.into()))
.await
Expand All @@ -53,7 +54,8 @@ impl<C: ConnectionExt> BlocksApi for C {
}

async fn get_finalized_block_hash(&self) -> anyhow::Result<BlockHash> {
self.as_client()
self.as_connection()
.as_client()
.rpc()
.finalized_head()
.await
Expand All @@ -64,7 +66,8 @@ impl<C: ConnectionExt> BlocksApi for C {
&self,
block: Option<BlockHash>,
) -> anyhow::Result<Option<BlockNumber>> {
self.as_client()
self.as_connection()
.as_client()
.rpc()
.header(block)
.await
Expand Down
5 changes: 5 additions & 0 deletions aleph-client/src/waiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ impl<C: ConnectionExt> AlephWaiting for C {
async fn wait_for_block<P: Fn(u32) -> bool + Send>(&self, predicate: P, status: BlockStatus) {
let mut block_sub = match status {
BlockStatus::Best => self
.as_connection()
.as_client()
.blocks()
.subscribe_best()
.await
.expect("Failed to subscribe to the best block stream!"),
BlockStatus::Finalized => self
.as_connection()
.as_client()
.blocks()
.subscribe_finalized()
Expand All @@ -65,12 +67,14 @@ impl<C: ConnectionExt> AlephWaiting for C {
) -> T {
let mut block_sub = match status {
BlockStatus::Best => self
.as_connection()
.as_client()
.blocks()
.subscribe_best()
.await
.expect("Failed to subscribe to the best block stream!"),
BlockStatus::Finalized => self
.as_connection()
.as_client()
.blocks()
.subscribe_finalized()
Expand Down Expand Up @@ -102,6 +106,7 @@ impl<C: ConnectionExt> AlephWaiting for C {
async fn wait_for_era(&self, era: EraIndex, status: BlockStatus) {
let addrs = aleph_zero::api::constants().staking().sessions_per_era();
let sessions_per_era = self
.as_connection()
.as_client()
.constants()
.at(&addrs)
Expand Down
2 changes: 1 addition & 1 deletion benches/payout-stakers/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/cliain/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion e2e-tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions e2e-tests/src/transfer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use aleph_client::{create_connection, AccountId, Client, KeyPair, Pair, SignedConnection};
use aleph_client::{create_connection, AccountId, Connection, KeyPair, Pair, SignedConnection};

use crate::{accounts::get_validators_raw_keys, config::Config};

async fn setup(config: &Config) -> (Client, KeyPair, AccountId) {
async fn setup(config: &Config) -> (Connection, KeyPair, AccountId) {
let accounts = get_validators_raw_keys(config);
let (from, to) = (
KeyPair::new(accounts[0].clone()),
Expand Down