internal static UpdateFileParams UpdateParameters(UpdateFileParams updateParameters)
 {
     if (updateParameters is null)
     {
         throw new ArgumentNullException(nameof(updateParameters), "File Update Parameters argument is missing. Please check that it is not null.");
     }
     if (updateParameters.File is null)
     {
         throw new ArgumentNullException(nameof(updateParameters.File), "File identifier is missing. Please check that it is not null.");
     }
     if (updateParameters.Endorsements is null &&
         updateParameters.Contents is null)
     {
         throw new ArgumentException(nameof(updateParameters), "The File Update parameters contain no update properties, it is blank.");
     }
     return(updateParameters);
 }
예제 #2
0
 protected async Task HandleValidSubmit()
 {
     _output = null;
     await _network.ExecuteAsync(_input.Gateway, _input.Payer, async client =>
     {
         var updateParams = new UpdateFileParams
         {
             File = _input.File
         };
         if (_input.UpdateAdministrators)
         {
             updateParams.Endorsements = _input.Administrators == null ? Array.Empty <Endorsement>() : _input.Administrators;
         }
         if (_input.UpdateContents)
         {
             updateParams.Contents = _input.Contents;
         }
         _output = await client.UpdateFileAsync(updateParams, ctx => ctx.Memo = _input.Memo?.Trim());
     });
 }
예제 #3
0
 /// <summary>
 /// Updates the properties or contents of an existing file stored in the network.
 /// </summary>
 /// <param name="updateParameters">
 /// Update parameters indicating the file to update and what properties such
 /// as the access key or content that should be updated.
 /// </param>
 /// <param name="configure">
 /// Optional callback method providing an opportunity to modify
 /// the execution configuration for just this method call.
 /// It is executed prior to submitting the request to the network.
 /// </param>
 /// <returns>
 /// A transaction record describing the details of the operation
 /// including fees and transaction hash.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">If required arguments are missing.</exception>
 /// <exception cref="InvalidOperationException">If required context configuration is missing.</exception>
 /// <exception cref="PrecheckException">If the gateway node create rejected the request upon submission.</exception>
 /// <exception cref="ConsensusException">If the network was unable to come to consensus before the duration of the transaction expired.</exception>
 /// <exception cref="TransactionException">If the network rejected the create request as invalid or had missing data.</exception>
 public async Task <TransactionRecord> UpdateFileWithRecordAsync(UpdateFileParams updateParameters, Action <IContext>?configure = null)
 {
     return(new TransactionRecord(await ExecuteTransactionAsync(new FileUpdateTransactionBody(updateParameters), configure, true, updateParameters.Signatory).ConfigureAwait(false)));
 }