Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transaction-payment runtime API V3 #5430

Merged
merged 6 commits into from
Jan 27, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 73 additions & 36 deletions packages/types/src/interfaces/payment/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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: [
Expand All @@ -39,25 +39,67 @@ const V1_V2_SHARED_CALL: Record<string, DefinitionCall> = {
}
};

const V2_V3_SHARED_QUERY_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: {
jacogr marked this conversation as resolved.
Show resolved Hide resolved
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,
jacogr marked this conversation as resolved.
Show resolved Hide resolved
V1_V2_V3_SHARED_PAY
),
version: 3
},
{
methods: objectSpread(
{},
V2_V3_SHARED_QUERY_INFO,
V1_V2_V3_SHARED_PAY
),
version: 2
},
{
Expand All @@ -80,28 +122,23 @@ 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_INFO,
V1_V2_V3_SHARED_CALL),
jacogr marked this conversation as resolved.
Show resolved Hide resolved
version: 3
},
{
methods: objectSpread(
V2_V3_SHARED_QUERY_INFO,
V1_V2_V3_SHARED_CALL),
jacogr marked this conversation as resolved.
Show resolved Hide resolved
version: 2
},
{
Expand All @@ -122,7 +159,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
}
]
Expand Down