@polkadot/types-create 10.9.1 → 10.10.1
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/cjs/create/class.js +11 -1
- package/cjs/create/type.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/types/types.js +1 -1
- package/cjs/util/encodeTypes.js +3 -0
- package/cjs/util/getTypeDef.js +2 -2
- package/create/class.js +11 -1
- package/create/type.js +1 -1
- package/package.json +4 -4
- package/packageInfo.js +1 -1
- package/util/encodeTypes.d.ts +2 -2
- package/util/encodeTypes.js +3 -0
- package/util/getTypeDef.js +3 -3
package/cjs/create/class.js
CHANGED
|
@@ -27,7 +27,11 @@ function getTypeClassMap(value) {
|
|
|
27
27
|
const subs = getSubDefArray(value);
|
|
28
28
|
const map = {};
|
|
29
29
|
for (let i = 0, count = subs.length; i < count; i++) {
|
|
30
|
-
|
|
30
|
+
const sub = subs[i];
|
|
31
|
+
if (!sub.name) {
|
|
32
|
+
throw new Error(`No name found in definition ${(0, util_1.stringify)(sub)}`);
|
|
33
|
+
}
|
|
34
|
+
map[sub.name] = getTypeDefType(sub);
|
|
31
35
|
}
|
|
32
36
|
return map;
|
|
33
37
|
}
|
|
@@ -56,6 +60,9 @@ const infoMapping = {
|
|
|
56
60
|
const subs = getSubDefArray(value);
|
|
57
61
|
return types_codec_1.Enum.with(subs.every(({ type }) => type === 'Null')
|
|
58
62
|
? subs.reduce((out, { index, name }, count) => {
|
|
63
|
+
if (!name) {
|
|
64
|
+
throw new Error('No name found in sub definition');
|
|
65
|
+
}
|
|
59
66
|
out[name] = index || count;
|
|
60
67
|
return out;
|
|
61
68
|
}, {})
|
|
@@ -95,6 +102,9 @@ const infoMapping = {
|
|
|
95
102
|
return types_codec_1.Result.with({ Err, Ok });
|
|
96
103
|
},
|
|
97
104
|
[index_js_1.TypeDefInfo.Set]: (_registry, value) => types_codec_1.CodecSet.with(getSubDefArray(value).reduce((result, { index, name }) => {
|
|
105
|
+
if (!name || !(0, util_1.isNumber)(index)) {
|
|
106
|
+
throw new Error('No name found in sub definition');
|
|
107
|
+
}
|
|
98
108
|
result[name] = index;
|
|
99
109
|
return result;
|
|
100
110
|
}, {}), value.length),
|
package/cjs/create/type.js
CHANGED
|
@@ -53,7 +53,7 @@ function createTypeUnsafe(registry, type, params = [], options = {}) {
|
|
|
53
53
|
catch (error) {
|
|
54
54
|
firstError = new Error(`createType(${type}):: ${error.message}`);
|
|
55
55
|
}
|
|
56
|
-
if (Clazz
|
|
56
|
+
if (Clazz?.__fallbackType) {
|
|
57
57
|
try {
|
|
58
58
|
Clazz = (0, class_js_1.createClassUnsafe)(registry, Clazz.__fallbackType);
|
|
59
59
|
return initType(registry, Clazz, params, options);
|
package/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@polkadot/types-create', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.
|
|
4
|
+
exports.packageInfo = { name: '@polkadot/types-create', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.10.1' };
|
package/cjs/types/types.js
CHANGED
|
@@ -26,4 +26,4 @@ var TypeDefInfo;
|
|
|
26
26
|
TypeDefInfo[TypeDefInfo["VecFixed"] = 20] = "VecFixed";
|
|
27
27
|
TypeDefInfo[TypeDefInfo["WrapperKeepOpaque"] = 21] = "WrapperKeepOpaque";
|
|
28
28
|
TypeDefInfo[TypeDefInfo["WrapperOpaque"] = 22] = "WrapperOpaque";
|
|
29
|
-
})(TypeDefInfo
|
|
29
|
+
})(TypeDefInfo || (exports.TypeDefInfo = TypeDefInfo = {}));
|
package/cjs/util/encodeTypes.js
CHANGED
|
@@ -38,6 +38,9 @@ function encodeSubTypes(registry, sub, asEnum, extra) {
|
|
|
38
38
|
const inner = (0, util_1.objectSpread)({}, extra);
|
|
39
39
|
for (let i = 0, count = sub.length; i < count; i++) {
|
|
40
40
|
const def = sub[i];
|
|
41
|
+
if (!def.name) {
|
|
42
|
+
throw new Error(`No name found in ${(0, util_1.stringify)(def)}`);
|
|
43
|
+
}
|
|
41
44
|
inner[def.name] = encodeTypeDef(registry, def);
|
|
42
45
|
}
|
|
43
46
|
return (0, util_1.stringify)(asEnum
|
package/cjs/util/getTypeDef.js
CHANGED
|
@@ -9,7 +9,7 @@ const KNOWN_INTERNALS = ['_alias', '_fallback'];
|
|
|
9
9
|
function getTypeString(typeOrObj) {
|
|
10
10
|
return (0, util_1.isString)(typeOrObj)
|
|
11
11
|
? typeOrObj.toString()
|
|
12
|
-
:
|
|
12
|
+
: (0, util_1.stringify)(typeOrObj);
|
|
13
13
|
}
|
|
14
14
|
function isRustEnum(details) {
|
|
15
15
|
const values = Object.values(details);
|
|
@@ -145,7 +145,7 @@ function _decodeDoNotConstruct(value, type, _) {
|
|
|
145
145
|
return value;
|
|
146
146
|
}
|
|
147
147
|
function hasWrapper(type, [start, end]) {
|
|
148
|
-
return (type.
|
|
148
|
+
return (type.startsWith(start)) && (type.slice(-1 * end.length) === end);
|
|
149
149
|
}
|
|
150
150
|
const nestedExtraction = [
|
|
151
151
|
['[', ']', index_js_1.TypeDefInfo.VecFixed, _decodeFixedVec],
|
package/create/class.js
CHANGED
|
@@ -24,7 +24,11 @@ function getTypeClassMap(value) {
|
|
|
24
24
|
const subs = getSubDefArray(value);
|
|
25
25
|
const map = {};
|
|
26
26
|
for (let i = 0, count = subs.length; i < count; i++) {
|
|
27
|
-
|
|
27
|
+
const sub = subs[i];
|
|
28
|
+
if (!sub.name) {
|
|
29
|
+
throw new Error(`No name found in definition ${stringify(sub)}`);
|
|
30
|
+
}
|
|
31
|
+
map[sub.name] = getTypeDefType(sub);
|
|
28
32
|
}
|
|
29
33
|
return map;
|
|
30
34
|
}
|
|
@@ -53,6 +57,9 @@ const infoMapping = {
|
|
|
53
57
|
const subs = getSubDefArray(value);
|
|
54
58
|
return Enum.with(subs.every(({ type }) => type === 'Null')
|
|
55
59
|
? subs.reduce((out, { index, name }, count) => {
|
|
60
|
+
if (!name) {
|
|
61
|
+
throw new Error('No name found in sub definition');
|
|
62
|
+
}
|
|
56
63
|
out[name] = index || count;
|
|
57
64
|
return out;
|
|
58
65
|
}, {})
|
|
@@ -92,6 +99,9 @@ const infoMapping = {
|
|
|
92
99
|
return Result.with({ Err, Ok });
|
|
93
100
|
},
|
|
94
101
|
[TypeDefInfo.Set]: (_registry, value) => CodecSet.with(getSubDefArray(value).reduce((result, { index, name }) => {
|
|
102
|
+
if (!name || !isNumber(index)) {
|
|
103
|
+
throw new Error('No name found in sub definition');
|
|
104
|
+
}
|
|
95
105
|
result[name] = index;
|
|
96
106
|
return result;
|
|
97
107
|
}, {}), value.length),
|
package/create/type.js
CHANGED
|
@@ -50,7 +50,7 @@ export function createTypeUnsafe(registry, type, params = [], options = {}) {
|
|
|
50
50
|
catch (error) {
|
|
51
51
|
firstError = new Error(`createType(${type}):: ${error.message}`);
|
|
52
52
|
}
|
|
53
|
-
if (Clazz
|
|
53
|
+
if (Clazz?.__fallbackType) {
|
|
54
54
|
try {
|
|
55
55
|
Clazz = createClassUnsafe(registry, Clazz.__fallbackType);
|
|
56
56
|
return initType(registry, Clazz, params, options);
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"./cjs/detectPackage.js"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "10.
|
|
21
|
+
"version": "10.10.1",
|
|
22
22
|
"main": "./cjs/index.js",
|
|
23
23
|
"module": "./index.js",
|
|
24
24
|
"types": "./index.d.ts",
|
|
@@ -145,8 +145,8 @@
|
|
|
145
145
|
}
|
|
146
146
|
},
|
|
147
147
|
"dependencies": {
|
|
148
|
-
"@polkadot/types-codec": "10.
|
|
149
|
-
"@polkadot/util": "^12.
|
|
150
|
-
"tslib": "^2.
|
|
148
|
+
"@polkadot/types-codec": "10.10.1",
|
|
149
|
+
"@polkadot/util": "^12.5.1",
|
|
150
|
+
"tslib": "^2.6.2"
|
|
151
151
|
}
|
|
152
152
|
}
|
package/packageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@polkadot/types-create', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.
|
|
1
|
+
export const packageInfo = { name: '@polkadot/types-create', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '10.10.1' };
|
package/util/encodeTypes.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Registry } from '@polkadot/types-codec/types';
|
|
2
2
|
import type { TypeDef } from '@polkadot/types-create/types';
|
|
3
|
-
|
|
3
|
+
interface ToString {
|
|
4
4
|
toString: () => string;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
export declare function paramsNotation<T extends ToString>(outer: string, inner?: T | T[], transform?: (_: T) => string): string;
|
|
7
7
|
export declare function encodeTypeDef(registry: Registry, typeDef: TypeDef): string;
|
|
8
8
|
export declare function withTypeString(registry: Registry, typeDef: Omit<TypeDef, 'type'> & {
|
package/util/encodeTypes.js
CHANGED
|
@@ -34,6 +34,9 @@ function encodeSubTypes(registry, sub, asEnum, extra) {
|
|
|
34
34
|
const inner = objectSpread({}, extra);
|
|
35
35
|
for (let i = 0, count = sub.length; i < count; i++) {
|
|
36
36
|
const def = sub[i];
|
|
37
|
+
if (!def.name) {
|
|
38
|
+
throw new Error(`No name found in ${stringify(def)}`);
|
|
39
|
+
}
|
|
37
40
|
inner[def.name] = encodeTypeDef(registry, def);
|
|
38
41
|
}
|
|
39
42
|
return stringify(asEnum
|
package/util/getTypeDef.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { sanitize } from '@polkadot/types-codec';
|
|
2
|
-
import { isNumber, isString, objectSpread } from '@polkadot/util';
|
|
2
|
+
import { isNumber, isString, objectSpread, stringify } from '@polkadot/util';
|
|
3
3
|
import { TypeDefInfo } from '../types/index.js';
|
|
4
4
|
import { typeSplit } from './typeSplit.js';
|
|
5
5
|
const KNOWN_INTERNALS = ['_alias', '_fallback'];
|
|
6
6
|
function getTypeString(typeOrObj) {
|
|
7
7
|
return isString(typeOrObj)
|
|
8
8
|
? typeOrObj.toString()
|
|
9
|
-
:
|
|
9
|
+
: stringify(typeOrObj);
|
|
10
10
|
}
|
|
11
11
|
function isRustEnum(details) {
|
|
12
12
|
const values = Object.values(details);
|
|
@@ -142,7 +142,7 @@ function _decodeDoNotConstruct(value, type, _) {
|
|
|
142
142
|
return value;
|
|
143
143
|
}
|
|
144
144
|
function hasWrapper(type, [start, end]) {
|
|
145
|
-
return (type.
|
|
145
|
+
return (type.startsWith(start)) && (type.slice(-1 * end.length) === end);
|
|
146
146
|
}
|
|
147
147
|
const nestedExtraction = [
|
|
148
148
|
['[', ']', TypeDefInfo.VecFixed, _decodeFixedVec],
|