All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hedera.hashgraph.sdk.ScheduleDeleteTransaction Maven / Gradle / Ivy

The newest version!
/*-
 *
 * Hedera Java SDK
 *
 * Copyright (C) 2020 - 2022 Hedera Hashgraph, LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.hedera.hashgraph.sdk;

import com.google.protobuf.InvalidProtocolBufferException;
import com.hedera.hashgraph.sdk.proto.SchedulableTransactionBody;
import com.hedera.hashgraph.sdk.proto.ScheduleDeleteTransactionBody;
import com.hedera.hashgraph.sdk.proto.ScheduleServiceGrpc;
import com.hedera.hashgraph.sdk.proto.TransactionBody;
import com.hedera.hashgraph.sdk.proto.TransactionResponse;
import io.grpc.MethodDescriptor;

import javax.annotation.Nullable;
import java.util.LinkedHashMap;
import java.util.Objects;

/**
 * Delete a scheduled transaction.
 * 

* See Hedera Documentation */ public final class ScheduleDeleteTransaction extends Transaction { @Nullable private ScheduleId scheduleId = null; /** * Constructor. */ public ScheduleDeleteTransaction() { defaultMaxTransactionFee = new Hbar(5); } /** * Constructor. * * @param txs Compound list of transaction id's list of (AccountId, Transaction) * records * @throws InvalidProtocolBufferException when there is an issue with the protobuf */ ScheduleDeleteTransaction(LinkedHashMap> txs) throws InvalidProtocolBufferException { super(txs); initFromTransactionBody(); } /** * Constructor. * * @param txBody protobuf TransactionBody */ ScheduleDeleteTransaction(com.hedera.hashgraph.sdk.proto.TransactionBody txBody) { super(txBody); initFromTransactionBody(); } /** * Extract the schedule id. * * @return the schedule id */ @Nullable public ScheduleId getScheduleId() { return scheduleId; } /** * Assign the scheduled id. * * @param scheduleId the schedule id * @return {@code this} */ public ScheduleDeleteTransaction setScheduleId(ScheduleId scheduleId) { Objects.requireNonNull(scheduleId); requireNotFrozen(); this.scheduleId = scheduleId; return this; } /** * Initialize from the transaction body. */ void initFromTransactionBody() { var body = sourceTransactionBody.getScheduleDelete(); if (body.hasScheduleID()) { scheduleId = ScheduleId.fromProtobuf(body.getScheduleID()); } } /** * Build the correct transaction body. * * @return {@link com.hedera.hashgraph.sdk.proto.ScheduleDeleteTransactionBody builder } */ ScheduleDeleteTransactionBody.Builder build() { var builder = ScheduleDeleteTransactionBody.newBuilder(); if (scheduleId != null) { builder.setScheduleID(scheduleId.toProtobuf()); } return builder; } @Override void validateChecksums(Client client) throws BadEntityIdException { if (scheduleId != null) { scheduleId.validateChecksum(client); } } @Override MethodDescriptor getMethodDescriptor() { return ScheduleServiceGrpc.getDeleteScheduleMethod(); } @Override void onFreeze(TransactionBody.Builder bodyBuilder) { bodyBuilder.setScheduleDelete(build()); } @Override void onScheduled(SchedulableTransactionBody.Builder scheduled) { scheduled.setScheduleDelete(build()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy