Alias for WrapperOpaque to Opaque (#5039)
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `Opaque{Metadata, Multiaddr, PeerId}` decoding to `WrapperOpaque<Bytes>`
|
||||
- Adjust `Opaque{Metadata, Multiaddr, PeerId}` decoding to `Opaque<Bytes>`
|
||||
- Adjust type generation to correctly cater for ambient definitions
|
||||
- Improve type argument generation for `Option<...>` types
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/register": "^7.18.6",
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/dev": "^0.67.55",
|
||||
"@polkadot/dev": "^0.67.58",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^28.1.4",
|
||||
"copyfiles": "^2.4.1"
|
||||
|
||||
@@ -6,7 +6,7 @@ import { AnyString } from '../types';
|
||||
type Mapper = (value: string) => string;
|
||||
|
||||
const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
|
||||
const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
|
||||
const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Opaque', 'Option', 'UInt', 'WrapperKeepOpaque', 'WrapperOpaque']);
|
||||
const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
|
||||
|
||||
const mappings: Mapper[] = [
|
||||
|
||||
@@ -226,6 +226,7 @@ const wrappedExtraction: [string, string, TypeDefInfo][] = [
|
||||
['BTreeSet<', '>', TypeDefInfo.BTreeSet],
|
||||
['Compact<', '>', TypeDefInfo.Compact],
|
||||
['Linkage<', '>', TypeDefInfo.Linkage],
|
||||
['Opaque<', '>', TypeDefInfo.WrapperOpaque],
|
||||
['Option<', '>', TypeDefInfo.Option],
|
||||
['Range<', '>', TypeDefInfo.Range],
|
||||
['RangeInclusive<', '>', TypeDefInfo.RangeInclusive],
|
||||
|
||||
@@ -24,8 +24,8 @@ export default {
|
||||
sessionIndex: 'SessionIndex',
|
||||
authorityIndex: 'AuthIndex'
|
||||
},
|
||||
OpaqueMultiaddr: 'WrapperOpaque<Bytes>',
|
||||
OpaquePeerId: 'WrapperOpaque<Bytes>',
|
||||
OpaqueMultiaddr: 'Opaque<Bytes>',
|
||||
OpaquePeerId: 'Opaque<Bytes>',
|
||||
OpaqueNetworkState: {
|
||||
peerId: 'OpaquePeerId',
|
||||
externalAddresses: 'Vec<OpaqueMultiaddr>'
|
||||
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
StorageHasher: 'StorageHasherV14',
|
||||
|
||||
// additional types
|
||||
OpaqueMetadata: 'WrapperOpaque<Bytes>',
|
||||
OpaqueMetadata: 'Opaque<Bytes>',
|
||||
|
||||
// the enum containing all the mappings
|
||||
MetadataAll: {
|
||||
|
||||
@@ -8,22 +8,20 @@ import { isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { MetadataVersioned } from './MetadataVersioned';
|
||||
|
||||
// magic u32 preceding the version id
|
||||
const VERSION_IDX = 4;
|
||||
|
||||
// magic + lowest supported version
|
||||
const EMPTY_METADATA = new Uint8Array([0x6d, 0x65, 0x74, 0x61, 9]);
|
||||
|
||||
/** @internal */
|
||||
function decodeU8a (registry: Registry, value: Uint8Array): MetadataVersioned | Uint8Array {
|
||||
const u8a = value.length === 0
|
||||
? EMPTY_METADATA
|
||||
: value;
|
||||
// magic u32 preceding the version id
|
||||
const VERSION_IDX = EMPTY_METADATA.length - 1;
|
||||
|
||||
// This is an f-ing hack as a follow-up to another ugly hack
|
||||
// https://github.com/polkadot-js/api/commit/a9211690be6b68ad6c6dad7852f1665cadcfa5b2
|
||||
// when we fail on V9, try to re-parse it as v10...
|
||||
if (u8a[VERSION_IDX] === 9) {
|
||||
/** @internal */
|
||||
function decodeU8a (registry: Registry, u8a: Uint8Array): MetadataVersioned | Uint8Array {
|
||||
if (u8a.length === 0) {
|
||||
return EMPTY_METADATA;
|
||||
} else if (u8a[VERSION_IDX] === 9) {
|
||||
// This is an f-ing hack as a follow-up to another ugly hack
|
||||
// https://github.com/polkadot-js/api/commit/a9211690be6b68ad6c6dad7852f1665cadcfa5b2
|
||||
// when we fail on V9, try to re-parse it as v10...
|
||||
try {
|
||||
return new MetadataVersioned(registry, u8a);
|
||||
} catch (error) {
|
||||
|
||||
@@ -2044,9 +2044,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/dev@npm:^0.67.55":
|
||||
version: 0.67.55
|
||||
resolution: "@polkadot/dev@npm:0.67.55"
|
||||
"@polkadot/dev@npm:^0.67.58":
|
||||
version: 0.67.58
|
||||
resolution: "@polkadot/dev@npm:0.67.58"
|
||||
dependencies:
|
||||
"@babel/cli": ^7.18.6
|
||||
"@babel/core": ^7.18.6
|
||||
@@ -2134,7 +2134,7 @@ __metadata:
|
||||
polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs
|
||||
polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs
|
||||
polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs
|
||||
checksum: 695f7250519af45dd5ef22f8c383033ecf0aacd4c356ab87a5a47e51863f2d44c0283a8ff896e4999923489b8d043e8b36c5f6c53aa912f7c8e2576895ec6083
|
||||
checksum: b7f45bb635cdf8734ec9c8410a489a8d8b9667f944a0816d4fb3f0f7bcde0881b74742072df312e990fa59610439a7d52021e215b42879d04338fd1e457497d7
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -9205,7 +9205,7 @@ resolve@^2.0.0-next.3:
|
||||
"@babel/core": ^7.18.6
|
||||
"@babel/register": ^7.18.6
|
||||
"@babel/runtime": ^7.18.6
|
||||
"@polkadot/dev": ^0.67.55
|
||||
"@polkadot/dev": ^0.67.58
|
||||
"@polkadot/typegen": "workspace:packages/typegen"
|
||||
"@types/jest": ^28.1.4
|
||||
copyfiles: ^2.4.1
|
||||
|
||||
Reference in New Issue
Block a user