Extend WrapperKeepOpaque with optional decoding (#4422)

* Extend WrapperKeepOpaque with optional decoding

* headers

* TypeDefInfo.WrapperKeepOpaque

* Rebuild

* CHANGELOG
This commit is contained in:
Jaco
2022-01-07 12:36:28 +02:00
committed by GitHub
parent 763e73138a
commit a9b0f97f74
66 changed files with 238 additions and 69 deletions
+1 -1
View File
@@ -6,4 +6,4 @@
// expand with slight care (for instance, Length is really only used internally to
// others, so there _should_ not be need for direct use)
export { BTreeMap, BTreeSet, Compact, DoNotConstruct, Enum, HashMap, Int, Json, Linkage, CodecMap, Map, Option, Range, RangeInclusive, Raw, Result, CodecSet, Set, Struct, Tuple, UInt, U8aFixed, Vec, VecFixed, WrapperOpaque } from '@polkadot/types-codec';
export { BTreeMap, BTreeSet, Compact, DoNotConstruct, Enum, HashMap, Int, Json, Linkage, CodecMap, Map, Option, Range, RangeInclusive, Raw, Result, CodecSet, Set, Struct, Tuple, UInt, U8aFixed, Vec, VecFixed, WrapperKeepOpaque, WrapperOpaque } from '@polkadot/types-codec';
@@ -533,16 +533,15 @@ export class PortableRegistry extends Struct implements ILookup {
))
});
} else if (path.length) {
if (path[path.length - 1].toString() === 'WrapperOpaque') {
const last = path[path.length - 1].toString();
if (['WrapperKeepOpaque', 'WrapperOpaque'].includes(last)) {
return withTypeString(this.registry, {
info: TypeDefInfo.WrapperOpaque,
info: last === 'WrapperKeepOpaque'
? TypeDefInfo.WrapperKeepOpaque
: TypeDefInfo.WrapperOpaque,
sub: this.#createSiDef(params[0].type.unwrap())
});
} else if (path[path.length - 1].toString() === 'WrapperKeepOpaque') {
return {
info: TypeDefInfo.Plain,
type: 'Bytes'
};
}
}
@@ -29,6 +29,7 @@ export function extractTypes (types: string[]): Extracted[] {
case TypeDefInfo.Option:
case TypeDefInfo.Vec:
case TypeDefInfo.VecFixed:
case TypeDefInfo.WrapperKeepOpaque:
case TypeDefInfo.WrapperOpaque:
return extractSubSingle(decoded.sub as TypeDef);