protected async Task HandleValidSubmit() { _output = null; await _network.ExecuteAsync(_input.Gateway, _input.Payer, async client => { var createParams = new CreateTopicParams { Memo = _input.Desciption?.Trim(), Administrator = _input.Administrator != Endorsement.None ? _input.Administrator : null, Participant = _input.Participant != Endorsement.None ? _input.Participant : null, RenewAccount = _input.RenewAccount != Address.None ? _input.RenewAccount : null }; _output = await client.CreateTopicAsync(createParams, ctx => ctx.Memo = _input.Memo?.Trim()); }); }
internal static CreateTopicParams CreateParameters(CreateTopicParams 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.Memo is null) { throw new ArgumentNullException(nameof(createParameters.Memo), "Memo can not be null."); } if (!(createParameters.RenewAccount is null) && createParameters.Administrator is null) { throw new ArgumentNullException(nameof(createParameters.Administrator), "The Administrator endorssement must not be null if RenewAccount is specified."); } if (createParameters.RenewPeriod.Ticks < 0) { throw new ArgumentOutOfRangeException(nameof(createParameters.RenewPeriod), "The renew period must be greater than zero, and typically less than or equal to 90 days."); } return(createParameters); }
internal ConsensusCreateTopicTransactionBody(CreateTopicParams createParameters) : this() { if (createParameters is null) { throw new ArgumentNullException(nameof(createParameters), "The create parameters are missing. Please check that the argument is not null."); } if (createParameters.Memo is null) { throw new ArgumentNullException(nameof(createParameters.Memo), "Memo can not be null."); } if (!(createParameters.RenewAccount is null) && createParameters.Administrator is null) { throw new ArgumentNullException(nameof(createParameters.Administrator), "The Administrator endorssement must not be null if RenewAccount is specified."); } if (createParameters.RenewPeriod.Ticks < 0) { throw new ArgumentOutOfRangeException(nameof(createParameters.RenewPeriod), "The renew period must be greater than zero, and typically less than or equal to 90 days."); } Memo = createParameters.Memo; AdminKey = createParameters.Administrator is null ? null : new Key(createParameters.Administrator); SubmitKey = createParameters.Participant is null ? null : new Key(createParameters.Participant); AutoRenewPeriod = new Duration(createParameters.RenewPeriod); AutoRenewAccount = createParameters.RenewAccount is null ? null : new AccountID(createParameters.RenewAccount); }
/// <summary> /// Creates a new topic instance with the given create parameters. /// </summary> /// <param name="createParameters"> /// Details regarding the topic 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 topic. /// </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 <CreateTopicRecord> CreateTopicWithRecordAsync(CreateTopicParams createParameters, Action <IContext>?configure = null) { return(new CreateTopicRecord(await ExecuteTransactionAsync(new ConsensusCreateTopicTransactionBody(createParameters), configure, true, createParameters.Signatory).ConfigureAwait(false))); }