v0.77.100
This commit is contained in:
@@ -11,6 +11,7 @@ import Vector from '../../codec/Vector';
|
||||
import Bytes from '../../primitive/Bytes';
|
||||
import Text from '../../primitive/Text';
|
||||
import Type from '../../primitive/Type';
|
||||
import { DoubleMapType } from '../v4/Storage';
|
||||
|
||||
export class StorageFunctionModifier extends Enum {
|
||||
constructor (value?: any) {
|
||||
@@ -69,14 +70,22 @@ export class MapType extends Struct {
|
||||
export class PlainType extends Type {
|
||||
}
|
||||
|
||||
export class StorageFunctionType extends EnumType<PlainType | MapType> {
|
||||
export class StorageFunctionType extends EnumType<PlainType | MapType | DoubleMapType> {
|
||||
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
|
||||
*/
|
||||
@@ -84,6 +93,13 @@ export class StorageFunctionType extends EnumType<PlainType | MapType> {
|
||||
return this.toNumber() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The value as a double mapped value
|
||||
*/
|
||||
get asDoubleMap (): DoubleMapType {
|
||||
return this.value as DoubleMapType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The value as a mapped value
|
||||
*/
|
||||
@@ -102,6 +118,10 @@ export class StorageFunctionType extends EnumType<PlainType | MapType> {
|
||||
* @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()}>)`;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { DoubleMapType } from './../v4/Storage';
|
||||
|
||||
import { AnyNumber } from '../../types';
|
||||
|
||||
import EnumType from '../../codec/EnumType';
|
||||
@@ -50,14 +52,22 @@ export class MapType extends Struct {
|
||||
}
|
||||
}
|
||||
|
||||
export class StorageFunctionType extends EnumType<PlainType | MapType> {
|
||||
export class StorageFunctionType extends EnumType<PlainType | MapType | DoubleMapType> {
|
||||
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
|
||||
*/
|
||||
@@ -65,6 +75,13 @@ export class StorageFunctionType extends EnumType<PlainType | MapType> {
|
||||
return this.toNumber() === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The value as a double mapped value
|
||||
*/
|
||||
get asDoubleMap (): DoubleMapType {
|
||||
return this.value as DoubleMapType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The value as a mapped value
|
||||
*/
|
||||
@@ -83,6 +100,9 @@ export class StorageFunctionType extends EnumType<PlainType | MapType> {
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
toString (): string {
|
||||
if (this.isDoubleMap) {
|
||||
return this.asDoubleMap.value.toString();
|
||||
}
|
||||
return this.isMap
|
||||
? this.asMap.value.toString()
|
||||
: this.asType.toString();
|
||||
|
||||
Reference in New Issue
Block a user