Skip to content

Commit cb58f2a

Browse files
Move to lib
1 parent 48a5ccd commit cb58f2a

File tree

16 files changed

+43
-44
lines changed

16 files changed

+43
-44
lines changed

aleph-client/src/connections.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ use std::{thread::sleep, time::Duration};
33
use anyhow::anyhow;
44
use codec::Decode;
55
use log::info;
6-
use serde::{Deserialize, Serialize};
76
use subxt::{
8-
blocks::ExtrinsicEvents,
97
ext::sp_core::Bytes,
108
metadata::DecodeWithMetadata,
119
rpc::RpcParams,
@@ -15,8 +13,8 @@ use subxt::{
1513
};
1614

1715
use crate::{
18-
api, sp_weights::weight_v2::Weight, AccountId, AlephConfig, BlockHash, Call, KeyPair,
19-
SubxtClient, TxHash, TxStatus,
16+
api, sp_weights::weight_v2::Weight, AccountId, BlockHash, Call, KeyPair, SubxtClient, TxInfo,
17+
TxStatus,
2018
};
2119

2220
/// Capable of communicating with a live Aleph chain.
@@ -108,22 +106,6 @@ pub trait ConnectionApi: Sync {
108106
async fn rpc_call<R: Decode>(&self, func_name: String, params: RpcParams) -> anyhow::Result<R>;
109107
}
110108

111-
/// Data regarding submitted transaction.
112-
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Deserialize, Serialize)]
113-
pub struct TxInfo {
114-
pub block_hash: BlockHash,
115-
pub tx_hash: TxHash,
116-
}
117-
118-
impl From<ExtrinsicEvents<AlephConfig>> for TxInfo {
119-
fn from(ee: ExtrinsicEvents<AlephConfig>) -> Self {
120-
Self {
121-
block_hash: ee.extrinsic_hash(),
122-
tx_hash: ee.block_hash(),
123-
}
124-
}
125-
}
126-
127109
/// Signed connection should be able to sends transactions to chain
128110
#[async_trait::async_trait]
129111
pub trait SignedConnectionApi: ConnectionApi {

aleph-client/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
extern crate core;
1414

1515
pub use contract_transcode;
16+
use serde::{Deserialize, Serialize};
1617
pub use subxt::ext::sp_core::Pair;
1718
use subxt::{
19+
blocks::ExtrinsicEvents,
1820
ext::sp_core::{ed25519, sr25519, H256},
1921
tx::PairSigner,
2022
OnlineClient, PolkadotConfig,
@@ -100,3 +102,21 @@ where
100102
{
101103
AccountId::from(keypair.public())
102104
}
105+
106+
/// Data regarding submitted transaction.
107+
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Deserialize, Serialize)]
108+
pub struct TxInfo {
109+
/// Hash of the block that contains the transaction.
110+
pub block_hash: BlockHash,
111+
/// The hash of the transaction.
112+
pub tx_hash: TxHash,
113+
}
114+
115+
impl From<ExtrinsicEvents<AlephConfig>> for TxInfo {
116+
fn from(ee: ExtrinsicEvents<AlephConfig>) -> Self {
117+
Self {
118+
block_hash: ee.extrinsic_hash(),
119+
tx_hash: ee.block_hash(),
120+
}
121+
}
122+
}

aleph-client/src/pallets/aleph.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ use crate::{
77
pallet_aleph::pallet::Call::set_emergency_finalizer, primitives::app::Public,
88
sp_core::ed25519::Public as EdPublic,
99
},
10-
connections::TxInfo,
1110
pallet_aleph::pallet::Call::schedule_finality_version_change,
1211
AccountId, AlephKeyPair, BlockHash,
1312
Call::Aleph,
14-
ConnectionApi, Pair, RootConnection, SudoCall, TxStatus,
13+
ConnectionApi, Pair, RootConnection, SudoCall, TxInfo, TxStatus,
1514
};
1615

1716
// TODO replace docs with link to pallet aleph docs, once they are published

aleph-client/src/pallets/balances.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use subxt::{ext::sp_runtime::MultiAddress, tx::PolkadotExtrinsicParamsBuilder};
33

