-
Notifications
You must be signed in to change notification settings - Fork 339
/
Metadata.ts
86 lines (75 loc) · 2.31 KB
/
Metadata.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// 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 { EventMetadataV3, FunctionMetadataV3 } 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 ModuleMetadataV3
* @description
* The definition of a module in the system
*/
export class ModuleMetadataV3 extends Struct {
constructor (registry: Registry, value?: any) {
super(registry, {
name: 'Text',
prefix: 'Text',
storage: Option.with(Vec.with(StorageFunctionMetadata)),
calls: Option.with('Vec<FunctionMetadataV3>'),
events: Option.with('Vec<EventMetadataV3>')
}, value);
}
/**
* @description the module calls
*/
public get calls (): Option<Vec<FunctionMetadataV3>> {
return this.get('calls') as Option<Vec<FunctionMetadataV3>>;
}
/**
* @description the module events
*/
public get events (): Option<Vec<EventMetadataV3>> {
return this.get('events') as Option<Vec<EventMetadataV3>>;
}
/**
* @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 MetadataV3
* @description
* The runtime metadata as a decoded structure
*/
export default class MetadataV3 extends Struct implements MetadataInterface<ModuleMetadataV3> {
constructor (registry: Registry, value?: any) {
super(registry, {
modules: Vec.with(ModuleMetadataV3)
}, value);
}
/**
* @description The associated modules for this structure
*/
public get modules (): Vec<ModuleMetadataV3> {
return this.get('modules') as Vec<ModuleMetadataV3>;
}
}