@polkadot/types-create 10.1.2 → 10.1.4
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/bundle.js +1 -1
- package/cjs/bundle.js +1 -1
- package/cjs/create/class.js +22 -23
- package/cjs/create/index.js +1 -1
- package/cjs/create/type.js +1 -1
- package/cjs/detectOther.js +1 -1
- package/cjs/detectPackage.js +1 -1
- package/cjs/index.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/types/augmentRegistry.js +1 -1
- package/cjs/types/index.js +1 -1
- package/cjs/types/lookup.js +1 -1
- package/cjs/types/types.js +1 -1
- package/cjs/util/encodeTypes.js +8 -12
- package/cjs/util/getTypeDef.js +1 -1
- package/cjs/util/index.js +1 -1
- package/cjs/util/typeSplit.js +1 -1
- package/cjs/util/xcm.js +1 -1
- package/create/class.js +22 -23
- package/create/index.js +1 -1
- package/create/type.js +1 -1
- package/detectOther.js +1 -1
- package/detectPackage.js +1 -1
- package/index.js +1 -1
- package/package.json +4 -6
- package/packageInfo.js +1 -1
- package/types/augmentRegistry.js +1 -1
- package/types/index.js +1 -1
- package/types/lookup.js +1 -1
- package/types/types.js +1 -1
- package/util/encodeTypes.js +8 -12
- package/util/getTypeDef.js +1 -1
- package/util/index.js +1 -1
- package/util/typeSplit.js +1 -1
- package/util/xcm.js +1 -1
package/bundle.js
CHANGED
package/cjs/bundle.js
CHANGED
|
@@ -7,4 +7,4 @@ Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function
|
|
|
7
7
|
var index_js_1 = require("./types/index.js");
|
|
8
8
|
Object.defineProperty(exports, "TypeDefInfo", { enumerable: true, get: function () { return index_js_1.TypeDefInfo; } });
|
|
9
9
|
tslib_1.__exportStar(require("./create/index.js"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./util/index.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./util/index.js"), exports);
|
package/cjs/create/class.js
CHANGED
|
@@ -48,11 +48,11 @@ function createWithSub(Clazz, value) {
|
|
|
48
48
|
return Clazz.with(getSubType(value));
|
|
49
49
|
}
|
|
50
50
|
const infoMapping = {
|
|
51
|
-
[index_js_1.TypeDefInfo.BTreeMap]: (
|
|
52
|
-
[index_js_1.TypeDefInfo.BTreeSet]: (
|
|
53
|
-
[index_js_1.TypeDefInfo.Compact]: (
|
|
54
|
-
[index_js_1.TypeDefInfo.DoNotConstruct]: (
|
|
55
|
-
[index_js_1.TypeDefInfo.Enum]: (
|
|
51
|
+
[index_js_1.TypeDefInfo.BTreeMap]: (_registry, value) => createHashMap(types_codec_1.BTreeMap, value),
|
|
52
|
+
[index_js_1.TypeDefInfo.BTreeSet]: (_registry, value) => createWithSub(types_codec_1.BTreeSet, value),
|
|
53
|
+
[index_js_1.TypeDefInfo.Compact]: (_registry, value) => createWithSub(types_codec_1.Compact, value),
|
|
54
|
+
[index_js_1.TypeDefInfo.DoNotConstruct]: (_registry, value) => types_codec_1.DoNotConstruct.with(value.displayName || value.type),
|
|
55
|
+
[index_js_1.TypeDefInfo.Enum]: (_registry, value) => {
|
|
56
56
|
const subs = getSubDefArray(value);
|
|
57
57
|
return types_codec_1.Enum.with(subs.every(({ type }) => type === 'Null')
|
|
58
58
|
? subs.reduce((out, { index, name }, count) => {
|
|
@@ -61,10 +61,10 @@ const infoMapping = {
|
|
|
61
61
|
}, {})
|
|
62
62
|
: getTypeClassMap(value));
|
|
63
63
|
},
|
|
64
|
-
[index_js_1.TypeDefInfo.HashMap]: (
|
|
65
|
-
[index_js_1.TypeDefInfo.Int]: (
|
|
64
|
+
[index_js_1.TypeDefInfo.HashMap]: (_registry, value) => createHashMap(types_codec_1.HashMap, value),
|
|
65
|
+
[index_js_1.TypeDefInfo.Int]: (_registry, value) => createInt(types_codec_1.Int, value),
|
|
66
66
|
// We have circular deps between Linkage & Struct
|
|
67
|
-
[index_js_1.TypeDefInfo.Linkage]: (
|
|
67
|
+
[index_js_1.TypeDefInfo.Linkage]: (_registry, value) => {
|
|
68
68
|
const type = `Option<${getSubType(value)}>`;
|
|
69
69
|
// eslint-disable-next-line sort-keys
|
|
70
70
|
const Clazz = types_codec_1.Struct.with({ previous: type, next: type });
|
|
@@ -75,9 +75,8 @@ const infoMapping = {
|
|
|
75
75
|
};
|
|
76
76
|
return Clazz;
|
|
77
77
|
},
|
|
78
|
-
|
|
79
|
-
[index_js_1.TypeDefInfo.
|
|
80
|
-
[index_js_1.TypeDefInfo.Option]: (registry, value) => {
|
|
78
|
+
[index_js_1.TypeDefInfo.Null]: (_registry, _value) => types_codec_1.Null,
|
|
79
|
+
[index_js_1.TypeDefInfo.Option]: (_registry, value) => {
|
|
81
80
|
if (!value.sub || Array.isArray(value.sub)) {
|
|
82
81
|
throw new Error('Expected type information for Option');
|
|
83
82
|
}
|
|
@@ -88,22 +87,22 @@ const infoMapping = {
|
|
|
88
87
|
return createWithSub(types_codec_1.Option, value);
|
|
89
88
|
},
|
|
90
89
|
[index_js_1.TypeDefInfo.Plain]: (registry, value) => registry.getOrUnknown(value.type),
|
|
91
|
-
[index_js_1.TypeDefInfo.Range]: (
|
|
92
|
-
[index_js_1.TypeDefInfo.RangeInclusive]: (
|
|
93
|
-
[index_js_1.TypeDefInfo.Result]: (
|
|
90
|
+
[index_js_1.TypeDefInfo.Range]: (_registry, value) => createWithSub(types_codec_1.Range, value),
|
|
91
|
+
[index_js_1.TypeDefInfo.RangeInclusive]: (_registry, value) => createWithSub(types_codec_1.RangeInclusive, value),
|
|
92
|
+
[index_js_1.TypeDefInfo.Result]: (_registry, value) => {
|
|
94
93
|
const [Ok, Err] = getTypeClassArray(value);
|
|
95
94
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
96
95
|
return types_codec_1.Result.with({ Err, Ok });
|
|
97
96
|
},
|
|
98
|
-
[index_js_1.TypeDefInfo.Set]: (
|
|
97
|
+
[index_js_1.TypeDefInfo.Set]: (_registry, value) => types_codec_1.CodecSet.with(getSubDefArray(value).reduce((result, { index, name }) => {
|
|
99
98
|
result[name] = index;
|
|
100
99
|
return result;
|
|
101
100
|
}, {}), value.length),
|
|
102
101
|
[index_js_1.TypeDefInfo.Si]: (registry, value) => getTypeClass(registry, registry.lookup.getTypeDef(value.type)),
|
|
103
|
-
[index_js_1.TypeDefInfo.Struct]: (
|
|
104
|
-
[index_js_1.TypeDefInfo.Tuple]: (
|
|
105
|
-
[index_js_1.TypeDefInfo.UInt]: (
|
|
106
|
-
[index_js_1.TypeDefInfo.Vec]: (
|
|
102
|
+
[index_js_1.TypeDefInfo.Struct]: (_registry, value) => types_codec_1.Struct.with(getTypeClassMap(value), value.alias),
|
|
103
|
+
[index_js_1.TypeDefInfo.Tuple]: (_registry, value) => types_codec_1.Tuple.with(getTypeClassArray(value)),
|
|
104
|
+
[index_js_1.TypeDefInfo.UInt]: (_registry, value) => createInt(types_codec_1.UInt, value),
|
|
105
|
+
[index_js_1.TypeDefInfo.Vec]: (_registry, { sub }) => {
|
|
107
106
|
if (!sub || Array.isArray(sub)) {
|
|
108
107
|
throw new Error('Expected type information for vector');
|
|
109
108
|
}
|
|
@@ -111,7 +110,7 @@ const infoMapping = {
|
|
|
111
110
|
? types_codec_1.Bytes
|
|
112
111
|
: types_codec_1.Vec.with(getTypeDefType(sub)));
|
|
113
112
|
},
|
|
114
|
-
[index_js_1.TypeDefInfo.VecFixed]: (
|
|
113
|
+
[index_js_1.TypeDefInfo.VecFixed]: (_registry, { displayName, length, sub }) => {
|
|
115
114
|
if (!(0, util_1.isNumber)(length) || !sub || Array.isArray(sub)) {
|
|
116
115
|
throw new Error('Expected length & type information for fixed vector');
|
|
117
116
|
}
|
|
@@ -119,8 +118,8 @@ const infoMapping = {
|
|
|
119
118
|
? types_codec_1.U8aFixed.with((length * 8), displayName)
|
|
120
119
|
: types_codec_1.VecFixed.with(getTypeDefType(sub), length));
|
|
121
120
|
},
|
|
122
|
-
[index_js_1.TypeDefInfo.WrapperKeepOpaque]: (
|
|
123
|
-
[index_js_1.TypeDefInfo.WrapperOpaque]: (
|
|
121
|
+
[index_js_1.TypeDefInfo.WrapperKeepOpaque]: (_registry, value) => createWithSub(types_codec_1.WrapperKeepOpaque, value),
|
|
122
|
+
[index_js_1.TypeDefInfo.WrapperOpaque]: (_registry, value) => createWithSub(types_codec_1.WrapperOpaque, value)
|
|
124
123
|
};
|
|
125
124
|
function constructTypeClass(registry, typeDef) {
|
|
126
125
|
try {
|
|
@@ -154,4 +153,4 @@ function createClassUnsafe(registry, type) {
|
|
|
154
153
|
? registry.lookup.getTypeDef(type)
|
|
155
154
|
: (0, getTypeDef_js_1.getTypeDef)(type)));
|
|
156
155
|
}
|
|
157
|
-
exports.createClassUnsafe = createClassUnsafe;
|
|
156
|
+
exports.createClassUnsafe = createClassUnsafe;
|
package/cjs/create/index.js
CHANGED
package/cjs/create/type.js
CHANGED
package/cjs/detectOther.js
CHANGED
package/cjs/detectPackage.js
CHANGED
|
@@ -4,4 +4,4 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const util_1 = require("@polkadot/util");
|
|
5
5
|
const detectOther_js_1 = tslib_1.__importDefault(require("./detectOther.js"));
|
|
6
6
|
const packageInfo_js_1 = require("./packageInfo.js");
|
|
7
|
-
(0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, detectOther_js_1.default);
|
|
7
|
+
(0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, detectOther_js_1.default);
|
package/cjs/index.js
CHANGED
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.1.
|
|
4
|
+
exports.packageInfo = { name: '@polkadot/types-create', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.1.4' };
|
package/cjs/types/index.js
CHANGED
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
require("./augmentRegistry.js");
|
|
5
5
|
tslib_1.__exportStar(require("./lookup.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./types.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types.js"), exports);
|
package/cjs/types/lookup.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
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 = exports.TypeDefInfo || (exports.TypeDefInfo = {}));
|
|
29
|
+
})(TypeDefInfo = exports.TypeDefInfo || (exports.TypeDefInfo = {}));
|
package/cjs/util/encodeTypes.js
CHANGED
|
@@ -60,18 +60,15 @@ const encoders = {
|
|
|
60
60
|
: encodeSubTypes(registry, sub, true);
|
|
61
61
|
},
|
|
62
62
|
[index_js_1.TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
|
|
63
|
-
[index_js_1.TypeDefInfo.Int]: (
|
|
63
|
+
[index_js_1.TypeDefInfo.Int]: (_registry, { length = 32 }) => `Int<${length}>`,
|
|
64
64
|
[index_js_1.TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
|
|
65
|
-
|
|
66
|
-
[index_js_1.TypeDefInfo.Null]: (registry, typeDef) => 'Null',
|
|
65
|
+
[index_js_1.TypeDefInfo.Null]: (_registry, _typeDef) => 'Null',
|
|
67
66
|
[index_js_1.TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
|
|
68
|
-
|
|
69
|
-
[index_js_1.TypeDefInfo.Plain]: (registry, { displayName, type }) => displayName || type,
|
|
67
|
+
[index_js_1.TypeDefInfo.Plain]: (_registry, { displayName, type }) => displayName || type,
|
|
70
68
|
[index_js_1.TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Range'),
|
|
71
69
|
[index_js_1.TypeDefInfo.RangeInclusive]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'RangeInclusive'),
|
|
72
70
|
[index_js_1.TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
|
|
73
|
-
|
|
74
|
-
[index_js_1.TypeDefInfo.Set]: (registry, { length = 8, sub }) => {
|
|
71
|
+
[index_js_1.TypeDefInfo.Set]: (_registry, { length = 8, sub }) => {
|
|
75
72
|
if (!Array.isArray(sub)) {
|
|
76
73
|
throw new Error('Unable to encode Set type');
|
|
77
74
|
}
|
|
@@ -79,8 +76,7 @@ const encoders = {
|
|
|
79
76
|
_set: sub.reduce((all, { index, name }, count) => (0, util_1.objectSpread)(all, { [`${name || `Unknown${index || count}`}`]: index || count }), { _bitLength: length || 8 })
|
|
80
77
|
});
|
|
81
78
|
},
|
|
82
|
-
|
|
83
|
-
[index_js_1.TypeDefInfo.Si]: (registry, { lookupName, type }) => lookupName || type,
|
|
79
|
+
[index_js_1.TypeDefInfo.Si]: (_registry, { lookupName, type }) => lookupName || type,
|
|
84
80
|
[index_js_1.TypeDefInfo.Struct]: (registry, { alias, sub }) => {
|
|
85
81
|
if (!Array.isArray(sub)) {
|
|
86
82
|
throw new Error('Unable to encode Struct type');
|
|
@@ -97,9 +93,9 @@ const encoders = {
|
|
|
97
93
|
}
|
|
98
94
|
return `(${sub.map((type) => encodeTypeDef(registry, type)).join(',')})`;
|
|
99
95
|
},
|
|
100
|
-
[index_js_1.TypeDefInfo.UInt]: (
|
|
96
|
+
[index_js_1.TypeDefInfo.UInt]: (_registry, { length = 32 }) => `UInt<${length}>`,
|
|
101
97
|
[index_js_1.TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
|
|
102
|
-
[index_js_1.TypeDefInfo.VecFixed]: (
|
|
98
|
+
[index_js_1.TypeDefInfo.VecFixed]: (_registry, { length, sub }) => {
|
|
103
99
|
if (!(0, util_1.isNumber)(length) || !sub || Array.isArray(sub)) {
|
|
104
100
|
throw new Error('Unable to encode VecFixed type');
|
|
105
101
|
}
|
|
@@ -127,4 +123,4 @@ function withTypeString(registry, typeDef) {
|
|
|
127
123
|
type: encodeType(registry, typeDef, false)
|
|
128
124
|
});
|
|
129
125
|
}
|
|
130
|
-
exports.withTypeString = withTypeString;
|
|
126
|
+
exports.withTypeString = withTypeString;
|
package/cjs/util/getTypeDef.js
CHANGED
package/cjs/util/index.js
CHANGED
|
@@ -4,4 +4,4 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./encodeTypes.js"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./getTypeDef.js"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./typeSplit.js"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./xcm.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./xcm.js"), exports);
|
package/cjs/util/typeSplit.js
CHANGED
package/cjs/util/xcm.js
CHANGED
|
@@ -6,4 +6,4 @@ exports.XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions',
|
|
|
6
6
|
function mapXcmTypes(version) {
|
|
7
7
|
return exports.XCM_MAPPINGS.reduce((all, key) => (0, util_1.objectSpread)(all, { [key]: `${key}${version}` }), {});
|
|
8
8
|
}
|
|
9
|
-
exports.mapXcmTypes = mapXcmTypes;
|
|
9
|
+
exports.mapXcmTypes = mapXcmTypes;
|
package/create/class.js
CHANGED
|
@@ -45,11 +45,11 @@ function createWithSub(Clazz, value) {
|
|
|
45
45
|
return Clazz.with(getSubType(value));
|
|
46
46
|
}
|
|
47
47
|
const infoMapping = {
|
|
48
|
-
[TypeDefInfo.BTreeMap]: (
|
|
49
|
-
[TypeDefInfo.BTreeSet]: (
|
|
50
|
-
[TypeDefInfo.Compact]: (
|
|
51
|
-
[TypeDefInfo.DoNotConstruct]: (
|
|
52
|
-
[TypeDefInfo.Enum]: (
|
|
48
|
+
[TypeDefInfo.BTreeMap]: (_registry, value) => createHashMap(BTreeMap, value),
|
|
49
|
+
[TypeDefInfo.BTreeSet]: (_registry, value) => createWithSub(BTreeSet, value),
|
|
50
|
+
[TypeDefInfo.Compact]: (_registry, value) => createWithSub(Compact, value),
|
|
51
|
+
[TypeDefInfo.DoNotConstruct]: (_registry, value) => DoNotConstruct.with(value.displayName || value.type),
|
|
52
|
+
[TypeDefInfo.Enum]: (_registry, value) => {
|
|
53
53
|
const subs = getSubDefArray(value);
|
|
54
54
|
return Enum.with(subs.every(({ type }) => type === 'Null')
|
|
55
55
|
? subs.reduce((out, { index, name }, count) => {
|
|
@@ -58,10 +58,10 @@ const infoMapping = {
|
|
|
58
58
|
}, {})
|
|
59
59
|
: getTypeClassMap(value));
|
|
60
60
|
},
|
|
61
|
-
[TypeDefInfo.HashMap]: (
|
|
62
|
-
[TypeDefInfo.Int]: (
|
|
61
|
+
[TypeDefInfo.HashMap]: (_registry, value) => createHashMap(HashMap, value),
|
|
62
|
+
[TypeDefInfo.Int]: (_registry, value) => createInt(Int, value),
|
|
63
63
|
// We have circular deps between Linkage & Struct
|
|
64
|
-
[TypeDefInfo.Linkage]: (
|
|
64
|
+
[TypeDefInfo.Linkage]: (_registry, value) => {
|
|
65
65
|
const type = `Option<${getSubType(value)}>`;
|
|
66
66
|
// eslint-disable-next-line sort-keys
|
|
67
67
|
const Clazz = Struct.with({ previous: type, next: type });
|
|
@@ -72,9 +72,8 @@ const infoMapping = {
|
|
|
72
72
|
};
|
|
73
73
|
return Clazz;
|
|
74
74
|
},
|
|
75
|
-
|
|
76
|
-
[TypeDefInfo.
|
|
77
|
-
[TypeDefInfo.Option]: (registry, value) => {
|
|
75
|
+
[TypeDefInfo.Null]: (_registry, _value) => Null,
|
|
76
|
+
[TypeDefInfo.Option]: (_registry, value) => {
|
|
78
77
|
if (!value.sub || Array.isArray(value.sub)) {
|
|
79
78
|
throw new Error('Expected type information for Option');
|
|
80
79
|
}
|
|
@@ -85,22 +84,22 @@ const infoMapping = {
|
|
|
85
84
|
return createWithSub(Option, value);
|
|
86
85
|
},
|
|
87
86
|
[TypeDefInfo.Plain]: (registry, value) => registry.getOrUnknown(value.type),
|
|
88
|
-
[TypeDefInfo.Range]: (
|
|
89
|
-
[TypeDefInfo.RangeInclusive]: (
|
|
90
|
-
[TypeDefInfo.Result]: (
|
|
87
|
+
[TypeDefInfo.Range]: (_registry, value) => createWithSub(Range, value),
|
|
88
|
+
[TypeDefInfo.RangeInclusive]: (_registry, value) => createWithSub(RangeInclusive, value),
|
|
89
|
+
[TypeDefInfo.Result]: (_registry, value) => {
|
|
91
90
|
const [Ok, Err] = getTypeClassArray(value);
|
|
92
91
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
93
92
|
return Result.with({ Err, Ok });
|
|
94
93
|
},
|
|
95
|
-
[TypeDefInfo.Set]: (
|
|
94
|
+
[TypeDefInfo.Set]: (_registry, value) => CodecSet.with(getSubDefArray(value).reduce((result, { index, name }) => {
|
|
96
95
|
result[name] = index;
|
|
97
96
|
return result;
|
|
98
97
|
}, {}), value.length),
|
|
99
98
|
[TypeDefInfo.Si]: (registry, value) => getTypeClass(registry, registry.lookup.getTypeDef(value.type)),
|
|
100
|
-
[TypeDefInfo.Struct]: (
|
|
101
|
-
[TypeDefInfo.Tuple]: (
|
|
102
|
-
[TypeDefInfo.UInt]: (
|
|
103
|
-
[TypeDefInfo.Vec]: (
|
|
99
|
+
[TypeDefInfo.Struct]: (_registry, value) => Struct.with(getTypeClassMap(value), value.alias),
|
|
100
|
+
[TypeDefInfo.Tuple]: (_registry, value) => Tuple.with(getTypeClassArray(value)),
|
|
101
|
+
[TypeDefInfo.UInt]: (_registry, value) => createInt(UInt, value),
|
|
102
|
+
[TypeDefInfo.Vec]: (_registry, { sub }) => {
|
|
104
103
|
if (!sub || Array.isArray(sub)) {
|
|
105
104
|
throw new Error('Expected type information for vector');
|
|
106
105
|
}
|
|
@@ -108,7 +107,7 @@ const infoMapping = {
|
|
|
108
107
|
? Bytes
|
|
109
108
|
: Vec.with(getTypeDefType(sub)));
|
|
110
109
|
},
|
|
111
|
-
[TypeDefInfo.VecFixed]: (
|
|
110
|
+
[TypeDefInfo.VecFixed]: (_registry, { displayName, length, sub }) => {
|
|
112
111
|
if (!isNumber(length) || !sub || Array.isArray(sub)) {
|
|
113
112
|
throw new Error('Expected length & type information for fixed vector');
|
|
114
113
|
}
|
|
@@ -116,8 +115,8 @@ const infoMapping = {
|
|
|
116
115
|
? U8aFixed.with((length * 8), displayName)
|
|
117
116
|
: VecFixed.with(getTypeDefType(sub), length));
|
|
118
117
|
},
|
|
119
|
-
[TypeDefInfo.WrapperKeepOpaque]: (
|
|
120
|
-
[TypeDefInfo.WrapperOpaque]: (
|
|
118
|
+
[TypeDefInfo.WrapperKeepOpaque]: (_registry, value) => createWithSub(WrapperKeepOpaque, value),
|
|
119
|
+
[TypeDefInfo.WrapperOpaque]: (_registry, value) => createWithSub(WrapperOpaque, value)
|
|
121
120
|
};
|
|
122
121
|
export function constructTypeClass(registry, typeDef) {
|
|
123
122
|
try {
|
|
@@ -148,4 +147,4 @@ export function createClassUnsafe(registry, type) {
|
|
|
148
147
|
getTypeClass(registry, registry.isLookupType(type)
|
|
149
148
|
? registry.lookup.getTypeDef(type)
|
|
150
149
|
: getTypeDef(type)));
|
|
151
|
-
}
|
|
150
|
+
}
|
package/create/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './class.js';
|
|
2
|
-
export * from './type.js';
|
|
2
|
+
export * from './type.js';
|
package/create/type.js
CHANGED
package/detectOther.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { packageInfo as codecInfo } from '@polkadot/types-codec/packageInfo';
|
|
2
|
-
export default [codecInfo];
|
|
2
|
+
export default [codecInfo];
|
package/detectPackage.js
CHANGED
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './detectPackage.js';
|
|
2
|
-
export * from './bundle.js';
|
|
2
|
+
export * from './bundle.js';
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Jaco Greeff <jacogr@gmail.com>",
|
|
3
3
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
|
4
|
-
"contributors": [],
|
|
5
4
|
"description": "Type creator helpers",
|
|
6
5
|
"engines": {
|
|
7
|
-
"node": ">=14
|
|
6
|
+
"node": ">=14"
|
|
8
7
|
},
|
|
9
8
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-create#readme",
|
|
10
9
|
"license": "Apache-2.0",
|
|
11
|
-
"maintainers": [],
|
|
12
10
|
"name": "@polkadot/types-create",
|
|
13
11
|
"repository": {
|
|
14
12
|
"directory": "packages/types-create",
|
|
@@ -20,7 +18,7 @@
|
|
|
20
18
|
"./cjs/detectPackage.js"
|
|
21
19
|
],
|
|
22
20
|
"type": "module",
|
|
23
|
-
"version": "10.1.
|
|
21
|
+
"version": "10.1.4",
|
|
24
22
|
"main": "./cjs/index.js",
|
|
25
23
|
"module": "./index.js",
|
|
26
24
|
"types": "./index.d.ts",
|
|
@@ -123,8 +121,8 @@
|
|
|
123
121
|
}
|
|
124
122
|
},
|
|
125
123
|
"dependencies": {
|
|
126
|
-
"@polkadot/types-codec": "10.1.
|
|
127
|
-
"@polkadot/util": "^11.
|
|
124
|
+
"@polkadot/types-codec": "10.1.4",
|
|
125
|
+
"@polkadot/util": "^11.1.1",
|
|
128
126
|
"tslib": "^2.5.0"
|
|
129
127
|
}
|
|
130
128
|
}
|
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.
|
|
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.4' };
|
package/types/augmentRegistry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import '@polkadot/types-codec/types/registry';
|
|
1
|
+
import '@polkadot/types-codec/types/registry';
|
package/types/index.js
CHANGED
package/types/lookup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/types/types.js
CHANGED
|
@@ -23,4 +23,4 @@ export var TypeDefInfo;
|
|
|
23
23
|
TypeDefInfo[TypeDefInfo["VecFixed"] = 20] = "VecFixed";
|
|
24
24
|
TypeDefInfo[TypeDefInfo["WrapperKeepOpaque"] = 21] = "WrapperKeepOpaque";
|
|
25
25
|
TypeDefInfo[TypeDefInfo["WrapperOpaque"] = 22] = "WrapperOpaque";
|
|
26
|
-
})(TypeDefInfo || (TypeDefInfo = {}));
|
|
26
|
+
})(TypeDefInfo || (TypeDefInfo = {}));
|
package/util/encodeTypes.js
CHANGED
|
@@ -56,18 +56,15 @@ const encoders = {
|
|
|
56
56
|
: encodeSubTypes(registry, sub, true);
|
|
57
57
|
},
|
|
58
58
|
[TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
|
|
59
|
-
[TypeDefInfo.Int]: (
|
|
59
|
+
[TypeDefInfo.Int]: (_registry, { length = 32 }) => `Int<${length}>`,
|
|
60
60
|
[TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
|
|
61
|
-
|
|
62
|
-
[TypeDefInfo.Null]: (registry, typeDef) => 'Null',
|
|
61
|
+
[TypeDefInfo.Null]: (_registry, _typeDef) => 'Null',
|
|
63
62
|
[TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
|
|
64
|
-
|
|
65
|
-
[TypeDefInfo.Plain]: (registry, { displayName, type }) => displayName || type,
|
|
63
|
+
[TypeDefInfo.Plain]: (_registry, { displayName, type }) => displayName || type,
|
|
66
64
|
[TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Range'),
|
|
67
65
|
[TypeDefInfo.RangeInclusive]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'RangeInclusive'),
|
|
68
66
|
[TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
|
|
69
|
-
|
|
70
|
-
[TypeDefInfo.Set]: (registry, { length = 8, sub }) => {
|
|
67
|
+
[TypeDefInfo.Set]: (_registry, { length = 8, sub }) => {
|
|
71
68
|
if (!Array.isArray(sub)) {
|
|
72
69
|
throw new Error('Unable to encode Set type');
|
|
73
70
|
}
|
|
@@ -75,8 +72,7 @@ const encoders = {
|
|
|
75
72
|
_set: sub.reduce((all, { index, name }, count) => objectSpread(all, { [`${name || `Unknown${index || count}`}`]: index || count }), { _bitLength: length || 8 })
|
|
76
73
|
});
|
|
77
74
|
},
|
|
78
|
-
|
|
79
|
-
[TypeDefInfo.Si]: (registry, { lookupName, type }) => lookupName || type,
|
|
75
|
+
[TypeDefInfo.Si]: (_registry, { lookupName, type }) => lookupName || type,
|
|
80
76
|
[TypeDefInfo.Struct]: (registry, { alias, sub }) => {
|
|
81
77
|
if (!Array.isArray(sub)) {
|
|
82
78
|
throw new Error('Unable to encode Struct type');
|
|
@@ -93,9 +89,9 @@ const encoders = {
|
|
|
93
89
|
}
|
|
94
90
|
return `(${sub.map((type) => encodeTypeDef(registry, type)).join(',')})`;
|
|
95
91
|
},
|
|
96
|
-
[TypeDefInfo.UInt]: (
|
|
92
|
+
[TypeDefInfo.UInt]: (_registry, { length = 32 }) => `UInt<${length}>`,
|
|
97
93
|
[TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
|
|
98
|
-
[TypeDefInfo.VecFixed]: (
|
|
94
|
+
[TypeDefInfo.VecFixed]: (_registry, { length, sub }) => {
|
|
99
95
|
if (!isNumber(length) || !sub || Array.isArray(sub)) {
|
|
100
96
|
throw new Error('Unable to encode VecFixed type');
|
|
101
97
|
}
|
|
@@ -121,4 +117,4 @@ export function withTypeString(registry, typeDef) {
|
|
|
121
117
|
return objectSpread({}, typeDef, {
|
|
122
118
|
type: encodeType(registry, typeDef, false)
|
|
123
119
|
});
|
|
124
|
-
}
|
|
120
|
+
}
|
package/util/getTypeDef.js
CHANGED
package/util/index.js
CHANGED
package/util/typeSplit.js
CHANGED
package/util/xcm.js
CHANGED
|
@@ -2,4 +2,4 @@ import { objectSpread } from '@polkadot/util';
|
|
|
2
2
|
export const XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions', 'MultiAsset', 'MultiAssetFilter', 'MultiLocation', 'Response', 'WildFungibility', 'WildMultiAsset', 'Xcm', 'XcmError', 'XcmOrder'];
|
|
3
3
|
export function mapXcmTypes(version) {
|
|
4
4
|
return XCM_MAPPINGS.reduce((all, key) => objectSpread(all, { [key]: `${key}${version}` }), {});
|
|
5
|
-
}
|
|
5
|
+
}
|