Adjust (to be deprecated) payment RPC return values (#5341)

* Adjust (to be deprecated) payment RPC return values

* Adjust

* Build TS interfaces
This commit is contained in:
Jaco
2022-11-16 18:16:49 +02:00
committed by GitHub
parent d22a2918ce
commit a3901ca7ad
9 changed files with 158 additions and 101 deletions
@@ -27,6 +27,11 @@ export default {
weight: 'Weight',
class: 'DispatchClass',
partialFee: 'Balance'
},
RuntimeDispatchInfoV1: {
weight: 'WeightV1',
class: 'DispatchClass',
partialFee: 'Balance'
}
}
} as Definitions;
+6 -1
View File
@@ -5,6 +5,8 @@ import type { DefinitionsRpc } from '../../types';
export const rpc: DefinitionsRpc = {
queryFeeDetails: {
// NOTE: Not deprecated (yet) in Substrate, but it is the intent to do so
deprecated: 'Use `api.call.transactionPaymentApi.queryFeeDetails` instead',
description: 'Query the detailed fee of a given encoded extrinsic',
params: [
{
@@ -21,6 +23,8 @@ export const rpc: DefinitionsRpc = {
type: 'FeeDetails'
},
queryInfo: {
// NOTE: Not deprecated (yet) in Substrate, but it is the intent to do so
deprecated: 'Use `api.call.transactionPaymentApi.queryInfo` instead',
description: 'Retrieves the fee information for an encoded extrinsic',
params: [
{
@@ -34,6 +38,7 @@ export const rpc: DefinitionsRpc = {
type: 'BlockHash'
}
],
type: 'RuntimeDispatchInfo'
// NOTE: Stuck on V1 forever (at least for the time being)
type: 'RuntimeDispatchInfoV1'
}
};
@@ -19,23 +19,6 @@ const V1_V2_SHARED_PAY: Record<string, DefinitionCall> = {
}
],
type: 'FeeDetails'
},
query_info: {
description: 'The transaction info',
params: [
{
name: 'uxt',
type: 'Extrinsic'
},
{
name: 'len',
type: 'u32'
}
],
// NOTE: Since we detect the Weight type based on the runtime, we can have the same
// result for V1 & V2 (additionally, the v2 API came a bit later, so we don't want
// to fix this to V1 weights, since _some_ chains may be incorrect)
type: 'RuntimeDispatchInfo'
}
};
@@ -53,41 +36,87 @@ const V1_V2_SHARED_CALL: Record<string, DefinitionCall> = {
}
],
type: 'FeeDetails'
},
query_call_info: {
description: 'The call info',
params: [
{
name: 'call',
type: 'Call'
},
{
name: 'len',
type: 'u32'
}
],
type: 'RuntimeDispatchInfo'
}
};
export const runtime: DefinitionsCall = {
TransactionPaymentApi: [
{
methods: objectSpread({}, V1_V2_SHARED_PAY),
methods: objectSpread({
query_info: {
description: 'The transaction info',
params: [
{
name: 'uxt',
type: 'Extrinsic'
},
{
name: 'len',
type: 'u32'
}
],
type: 'RuntimeDispatchInfo'
}
}, V1_V2_SHARED_PAY),
version: 2
},
{
methods: objectSpread({}, V1_V2_SHARED_PAY),
methods: objectSpread({
query_info: {
description: 'The transaction info',
params: [
{
name: 'uxt',
type: 'Extrinsic'
},
{
name: 'len',
type: 'u32'
}
],
type: 'RuntimeDispatchInfoV1'
}
}, V1_V2_SHARED_PAY),
version: 1
}
],
TransactionPaymentCallApi: [
{
methods: objectSpread({}, V1_V2_SHARED_CALL),
methods: objectSpread({
query_call_info: {
description: 'The call info',
params: [
{
name: 'call',
type: 'Call'
},
{
name: 'len',
type: 'u32'
}
],
type: 'RuntimeDispatchInfo'
}
}, V1_V2_SHARED_CALL),
version: 2
},
{
methods: objectSpread({}, V1_V2_SHARED_CALL),
methods: objectSpread({
query_call_info: {
description: 'The call info',
params: [
{
name: 'call',
type: 'Call'
},
{
name: 'len',
type: 'u32'
}
],
type: 'RuntimeDispatchInfoV1'
}
}, V1_V2_SHARED_CALL),
version: 1
}
]
@@ -2,7 +2,7 @@
/* eslint-disable */
import type { Option, Struct } from '@polkadot/types-codec';
import type { Balance, Weight } from '@polkadot/types/interfaces/runtime';
import type { Balance, Weight, WeightV1 } from '@polkadot/types/interfaces/runtime';
import type { DispatchClass } from '@polkadot/types/interfaces/system';
/** @name FeeDetails */
@@ -24,4 +24,11 @@ export interface RuntimeDispatchInfo extends Struct {
readonly partialFee: Balance;
}
/** @name RuntimeDispatchInfoV1 */
export interface RuntimeDispatchInfoV1 extends Struct {
readonly weight: WeightV1;
readonly class: DispatchClass;
readonly partialFee: Balance;
}
export type PHANTOM_PAYMENT = 'payment';