From b544f24bcf63f9ecf1dd9bc1d1abd2eea1d618e2 Mon Sep 17 00:00:00 2001 From: Jaco Date: Sat, 28 Jan 2023 09:07:44 +0200 Subject: [PATCH] Runtime definition cleanups (& CHANGELOG) (#5450) * Runtime definition cleanups (& CHANGELOG) * Adjust to pre-v3 levels * Full CHANGELOG --- CHANGELOG.md | 8 +++ packages/api-augment/src/kusama/runtime.ts | 4 +- packages/api-augment/src/polkadot/runtime.ts | 4 +- packages/api-augment/src/substrate/runtime.ts | 4 +- .../types/src/interfaces/payment/runtime.ts | 52 ++++++++----------- 5 files changed, 37 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d9ad98397d..5d2b0bfdb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,17 @@ ## master +Contributed: + +- Add support for V3 of `TransactionPaymentApi` (Thanks to https://github.com/notlesh) + Changes: - Adjust `Weight` alias detection (moved from `PortableRegistry` -> `Registry`) +- Move default (typegen) weight alias to `WeightV2` (does not affect runtime detection) +- Prepare metadata docs from chain generation for future cli arguments +- Add base type object for (future) composite types +- Apply additional JSDoc comments into `PortaleRegistry` ## 9.12.1 Jan 22, 2023 diff --git a/packages/api-augment/src/kusama/runtime.ts b/packages/api-augment/src/kusama/runtime.ts index fa7be393b6..d5a9626ee0 100644 --- a/packages/api-augment/src/kusama/runtime.ts +++ b/packages/api-augment/src/kusama/runtime.ts @@ -340,9 +340,9 @@ declare module '@polkadot/api-base/types/calls' { **/ queryFeeDetails: AugmentedCall Observable>; /** - * The call info + * The transaction info **/ - queryInfo: AugmentedCall Observable>; + queryInfo: AugmentedCall Observable>; /** * Generic call **/ diff --git a/packages/api-augment/src/polkadot/runtime.ts b/packages/api-augment/src/polkadot/runtime.ts index fa7be393b6..d5a9626ee0 100644 --- a/packages/api-augment/src/polkadot/runtime.ts +++ b/packages/api-augment/src/polkadot/runtime.ts @@ -340,9 +340,9 @@ declare module '@polkadot/api-base/types/calls' { **/ queryFeeDetails: AugmentedCall Observable>; /** - * The call info + * The transaction info **/ - queryInfo: AugmentedCall Observable>; + queryInfo: AugmentedCall Observable>; /** * Generic call **/ diff --git a/packages/api-augment/src/substrate/runtime.ts b/packages/api-augment/src/substrate/runtime.ts index 7e3cd94014..10d9d88089 100644 --- a/packages/api-augment/src/substrate/runtime.ts +++ b/packages/api-augment/src/substrate/runtime.ts @@ -271,9 +271,9 @@ declare module '@polkadot/api-base/types/calls' { **/ queryFeeDetails: AugmentedCall Observable>; /** - * The call info + * The transaction info **/ - queryInfo: AugmentedCall Observable>; + queryInfo: AugmentedCall Observable>; /** * Generic call **/ diff --git a/packages/types/src/interfaces/payment/runtime.ts b/packages/types/src/interfaces/payment/runtime.ts index e3afc296ec..778c7f7e33 100644 --- a/packages/types/src/interfaces/payment/runtime.ts +++ b/packages/types/src/interfaces/payment/runtime.ts @@ -39,13 +39,13 @@ const V1_V2_V3_SHARED_CALL: Record = { } }; -const V2_V3_SHARED_QUERY_INFO: Record = { +const V2_V3_SHARED_PAY: Record = { query_info: { - description: 'The call info', + description: 'The transaction info', params: [ { - name: 'call', - type: 'Call' + name: 'uxt', + type: 'Extrinsic' }, { name: 'len', @@ -56,7 +56,7 @@ const V2_V3_SHARED_QUERY_INFO: Record = { } }; -const V2_V3_SHARED_QUERY_CALL_INFO: Record = { +const V2_V3_SHARED_CALL: Record = { query_call_info: { description: 'The call info', params: [ @@ -73,7 +73,17 @@ const V2_V3_SHARED_QUERY_CALL_INFO: Record = { } }; -const V3_QUERY_WEIGHT_TO_FEE: Record = { +const V3_SHARED_PAY_CALL: Record = { + query_length_to_fee: { + description: 'Query the output of the current LengthToFee given some input', + params: [ + { + name: 'length', + type: 'u32' + } + ], + type: 'Balance' + }, query_weight_to_fee: { description: 'Query the output of the current WeightToFee given some input', params: [ @@ -86,27 +96,13 @@ const V3_QUERY_WEIGHT_TO_FEE: Record = { } }; -const V3_QUERY_LENGTH_TO_FEE: Record = { - query_length_to_fee: { - description: 'Query the output of the current LengthToFee given some input', - params: [ - { - name: 'length', - type: 'u32' - } - ], - type: 'Balance' - } -}; - export const runtime: DefinitionsCall = { TransactionPaymentApi: [ { methods: objectSpread( {}, - V3_QUERY_WEIGHT_TO_FEE, - V3_QUERY_LENGTH_TO_FEE, - V2_V3_SHARED_QUERY_INFO, + V3_SHARED_PAY_CALL, + V2_V3_SHARED_PAY, V1_V2_V3_SHARED_PAY ), version: 3 @@ -114,7 +110,7 @@ export const runtime: DefinitionsCall = { { methods: objectSpread( {}, - V2_V3_SHARED_QUERY_INFO, + V2_V3_SHARED_PAY, V1_V2_V3_SHARED_PAY ), version: 2 @@ -136,7 +132,6 @@ export const runtime: DefinitionsCall = { // NOTE: _Should_ be V1 (as per current Substrate), however the interface was // changed mid-flight between versions. So we have some of each depending on // runtime. (We do detect the weight type, so correct) - // type: 'RuntimeDispatchInfoV1' type: 'RuntimeDispatchInfo' } }, V1_V2_V3_SHARED_PAY), @@ -147,9 +142,8 @@ export const runtime: DefinitionsCall = { { methods: objectSpread( {}, - V3_QUERY_WEIGHT_TO_FEE, - V3_QUERY_LENGTH_TO_FEE, - V2_V3_SHARED_QUERY_CALL_INFO, + V3_SHARED_PAY_CALL, + V2_V3_SHARED_CALL, V1_V2_V3_SHARED_CALL ), version: 3 @@ -157,14 +151,14 @@ export const runtime: DefinitionsCall = { { methods: objectSpread( {}, - V2_V3_SHARED_QUERY_CALL_INFO, + V2_V3_SHARED_CALL, V1_V2_V3_SHARED_CALL ), version: 2 }, { methods: objectSpread({ - query_call_info: { + CALL: { description: 'The call info', params: [ {