mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
XXX: Backup v15 show md via metadata_at_version
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ serde_json = "1.0.68"
|
||||
# hex encoded metadata to bytes
|
||||
hex = "0.4.3"
|
||||
# actual metadata types
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v15", "std"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v14", "v15-unstable", "std"] }
|
||||
# decode bytes into the metadata types
|
||||
scale = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
|
||||
# generate the item mod for codegen
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ description = "Generate an API for interacting with a substrate node from FRAME
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full"] }
|
||||
darling = "0.14.0"
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v15", "std"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v14", "v15-unstable", "std"] }
|
||||
heck = "0.4.0"
|
||||
proc-macro2 = "1.0.24"
|
||||
proc-macro-error = "1.0.4"
|
||||
|
||||
@@ -29,10 +29,12 @@ use crate::{
|
||||
};
|
||||
use codec::Decode;
|
||||
use frame_metadata::{
|
||||
v15::RuntimeMetadataV15,
|
||||
v15::{
|
||||
RuntimeMetadataV15,
|
||||
TraitMetadata,
|
||||
},
|
||||
RuntimeMetadata,
|
||||
RuntimeMetadataPrefixed,
|
||||
TraitMetadata,
|
||||
};
|
||||
use heck::ToSnakeCase as _;
|
||||
use proc_macro2::TokenStream as TokenStream2;
|
||||
|
||||
@@ -21,8 +21,8 @@ use subxt::{
|
||||
PolkadotConfig,
|
||||
};
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
pub mod polkadot {}
|
||||
// #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
|
||||
// pub mod polkadot {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -31,35 +31,35 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a client to use:
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
|
||||
let active_era_addr = polkadot::storage().staking().active_era();
|
||||
let era = api.storage().fetch(&active_era_addr, None).await?.unwrap();
|
||||
println!(
|
||||
"Staking active era: index: {:?}, start: {:?}",
|
||||
era.index, era.start
|
||||
);
|
||||
// let active_era_addr = polkadot::storage().staking().active_era();
|
||||
// let era = api.storage().fetch(&active_era_addr, None).await?.unwrap();
|
||||
// println!(
|
||||
// "Staking active era: index: {:?}, start: {:?}",
|
||||
// era.index, era.start
|
||||
// );
|
||||
|
||||
let alice_id = AccountKeyring::Alice.to_account_id();
|
||||
println!(" Alice account id: {:?}", alice_id);
|
||||
// let alice_id = AccountKeyring::Alice.to_account_id();
|
||||
// println!(" Alice account id: {:?}", alice_id);
|
||||
|
||||
// Get Alice' Stash account ID
|
||||
let alice_stash_id: AccountId32 = sr25519::Pair::from_string("//Alice//stash", None)
|
||||
.expect("Could not obtain stash signer pair")
|
||||
.public()
|
||||
.into();
|
||||
println!(" Alice//stash account id: {:?}", alice_stash_id);
|
||||
// // Get Alice' Stash account ID
|
||||
// let alice_stash_id: AccountId32 = sr25519::Pair::from_string("//Alice//stash", None)
|
||||
// .expect("Could not obtain stash signer pair")
|
||||
// .public()
|
||||
// .into();
|
||||
// println!(" Alice//stash account id: {:?}", alice_stash_id);
|
||||
|
||||
// Map from all locked "stash" accounts to the controller account.
|
||||
let controller_acc_addr = polkadot::storage().staking().bonded(&alice_stash_id);
|
||||
let controller_acc = api
|
||||
.storage()
|
||||
.fetch(&controller_acc_addr, None)
|
||||
.await?
|
||||
.unwrap();
|
||||
println!(" account controlled by: {:?}", controller_acc);
|
||||
// // Map from all locked "stash" accounts to the controller account.
|
||||
// let controller_acc_addr = polkadot::storage().staking().bonded(&alice_stash_id);
|
||||
// let controller_acc = api
|
||||
// .storage()
|
||||
// .fetch(&controller_acc_addr, None)
|
||||
// .await?
|
||||
// .unwrap();
|
||||
// println!(" account controlled by: {:?}", controller_acc);
|
||||
|
||||
let era_reward_addr = polkadot::storage().staking().eras_reward_points(era.index);
|
||||
let era_result = api.storage().fetch(&era_reward_addr, None).await?;
|
||||
println!("Era reward points: {:?}", era_result);
|
||||
// let era_reward_addr = polkadot::storage().staking().eras_reward_points(era.index);
|
||||
// let era_result = api.storage().fetch(&era_reward_addr, None).await?;
|
||||
// println!("Era reward points: {:?}", era_result);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ description = "Command line utilities for checking metadata compatibility betwee
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v15", "std"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v14", "v15-unstable", "std"] }
|
||||
scale-info = "2.0.0"
|
||||
sp-core-hashing = "6.0.0"
|
||||
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use frame_metadata::{
|
||||
v15::RuntimeMetadataV15,
|
||||
ExtrinsicMetadata,
|
||||
RuntimeMetadataV15,
|
||||
StorageEntryMetadata,
|
||||
StorageEntryType,
|
||||
};
|
||||
@@ -247,7 +247,7 @@ fn get_storage_entry_hash(
|
||||
|
||||
/// Obtain the hash for a specific storage item, or an error if it's not found.
|
||||
pub fn get_storage_hash(
|
||||
metadata: &RuntimeMetadataV15,
|
||||
metadata: &frame_metadata::v15::RuntimeMetadataV15,
|
||||
pallet_name: &str,
|
||||
storage_name: &str,
|
||||
) -> Result<[u8; 32], NotFound> {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ serde_json = { version = "1.0.64", features = ["raw_value"] }
|
||||
thiserror = "1.0.24"
|
||||
tracing = "0.1.34"
|
||||
parking_lot = "0.12.0"
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v15", "std"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v14", "v15-unstable", "std"] }
|
||||
derivative = "2.2.0"
|
||||
|
||||
subxt-macro = { version = "0.25.0", path = "../macro" }
|
||||
|
||||
@@ -109,6 +109,8 @@ impl<T: Config> OnlineClient<T> {
|
||||
pub async fn from_rpc_client<R: RpcClientT>(
|
||||
rpc_client: Arc<R>,
|
||||
) -> Result<OnlineClient<T>, Error> {
|
||||
println!("CONSTRUCT CLIENT");
|
||||
|
||||
let rpc = Rpc::<T>::new(rpc_client.clone());
|
||||
let (genesis_hash, runtime_version, metadata) = future::join3(
|
||||
rpc.genesis_hash(),
|
||||
@@ -155,20 +157,36 @@ impl<T: Config> OnlineClient<T> {
|
||||
|
||||
/// Fetch the metadata from substrate using the runtime API.
|
||||
async fn fetch_metadata(rpc: &Rpc<T>) -> Result<Metadata, Error> {
|
||||
let bytes = rpc.state_call("Metadata_metadata", None, None).await?;
|
||||
use codec::Encode;
|
||||
|
||||
let decoded: (Vec<String>, OpaqueMetadata) = Decode::decode(&mut &*bytes)?;
|
||||
|
||||
let bytes = decoded.1 .0;
|
||||
let param = 15u32.encode();
|
||||
let bytes = rpc
|
||||
.state_call("Metadata_metadata_at_version", Some(¶m), None)
|
||||
.await?;
|
||||
|
||||
// println!("GOT BYTES: {:?}", bytes);
|
||||
|
||||
let decoded: Option<OpaqueMetadata> = Decode::decode(&mut &*bytes)?;
|
||||
|
||||
println!("Decoded opaque");
|
||||
|
||||
let decoded = decoded.unwrap();
|
||||
let bytes = &decoded.0;
|
||||
let meta: RuntimeMetadataPrefixed = Decode::decode(&mut &bytes[..])?;
|
||||
|
||||
let metadata: Metadata = meta.try_into()?;
|
||||
// let metadata: Metadata = meta.try_into()?;
|
||||
|
||||
println!("Availb methods {:?}", decoded.0);
|
||||
// println!("Availb methods {:?}", decoded.0);
|
||||
|
||||
// let cursor = &mut &*bytes;
|
||||
// let _ = <Compact<u32>>::decode(cursor)?;
|
||||
// let meta: RuntimeMetadataPrefixed = Decode::decode(cursor)?;
|
||||
// let meta: frame_metadata::RuntimeMetadataPrefixed = Decode::decode(cursor)?;
|
||||
|
||||
println!("METADATA {:#?}", meta);
|
||||
|
||||
let metadata: Metadata = meta.try_into()?;
|
||||
|
||||
Ok(metadata)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
use super::hash_cache::HashCache;
|
||||
use codec::Error as CodecError;
|
||||
use frame_metadata::{
|
||||
v15::RuntimeMetadataV15,
|
||||
PalletConstantMetadata,
|
||||
RuntimeMetadata,
|
||||
RuntimeMetadataPrefixed,
|
||||
RuntimeMetadataV15,
|
||||
StorageEntryMetadata,
|
||||
META_RESERVED,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ default = ["subxt/integration-tests"]
|
||||
[dev-dependencies]
|
||||
assert_matches = "1.5.0"
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v15", "std"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v14", "v15-unstable", "std"] }
|
||||
futures = "0.3.13"
|
||||
hex = "0.4.3"
|
||||
regex = "1.5.0"
|
||||
|
||||
@@ -11,6 +11,6 @@ publish = false
|
||||
[dev-dependencies]
|
||||
trybuild = "1.0.76"
|
||||
scale-info = { version = "2.3.0", features = ["bit-vec"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v15", "std"] }
|
||||
frame-metadata = { version = "15.0.0", path = "/home/lexnv/remote-builds/frame-metadata/frame-metadata", features = ["v14", "v15-unstable", "std"] }
|
||||
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive", "full", "bit-vec"] }
|
||||
subxt = { path = "../../subxt" }
|
||||
|
||||
Reference in New Issue
Block a user