Update GQL and getBlock API usage (#210)

* Update getLogs and getBlockWithTransactions usage to add block number arg

* Update getFullTransaction usage to add block number arg
This commit is contained in:
prathamesh0
2022-11-03 14:14:58 +05:30
committed by GitHub
parent 52c42f4e84
commit 2517f110ea
12 changed files with 35 additions and 26 deletions
+4 -3
View File
@@ -273,7 +273,7 @@ export class Indexer {
return [blockProgress, events];
}
async fetchEvents (blockHash: string, parseEventNameAndArgs: (kind: string, logObj: any) => any): Promise<DeepPartial<EventInterface>[]> {
async fetchEvents (blockHash: string, blockNumber: number, parseEventNameAndArgs: (kind: string, logObj: any) => any): Promise<DeepPartial<EventInterface>[]> {
let logsPromise: Promise<any>;
if (this._serverConfig.filterLogs) {
@@ -284,13 +284,14 @@ export class Indexer {
logsPromise = this._ethClient.getLogs({
blockHash,
blockNumber: blockNumber.toString(),
addresses
});
} else {
logsPromise = this._ethClient.getLogs({ blockHash });
logsPromise = this._ethClient.getLogs({ blockHash, blockNumber: blockNumber.toString() });
}
const transactionsPromise = this._ethClient.getBlockWithTransactions({ blockHash });
const transactionsPromise = this._ethClient.getBlockWithTransactions({ blockHash, blockNumber });
const [
{ logs },
+2 -2
View File
@@ -220,10 +220,10 @@ export const getFullBlock = async (ethClient: EthClient, ethProvider: providers.
};
};
export const getFullTransaction = async (ethClient: EthClient, txHash: string): Promise<any> => {
export const getFullTransaction = async (ethClient: EthClient, txHash: string, blockNumber: number): Promise<any> => {
const {
ethTransactionCidByTxHash: fullTx
} = await ethClient.getFullTransaction(txHash);
} = await ethClient.getFullTransaction(txHash, blockNumber);
assert(fullTx.blockByMhKey);