From 142a11e4690a3af7d3e9bf608051db166c7329cd Mon Sep 17 00:00:00 2001 From: gantunesr Date: Wed, 8 Sep 2021 18:11:03 -0300 Subject: [PATCH] fix(TransactionController): Address review comments --- src/transaction/TransactionController.ts | 12 ++++++------ src/util.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/transaction/TransactionController.ts b/src/transaction/TransactionController.ts index 84d2a64779..061b98fdc1 100644 --- a/src/transaction/TransactionController.ts +++ b/src/transaction/TransactionController.ts @@ -1148,7 +1148,7 @@ export class TransactionController extends BaseController< normalizedTxs = this.trimTransactionsForState(normalizedTxs); normalizedTokenTxs = this.trimTransactionsForState(normalizedTokenTxs); - const [updateTxs, allTxs] = this.transactionStateReconciler( + const [updateRequired, allTxs] = this.transactionStateReconciler( [...normalizedTxs, ...normalizedTokenTxs], transactions, StateReconcileMethod.ETHERSCAN, @@ -1193,7 +1193,7 @@ export class TransactionController extends BaseController< }); // Update state only if new transactions were fetched or // the status or gas data of a transaction has changed - if (updateTxs) { + if (updateRequired) { this.update({ transactions: allTxs }); } return latestIncomingTxBlockNumber; @@ -1293,9 +1293,9 @@ export class TransactionController extends BaseController< return txIdx === -1 ? tx : outdatedTxs[txIdx]; }); - const update = newTxs.length > 0 || updatedLocalTxs.length > 0; + const updateRequired = newTxs.length > 0 || updatedLocalTxs.length > 0; - return [update, [...newTxs, ...updatedLocalTxs]]; + return [updateRequired, [...newTxs, ...updatedLocalTxs]]; } /** @@ -1318,8 +1318,8 @@ export class TransactionController extends BaseController< } /** - * Get all the transactions that are locally outdated respect a - * remote source (etherscan or blockchain). The returned array + * Get all the transactions that are locally outdated with respect + * to a remote source (etherscan or blockchain). The returned array * contains the transactions with the updated data. * @param remoteTxs - Array of transactions from remote source * @param localTxs - Array of transactions stored locally diff --git a/src/util.ts b/src/util.ts index 94b9444762..732eaa3b1a 100644 --- a/src/util.ts +++ b/src/util.ts @@ -183,7 +183,7 @@ export async function handleTransactionFetch( networkType: string, address: string, opt?: FetchAllOptions, -): Promise { +): Promise<[{ [result: string]: [] }, { [result: string]: [] }]> { // transactions const urlParams = { module: 'account',