@polkadot/types-create 9.5.2 → 9.6.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/bundle.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Copyright 2017-2022 @polkadot/types-codec authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
+
3
4
  export { packageInfo } from "./packageInfo.js";
4
5
  export { TypeDefInfo } from "./types/index.js";
5
6
  export * from "./create/index.js";
package/cjs/bundle.js CHANGED
@@ -19,13 +19,9 @@ Object.defineProperty(exports, "packageInfo", {
19
19
  return _packageInfo.packageInfo;
20
20
  }
21
21
  });
22
-
23
22
  var _packageInfo = require("./packageInfo");
24
-
25
23
  var _types = require("./types");
26
-
27
24
  var _create = require("./create");
28
-
29
25
  Object.keys(_create).forEach(function (key) {
30
26
  if (key === "default" || key === "__esModule") return;
31
27
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -37,9 +33,7 @@ Object.keys(_create).forEach(function (key) {
37
33
  }
38
34
  });
39
35
  });
40
-
41
36
  var _util = require("./util");
42
-
43
37
  Object.keys(_util).forEach(function (key) {
44
38
  if (key === "default" || key === "__esModule") return;
45
39
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -6,17 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.constructTypeClass = constructTypeClass;
7
7
  exports.createClassUnsafe = createClassUnsafe;
8
8
  exports.getTypeClass = getTypeClass;
9
-
10
9
  var _typesCodec = require("@polkadot/types-codec");
11
-
12
10
  var _util = require("@polkadot/util");
13
-
14
11
  var _types = require("../types");
15
-
16
12
  var _getTypeDef = require("../util/getTypeDef");
17
-
18
13
  // Copyright 2017-2022 @polkadot/types-create authors & contributors
19
14
  // SPDX-License-Identifier: Apache-2.0
15
+
20
16
  function getTypeDefType(_ref) {
21
17
  let {
22
18
  lookupName,
@@ -24,66 +20,53 @@ function getTypeDefType(_ref) {
24
20
  } = _ref;
25
21
  return lookupName || type;
26
22
  }
27
-
28
23
  function getSubDefArray(value) {
29
24
  if (!Array.isArray(value.sub)) {
30
25
  throw new Error(`Expected subtype as TypeDef[] in ${(0, _util.stringify)(value)}`);
31
26
  }
32
-
33
27
  return value.sub;
34
28
  }
35
-
36
29
  function getSubDef(value) {
37
30
  if (!value.sub || Array.isArray(value.sub)) {
38
31
  throw new Error(`Expected subtype as TypeDef in ${(0, _util.stringify)(value)}`);
39
32
  }
40
-
41
33
  return value.sub;
42
34
  }
43
-
44
35
  function getSubType(value) {
45
36
  return getTypeDefType(getSubDef(value));
46
- } // create a maps of type string CodecClasss from the input
47
-
37
+ }
48
38
 
39
+ // create a maps of type string CodecClasss from the input
49
40
  function getTypeClassMap(value) {
50
41
  const subs = getSubDefArray(value);
51
42
  const map = {};
52
-
53
43
  for (let i = 0; i < subs.length; i++) {
54
44
  map[subs[i].name] = getTypeDefType(subs[i]);
55
45
  }
56
-
57
46
  return map;
58
- } // create an array of type string CodecClasss from the input
59
-
47
+ }
60
48
 
49
+ // create an array of type string CodecClasss from the input
61
50
  function getTypeClassArray(value) {
62
51
  return getSubDefArray(value).map(getTypeDefType);
63
52
  }
64
-
65
53
  function createInt(Clazz, _ref2) {
66
54
  let {
67
55
  displayName,
68
56
  length
69
57
  } = _ref2;
70
-
71
58
  if (!(0, _util.isNumber)(length)) {
72
59
  throw new Error(`Expected bitLength information for ${displayName || Clazz.constructor.name}<bitLength>`);
73
60
  }
74
-
75
61
  return Clazz.with(length, displayName);
76
62
  }
77
-
78
63
  function createHashMap(Clazz, value) {
79
64
  const [keyType, valueType] = getTypeClassArray(value);
80
65
  return Clazz.with(keyType, valueType);
81
66
  }
82
-
83
67
  function createWithSub(Clazz, value) {
84
68
  return Clazz.with(getSubType(value));
85
69
  }
86
-
87
70
  const infoMapping = {
88
71
  [_types.TypeDefInfo.BTreeMap]: (registry, value) => createHashMap(_typesCodec.BTreeMap, value),
89
72
  [_types.TypeDefInfo.BTreeSet]: (registry, value) => createWithSub(_typesCodec.BTreeSet, value),
@@ -109,19 +92,18 @@ const infoMapping = {
109
92
  [_types.TypeDefInfo.Int]: (registry, value) => createInt(_typesCodec.Int, value),
110
93
  // We have circular deps between Linkage & Struct
111
94
  [_types.TypeDefInfo.Linkage]: (registry, value) => {
112
- const type = `Option<${getSubType(value)}>`; // eslint-disable-next-line sort-keys
113
-
95
+ const type = `Option<${getSubType(value)}>`;
96
+ // eslint-disable-next-line sort-keys
114
97
  const Clazz = _typesCodec.Struct.with({
115
98
  previous: type,
116
99
  next: type
117
- }); // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
118
-
100
+ });
119
101
 
102
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
120
103
  Clazz.prototype.toRawType = function () {
121
104
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
122
105
  return `Linkage<${this.next.toRawType(true)}>`;
123
106
  };
124
-
125
107
  return Clazz;
126
108
  },
127
109
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -129,20 +111,22 @@ const infoMapping = {
129
111
  [_types.TypeDefInfo.Option]: (registry, value) => {
130
112
  if (!value.sub || Array.isArray(value.sub)) {
131
113
  throw new Error('Expected type information for Option');
132
- } // NOTE This is opt-in (unhandled), not by default
114
+ }
115
+
116
+ // NOTE This is opt-in (unhandled), not by default
133
117
  // if (value.sub.type === 'bool') {
134
118
  // return OptionBool;
135
119
  // }
136
120
 
137
-
138
121
  return createWithSub(_typesCodec.Option, value);
139
122
  },
140
123
  [_types.TypeDefInfo.Plain]: (registry, value) => registry.getOrUnknown(value.type),
141
124
  [_types.TypeDefInfo.Range]: (registry, value) => createWithSub(_typesCodec.Range, value),
142
125
  [_types.TypeDefInfo.RangeInclusive]: (registry, value) => createWithSub(_typesCodec.RangeInclusive, value),
143
126
  [_types.TypeDefInfo.Result]: (registry, value) => {
144
- const [Ok, Err] = getTypeClassArray(value); // eslint-disable-next-line @typescript-eslint/no-use-before-define
127
+ const [Ok, Err] = getTypeClassArray(value);
145
128
 
129
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
146
130
  return _typesCodec.Result.with({
147
131
  Err,
148
132
  Ok
@@ -164,11 +148,9 @@ const infoMapping = {
164
148
  let {
165
149
  sub
166
150
  } = _ref6;
167
-
168
151
  if (!sub || Array.isArray(sub)) {
169
152
  throw new Error('Expected type information for vector');
170
153
  }
171
-
172
154
  return sub.type === 'u8' ? _typesCodec.Bytes : _typesCodec.Vec.with(getTypeDefType(sub));
173
155
  },
174
156
  [_types.TypeDefInfo.VecFixed]: (registry, _ref7) => {
@@ -177,46 +159,42 @@ const infoMapping = {
177
159
  length,
178
160
  sub
179
161
  } = _ref7;
180
-
181
162
  if (!(0, _util.isNumber)(length) || !sub || Array.isArray(sub)) {
182
163
  throw new Error('Expected length & type information for fixed vector');
183
164
  }
184
-
185
165
  return sub.type === 'u8' ? _typesCodec.U8aFixed.with(length * 8, displayName) : _typesCodec.VecFixed.with(getTypeDefType(sub), length);
186
166
  },
187
167
  [_types.TypeDefInfo.WrapperKeepOpaque]: (registry, value) => createWithSub(_typesCodec.WrapperKeepOpaque, value),
188
168
  [_types.TypeDefInfo.WrapperOpaque]: (registry, value) => createWithSub(_typesCodec.WrapperOpaque, value)
189
169
  };
190
-
191
170
  function constructTypeClass(registry, typeDef) {
192
171
  try {
193
172
  const Type = infoMapping[typeDef.info](registry, typeDef);
194
-
195
173
  if (!Type) {
196
174
  throw new Error('No class created');
197
- } // don't clobber any existing
198
-
175
+ }
199
176
 
177
+ // don't clobber any existing
200
178
  if (!Type.__fallbackType && typeDef.fallbackType) {
201
179
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
202
180
  // @ts-ignore ...this is the only place we we actually assign this...
203
181
  Type.__fallbackType = typeDef.fallbackType;
204
182
  }
205
-
206
183
  return Type;
207
184
  } catch (error) {
208
185
  throw new Error(`Unable to construct class from ${(0, _util.stringify)(typeDef)}: ${error.message}`);
209
186
  }
210
- } // Returns the type Class for construction
211
-
187
+ }
212
188
 
189
+ // Returns the type Class for construction
213
190
  function getTypeClass(registry, typeDef) {
214
191
  return registry.getUnsafe(typeDef.type, false, typeDef);
215
192
  }
216
-
217
193
  function createClassUnsafe(registry, type) {
218
- return (// just retrieve via name, no creation via typeDef
219
- registry.getUnsafe(type) || // we don't have an existing type, create the class via typeDef
194
+ return (
195
+ // just retrieve via name, no creation via typeDef
196
+ registry.getUnsafe(type) ||
197
+ // we don't have an existing type, create the class via typeDef
220
198
  getTypeClass(registry, registry.isLookupType(type) ? registry.lookup.getTypeDef(type) : (0, _getTypeDef.getTypeDef)(type))
221
199
  );
222
200
  }
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _class = require("./class");
8
-
9
7
  Object.keys(_class).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _class[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_class).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _type = require("./type");
21
-
22
18
  Object.keys(_type).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _type[key]) return;
@@ -4,42 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createTypeUnsafe = createTypeUnsafe;
7
-
8
7
  var _typesCodec = require("@polkadot/types-codec");
9
-
10
8
  var _util = require("@polkadot/util");
11
-
12
9
  var _class = require("./class");
13
-
14
10
  // Copyright 2017-2022 @polkadot/types-create authors & contributors
15
11
  // SPDX-License-Identifier: Apache-2.0
12
+
16
13
  // With isPedantic, actually check that the encoding matches that supplied. This
17
14
  // is much slower, but verifies that we have the correct types defined
18
15
  function checkInstance(created, matcher) {
19
16
  const u8a = created.toU8a();
20
17
  const rawType = created.toRawType();
21
- const isOk = // full match, all ok
22
- (0, _util.u8aEq)(u8a, matcher) || // on a length-prefixed type, just check the actual length
23
- ['Bytes', 'Text', 'Type'].includes(rawType) && matcher.length === created.length || // when the created is empty and matcher is also empty, let it slide...
18
+ const isOk =
19
+ // full match, all ok
20
+ (0, _util.u8aEq)(u8a, matcher) ||
21
+ // on a length-prefixed type, just check the actual length
22
+ ['Bytes', 'Text', 'Type'].includes(rawType) && matcher.length === created.length ||
23
+ // when the created is empty and matcher is also empty, let it slide...
24
24
  created.isEmpty && matcher.every(v => !v);
25
-
26
25
  if (!isOk) {
27
26
  throw new Error(`${rawType}:: Decoded input doesn't match input, received ${(0, _util.u8aToHex)(matcher, 512)} (${matcher.length} bytes), created ${(0, _util.u8aToHex)(u8a, 512)} (${u8a.length} bytes)`);
28
27
  }
29
28
  }
30
-
31
29
  function checkPedantic(created, _ref) {
32
30
  let [value] = _ref;
33
-
34
31
  if ((0, _util.isU8a)(value)) {
35
32
  checkInstance(created, value);
36
33
  } else if ((0, _util.isHex)(value)) {
37
34
  checkInstance(created, (0, _util.u8aToU8a)(value));
38
35
  }
39
- } // Initializes a type with a value. This also checks for fallbacks and in the cases
40
- // where isPedantic is specified (storage decoding), also check the format/structure
41
-
36
+ }
42
37
 
