Adjust xcm version mapping utility (#4081)
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
# CHANGELOG
|
||||
|
||||
## master
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix browser bundle imports for xcm-mapping (move to `types-known`)
|
||||
|
||||
|
||||
## 6.4.2 Oct 18, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for Westmint runtime 500+
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
"@babel/core": "^7.15.8",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/dev": "^0.63.3",
|
||||
"@polkadot/dev": "^0.63.5",
|
||||
"@polkadot/ts": "^0.4.9",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^27.0.2",
|
||||
|
||||
@@ -16,6 +16,7 @@ import upgrades from './upgrades';
|
||||
|
||||
export { knownOrigins } from './knownOrigins';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { mapXcmTypes } from './xcm';
|
||||
|
||||
// flatten a VersionedType[] into a Record<string, string>
|
||||
/** @internal */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
import { mapXcm } from '@polkadot/types/interfaces/xcm/definitions';
|
||||
import { mapXcmTypes } from '../xcm';
|
||||
|
||||
const sharedTypes = {
|
||||
CompactAssignments: 'CompactAssignmentsWith24',
|
||||
@@ -196,7 +196,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [9010, 9099],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V0')
|
||||
...mapXcmTypes('V0')
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -204,7 +204,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [9100, 9105],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V1')
|
||||
...mapXcmTypes('V1')
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
import { mapXcm } from '@polkadot/types/interfaces/xcm/definitions';
|
||||
import { mapXcmTypes } from '../xcm';
|
||||
|
||||
// structs need to be in order
|
||||
/* eslint-disable sort-keys */
|
||||
@@ -43,14 +43,14 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [229, 9099],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V0')
|
||||
...mapXcmTypes('V0')
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [9100, 9105],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V1')
|
||||
...mapXcmTypes('V1')
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
import { mapXcm } from '@polkadot/types/interfaces/xcm/definitions';
|
||||
import { mapXcmTypes } from '../xcm';
|
||||
|
||||
const sharedTypes = {
|
||||
TAssetBalance: 'u128',
|
||||
@@ -28,14 +28,14 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [0, 3],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V0')
|
||||
...mapXcmTypes('V0')
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [4, 5],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V1')
|
||||
...mapXcmTypes('V1')
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
import { mapXcm } from '@polkadot/types/interfaces/xcm/definitions';
|
||||
import { mapXcmTypes } from '../xcm';
|
||||
|
||||
const sharedTypes = {
|
||||
// 16 validators
|
||||
@@ -94,14 +94,14 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [50, 9099],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V0')
|
||||
...mapXcmTypes('V0')
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [9100, 9105],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
...mapXcm('V1')
|
||||
...mapXcmTypes('V1')
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/types-known authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions', 'MultiAsset', 'MultiAssetFilter', 'MultiLocation', 'Response', 'WildFungibility', 'WildMultiAsset', 'Xcm', 'XcmError', 'XcmOrder'];
|
||||
|
||||
export function mapXcmTypes (version: 'V0' | 'V1' | 'V2'): Record<string, string> {
|
||||
return XCM_MAPPINGS.reduce<Record<string, string>>((all, key) => ({
|
||||
...all,
|
||||
[key]: `${key}${version}`
|
||||
}), {});
|
||||
}
|
||||
@@ -6,21 +6,14 @@
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
import { mapXcmTypes } from '@polkadot/types-known';
|
||||
|
||||
import { v0 } from './v0';
|
||||
import { v1 } from './v1';
|
||||
import { v2 } from './v2';
|
||||
|
||||
export const XCM_MAPPINGS = ['AssetInstance', 'Fungibility', 'Junction', 'Junctions', 'MultiAsset', 'MultiAssetFilter', 'MultiLocation', 'Response', 'WildFungibility', 'WildMultiAsset', 'Xcm', 'XcmError', 'XcmOrder'];
|
||||
|
||||
const XCM_LATEST = 'V2';
|
||||
|
||||
export function mapXcm (version: 'V0' | 'V1' | 'V2'): Record<string, string> {
|
||||
return XCM_MAPPINGS.reduce<Record<string, string>>((all, key) => ({
|
||||
...all,
|
||||
[key]: `${key}${version}`
|
||||
}), {});
|
||||
}
|
||||
|
||||
const xcm = {
|
||||
XcmOrigin: {
|
||||
_enum: {
|
||||
@@ -94,7 +87,7 @@ export default {
|
||||
...v0,
|
||||
...v1,
|
||||
...v2,
|
||||
...mapXcm(XCM_LATEST),
|
||||
...mapXcmTypes(XCM_LATEST),
|
||||
DoubleEncodedCall: {
|
||||
encoded: 'Vec<u8>'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user