Skip to content

Commit

Permalink
chore(deps): update substrate dev package & types
Browse files Browse the repository at this point in the history
  • Loading branch information
Imod7 committed Oct 1, 2024
1 parent 6aac632 commit 90328e5
Show file tree
Hide file tree
Showing 24 changed files with 400 additions and 621 deletions.
4 changes: 2 additions & 2 deletions e2e-tests/historical/types/responses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -114,4 +114,4 @@ export interface IRuntimeCode {
/**
* Response for `/runtime/code`
*/
export type IRuntimeMetadata = Object;
export type IRuntimeMetadata = object;
1 change: 0 additions & 1 deletion e2e-tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"baseUrl": ".",
"outDir": "build",
"rootDirs": ["./historical", "./helpers", "./latest"],
"suppressImplicitAnyIndexErrors": true,
"ignoreDeprecations": "5.0",
"resolveJsonModule": true,
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"winston-loki": "^6.1.2"
},
"devDependencies": {
"@substrate/dev": "^0.7.1",
"@substrate/dev": "^0.8.0",
"@types/argparse": "2.0.16",
"@types/express": "^4.17.21",
"@types/express-serve-static-core": "^4.19.5",
Expand Down
1 change: 0 additions & 1 deletion scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "build",
"suppressImplicitAnyIndexErrors": true,
"ignoreDeprecations": "5.0",
"resolveJsonModule": true,
},
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/accounts/AccountsBalanceInfoController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -81,7 +81,7 @@ export default class AccountsBalanceController extends AbstractController<Accoun
typeof token === 'string'
? token.toUpperCase()
: // We assume the first token is the native token
this.api.registry.chainTokens[0].toUpperCase();
this.api.registry.chainTokens[0].toUpperCase();
const withDenomination = denominated === 'true';

const hash = await this.getHashFromAt(at);
Expand Down
9 changes: 6 additions & 3 deletions src/logging/consoleOverride.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -33,10 +33,13 @@ export function consoleOverride(logger: Logger): void {
['error', 'error'],
['debug', 'debug'],
].forEach(([consoleLevel, winstonLevel]) => {
console[consoleLevel] = function (...args: unknown[]) {
(console[consoleLevel as keyof Console] as (...args: unknown[]) => void) = function (...args: unknown[]) {
// We typecast here because the typescript compiler is not sure what we are keying into.
// The type within the logger of any of the following log levels is `LeveledLogMethod`.
(logger[winstonLevel] as LeveledLogMethod).call<Logger, string[], Logger>(logger, format.apply(format, args));
(logger[winstonLevel as keyof Logger] as LeveledLogMethod).call<Logger, string[], Logger>(
logger,
format.apply(format, args),
);
};
});
}
4 changes: 2 additions & 2 deletions src/logging/transformers/stripAnsi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -52,7 +52,7 @@ function stripAnsiShellCodes(data: unknown): unknown {
}

