diff --git a/src/createXcmTypes/SystemToSystem.ts b/src/createXcmTypes/SystemToSystem.ts index 731f9f2b..8b6c4645 100644 --- a/src/createXcmTypes/SystemToSystem.ts +++ b/src/createXcmTypes/SystemToSystem.ts @@ -6,6 +6,7 @@ import type { WeightLimitV2 } from '@polkadot/types/interfaces'; import { BaseError, BaseErrorsEnum } from '../errors'; import type { Registry } from '../registry'; +import { RequireOnlyOne } from '../types'; import { getFeeAssetItemIndex } from '../util/getFeeAssetItemIndex'; import { normalizeArrToStr } from '../util/normalizeArrToStr'; import { resolveMultiLocation } from '../util/resolveMultiLocation'; @@ -20,6 +21,8 @@ import { UnionXcmMultiAssets, UnionXcmMultiLocation, XcmBase, + XcmV2Junctions, + XcmV3Junctions, } from './types'; import { dedupeMultiAssets } from './util/dedupeMultiAssets'; import { fetchPalletInstanceId } from './util/fetchPalletInstanceId'; @@ -275,7 +278,7 @@ export const createSystemToSystemMultiAssets = async ( concreteMultiLocation = resolveMultiLocation( { parents: assetIdMultiLocation.parents, - interior: JSON.parse(interiorMultiLocationStr), + interior: JSON.parse(interiorMultiLocationStr) as RequireOnlyOne, }, xcmVersion ); diff --git a/src/createXcmTypes/util/constructForeignAssetMultiLocationFromAssetId.ts b/src/createXcmTypes/util/constructForeignAssetMultiLocationFromAssetId.ts index c3deb5c7..31ff6806 100644 --- a/src/createXcmTypes/util/constructForeignAssetMultiLocationFromAssetId.ts +++ b/src/createXcmTypes/util/constructForeignAssetMultiLocationFromAssetId.ts @@ -36,8 +36,8 @@ export const constructForeignAssetMultiLocationFromAssetId = ( const palletInstanceJunctionStr = `{"PalletInstance":"${foreignAssetsPalletInstance}"},`; const interiorMultiLocationStr = `{${numberOfJunctions}:[${palletInstanceJunctionStr}${junctions}]}`; const multiLocation = { - // TODO: keying into any xcm field should be standardized to all caps. - parents: assetIdMultiLocation['Parents'] || assetIdMultiLocation['parents'], + // Since sanitizeKeys is run in resolveMultiLocation Parents will always be capitalized + parents: assetIdMultiLocation['Parents'] as string | number, interior: JSON.parse(interiorMultiLocationStr) as AnyJson, }; diff --git a/src/createXcmTypes/util/sortMultiAssetsAscending.ts b/src/createXcmTypes/util/sortMultiAssetsAscending.ts index cc1188fa..fa1041dd 100644 --- a/src/createXcmTypes/util/sortMultiAssetsAscending.ts +++ b/src/createXcmTypes/util/sortMultiAssetsAscending.ts @@ -1,5 +1,7 @@ // Copyright 2023 Parity Technologies (UK) Ltd. +/* eslint-disable @typescript-eslint/no-non-null-assertion */ +/* eslint-disable no-case-declarations */ import { stringToHex } from '@polkadot/util'; import { BN } from 'bn.js'; @@ -32,8 +34,8 @@ export const sortMultiAssetsAscending = (multiAssets: FungibleStrMultiAsset[] | ); } - const aParents = a.id.Concrete.parents || a.id.Concrete['Parents']; - const bParents = b.id.Concrete.parents || b.id.Concrete['Parents']; + const aParents = (a.id.Concrete.parents || a.id.Concrete['Parents']) as string | number; + const bParents = (b.id.Concrete.parents || b.id.Concrete['Parents']) as string | number; if (aParents < bParents) { parentSortOrder = -1; } else if (aParents > bParents) { diff --git a/src/util/getFeeAssetItemIndex.ts b/src/util/getFeeAssetItemIndex.ts index 6ffc042e..3001d600 100644 --- a/src/util/getFeeAssetItemIndex.ts +++ b/src/util/getFeeAssetItemIndex.ts @@ -98,9 +98,9 @@ export const getFeeAssetItemIndex = async ( if (result === -1) { throw new BaseError( - `Invalid paysWithFeeDest value. ${paysWithFeeDest} did not match any asset in assets: ${multiAssets.map((asset) => - JSON.stringify(asset.id.Concrete.interior) - )}`, + `Invalid paysWithFeeDest value. ${paysWithFeeDest} did not match any asset in assets: ${multiAssets + .map((asset) => JSON.stringify(asset.id.Concrete.interior)) + .join(',')}`, BaseErrorsEnum.InvalidInput ); } diff --git a/src/util/sanitizeKeys.ts b/src/util/sanitizeKeys.ts index 898ad096..8e4802aa 100644 --- a/src/util/sanitizeKeys.ts +++ b/src/util/sanitizeKeys.ts @@ -43,7 +43,7 @@ export const sanitizeKeys = (xcmObj: T): T => { const mapKey = (key: string): string => { const lowerKey = key.toLowerCase(); if (MultiLocationJunctionTypeKeys[lowerKey]) { - return MultiLocationJunctionTypeKeys[lowerKey]; + return MultiLocationJunctionTypeKeys[lowerKey] as string; } return key[0].toUpperCase() + key.slice(1).toLowerCase(); };