38
+ // Initializes a type with a value. This also checks for fallbacks and in the cases
39
+ // where isPedantic is specified (storage decoding), also check the format/structure
43
40
  function initType(registry, Type) {
44
41
  let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
45
42
  let {
@@ -49,37 +46,33 @@ function initType(registry, Type) {
49
46
  } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
50
47
  const created = new (isOptional ? _typesCodec.Option.with(Type) : Type)(registry, ...params);
51
48
  isPedantic && checkPedantic(created, params);
52
-
53
49
  if (blockHash) {
54
50
  created.createdAtHash = createTypeUnsafe(registry, 'Hash', [blockHash]);
55
51
  }
56
-
57
52
  return created;
58
- } // An unsafe version of the `createType` below. It's unsafe because the `type`
53
+ }
54
+
55
+ // An unsafe version of the `createType` below. It's unsafe because the `type`
59
56
  // argument here can be any string, which, when it cannot parse, will yield a
60
57
  // runtime error.
61
-
62
-
63
58
  function createTypeUnsafe(registry, type) {
64
59
  let params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
65
60
  let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
66
61
  let Clazz = null;
67
62
  let firstError = null;
68
-
69
63
  try {
70
64
  Clazz = (0, _class.createClassUnsafe)(registry, type);
71
65
  return initType(registry, Clazz, params, options);
72
66
  } catch (error) {
73
67
  firstError = new Error(`createType(${type}):: ${error.message}`);
74
68
  }
75
-
76
69
  if (Clazz && Clazz.__fallbackType) {
77
70
  try {
78
71
  Clazz = (0, _class.createClassUnsafe)(registry, Clazz.__fallbackType);
79
72
  return initType(registry, Clazz, params, options);
80
- } catch {// swallow, we will throw the first error again
73
+ } catch {
74
+ // swallow, we will throw the first error again
81
75
  }
82
76
  }
83
-
84
77
  throw firstError;
85
78
  }
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _packageInfo = require("@polkadot/types-codec/cjs/packageInfo");
9
-
10
8
  // Copyright 2017-2022 @polkadot/types-create authors & contributors
