/// <summary> /// Internal implementation of the update Topic functionality. /// </summary> private async Task <TResult> UpdateTopicImplementationAsync <TResult>(UpdateTopicParams updateParameters, Action <IContext>?configure) where TResult : new() { updateParameters = RequireInputParameter.UpdateParameters(updateParameters); await using var context = CreateChildContext(configure); RequireInContext.Gateway(context); var payer = RequireInContext.Payer(context); var signatory = Transactions.GatherSignatories(context, updateParameters.Signatory); var updateTopicBody = new ConsensusUpdateTopicTransactionBody { TopicID = Protobuf.ToTopicID(updateParameters.Topic) }; if (updateParameters.Memo != null) { updateTopicBody.Memo = updateParameters.Memo; } if (!(updateParameters.Administrator is null)) { updateTopicBody.AdminKey = Protobuf.ToPublicKey(updateParameters.Administrator); } if (!(updateParameters.Participant is null)) { updateTopicBody.SubmitKey = Protobuf.ToPublicKey(updateParameters.Participant); } if (updateParameters.RenewPeriod.HasValue) { updateTopicBody.AutoRenewPeriod = Protobuf.ToDuration(updateParameters.RenewPeriod.Value); } if (!(updateParameters.RenewAccount is null)) { updateTopicBody.AutoRenewAccount = Protobuf.ToAccountID(updateParameters.RenewAccount); } var transactionId = Transactions.GetOrCreateTransactionID(context); var transactionBody = Transactions.CreateTransactionBody(context, transactionId); transactionBody.ConsensusUpdateTopic = updateTopicBody; var request = await Transactions.SignTransactionAsync(transactionBody, signatory); var precheck = await Transactions.ExecuteSignedRequestWithRetryAsync(context, request, getRequestMethod, getResponseCode); ValidateResult.PreCheck(transactionId, precheck); var receipt = await GetReceiptAsync(context, transactionId); if (receipt.Status != ResponseCodeEnum.Success) { throw new TransactionException($"Unable to update Topic, status: {receipt.Status}", Protobuf.FromTransactionId(transactionId), (ResponseCode)receipt.Status); } var result = new TResult(); if (result is TransactionRecord arec) { var record = await GetTransactionRecordAsync(context, transactionId); Protobuf.FillRecordProperties(record, arec); } else if (result is TransactionReceipt arcpt) { Protobuf.FillReceiptProperties(transactionId, receipt, arcpt); } return(result);
/// <summary> /// Internal implementation of the update Topic functionality. /// </summary> private async Task <TResult> UpdateTopicImplementationAsync <TResult>(UpdateTopicParams updateParameters, Action <IContext>?configure) where TResult : new() { updateParameters = RequireInputParameter.UpdateParameters(updateParameters); await using var context = CreateChildContext(configure); RequireInContext.Gateway(context); var payer = RequireInContext.Payer(context); var signatory = Transactions.GatherSignatories(context, updateParameters.Signatory); var updateTopicBody = new ConsensusUpdateTopicTransactionBody { TopicID = new TopicID(updateParameters.Topic) }; if (updateParameters.Memo != null) { updateTopicBody.Memo = updateParameters.Memo; } if (!(updateParameters.Administrator is null)) { updateTopicBody.AdminKey = new Key(updateParameters.Administrator); } if (!(updateParameters.Participant is null)) { updateTopicBody.SubmitKey = new Key(updateParameters.Participant); } if (updateParameters.RenewPeriod.HasValue) { updateTopicBody.AutoRenewPeriod = new Duration(updateParameters.RenewPeriod.Value); } if (!(updateParameters.RenewAccount is null)) { updateTopicBody.AutoRenewAccount = new AccountID(updateParameters.RenewAccount); } var transactionId = Transactions.GetOrCreateTransactionID(context); var transactionBody = new TransactionBody(context, transactionId); transactionBody.ConsensusUpdateTopic = updateTopicBody; var receipt = await transactionBody.SignAndExecuteWithRetryAsync(signatory, context); if (receipt.Status != ResponseCodeEnum.Success) { throw new TransactionException($"Unable to update Topic, status: {receipt.Status}", transactionId.ToTxId(), (ResponseCode)receipt.Status); } var result = new TResult(); if (result is TransactionRecord rec) { var record = await GetTransactionRecordAsync(context, transactionId); record.FillProperties(rec); } else if (result is TransactionReceipt rcpt) { receipt.FillProperties(transactionId, rcpt); } return(result); }