internal static CreateContractParams CreateParameters(CreateContractParams 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.File is null)
     {
         throw new ArgumentNullException(nameof(createParameters.File), "The File Address containing the contract is missing, it cannot be null.");
     }
     return(createParameters);
 }
예제 #2
0
 protected async Task HandleValidSubmit()
 {
     _output = null;
     await _network.ExecuteAsync(_input.Gateway, _input.Payer, async client =>
     {
         var createParams = new CreateContractParams
         {
             File           = _input.File,
             Administrator  = _input.Administrator != Endorsement.None ? _input.Administrator : null,
             Gas            = _input.Gas.GetValueOrDefault(),
             RenewPeriod    = TimeSpan.FromSeconds(7890000),
             InitialBalance = _input.InitialBalance.GetValueOrDefault(),
             Arguments      = _input.Arguments.ToArray()
         };
         _output = await client.CreateContractAsync(createParams, ctx => ctx.Memo = _input.Memo?.Trim());
     });
 }
예제 #3
0
 /// <summary>
 /// Creates a new contract instance with the given create parameters
 /// returning a detailed record.
 /// </summary>
 /// <param name="createParameters">
 /// Details regarding the contract to instantiate.
 /// </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 contract.
 /// and receipt 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 <CreateContractRecord> CreateContractWithRecordAsync(CreateContractParams createParameters, Action <IContext>?configure = null)
 {
     return(new CreateContractRecord(await ExecuteTransactionAsync(new ContractCreateTransactionBody(createParameters), configure, true, createParameters.Signatory).ConfigureAwait(false)));
 }