Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"@substrate/dev": "^0.9.0",
"@types/argparse": "2.0.17",
"@types/express": "^5.0.5",
"@types/express-serve-static-core": "^5.0.6",
"@types/express-serve-static-core": "^5.1.1",
"@types/http-errors": "2.0.5",
"@types/lru-cache": "^7.10.10",
"@types/morgan": "1.9.10",
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/blocks/BlocksExtrinsicsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class BlocksExtrinsicsController extends AbstractController<Block
/**
* Verify our param `extrinsicIndex` is an integer represented as a string
*/
this.parseNumberOrThrow(extrinsicIndex, '`exstrinsicIndex` path param is not a number');
this.parseNumberOrThrow(extrinsicIndex, '`extrinsicIndex` path param is not a number');

/**
* Change extrinsicIndex from a type string to a number before passing it
Expand Down Expand Up @@ -153,7 +153,7 @@ export default class BlocksExtrinsicsController extends AbstractController<Block
/**
* Verify our param `extrinsicIndex` is an integer represented as a string
*/
this.parseNumberOrThrow(extrinsicIndex, '`exstrinsicIndex` path param is not a number');
this.parseNumberOrThrow(extrinsicIndex, '`extrinsicIndex` path param is not a number');

/**
* Change extrinsicIndex from a type string to a number before passing it
Expand Down
14 changes: 9 additions & 5 deletions src/controllers/blocks/BlocksTraceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { RequestHandler } from 'express-serve-static-core';
import { RequestHandler } from 'express';

import { validateBoolean } from '../../middleware';
import { BlocksTraceService } from '../../services';
import type { INumberParam } from '../../types/requests';
import AbstractController from '../AbstractController';
import BlocksController from './BlocksController';

Expand All @@ -39,27 +40,30 @@ export default class BlocksTraceController extends AbstractController<BlocksTrac
]);
}

private getLatestBlockTraces: RequestHandler = async (_req, res): Promise<void> => {
private getLatestBlockTraces: RequestHandler<INumberParam> = async (_req, res): Promise<void> => {
const hash = await this.api.rpc.chain.getFinalizedHead();

BlocksController.sanitizedSend(res, await this.service.traces(hash));
};

private getBlockTraces: RequestHandler = async ({ params: { number } }, res): Promise<void> => {
private getBlockTraces: RequestHandler<INumberParam> = async ({ params: { number } }, res): Promise<void> => {
const hash = await this.getHashForBlock(number);

BlocksController.sanitizedSend(res, await this.service.traces(hash));
};

private getLatestBlockOperations: RequestHandler = async ({ query: { actions } }, res): Promise<void> => {
private getLatestBlockOperations: RequestHandler<INumberParam> = async (
{ query: { actions } },
res,
): Promise<void> => {
const hash = await this.api.rpc.chain.getFinalizedHead();
const includeActions = actions === 'true';
const historicApi = await this.api.at(hash);

BlocksController.sanitizedSend(res, await this.service.operations(hash, historicApi, includeActions));
};

private getBlockOperations: RequestHandler = async (
private getBlockOperations: RequestHandler<INumberParam> = async (
{ params: { number }, query: { actions } },
res,
): Promise<void> => {
Expand Down
4 changes: 2 additions & 2 deletions src/services/blocks/BlocksService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ describe('BlocksService', () => {

it('Throw an error when param `extrinsicIndex` is less than 0', () => {
expect(() => {
parseNumberOrThrow('-5', '`exstrinsicIndex` path param is not a number');
}).toThrow(new BadRequest('`exstrinsicIndex` path param is not a number'));
parseNumberOrThrow('-5', '`extrinsicIndex` path param is not a number');
}).toThrow(new BadRequest('`extrinsicIndex` path param is not a number'));
});
});

Expand Down
16 changes: 14 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ __metadata:
"@substrate/dev": "npm:^0.9.0"
"@types/argparse": "npm:2.0.17"
"@types/express": "npm:^5.0.5"
"@types/express-serve-static-core": "npm:^5.0.6"
"@types/express-serve-static-core": "npm:^5.1.1"
"@types/http-errors": "npm:2.0.5"
"@types/lru-cache": "npm:^7.10.10"
"@types/morgan": "npm:1.9.10"
Expand Down Expand Up @@ -2708,7 +2708,7 @@ __metadata:
languageName: node
linkType: hard

"@types/express-serve-static-core@npm:^5.0.0, @types/express-serve-static-core@npm:^5.0.6":
"@types/express-serve-static-core@npm:^5.0.0":
version: 5.0.6
resolution: "@types/express-serve-static-core@npm:5.0.6"
dependencies:
Expand All @@ -2720,6 +2720,18 @@ __metadata:
languageName: node
linkType: hard

"@types/express-serve-static-core@npm:^5.1.1":
version: 5.1.1
resolution: "@types/express-serve-static-core@npm:5.1.1"
dependencies:
"@types/node": "npm:*"
"@types/qs": "npm:*"
"@types/range-parser": "npm:*"
"@types/send": "npm:*"
checksum: 10/7f3d8cf7e68764c9f3e8f6a12825b69ccf5287347fc1c20b29803d4f08a4abc1153ae11d7258852c61aad50f62ef72d4c1b9c97092b0a90462c3dddec2f6026c
languageName: node
linkType: hard

"@types/express@npm:^5.0.5":
version: 5.0.5
resolution: "@types/express@npm:5.0.5"
Expand Down
Loading