@polkadot/types-codec 7.4.2-9 → 7.5.2-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstract/AbstractArray.js +0 -4
- package/abstract/AbstractInt.js +10 -24
- package/base/Base.js +15 -29
- package/base/Compact.js +20 -34
- package/base/DoNotConstruct.js +14 -23
- package/base/Enum.js +36 -70
- package/base/Null.js +2 -3
- package/base/Option.js +19 -37
- package/base/Tuple.js +5 -11
- package/base/Vec.js +6 -12
- package/base/VecFixed.js +4 -10
- package/extended/BTreeSet.js +4 -13
- package/extended/BitVec.js +5 -11
- package/extended/Map.js +8 -27
- package/extended/Range.cjs +2 -20
- package/extended/Range.d.ts +0 -4
- package/extended/Range.js +4 -25
- package/extended/RangeInclusive.cjs +28 -0
- package/extended/RangeInclusive.d.ts +6 -0
- package/extended/RangeInclusive.js +18 -0
- package/extended/WrapperKeepOpaque.cjs +11 -3
- package/extended/WrapperKeepOpaque.d.ts +4 -2
- package/extended/WrapperKeepOpaque.js +15 -24
- package/extended/WrapperOpaque.cjs +7 -31
- package/extended/WrapperOpaque.d.ts +6 -10
- package/extended/WrapperOpaque.js +7 -30
- package/extended/index.cjs +3 -1
- package/extended/index.d.ts +2 -1
- package/extended/index.js +2 -1
- package/native/Bool.js +0 -2
- package/native/Date.js +0 -2
- package/native/Json.js +0 -2
- package/native/Raw.js +0 -3
- package/native/Set.js +18 -32
- package/native/Struct.js +12 -30
- package/native/Text.js +7 -20
- package/package.json +7 -2
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
- package/primitive/I128.js +2 -5
- package/primitive/I16.js +2 -5
- package/primitive/I256.js +2 -5
- package/primitive/I32.js +2 -5
- package/primitive/I64.js +2 -5
- package/primitive/I8.js +2 -5
- package/primitive/U128.js +2 -5
- package/primitive/U16.js +2 -5
- package/primitive/U256.js +2 -5
- package/primitive/U32.js +2 -5
- package/primitive/U64.js +2 -5
- package/primitive/U8.js +2 -5
package/extended/Map.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
|
@@ -81,36 +79,19 @@ function decodeMap(registry, keyType, valType, value) {
|
|
|
81
79
|
throw new Error('Map: cannot decode type');
|
|
82
80
|
}
|
|
83
81
|
|
|
84
|
-
var _KeyClass = /*#__PURE__*/_classPrivateFieldLooseKey("KeyClass");
|
|
85
|
-
|
|
86
|
-
var _ValClass = /*#__PURE__*/_classPrivateFieldLooseKey("ValClass");
|
|
87
|
-
|
|
88
|
-
var _type = /*#__PURE__*/_classPrivateFieldLooseKey("type");
|
|
89
|
-
|
|
90
82
|
export class CodecMap extends Map {
|
|
83
|
+
#KeyClass;
|
|
84
|
+
#ValClass;
|
|
85
|
+
#type;
|
|
86
|
+
|
|
91
87
|
constructor(registry, keyType, valType, rawValue, type = 'HashMap') {
|
|
92
88
|
const [decoded, decodedLength] = decodeMap(registry, keyType, valType, rawValue);
|
|
93
89
|
super(type === 'BTreeMap' ? sortMap(decoded) : decoded);
|
|
94
|
-
this.registry = void 0;
|
|
95
|
-
this.createdAtHash = void 0;
|
|
96
|
-
Object.defineProperty(this, _KeyClass, {
|
|
97
|
-
writable: true,
|
|
98
|
-
value: void 0
|
|
99
|
-
});
|
|
100
|
-
Object.defineProperty(this, _ValClass, {
|
|
101
|
-
writable: true,
|
|
102
|
-
value: void 0
|
|
103
|
-
});
|
|
104
|
-
this.initialU8aLength = void 0;
|
|
105
|
-
Object.defineProperty(this, _type, {
|
|
106
|
-
writable: true,
|
|
107
|
-
value: void 0
|
|
108
|
-
});
|
|
109
90
|
this.registry = registry;
|
|
110
91
|
this.initialU8aLength = decodedLength;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
this.#KeyClass = typeToConstructor(registry, keyType);
|
|
93
|
+
this.#ValClass = typeToConstructor(registry, valType);
|
|
94
|
+
this.#type = type;
|
|
114
95
|
}
|
|
115
96
|
/**
|
|
116
97
|
* @description The length of the value when encoded as a Uint8Array
|
|
@@ -192,7 +173,7 @@ export class CodecMap extends Map {
|
|
|
192
173
|
|
|
193
174
|
|
|
194
175
|
toRawType() {
|
|
195
|
-
return `${
|
|
176
|
+
return `${this.#type}<${this.registry.getClassName(this.#KeyClass) || new this.#KeyClass(this.registry).toRawType()},${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
|
196
177
|
}
|
|
197
178
|
/**
|
|
198
179
|
* @description Returns the string representation of the value
|
package/extended/Range.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.Range = void 0;
|
|
9
9
|
|
|
10
10
|
var _classPrivateFieldLooseBase2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldLooseBase"));
|
|
11
11
|
|
|
@@ -71,22 +71,4 @@ class Range extends _Tuple.Tuple {
|
|
|
71
71
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
exports.Range = Range;
|
|
75
|
-
|
|
76
|
-
class RangeInclusive extends Range {
|
|
77
|
-
constructor(registry, Type, value) {
|
|
78
|
-
super(registry, Type, value, 'RangeInclusive');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
static with(Type) {
|
|
82
|
-
return class extends RangeInclusive {
|
|
83
|
-
constructor(registry, value) {
|
|
84
|
-
super(registry, Type, value);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
exports.RangeInclusive = RangeInclusive;
|
|
74
|
+
exports.Range = Range;
|
package/extended/Range.d.ts
CHANGED
|
@@ -23,8 +23,4 @@ export declare class Range<T extends INumber> extends Tuple {
|
|
|
23
23
|
*/
|
|
24
24
|
toRawType(): string;
|
|
25
25
|
}
|
|
26
|
-
export declare class RangeInclusive<T extends INumber = INumber> extends Range<T> {
|
|
27
|
-
constructor(registry: Registry, Type: CodecClass<T> | string, value?: AnyTuple);
|
|
28
|
-
static with<T extends INumber>(Type: CodecClass<T> | string): CodecClass<RangeInclusive<T>>;
|
|
29
|
-
}
|
|
30
26
|
export {};
|
package/extended/Range.js
CHANGED
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
3
|
import { Tuple } from "../base/Tuple.js";
|
|
6
4
|
|
|
7
|
-
var _rangeName = /*#__PURE__*/_classPrivateFieldLooseKey("rangeName");
|
|
8
|
-
|
|
9
5
|
/**
|
|
10
6
|
* @name Range
|
|
11
7
|
* @description
|
|
12
8
|
* Rust `Range<T>` representation
|
|
13
9
|
*/
|
|
14
10
|
export class Range extends Tuple {
|
|
11
|
+
#rangeName;
|
|
12
|
+
|
|
15
13
|
constructor(registry, Type, value, rangeName = 'Range') {
|
|
16
14
|
super(registry, {
|
|
17
15
|
end: Type,
|
|
18
16
|
start: Type
|
|
19
17
|
}, value);
|
|
20
|
-
|
|
21
|
-
writable: true,
|
|
22
|
-
value: void 0
|
|
23
|
-
});
|
|
24
|
-
_classPrivateFieldLooseBase(this, _rangeName)[_rangeName] = rangeName;
|
|
18
|
+
this.#rangeName = rangeName;
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
static with(Types) {
|
|
@@ -54,22 +48,7 @@ export class Range extends Tuple {
|
|
|
54
48
|
|
|
55
49
|
|
|
56
50
|
toRawType() {
|
|
57
|
-
return `${
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
export class RangeInclusive extends Range {
|
|
62
|
-
constructor(registry, Type, value) {
|
|
63
|
-
super(registry, Type, value, 'RangeInclusive');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
static with(Type) {
|
|
67
|
-
return class extends RangeInclusive {
|
|
68
|
-
constructor(registry, value) {
|
|
69
|
-
super(registry, Type, value);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
};
|
|
51
|
+
return `${this.#rangeName}<${this.start.toRawType()}>`;
|
|
73
52
|
}
|
|
74
53
|
|
|
75
54
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RangeInclusive = void 0;
|
|
7
|
+
|
|
8
|
+
var _Range = require("./Range.cjs");
|
|
9
|
+
|
|
10
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
class RangeInclusive extends _Range.Range {
|
|
13
|
+
constructor(registry, Type, value) {
|
|
14
|
+
super(registry, Type, value, 'RangeInclusive');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static with(Type) {
|
|
18
|
+
return class extends RangeInclusive {
|
|
19
|
+
constructor(registry, value) {
|
|
20
|
+
super(registry, Type, value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.RangeInclusive = RangeInclusive;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AnyTuple, CodecClass, INumber, Registry } from '../types';
|
|
2
|
+
import { Range } from './Range';
|
|
3
|
+
export declare class RangeInclusive<T extends INumber = INumber> extends Range<T> {
|
|
4
|
+
constructor(registry: Registry, Type: CodecClass<T> | string, value?: AnyTuple);
|
|
5
|
+
static with<T extends INumber>(Type: CodecClass<T> | string): CodecClass<RangeInclusive<T>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { Range } from "./Range.js";
|
|
4
|
+
export class RangeInclusive extends Range {
|
|
5
|
+
constructor(registry, Type, value) {
|
|
6
|
+
super(registry, Type, value, 'RangeInclusive');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
static with(Type) {
|
|
10
|
+
return class extends RangeInclusive {
|
|
11
|
+
constructor(registry, value) {
|
|
12
|
+
super(registry, Type, value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -34,15 +34,18 @@ function decodeRaw(registry, typeName, value) {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const instance = new Type(registry, value);
|
|
37
|
-
return [Type, instance, instance.
|
|
37
|
+
return [Type, instance, (0, _util.compactAddLength)(instance.toU8a())];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
var _Type = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("Type");
|
|
41
41
|
|
|
42
42
|
var _decoded = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("decoded");
|
|
43
43
|
|
|
44
|
+
var _opaqueName = /*#__PURE__*/(0, _classPrivateFieldLooseKey2.default)("opaqueName");
|
|
45
|
+
|
|
44
46
|
class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
45
47
|
constructor(registry, typeName, value) {
|
|
48
|
+
let opaqueName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'WrapperKeepOpaque';
|
|
46
49
|
const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
|
|
47
50
|
super(registry, u8a);
|
|
48
51
|
Object.defineProperty(this, _Type, {
|
|
@@ -53,8 +56,13 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
53
56
|
writable: true,
|
|
54
57
|
value: void 0
|
|
55
58
|
});
|
|
59
|
+
Object.defineProperty(this, _opaqueName, {
|
|
60
|
+
writable: true,
|
|
61
|
+
value: void 0
|
|
62
|
+
});
|
|
56
63
|
(0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type] = Type;
|
|
57
64
|
(0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded] = decoded;
|
|
65
|
+
(0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName] = opaqueName;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
static with(Type) {
|
|
@@ -87,7 +95,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
87
95
|
|
|
88
96
|
|
|
89
97
|
toRawType() {
|
|
90
|
-
return
|
|
98
|
+
return `${(0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName]}<${this.registry.getClassName((0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type]) || ((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded] ? (0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded].toRawType() : new ((0, _classPrivateFieldLooseBase2.default)(this, _Type)[_Type])(this.registry).toRawType())}>`;
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
93
101
|
* @description Converts the Object to to a string (either decoded or bytes)
|
|
@@ -103,7 +111,7 @@ class WrapperKeepOpaque extends _Bytes.Bytes {
|
|
|
103
111
|
|
|
104
112
|
|
|
105
113
|
unwrap() {
|
|
106
|
-
return (0, _util.assertReturn)((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded],
|
|
114
|
+
return (0, _util.assertReturn)((0, _classPrivateFieldLooseBase2.default)(this, _decoded)[_decoded], () => `${(0, _classPrivateFieldLooseBase2.default)(this, _opaqueName)[_opaqueName]}: unwrapping an undecodable value`);
|
|
107
115
|
}
|
|
108
116
|
|
|
109
117
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { AnyJson,
|
|
1
|
+
import type { AnyJson, Codec, CodecClass, Registry } from '../types';
|
|
2
2
|
import { Bytes } from './Bytes';
|
|
3
|
+
declare type OpaqueName = 'WrapperKeepOpaque' | 'WrapperOpaque';
|
|
3
4
|
export declare class WrapperKeepOpaque<T extends Codec> extends Bytes {
|
|
4
5
|
#private;
|
|
5
|
-
constructor(registry: Registry, typeName: CodecClass<T> | string, value?:
|
|
6
|
+
constructor(registry: Registry, typeName: CodecClass<T> | string, value?: unknown, opaqueName?: OpaqueName);
|
|
6
7
|
static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<WrapperKeepOpaque<T>>;
|
|
7
8
|
/**
|
|
8
9
|
* @description Checks if the wrapper is decodable
|
|
@@ -25,3 +26,4 @@ export declare class WrapperKeepOpaque<T extends Codec> extends Bytes {
|
|
|
25
26
|
*/
|
|
26
27
|
unwrap(): T;
|
|
27
28
|
}
|
|
29
|
+
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import _classPrivateFieldLooseBase from "@babel/runtime/helpers/esm/classPrivateFieldLooseBase";
|
|
2
|
-
import _classPrivateFieldLooseKey from "@babel/runtime/helpers/esm/classPrivateFieldLooseKey";
|
|
3
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
import { assertReturn, compactStripLength, isHex, isU8a } from '@polkadot/util';
|
|
3
|
+
import { assertReturn, compactAddLength, compactStripLength, isHex, isU8a } from '@polkadot/util';
|
|
6
4
|
import { Raw } from "../native/Raw.js";
|
|
7
5
|
import { typeToConstructor } from "../utils/index.js";
|
|
8
6
|
import { Bytes } from "./Bytes.js";
|
|
@@ -20,27 +18,20 @@ function decodeRaw(registry, typeName, value) {
|
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
const instance = new Type(registry, value);
|
|
23
|
-
return [Type, instance, instance.
|
|
21
|
+
return [Type, instance, compactAddLength(instance.toU8a())];
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
var _Type = /*#__PURE__*/_classPrivateFieldLooseKey("Type");
|
|
27
|
-
|
|
28
|
-
var _decoded = /*#__PURE__*/_classPrivateFieldLooseKey("decoded");
|
|
29
|
-
|
|
30
24
|
export class WrapperKeepOpaque extends Bytes {
|
|
31
|
-
|
|
25
|
+
#Type;
|
|
26
|
+
#decoded;
|
|
27
|
+
#opaqueName;
|
|
28
|
+
|
|
29
|
+
constructor(registry, typeName, value, opaqueName = 'WrapperKeepOpaque') {
|
|
32
30
|
const [Type, decoded, u8a] = decodeRaw(registry, typeName, value);
|
|
33
31
|
super(registry, u8a);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(this, _decoded, {
|
|
39
|
-
writable: true,
|
|
40
|
-
value: void 0
|
|
41
|
-
});
|
|
42
|
-
_classPrivateFieldLooseBase(this, _Type)[_Type] = Type;
|
|
43
|
-
_classPrivateFieldLooseBase(this, _decoded)[_decoded] = decoded;
|
|
32
|
+
this.#Type = Type;
|
|
33
|
+
this.#decoded = decoded;
|
|
34
|
+
this.#opaqueName = opaqueName;
|
|
44
35
|
}
|
|
45
36
|
|
|
46
37
|
static with(Type) {
|
|
@@ -57,7 +48,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
57
48
|
|
|
58
49
|
|
|
59
50
|
get isDecoded() {
|
|
60
|
-
return !!
|
|
51
|
+
return !!this.#decoded;
|
|
61
52
|
}
|
|
62
53
|
/**
|
|
63
54
|
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
|
@@ -65,7 +56,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
65
56
|
|
|
66
57
|
|
|
67
58
|
toHuman(isExtended) {
|
|
68
|
-
return
|
|
59
|
+
return this.#decoded ? this.#decoded.toHuman(isExtended) : super.toHuman();
|
|
69
60
|
}
|
|
70
61
|
/**
|
|
71
62
|
* @description Returns the base runtime type name for this instance
|
|
@@ -73,7 +64,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
73
64
|
|
|
74
65
|
|
|
75
66
|
toRawType() {
|
|
76
|
-
return
|
|
67
|
+
return `${this.#opaqueName}<${this.registry.getClassName(this.#Type) || (this.#decoded ? this.#decoded.toRawType() : new this.#Type(this.registry).toRawType())}>`;
|
|
77
68
|
}
|
|
78
69
|
/**
|
|
79
70
|
* @description Converts the Object to to a string (either decoded or bytes)
|
|
@@ -81,7 +72,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
81
72
|
|
|
82
73
|
|
|
83
74
|
toString() {
|
|
84
|
-
return
|
|
75
|
+
return this.#decoded ? this.#decoded.toString() : super.toString();
|
|
85
76
|
}
|
|
86
77
|
/**
|
|
87
78
|
* @description Returns the decoded that the WrapperKeepOpaque represents (if available), throws if non-decodable
|
|
@@ -89,7 +80,7 @@ export class WrapperKeepOpaque extends Bytes {
|
|
|
89
80
|
|
|
90
81
|
|
|
91
82
|
unwrap() {
|
|
92
|
-
return assertReturn(
|
|
83
|
+
return assertReturn(this.#decoded, () => `${this.#opaqueName}: unwrapping an undecodable value`);
|
|
93
84
|
}
|
|
94
85
|
|
|
95
86
|
}
|
|
@@ -5,28 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.WrapperOpaque = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _Base = require("../base/Base.cjs");
|
|
11
|
-
|
|
12
|
-
var _index = require("../utils/index.cjs");
|
|
8
|
+
var _WrapperKeepOpaque = require("./WrapperKeepOpaque.cjs");
|
|
13
9
|
|
|
14
10
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
15
11
|
// SPDX-License-Identifier: Apache-2.0
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if ((0, _util.isU8a)(value)) {
|
|
20
|
-
const [, u8a] = (0, _util.compactStripLength)(value);
|
|
21
|
-
return new Clazz(registry, u8a);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return new Clazz(registry, value);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class WrapperOpaque extends _Base.Base {
|
|
28
|
-
constructor(registry, Type, value) {
|
|
29
|
-
super(registry, decodeRaw(registry, Type, value));
|
|
12
|
+
class WrapperOpaque extends _WrapperKeepOpaque.WrapperKeepOpaque {
|
|
13
|
+
constructor(registry, typeName, value) {
|
|
14
|
+
super(registry, typeName, value, 'WrapperOpaque');
|
|
30
15
|
}
|
|
31
16
|
|
|
32
17
|
static with(Type) {
|
|
@@ -38,21 +23,12 @@ class WrapperOpaque extends _Base.Base {
|
|
|
38
23
|
};
|
|
39
24
|
}
|
|
40
25
|
/**
|
|
41
|
-
* @description
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
toRawType() {
|
|
46
|
-
return `WrapperOpaque<${this.inner.toRawType()}>`;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* @description The length of the value when encoded as a Uint8Array
|
|
26
|
+
* @description The inner value for this wrapper, in all cases it _should_ be decodable (unlike KeepOpaque)
|
|
50
27
|
*/
|
|
51
28
|
|
|
52
29
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return isBare ? u8a : (0, _util.compactAddLength)(u8a);
|
|
30
|
+
get inner() {
|
|
31
|
+
return this.unwrap();
|
|
56
32
|
}
|
|
57
33
|
|
|
58
34
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import type { Codec, CodecClass, Registry } from '../types';
|
|
2
|
-
import {
|
|
3
|
-
export declare class WrapperOpaque<T extends Codec> extends
|
|
4
|
-
constructor(registry: Registry,
|
|
5
|
-
static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<
|
|
2
|
+
import { WrapperKeepOpaque } from './WrapperKeepOpaque';
|
|
3
|
+
export declare class WrapperOpaque<T extends Codec> extends WrapperKeepOpaque<T> {
|
|
4
|
+
constructor(registry: Registry, typeName: CodecClass<T> | string, value?: unknown);
|
|
5
|
+
static with<T extends Codec>(Type: CodecClass<T> | string): CodecClass<WrapperKeepOpaque<T>>;
|
|
6
6
|
/**
|
|
7
|
-
* @description
|
|
7
|
+
* @description The inner value for this wrapper, in all cases it _should_ be decodable (unlike KeepOpaque)
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @description The length of the value when encoded as a Uint8Array
|
|
12
|
-
*/
|
|
13
|
-
toU8a(isBare?: boolean): Uint8Array;
|
|
9
|
+
get inner(): T;
|
|
14
10
|
}
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function decodeRaw(registry, Type, value) {
|
|
8
|
-
const Clazz = typeToConstructor(registry, Type);
|
|
9
|
-
|
|
10
|
-
if (isU8a(value)) {
|
|
11
|
-
const [, u8a] = compactStripLength(value);
|
|
12
|
-
return new Clazz(registry, u8a);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return new Clazz(registry, value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export class WrapperOpaque extends Base {
|
|
19
|
-
constructor(registry, Type, value) {
|
|
20
|
-
super(registry, decodeRaw(registry, Type, value));
|
|
3
|
+
import { WrapperKeepOpaque } from "./WrapperKeepOpaque.js";
|
|
4
|
+
export class WrapperOpaque extends WrapperKeepOpaque {
|
|
5
|
+
constructor(registry, typeName, value) {
|
|
6
|
+
super(registry, typeName, value, 'WrapperOpaque');
|
|
21
7
|
}
|
|
22
8
|
|
|
23
9
|
static with(Type) {
|
|
@@ -29,21 +15,12 @@ export class WrapperOpaque extends Base {
|
|
|
29
15
|
};
|
|
30
16
|
}
|
|
31
17
|
/**
|
|
32
|
-
* @description
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
toRawType() {
|
|
37
|
-
return `WrapperOpaque<${this.inner.toRawType()}>`;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @description The length of the value when encoded as a Uint8Array
|
|
18
|
+
* @description The inner value for this wrapper, in all cases it _should_ be decodable (unlike KeepOpaque)
|
|
41
19
|
*/
|
|
42
20
|
|
|
43
21
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return isBare ? u8a : compactAddLength(u8a);
|
|
22
|
+
get inner() {
|
|
23
|
+
return this.unwrap();
|
|
47
24
|
}
|
|
48
25
|
|
|
49
26
|
}
|
package/extended/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ Object.defineProperty(exports, "Range", {
|
|
|
60
60
|
Object.defineProperty(exports, "RangeInclusive", {
|
|
61
61
|
enumerable: true,
|
|
62
62
|
get: function () {
|
|
63
|
-
return
|
|
63
|
+
return _RangeInclusive.RangeInclusive;
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
Object.defineProperty(exports, "Type", {
|
|
@@ -104,6 +104,8 @@ var _Map = require("./Map.cjs");
|
|
|
104
104
|
|
|
105
105
|
var _Range = require("./Range.cjs");
|
|
106
106
|
|
|
107
|
+
var _RangeInclusive = require("./RangeInclusive.cjs");
|
|
108
|
+
|
|
107
109
|
var _Type = require("./Type.cjs");
|
|
108
110
|
|
|
109
111
|
var _U8aFixed = require("./U8aFixed.cjs");
|
package/extended/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export { Bytes } from './Bytes';
|
|
|
5
5
|
export { HashMap } from './HashMap';
|
|
6
6
|
export { Linkage } from './Linkage';
|
|
7
7
|
export { CodecMap, CodecMap as Map } from './Map';
|
|
8
|
-
export { Range
|
|
8
|
+
export { Range } from './Range';
|
|
9
|
+
export { RangeInclusive } from './RangeInclusive';
|
|
9
10
|
export { Type } from './Type';
|
|
10
11
|
export { U8aFixed } from './U8aFixed';
|
|
11
12
|
export { WrapperKeepOpaque } from './WrapperKeepOpaque';
|
package/extended/index.js
CHANGED
|
@@ -7,7 +7,8 @@ export { Bytes } from "./Bytes.js";
|
|
|
7
7
|
export { HashMap } from "./HashMap.js";
|
|
8
8
|
export { Linkage } from "./Linkage.js";
|
|
9
9
|
export { CodecMap, CodecMap as Map } from "./Map.js";
|
|
10
|
-
export { Range
|
|
10
|
+
export { Range } from "./Range.js";
|
|
11
|
+
export { RangeInclusive } from "./RangeInclusive.js";
|
|
11
12
|
export { Type } from "./Type.js";
|
|
12
13
|
export { U8aFixed } from "./U8aFixed.js";
|
|
13
14
|
export { WrapperKeepOpaque } from "./WrapperKeepOpaque.js";
|
package/native/Bool.js
CHANGED
|
@@ -24,8 +24,6 @@ export class bool extends Boolean {
|
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
25
25
|
constructor(registry, value = false) {
|
|
26
26
|
super(decodeBool(value));
|
|
27
|
-
this.registry = void 0;
|
|
28
|
-
this.createdAtHash = void 0;
|
|
29
27
|
this.registry = registry;
|
|
30
28
|
}
|
|
31
29
|
/**
|
package/native/Date.js
CHANGED
package/native/Json.js
CHANGED
|
@@ -21,8 +21,6 @@ export class Json extends Map {
|
|
|
21
21
|
constructor(registry, value) {
|
|
22
22
|
const decoded = decodeJson(value);
|
|
23
23
|
super(decoded);
|
|
24
|
-
this.registry = void 0;
|
|
25
|
-
this.createdAtHash = void 0;
|
|
26
24
|
this.registry = registry;
|
|
27
25
|
objectProperties(this, decoded.map(([k]) => k), k => this.get(k));
|
|
28
26
|
}
|
package/native/Raw.js
CHANGED
|
@@ -14,9 +14,6 @@ import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a }
|
|
|
14
14
|
export class Raw extends Uint8Array {
|
|
15
15
|
constructor(registry, value, initialU8aLength) {
|
|
16
16
|
super(u8aToU8a(value));
|
|
17
|
-
this.registry = void 0;
|
|
18
|
-
this.createdAtHash = void 0;
|
|
19
|
-
this.initialU8aLength = void 0;
|
|
20
17
|
this.registry = registry;
|
|
21
18
|
this.initialU8aLength = initialU8aLength;
|
|
22
19
|
}
|