mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 04:17:57 +00:00
29ea9e0ad9
* impl_runtime_apis: Generate getters for `metadata_at` functions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime: Implement new `Metadata` runtime trait Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime: Move `metadata_at` functions to construct_runtime macro Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * contruct_runtime: Use `OpaqueMetadata` from hidden imports Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Add tests for the new API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Helper to extract documentation literals Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Helper to filter all `cfg` attributes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate documentation getters for metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Avoid trait collision with snake case methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * proc-macro/tests: Check doc getters Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate metadata for runtime methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Export scale-info and frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate metadata for runtime traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/runtime: Expose metadata v15 internally Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * test: Use metadata v15 from `lexnv/md_v15_test` branch Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate crate access one module up Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Implement `runtime_metadata` for mocks and tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Fix warnings Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Add no-docs flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Adjust more tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Check runtime metadata correctness Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/benchmarking: Adjust benchmarks Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/benchmarks: Adjust more benchmarks Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/proc-macro: Generate runtime metadata on the `decl_runtime_apis` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Abuse Deref to resolve `runtime_metadata` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "frame: Implement `runtime_metadata` for mocks and tests" This reverts commit b7f41aa189218589392a6e713ea9488e93c4db45. Revert "frame: Adjust more tests" This reverts commit 3cba5982c7f45552e76335e96c430aecbc42d8c6. Revert "frame/benchmarking: Adjust benchmarks" This reverts commit 60b382ada486c791ffceeb65da587e949b90ec5d. Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Revert "frame/benchmarks: Adjust more benchmarks" This reverts commit eb75c477179b1a27347a5554c5732ef26a00d7e8. * primitives/proc-macro: Remove unused imports and function Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Adjust runtime metadata test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/tests: Remove doc getter test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Enable `no-metadata-docs` feature from `sp-api` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/tests: Add `TypeInfo` for test::extrinsic Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Expose scale-info and frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame-metadata to include v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix merge conflicts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata_ir: Add IR for runtime API metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata_ir: Convert IR to V15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Collect IR metadata for runtime API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/api: Move `metadata_ir` from frame/support Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Adjust `metadata_versions` test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/runtime_metadata: Exclude default type parameters from methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/src/metadata_ir/types.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/src/metadata_ir/mod.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/utils.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * primitives: Fix build Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/metadata-ir: Move IR to dedicated crate Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Reexport metadata-ir and frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Use apis field instead of runtime Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Better documentation for the `Deref` abstraction Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ui-tests: Check empty `impl_runtime_apis` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Remove unneeded bounds on generic params Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Rename `collect_where_bounds` to `get_argument_type_param` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Generate crate access per fn call Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "primitives: Remove unneeded bounds on generic params" This reverts commit 5178e38cf21cfb481156eefd628d62989201d59a. * metadata-ir: Add no-std Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Adjust where bounds Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Change `frame-metadata` branch to "origin/main" Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update to `main` from origin Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame-metadata to crates.io v15.1 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "ui-tests: Check empty `impl_runtime_apis`" This reverts commit cf78a7190ad9cba3c3bb2e78dc3d0dc382b2fea9. * Move ui test to primitives/ui Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update frame/support/test/tests/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/api/proc-macro/src/runtime_metadata.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Test already covered by `empty_impl_runtime_apis_call.stderr` This reverts commit 3bafb294cbe9745569bf5e5a1a2e6b4a4c1aadc5. * Retriger CI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Import `TokenStream` as `TokenStream2` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <git@kchr.de>
159 lines
4.6 KiB
Rust
159 lines
4.6 KiB
Rust
// This file is part of Substrate.
|
|
|
|
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
//! Convert the IR to V14 metadata.
|
|
|
|
use super::types::{
|
|
ExtrinsicMetadataIR, MetadataIR, PalletCallMetadataIR, PalletConstantMetadataIR,
|
|
PalletErrorMetadataIR, PalletEventMetadataIR, PalletMetadataIR, PalletStorageMetadataIR,
|
|
SignedExtensionMetadataIR, StorageEntryMetadataIR, StorageEntryModifierIR, StorageEntryTypeIR,
|
|
StorageHasherIR,
|
|
};
|
|
|
|
use frame_metadata::v14::{
|
|
ExtrinsicMetadata, PalletCallMetadata, PalletConstantMetadata, PalletErrorMetadata,
|
|
PalletEventMetadata, PalletMetadata, PalletStorageMetadata, RuntimeMetadataV14,
|
|
SignedExtensionMetadata, StorageEntryMetadata, StorageEntryModifier, StorageEntryType,
|
|
StorageHasher,
|
|
};
|
|
|
|
impl From<MetadataIR> for RuntimeMetadataV14 {
|
|
fn from(ir: MetadataIR) -> Self {
|
|
RuntimeMetadataV14::new(
|
|
ir.pallets.into_iter().map(Into::into).collect(),
|
|
ir.extrinsic.into(),
|
|
ir.ty,
|
|
)
|
|
}
|
|
}
|
|
|
|
impl From<PalletMetadataIR> for PalletMetadata {
|
|
fn from(ir: PalletMetadataIR) -> Self {
|
|
PalletMetadata {
|
|
name: ir.name,
|
|
storage: ir.storage.map(Into::into),
|
|
calls: ir.calls.map(Into::into),
|
|
event: ir.event.map(Into::into),
|
|
constants: ir.constants.into_iter().map(Into::into).collect(),
|
|
error: ir.error.map(Into::into),
|
|
index: ir.index,
|
|
// Note: ir.docs not part of v14.
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<StorageEntryModifierIR> for StorageEntryModifier {
|
|
fn from(ir: StorageEntryModifierIR) -> Self {
|
|
match ir {
|
|
StorageEntryModifierIR::Optional => StorageEntryModifier::Optional,
|
|
StorageEntryModifierIR::Default => StorageEntryModifier::Default,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<StorageHasherIR> for StorageHasher {
|
|
fn from(ir: StorageHasherIR) -> Self {
|
|
match ir {
|
|
StorageHasherIR::Blake2_128 => StorageHasher::Blake2_128,
|
|
StorageHasherIR::Blake2_256 => StorageHasher::Blake2_256,
|
|
StorageHasherIR::Blake2_128Concat => StorageHasher::Blake2_128Concat,
|
|
StorageHasherIR::Twox128 => StorageHasher::Twox128,
|
|
StorageHasherIR::Twox256 => StorageHasher::Twox256,
|
|
StorageHasherIR::Twox64Concat => StorageHasher::Twox64Concat,
|
|
StorageHasherIR::Identity => StorageHasher::Identity,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<StorageEntryTypeIR> for StorageEntryType {
|
|
fn from(ir: StorageEntryTypeIR) -> Self {
|
|
match ir {
|
|
StorageEntryTypeIR::Plain(ty) => StorageEntryType::Plain(ty),
|
|
StorageEntryTypeIR::Map { hashers, key, value } => StorageEntryType::Map {
|
|
hashers: hashers.into_iter().map(Into::into).collect(),
|
|
key,
|
|
value,
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<StorageEntryMetadataIR> for StorageEntryMetadata {
|
|
fn from(ir: StorageEntryMetadataIR) -> Self {
|
|
StorageEntryMetadata {
|
|
name: ir.name,
|
|
modifier: ir.modifier.into(),
|
|
ty: ir.ty.into(),
|
|
default: ir.default,
|
|
docs: ir.docs,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<PalletStorageMetadataIR> for PalletStorageMetadata {
|
|
fn from(ir: PalletStorageMetadataIR) -> Self {
|
|
PalletStorageMetadata {
|
|
prefix: ir.prefix,
|
|
entries: ir.entries.into_iter().map(Into::into).collect(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<PalletCallMetadataIR> for PalletCallMetadata {
|
|
fn from(ir: PalletCallMetadataIR) -> Self {
|
|
PalletCallMetadata { ty: ir.ty }
|
|
}
|
|
}
|
|
|
|
impl From<PalletEventMetadataIR> for PalletEventMetadata {
|
|
fn from(ir: PalletEventMetadataIR) -> Self {
|
|
PalletEventMetadata { ty: ir.ty }
|
|
}
|
|
}
|
|
|
|
impl From<PalletConstantMetadataIR> for PalletConstantMetadata {
|
|
fn from(ir: PalletConstantMetadataIR) -> Self {
|
|
PalletConstantMetadata { name: ir.name, ty: ir.ty, value: ir.value, docs: ir.docs }
|
|
}
|
|
}
|
|
|
|
impl From<PalletErrorMetadataIR> for PalletErrorMetadata {
|
|
fn from(ir: PalletErrorMetadataIR) -> Self {
|
|
PalletErrorMetadata { ty: ir.ty }
|
|
}
|
|
}
|
|
|
|
impl From<SignedExtensionMetadataIR> for SignedExtensionMetadata {
|
|
fn from(ir: SignedExtensionMetadataIR) -> Self {
|
|
SignedExtensionMetadata {
|
|
identifier: ir.identifier,
|
|
ty: ir.ty,
|
|
additional_signed: ir.additional_signed,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<ExtrinsicMetadataIR> for ExtrinsicMetadata {
|
|
fn from(ir: ExtrinsicMetadataIR) -> Self {
|
|
ExtrinsicMetadata {
|
|
ty: ir.ty,
|
|
version: ir.version,
|
|
signed_extensions: ir.signed_extensions.into_iter().map(Into::into).collect(),
|
|
}
|
|
}
|
|
}
|