Add transaction-payment runtime API V3 (#5430)
* Add transaction-payment runtime API V3 * Apply suggestions from code review * Update packages/types/src/interfaces/payment/runtime.ts * Update packages/types/src/interfaces/payment/runtime.ts * Apply suggestions from code review * Handle query_info vs query_call_info correctly Co-authored-by: Jaco <jacogr@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import type { DefinitionCall, DefinitionsCall } from '../../types';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
const V1_V2_SHARED_PAY: Record<string, DefinitionCall> = {
|
||||
const V1_V2_V3_SHARED_PAY: Record<string, DefinitionCall> = {
|
||||
query_fee_details: {
|
||||
description: 'The transaction fee details',
|
||||
params: [
|
||||
@@ -22,7 +22,7 @@ const V1_V2_SHARED_PAY: Record<string, DefinitionCall> = {
|
||||
}
|
||||
};
|
||||
|
||||
const V1_V2_SHARED_CALL: Record<string, DefinitionCall> = {
|
||||
const V1_V2_V3_SHARED_CALL: Record<string, DefinitionCall> = {
|
||||
query_call_fee_details: {
|
||||
description: 'The call fee details',
|
||||
params: [
|
||||
@@ -39,25 +39,84 @@ const V1_V2_SHARED_CALL: Record<string, DefinitionCall> = {
|
||||
}
|
||||
};
|
||||
|
||||
const V2_V3_SHARED_QUERY_INFO: Record<string, DefinitionCall> = {
|
||||
query_info: {
|
||||
description: 'The call info',
|
||||
params: [
|
||||
{
|
||||
name: 'call',
|
||||
type: 'Call'
|
||||
},
|
||||
{
|
||||
name: 'len',
|
||||
type: 'u32'
|
||||
}
|
||||
],
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
};
|
||||
|
||||
const V2_V3_SHARED_QUERY_CALL_INFO: Record<string, DefinitionCall> = {
|
||||
query_call_info: {
|
||||
description: 'The call info',
|
||||
params: [
|
||||
{
|
||||
name: 'call',
|
||||
type: 'Call'
|
||||
},
|
||||
{
|
||||
name: 'len',
|
||||
type: 'u32'
|
||||
}
|
||||
],
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
};
|
||||
|
||||
const V3_QUERY_WEIGHT_TO_FEE: Record<string, DefinitionCall> = {
|
||||
query_weight_to_fee: {
|
||||
description: 'Query the output of the current WeightToFee given some input',
|
||||
params: [
|
||||
{
|
||||
name: 'weight',
|
||||
type: 'Weight'
|
||||
}
|
||||
],
|
||||
type: 'Balance'
|
||||
}
|
||||
};
|
||||
|
||||
const V3_QUERY_LENGTH_TO_FEE: Record<string, DefinitionCall> = {
|
||||
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({
|
||||
query_info: {
|
||||
description: 'The transaction info',
|
||||
params: [
|
||||
{
|
||||
name: 'uxt',
|
||||
type: 'Extrinsic'
|
||||
},
|
||||
{
|
||||
name: 'len',
|
||||
type: 'u32'
|
||||
}
|
||||
],
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
}, V1_V2_SHARED_PAY),
|
||||
methods: objectSpread(
|
||||
{},
|
||||
V3_QUERY_WEIGHT_TO_FEE,
|
||||
V3_QUERY_LENGTH_TO_FEE,
|
||||
V2_V3_SHARED_QUERY_INFO,
|
||||
V1_V2_V3_SHARED_PAY
|
||||
),
|
||||
version: 3
|
||||
},
|
||||
{
|
||||
methods: objectSpread(
|
||||
{},
|
||||
V2_V3_SHARED_QUERY_INFO,
|
||||
V1_V2_V3_SHARED_PAY
|
||||
),
|
||||
version: 2
|
||||
},
|
||||
{
|
||||
@@ -80,28 +139,27 @@ export const runtime: DefinitionsCall = {
|
||||
// type: 'RuntimeDispatchInfoV1'
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
}, V1_V2_SHARED_PAY),
|
||||
}, V1_V2_V3_SHARED_PAY),
|
||||
version: 1
|
||||
}
|
||||
],
|
||||
TransactionPaymentCallApi: [
|
||||
{
|
||||
methods: objectSpread({
|
||||
query_call_info: {
|
||||
description: 'The call info',
|
||||
params: [
|
||||
{
|
||||
name: 'call',
|
||||
type: 'Call'
|
||||
},
|
||||
{
|
||||
name: 'len',
|
||||
type: 'u32'
|
||||
}
|
||||
],
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
}, V1_V2_SHARED_CALL),
|
||||
methods: objectSpread(
|
||||
{},
|
||||
V3_QUERY_WEIGHT_TO_FEE,
|
||||
V3_QUERY_LENGTH_TO_FEE,
|
||||
V2_V3_SHARED_QUERY_CALL_INFO,
|
||||
V1_V2_V3_SHARED_CALL
|
||||
),
|
||||
version: 3
|
||||
},
|
||||
{
|
||||
methods: objectSpread(
|
||||
{},
|
||||
V2_V3_SHARED_QUERY_CALL_INFO,
|
||||
V1_V2_V3_SHARED_CALL
|
||||
),
|
||||
version: 2
|
||||
},
|
||||
{
|
||||
@@ -122,7 +180,7 @@ export const runtime: DefinitionsCall = {
|
||||
// _may_ yield fallback decoding on some versions of the runtime
|
||||
type: 'RuntimeDispatchInfo'
|
||||
}
|
||||
}, V1_V2_SHARED_CALL),
|
||||
}, V1_V2_V3_SHARED_CALL),
|
||||
version: 1
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user