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

com.hedera.hapi.node.contract.schema.ContractDeleteTransactionBodySchema Maven / Gradle / Ivy

package com.hedera.hapi.node.contract.schema;

import com.hedera.pbj.runtime.FieldDefinition;
import com.hedera.pbj.runtime.FieldType;
import com.hedera.pbj.runtime.Schema;

import com.hedera.hapi.node.base.*;
import com.hedera.pbj.runtime.*;


/**
 * Schema for ContractDeleteTransactionBody model object. Generate based on protobuf schema.
 */
public final class ContractDeleteTransactionBodySchema implements Schema {

    // -- FIELD DEFINITIONS ---------------------------------------------

    /**
     * (1) The id of the contract to be deleted
     */
    public static final FieldDefinition CONTRACT_ID = new FieldDefinition("contractID", FieldType.MESSAGE, false, false, false, 1);


    /**
     * (2) The id of an account to receive any remaining hBars from the deleted contract
     */
    public static final FieldDefinition TRANSFER_ACCOUNT_ID = new FieldDefinition("transferAccountID", FieldType.MESSAGE, false, false, true, 2);

    /**
     * (3) The id of a contract to receive any remaining hBars from the deleted contract
     */
    public static final FieldDefinition TRANSFER_CONTRACT_ID = new FieldDefinition("transferContractID", FieldType.MESSAGE, false, false, true, 3);


    /**
     * (4) If set to true, means this is a "synthetic" system transaction being used to 
     * alert mirror nodes that the contract is being permanently removed from the ledger.
     * IMPORTANT: User transactions cannot set this field to true, as permanent
     * removal is always managed by the ledger itself. Any ContractDeleteTransactionBody
     * submitted to HAPI with permanent_removal=true will be rejected with precheck status
     * PERMANENT_REMOVAL_REQUIRES_SYSTEM_INITIATION.
     */
    public static final FieldDefinition PERMANENT_REMOVAL = new FieldDefinition("permanent_removal", FieldType.BOOL, false, false, false, 4);


    // -- OTHER METHODS -------------------------------------------------

    /**
     * Check if a field definition belongs to this schema.
     *
     * @param f field def to check
     * @return true if it belongs to this schema
     */
    public static boolean valid(FieldDefinition f) {
    	return f != null && getField(f.number()) == f;
    }

	/**
	 * Get a field definition given a field number
	 *
	 * @param fieldNumber the fields number to get def for
	 * @return field def or null if field number does not exist
	 */
	public static FieldDefinition getField(final int fieldNumber) {
	    return switch(fieldNumber) {
	        case 1 -> CONTRACT_ID;
            case 2 -> TRANSFER_ACCOUNT_ID;
            case 3 -> TRANSFER_CONTRACT_ID;
            case 4 -> PERMANENT_REMOVAL;
	        default -> null;
	    };
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy