Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit b3361f9

Browse files
author
Andres Adjimann
committed
fix eth_getBlockTransactionCountByHash to work with forks
1 parent 274d552 commit b3361f9

File tree

1 file changed

+6
-8
lines changed
  • src/chains/ethereum/ethereum/src

1 file changed

+6
-8
lines changed

src/chains/ethereum/ethereum/src/api.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,14 +1266,12 @@ export default class EthereumApi implements Api {
12661266
@assertArgLength(1)
12671267
async eth_getBlockTransactionCountByHash(hash: DATA) {
12681268
const { blocks } = this.#blockchain;
1269-
const blockNum = await blocks.getNumberFromHash(hash);
1270-
if (!blockNum) return null;
1271-
1272-
const rawBlock = await blocks.getRawByBlockNumber(Quantity.from(blockNum));
1273-
if (!rawBlock) return null;
1274-
1275-
const [, rawTransactions] = decode<GanacheRawBlock>(rawBlock);
1276-
return Quantity.from(rawTransactions.length);
1269+
const block = await blocks
1270+
.getByHash(hash)
1271+
.catch<Block>(_ => null);
1272+
if (!block) return null;
1273+
const transactions = block.getTransactions();
1274+
return Quantity.from(transactions.length);
12771275
}
12781276

12791277
/**

0 commit comments

Comments
 (0)