diff --git a/packages/types/src/Metadata/v3/Metadata.ts b/packages/types/src/Metadata/v3/Metadata.ts index f0c1e0b2bc..5f2409703b 100644 --- a/packages/types/src/Metadata/v3/Metadata.ts +++ b/packages/types/src/Metadata/v3/Metadata.ts @@ -109,11 +109,15 @@ export default class MetadataV3 extends Struct implements MetadataInterface { return this.modules.map((mod) => mod.storage.isNone ? [] - : mod.storage.unwrap().map((fn) => - fn.type.isMap - ? [fn.type.asMap.key.toString(), fn.type.asMap.value.toString()] - : [fn.type.asType.toString()] - ) + : mod.storage.unwrap().map((fn) => { + if (fn.type.isMap) { + return [fn.type.asMap.key.toString(), fn.type.asMap.value.toString()]; + } else if (fn.type.isDoubleMap) { + return [fn.type.asDoubleMap.key1.toString(), fn.type.asDoubleMap.key2.toString(), fn.type.asDoubleMap.value.toString()]; + } else { + return [fn.type.asType.toString()]; + } + }) ); } diff --git a/packages/types/src/Metadata/v3/Storage.ts b/packages/types/src/Metadata/v3/Storage.ts index c685d0e602..0a2c0d4823 100644 --- a/packages/types/src/Metadata/v3/Storage.ts +++ b/packages/types/src/Metadata/v3/Storage.ts @@ -11,6 +11,7 @@ import Struct from '../../codec/Struct'; import Vector from '../../codec/Vector'; import Bytes from '../../primitive/Bytes'; import Text from '../../primitive/Text'; +import Type from '../../primitive/Type'; import { MapType, PlainType, @@ -27,25 +28,25 @@ export { export class DoubleMapType extends Struct { constructor (value?: any) { super({ - key1: Text, - key2: Text, - value: Text, + key1: Type, + key2: Type, + value: Type, key2Hasher: Text }, value); } /** - * @description The mapped key as [[Text]] + * @description The mapped key as [[Type]] */ - get key1 (): Text { - return this.get('key1') as Text; + get key1 (): Type { + return this.get('key1') as Type; } /** - * @description The mapped key as [[Text]] + * @description The mapped key as [[Type]] */ - get key2 (): Text { - return this.get('key2') as Text; + get key2 (): Type { + return this.get('key2') as Type; } /** @@ -56,10 +57,10 @@ export class DoubleMapType extends Struct { } /** - * @description The mapped key as [[Text]] + * @description The mapped key as [[Type]] */ - get value (): Text { - return this.get('value') as Text; + get value (): Type { + return this.get('value') as Type; } } @@ -125,7 +126,7 @@ export class StorageFunctionType extends EnumType mod.storage.isNone ? [] - : mod.storage.unwrap().map((fn) => - fn.type.isMap - ? [fn.type.asMap.key.toString(), fn.type.asMap.value.toString()] - : [fn.type.asType.toString()] - ) + : mod.storage.unwrap().map((fn) => { + if (fn.type.isMap) { + return [fn.type.asMap.key.toString(), fn.type.asMap.value.toString()]; + } else if (fn.type.isDoubleMap) { + return [fn.type.asDoubleMap.key1.toString(), fn.type.asDoubleMap.key2.toString(), fn.type.asDoubleMap.value.toString()]; + } else { + return [fn.type.asType.toString()]; + } + }) ); } diff --git a/packages/types/src/Metadata/v4/Storage.ts b/packages/types/src/Metadata/v4/Storage.ts index e117095308..b3b1df477b 100644 --- a/packages/types/src/Metadata/v4/Storage.ts +++ b/packages/types/src/Metadata/v4/Storage.ts @@ -114,32 +114,32 @@ export class DoubleMapType extends Struct { constructor (value?: any) { super({ hasher: StorageHasher, - key1: Text, - key2: Text, - value: Text, + key1: Type, + key2: Type, + value: Type, key2Hasher: Text }, value); } /** - * @description The hashing algorithm used to hash keys, as [[Text]] + * @description The hashing algorithm used to hash keys, as [[StorageHasher]] */ - get hasher (): Text { - return this.get('hasher') as Text; + get hasher (): StorageHasher { + return this.get('hasher') as StorageHasher; } /** - * @description The mapped key as [[Text]] + * @description The mapped key as [[Type]] */ - get key1 (): Text { - return this.get('key1') as Text; + get key1 (): Type { + return this.get('key1') as Type; } /** - * @description The mapped key as [[Text]] + * @description The mapped key as [[Type]] */ - get key2 (): Text { - return this.get('key2') as Text; + get key2 (): Type { + return this.get('key2') as Type; } /** @@ -150,10 +150,10 @@ export class DoubleMapType extends Struct { } /** - * @description The mapped key as [[Text]] + * @description The mapped key as [[Type]] */ - get value (): Text { - return this.get('value') as Text; + get value (): Type { + return this.get('value') as Type; } }