From e9030ff04075edd578ecaab4c1a8b53475f607a0 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 15 Mar 2023 20:50:33 +0200 Subject: [PATCH 1/2] Cater for runtime Metadata_* v2 --- .../types/src/interfaces/metadata/runtime.ts | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/packages/types/src/interfaces/metadata/runtime.ts b/packages/types/src/interfaces/metadata/runtime.ts index 72a06977a53e..f06122649f67 100644 --- a/packages/types/src/interfaces/metadata/runtime.ts +++ b/packages/types/src/interfaces/metadata/runtime.ts @@ -1,19 +1,43 @@ // Copyright 2017-2023 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { DefinitionsCall } from '../../types/index.js'; +import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js'; + +import { objectSpread } from '@polkadot/util'; + +const META_V1_TO_V2: DefinitionsCallEntry['methods'] = { + metadata: { + description: 'Returns the metadata of a runtime', + params: [], + type: 'OpaqueMetadata' + } +}; export const runtime: DefinitionsCall = { Metadata: [ { - methods: { - metadata: { - description: 'Returns the metadata of a runtime', + methods: objectSpread({}, META_V1_TO_V2), + version: 1 + }, + { + methods: objectSpread({ + metadata_at_version: { + description: 'Returns the metadata at a given version.', + params: [ + { + name: 'version', + type: 'u32' + } + ], + type: 'Option' + }, + metadata_versions: { + description: 'Returns the supported metadata versions.', params: [], - type: 'OpaqueMetadata' + type: 'Vec' } - }, - version: 1 + }, META_V1_TO_V2), + version: 2 } ] }; From 81255c1c90b1c7ef20157de7244a9a8de744425f Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 15 Mar 2023 20:53:32 +0200 Subject: [PATCH 2/2] Swap order, latest first (as elsewhere) --- packages/types/src/interfaces/metadata/runtime.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/types/src/interfaces/metadata/runtime.ts b/packages/types/src/interfaces/metadata/runtime.ts index f06122649f67..f2608d162f9c 100644 --- a/packages/types/src/interfaces/metadata/runtime.ts +++ b/packages/types/src/interfaces/metadata/runtime.ts @@ -15,10 +15,6 @@ const META_V1_TO_V2: DefinitionsCallEntry['methods'] = { export const runtime: DefinitionsCall = { Metadata: [ - { - methods: objectSpread({}, META_V1_TO_V2), - version: 1 - }, { methods: objectSpread({ metadata_at_version: { @@ -38,6 +34,10 @@ export const runtime: DefinitionsCall = { } }, META_V1_TO_V2), version: 2 + }, + { + methods: objectSpread({}, META_V1_TO_V2), + version: 1 } ] };