Skip to content
Snippets Groups Projects

Upgrade to polkadot-v1.6.0

Merged Benjamin Gallois requested to merge bgallois/duniter-v2s:update-polkadot-1.6.0 into master
4 files
+ 1105
102
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 13
9
@@ -18,7 +18,7 @@ use crate::runtime;
use log::debug;
use sp_core::H256;
use subxt::storage::StorageKey;
use subxt::storage::Storage;
pub type Client = subxt::OnlineClient<crate::RuntimeConfig>;
pub type AccountId = subxt::utils::AccountId32;
@@ -31,7 +31,12 @@ pub async fn client(rpc_url: String) -> Client {
}
pub async fn parent_hash(client: &Client) -> H256 {
client.rpc().block_hash(None).await.unwrap().unwrap()
client
.blocks()
.at_latest()
.await
.expect("Cannot fetch latest block hash")
.hash()
}
pub async fn current_session(client: &Client, parent_hash: H256) -> u32 {
@@ -93,18 +98,17 @@ pub async fn member_iter(client: &Client, evaluation_block: H256) -> MemberIter
client
.storage()
.at(evaluation_block)
.iter(runtime::storage().membership().membership(0), 100)
.iter(runtime::storage().membership().membership(0))
.await
.expect("Cannot fetch memberships"),
)
}
pub struct MemberIter(
subxt::storage::KeyIter<
crate::RuntimeConfig,
Client,
subxt::backend::StreamOfResults<(
Vec<u8>,
runtime::runtime_types::sp_membership::MembershipData<u32>,
>,
)>,
);
impl MemberIter {
@@ -128,7 +132,7 @@ pub async fn cert_iter(client: &Client, evaluation_block: H256) -> CertIter {
)
}
pub struct CertIter(subxt::storage::KeyIter<crate::RuntimeConfig, Client, Vec<(IdtyIndex, u32)>>);
pub struct CertIter(subxt::backend::StreamOfResults<(Vec<u8>, Vec<(IdtyIndex, u32)>)>);
impl CertIter {
pub async fn next(
@@ -142,6 +146,6 @@ impl CertIter {
}
}
fn idty_id_from_storage_key(storage_key: &StorageKey) -> IdtyIndex {
fn idty_id_from_storage_key<T: subxt::Config>(storage_key: &Storage<T, Client>) -> IdtyIndex {
u32::from_le_bytes(storage_key.as_ref()[40..44].try_into().unwrap())
}
Loading