44
use crate::{
55
aleph_zero::{self, api, api::runtime_types::pallet_balances::BalanceLock},
6-
connections::TxInfo,
76
pallet_balances::pallet::Call::transfer,
87
pallets::utility::UtilityApi,
98
AccountId, BlockHash,
109
Call::Balances,
11-
ConnectionApi, SignedConnectionApi, TxStatus,
10+
ConnectionApi, SignedConnectionApi, TxInfo, TxStatus,
1211
};
1312

1413
/// Pallet balances read-only API.

aleph-client/src/pallets/contract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use primitives::Balance;
44
use subxt::{ext::sp_core::Bytes, rpc_params};
55

66
use crate::{
7-
api, connections::TxInfo, pallet_contracts::wasm::OwnerInfo, sp_weights::weight_v2::Weight,
8-
AccountId, BlockHash, ConnectionApi, SignedConnectionApi, TxStatus,
7+
api, pallet_contracts::wasm::OwnerInfo, sp_weights::weight_v2::Weight, AccountId, BlockHash,
8+
ConnectionApi, SignedConnectionApi, TxInfo, TxStatus,
99
};
1010

1111
/// Arguments to [`ContractRpc::call_and_get`].

aleph-client/src/pallets/elections.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ use crate::{
66
pallet_elections::pallet::Call::set_ban_config,
77
primitives::{BanReason, CommitteeSeats, EraValidators},
88
},
9-
connections::{AsConnection, TxInfo},
9+
connections::AsConnection,
1010
pallet_elections::pallet::Call::{
1111
ban_from_committee, change_validators, set_elections_openness,
1212
},
1313
primitives::{BanConfig, BanInfo, ElectionOpenness},
1414
AccountId, BlockHash,
1515
Call::Elections,
16-
ConnectionApi, RootConnection, SudoCall, TxStatus,
16+
ConnectionApi, RootConnection, SudoCall, TxInfo, TxStatus,
1717
};
1818

1919
// TODO once pallet elections docs are published, replace api docs with links to public docs

aleph-client/src/pallets/multisig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use sp_core::blake2_256;
77
use sp_runtime::traits::TrailingZeroInput;
88

99
use crate::{
10-
account_from_keypair, aleph_runtime::RuntimeCall, api, api::runtime_types, connections::TxInfo,
10+
account_from_keypair, aleph_runtime::RuntimeCall, api, api::runtime_types,
1111
sp_weights::weight_v2::Weight, AccountId, BlockHash, ConnectionApi, SignedConnectionApi,
12-
TxStatus,
12+
TxInfo, TxStatus,
1313
};
1414

1515
/// An alias for a call hash.

aleph-client/src/pallets/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use primitives::SessionIndex;
22

33
use crate::{
4-
api, api::runtime_types::aleph_runtime::SessionKeys, connections::TxInfo, AccountId, BlockHash,
5-
ConnectionApi, SignedConnectionApi, TxStatus,
4+
api, api::runtime_types::aleph_runtime::SessionKeys, AccountId, BlockHash, ConnectionApi,
5+
SignedConnectionApi, TxInfo, TxStatus,
66
};
77

88
/// Pallet session read-only api.

aleph-client/src/pallets/staking.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use subxt::{
99

1010
use crate::{
1111
api,
12-
connections::{AsConnection, TxInfo},
12+
connections::AsConnection,
1313
pallet_staking::{
1414
pallet::pallet::{
1515
Call::{bond, force_new_era, nominate, set_staking_configs},
@@ -23,7 +23,7 @@ use crate::{
2323
sp_arithmetic::per_things::Perbill,
2424
AccountId, BlockHash,
2525
Call::{Staking, Sudo},
26-
ConnectionApi, RootConnection, SignedConnectionApi, SudoCall, TxStatus,
26+
ConnectionApi, RootConnection, SignedConnectionApi, SudoCall, TxInfo, TxStatus,
2727
};
2828

2929
/// Any object that implemnts pallet staking read-only api.

aleph-client/src/pallets/system.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ use subxt::ext::sp_runtime::Perbill as SPerbill;
33

44
use crate::{
55
api,
6-
connections::TxInfo,
76
frame_system::pallet::Call::{fill_block, set_code},
87
sp_arithmetic::per_things::Perbill,
98
AccountId, BlockHash,
109
Call::System,
11-
ConnectionApi, RootConnection, SudoCall, TxStatus,
10+
ConnectionApi, RootConnection, SudoCall, TxInfo, TxStatus,
1211
};
1312

1413
/// Pallet system read-only api.

0 commit comments

Comments
 (0)