* Pass registry to all codec types
* Pass through registry inside API (where the rubber meets the road)
* Small additions
* Derive w/ registry
* Types are more-or-less covered
* Some test adjustments (guided by linting)
* Rid the world of some ../injector
* Additional cleanups, merge injector into registry
* Cleanup extrinsics (always passing registry)
* Remove injector imports (not all replaced)
* Typ spec cleanups
* Phase 1 - types seem lint-free
* rpc-{core,provider} lint free
* Start working through metadata
* Small metadata additions
* Some e2e tests (out-of-order)
* Down to a handful
* Fixup tests for packages/types/src/codec/*.spec.ts
* packages/types/src/codec passes all tests
* packages/types ok (Convert storage with registry fn)
* progress (sort out injection, dreaded find-before msg)
* Down to 1 lint issue...
* Linting done... along with on-demand import
* Exposed ordering
* Remove global injects
* Cleanup comments
* Add CHANGELOG & UPGRADING
* Apply suggestions from code review
Co-Authored-By: Amaury Martiny <amaury.martiny@protonmail.com>
* Update Metadata description
87 lines
2.3 KiB
TypeScript
87 lines
2.3 KiB
TypeScript
// 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<FunctionMetadataV2>'),
|
|
events: Option.with('Vec<EventMetadataV2>')
|
|
}, value);
|
|
}
|
|
|
|
/**
|
|
* @description the module calls
|
|
*/
|
|
public get calls (): Option<Vec<FunctionMetadataV2>> {
|
|
return this.get('calls') as Option<Vec<FunctionMetadataV2>>;
|
|
}
|
|
|
|
/**
|
|
* @description the module events
|
|
*/
|
|
public get events (): Option<Vec<EventMetadataV2>> {
|
|
return this.get('events') as Option<Vec<EventMetadataV2>>;
|
|
}
|
|
|
|
/**
|
|
* @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<Vec<StorageFunctionMetadata>> {
|
|
return this.get('storage') as Option<Vec<StorageFunctionMetadata>>;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @name MetadataV2
|
|
* @description
|
|
* The runtime metadata as a decoded structure
|
|
*/
|
|
export default class MetadataV2 extends Struct implements MetadataInterface<ModuleMetadataV2> {
|
|
constructor (registry: Registry, value?: any) {
|
|
super(registry, {
|
|
modules: Vec.with(ModuleMetadataV2)
|
|
}, value);
|
|
}
|
|
|
|
/**
|
|
* @description The associated modules for this structure
|
|
*/
|
|
public get modules (): Vec<ModuleMetadataV2> {
|
|
return this.get('modules') as Vec<ModuleMetadataV2>;
|
|
}
|
|
}
|