MCPcopy Index your code
hub / github.com/numbersprotocol/nit / getCommit

Function getCommit

src/nit.ts:346–370  ·  view source on GitHub ↗
(assetCid: string, blockchainInfo, blockNumber: number)

Source from the content-addressed store, hash-verified

344}
345
346export 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
372export async function showCommits(commits) {
373 commits.map(commit => {

Callers

nothing calls this directly

Calls 1

getCommitsFunction · 0.85

Tested by

no test coverage detected