Skip to content

Commit

Permalink
fix(core-api): use getRegisteredHandlers() to get all registered hand…
Browse files Browse the repository at this point in the history
…lers in /node/fees controller (#4046)
  • Loading branch information
air1one authored Sep 18, 2020
1 parent bab1d91 commit a917e08
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/core-api/src/controllers/node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Repositories } from "@arkecosystem/core-database";
import { Container, Contracts, Providers, Services } from "@arkecosystem/core-kernel";
import { Handlers } from "@arkecosystem/core-transactions";
import { Crypto, Managers, Transactions } from "@arkecosystem/crypto";
import { Crypto, Managers } from "@arkecosystem/crypto";
import Hapi from "@hapi/hapi";

import { PortsResource } from "../resources";
Expand Down Expand Up @@ -93,6 +93,14 @@ export class NodeController extends Controller {

public async fees(request: Hapi.Request) {
// @ts-ignore
const handlers = this.nullHandlerRegistry.getRegisteredHandlers();
const handlersKey = {};
for (const handler of handlers) {
handlersKey[
`${handler.getConstructor().type}-${handler.getConstructor().typeGroup}`
] = handler.getConstructor().key;
}

const results = await this.transactionRepository.getFeeStatistics(request.query.days);

const groupedByTypeGroup = {};
Expand All @@ -101,10 +109,9 @@ export class NodeController extends Controller {
groupedByTypeGroup[result.typeGroup] = {};
}

const internalType = Transactions.InternalTransactionType.from(result.type, result.typeGroup);
const handler = this.nullHandlerRegistry.getRegisteredHandlerByType(internalType);
const handlerKey = handlersKey[`${result.type}-${result.typeGroup}`];

groupedByTypeGroup[result.typeGroup][handler.getConstructor().key] = {
groupedByTypeGroup[result.typeGroup][handlerKey] = {
avg: result.avg,
max: result.max,
min: result.min,
Expand Down

0 comments on commit a917e08

Please sign in to comment.