@polkadot/types-create 7.3.2-2 → 7.3.2-6
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/package.json +2 -2
- package/packageInfo.cjs +1 -1
- package/packageInfo.js +1 -1
- package/util/encodeTypes.cjs +37 -36
- package/util/encodeTypes.d.ts +2 -2
- package/util/encodeTypes.js +37 -36
package/package.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./detectPackage.cjs"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"version": "7.3.2-
|
|
23
|
+
"version": "7.3.2-6",
|
|
24
24
|
"main": "index.cjs",
|
|
25
25
|
"module": "index.js",
|
|
26
26
|
"types": "index.d.ts",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@babel/runtime": "^7.16.7",
|
|
104
|
-
"@polkadot/types-codec": "7.3.2-
|
|
104
|
+
"@polkadot/types-codec": "7.3.2-6",
|
|
105
105
|
"@polkadot/util": "^8.3.1"
|
|
106
106
|
}
|
|
107
107
|
}
|
package/packageInfo.cjs
CHANGED
package/packageInfo.js
CHANGED
package/util/encodeTypes.cjs
CHANGED
|
@@ -22,7 +22,7 @@ function paramsNotation(outer, inner) {
|
|
|
22
22
|
return `${outer}${inner ? `<${(Array.isArray(inner) ? inner : [inner]).map(transform).join(', ')}>` : ''}`;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
function encodeWithParams(
|
|
25
|
+
function encodeWithParams(registry, typeDef, outer) {
|
|
26
26
|
const {
|
|
27
27
|
info,
|
|
28
28
|
sub
|
|
@@ -35,17 +35,18 @@ function encodeWithParams(CodecRegistry, typeDef, outer) {
|
|
|
35
35
|
case _types.TypeDefInfo.HashMap:
|
|
36
36
|
case _types.TypeDefInfo.Linkage:
|
|
37
37
|
case _types.TypeDefInfo.Option:
|
|
38
|
+
case _types.TypeDefInfo.Range:
|
|
38
39
|
case _types.TypeDefInfo.Result:
|
|
39
40
|
case _types.TypeDefInfo.Vec:
|
|
40
41
|
case _types.TypeDefInfo.WrapperKeepOpaque:
|
|
41
42
|
case _types.TypeDefInfo.WrapperOpaque:
|
|
42
|
-
return paramsNotation(outer, sub, p => encodeTypeDef(
|
|
43
|
+
return paramsNotation(outer, sub, p => encodeTypeDef(registry, p));
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
throw new Error(`Unable to encode ${(0, _util.stringify)(typeDef)} with params`);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
function encodeSubTypes(
|
|
49
|
+
function encodeSubTypes(registry, sub, asEnum, extra) {
|
|
49
50
|
const names = sub.map(_ref => {
|
|
50
51
|
let {
|
|
51
52
|
name
|
|
@@ -57,7 +58,7 @@ function encodeSubTypes(CodecRegistry, sub, asEnum, extra) {
|
|
|
57
58
|
|
|
58
59
|
for (let i = 0; i < sub.length; i++) {
|
|
59
60
|
const def = sub[i];
|
|
60
|
-
inner[def.name] = encodeTypeDef(
|
|
61
|
+
inner[def.name] = encodeTypeDef(registry, def);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
return (0, _util.stringify)(asEnum ? {
|
|
@@ -68,18 +69,18 @@ function encodeSubTypes(CodecRegistry, sub, asEnum, extra) {
|
|
|
68
69
|
|
|
69
70
|
|
|
70
71
|
const encoders = {
|
|
71
|
-
[_types.TypeDefInfo.BTreeMap]: (
|
|
72
|
-
[_types.TypeDefInfo.BTreeSet]: (
|
|
73
|
-
[_types.TypeDefInfo.Compact]: (
|
|
74
|
-
[_types.TypeDefInfo.DoNotConstruct]: (
|
|
72
|
+
[_types.TypeDefInfo.BTreeMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeMap'),
|
|
73
|
+
[_types.TypeDefInfo.BTreeSet]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeSet'),
|
|
74
|
+
[_types.TypeDefInfo.Compact]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Compact'),
|
|
75
|
+
[_types.TypeDefInfo.DoNotConstruct]: (registry, _ref2) => {
|
|
75
76
|
let {
|
|
76
77
|
displayName,
|
|
77
78
|
lookupIndex,
|
|
78
79
|
lookupName
|
|
79
80
|
} = _ref2;
|
|
80
|
-
return `DoNotConstruct<${lookupName || displayName || ((0, _util.isUndefined)(lookupIndex) ? 'Unknown' :
|
|
81
|
+
return `DoNotConstruct<${lookupName || displayName || ((0, _util.isUndefined)(lookupIndex) ? 'Unknown' : registry.createLookupType(lookupIndex))}>`;
|
|
81
82
|
},
|
|
82
|
-
[_types.TypeDefInfo.Enum]: (
|
|
83
|
+
[_types.TypeDefInfo.Enum]: (registry, _ref3) => {
|
|
83
84
|
let {
|
|
84
85
|
sub
|
|
85
86
|
} = _ref3;
|
|
@@ -98,31 +99,31 @@ const encoders = {
|
|
|
98
99
|
} = _ref5;
|
|
99
100
|
return `${name || `Empty${index}`}`;
|
|
100
101
|
})
|
|
101
|
-
}) : encodeSubTypes(
|
|
102
|
+
}) : encodeSubTypes(registry, sub, true);
|
|
102
103
|
},
|
|
103
|
-
[_types.TypeDefInfo.HashMap]: (
|
|
104
|
-
[_types.TypeDefInfo.Int]: (
|
|
104
|
+
[_types.TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
|
|
105
|
+
[_types.TypeDefInfo.Int]: (registry, _ref6) => {
|
|
105
106
|
let {
|
|
106
107
|
length = 32
|
|
107
108
|
} = _ref6;
|
|
108
109
|
return `Int<${length}>`;
|
|
109
110
|
},
|
|
110
|
-
[_types.TypeDefInfo.Linkage]: (
|
|
111
|
+
[_types.TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
|
|
111
112
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
112
|
-
[_types.TypeDefInfo.Null]: (
|
|
113
|
-
[_types.TypeDefInfo.Option]: (
|
|
113
|
+
[_types.TypeDefInfo.Null]: (registry, typeDef) => 'Null',
|
|
114
|
+
[_types.TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
|
|
114
115
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
115
|
-
[_types.TypeDefInfo.Plain]: (
|
|
116
|
+
[_types.TypeDefInfo.Plain]: (registry, _ref7) => {
|
|
116
117
|
let {
|
|
117
118
|
displayName,
|
|
118
119
|
type
|
|
119
120
|
} = _ref7;
|
|
120
121
|
return displayName || type;
|
|
121
122
|
},
|
|
122
|
-
[_types.TypeDefInfo.Range]: (
|
|
123
|
-
[_types.TypeDefInfo.Result]: (
|
|
123
|
+
[_types.TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, typeDef.type.includes('RangeInclusive') ? 'RangeInclusive' : 'Range'),
|
|
124
|
+
[_types.TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
|
|
124
125
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
125
|
-
[_types.TypeDefInfo.Set]: (
|
|
126
|
+
[_types.TypeDefInfo.Set]: (registry, _ref8) => {
|
|
126
127
|
let {
|
|
127
128
|
length = 8,
|
|
128
129
|
sub
|
|
@@ -143,20 +144,20 @@ const encoders = {
|
|
|
143
144
|
});
|
|
144
145
|
},
|
|
145
146
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
146
|
-
[_types.TypeDefInfo.Si]: (
|
|
147
|
+
[_types.TypeDefInfo.Si]: (registry, _ref10) => {
|
|
147
148
|
let {
|
|
148
149
|
lookupName,
|
|
149
150
|
type
|
|
150
151
|
} = _ref10;
|
|
151
152
|
return lookupName || type;
|
|
152
153
|
},
|
|
153
|
-
[_types.TypeDefInfo.Struct]: (
|
|
154
|
+
[_types.TypeDefInfo.Struct]: (registry, _ref11) => {
|
|
154
155
|
let {
|
|
155
156
|
alias,
|
|
156
157
|
sub
|
|
157
158
|
} = _ref11;
|
|
158
159
|
(0, _util.assert)(sub && Array.isArray(sub), 'Unable to encode Struct type');
|
|
159
|
-
return encodeSubTypes(
|
|
160
|
+
return encodeSubTypes(registry, sub, false, alias ? {
|
|
160
161
|
_alias: [...alias.entries()].reduce((all, _ref12) => {
|
|
161
162
|
let [k, v] = _ref12;
|
|
162
163
|
return (0, _util.objectSpread)(all, {
|
|
@@ -165,21 +166,21 @@ const encoders = {
|
|
|
165
166
|
}, {})
|
|
166
167
|
} : {});
|
|
167
168
|
},
|
|
168
|
-
[_types.TypeDefInfo.Tuple]: (
|
|
169
|
+
[_types.TypeDefInfo.Tuple]: (registry, _ref13) => {
|
|
169
170
|
let {
|
|
170
171
|
sub
|
|
171
172
|
} = _ref13;
|
|
172
173
|
(0, _util.assert)(sub && Array.isArray(sub), 'Unable to encode Tuple type');
|
|
173
|
-
return `(${sub.map(type => encodeTypeDef(
|
|
174
|
+
return `(${sub.map(type => encodeTypeDef(registry, type)).join(',')})`;
|
|
174
175
|
},
|
|
175
|
-
[_types.TypeDefInfo.UInt]: (
|
|
176
|
+
[_types.TypeDefInfo.UInt]: (registry, _ref14) => {
|
|
176
177
|
let {
|
|
177
178
|
length = 32
|
|
178
179
|
} = _ref14;
|
|
179
180
|
return `UInt<${length}>`;
|
|
180
181
|
},
|
|
181
|
-
[_types.TypeDefInfo.Vec]: (
|
|
182
|
-
[_types.TypeDefInfo.VecFixed]: (
|
|
182
|
+
[_types.TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
|
|
183
|
+
[_types.TypeDefInfo.VecFixed]: (registry, _ref15) => {
|
|
183
184
|
let {
|
|
184
185
|
length,
|
|
185
186
|
sub
|
|
@@ -187,24 +188,24 @@ const encoders = {
|
|
|
187
188
|
(0, _util.assert)((0, _util.isNumber)(length) && !(0, _util.isUndefined)(sub) && !Array.isArray(sub), 'Unable to encode VecFixed type');
|
|
188
189
|
return `[${sub.type};${length}]`;
|
|
189
190
|
},
|
|
190
|
-
[_types.TypeDefInfo.WrapperKeepOpaque]: (
|
|
191
|
-
[_types.TypeDefInfo.WrapperOpaque]: (
|
|
191
|
+
[_types.TypeDefInfo.WrapperKeepOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperKeepOpaque'),
|
|
192
|
+
[_types.TypeDefInfo.WrapperOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperOpaque')
|
|
192
193
|
};
|
|
193
194
|
|
|
194
|
-
function encodeType(
|
|
195
|
+
function encodeType(registry, typeDef) {
|
|
195
196
|
let withLookup = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
196
|
-
return withLookup && typeDef.lookupName ? typeDef.lookupName : encoders[typeDef.info](
|
|
197
|
+
return withLookup && typeDef.lookupName ? typeDef.lookupName : encoders[typeDef.info](registry, typeDef);
|
|
197
198
|
}
|
|
198
199
|
|
|
199
|
-
function encodeTypeDef(
|
|
200
|
+
function encodeTypeDef(registry, typeDef) {
|
|
200
201
|
// In the case of contracts we do have the unfortunate situation where the displayName would
|
|
201
202
|
// refer to "Option" when it is an option. For these, string it out, only using when actually
|
|
202
203
|
// not a top-level element to be used
|
|
203
|
-
return typeDef.displayName && !INFO_WRAP.some(i => typeDef.displayName === i) ? typeDef.displayName : encodeType(
|
|
204
|
+
return typeDef.displayName && !INFO_WRAP.some(i => typeDef.displayName === i) ? typeDef.displayName : encodeType(registry, typeDef);
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
function withTypeString(
|
|
207
|
+
function withTypeString(registry, typeDef) {
|
|
207
208
|
return (0, _util.objectSpread)({}, typeDef, {
|
|
208
|
-
type: encodeType(
|
|
209
|
+
type: encodeType(registry, typeDef, false)
|
|
209
210
|
});
|
|
210
211
|
}
|
package/util/encodeTypes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CodecRegistry } from '@polkadot/types-codec/types';
|
|
2
2
|
import type { TypeDef } from '@polkadot/types-create/types';
|
|
3
3
|
export declare function paramsNotation<T>(outer: string, inner?: T | T[], transform?: (_: T) => string): string;
|
|
4
|
-
export declare function encodeTypeDef(
|
|
5
|
-
export declare function withTypeString(
|
|
4
|
+
export declare function encodeTypeDef(registry: CodecRegistry, typeDef: TypeDef): string;
|
|
5
|
+
export declare function withTypeString(registry: CodecRegistry, typeDef: Omit<TypeDef, 'type'> & {
|
|
6
6
|
type?: string;
|
|
7
7
|
}): TypeDef;
|
package/util/encodeTypes.js
CHANGED
|
@@ -10,7 +10,7 @@ export function paramsNotation(outer, inner, transform = stringIdentity) {
|
|
|
10
10
|
return `${outer}${inner ? `<${(Array.isArray(inner) ? inner : [inner]).map(transform).join(', ')}>` : ''}`;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function encodeWithParams(
|
|
13
|
+
function encodeWithParams(registry, typeDef, outer) {
|
|
14
14
|
const {
|
|
15
15
|
info,
|
|
16
16
|
sub
|
|
@@ -23,17 +23,18 @@ function encodeWithParams(CodecRegistry, typeDef, outer) {
|
|
|
23
23
|
case TypeDefInfo.HashMap:
|
|
24
24
|
case TypeDefInfo.Linkage:
|
|
25
25
|
case TypeDefInfo.Option:
|
|
26
|
+
case TypeDefInfo.Range:
|
|
26
27
|
case TypeDefInfo.Result:
|
|
27
28
|
case TypeDefInfo.Vec:
|
|
28
29
|
case TypeDefInfo.WrapperKeepOpaque:
|
|
29
30
|
case TypeDefInfo.WrapperOpaque:
|
|
30
|
-
return paramsNotation(outer, sub, p => encodeTypeDef(
|
|
31
|
+
return paramsNotation(outer, sub, p => encodeTypeDef(registry, p));
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
throw new Error(`Unable to encode ${stringify(typeDef)} with params`);
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
function encodeSubTypes(
|
|
37
|
+
function encodeSubTypes(registry, sub, asEnum, extra) {
|
|
37
38
|
const names = sub.map(({
|
|
38
39
|
name
|
|
39
40
|
}) => name);
|
|
@@ -42,7 +43,7 @@ function encodeSubTypes(CodecRegistry, sub, asEnum, extra) {
|
|
|
42
43
|
|
|
43
44
|
for (let i = 0; i < sub.length; i++) {
|
|
44
45
|
const def = sub[i];
|
|
45
|
-
inner[def.name] = encodeTypeDef(
|
|
46
|
+
inner[def.name] = encodeTypeDef(registry, def);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
return stringify(asEnum ? {
|
|
@@ -53,15 +54,15 @@ function encodeSubTypes(CodecRegistry, sub, asEnum, extra) {
|
|
|
53
54
|
|
|
54
55
|
|
|
55
56
|
const encoders = {
|
|
56
|
-
[TypeDefInfo.BTreeMap]: (
|
|
57
|
-
[TypeDefInfo.BTreeSet]: (
|
|
58
|
-
[TypeDefInfo.Compact]: (
|
|
59
|
-
[TypeDefInfo.DoNotConstruct]: (
|
|
57
|
+
[TypeDefInfo.BTreeMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeMap'),
|
|
58
|
+
[TypeDefInfo.BTreeSet]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'BTreeSet'),
|
|
59
|
+
[TypeDefInfo.Compact]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Compact'),
|
|
60
|
+
[TypeDefInfo.DoNotConstruct]: (registry, {
|
|
60
61
|
displayName,
|
|
61
62
|
lookupIndex,
|
|
62
63
|
lookupName
|
|
63
|
-
}) => `DoNotConstruct<${lookupName || displayName || (isUndefined(lookupIndex) ? 'Unknown' :
|
|
64
|
-
[TypeDefInfo.Enum]: (
|
|
64
|
+
}) => `DoNotConstruct<${lookupName || displayName || (isUndefined(lookupIndex) ? 'Unknown' : registry.createLookupType(lookupIndex))}>`,
|
|
65
|
+
[TypeDefInfo.Enum]: (registry, {
|
|
65
66
|
sub
|
|
66
67
|
}) => {
|
|
67
68
|
assert(sub && Array.isArray(sub), 'Unable to encode Enum type'); // c-like enums have all Null entries
|
|
@@ -73,25 +74,25 @@ const encoders = {
|
|
|
73
74
|
_enum: sub.map(({
|
|
74
75
|
name
|
|
75
76
|
}, index) => `${name || `Empty${index}`}`)
|
|
76
|
-
}) : encodeSubTypes(
|
|
77
|
+
}) : encodeSubTypes(registry, sub, true);
|
|
77
78
|
},
|
|
78
|
-
[TypeDefInfo.HashMap]: (
|
|
79
|
-
[TypeDefInfo.Int]: (
|
|
79
|
+
[TypeDefInfo.HashMap]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'HashMap'),
|
|
80
|
+
[TypeDefInfo.Int]: (registry, {
|
|
80
81
|
length = 32
|
|
81
82
|
}) => `Int<${length}>`,
|
|
82
|
-
[TypeDefInfo.Linkage]: (
|
|
83
|
+
[TypeDefInfo.Linkage]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Linkage'),
|
|
83
84
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
84
|
-
[TypeDefInfo.Null]: (
|
|
85
|
-
[TypeDefInfo.Option]: (
|
|
85
|
+
[TypeDefInfo.Null]: (registry, typeDef) => 'Null',
|
|
86
|
+
[TypeDefInfo.Option]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Option'),
|
|
86
87
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
-
[TypeDefInfo.Plain]: (
|
|
88
|
+
[TypeDefInfo.Plain]: (registry, {
|
|
88
89
|
displayName,
|
|
89
90
|
type
|
|
90
91
|
}) => displayName || type,
|
|
91
|
-
[TypeDefInfo.Range]: (
|
|
92
|
-
[TypeDefInfo.Result]: (
|
|
92
|
+
[TypeDefInfo.Range]: (registry, typeDef) => encodeWithParams(registry, typeDef, typeDef.type.includes('RangeInclusive') ? 'RangeInclusive' : 'Range'),
|
|
93
|
+
[TypeDefInfo.Result]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Result'),
|
|
93
94
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
[TypeDefInfo.Set]: (
|
|
95
|
+
[TypeDefInfo.Set]: (registry, {
|
|
95
96
|
length = 8,
|
|
96
97
|
sub
|
|
97
98
|
}) => {
|
|
@@ -108,54 +109,54 @@ const encoders = {
|
|
|
108
109
|
});
|
|
109
110
|
},
|
|
110
111
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
111
|
-
[TypeDefInfo.Si]: (
|
|
112
|
+
[TypeDefInfo.Si]: (registry, {
|
|
112
113
|
lookupName,
|
|
113
114
|
type
|
|
114
115
|
}) => lookupName || type,
|
|
115
|
-
[TypeDefInfo.Struct]: (
|
|
116
|
+
[TypeDefInfo.Struct]: (registry, {
|
|
116
117
|
alias,
|
|
117
118
|
sub
|
|
118
119
|
}) => {
|
|
119
120
|
assert(sub && Array.isArray(sub), 'Unable to encode Struct type');
|
|
120
|
-
return encodeSubTypes(
|
|
121
|
+
return encodeSubTypes(registry, sub, false, alias ? {
|
|
121
122
|
_alias: [...alias.entries()].reduce((all, [k, v]) => objectSpread(all, {
|
|
122
123
|
[k]: v
|
|
123
124
|
}), {})
|
|
124
125
|
} : {});
|
|
125
126
|
},
|
|
126
|
-
[TypeDefInfo.Tuple]: (
|
|
127
|
+
[TypeDefInfo.Tuple]: (registry, {
|
|
127
128
|
sub
|
|
128
129
|
}) => {
|
|
129
130
|
assert(sub && Array.isArray(sub), 'Unable to encode Tuple type');
|
|
130
|
-
return `(${sub.map(type => encodeTypeDef(
|
|
131
|
+
return `(${sub.map(type => encodeTypeDef(registry, type)).join(',')})`;
|
|
131
132
|
},
|
|
132
|
-
[TypeDefInfo.UInt]: (
|
|
133
|
+
[TypeDefInfo.UInt]: (registry, {
|
|
133
134
|
length = 32
|
|
134
135
|
}) => `UInt<${length}>`,
|
|
135
|
-
[TypeDefInfo.Vec]: (
|
|
136
|
-
[TypeDefInfo.VecFixed]: (
|
|
136
|
+
[TypeDefInfo.Vec]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'Vec'),
|
|
137
|
+
[TypeDefInfo.VecFixed]: (registry, {
|
|
137
138
|
length,
|
|
138
139
|
sub
|
|
139
140
|
}) => {
|
|
140
141
|
assert(isNumber(length) && !isUndefined(sub) && !Array.isArray(sub), 'Unable to encode VecFixed type');
|
|
141
142
|
return `[${sub.type};${length}]`;
|
|
142
143
|
},
|
|
143
|
-
[TypeDefInfo.WrapperKeepOpaque]: (
|
|
144
|
-
[TypeDefInfo.WrapperOpaque]: (
|
|
144
|
+
[TypeDefInfo.WrapperKeepOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperKeepOpaque'),
|
|
145
|
+
[TypeDefInfo.WrapperOpaque]: (registry, typeDef) => encodeWithParams(registry, typeDef, 'WrapperOpaque')
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
function encodeType(
|
|
148
|
-
return withLookup && typeDef.lookupName ? typeDef.lookupName : encoders[typeDef.info](
|
|
148
|
+
function encodeType(registry, typeDef, withLookup = true) {
|
|
149
|
+
return withLookup && typeDef.lookupName ? typeDef.lookupName : encoders[typeDef.info](registry, typeDef);
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
export function encodeTypeDef(
|
|
152
|
+
export function encodeTypeDef(registry, typeDef) {
|
|
152
153
|
// In the case of contracts we do have the unfortunate situation where the displayName would
|
|
153
154
|
// refer to "Option" when it is an option. For these, string it out, only using when actually
|
|
154
155
|
// not a top-level element to be used
|
|
155
|
-
return typeDef.displayName && !INFO_WRAP.some(i => typeDef.displayName === i) ? typeDef.displayName : encodeType(
|
|
156
|
+
return typeDef.displayName && !INFO_WRAP.some(i => typeDef.displayName === i) ? typeDef.displayName : encodeType(registry, typeDef);
|
|
156
157
|
}
|
|
157
|
-
export function withTypeString(
|
|
158
|
+
export function withTypeString(registry, typeDef) {
|
|
158
159
|
return objectSpread({}, typeDef, {
|
|
159
|
-
type: encodeType(
|
|
160
|
+
type: encodeType(registry, typeDef, false)
|
|
160
161
|
});
|
|
161
162
|
}
|