Implement xcm payment api (#5911)

* implement xcm payment api

* lint

* merge

* refactor
This commit is contained in:
girazoki
2024-06-28 10:31:55 -04:00
committed by GitHub
parent aafd0a90c7
commit dda0c3b980
8 changed files with 98 additions and 1 deletions
@@ -74,6 +74,7 @@ import type { ClassDetails, ClassId, ClassMetadata, DepositBalance, DepositBalan
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
import type { AssetInstance, AssetInstanceV0, AssetInstanceV1, AssetInstanceV2, BodyId, BodyPart, DoubleEncodedCall, Fungibility, FungibilityV0, FungibilityV1, FungibilityV2, InboundStatus, InstructionV2, InteriorMultiLocation, Junction, JunctionV0, JunctionV1, JunctionV2, Junctions, JunctionsV1, JunctionsV2, MultiAsset, MultiAssetFilter, MultiAssetFilterV1, MultiAssetFilterV2, MultiAssetV0, MultiAssetV1, MultiAssetV2, MultiAssets, MultiAssetsV1, MultiAssetsV2, MultiLocation, MultiLocationV0, MultiLocationV1, MultiLocationV2, NetworkId, OriginKindV0, OriginKindV1, OriginKindV2, OutboundStatus, Outcome, QueryId, QueryStatus, QueueConfigData, Response, ResponseV0, ResponseV1, ResponseV2, ResponseV2Error, ResponseV2Result, VersionMigrationStage, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WeightLimitV2, WildFungibility, WildFungibilityV0, WildFungibilityV1, WildFungibilityV2, WildMultiAsset, WildMultiAssetV1, WildMultiAssetV2, Xcm, XcmAssetId, XcmError, XcmErrorV0, XcmErrorV1, XcmErrorV2, XcmOrder, XcmOrderV0, XcmOrderV1, XcmOrderV2, XcmOrigin, XcmOriginKind, XcmV0, XcmV1, XcmV2, XcmVersion, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
import type { XcmPaymentApiError } from '@polkadot/types/interfaces/xcmPaymentApi';
import type { Error } from '@polkadot/types/interfaces/xcmRuntimeApi';
declare module '@polkadot/types/types/registry' {
@@ -1249,6 +1250,7 @@ declare module '@polkadot/types/types/registry' {
XcmOrderV2: XcmOrderV2;
XcmOrigin: XcmOrigin;
XcmOriginKind: XcmOriginKind;
XcmPaymentApiError: XcmPaymentApiError;
XcmpMessageFormat: XcmpMessageFormat;
XcmV0: XcmV0;
XcmV1: XcmV1;
@@ -122,7 +122,7 @@ describe('runtime definitions', (): void => {
for (const { methods, version } of versions) {
describe(`version ${version}`, (): void => {
const methodsEntries = Object.entries<DefinitionCall>(methods);
const skipInspectTypes = ['StagingXcmV3MultiLocation', 'StagingXcmV4Location', 'Result<Vec<XcmV3MultiAsset>, FungiblesAccessError>', 'Result<XcmVersionedMultiAssets, FungiblesAccessError>', 'XcmVersionedLocation'];
const skipInspectTypes = ['StagingXcmV3MultiLocation', 'StagingXcmV4Location', 'Result<Vec<XcmV3MultiAsset>, FungiblesAccessError>', 'Result<XcmVersionedMultiAssets, FungiblesAccessError>', 'XcmVersionedLocation', 'XcmVersionedAssetId', 'XcmVersionedXcm', 'Result<Vec<XcmVersionedAssetId>, XcmPaymentApiError>'];
for (const [key, { params, type }] of methodsEntries) {
describe(`${key}`, (): void => {
@@ -67,6 +67,7 @@ export { default as purchase } from './purchase/definitions.js';
// XCM related types
export { default as xcm } from './xcm/definitions.js';
export { default as xcmPaymentApi } from './xcmPaymentApi/definitions.js';
export { default as xcmRuntimeApi } from './xcmRuntimeApi/definitions.js';
// other useful types
+1
View File
@@ -75,4 +75,5 @@ export * from './uniques/types.js';
export * from './utility/types.js';
export * from './vesting/types.js';
export * from './xcm/types.js';
export * from './xcmPaymentApi/types.js';
export * from './xcmRuntimeApi/types.js';
@@ -0,0 +1,25 @@
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { Definitions } from '../../types/index.js';
import { runtime } from './runtime.js';
export default {
rpc: {},
runtime,
types: {
XcmPaymentApiError: {
_enum: [
'Unimplemented',
'VersionedConversionFailed',
'WeightNotComputable',
'UnhandledXcmVersion',
'AssetNotFound'
]
}
}
} as Definitions;
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
export * from './types.js';
@@ -0,0 +1,48 @@
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall } from '../../types/index.js';
export const runtime: DefinitionsCall = {
XcmPaymentApi: [
{
methods: {
query_acceptable_payment_assets: {
description: 'The API to query acceptable payment assets',
params: [
{
name: 'version',
type: 'u32'
}
],
type: 'Result<Vec<XcmVersionedAssetId>, XcmPaymentApiError>'
},
query_weight_to_asset_fee: {
description: '',
params: [
{
name: 'weight',
type: 'WeightV2'
},
{
name: 'asset',
type: 'XcmVersionedAssetId'
}
],
type: 'Result<u128, XcmPaymentApiError>'
},
query_xcm_weight: {
description: '',
params: [
{
name: 'message',
type: 'XcmVersionedXcm'
}
],
type: 'Result<WeightV2, XcmPaymentApiError>'
}
},
version: 1
}
]
};
@@ -0,0 +1,16 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Enum } from '@polkadot/types-codec';
/** @name XcmPaymentApiError */
export interface XcmPaymentApiError extends Enum {
readonly isUnimplemented: boolean;
readonly isVersionedConversionFailed: boolean;
readonly isWeightNotComputable: boolean;
readonly isUnhandledXcmVersion: boolean;
readonly isAssetNotFound: boolean;
readonly type: 'Unimplemented' | 'VersionedConversionFailed' | 'WeightNotComputable' | 'UnhandledXcmVersion' | 'AssetNotFound';
}
export type PHANTOM_XCMPAYMENTAPI = 'xcmPaymentApi';