Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul committed Oct 25, 2023
1 parent 24a5ed3 commit 0f8fedf
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/createXcmTypes/SystemToSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -20,6 +21,8 @@ import {
UnionXcmMultiAssets,
UnionXcmMultiLocation,
XcmBase,
XcmV2Junctions,
XcmV3Junctions,
} from './types';
import { dedupeMultiAssets } from './util/dedupeMultiAssets';
import { fetchPalletInstanceId } from './util/fetchPalletInstanceId';
Expand Down Expand Up @@ -275,7 +278,7 @@ export const createSystemToSystemMultiAssets = async (
concreteMultiLocation = resolveMultiLocation(
{
parents: assetIdMultiLocation.parents,
interior: JSON.parse(interiorMultiLocationStr),
interior: JSON.parse(interiorMultiLocationStr) as RequireOnlyOne<XcmV3Junctions | XcmV2Junctions>,
},
xcmVersion
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
6 changes: 4 additions & 2 deletions src/createXcmTypes/util/sortMultiAssetsAscending.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/util/getFeeAssetItemIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/sanitizeKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const sanitizeKeys = <T extends AnyObj>(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();
};

0 comments on commit 0f8fedf

Please sign in to comment.