mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 12:17:58 +00:00
943697fa69
* metadata-ir: Add extrinsic type info to decode address, call, sig Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame-metadata: Point to unreleased branch Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-ir: Include addrees, call, signature in V15 conversion Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-ir: Include extra ty Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * construct_runtime: Extract address,call,sig,extra ty from tx type Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Check metadata populates xt types correctly Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-ir/tests: Add extra fields on ExtrinsicMetadataIR Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives/traits: Expand the `Extrinsic::SignaturePayload` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Adjust to new `Extrinsic` associated types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/metadata: Simplify metadata generation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/example: Adjust to new interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/tests: Adjust `extrinsic_metadata_ir_types` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert the additional Extrinsic' associated types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Add `SignaturePayload` marker trait Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Implement SignaturePayload for empty tuple Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust to new SignaturePayload trait Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Adjust `extrinsic_metadata_ir_types` to new interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame/support: Adjust pallet test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * frame: Add Extrinsic length prefix to the metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * primitives: Populate `ExtrinsicMetadataIR` with `len_ty` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update primitives/runtime/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Apply cargo fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * v15: Remove len type of the extrinsic Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cargo: Update frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: parity-processbot <>
122 lines
3.4 KiB
Rust
122 lines
3.4 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 V15 metadata.
|
|
|
|
use crate::OuterEnumsIR;
|
|
|
|
use super::types::{
|
|
ExtrinsicMetadataIR, MetadataIR, PalletMetadataIR, RuntimeApiMetadataIR,
|
|
RuntimeApiMethodMetadataIR, RuntimeApiMethodParamMetadataIR, SignedExtensionMetadataIR,
|
|
};
|
|
|
|
use frame_metadata::v15::{
|
|
CustomMetadata, ExtrinsicMetadata, OuterEnums, PalletMetadata, RuntimeApiMetadata,
|
|
RuntimeApiMethodMetadata, RuntimeApiMethodParamMetadata, RuntimeMetadataV15,
|
|
SignedExtensionMetadata,
|
|
};
|
|
|
|
impl From<MetadataIR> for RuntimeMetadataV15 {
|
|
fn from(ir: MetadataIR) -> Self {
|
|
RuntimeMetadataV15::new(
|
|
ir.pallets.into_iter().map(Into::into).collect(),
|
|
ir.extrinsic.into(),
|
|
ir.ty,
|
|
ir.apis.into_iter().map(Into::into).collect(),
|
|
ir.outer_enums.into(),
|
|
// Substrate does not collect yet the custom metadata fields.
|
|
// This allows us to extend the V15 easily.
|
|
CustomMetadata { map: Default::default() },
|
|
)
|
|
}
|
|
}
|
|
|
|
impl From<RuntimeApiMetadataIR> for RuntimeApiMetadata {
|
|
fn from(ir: RuntimeApiMetadataIR) -> Self {
|
|
RuntimeApiMetadata {
|
|
name: ir.name,
|
|
methods: ir.methods.into_iter().map(Into::into).collect(),
|
|
docs: ir.docs,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<RuntimeApiMethodMetadataIR> for RuntimeApiMethodMetadata {
|
|
fn from(ir: RuntimeApiMethodMetadataIR) -> Self {
|
|
RuntimeApiMethodMetadata {
|
|
name: ir.name,
|
|
inputs: ir.inputs.into_iter().map(Into::into).collect(),
|
|
output: ir.output,
|
|
docs: ir.docs,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<RuntimeApiMethodParamMetadataIR> for RuntimeApiMethodParamMetadata {
|
|
fn from(ir: RuntimeApiMethodParamMetadataIR) -> Self {
|
|
RuntimeApiMethodParamMetadata { name: ir.name, ty: 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,
|
|
docs: ir.docs,
|
|
}
|
|
}
|
|
}
|
|
|
|
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 {
|
|
version: ir.version,
|
|
address_ty: ir.address_ty,
|
|
call_ty: ir.call_ty,
|
|
signature_ty: ir.signature_ty,
|
|
extra_ty: ir.extra_ty,
|
|
signed_extensions: ir.signed_extensions.into_iter().map(Into::into).collect(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<OuterEnumsIR> for OuterEnums {
|
|
fn from(ir: OuterEnumsIR) -> Self {
|
|
OuterEnums {
|
|
call_enum_ty: ir.call_enum_ty,
|
|
event_enum_ty: ir.event_enum_ty,
|
|
error_enum_ty: ir.error_enum_ty,
|
|
}
|
|
}
|
|
}
|