Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.hedera.hapi.node.contract;
import com.hedera.hapi.node.base.*;
import com.hedera.pbj.runtime.*;
import com.hedera.pbj.runtime.io.*;
import com.hedera.pbj.runtime.io.buffer.*;
import com.hedera.pbj.runtime.io.stream.*;
import edu.umd.cs.findbugs.annotations.*;
import com.hedera.pbj.runtime.Codec;
import java.util.function.Consumer;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.NonNull;
import static java.util.Objects.requireNonNull;
/**
* EthereumTransactionBody
*
* @param ethereumData (1) The raw Ethereum transaction (RLP encoded type 0, 1, and 2). Complete
* unless the callData field is set.
* @param callData (2) For large transactions (for example contract create) this is the callData
* of the ethereumData. The data in the ethereumData will be re-written with
* the callData element as a zero length string with the original contents in
* the referenced file at time of execution. The ethereumData will need to be
* "rehydrated" with the callData for signature validation to pass.
* @param maxGasAllowance (3) The maximum amount, in tinybars, that the payer of the hedera transaction
* is willing to pay to complete the transaction.
* *
* Ordinarily the account with the ECDSA alias corresponding to the public
* key that is extracted from the ethereum_data signature is responsible for
* fees that result from the execution of the transaction. If that amount of
* authorized fees is not sufficient then the payer of the transaction can be
* charged, up to but not exceeding this amount. If the ethereum_data
* transaction authorized an amount that was insufficient then the payer will
* only be charged the amount needed to make up the difference. If the gas
* price in the transaction was set to zero then the payer will be assessed
* the entire fee.
*/
public record EthereumTransactionBody(
@NonNull Bytes ethereumData,
@Nullable FileID callData,
long maxGasAllowance
) {
/** Protobuf codec for reading and writing in protobuf format */
public static final Codec PROTOBUF = new com.hedera.hapi.node.contract.codec.EthereumTransactionBodyProtoCodec();
/** JSON codec for reading and writing in JSON format */
public static final JsonCodec JSON = new com.hedera.hapi.node.contract.codec.EthereumTransactionBodyJsonCodec();
/** Default instance with all fields set to default values */
public static final EthereumTransactionBody DEFAULT = newBuilder().build();
/**
* Create a pre-populated EthereumTransactionBody.
*
* @param ethereumData (1) The raw Ethereum transaction (RLP encoded type 0, 1, and 2). Complete
* unless the callData field is set.,
* @param callData (2) For large transactions (for example contract create) this is the callData
* of the ethereumData. The data in the ethereumData will be re-written with
* the callData element as a zero length string with the original contents in
* the referenced file at time of execution. The ethereumData will need to be
* "rehydrated" with the callData for signature validation to pass.,
* @param maxGasAllowance (3) The maximum amount, in tinybars, that the payer of the hedera transaction
* is willing to pay to complete the transaction.
* *
* Ordinarily the account with the ECDSA alias corresponding to the public
* key that is extracted from the ethereum_data signature is responsible for
* fees that result from the execution of the transaction. If that amount of
* authorized fees is not sufficient then the payer of the transaction can be
* charged, up to but not exceeding this amount. If the ethereum_data
* transaction authorized an amount that was insufficient then the payer will
* only be charged the amount needed to make up the difference. If the gas
* price in the transaction was set to zero then the payer will be assessed
* the entire fee.
*/
public EthereumTransactionBody(Bytes ethereumData, FileID callData, long maxGasAllowance) {
this.ethereumData = ethereumData != null ? ethereumData : Bytes.EMPTY;
this.callData = callData;
this.maxGasAllowance = maxGasAllowance;
}
/**
* Override the default hashCode method for
* all other objects to make hashCode
*/
@Override
public int hashCode() {
int result = 1;
if (ethereumData != null && !ethereumData.equals(DEFAULT.ethereumData)) {
result = 31 * result + ethereumData.hashCode();
}
if (callData != null && !callData.equals(DEFAULT.callData)) {
result = 31 * result + callData.hashCode();
}
if (maxGasAllowance != DEFAULT.maxGasAllowance) {
result = 31 * result + Long.hashCode(maxGasAllowance);
}
long hashCode = result;
// Shifts: 30, 27, 16, 20, 5, 18, 10, 24, 30
hashCode += hashCode << 30;
hashCode ^= hashCode >>> 27;
hashCode += hashCode << 16;
hashCode ^= hashCode >>> 20;
hashCode += hashCode << 5;
hashCode ^= hashCode >>> 18;
hashCode += hashCode << 10;
hashCode ^= hashCode >>> 24;
hashCode += hashCode << 30;
return (int)hashCode;
}
/**
* Override the default equals method for
*/
@Override
public boolean equals(Object that) {
if (that == null || this.getClass() != that.getClass()) {
return false;
}
EthereumTransactionBody thatObj = (EthereumTransactionBody)that;
if (ethereumData == null && thatObj.ethereumData != null) {
return false;
}
if (ethereumData != null && !ethereumData.equals(thatObj.ethereumData)) {
return false;
}
if (callData == null && thatObj.callData != null) {
return false;
}
if (callData != null && !callData.equals(thatObj.callData)) {
return false;
}
if (maxGasAllowance != thatObj.maxGasAllowance) {
return false;
}
return true;
}
/**
* Convenience method to check if the callData has a value
*
* @return true of the callData has a value
*/
public boolean hasCallData() {
return callData != null;
}
/**
* Gets the value for callData if it has a value, or else returns the default
* value for the type.
*
* @param defaultValue the default value to return if callData is null
* @return the value for callData if it has a value, or else returns the default value
*/
public FileID callDataOrElse(@NonNull final FileID defaultValue) {
return hasCallData() ? callData : defaultValue;
}
/**
* Gets the value for callData if it has a value, or else throws an NPE.
* value for the type.
*
* @return the value for callData if it has a value
* @throws NullPointerException if callData is null
*/
public @NonNull FileID callDataOrThrow() {
return requireNonNull(callData, "Field callData is null");
}
/**
* Executes the supplied {@link Consumer} if, and only if, the callData has a value
*
* @param ifPresent the {@link Consumer} to execute
*/
public void ifCallData(@NonNull final Consumer ifPresent) {
if (hasCallData()) {
ifPresent.accept(callData);
}
}
/**
* Return a builder for building a copy of this model object. It will be pre-populated with all the data from this
* model object.
*
* @return a pre-populated builder
*/
public Builder copyBuilder() {
return new Builder(ethereumData, callData, maxGasAllowance);
}
/**
* Return a new builder for building a model object. This is just a shortcut for new Model.Builder().
*
* @return a new builder
*/
public static Builder newBuilder() {
return new Builder();
}
/**
* Builder class for easy creation, ideal for clean code where performance is not critical. In critical performance
* paths use the constructor directly.
*/
public static final class Builder {
@NonNull private Bytes ethereumData = Bytes.EMPTY;
@Nullable private FileID callData = null;
private long maxGasAllowance = 0;
/**
* Create an empty builder
*/
public Builder() {}
/**
* Create a pre-populated Builder.
*
* @param ethereumData (1) The raw Ethereum transaction (RLP encoded type 0, 1, and 2). Complete
* unless the callData field is set.,
* @param callData (2) For large transactions (for example contract create) this is the callData
* of the ethereumData. The data in the ethereumData will be re-written with
* the callData element as a zero length string with the original contents in
* the referenced file at time of execution. The ethereumData will need to be
* "rehydrated" with the callData for signature validation to pass.,
* @param maxGasAllowance (3) The maximum amount, in tinybars, that the payer of the hedera transaction
* is willing to pay to complete the transaction.
* *
* Ordinarily the account with the ECDSA alias corresponding to the public
* key that is extracted from the ethereum_data signature is responsible for
* fees that result from the execution of the transaction. If that amount of
* authorized fees is not sufficient then the payer of the transaction can be
* charged, up to but not exceeding this amount. If the ethereum_data
* transaction authorized an amount that was insufficient then the payer will
* only be charged the amount needed to make up the difference. If the gas
* price in the transaction was set to zero then the payer will be assessed
* the entire fee.
*/
public Builder(Bytes ethereumData, FileID callData, long maxGasAllowance) {
this.ethereumData = ethereumData != null ? ethereumData : Bytes.EMPTY;
this.callData = callData;
this.maxGasAllowance = maxGasAllowance;
}
/**
* Build a new model record with data set on builder
*
* @return new model record with data set
*/
public EthereumTransactionBody build() {
return new EthereumTransactionBody(ethereumData, callData, maxGasAllowance);
}
/**
* (1) The raw Ethereum transaction (RLP encoded type 0, 1, and 2). Complete
* unless the callData field is set.
*
* @param ethereumData value to set
* @return builder to continue building with
*/
public Builder ethereumData(@NonNull Bytes ethereumData) {
this.ethereumData = ethereumData != null ? ethereumData : Bytes.EMPTY;
return this;
}
/**
* (2) For large transactions (for example contract create) this is the callData
* of the ethereumData. The data in the ethereumData will be re-written with
* the callData element as a zero length string with the original contents in
* the referenced file at time of execution. The ethereumData will need to be
* "rehydrated" with the callData for signature validation to pass.
*
* @param callData value to set
* @return builder to continue building with
*/
public Builder callData(@Nullable FileID callData) {
this.callData = callData;
return this;
}
/**
* (2) For large transactions (for example contract create) this is the callData
* of the ethereumData. The data in the ethereumData will be re-written with
* the callData element as a zero length string with the original contents in
* the referenced file at time of execution. The ethereumData will need to be
* "rehydrated" with the callData for signature validation to pass.
*
* @param builder A pre-populated builder
* @return builder to continue building with
*/
public Builder callData(FileID.Builder builder) {
this.callData = builder.build() ;
return this;
}
/**
* (3) The maximum amount, in tinybars, that the payer of the hedera transaction
* is willing to pay to complete the transaction.
* *
* Ordinarily the account with the ECDSA alias corresponding to the public
* key that is extracted from the ethereum_data signature is responsible for
* fees that result from the execution of the transaction. If that amount of
* authorized fees is not sufficient then the payer of the transaction can be
* charged, up to but not exceeding this amount. If the ethereum_data
* transaction authorized an amount that was insufficient then the payer will
* only be charged the amount needed to make up the difference. If the gas
* price in the transaction was set to zero then the payer will be assessed
* the entire fee.
*
* @param maxGasAllowance value to set
* @return builder to continue building with
*/
public Builder maxGasAllowance(long maxGasAllowance) {
this.maxGasAllowance = maxGasAllowance;
return this;
}
}
}