Skip to content

Commit

Permalink
fix(dev): updates substrate-js-dev, and fixes latest eslint rules (#913)
Browse files Browse the repository at this point in the history
* fix(deps): update substrate-js-dev

* fix no-unsafe-argument for specToControllers

* ignore no-unsafe-argument for nodeUtils transformer

* cleanup unsafe usage of optional chaining

* fix unsafe argument of type GenericCall<any> with safe typecasting

* fix This number literal will lose precision at runtime

* fix tsc issue with scripts
  • Loading branch information
TarikGul committed May 18, 2022
1 parent 6baf526 commit 12c5914
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 391 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test:init-e2e-tests:statemine": "yarn test:init-e2e-tests --chain statemine",
"test:init-e2e-tests:statemint": "yarn test:init-e2e-tests --chain statemint",
"start:e2e-scripts": "yarn build:scripts && node scripts/build/runChainTests.js",
"build:scripts": "substrate-exec-rimraf scripts/build/ && cd scripts && substrate-exec-tsc",
"build:scripts": "substrate-exec-rimraf scripts/build/ && substrate-exec-tsc --project scripts/tsconfig.json",
"lint:scripts": "cd scripts && substrate-dev-run-lint",
"start:test-release": "yarn build:scripts && node scripts/build/runYarnPack.js",
"test:test-release": "yarn start:test-release",
Expand All @@ -68,7 +68,7 @@
"winston": "^3.3.3"
},
"devDependencies": {
"@substrate/dev": "^0.6.0",
"@substrate/dev": "^0.6.1",
"@types/argparse": "2.0.10",
"@types/express": "4.17.13",
"@types/express-serve-static-core": "4.17.25",
Expand Down
2 changes: 1 addition & 1 deletion src/chains-config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { statemineControllers } from './statemineControllers';
import { statemintControllers } from './statemintControllers';
import { westendControllers } from './westendControllers';

const specToControllerMap = {
const specToControllerMap: { [x: string]: ControllerConfig } = {
westend: westendControllers,
polkadot: polkadotControllers,
polymesh: polymeshControllers,
Expand Down
1 change: 1 addition & 0 deletions src/logging/transformers/nodeUtilFormat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const nodeUtilFormat = winston.format(
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const args = info[SPLAT as unknown as string];
if (args) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
info.message = format(info.message, ...args);
}
return info;
Expand Down
6 changes: 3 additions & 3 deletions src/services/accounts/AccountsStakingPayoutsService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ describe('AccountsStakingPayoutsService', () => {
derivedExposure
);
expect(sanitizeNumbers(res)).toStrictEqual({
nominatorExposure: '33223051661066608',
totalExposure: '33223251661066608',
nominatorExposure: '33223051661066606',
totalExposure: '33223251661066606',
});
});

Expand All @@ -206,7 +206,7 @@ describe('AccountsStakingPayoutsService', () => {
);
expect(sanitizeNumbers(res)).toStrictEqual({
nominatorExposure: '200000000000',
totalExposure: '33223251661066608',
totalExposure: '33223251661066606',
});
});

Expand Down
9 changes: 6 additions & 3 deletions src/services/blocks/BlocksService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ export class BlocksService extends AbstractService {

let weightValue;
if (system.blockWeights?.perClass) {
const { normal, operational, mandatory } = system.blockWeights?.perClass;
const { normal, operational, mandatory } = system.blockWeights.perClass;

const perClass = {
normal: {
Expand Down Expand Up @@ -684,7 +684,7 @@ export class BlocksService extends AbstractService {
): (Codec | ISanitizedCall)[] {
return argsArray.map((argument) => {
if (argument instanceof GenericCall) {
return this.parseGenericCall(argument, registry);
return this.parseGenericCall(argument as GenericCall, registry);
}

return argument;
Expand Down Expand Up @@ -717,7 +717,10 @@ export class BlocksService extends AbstractService {
if (Array.isArray(argument)) {
newArgs[paramName] = this.parseArrayGenericCalls(argument, registry);
} else if (argument instanceof GenericCall) {
newArgs[paramName] = this.parseGenericCall(argument, registry);
newArgs[paramName] = this.parseGenericCall(
argument as GenericCall,
registry
);
} else if (
argument &&
paramName === 'call' &&
Expand Down
8 changes: 5 additions & 3 deletions src/services/test-helpers/mock/accounts/deriveValidators.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import BN from 'bn.js';

import { polkadotRegistryV9122 } from '../../../../test-helpers/registries';

const value = polkadotRegistryV9122.createType(
'Compact<u128>',
BigInt(33223051661066606)
new BN('33223051661066606')
);

export const mockDeriveValidatorExposure = {
'12JZr1HgK8w6zsbBj6oAEVRkvisn8j3MrkXugqtvc4E8uwLo': {
total: polkadotRegistryV9122.createType(
'Compact<u128>',
BigInt(33223251661066606)
new BN('33223251661066606')
),
own: polkadotRegistryV9122.createType('Compact<u128>', 200000000000),
others: [
Expand All @@ -22,7 +24,7 @@ export const mockDeriveValidatorExposure = {
'1HDgY7vpDjafR5NM8dbwm1b3Rrs4zATuSCHHbe7YgpKUKFw': {
total: polkadotRegistryV9122.createType(
'Compact<u128>',
BigInt(33223061661066606)
new BN('33223061661066606')
),
own: polkadotRegistryV9122.createType('Compact<u128>', 10000000000),
others: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
"payouts": [
{
"claimed": false,
"nominatorExposure": "33223051661066608",
"nominatorExposure": "33223051661066606",
"nominatorStakingPayout": "8335838960366",
"totalValidatorExposure": "33223251661066608",
"totalValidatorExposure": "33223251661066606",
"totalValidatorRewardPoints": "3360",
"validatorCommission": "10000000",
"validatorId": "12JZr1HgK8w6zsbBj6oAEVRkvisn8j3MrkXugqtvc4E8uwLo"
},
{
"claimed": false,
"nominatorExposure": "33223051661066608",
"nominatorExposure": "33223051661066606",
"nominatorStakingPayout": "11015277392614",
"totalValidatorExposure": "33223061661066608",
"totalValidatorExposure": "33223061661066606",
"totalValidatorRewardPoints": "4440",
"validatorCommission": "10000000",
"validatorId": "1HDgY7vpDjafR5NM8dbwm1b3Rrs4zATuSCHHbe7YgpKUKFw"
Expand Down
Loading

0 comments on commit 12c5914

Please sign in to comment.