mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-24 15:57:58 +00:00
1e111ea9db
* Move Extrinsic decoding things to subxt_core and various tidy-ups * A couple more fixes and fmt * first pass moving tx logic to subxt_core * cargo fmt * fix wasm example * clippy * more clippy * WIP Adding examples and such * Move storage functionality more fully to subxt_core and nice examples for storage and txs * Add example for events * consistify how addresses/payloads are exposed in subxt-core and add runtime API fns * Add runtime API core example * fmt * remove scale-info patch * Add a little to the top level docs * swap args around * clippy * cargo fmt and fix wasm-example * doc fixes * no-std-ise new subxt-core additions * alloc, not core * more no-std fixes * A couple more fixes * Add back extrinsic decode test
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
// Copyright 2019-2024 Parity Technologies (UK) Ltd.
|
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
|
// see LICENSE for license details.
|
|
|
|
//! A [`Metadata`] type, which is used through this crate.
|
|
//!
|
|
//! This can be decoded from the bytes handed back from a node when asking for metadata.
|
|
//!
|
|
//! # Examples
|
|
//!
|
|
//! ```rust
|
|
//! use subxt_core::metadata;
|
|
//!
|
|
//! // We need to fetch the bytes from somewhere, and then we can decode them:
|
|
//! let metadata_bytes = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
|
//! let metadata = metadata::decode_from(&metadata_bytes[..]).unwrap();
|
|
//! ```
|
|
|
|
mod decode_encode_traits;
|
|
mod metadata_type;
|
|
|
|
use codec::Decode;
|
|
|
|
pub use decode_encode_traits::{DecodeWithMetadata, EncodeWithMetadata};
|
|
pub use metadata_type::Metadata;
|
|
|
|
/// Attempt to decode some bytes into [`Metadata`], returning an error
|
|
/// if decoding fails.
|
|
///
|
|
/// This is a shortcut for importing [`codec::Decode`] and using the
|
|
/// implementation of that on [`Metadata`].
|
|
pub fn decode_from(bytes: &[u8]) -> Result<Metadata, codec::Error> {
|
|
Metadata::decode(&mut &*bytes)
|
|
}
|