// creates and returns a History object by calling Eth functions GetFileAddressGivenId // and GetNumberOfReceipts, which are used to loop a series of calls to // GetReceiptAddressAtIndex, GetVerificationDateTime, and GetVerifiedBy public async Task <History> GetHistory(string registryAddress, string fileId) { History history = new History(); // get address of file contract with corresponding fileid string fileAddress = await GetFileAddressGivenId.SendRequestAsync(MyWeb3, registryAddress, fileId); // call number of receipts function on file contract int numReceipts = await GetNumberOfReceipts.SendRequestAsync(MyWeb3, fileAddress); // for each receipt for (int i = 0; i < numReceipts; ++i) { // get receipt address at index string receiptAddress = await GetReceiptAddressAtIndex.SendRequestAsync(MyWeb3, fileAddress, i); // get datetime string dateTime = await GetVerificationDateTime.SendRequestAsync(MyWeb3, receiptAddress); // get state of receipt string state = StateConvert.IntToString(await GetState.SendRequestAsync(MyWeb3, receiptAddress)); // get user that created receipt string verifiedBy = await GetVerifiedBy.SendRequestAsync(MyWeb3, receiptAddress); // add values to History object history.AddLine(dateTime, state, verifiedBy); } return(history); }
// returns state private async Task <int> NewReceiptPrivate(string registryAddress, string fileId, string fileHash, string metadataHash, string verifiedBy) { // deploy new receipt contract to blockchain string receiptAddress = await DeployReceipt.SendRequestAsync(MyWeb3, registryAddress, fileId, fileHash, metadataHash, verifiedBy); // get state of receipt return(await GetState.SendRequestAsync(MyWeb3, receiptAddress)); }