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

Function extend

src/commitdb.ts:30–72  ·  view source on GitHub ↗
(commitEventIndex, commitSummary, blockchainName)

Source from the content-addressed store, hash-verified

28}
29
30async function extend(commitEventIndex, commitSummary, blockchainName) {
31 const blockNumber = commitSummary.blockNumber ;
32 const transactionHash = commitSummary.transactionHash;
33 const commitObject = commitSummary.commit;
34 const commit = JSON.stringify(commitObject);
35
36 const author = await ipfs.cidToJsonString(commitObject.author);
37 const authorWalletAddress = JSON.parse(author).wallet;
38 const committer = await ipfs.cidToJsonString(commitObject.committer);
39 const committerWalletAddress = JSON.parse(committer).wallet;
40 const provider = await ipfs.cidToJsonString(commitObject.provider);
41 const action = await ipfs.cidToJsonString(commitObject.action);
42 const commitCreatedIsoTime = util.timestampToIsoString(commitObject.timestampCreated);
43 const assetTree = await ipfs.cidToJsonString(commitObject.assetTreeCid);
44 const assetTreeObject = JSON.parse(assetTree);
45 const assetCid = assetTreeObject.assetCid;
46 const license = await ipfs.cidToJsonString(assetTreeObject.provider);
47 const integrity = await ipfs.cidToJsonString(assetTreeObject.integrityCid);
48 const assetCreatedIsoTime = util.timestampToIsoString(assetTreeObject.assetTimestampCreated);
49 const blockchain = blockchainName;
50
51 const extendedCommit: ExtendedCommit = {
52 "commitEventIndex": commitEventIndex,
53 "blockNumber": blockNumber,
54 "transactionHash": transactionHash,
55 "commit": commit,
56 "author": author,
57 "authorWalletAddress": authorWalletAddress,
58 "committer": committer,
59 "committerWalletAddress": committerWalletAddress,
60 "provider": provider,
61 "action": action,
62 "commitCreatedIsoTime": commitCreatedIsoTime,
63 "assetTree": assetTree,
64 "assetCid": assetCid,
65 "license": license,
66 "integrity": integrity,
67 "assetCreatedIsoTime": assetCreatedIsoTime,
68 "blockchain": blockchain,
69 };
70
71 return extendedCommit;
72}
73
74export async function extendCommits(assetCid, blockchainInfo, fromIndex, toIndex) {
75 const commitEvents = await nit.iterateCommitEvents(assetCid, blockchainInfo, fromIndex, toIndex);

Callers 1

extendCommitsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected