internal ContractUpdateTransactionBody(UpdateContractParams updateParameters) : this() { if (updateParameters is null) { throw new ArgumentNullException(nameof(updateParameters), "Contract Update Parameters argument is missing. Please check that it is not null."); } if (updateParameters.Contract is null) { throw new ArgumentNullException(nameof(updateParameters.Contract), "Contract address is missing. Please check that it is not null."); } if (updateParameters.Expiration is null && updateParameters.Administrator is null && updateParameters.RenewPeriod is null && updateParameters.Memo is null) { throw new ArgumentException("The Contract Updates contains no update properties, it is blank.", nameof(updateParameters)); } ContractID = new ContractID(updateParameters.Contract); if (updateParameters.Expiration.HasValue) { ExpirationTime = new Timestamp(updateParameters.Expiration.Value); } if (!(updateParameters.Administrator is null)) { AdminKey = new Key(updateParameters.Administrator); } if (updateParameters.RenewPeriod.HasValue) { AutoRenewPeriod = new Duration(updateParameters.RenewPeriod.Value); } if (!string.IsNullOrWhiteSpace(updateParameters.Memo)) { MemoWrapper = updateParameters.Memo; } }
internal static UpdateContractParams UpdateParameters(UpdateContractParams updateParameters) { { if (updateParameters is null) { throw new ArgumentNullException(nameof(updateParameters), "Contract Update Parameters argument is missing. Please check that it is not null."); } if (updateParameters.Contract is null) { throw new ArgumentNullException(nameof(updateParameters.Contract), "Contract address is missing. Please check that it is not null."); } if (updateParameters.Expiration is null && updateParameters.Administrator is null && updateParameters.RenewPeriod is null && updateParameters.File is null && updateParameters.Memo is null) { throw new ArgumentException("The Contract Updates contains no update properties, it is blank.", nameof(updateParameters)); } return(updateParameters); } }
/// <summary> /// Updates the changeable properties of a hedera network Contract. /// </summary> /// <param name="updateParameters"> /// The Contract update parameters, includes a required /// <see cref="Address"/> reference to the Contract to update plus /// a number of changeable properties of the Contract. /// </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 containing the details of the results. /// of the request. /// </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> UpdateContractWithRecordAsync(UpdateContractParams updateParameters, Action <IContext>?configure = null) { return(new TransactionRecord(await ExecuteTransactionAsync(new ContractUpdateTransactionBody(updateParameters), configure, true, updateParameters.Signatory).ConfigureAwait(false))); }