11
9
  // SPDX-License-Identifier: Apache-2.0
12
10
  var _default = [_packageInfo.packageInfo];
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _util = require("@polkadot/util");
6
-
7
5
  var _detectOther = _interopRequireDefault(require("./detectOther"));
8
-
9
6
  var _packageInfo = require("./packageInfo");
10
-
11
7
  // Copyright 2017-2022 @polkadot/types-create authors & contributors
12
8
  // SPDX-License-Identifier: Apache-2.0
9
+
13
10
  // Do not edit, auto-generated by @polkadot/dev
11
+
14
12
  (0, _util.detectPackage)(_packageInfo.packageInfo, null, _detectOther.default);
package/cjs/index.js CHANGED
@@ -3,11 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  require("./detectPackage");
8
-
9
7
  var _bundle = require("./bundle");
10
-
11
8
  Object.keys(_bundle).forEach(function (key) {
12
9
  if (key === "default" || key === "__esModule") return;
13
10
  if (key in exports && exports[key] === _bundle[key]) return;
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.packageInfo = void 0;
7
7
  // Copyright 2017-2022 @polkadot/types-create authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
+
9
10
  // Do not edit, auto-generated by @polkadot/dev
11
+
10
12
  const packageInfo = {
11
13
  name: '@polkadot/types-create',
12
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
13
15
  type: 'cjs',
14
- version: '9.5.2'
16
+ version: '9.6.1'
15
17
  };
16
18
  exports.packageInfo = packageInfo;
@@ -3,11 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  require("./augmentRegistry");
8
-
9
7
  var _lookup = require("./lookup");
10
-
11
8
  Object.keys(_lookup).forEach(function (key) {
12
9
  if (key === "default" || key === "__esModule") return;
13
10
  if (key in exports && exports[key] === _lookup[key]) return;
@@ -18,9 +15,7 @@ Object.keys(_lookup).forEach(function (key) {
18
15
  }
19
16
  });
20
17
  });
21
-
22
18
  var _types = require("./types");
23
-
24
19
  Object.keys(_types).forEach(function (key) {
25
20
  if (key === "default" || key === "__esModule") return;
26
21
  if (key in exports && exports[key] === _types[key]) return;
@@ -8,7 +8,6 @@ exports.TypeDefInfo = void 0;
8
8
  // SPDX-License-Identifier: Apache-2.0
9
9
  let TypeDefInfo;
10
10
  exports.TypeDefInfo = TypeDefInfo;
11
-
12
11
  (function (TypeDefInfo) {
13
12
  TypeDefInfo[TypeDefInfo["BTreeMap"] = 0] = "BTreeMap";
14
13
  TypeDefInfo[TypeDefInfo["BTreeSet"] = 1] = "BTreeSet";
@@ -6,28 +6,22 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.encodeTypeDef = encodeTypeDef;
7
7
  exports.paramsNotation = paramsNotation;
8
8
  exports.withTypeString = withTypeString;
9
-
10
9
  var _util = require("@polkadot/util");
11
-
12
10
  var _types = require("../types");
13
-
14
11
  // Copyright 2017-2022 @polkadot/types-create authors & contributors
15
12
  // SPDX-License-Identifier: Apache-2.0
16
- const stringIdentity = value => value.toString();
17
13
 
14
+ const stringIdentity = value => value.toString();
18
15
  const INFO_WRAP = ['BTreeMap', 'BTreeSet', 'Compact', 'HashMap', 'Option', 'Result', 'Vec'];
19
-
20
16
  function paramsNotation(outer, inner) {
21
17
  let transform = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringIdentity;
22
18
  return `${outer}${inner ? `<${(Array.isArray(inner) ? inner : [inner]).map(transform).join(', ')}>` : ''}`;
23
19
  }
24
-
25
20
  function encodeWithParams(registry, typeDef, outer) {
26
21
  const {
27
22
  info,
28
23
  sub
29
24
  } = typeDef;
30
-
31
25
  switch (info) {
32
26
  case _types.TypeDefInfo.BTreeMap:
33
27
  case _types.TypeDefInfo.BTreeSet:
@@ -43,10 +37,8 @@ function encodeWithParams(registry, typeDef, outer) {
43
37
  case _types.TypeDefInfo.WrapperOpaque:
44
38
  return paramsNotation(outer, sub, p => encodeTypeDef(registry, p));
45
39
  }
46
-
47
40
  throw new Error(`Unable to encode ${(0, _util.stringify)(typeDef)} with params`);
48
41
  }
49
-
50
42
  function encodeSubTypes(registry, sub, asEnum, extra) {
51
43
  const names = sub.map(_ref => {
52
44
  let {
@@ -54,25 +46,21 @@ function encodeSubTypes(registry, sub, asEnum, extra) {
54
46
  } = _ref;
55
47
  return name;
56
48
  });
57
-
58
49
  if (!names.every(n => !!n)) {
59
50
  throw new Error(`Subtypes does not have consistent names, ${names.join(', ')}`);
60
51
  }
61
-
62
52
  const inner = (0, _util.objectSpread)({}, extra);
63
-
64
53
  for (let i = 0; i < sub.length; i++) {
65
54
  const def = sub[i];
66
55
  inner[def.name] = encodeTypeDef(registry, def);
67
56
  }
68
-
69
57
  return (0, _util.stringify)(asEnum ? {
70
58
  _enum: inner
71
59
  } : inner);
72
- } // We setup a record here to ensure we have comprehensive coverage (any item not covered will result
73
- // in a compile-time error with the missing index)
74
-
60
+ }
75
61
 
62
+ // We setup a record here to ensure we have comprehensive coverage (any item not covered will result
63
+ // in a compile-time error with the missing index)
76
64
  const encoders = {
77
65
  [_types.TypeDefInfo.BTreeMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeMap'),
78
66
  [_types.TypeDefInfo.BTreeSet]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeSet'),
@@ -89,13 +77,12 @@ const encoders = {
89
77
  let {
90
78
  sub
91
79
  } = _ref3;
92
-
93
80
  if (!Array.isArray(sub)) {
94
81
  throw new Error('Unable to encode Enum type');
95
- } // c-like enums have all Null entries
96
- // TODO We need to take the disciminant into account and auto-add empty entries
97
-
82
+ }
98
83
 
84
+ // c-like enums have all Null entries
85
+ // TODO We need to take the disciminant into account and auto-add empty entries
99
86
  return sub.every(_ref4 => {
100
87
  let {
101
88
  type
@@ -138,11 +125,9 @@ const encoders = {
138
125
  length = 8,
139
126
  sub
140
127
  } = _ref8;
141
-
142
128
  if (!Array.isArray(sub)) {
143
129
  throw new Error('Unable to encode Set type');
144
130
  }
145
-
146
131
  return (0, _util.stringify)({
147
132
  _set: sub.reduce((all, _ref9, count) => {
148
133
  let {
@@ -170,11 +155,9 @@ const encoders = {
170
155
  alias,
171
156
  sub
172
157
  } = _ref11;
173
-
174
158
  if (!Array.isArray(sub)) {
175
159
  throw new Error('Unable to encode Struct type');
176
160
  }
177
-
178
161
  return encodeSubTypes(registry, sub, false, alias ? {
179
162
  _alias: [...alias.entries()].reduce((all, _ref12) => {
180
163
  let [k, v] = _ref12;
@@ -188,11 +171,9 @@ const encoders = {
188
171
  let {
189
172
  sub
190
173
  } = _ref13;
191
-
192
174
  if (!Array.isArray(sub)) {
193
175
  throw new Error('Unable to encode Tuple type');
194
176
  }
195
-
196
177
  return `(${sub.map(type => encodeTypeDef(registry, type)).join(',')})`;
197
178
  },
198
179
  [_types.TypeDefInfo.UInt]: (registry, _ref14) => {
@@ -207,29 +188,24 @@ const encoders = {
207
188
  length,
208
189
  sub
209
190
  } = _ref15;
210
-
211
191
  if (!(0, _util.isNumber)(length) || !sub || Array.isArray(sub)) {
212
192
  throw new Error('Unable to encode VecFixed type');
213
193
  }
214
-
215
194
  return `[${sub.type};${length}]`;
216
195
  },
217
196
  [_types.TypeDefInfo.WrapperKeepOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperKeepOpaque'),
218
197
  [_types.TypeDefInfo.WrapperOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperOpaque')
219
198
  };
220
-
221
199
  function encodeType(registry, typeDef) {
222
200
  let withLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
223
201
  return withLookup && typeDef.lookupName ? typeDef.lookupName : encoders[typeDef.info](registry, typeDef);
224
202
  }
225
-
226
203
  function encodeTypeDef(registry, typeDef) {
227
204
  // In the case of contracts we do have the unfortunate situation where the displayName would
228
205
  // refer to "Option" when it is an option. For these, string it out, only using when actually
229
206
  // not a top-level element to be used
230
207
  return typeDef.displayName && !INFO_WRAP.some(i => typeDef.displayName === i) ? typeDef.displayName : encodeType(registry, typeDef);
231
208
  }
232
-
233
209
  function withTypeString(registry, typeDef) {
234
210
  return (0, _util.objectSpread)({}, typeDef, {
235
211
  type: encodeType(registry, typeDef, false)