* Support for metadata v13 * Lint fixes * Lastest tag as string * Documentation * MagicNumber opt * NMap enum entry * NMapTypeLatest * Adjust for NMap type overrides * Static from v13 * Basic NMap support * lint * Test expectations
20 lines
664 B
TypeScript
20 lines
664 B
TypeScript
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { AnyNumber, Registry } from '@polkadot/types/types';
|
|
|
|
import { U32 } from '@polkadot/types/primitive';
|
|
import { assert } from '@polkadot/util';
|
|
|
|
export const MAGIC_NUMBER = 0x6174656d; // `meta`, reversed for Little Endian encoding
|
|
|
|
export class MagicNumber extends U32 {
|
|
constructor (registry: Registry, value?: AnyNumber) {
|
|
super(registry, value);
|
|
|
|
if (!this.isEmpty) {
|
|
assert(this.eq(MAGIC_NUMBER), () => `MagicNumber mismatch: expected ${registry.createType('u32', MAGIC_NUMBER).toHex()}, found ${this.toHex()}`);
|
|
}
|
|
}
|
|
}
|