if (typeof data === 'object' && data !== null) {
const sanitizedData = {};
const sanitizedData: { [key: string]: unknown } = {};
for (const [k, v] of Object.entries(data)) {
sanitizedData[k] = stripAnsiShellCodes(v);
}
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/validate/validateBooleanMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -28,7 +28,7 @@ export const validateBooleanMiddleware = (queryParams: string[]): RequestHandler

for (const key of queryParams) {
if (req.query[key]) {
const queryParamVal = typeof req.query[key] === 'string' ? (req.query[key] as string).toLowerCase() : '';
const queryParamVal = typeof req.query[key] === 'string' ? req.query[key].toLowerCase() : '';
if (!(queryParamVal === 'true' || queryParamVal === 'false')) {
errQueryParams.push(`Query parameter: ${key} has an invalid boolean value of ${req.query[key] as string}`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/accounts/AccountsAssetsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -196,7 +196,7 @@ export class AccountsAssetsService extends AbstractService {

// 3. The older legacy type of `PalletAssetsAssetBalance` has a key of `isSufficient` instead
// of `sufficient`.
if (assetBalance['isSufficient'] as bool) {
if ((assetBalance as unknown as LegacyPalletAssetsAssetBalance).isSufficient) {
const balanceProps = assetBalance as unknown as LegacyPalletAssetsAssetBalance;

return {
Expand Down
4 changes: 2 additions & 2 deletions src/services/accounts/AccountsBalanceInfoService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -42,7 +42,7 @@ const accountAt = (_address: string) =>
),
);

const accountDataAt = (_address: String) =>
const accountDataAt = (_address: string) =>
Promise.resolve().then(() => {
return {
data: polkadotRegistryV9370.createType('AccountData', {
Expand Down
4 changes: 2 additions & 2 deletions src/services/accounts/AccountsPoolAssetsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -201,7 +201,7 @@ export class AccountsPoolAssetsService extends AbstractService {

// 3. The older legacy type of `PalletAssetsAssetBalance` has a key of `isSufficient` instead
// of `sufficient`.
if (assetBalance['isSufficient'] as bool) {
if ((assetBalance as unknown as LegacyPalletPoolAssetsAssetBalance).isSufficient) {
const balanceProps = assetBalance as unknown as LegacyPalletPoolAssetsAssetBalance;

return {
Expand Down
11 changes: 6 additions & 5 deletions src/services/accounts/AccountsStakingPayoutsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import type {
DeriveEraNominatorExposure,
DeriveEraValidatorExposure,
} from '@polkadot/api-derive/staking/types';
import { Compact, Option, StorageKey, u32, u128 } from '@polkadot/types';
import { Compact, Linkage, Option, StorageKey, u32, u128 } from '@polkadot/types';
import { Vec } from '@polkadot/types';
import type {
AccountId,
Expand All @@ -32,6 +32,7 @@ import type {
Perbill,
StakingLedger,
StakingLedgerTo240,
ValidatorPrefs,
ValidatorPrefsWithCommission,
} from '@polkadot/types/interfaces';
import type {
Expand Down Expand Up @@ -514,7 +515,7 @@ export class AccountsStakingPayoutsService extends AbstractService {
commission = prefs.commission.unwrap();
} else {
prefs = (await historicApi.query.staking.validators(validatorId)) as ValidatorPrefsWithCommission;
commission = (prefs[0] as PalletStakingValidatorPrefs | ValidatorPrefsWithCommission).commission.unwrap();
commission = (prefs as unknown as [ValidatorPrefs, Linkage<AccountId>])[0].commission.unwrap();
}
} else {
commissionPromise =
Expand All @@ -529,7 +530,7 @@ export class AccountsStakingPayoutsService extends AbstractService {

commission =
ancient && isKusama
? (prefs[0] as PalletStakingValidatorPrefs | ValidatorPrefsWithCommission).commission.unwrap()
? (prefs as unknown as [ValidatorPrefs, Linkage<AccountId>])[0].commission.unwrap()
: prefs.commission.unwrap();

if (validatorControllerOption.isNone) {
Expand Down Expand Up @@ -597,8 +598,8 @@ export class AccountsStakingPayoutsService extends AbstractService {
const individualExposure = exposure.others
? exposure.others
: (exposure as unknown as Option<SpStakingExposurePage>).isSome
? (exposure as unknown as Option<SpStakingExposurePage>).unwrap().others
: [];
? (exposure as unknown as Option<SpStakingExposurePage>).unwrap().others
: [];
individualExposure.forEach(({ who }, validatorIndex): void => {
const nominatorId = who.toString();

Expand Down
2 changes: 1 addition & 1 deletion src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const mockApi = {
/**
* For type casting mock getBlock functions so tsc does not complain
*/
type GetBlock = PromiseRpcResult<(hash?: string | BlockHash | Uint8Array | undefined) => Promise<SignedBlock>>;
type GetBlock = PromiseRpcResult<(hash?: string | BlockHash | Uint8Array) => Promise<SignedBlock>>;

// Block Service
const blocksService = new BlocksService(mockApi, 0, new QueryFeeDetailsCache(null, null));
Expand Down
10 changes: 5 additions & 5 deletions src/services/blocks/trace/Trace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -336,11 +336,11 @@ export class Trace {

phase = secondarySpans[0]
? // This case catches `onInitialize` spans since they are the secondary
// spans of `initBlock`
stringCamelCase(secondarySpans[0]?.name)
// spans of `initBlock`
stringCamelCase(secondarySpans[0]?.name)
: // This case catches `onFinalize` since `onFinalize` spans are
// identified by the priamry spans name.
stringCamelCase(primary.name);
// identified by the priamry spans name.
stringCamelCase(primary.name);
}

const primarySpanEvents = eventsByParentId.get(primary.id);
Expand Down
9 changes: 5 additions & 4 deletions src/services/node/NodeTransactionPoolService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -97,9 +97,10 @@ export class NodeTransactionPoolService extends AbstractService {
const sanitizedClass = this.defineDispatchClassType(dispatchClass);

// Check which versions of Weight we are using by checking to see if refTime exists.
const versionedWeight = weight['refTime']
? (weight as unknown as WeightV2).refTime.unwrap().toBn()
: (weight as WeightV1).toBn();
const versionedWeight =
(weight as unknown as WeightV2)?.refTime != undefined
? (weight as unknown as WeightV2).refTime.unwrap().toBn()
: (weight as WeightV1).toBn();
const maxBlockWeight = api.consts.system.blockWeights.maxBlock.refTime
? api.consts.system.blockWeights.maxBlock.refTime.unwrap()
: (api.consts.system.blockWeights.maxBlock as unknown as u64);
Expand Down
7 changes: 4 additions & 3 deletions src/services/pallets/PalletsDispatchablesService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -49,11 +49,12 @@ export class PalletsDispatchablesService extends AbstractPalletsService {
palletMeta,
dispatchableItemId,
metadataFieldType,
) as FunctionMetadataLatest;
) as unknown as [string, FunctionMetadataLatest];

let palletDispatchableMetadata: FunctionMetadataLatest | undefined;
if (metadata) {
palletDispatchableMetadata = (dispatchableItemMetadata[1] as SubmittableExtrinsicFunction<ApiTypes>).meta;
palletDispatchableMetadata = (dispatchableItemMetadata[1] as unknown as SubmittableExtrinsicFunction<ApiTypes>)
.meta;
}

const { number } = await this.api.rpc.chain.getHeader(hash);
Expand Down
6 changes: 3 additions & 3 deletions src/services/pallets/PalletsErrorsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -50,11 +50,11 @@ export class PalletsErrorsService extends AbstractPalletsService {
palletMeta,
errorItemId,
metadataFieldType,
) as ErrorMetadataLatest;
) as unknown as [string, ErrorMetadataLatest];

let palletErrorMetadata: ErrorMetadataLatest | undefined;
if (metadata) {
palletErrorMetadata = (errorItemMetadata[1] as IsError).meta;
palletErrorMetadata = (errorItemMetadata[1] as unknown as IsError).meta;
}

const { number } = await this.api.rpc.chain.getHeader(hash);
Expand Down
6 changes: 3 additions & 3 deletions src/services/pallets/PalletsEventsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2023 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -51,11 +51,11 @@ export class PalletsEventsService extends AbstractPalletsService {
palletMeta,
eventItemId,
metadataFieldType,
) as EventMetadataLatest;
) as unknown as [string, EventMetadataLatest];

let palletEventMetadata: EventMetadataLatest | undefined;
if (metadata) {
palletEventMetadata = (eventItemMetadata[1] as IsEvent<AnyTuple>).meta;
palletEventMetadata = (eventItemMetadata[1] as unknown as IsEvent<AnyTuple>).meta;
}

const { number } = await this.api.rpc.chain.getHeader(hash);
Expand Down
6 changes: 4 additions & 2 deletions src/services/pallets/PalletsForeignAssetsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ApiPromise } from '@polkadot/api';
import { Option } from '@polkadot/types';
import { AssetMetadata, BlockHash } from '@polkadot/types/interfaces';
import { PalletAssetsAssetDetails } from '@polkadot/types/lookup';
import { PalletAssetsAssetDetails, StagingXcmV3MultiLocation } from '@polkadot/types/lookup';

import { IForeignAssetInfo, IForeignAssets } from '../../types/responses';
import { AbstractService } from '../AbstractService';
Expand Down Expand Up @@ -51,7 +51,9 @@ export class PalletsForeignAssetsService extends AbstractService {
* https://github.com/paritytech/asset-transfer-api-registry/blob/main/src/createRegistry.ts#L193-L238
*/
for (const [assetStorageKeyData, assetInfo] of foreignAssetInfo) {
const foreignAssetData = assetStorageKeyData.toHuman();
const foreignAssetData: [StagingXcmV3MultiLocation] = assetStorageKeyData.toHuman() as unknown as [
StagingXcmV3MultiLocation,
];

if (foreignAssetData) {
// remove any commas from multilocation key values e.g. Parachain: 2,125 -> Parachain: 2125
Expand Down
6 changes: 3 additions & 3 deletions src/services/pallets/PalletsNominationPoolsService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -59,12 +59,12 @@ export class PalletsNominationPoolService extends AbstractService {
bondedPool,
rewardPool,
metadata,
}
}
: {
at,
bondedPool,
rewardPool,
};
};

return response;
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/pallets/PalletsStakingProgressService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2017-2022 Parity Technologies (UK) Ltd.
// Copyright 2017-2024 Parity Technologies (UK) Ltd.
// This file is part of Substrate API Sidecar.
//
// Substrate API Sidecar is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -107,7 +107,7 @@ export class PalletsStakingProgressService extends AbstractService {
? {
status: eraElectionStatus.toJSON(),
toggleEstimate: toggle?.toString(10) ?? null,
}
}
: 'Deprecated, see docs',
idealValidatorCount: validatorCount.toString(10),
validatorSet: validators.map((accountId) => accountId.toString()),
Expand Down
4 changes: 2 additions & 2 deletions src/services/test-helpers/mock/data/referendaEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const referendaEntries = () => {
? null
: polkadotRegistryV1000001.createType('Balance', decisionDeposit.amount),
who: polkadotRegistryV1000001.createType('AccountId', decisionDeposit.who),
};
};
const decidingVal =
deciding === null
? null
Expand All @@ -51,7 +51,7 @@ export const referendaEntries = () => {
? null
: polkadotRegistryV1000001.createType('Compact<BlockNumber>', deciding.confirming),
since: polkadotRegistryV1000001.createType('Compact<BlockNumber>', deciding.since),
};
};

const onGoingRefInfo = {
ongoing: {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"baseUrl": ".",
"outDir": "build",
"rootDirs": ["./src", "./e2e-tests", "./scripts"],
"suppressImplicitAnyIndexErrors": true,
"ignoreDeprecations": "5.0",
"resolveJsonModule": true,
},
Expand Down
Loading

0 comments on commit 90328e5

Please sign in to comment.