mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Merge branch 'master' into tadeohepperle/pull-in-sp-arithmetic-for-perbill-permill-etc
This commit is contained in:
@@ -11,13 +11,13 @@ use generate_custom_metadata::dispatch_error::{
|
||||
use frame_metadata::RuntimeMetadataPrefixed;
|
||||
|
||||
pub fn metadata_array_dispatch_error() -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<ArrayDispatchError>(vec![])
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<ArrayDispatchError>(vec![], vec![])
|
||||
}
|
||||
|
||||
pub fn metadata_legacy_dispatch_error() -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<LegacyDispatchError>(vec![])
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<LegacyDispatchError>(vec![], vec![])
|
||||
}
|
||||
|
||||
pub fn metadata_named_field_dispatch_error() -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<NamedFieldDispatchError>(vec![])
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<NamedFieldDispatchError>(vec![], vec![])
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
//! to automatically regenerate `stderr` files, but don't forget to check that new files make sense.
|
||||
|
||||
mod dispatch_errors;
|
||||
mod runtime_apis;
|
||||
mod storage;
|
||||
mod utils;
|
||||
|
||||
@@ -34,6 +35,13 @@ fn ui_tests() {
|
||||
.build(storage::metadata_storage_map_no_keys()),
|
||||
);
|
||||
|
||||
// Check runtime APIs with _ in method names work
|
||||
t.pass(
|
||||
m.new_test_case()
|
||||
.name("runtime_api_underscore_method_name")
|
||||
.build(runtime_apis::metadata_runtime_api_underscore_method_name()),
|
||||
);
|
||||
|
||||
// Test that the codegen can handle the different types of DispatchError.
|
||||
t.pass(
|
||||
m.new_test_case()
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
use frame_metadata::{
|
||||
v15::{RuntimeApiMetadata, RuntimeApiMethodMetadata, RuntimeApiMethodParamMetadata},
|
||||
RuntimeMetadataPrefixed,
|
||||
};
|
||||
|
||||
use crate::utils::generate_metadata_from_runtime_apis;
|
||||
|
||||
/// Generate metadata which contains a `Map` storage entry with no hashers/values.
|
||||
/// This is a bit of an odd case, but it was raised in https://github.com/paritytech/subxt/issues/552,
|
||||
/// and this test will fail before the fix and should pass once the fix is applied.
|
||||
pub fn metadata_runtime_api_underscore_method_name() -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_runtime_apis(vec![RuntimeApiMetadata {
|
||||
name: "MyApi".to_owned(),
|
||||
docs: vec![],
|
||||
methods: vec![RuntimeApiMethodMetadata {
|
||||
name: "my_method".to_owned(),
|
||||
inputs: vec![RuntimeApiMethodParamMetadata {
|
||||
name: "_".to_owned(), // The important bit we're testing.
|
||||
ty: 0.into(), // we don't care what type this is.
|
||||
}],
|
||||
output: 0.into(), // we don't care what type this is.
|
||||
docs: vec![],
|
||||
}],
|
||||
}])
|
||||
}
|
||||
@@ -7,12 +7,12 @@ mod metadata_test_runner;
|
||||
use frame_metadata::{
|
||||
v15::{
|
||||
CustomMetadata, ExtrinsicMetadata, OuterEnums, PalletMetadata, PalletStorageMetadata,
|
||||
RuntimeMetadataV15, StorageEntryMetadata,
|
||||
RuntimeApiMetadata, RuntimeMetadataV15, StorageEntryMetadata,
|
||||
},
|
||||
RuntimeMetadataPrefixed,
|
||||
};
|
||||
use generate_custom_metadata::dispatch_error::ArrayDispatchError;
|
||||
use scale_info::{meta_type, IntoPortable, TypeInfo};
|
||||
use scale_info::{form::PortableForm, meta_type, IntoPortable, TypeInfo};
|
||||
|
||||
pub use metadata_test_runner::MetadataTestRunner;
|
||||
|
||||
@@ -21,6 +21,7 @@ pub use metadata_test_runner::MetadataTestRunner;
|
||||
/// type matching the generic type param provided.
|
||||
pub fn generate_metadata_from_pallets_custom_dispatch_error<DispatchError: TypeInfo + 'static>(
|
||||
pallets: Vec<PalletMetadata>,
|
||||
runtime_apis: Vec<RuntimeApiMetadata<PortableForm>>,
|
||||
) -> RuntimeMetadataPrefixed {
|
||||
// We don't care about the extrinsic type.
|
||||
let extrinsic = ExtrinsicMetadata {
|
||||
@@ -60,7 +61,7 @@ pub fn generate_metadata_from_pallets_custom_dispatch_error<DispatchError: TypeI
|
||||
pallets,
|
||||
extrinsic,
|
||||
ty,
|
||||
apis: vec![],
|
||||
apis: runtime_apis,
|
||||
outer_enums: OuterEnums {
|
||||
call_enum_ty: runtime_call,
|
||||
event_enum_ty: runtime_event,
|
||||
@@ -78,7 +79,16 @@ pub fn generate_metadata_from_pallets_custom_dispatch_error<DispatchError: TypeI
|
||||
/// We default to a useless extrinsic type, and register a fake `DispatchError`
|
||||
/// type so that codegen is happy with the metadata generated.
|
||||
pub fn generate_metadata_from_pallets(pallets: Vec<PalletMetadata>) -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<ArrayDispatchError>(pallets)
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<ArrayDispatchError>(pallets, vec![])
|
||||
}
|
||||
|
||||
/// Given some runtime API metadata, generate a [`RuntimeMetadataPrefixed`] struct.
|
||||
/// We default to a useless extrinsic type, and register a fake `DispatchError`
|
||||
/// type so that codegen is happy with the metadata generated.
|
||||
pub fn generate_metadata_from_runtime_apis(
|
||||
runtime_apis: Vec<RuntimeApiMetadata<PortableForm>>,
|
||||
) -> RuntimeMetadataPrefixed {
|
||||
generate_metadata_from_pallets_custom_dispatch_error::<ArrayDispatchError>(vec![], runtime_apis)
|
||||
}
|
||||
|
||||
/// Given some storage entries, generate a [`RuntimeMetadataPrefixed`] struct.
|
||||
|
||||
Reference in New Issue
Block a user