Skip to content

Instantly share code, notes, and snippets.

@buraktabn
Created June 11, 2022 21:42
Show Gist options
  • Save buraktabn/1786a289e154aacd9ead7bab3e511145 to your computer and use it in GitHub Desktop.
Save buraktabn/1786a289e154aacd9ead7bab3e511145 to your computer and use it in GitHub Desktop.
// codec.ts
import * as metadataDefinition from "./old/definitions/metadata"
function createScaleCodec(): {codec: Codec, versions: Ti[]} {
let registry = new OldTypeRegistry(metadataDefinition)
}
// ./old/definitions/metadata/index.ts
import type {OldTypes} from "../../types"
import {ScaleInfoTypes} from "./base"
import {V10} from "./v10"
import {V11} from "./v11"
import {V12} from "./v12"
import {V13} from "./v13"
import {V14} from "./v14"
import {V9} from "./v9"
export const types: OldTypes['types'] = {
Type: 'Str',
...ScaleInfoTypes,
...V9,
...V10,
...V11,
...V12,
...V13,
...V14,
Metadata: {
_enum: {
V0: 'DoNotConstruct',
V1: 'DoNotConstruct',
V2: 'DoNotConstruct',
V3: 'DoNotConstruct',
V4: 'DoNotConstruct',
V5: 'DoNotConstruct',
V6: 'DoNotConstruct',
V7: 'DoNotConstruct',
V8: 'DoNotConstruct',
// First version on Kusama is V9, dropping will be problematic
V9: 'MetadataV9',
V10: 'MetadataV10',
V11: 'MetadataV11',
V12: 'MetadataV12',
V13: 'MetadataV13',
V14: 'MetadataV14'
}
}
}
// registry.ts
export interface OldTypes {
types: Record<string, OldTypeDefinition>
typesAlias?: OldTypesAlias
}
export class OldTypeRegistry {
constructor(private oldTypes: OldTypes) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment