@polkadot/types-create 9.14.1 → 10.0.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.
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.packageInfo = void 0;
7
- // Copyright 2017-2023 @polkadot/types-create authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- // Do not edit, auto-generated by @polkadot/dev
11
-
12
- const packageInfo = {
13
- name: '@polkadot/types-create',
14
- path: typeof __dirname === 'string' ? __dirname : 'auto',
15
- type: 'cjs',
16
- version: '9.14.1'
17
- };
18
- exports.packageInfo = packageInfo;
4
+ exports.packageInfo = { name: '@polkadot/types-create', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '10.0.1' };
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
-
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("@polkadot/types-codec/types/registry");
@@ -1,28 +1,6 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
6
4
  require("./augmentRegistry");
7
- var _lookup = require("./lookup");
8
- Object.keys(_lookup).forEach(function (key) {
9
- if (key === "default" || key === "__esModule") return;
10
- if (key in exports && exports[key] === _lookup[key]) return;
11
- Object.defineProperty(exports, key, {
12
- enumerable: true,
13
- get: function () {
14
- return _lookup[key];
15
- }
16
- });
17
- });
18
- var _types = require("./types");
19
- Object.keys(_types).forEach(function (key) {
20
- if (key === "default" || key === "__esModule") return;
21
- if (key in exports && exports[key] === _types[key]) return;
22
- Object.defineProperty(exports, key, {
23
- enumerable: true,
24
- get: function () {
25
- return _types[key];
26
- }
27
- });
28
- });
5
+ tslib_1.__exportStar(require("./lookup"), exports);
6
+ tslib_1.__exportStar(require("./types"), exports);
@@ -1 +1,2 @@
1
- "use strict";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,35 +1,29 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.TypeDefInfo = void 0;
7
- // Copyright 2017-2023 @polkadot/types-create authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
- let TypeDefInfo;
10
- exports.TypeDefInfo = TypeDefInfo;
4
+ var TypeDefInfo;
11
5
  (function (TypeDefInfo) {
12
- TypeDefInfo[TypeDefInfo["BTreeMap"] = 0] = "BTreeMap";
13
- TypeDefInfo[TypeDefInfo["BTreeSet"] = 1] = "BTreeSet";
14
- TypeDefInfo[TypeDefInfo["Compact"] = 2] = "Compact";
15
- TypeDefInfo[TypeDefInfo["DoNotConstruct"] = 3] = "DoNotConstruct";
16
- TypeDefInfo[TypeDefInfo["Enum"] = 4] = "Enum";
17
- TypeDefInfo[TypeDefInfo["HashMap"] = 5] = "HashMap";
18
- TypeDefInfo[TypeDefInfo["Int"] = 6] = "Int";
19
- TypeDefInfo[TypeDefInfo["Linkage"] = 7] = "Linkage";
20
- TypeDefInfo[TypeDefInfo["Null"] = 8] = "Null";
21
- TypeDefInfo[TypeDefInfo["Option"] = 9] = "Option";
22
- TypeDefInfo[TypeDefInfo["Plain"] = 10] = "Plain";
23
- TypeDefInfo[TypeDefInfo["Range"] = 11] = "Range";
24
- TypeDefInfo[TypeDefInfo["RangeInclusive"] = 12] = "RangeInclusive";
25
- TypeDefInfo[TypeDefInfo["Result"] = 13] = "Result";
26
- TypeDefInfo[TypeDefInfo["Set"] = 14] = "Set";
27
- TypeDefInfo[TypeDefInfo["Si"] = 15] = "Si";
28
- TypeDefInfo[TypeDefInfo["Struct"] = 16] = "Struct";
29
- TypeDefInfo[TypeDefInfo["Tuple"] = 17] = "Tuple";
30
- TypeDefInfo[TypeDefInfo["UInt"] = 18] = "UInt";
31
- TypeDefInfo[TypeDefInfo["Vec"] = 19] = "Vec";
32
- TypeDefInfo[TypeDefInfo["VecFixed"] = 20] = "VecFixed";
33
- TypeDefInfo[TypeDefInfo["WrapperKeepOpaque"] = 21] = "WrapperKeepOpaque";
34
- TypeDefInfo[TypeDefInfo["WrapperOpaque"] = 22] = "WrapperOpaque";
35
- })(TypeDefInfo || (exports.TypeDefInfo = TypeDefInfo = {}));
6
+ TypeDefInfo[TypeDefInfo["BTreeMap"] = 0] = "BTreeMap";
7
+ TypeDefInfo[TypeDefInfo["BTreeSet"] = 1] = "BTreeSet";
8
+ TypeDefInfo[TypeDefInfo["Compact"] = 2] = "Compact";
9
+ TypeDefInfo[TypeDefInfo["DoNotConstruct"] = 3] = "DoNotConstruct";
10
+ TypeDefInfo[TypeDefInfo["Enum"] = 4] = "Enum";
11
+ TypeDefInfo[TypeDefInfo["HashMap"] = 5] = "HashMap";
12
+ TypeDefInfo[TypeDefInfo["Int"] = 6] = "Int";
13
+ TypeDefInfo[TypeDefInfo["Linkage"] = 7] = "Linkage";
14
+ TypeDefInfo[TypeDefInfo["Null"] = 8] = "Null";
15
+ TypeDefInfo[TypeDefInfo["Option"] = 9] = "Option";
16
+ TypeDefInfo[TypeDefInfo["Plain"] = 10] = "Plain";
17
+ TypeDefInfo[TypeDefInfo["Range"] = 11] = "Range";
18
+ TypeDefInfo[TypeDefInfo["RangeInclusive"] = 12] = "RangeInclusive";
19
+ TypeDefInfo[TypeDefInfo["Result"] = 13] = "Result";
20
+ TypeDefInfo[TypeDefInfo["Set"] = 14] = "Set";
21
+ TypeDefInfo[TypeDefInfo["Si"] = 15] = "Si";
22
+ TypeDefInfo[TypeDefInfo["Struct"] = 16] = "Struct";
23
+ TypeDefInfo[TypeDefInfo["Tuple"] = 17] = "Tuple";
24
+ TypeDefInfo[TypeDefInfo["UInt"] = 18] = "UInt";
25
+ TypeDefInfo[TypeDefInfo["Vec"] = 19] = "Vec";
26
+ TypeDefInfo[TypeDefInfo["VecFixed"] = 20] = "VecFixed";
27
+ TypeDefInfo[TypeDefInfo["WrapperKeepOpaque"] = 21] = "WrapperKeepOpaque";
28
+ TypeDefInfo[TypeDefInfo["WrapperOpaque"] = 22] = "WrapperOpaque";
29
+ })(TypeDefInfo = exports.TypeDefInfo || (exports.TypeDefInfo = {}));
@@ -1,213 +1,130 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.encodeTypeDef = encodeTypeDef;
7
- exports.paramsNotation = paramsNotation;
8
- exports.withTypeString = withTypeString;
9
- var _util = require("@polkadot/util");
10
- var _types = require("../types");
11
- // Copyright 2017-2023 @polkadot/types-create authors & contributors
12
- // SPDX-License-Identifier: Apache-2.0
13
-
14
- const stringIdentity = value => value.toString();
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withTypeString = exports.encodeTypeDef = exports.paramsNotation = void 0;
4
+ const util_1 = require("@polkadot/util");
5
+ const types_1 = require("../types");
6
+ const stringIdentity = (value) => value.toString();
15
7
  const INFO_WRAP = ['BTreeMap', 'BTreeSet', 'Compact', 'HashMap', 'Option', 'Result', 'Vec'];
16
- function paramsNotation(outer, inner) {
17
- let transform = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringIdentity;
18
- return `${outer}${inner ? `<${(Array.isArray(inner) ? inner : [inner]).map(transform).join(', ')}>` : ''}`;
8
+ function paramsNotation(outer, inner, transform = stringIdentity) {
9
+ return `${outer}${inner
10
+ ? `<${(Array.isArray(inner) ? inner : [inner]).map(transform).join(', ')}>`
11
+ : ''}`;
19
12
  }
13
+ exports.paramsNotation = paramsNotation;
20
14
  function encodeWithParams(registry, typeDef, outer) {
21
- const {
22
- info,
23
- sub
24
- } = typeDef;
25
- switch (info) {
26
- case _types.TypeDefInfo.BTreeMap:
27
- case _types.TypeDefInfo.BTreeSet:
28
- case _types.TypeDefInfo.Compact:
29
- case _types.TypeDefInfo.HashMap:
30
- case _types.TypeDefInfo.Linkage:
31
- case _types.TypeDefInfo.Option:
32
- case _types.TypeDefInfo.Range:
33
- case _types.TypeDefInfo.RangeInclusive:
34
- case _types.TypeDefInfo.Result:
35
- case _types.TypeDefInfo.Vec:
36
- case _types.TypeDefInfo.WrapperKeepOpaque:
37
- case _types.TypeDefInfo.WrapperOpaque:
38
- return paramsNotation(outer, sub, p => encodeTypeDef(registry, p));
39
- }
40
- throw new Error(`Unable to encode ${(0, _util.stringify)(typeDef)} with params`);
15
+ const { info, sub } = typeDef;
16
+ switch (info) {
17
+ case types_1.TypeDefInfo.BTreeMap:
18
+ case types_1.TypeDefInfo.BTreeSet:
19
+ case types_1.TypeDefInfo.Compact:
20
+ case types_1.TypeDefInfo.HashMap:
21
+ case types_1.TypeDefInfo.Linkage:
22
+ case types_1.TypeDefInfo.Option:
23
+ case types_1.TypeDefInfo.Range:
24
+ case types_1.TypeDefInfo.RangeInclusive:
25
+ case types_1.TypeDefInfo.Result:
26
+ case types_1.TypeDefInfo.Vec:
27
+ case types_1.TypeDefInfo.WrapperKeepOpaque:
28
+ case types_1.TypeDefInfo.WrapperOpaque:
29
+ return paramsNotation(outer, sub, (p) => encodeTypeDef(registry, p));
30
+ }
31
+ throw new Error(`Unable to encode ${(0, util_1.stringify)(typeDef)} with params`);
41
32
  }
42
33
  function encodeSubTypes(registry, sub, asEnum, extra) {
43
- const names = sub.map(_ref => {
44
- let {
45
- name
46
- } = _ref;
47
- return name;
48
- });
49
- if (!names.every(n => !!n)) {
50
- throw new Error(`Subtypes does not have consistent names, ${names.join(', ')}`);
51
- }
52
- const inner = (0, _util.objectSpread)({}, extra);
53
- for (let i = 0; i < sub.length; i++) {
54
- const def = sub[i];
55
- inner[def.name] = encodeTypeDef(registry, def);
56
- }
57
- return (0, _util.stringify)(asEnum ? {
58
- _enum: inner
59
- } : inner);
60
- }
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)
64
- const encoders = {
65
- [_types.TypeDefInfo.BTreeMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeMap'),
66
- [_types.TypeDefInfo.BTreeSet]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeSet'),
67
- [_types.TypeDefInfo.Compact]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Compact'),
68
- [_types.TypeDefInfo.DoNotConstruct]: (registry, _ref2) => {
69
- let {
70
- displayName,
71
- lookupIndex,
72
- lookupName
73
- } = _ref2;
74
- return `DoNotConstruct<${lookupName || displayName || ((0, _util.isUndefined)(lookupIndex) ? 'Unknown' : registry.createLookupType(lookupIndex))}>`;
75
- },
76
- [_types.TypeDefInfo.Enum]: (registry, _ref3) => {
77
- let {
78
- sub
79
- } = _ref3;
80
- if (!Array.isArray(sub)) {
81
- throw new Error('Unable to encode Enum type');
34
+ const names = sub.map(({ name }) => name);
35
+ if (!names.every((n) => !!n)) {
36
+ throw new Error(`Subtypes does not have consistent names, ${names.join(', ')}`);
82
37
  }
83
-
84
- // c-like enums have all Null entries
85
- // TODO We need to take the disciminant into account and auto-add empty entries
86
- return sub.every(_ref4 => {
87
- let {
88
- type
89
- } = _ref4;
90
- return type === 'Null';
91
- }) ? (0, _util.stringify)({
92
- _enum: sub.map((_ref5, index) => {
93
- let {
94
- name
95
- } = _ref5;
96
- return `${name || `Empty${index}`}`;
97
- })
98
- }) : encodeSubTypes(registry, sub, true);
99
- },
100
- [_types.TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
101
- [_types.TypeDefInfo.Int]: (registry, _ref6) => {
102
- let {
103
- length = 32
104
- } = _ref6;
105
- return `Int<${length}>`;
106
- },
107
- [_types.TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
108
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
109
- [_types.TypeDefInfo.Null]: (registry, typeDef) => 'Null',
110
- [_types.TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
111
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
- [_types.TypeDefInfo.Plain]: (registry, _ref7) => {
113
- let {
114
- displayName,
115
- type
116
- } = _ref7;
117
- return displayName || type;
118
- },
119
- [_types.TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Range'),
120
- [_types.TypeDefInfo.RangeInclusive]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'RangeInclusive'),
121
- [_types.TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
122
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
123
- [_types.TypeDefInfo.Set]: (registry, _ref8) => {
124
- let {
125
- length = 8,
126
- sub
127
- } = _ref8;
128
- if (!Array.isArray(sub)) {
129
- throw new Error('Unable to encode Set type');
130
- }
131
- return (0, _util.stringify)({
132
- _set: sub.reduce((all, _ref9, count) => {
133
- let {
134
- index,
135
- name
136
- } = _ref9;
137
- return (0, _util.objectSpread)(all, {
138
- [`${name || `Unknown${index || count}`}`]: index || count
139
- });
140
- }, {
141
- _bitLength: length || 8
142
- })
143
- });
144
- },
145
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
146
- [_types.TypeDefInfo.Si]: (registry, _ref10) => {
147
- let {
148
- lookupName,
149
- type
150
- } = _ref10;
151
- return lookupName || type;
152
- },
153
- [_types.TypeDefInfo.Struct]: (registry, _ref11) => {
154
- let {
155
- alias,
156
- sub
157
- } = _ref11;
158
- if (!Array.isArray(sub)) {
159
- throw new Error('Unable to encode Struct type');
38
+ const inner = (0, util_1.objectSpread)({}, extra);
39
+ for (let i = 0; i < sub.length; i++) {
40
+ const def = sub[i];
41
+ inner[def.name] = encodeTypeDef(registry, def);
160
42
  }
161
- return encodeSubTypes(registry, sub, false, alias ? {
162
- _alias: [...alias.entries()].reduce((all, _ref12) => {
163
- let [k, v] = _ref12;
164
- return (0, _util.objectSpread)(all, {
165
- [k]: v
43
+ return (0, util_1.stringify)(asEnum
44
+ ? { _enum: inner }
45
+ : inner);
46
+ }
47
+ const encoders = {
48
+ [types_1.TypeDefInfo.BTreeMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeMap'),
49
+ [types_1.TypeDefInfo.BTreeSet]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeSet'),
50
+ [types_1.TypeDefInfo.Compact]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Compact'),
51
+ [types_1.TypeDefInfo.DoNotConstruct]: (registry, { displayName, lookupIndex, lookupName }) => `DoNotConstruct<${lookupName || displayName || ((0, util_1.isUndefined)(lookupIndex) ? 'Unknown' : registry.createLookupType(lookupIndex))}>`,
52
+ [types_1.TypeDefInfo.Enum]: (registry, { sub }) => {
53
+ if (!Array.isArray(sub)) {
54
+ throw new Error('Unable to encode Enum type');
55
+ }
56
+ // c-like enums have all Null entries
57
+ // TODO We need to take the disciminant into account and auto-add empty entries
58
+ return sub.every(({ type }) => type === 'Null')
59
+ ? (0, util_1.stringify)({ _enum: sub.map(({ name }, index) => `${name || `Empty${index}`}`) })
60
+ : encodeSubTypes(registry, sub, true);
61
+ },
62
+ [types_1.TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
63
+ [types_1.TypeDefInfo.Int]: (registry, { length = 32 }) => `Int<${length}>`,
64
+ [types_1.TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
65
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
66
+ [types_1.TypeDefInfo.Null]: (registry, typeDef) => 'Null',
67
+ [types_1.TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
68
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
69
+ [types_1.TypeDefInfo.Plain]: (registry, { displayName, type }) => displayName || type,
70
+ [types_1.TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Range'),
71
+ [types_1.TypeDefInfo.RangeInclusive]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'RangeInclusive'),
72
+ [types_1.TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
73
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
+ [types_1.TypeDefInfo.Set]: (registry, { length = 8, sub }) => {
75
+ if (!Array.isArray(sub)) {
76
+ throw new Error('Unable to encode Set type');
77
+ }
78
+ return (0, util_1.stringify)({
79
+ _set: sub.reduce((all, { index, name }, count) => (0, util_1.objectSpread)(all, { [`${name || `Unknown${index || count}`}`]: index || count }), { _bitLength: length || 8 })
166
80
  });
167
- }, {})
168
- } : {});
169
- },
170
- [_types.TypeDefInfo.Tuple]: (registry, _ref13) => {
171
- let {
172
- sub
173
- } = _ref13;
174
- if (!Array.isArray(sub)) {
175
- throw new Error('Unable to encode Tuple type');
176
- }
177
- return `(${sub.map(type => encodeTypeDef(registry, type)).join(',')})`;
178
- },
179
- [_types.TypeDefInfo.UInt]: (registry, _ref14) => {
180
- let {
181
- length = 32
182
- } = _ref14;
183
- return `UInt<${length}>`;
184
- },
185
- [_types.TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
186
- [_types.TypeDefInfo.VecFixed]: (registry, _ref15) => {
187
- let {
188
- length,
189
- sub
190
- } = _ref15;
191
- if (!(0, _util.isNumber)(length) || !sub || Array.isArray(sub)) {
192
- throw new Error('Unable to encode VecFixed type');
193
- }
194
- return `[${sub.type};${length}]`;
195
- },
196
- [_types.TypeDefInfo.WrapperKeepOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperKeepOpaque'),
197
- [_types.TypeDefInfo.WrapperOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperOpaque')
81
+ },
82
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
83
+ [types_1.TypeDefInfo.Si]: (registry, { lookupName, type }) => lookupName || type,
84
+ [types_1.TypeDefInfo.Struct]: (registry, { alias, sub }) => {
85
+ if (!Array.isArray(sub)) {
86
+ throw new Error('Unable to encode Struct type');
87
+ }
88
+ return encodeSubTypes(registry, sub, false, alias
89
+ ? {
90
+ _alias: [...alias.entries()].reduce((all, [k, v]) => (0, util_1.objectSpread)(all, { [k]: v }), {})
91
+ }
92
+ : {});
93
+ },
94
+ [types_1.TypeDefInfo.Tuple]: (registry, { sub }) => {
95
+ if (!Array.isArray(sub)) {
96
+ throw new Error('Unable to encode Tuple type');
97
+ }
98
+ return `(${sub.map((type) => encodeTypeDef(registry, type)).join(',')})`;
99
+ },
100
+ [types_1.TypeDefInfo.UInt]: (registry, { length = 32 }) => `UInt<${length}>`,
101
+ [types_1.TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
102
+ [types_1.TypeDefInfo.VecFixed]: (registry, { length, sub }) => {
103
+ if (!(0, util_1.isNumber)(length) || !sub || Array.isArray(sub)) {
104
+ throw new Error('Unable to encode VecFixed type');
105
+ }
106
+ return `[${sub.type};${length}]`;
107
+ },
108
+ [types_1.TypeDefInfo.WrapperKeepOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperKeepOpaque'),
109
+ [types_1.TypeDefInfo.WrapperOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperOpaque')
198
110
  };
199
- function encodeType(registry, typeDef) {
200
- let withLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
201
- return withLookup && typeDef.lookupName ? typeDef.lookupName : encoders[typeDef.info](registry, typeDef);
111
+ function encodeType(registry, typeDef, withLookup = true) {
112
+ return withLookup && typeDef.lookupName
113
+ ? typeDef.lookupName
114
+ : encoders[typeDef.info](registry, typeDef);
202
115
  }
203
116
  function encodeTypeDef(registry, typeDef) {
204
- // In the case of contracts we do have the unfortunate situation where the displayName would
205
- // refer to "Option" when it is an option. For these, string it out, only using when actually
206
- // not a top-level element to be used
207
- return typeDef.displayName && !INFO_WRAP.some(i => typeDef.displayName === i) ? typeDef.displayName : encodeType(registry, typeDef);
117
+ // In the case of contracts we do have the unfortunate situation where the displayName would
118
+ // refer to "Option" when it is an option. For these, string it out, only using when actually
119
+ // not a top-level element to be used
120
+ return (typeDef.displayName && !INFO_WRAP.some((i) => typeDef.displayName === i))
121
+ ? typeDef.displayName
122
+ : encodeType(registry, typeDef);
208
123
  }
124
+ exports.encodeTypeDef = encodeTypeDef;
209
125
  function withTypeString(registry, typeDef) {
210
- return (0, _util.objectSpread)({}, typeDef, {
211
- type: encodeType(registry, typeDef, false)
212
- });
213
- }
126
+ return (0, util_1.objectSpread)({}, typeDef, {
127
+ type: encodeType(registry, typeDef, false)
128
+ });
129
+ }
130
+ exports.withTypeString = withTypeString;