Auto-extract Meta* interface types based on version list (#5100)

* Auto-extract Meta* interface types based on version list

* Additional dedupe

* s/ALL_VERSIONS/KNOWN_VERSIONS/

* Restore type addition

* Additional <const> specifiers

* Handle contracts similar to metadata
This commit is contained in:
Jaco
2022-07-22 17:30:12 +03:00
committed by GitHub
parent 714380575c
commit 21808f0283
4 changed files with 15 additions and 11 deletions
@@ -4,7 +4,7 @@
// order important in structs... :)
/* eslint-disable sort-keys */
export const AllHashers = {
export const AllHashers = <const> {
Blake2_128: null, // eslint-disable-line camelcase
Blake2_256: null, // eslint-disable-line camelcase
Blake2_128Concat: null, // eslint-disable-line camelcase
@@ -17,11 +17,15 @@ import { toLatest } from './v14/toLatest';
import { MagicNumber } from './MagicNumber';
import { getUniqTypes, toCallsOnly } from './util';
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12 | MetadataV13 | MetadataV14;
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12' | 'asV13' | 'asV14';
type MetaVersions = 'latest' | 9 | 10 | 11 | 12 | 13 | 14;
// Use these to generate all the Meta* types below via template keys
// NOTE: Keep from latest -> earliest, see the LATEST_VERSION 0 index
const KNOWN_VERSIONS = <const> [14, 13, 12, 11, 10, 9];
const LATEST_VERSION = KNOWN_VERSIONS[0];
const LATEST_VERSION = 14;
type MetaAll = typeof KNOWN_VERSIONS[number];
type MetaAsX = `asV${MetaAll}`;
type MetaMapped = MetadataAll[MetaAsX];
type MetaVersions = MetaAll | 'latest';
/**
* @name MetadataVersioned