mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
no-std tests and porting of subxt-metadata
This commit is contained in:
@@ -358,3 +358,30 @@ jobs:
|
||||
wasm-pack test --headless --firefox
|
||||
wasm-pack test --headless --chrome
|
||||
working-directory: signer/wasm-tests
|
||||
|
||||
no-std-tests:
|
||||
name: "Test (no_std)"
|
||||
runs-on: ubuntu-latest
|
||||
needs: [machete, docs]
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Note: needs nighly toolchain because otherwise we cannot define custom lang-items.
|
||||
- name: Install Rust nightly toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
|
||||
- name: Rust Cache
|
||||
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
|
||||
|
||||
# Note: in `no_std` no real tests are possible, we just run a binary with some tests in it which panic upon failure.
|
||||
- name: Run tests
|
||||
uses: actions-rs/cargo@v1.0.3
|
||||
run: |
|
||||
cargo run
|
||||
working-directory: testing/no-std-tests
|
||||
|
||||
Generated
+28
-22
@@ -793,9 +793,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "chrono"
|
||||
version = "0.4.32"
|
||||
version = "0.4.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a"
|
||||
checksum = "9f13690e35a5e4ace198e7beea2895d29f3a9cc55015fcebe6336bd2010af9eb"
|
||||
dependencies = [
|
||||
"android-tzdata",
|
||||
"iana-time-zone",
|
||||
@@ -805,9 +805,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ciborium"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926"
|
||||
checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e"
|
||||
dependencies = [
|
||||
"ciborium-io",
|
||||
"ciborium-ll",
|
||||
@@ -816,15 +816,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ciborium-io"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656"
|
||||
checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757"
|
||||
|
||||
[[package]]
|
||||
name = "ciborium-ll"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b"
|
||||
checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9"
|
||||
dependencies = [
|
||||
"ciborium-io",
|
||||
"half",
|
||||
@@ -1891,9 +1891,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.2"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash-db"
|
||||
@@ -2865,18 +2869,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"
|
||||
checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0"
|
||||
dependencies = [
|
||||
"pin-project-internal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-internal"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"
|
||||
checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -3182,7 +3186,7 @@ checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata 0.4.4",
|
||||
"regex-automata 0.4.5",
|
||||
"regex-syntax 0.8.2",
|
||||
]
|
||||
|
||||
@@ -3197,9 +3201,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b7fa1134405e2ec9353fd416b17f8dacd46c473d7d3fd1cf202706a14eb792a"
|
||||
checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -4573,12 +4577,14 @@ version = "0.34.0"
|
||||
dependencies = [
|
||||
"assert_matches",
|
||||
"bitvec",
|
||||
"cfg-if",
|
||||
"criterion",
|
||||
"derive_more",
|
||||
"frame-metadata 16.0.0",
|
||||
"hashbrown 0.14.3",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"sp-core-hashing",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5312,9 +5318,9 @@ checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b"
|
||||
|
||||
[[package]]
|
||||
name = "wasmi"
|
||||
version = "0.31.1"
|
||||
version = "0.31.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "acfc1e384a36ca532d070a315925887247f3c7e23567e23e0ac9b1c5d6b8bf76"
|
||||
checksum = "77a8281d1d660cdf54c76a3efa9ddd0c270cada1383a995db3ccb43d166456c7"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"spin",
|
||||
@@ -5325,9 +5331,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmi_arena"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "401c1f35e413fac1846d4843745589d9ec678977ab35a384db8ae7830525d468"
|
||||
checksum = "104a7f73be44570cac297b3035d76b169d6599637631cf37a1703326a0727073"
|
||||
|
||||
[[package]]
|
||||
name = "wasmi_core"
|
||||
|
||||
+7
-4
@@ -18,7 +18,7 @@ members = [
|
||||
# We exclude any crates that would depend on non mutually
|
||||
# exclusive feature flags and thus can't compile with the
|
||||
# workspace:
|
||||
exclude = ["testing/wasm-rpc-tests", "testing/wasm-lightclient-tests", "signer/wasm-tests", "examples/wasm-example", "examples/parachain-example"]
|
||||
exclude = ["testing/no-std-tests", "testing/wasm-rpc-tests", "testing/wasm-lightclient-tests", "signer/wasm-tests", "examples/wasm-example", "examples/parachain-example"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
@@ -57,16 +57,19 @@ base58 = { version = "0.2.0" }
|
||||
bitvec = { version = "1", default-features = false }
|
||||
blake2 = { version = "0.10.6", default-features = false }
|
||||
clap = { version = "4.4.18", features = ["derive", "cargo"] }
|
||||
cfg-if = "1.0.0"
|
||||
criterion = "0.4"
|
||||
codec = { package = "parity-scale-codec", version = "3.4.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false }
|
||||
color-eyre = "0.6.1"
|
||||
console_error_panic_hook = "0.1.7"
|
||||
darling = "0.20.3"
|
||||
derivative = "2.2.0"
|
||||
derive_more = "0.99.17"
|
||||
either = "1.9.0"
|
||||
frame-metadata = { version = "16.0.0", default-features = false, features = ["current", "std"] }
|
||||
frame-metadata = { version = "16.0.0", default-features = false }
|
||||
futures = { version = "0.3.30", default-features = false, features = ["std"] }
|
||||
getrandom = { version = "0.2", default-features = false }
|
||||
hashbrown = "0.14.3"
|
||||
hex = "0.4.3"
|
||||
heck = "0.4.1"
|
||||
impl-serde = { version = "0.4.0" }
|
||||
@@ -78,7 +81,7 @@ proc-macro-error = "1.0.4"
|
||||
proc-macro2 = "1.0.78"
|
||||
quote = "1.0.35"
|
||||
regex = "1.10.3"
|
||||
scale-info = "2.10.0"
|
||||
scale-info = { version = "2.10.0", default-features = false }
|
||||
scale-value = "0.13.0"
|
||||
scale-bits = "0.4.0"
|
||||
scale-decode = "0.10.0"
|
||||
|
||||
+10
-4
@@ -13,12 +13,18 @@ documentation.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Command line utilities for checking metadata compatibility between nodes."
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["scale-info/std", "frame-metadata/std"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", workspace = true, features = ["derive"] }
|
||||
frame-metadata = { workspace = true }
|
||||
scale-info = { workspace = true }
|
||||
scale-info = { workspace = true, default-features = false }
|
||||
frame-metadata = { workspace = true, default-features = false, features = ["current", "decode"] }
|
||||
codec = { package = "parity-scale-codec", workspace = true, default-features = false, features = ["derive"] }
|
||||
sp-core-hashing = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
hashbrown = { workspace = true }
|
||||
derive_more = { workspace = true }
|
||||
cfg-if = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
bitvec = { workspace = true, features = ["alloc"] }
|
||||
|
||||
@@ -2,31 +2,38 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::prelude::*;
|
||||
use derive_more::Display;
|
||||
use string::String;
|
||||
|
||||
mod v14;
|
||||
mod v15;
|
||||
|
||||
/// An error emitted if something goes wrong converting [`frame_metadata`]
|
||||
/// types into [`crate::Metadata`].
|
||||
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
|
||||
#[derive(Debug, Display, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum TryFromError {
|
||||
/// Type missing from type registry
|
||||
#[error("Type id {0} is expected but not found in the type registry")]
|
||||
#[display(fmt = "Type id {_0} is expected but not found in the type registry")]
|
||||
TypeNotFound(u32),
|
||||
/// Type was not a variant/enum type
|
||||
#[error("Type {0} was not a variant/enum type, but is expected to be one")]
|
||||
#[display(fmt = "Type {_0} was not a variant/enum type, but is expected to be one")]
|
||||
VariantExpected(u32),
|
||||
/// An unsupported metadata version was provided.
|
||||
#[error("Cannot convert v{0} metadata into Metadata type")]
|
||||
#[display(fmt = "Cannot convert v{_0} metadata into Metadata type")]
|
||||
UnsupportedMetadataVersion(u32),
|
||||
/// Type name missing from type registry
|
||||
#[error("Type name {0} is expected but not found in the type registry")]
|
||||
#[display(fmt = "Type name {_0} is expected but not found in the type registry")]
|
||||
TypeNameNotFound(String),
|
||||
/// Invalid type path.
|
||||
#[error("Type has an invalid path {0}")]
|
||||
#[display(fmt = "Type has an invalid path {_0}")]
|
||||
InvalidTypePath(String),
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl std::error::Error for TryFromError {}
|
||||
|
||||
impl From<crate::Metadata> for frame_metadata::RuntimeMetadataPrefixed {
|
||||
fn from(value: crate::Metadata) -> Self {
|
||||
let m: frame_metadata::v15::RuntimeMetadataV15 = value.into();
|
||||
|
||||
@@ -2,12 +2,16 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::TryFromError;
|
||||
use crate::prelude::*;
|
||||
use crate::Metadata;
|
||||
use borrow::ToOwned;
|
||||
use fmt::Write;
|
||||
use frame_metadata::{v14, v15};
|
||||
use hashbrown::HashMap;
|
||||
use scale_info::TypeDef;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
impl TryFrom<v14::RuntimeMetadataV14> for Metadata {
|
||||
type Error = TryFromError;
|
||||
@@ -31,27 +35,27 @@ fn v15_to_v14(mut metadata: v15::RuntimeMetadataV15) -> v14::RuntimeMetadataV14
|
||||
let extrinsic_type = scale_info::Type {
|
||||
path: scale_info::Path {
|
||||
segments: vec![
|
||||
"primitives".to_string(),
|
||||
"runtime".to_string(),
|
||||
"generic".to_string(),
|
||||
"UncheckedExtrinsic".to_string(),
|
||||
"primitives".to_owned(),
|
||||
"runtime".to_owned(),
|
||||
"generic".to_owned(),
|
||||
"UncheckedExtrinsic".to_owned(),
|
||||
],
|
||||
},
|
||||
type_params: vec![
|
||||
scale_info::TypeParameter::<scale_info::form::PortableForm> {
|
||||
name: "Address".to_string(),
|
||||
name: "Address".to_owned(),
|
||||
ty: Some(metadata.extrinsic.address_ty),
|
||||
},
|
||||
scale_info::TypeParameter::<scale_info::form::PortableForm> {
|
||||
name: "Call".to_string(),
|
||||
name: "Call".to_owned(),
|
||||
ty: Some(metadata.extrinsic.call_ty),
|
||||
},
|
||||
scale_info::TypeParameter::<scale_info::form::PortableForm> {
|
||||
name: "Signature".to_string(),
|
||||
name: "Signature".to_owned(),
|
||||
ty: Some(metadata.extrinsic.signature_ty),
|
||||
},
|
||||
scale_info::TypeParameter::<scale_info::form::PortableForm> {
|
||||
name: "Extra".to_string(),
|
||||
name: "Extra".to_owned(),
|
||||
ty: Some(metadata.extrinsic.extra_ty),
|
||||
},
|
||||
],
|
||||
@@ -342,7 +346,7 @@ fn generate_outer_enums(
|
||||
let Some(last) = call_path.last_mut() else {
|
||||
return Err(TryFromError::InvalidTypePath("RuntimeCall".into()));
|
||||
};
|
||||
*last = "RuntimeError".to_string();
|
||||
*last = "RuntimeError".to_owned();
|
||||
generate_outer_error_enum_type(metadata, call_path)
|
||||
};
|
||||
|
||||
@@ -368,7 +372,10 @@ fn generate_outer_error_enum_type(
|
||||
return None;
|
||||
};
|
||||
|
||||
let path = format!("{}Error", pallet.name);
|
||||
// Note: using the `format!` macro like in `let path = format!("{}Error", pallet.name);`
|
||||
// leads to linker errors about extern function `_Unwind_Resume` not being defined.
|
||||
let mut path = String::new();
|
||||
write!(path, "{}Error", pallet.name).expect("Cannot panic, qed;");
|
||||
let ty = error.ty.id.into();
|
||||
|
||||
Some(scale_info::Variant {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// see LICENSE for license details.
|
||||
|
||||
use super::TryFromError;
|
||||
use crate::prelude::*;
|
||||
use crate::utils::variant_index::VariantIndex;
|
||||
use crate::{
|
||||
utils::ordered_map::OrderedMap, ArcStr, ConstantMetadata, ExtrinsicMetadata, Metadata,
|
||||
@@ -10,9 +11,10 @@ use crate::{
|
||||
RuntimeApiMethodParamMetadata, SignedExtensionMetadata, StorageEntryMetadata,
|
||||
StorageEntryModifier, StorageEntryType, StorageHasher, StorageMetadata,
|
||||
};
|
||||
use borrow::ToOwned;
|
||||
use frame_metadata::v15;
|
||||
use hashbrown::HashMap;
|
||||
use scale_info::form::PortableForm;
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Converting from V15 metadata into our Subxt repr.
|
||||
mod from_v15 {
|
||||
|
||||
+7
-2
@@ -14,16 +14,21 @@
|
||||
//! 2. Obtaining [`frame_metadata::RuntimeMetadataPrefixed`], and then
|
||||
//! using `.try_into()` to convert it into [`Metadata`].
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![deny(missing_docs)]
|
||||
|
||||
mod from_into;
|
||||
mod prelude;
|
||||
mod utils;
|
||||
|
||||
use hashbrown::HashMap;
|
||||
use prelude::*;
|
||||
use scale_info::{form::PortableForm, PortableRegistry, Variant};
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use string::String;
|
||||
use sync::Arc;
|
||||
use utils::variant_index::VariantIndex;
|
||||
use utils::{ordered_map::OrderedMap, validation::outer_enum_hashes::OuterEnumHashes};
|
||||
use vec::Vec;
|
||||
|
||||
type ArcStr = Arc<str>;
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate alloc;
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "std")] {
|
||||
#[allow(unused)]
|
||||
pub use std::{
|
||||
any,
|
||||
borrow,
|
||||
boxed,
|
||||
cmp,
|
||||
collections,
|
||||
fmt,
|
||||
format,
|
||||
hash,
|
||||
marker,
|
||||
mem,
|
||||
num,
|
||||
ops,
|
||||
string,
|
||||
sync,
|
||||
time,
|
||||
vec,
|
||||
rc,
|
||||
iter,
|
||||
};
|
||||
} else {
|
||||
#[allow(unused)]
|
||||
pub use alloc::{
|
||||
borrow,
|
||||
boxed,
|
||||
collections,
|
||||
format,
|
||||
string,
|
||||
sync,
|
||||
vec,
|
||||
rc
|
||||
};
|
||||
#[allow(unused)]
|
||||
pub use core::{
|
||||
any,
|
||||
cmp,
|
||||
fmt,
|
||||
hash,
|
||||
marker,
|
||||
mem,
|
||||
num,
|
||||
ops,
|
||||
time,
|
||||
iter,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use crate::prelude::*;
|
||||
use hashbrown::HashMap;
|
||||
use vec::Vec;
|
||||
|
||||
/// A minimal ordered map to let one search for
|
||||
/// things by key or get the values in insert order.
|
||||
@@ -23,7 +25,7 @@ impl<K, V> Default for OrderedMap<K, V> {
|
||||
|
||||
impl<K, V> OrderedMap<K, V>
|
||||
where
|
||||
K: PartialEq + Eq + std::hash::Hash,
|
||||
K: PartialEq + Eq + hash::Hash,
|
||||
{
|
||||
/// Create a new, empty [`OrderedMap`].
|
||||
pub fn new() -> Self {
|
||||
@@ -47,8 +49,8 @@ where
|
||||
where
|
||||
F: FnMut(&V) -> bool,
|
||||
{
|
||||
let values = std::mem::take(&mut self.values);
|
||||
let map = std::mem::take(&mut self.map);
|
||||
let values = mem::take(&mut self.values);
|
||||
let map = mem::take(&mut self.map);
|
||||
|
||||
// Filter the values, storing a map from old to new positions:
|
||||
let mut new_values = Vec::new();
|
||||
@@ -78,8 +80,8 @@ where
|
||||
/// Get an item by its key.
|
||||
pub fn get_by_key<Q>(&self, key: &Q) -> Option<&V>
|
||||
where
|
||||
K: std::borrow::Borrow<Q>,
|
||||
Q: std::hash::Hash + Eq + ?Sized,
|
||||
K: borrow::Borrow<Q>,
|
||||
Q: hash::Hash + Eq + ?Sized,
|
||||
{
|
||||
self.map.get(key).and_then(|&v| self.values.get(v))
|
||||
}
|
||||
@@ -107,7 +109,7 @@ where
|
||||
|
||||
impl<K, V> FromIterator<(K, V)> for OrderedMap<K, V>
|
||||
where
|
||||
K: PartialEq + Eq + std::hash::Hash,
|
||||
K: PartialEq + Eq + hash::Hash,
|
||||
{
|
||||
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self {
|
||||
let mut map = OrderedMap::new();
|
||||
|
||||
@@ -4,12 +4,14 @@
|
||||
|
||||
//! Utility functions to generate a subset of the metadata.
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
ExtrinsicMetadata, Metadata, OuterEnumsMetadata, PalletMetadataInner, RuntimeApiMetadataInner,
|
||||
StorageEntryType,
|
||||
};
|
||||
use collections::BTreeMap;
|
||||
use hashbrown::HashSet;
|
||||
use scale_info::TypeDef;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
|
||||
/// Collect all type IDs needed to represent the provided pallet.
|
||||
fn collect_pallet_types(pallet: &PalletMetadataInner, type_ids: &mut HashSet<u32>) {
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
//! Utility functions for metadata validation.
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
CustomMetadata, CustomValueMetadata, ExtrinsicMetadata, Metadata, PalletMetadata,
|
||||
RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata, StorageEntryType,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use outer_enum_hashes::OuterEnumHashes;
|
||||
use scale_info::{form::PortableForm, Field, PortableRegistry, TypeDef, TypeDefVariant, Variant};
|
||||
use std::collections::HashMap;
|
||||
use vec::Vec;
|
||||
|
||||
pub mod outer_enum_hashes;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Hash representations of the `frame_metadata::v15::OuterEnums`.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use hashbrown::HashMap;
|
||||
|
||||
use scale_info::{PortableRegistry, TypeDef};
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::prelude::*;
|
||||
use borrow::ToOwned;
|
||||
use hashbrown::HashMap;
|
||||
use scale_info::{form::PortableForm, PortableRegistry, TypeDef, Variant};
|
||||
use std::collections::HashMap;
|
||||
use string::String;
|
||||
|
||||
/// Given some type ID and type registry, build a couple of
|
||||
/// indexes to look up variants by index or name. If the ID provided
|
||||
@@ -62,8 +65,8 @@ impl VariantIndex {
|
||||
types: &'a PortableRegistry,
|
||||
) -> Option<&'a Variant<PortableForm>>
|
||||
where
|
||||
String: std::borrow::Borrow<K>,
|
||||
K: std::hash::Hash + Eq + ?Sized,
|
||||
String: borrow::Borrow<K>,
|
||||
K: hash::Hash + Eq + ?Sized,
|
||||
{
|
||||
let pos = *self.by_name.get(name)?;
|
||||
let variants = Self::get(variant_id, types)?;
|
||||
|
||||
+3
-15
@@ -24,23 +24,11 @@ default = ["jsonrpsee", "native"]
|
||||
|
||||
# Enable this for native (ie non web/wasm builds).
|
||||
# Exactly 1 of "web" and "native" is expected.
|
||||
native = [
|
||||
"jsonrpsee?/async-client",
|
||||
"jsonrpsee?/client-ws-transport-native-tls",
|
||||
"subxt-lightclient?/native",
|
||||
"tokio-util"
|
||||
]
|
||||
native = ["jsonrpsee?/async-client", "jsonrpsee?/client-ws-transport-native-tls", "subxt-lightclient?/native", "tokio-util"]
|
||||
|
||||
# Enable this for web/wasm builds.
|
||||
# Exactly 1 of "web" and "native" is expected.
|
||||
web = [
|
||||
"jsonrpsee?/async-wasm-client",
|
||||
"jsonrpsee?/client-web-transport",
|
||||
"getrandom/js",
|
||||
"subxt-lightclient?/web",
|
||||
"subxt-macro/web",
|
||||
"instant/wasm-bindgen"
|
||||
]
|
||||
web = ["jsonrpsee?/async-wasm-client", "jsonrpsee?/client-web-transport", "getrandom/js", "subxt-lightclient?/web", "subxt-macro/web", "instant/wasm-bindgen"]
|
||||
|
||||
# Enable this to use jsonrpsee (allowing for example `OnlineClient::from_url`).
|
||||
jsonrpsee = ["dep:jsonrpsee"]
|
||||
@@ -97,7 +85,7 @@ sp-runtime = { workspace = true, optional = true }
|
||||
|
||||
# Other subxt crates we depend on.
|
||||
subxt-macro = { workspace = true }
|
||||
subxt-metadata = { workspace = true }
|
||||
subxt-metadata = { workspace = true, features = ["std"] }
|
||||
subxt-lightclient = { workspace = true, optional = true, default-features = false }
|
||||
|
||||
# Light client support:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/target
|
||||
Generated
+489
@@ -0,0 +1,489 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
||||
|
||||
[[package]]
|
||||
name = "blake2b_simd"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780"
|
||||
dependencies = [
|
||||
"arrayref",
|
||||
"arrayvec",
|
||||
"constant_time_eq",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byte-slice-cast"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "constant_time_eq"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2"
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "0.99.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "frame-metadata"
|
||||
version = "16.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87cf1549fba25a6fcac22785b61698317d958e96cac72a59102ea45b9ae64692"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"allocator-api2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "impl-trait-for-tuples"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keccak"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654"
|
||||
dependencies = [
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||
|
||||
[[package]]
|
||||
name = "libc_alloc"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a835c038b748123287f9fb1743d565e7c635879997f43c345a18a026690364e"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
|
||||
[[package]]
|
||||
name = "parity-scale-codec"
|
||||
version = "3.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"byte-slice-cast",
|
||||
"impl-trait-for-tuples",
|
||||
"parity-scale-codec-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parity-scale-codec-derive"
|
||||
version = "3.6.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b"
|
||||
dependencies = [
|
||||
"proc-macro-crate 2.0.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"toml_edit 0.19.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a"
|
||||
dependencies = [
|
||||
"toml_datetime",
|
||||
"toml_edit 0.20.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scale-info"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"derive_more",
|
||||
"parity-scale-codec",
|
||||
"scale-info-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scale-info-derive"
|
||||
version = "2.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19"
|
||||
dependencies = [
|
||||
"proc-macro-crate 1.3.1",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha3"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"keccak",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sp-core-hashing"
|
||||
version = "15.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e0f4990add7b2cefdeca883c0efa99bb4d912cb2196120e1500c0cc099553b0"
|
||||
dependencies = [
|
||||
"blake2b_simd",
|
||||
"byteorder",
|
||||
"digest",
|
||||
"sha2",
|
||||
"sha3",
|
||||
"twox-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "subxt-core-no-std-tests"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"libc_alloc",
|
||||
"parity-scale-codec",
|
||||
"subxt-metadata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subxt-metadata"
|
||||
version = "0.34.0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"derive_more",
|
||||
"frame-metadata",
|
||||
"hashbrown",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"sp-core-hashing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "twox-hash"
|
||||
version = "1.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"digest",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.5.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b7cf47b659b318dccbd69cc4797a39ae128f533dce7902a1096044d1967b9c16"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "subxt-core-no-std-tests"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
version = "0.0.0"
|
||||
resolver = "2"
|
||||
|
||||
[dependencies]
|
||||
subxt-metadata = { path = "../../metadata", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = ["derive"] }
|
||||
libc = { version = "0.2", default-features = false }
|
||||
libc_alloc = { version = "1.0.6" }
|
||||
|
||||
[profile.dev]
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = "abort"
|
||||
|
||||
# this shouldn't be needed, it's in workspace.exclude, but still
|
||||
# I get the complaint unless I add it...
|
||||
[workspace]
|
||||
@@ -0,0 +1 @@
|
||||
nightly
|
||||
@@ -0,0 +1,49 @@
|
||||
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
#![allow(internal_features)]
|
||||
#![feature(lang_items, start)]
|
||||
#![feature(alloc_error_handler)]
|
||||
#![no_std]
|
||||
|
||||
#[start]
|
||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
run_tests();
|
||||
0
|
||||
}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
libc::abort();
|
||||
}
|
||||
}
|
||||
|
||||
use libc_alloc::LibcAlloc;
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: LibcAlloc = LibcAlloc;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
// Note: Panics in this function will lead to `Aborted (core dumped)` and a non-zero exit status => suitable for CI tests.
|
||||
fn run_tests() {
|
||||
subxt_metadata_test();
|
||||
}
|
||||
|
||||
/// Makes sure, subxt-metadata works in a no-std-context:
|
||||
fn subxt_metadata_test() {
|
||||
use codec::Decode;
|
||||
let bytes: alloc::vec::Vec<u8> = alloc::vec![0, 1, 2, 3, 4];
|
||||
subxt_metadata::Metadata::decode(&mut &bytes[..]).expect_err("invalid byte sequence");
|
||||
|
||||
const METADATA: &[u8] = include_bytes!("../../../artifacts/polkadot_metadata_small.scale");
|
||||
subxt_metadata::Metadata::decode(&mut &METADATA[..]).expect("should be valid metadata");
|
||||
}
|
||||
Reference in New Issue
Block a user