Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use the builder to create transactions #5980

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,17 +169,12 @@ private Object createFakeBlock(final Long height) {
null),
new BlockBody(
List.of(
new Transaction(
0,
Wei.of(height * 1000000L),
0,
Optional.empty(),
Wei.ZERO,
null,
Bytes.EMPTY,
Address.ZERO,
Optional.empty(),
Optional.empty())),
new Transaction.Builder()
.nonce(0)
.gasPrice(Wei.of(height * 1000000L))
.gasLimit(0)
.value(Wei.ZERO)
.build()),
List.of())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;

import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
Expand Down Expand Up @@ -68,64 +67,64 @@ public class BaseEeaSendRawTransaction {
final GasCalculator gasCalculator = new BerlinGasCalculator();

final Transaction PUBLIC_FLEXIBLE_TRANSACTION =
new Transaction(
0L,
Wei.of(1),
21000L,
Optional.of(FLEXIBLE_PRIVACY),
Wei.ZERO,
SIGNATURE_ALGORITHM_SUPPLIER
.get()
.createSignature(
new BigInteger(
"104310573331543561412661001400556426894275857431274618344686100036716947434951"),
new BigInteger(
"33080506591748900530090726168809539464160321639149722208454899701475015405641"),
Byte.parseByte("1")),
Bytes.fromBase64String(MOCK_ORION_KEY),
Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")),
Optional.empty(),
Optional.empty());
new Transaction.Builder()
.nonce(0)
.gasPrice(Wei.ONE)
.gasLimit(21000)
.value(Wei.ZERO)
.to(FLEXIBLE_PRIVACY)
.signature(
SIGNATURE_ALGORITHM_SUPPLIER
.get()
.createSignature(
new BigInteger(
"104310573331543561412661001400556426894275857431274618344686100036716947434951"),
new BigInteger(
"33080506591748900530090726168809539464160321639149722208454899701475015405641"),
Byte.parseByte("1")))
.payload(Bytes.fromBase64String(MOCK_ORION_KEY))
.sender(Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")))
.build();

final Transaction PUBLIC_PLUGIN_TRANSACTION =
new Transaction(
0L,
Wei.of(1),
21112L,
Optional.of(PLUGIN_PRIVACY),
Wei.ZERO,
SIGNATURE_ALGORITHM_SUPPLIER
.get()
.createSignature(
new BigInteger(
"111331907905663242841915789134040957461022579868467291368609335839524284474080"),
new BigInteger(
"16338460226177675602590882211136457396059831699034102939076916361204709826919"),
Byte.parseByte("0")),
Bytes.fromBase64String(MOCK_ORION_KEY),
Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")),
Optional.empty(),
Optional.empty());
new Transaction.Builder()
.nonce(0)
.gasPrice(Wei.ONE)
.gasLimit(21112)
.value(Wei.ZERO)
.to(PLUGIN_PRIVACY)
.signature(
SIGNATURE_ALGORITHM_SUPPLIER
.get()
.createSignature(
new BigInteger(
"111331907905663242841915789134040957461022579868467291368609335839524284474080"),
new BigInteger(
"16338460226177675602590882211136457396059831699034102939076916361204709826919"),
Byte.parseByte("0")))
.payload(Bytes.fromBase64String(MOCK_ORION_KEY))
.sender(Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")))
.build();

final Transaction PUBLIC_OFF_CHAIN_TRANSACTION =
new Transaction(
0L,
Wei.of(1),
21000L,
Optional.of(DEFAULT_PRIVACY),
Wei.ZERO,
SIGNATURE_ALGORITHM_SUPPLIER
.get()
.createSignature(
new BigInteger(
"45331864585825234947874751069766983839005678711670143534492294352090223768785"),
new BigInteger(
"32813839561238589140263096892921088101761344639911577803805398248765156383629"),
Byte.parseByte("1")),
Bytes.fromBase64String(MOCK_ORION_KEY),
Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")),
Optional.empty(),
Optional.empty());
new Transaction.Builder()
.nonce(0)
.gasPrice(Wei.ONE)
.gasLimit(21000)
.value(Wei.ZERO)
.to(DEFAULT_PRIVACY)
.signature(
SIGNATURE_ALGORITHM_SUPPLIER
.get()
.createSignature(
new BigInteger(
"45331864585825234947874751069766983839005678711670143534492294352090223768785"),
new BigInteger(
"32813839561238589140263096892921088101761344639911577803805398248765156383629"),
Byte.parseByte("1")))
.payload(Bytes.fromBase64String(MOCK_ORION_KEY))
.sender(Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")))
.build();

final JsonRpcRequestContext validPrivateForTransactionRequest =
new JsonRpcRequestContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,162 +226,6 @@ public Transaction(
}
}

public Transaction(
final long nonce,
final Optional<Wei> gasPrice,
final Optional<Wei> maxPriorityFeePerGas,
final Optional<Wei> maxFeePerGas,
final Optional<Wei> maxFeePerBlobGas,
final long gasLimit,
final Optional<Address> to,
final Wei value,
final SECPSignature signature,
final Bytes payload,
final Address sender,
final Optional<BigInteger> chainId,
final Optional<List<VersionedHash>> versionedHashes,
final Optional<BlobsWithCommitments> blobsWithCommitments) {
this(
TransactionType.FRONTIER,
nonce,
gasPrice,
maxPriorityFeePerGas,
maxFeePerGas,
maxFeePerBlobGas,
gasLimit,
to,
value,
signature,
payload,
Optional.empty(),
sender,
chainId,
versionedHashes,
blobsWithCommitments);
}

public Transaction(
final long nonce,
final Wei gasPrice,
final long gasLimit,
final Address to,
final Wei value,
final SECPSignature signature,
final Bytes payload,
final Optional<BigInteger> chainId,
final Optional<List<VersionedHash>> versionedHashes,
final Optional<BlobsWithCommitments> blobsWithCommitments) {
this(
TransactionType.FRONTIER,
nonce,
Optional.of(gasPrice),
Optional.empty(),
Optional.empty(),
Optional.empty(),
gasLimit,
Optional.of(to),
value,
signature,
payload,
Optional.empty(),
null,
chainId,
versionedHashes,
blobsWithCommitments);
}

/**
* Instantiates a transaction instance.
*
* @param nonce the nonce
* @param gasPrice the gas price
* @param gasLimit the gas limit
* @param to the transaction recipient
* @param value the value being transferred to the recipient
* @param signature the signature
* @param payload the payload
* @param sender the transaction sender
* @param chainId the chain id to apply the transaction to
* <p>The {@code to} will be an {@code Optional.empty()} for a contract creation transaction;
* otherwise it should contain an address.
* <p>The {@code chainId} must be greater than 0 to be applied to a specific chain; otherwise
* it will default to any chain.
*/
public Transaction(
final long nonce,
final Wei gasPrice,
final long gasLimit,
final Optional<Address> to,
final Wei value,
final SECPSignature signature,
final Bytes payload,
final Address sender,
final Optional<BigInteger> chainId,
final Optional<List<VersionedHash>> versionedHashes) {
this(
nonce,
Optional.of(gasPrice),
Optional.empty(),
Optional.empty(),
Optional.empty(),
gasLimit,
to,
value,
signature,
payload,
sender,
chainId,
versionedHashes,
Optional.empty());
}

/**
* Instantiates a transaction instance.
*
* @param nonce the nonce
* @param gasPrice the gas price
* @param gasLimit the gas limit
* @param to the transaction recipient
* @param value the value being transferred to the recipient
* @param signature the signature
* @param payload the payload
* @param sender the transaction sender
* @param chainId the chain id to apply the transaction to
* <p>The {@code to} will be an {@code Optional.empty()} for a contract creation transaction;
* otherwise it should contain an address.
* <p>The {@code chainId} must be greater than 0 to be applied to a specific chain; otherwise
* it will default to any chain.
*/
public Transaction(
final long nonce,
final Wei gasPrice,
final long gasLimit,
final Optional<Address> to,
final Wei value,
final SECPSignature signature,
final Bytes payload,
final Address sender,
final Optional<BigInteger> chainId,
final Optional<Wei> maxFeePerBlobGas,
final Optional<List<VersionedHash>> versionedHashes,
final Optional<BlobsWithCommitments> blobsWithCommitments) {
this(
nonce,
Optional.of(gasPrice),
Optional.empty(),
Optional.empty(),
maxFeePerBlobGas,
gasLimit,
to,
value,
signature,
payload,
sender,
chainId,
versionedHashes,
blobsWithCommitments);
}

/**
* Returns the transaction nonce.
*
Expand Down
Loading