(assetCid: string, blockchainInfo, blockNumber: number)
| 344 | } |
| 345 | |
| 346 | export async function getCommit(assetCid: string, blockchainInfo, blockNumber: number) { |
| 347 | const filter = await blockchainInfo.contract.filters.Commit(null, assetCid); |
| 348 | const abi = [ |
| 349 | "event Commit(address indexed recorder, string indexed assetCid, string commitData)" |
| 350 | ]; |
| 351 | const commitEventInterface = new ethers.utils.Interface(abi); |
| 352 | |
| 353 | let events = []; |
| 354 | |
| 355 | filter.fromBlock = blockNumber; |
| 356 | filter.toBlock = blockNumber; |
| 357 | const eventLogs = await blockchainInfo.provider.getLogs(filter); |
| 358 | |
| 359 | for (const eventLog of eventLogs) { |
| 360 | const commitEvent = commitEventInterface.parseLog(eventLog); |
| 361 | // merge eventLog and commitEvent |
| 362 | events.push(Object.assign({}, eventLog, commitEvent)); |
| 363 | } |
| 364 | |
| 365 | const commits = await getCommits(events); |
| 366 | console.log(`${JSON.stringify(commits[0].commit)}`); |
| 367 | |
| 368 | return commits[0].commit; |
| 369 | //await showCommits(commits); |
| 370 | } |
| 371 | |
| 372 | export async function showCommits(commits) { |
| 373 | commits.map(commit => { |
nothing calls this directly
no test coverage detected