(assetCid: string, blockchainInfo)
| 528 | * Query events on Ethereum. The performance is faster than eventLogIteratingQuery. |
| 529 | */ |
| 530 | async function eventLogRangeQuery(assetCid: string, blockchainInfo) { |
| 531 | console.log(`Commit logs of assetCid: ${assetCid}`); |
| 532 | |
| 533 | const commitBlockNumbers = await getCommitBlockNumbers(assetCid, blockchainInfo); |
| 534 | const commitAmount = commitBlockNumbers.length; |
| 535 | console.log(`Commit block numbers (${commitBlockNumbers.length}):`); |
| 536 | if (commitAmount > 0) { |
| 537 | console.log(`${JSON.stringify(commitBlockNumbers)}`); |
| 538 | } else { |
| 539 | return; |
| 540 | } |
| 541 | |
| 542 | // Get events |
| 543 | const filter = await blockchainInfo.contract.filters.Commit(null, assetCid); |
| 544 | filter.fromBlock = commitBlockNumbers[0]; |
| 545 | filter.toBlock = commitBlockNumbers[commitAmount - 1]; |
| 546 | let events = await blockchainInfo.contract.queryFilter(filter, filter.fromBlock, filter.toBlock); |
| 547 | const commitDataIndex = 2; |
| 548 | for (const event of events) { |
| 549 | console.log(`\nBlock ${event.blockNumber}`); |
| 550 | console.log(`${blockchainInfo.explorerBaseUrl}/${event.transactionHash}`) |
| 551 | console.log(`Commit: ${JSON.stringify(JSON.parse(event.args![commitDataIndex]), null, 2)}`); |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | /* TODO: Remove this function in the next feature release. |
| 556 | */ |
nothing calls this directly
no test coverage detected