123456789101112131415161718192021222324252627282930 |
- import { Struct, TypeRegistry } from '@polkadot/types'
- import { RegistryTypes } from '@polkadot/types/types'
- import defs from'./defs.json'
- const emptyStruct = new Struct(new TypeRegistry(), {})
- const normalizedDefs = {} as RegistryTypes
- Object.entries(defs).forEach(([typeName, typeDef]) => {
- if (typeof typeDef !== 'string' && !typeDef.hasOwnProperty('_enum') && !typeDef.hasOwnProperty('_set')) {
-
- const normalizedDef = {} as Record<string, string>
- Object.entries(typeDef).forEach(([key, value]) => {
- if ((emptyStruct as any)[key] !== undefined) {
- return
- }
- normalizedDef[key] = value
- })
- normalizedDefs[typeName] = normalizedDef;
- }
- else {
- normalizedDefs[typeName] = typeDef
- }
- })
- export default {
- types: normalizedDefs
- }
|