mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 17:31:05 +00:00
Update to latest frame-metadata changes
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -5,7 +5,10 @@ use subxt_core::config::{Config, DefaultExtrinsicParams};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
// Generate an interface that we can use from the node's metadata.
|
||||
#[subxt::subxt(runtime_metadata_insecure_url = "ws://localhost:9999")]
|
||||
#[subxt::subxt(
|
||||
runtime_metadata_insecure_url = "ws://localhost:9944",
|
||||
unstable_metadata
|
||||
)]
|
||||
pub mod polkadot {}
|
||||
|
||||
// Derives aren't strictly needed, they just make developer life easier.
|
||||
@@ -14,10 +17,10 @@ pub enum MetadataConfig {}
|
||||
|
||||
impl Config for MetadataConfig {
|
||||
// Extracted from metadata directly:
|
||||
type Hash = polkadot::custom_types::Hash;
|
||||
type AccountId = polkadot::custom_types::AccountId;
|
||||
type AssetId = polkadot::custom_types::AssetId;
|
||||
type Address = polkadot::custom_types::Address;
|
||||
type Hash = polkadot::system::associated_types::Hash;
|
||||
type AccountId = polkadot::system::associated_types::AccountId;
|
||||
type AssetId = polkadot::assets::associated_types::AssetId;
|
||||
type Address = polkadot::system::associated_types::Address;
|
||||
|
||||
// Present in metadata but this PoC needs to add
|
||||
// fn specific per name of type to impl the hashing fn.
|
||||
@@ -25,7 +28,7 @@ impl Config for MetadataConfig {
|
||||
//
|
||||
// TODO: Eventually extend this to a DynamicHasher object instead.
|
||||
// Similar logic already exists for StorageHasher.
|
||||
type Hasher = polkadot::custom_types::Hashing;
|
||||
type Hasher = polkadot::system::associated_types::Hashing;
|
||||
|
||||
// Present in metadata but this PoC needs to impl the header
|
||||
// trait to make use of this.
|
||||
@@ -37,13 +40,11 @@ impl Config for MetadataConfig {
|
||||
// generated hasher to expose the same information, this is not
|
||||
// as robust and codgen can be used instead.
|
||||
// type Header = polkadot::custom_types::Header;
|
||||
type Header =
|
||||
SubstrateHeader<polkadot::custom_types::HeaderNumber, polkadot::custom_types::Hashing>;
|
||||
type Header = SubstrateHeader<u32, polkadot::system::associated_types::Hashing>;
|
||||
|
||||
// Same story, present in md but needs subxt::tx::Signer<T>.
|
||||
// type Signature = polkadot::custom_types::Signature;
|
||||
type Signature = <SubstrateConfig as Config>::Signature;
|
||||
|
||||
// Not exposed in metadata, seems like heavily involved with
|
||||
// code functionality which cannot safely be expressed in the
|
||||
// metadata.
|
||||
@@ -53,7 +54,7 @@ impl Config for MetadataConfig {
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a new API client, configured to talk to nodes.
|
||||
let api = OnlineClient::<MetadataConfig>::from_insecure_url("ws://localhost:9999").await?;
|
||||
let api = OnlineClient::<MetadataConfig>::from_insecure_url("ws://localhost:9944").await?;
|
||||
|
||||
// Build a balance transfer extrinsic.
|
||||
let dest = dev::bob().public_key().into();
|
||||
|
||||
Reference in New Issue
Block a user