internal static CreateFileParams CreateParameters(CreateFileParams createParameters)
 {
     if (createParameters is null)
     {
         throw new ArgumentNullException(nameof(createParameters), "The create parameters are missing. Please check that the argument is not null.");
     }
     if (createParameters.Endorsements is null)
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Endorsements), "Endorsements are required.");
     }
     return(createParameters);
 }
Example #2
0
 protected async Task HandleValidSubmit()
 {
     _output = null;
     await _network.ExecuteAsync(_input.Gateway, _input.Payer, async client =>
     {
         var createParams = new CreateFileParams
         {
             Expiration   = DateTime.UtcNow.AddSeconds(7890000), // Default enforced by network at the moment
             Endorsements = _input.Endorsements != null ? _input.Endorsements : Array.Empty <Endorsement>(),
             Contents     = _input.Content
         };
         _output = await client.CreateFileAsync(createParams, ctx => ctx.Memo = _input.Memo?.Trim());
     });
 }
Example #3
0
 /// <summary>
 /// Creates a new file with the given content.
 /// </summary>
 /// <param name="createParameters">
 /// File creation parameters specifying contents and ownership of the file.
 /// </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 with a description of the newly created file &amp; fees.
 /// and record information.
 /// </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 <FileRecord> CreateFileWithRecordAsync(CreateFileParams createParameters, Action <IContext>?configure = null)
 {
     return(new FileRecord(await ExecuteTransactionAsync(new FileCreateTransactionBody(createParameters), configure, true, createParameters.Signatory).ConfigureAwait(false)));
 }