diff --git a/packages/types/src/Metadata/v0/Modules.ts b/packages/types/src/Metadata/v0/Modules.ts index c1b95c0402..f5a73ac5fd 100644 --- a/packages/types/src/Metadata/v0/Modules.ts +++ b/packages/types/src/Metadata/v0/Modules.ts @@ -151,7 +151,7 @@ export class DoubleMapType extends Struct { get key1 (): Text { return this.get('key1') as Text; } - + /** * @description The mapped key as [[Text]] */ @@ -213,14 +213,22 @@ export class MapType extends Struct { class PlainType extends Type { } -export class StorageFunctionType extends EnumType { +export class StorageFunctionType extends EnumType { constructor (value?: any, index?: number) { super({ PlainType, - MapType + MapType, + DoubleMapType }, value, index); } + /** + * @description `true` if the storage entry is a doublemap + */ + get isDoubleMap (): boolean { + return this.toNumber() === 2; + } + /** * @description `true` if the storage entry is a map */ @@ -228,6 +236,13 @@ export class StorageFunctionType extends EnumType { return this.toNumber() === 1; } + /** + * @description The value as a mapped value + */ + get asDoubleMap (): DoubleMapType { + return this.value as DoubleMapType; + } + /** * @description The value as a mapped value */ @@ -246,6 +261,10 @@ export class StorageFunctionType extends EnumType { * @description Returns the string representation of the value */ toString (): string { + if (this.isDoubleMap) { + return this.asDoubleMap.value.toString(); + } + if (this.isMap) { if (this.asMap.isLinked) { return `(${this.asMap.value.toString()}, Linkage<${this.asMap.key.toString()}>)`;