// Copyright 2017-2019 @polkadot/metadata authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { EventMetadataV2, FunctionMetadataV2 } from '@polkadot/types/interfaces/metadata'; import { Registry } from '@polkadot/types/types'; import { MetadataInterface } from '../types'; import Option from '@polkadot/types/codec/Option'; import Struct from '@polkadot/types/codec/Struct'; import Vec from '@polkadot/types/codec/Vec'; import Text from '@polkadot/types/primitive/Text'; import { StorageFunctionMetadata } from './Storage'; /** * @name ModuleMetadataV2 * @description * The definition of a module in the system */ export class ModuleMetadataV2 extends Struct { constructor (registry: Registry, value?: any) { super(registry, { name: 'Text', prefix: 'Text', storage: Option.with(Vec.with(StorageFunctionMetadata)), calls: Option.with('Vec'), events: Option.with('Vec') }, value); } /** * @description the module calls */ public get calls (): Option> { return this.get('calls') as Option>; } /** * @description the module events */ public get events (): Option> { return this.get('events') as Option>; } /** * @description the module name */ public get name (): Text { return this.get('name') as Text; } /** * @description the module prefix */ public get prefix (): Text { return this.get('prefix') as Text; } /** * @description the associated module storage */ public get storage (): Option> { return this.get('storage') as Option>; } } /** * @name MetadataV2 * @description * The runtime metadata as a decoded structure */ export default class MetadataV2 extends Struct implements MetadataInterface { constructor (registry: Registry, value?: any) { super(registry, { modules: Vec.with(ModuleMetadataV2) }, value); } /** * @description The associated modules for this structure */ public get modules (): Vec { return this.get('modules') as Vec; } }