@polkadot/types-create 10.1.3 → 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.
@@ -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]: (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) => {
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]: (registry, value) => createHashMap(types_codec_1.HashMap, value),
65
- [index_js_1.TypeDefInfo.Int]: (registry, value) => createInt(types_codec_1.Int, value),
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]: (registry, value) => {
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
79
- [index_js_1.TypeDefInfo.Null]: (registry, _) => types_codec_1.Null,
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]: (registry, value) => createWithSub(types_codec_1.Range, value),
92
- [index_js_1.TypeDefInfo.RangeInclusive]: (registry, value) => createWithSub(types_codec_1.RangeInclusive, value),
93
- [index_js_1.TypeDefInfo.Result]: (registry, value) => {
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]: (registry, value) => types_codec_1.CodecSet.with(getSubDefArray(value).reduce((result, { index, name }) => {
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]: (registry, value) => types_codec_1.Struct.with(getTypeClassMap(value), value.alias),
104
- [index_js_1.TypeDefInfo.Tuple]: (registry, value) => types_codec_1.Tuple.with(getTypeClassArray(value)),
105
- [index_js_1.TypeDefInfo.UInt]: (registry, value) => createInt(types_codec_1.UInt, value),
106
- [index_js_1.TypeDefInfo.Vec]: (registry, { sub }) => {
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]: (registry, { displayName, length, sub }) => {
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]: (registry, value) => createWithSub(types_codec_1.WrapperKeepOpaque, value),
123
- [index_js_1.TypeDefInfo.WrapperOpaque]: (registry, value) => createWithSub(types_codec_1.WrapperOpaque, value)
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 {
@@ -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.3' };
4
+ exports.packageInfo = { name: '@polkadot/types-create', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.1.4' };
@@ -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]: (registry, { length = 32 }) => `Int<${length}>`,
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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]: (registry, { length = 32 }) => `UInt<${length}>`,
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]: (registry, { length, sub }) => {
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
  }
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]: (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) => {
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]: (registry, value) => createHashMap(HashMap, value),
62
- [TypeDefInfo.Int]: (registry, value) => createInt(Int, value),
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]: (registry, value) => {
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
76
- [TypeDefInfo.Null]: (registry, _) => Null,
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]: (registry, value) => createWithSub(Range, value),
89
- [TypeDefInfo.RangeInclusive]: (registry, value) => createWithSub(RangeInclusive, value),
90
- [TypeDefInfo.Result]: (registry, value) => {
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]: (registry, value) => CodecSet.with(getSubDefArray(value).reduce((result, { index, name }) => {
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]: (registry, value) => Struct.with(getTypeClassMap(value), value.alias),
101
- [TypeDefInfo.Tuple]: (registry, value) => Tuple.with(getTypeClassArray(value)),
102
- [TypeDefInfo.UInt]: (registry, value) => createInt(UInt, value),
103
- [TypeDefInfo.Vec]: (registry, { sub }) => {
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]: (registry, { displayName, length, sub }) => {
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]: (registry, value) => createWithSub(WrapperKeepOpaque, value),
120
- [TypeDefInfo.WrapperOpaque]: (registry, value) => createWithSub(WrapperOpaque, value)
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 {
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "./cjs/detectPackage.js"
19
19
  ],
20
20
  "type": "module",
21
- "version": "10.1.3",
21
+ "version": "10.1.4",
22
22
  "main": "./cjs/index.js",
23
23
  "module": "./index.js",
24
24
  "types": "./index.d.ts",
@@ -121,8 +121,8 @@
121
121
  }
122
122
  },
123
123
  "dependencies": {
124
- "@polkadot/types-codec": "10.1.3",
125
- "@polkadot/util": "^11.0.2",
124
+ "@polkadot/types-codec": "10.1.4",
125
+ "@polkadot/util": "^11.1.1",
126
126
  "tslib": "^2.5.0"
127
127
  }
128
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.3' };
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' };
@@ -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]: (registry, { length = 32 }) => `Int<${length}>`,
59
+ [TypeDefInfo.Int]: (_registry, { length = 32 }) => `Int<${length}>`,
60
60
  [TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
61
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
62
- [TypeDefInfo.Null]: (registry, typeDef) => 'Null',
61
+ [TypeDefInfo.Null]: (_registry, _typeDef) => 'Null',
63
62
  [TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
64
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
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]: (registry, { length = 32 }) => `UInt<${length}>`,
92
+ [TypeDefInfo.UInt]: (_registry, { length = 32 }) => `UInt<${length}>`,
97
93
  [TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
98
- [TypeDefInfo.VecFixed]: (registry, { length, sub }) => {
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
  }