From 4f223d9936f4aadfb72ed282a78c8b60dc35bf52 Mon Sep 17 00:00:00 2001 From: Chen Kai <281165273grape@gmail.com> Date: Sat, 4 May 2024 16:34:01 +0800 Subject: [PATCH] fix:fix style Signed-off-by: Chen Kai <281165273grape@gmail.com> --- hildr-batcher/build.gradle | 4 +- hildr-node/build.gradle | 2 +- .../io/optimism/engine/ExecutionPayload.java | 1 + .../main/java/io/optimism/runner/Runner.java | 2 + hildr-utilities/build.gradle | 4 +- .../type/BeaconSignedBlockHeader.java | 29 + .../java/io/optimism/type/SpecConfig.java | 9 + .../java/io/optimism/type/enums/TxType.java | 43 +- .../utilities/encoding/TxEncoder.java | 46 ++ .../utilities/rpc/response/OpEthBlock.java | 523 ++++++++++++++++++ .../utilities/rpc/response/OpTransaction.java | 399 ++++++++++++- 11 files changed, 1052 insertions(+), 10 deletions(-) diff --git a/hildr-batcher/build.gradle b/hildr-batcher/build.gradle index acd4f72f..a4249521 100644 --- a/hildr-batcher/build.gradle +++ b/hildr-batcher/build.gradle @@ -8,8 +8,8 @@ plugins { id 'com.github.johnrengelman.shadow' version '8.1.1' } -group = 'io.optimism' -version = '0.2.5' +group = 'me.grapebaba' +version = '0.4.0' repositories { // Use Maven Central for resolving dependencies. diff --git a/hildr-node/build.gradle b/hildr-node/build.gradle index 913d89bb..e5a9b6f1 100644 --- a/hildr-node/build.gradle +++ b/hildr-node/build.gradle @@ -23,7 +23,7 @@ plugins { } group 'me.grapebaba' -version '0.2.5' +version '0.4.0' repositories { // Use Maven Central for resolving dependencies. diff --git a/hildr-node/src/main/java/io/optimism/engine/ExecutionPayload.java b/hildr-node/src/main/java/io/optimism/engine/ExecutionPayload.java index 1f785c70..8d23854f 100644 --- a/hildr-node/src/main/java/io/optimism/engine/ExecutionPayload.java +++ b/hildr-node/src/main/java/io/optimism/engine/ExecutionPayload.java @@ -170,6 +170,7 @@ public ExecutionPayload toExecutionPayload(String parentBeaconBlockRoot) { * From execution payload. * * @param block the L2 block + * @param config the chain config * @return the execution payload */ public static ExecutionPayload fromL2Block(OpEthBlock.Block block, Config.ChainConfig config) { diff --git a/hildr-node/src/main/java/io/optimism/runner/Runner.java b/hildr-node/src/main/java/io/optimism/runner/Runner.java index 72b0a5db..7b680185 100644 --- a/hildr-node/src/main/java/io/optimism/runner/Runner.java +++ b/hildr-node/src/main/java/io/optimism/runner/Runner.java @@ -151,6 +151,7 @@ public void challengeSync() { * Full sync. * * @throws InterruptedException the interrupted exception + * @throws ExecutionException the execution exception */ public void fullSync() throws InterruptedException, ExecutionException { LOGGER.info("starting full sync"); @@ -284,6 +285,7 @@ private static void addTrustedPeerToL2Engine(Web3j l2Provider) throws Interrupte * snap sync. * * @throws InterruptedException the interrupted exception + * @throws ExecutionException the execution exception */ public void executionLayerSync() throws InterruptedException, ExecutionException { LOGGER.info("execution layer sync"); diff --git a/hildr-utilities/build.gradle b/hildr-utilities/build.gradle index 0c1e2d08..3e8cd2e9 100644 --- a/hildr-utilities/build.gradle +++ b/hildr-utilities/build.gradle @@ -6,8 +6,8 @@ plugins { id "net.ltgt.errorprone" version "3.1.0" } -group = 'io.optimism' -version = '0.2.5' +group = 'me.grapebaba' +version = '0.4.0' repositories { // Use Maven Central for resolving dependencies. diff --git a/hildr-utilities/src/main/java/io/optimism/type/BeaconSignedBlockHeader.java b/hildr-utilities/src/main/java/io/optimism/type/BeaconSignedBlockHeader.java index dd489924..22234b54 100644 --- a/hildr-utilities/src/main/java/io/optimism/type/BeaconSignedBlockHeader.java +++ b/hildr-utilities/src/main/java/io/optimism/type/BeaconSignedBlockHeader.java @@ -14,25 +14,54 @@ public class BeaconSignedBlockHeader { private String signature; + /** + * Instantiates a new Beacon signed block header. + */ public BeaconSignedBlockHeader() {} + /** + * Instantiates a new Beacon signed block header. + * + * @param message the message + * @param signature the signature + */ public BeaconSignedBlockHeader(BeaconBlockHeader message, String signature) { this.message = message; this.signature = signature; } + /** + * Gets message. + * + * @return the message + */ public BeaconBlockHeader getMessage() { return message; } + /** + * Sets message. + * + * @param message the message + */ public void setMessage(BeaconBlockHeader message) { this.message = message; } + /** + * Gets signature. + * + * @return the signature + */ public String getSignature() { return signature; } + /** + * Sets signature. + * + * @param signature the signature + */ public void setSignature(String signature) { this.signature = signature; } diff --git a/hildr-utilities/src/main/java/io/optimism/type/SpecConfig.java b/hildr-utilities/src/main/java/io/optimism/type/SpecConfig.java index ff805800..6a418eec 100644 --- a/hildr-utilities/src/main/java/io/optimism/type/SpecConfig.java +++ b/hildr-utilities/src/main/java/io/optimism/type/SpecConfig.java @@ -20,6 +20,8 @@ public class SpecConfig { /** * The SpecConfig constructor. + * + * @return the seconds per slot */ public BigInteger getSecondsPerSlot() { return new BigInteger(secondsPerSlot); @@ -27,11 +29,18 @@ public BigInteger getSecondsPerSlot() { /** * The SpecConfig constructor. + * + * @param secondsPerSlot the seconds per slot */ public void setSecondsPerSlot(String secondsPerSlot) { this.secondsPerSlot = secondsPerSlot; } + /** + * The SpecConfig constructor. + */ + public SpecConfig() {} + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/hildr-utilities/src/main/java/io/optimism/type/enums/TxType.java b/hildr-utilities/src/main/java/io/optimism/type/enums/TxType.java index 616c575f..4db36a8d 100644 --- a/hildr-utilities/src/main/java/io/optimism/type/enums/TxType.java +++ b/hildr-utilities/src/main/java/io/optimism/type/enums/TxType.java @@ -2,15 +2,29 @@ import org.hyperledger.besu.datatypes.TransactionType; +/** + * The enum Tx type. + */ public enum TxType { + /** + * Legacy tx type. + */ LEGACY(0x00, "0x0", TransactionType.FRONTIER), - /** Access list transaction type. */ + /** + * Access list transaction type. + */ ACCESS_LIST(0x01, "0x1", TransactionType.ACCESS_LIST), - /** Eip1559 transaction type. */ + /** + * Eip1559 transaction type. + */ EIP1559(0x02, "0x2", TransactionType.EIP1559), - /** Blob transaction type. */ + /** + * Blob transaction type. + */ BLOB(0x03, "0x3", TransactionType.BLOB), - /** Optimism Deposit transaction type. */ + /** + * Optimism Deposit transaction type. + */ OPTIMISM_DEPOSIT(0x7e, "0x7e", null); private final int typeValue; @@ -23,18 +37,39 @@ public enum TxType { this.besuType = txBesuType; } + /** + * Is boolean. + * + * @param type the type + * @return the boolean + */ public boolean is(final String type) { return this.typeHexString.equalsIgnoreCase(type); } + /** + * Gets value. + * + * @return the value + */ public int getValue() { return this.typeValue; } + /** + * Gets string. + * + * @return the string + */ public String getString() { return this.typeHexString; } + /** + * Gets besu type. + * + * @return the besu type + */ public TransactionType getBesuType() { return besuType; } diff --git a/hildr-utilities/src/main/java/io/optimism/utilities/encoding/TxEncoder.java b/hildr-utilities/src/main/java/io/optimism/utilities/encoding/TxEncoder.java index 4714e94d..e1f457ec 100644 --- a/hildr-utilities/src/main/java/io/optimism/utilities/encoding/TxEncoder.java +++ b/hildr-utilities/src/main/java/io/optimism/utilities/encoding/TxEncoder.java @@ -24,16 +24,31 @@ import org.web3j.protocol.core.methods.response.EthBlock; import org.web3j.utils.Numeric; +/** + * The type Tx encoder. + */ public class TxEncoder { private static final Supplier SIGNATURE_ALGORITHM = Suppliers.memoize(SignatureAlgorithmFactory::getInstance); + /** + * The constant REPLAY_UNPROTECTED_V_BASE. + */ public static final BigInteger REPLAY_UNPROTECTED_V_BASE = BigInteger.valueOf(27); + /** + * The constant REPLAY_UNPROTECTED_V_BASE_PLUS_1. + */ public static final BigInteger REPLAY_UNPROTECTED_V_BASE_PLUS_1 = BigInteger.valueOf(28); + /** + * The constant REPLAY_PROTECTED_V_BASE. + */ public static final BigInteger REPLAY_PROTECTED_V_BASE = BigInteger.valueOf(35); + /** + * The constant REPLAY_PROTECTED_V_MIN. + */ // The v signature parameter starts at 36 because 1 is the first valid chainId so: // chainId > 1 implies that 2 * chainId + V_BASE > 36. public static final BigInteger REPLAY_PROTECTED_V_MIN = BigInteger.valueOf(36); @@ -44,6 +59,17 @@ public class TxEncoder { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } + /** + * Instantiates a new Tx encoder. + */ + public TxEncoder() {} + + /** + * Encode byte [ ]. + * + * @param tx the tx + * @return the byte [ ] + */ public static byte[] encode(EthBlock.TransactionObject tx) { if (TxType.OPTIMISM_DEPOSIT.is(tx.getType())) { throw new IllegalArgumentException("this method not support deposit transaction"); @@ -52,6 +78,13 @@ public static byte[] encode(EthBlock.TransactionObject tx) { .toArray(); } + /** + * To deposit tx deposit transaction. + * + * @param tx the tx + * @param isSystemTx the is system tx + * @return the deposit transaction + */ public static DepositTransaction toDepositTx(OpEthBlock.TransactionObject tx, boolean isSystemTx) { return new DepositTransaction( tx.getSourceHash(), @@ -64,6 +97,13 @@ public static DepositTransaction toDepositTx(OpEthBlock.TransactionObject tx, bo tx.getInput()); } + /** + * Encode deposit tx byte [ ]. + * + * @param tx the tx + * @param isSystemTx the is system tx + * @return the byte [ ] + */ public static byte[] encodeDepositTx(OpEthBlock.TransactionObject tx, boolean isSystemTx) { DepositTransaction depositTx = new DepositTransaction( tx.getSourceHash(), @@ -77,6 +117,12 @@ public static byte[] encodeDepositTx(OpEthBlock.TransactionObject tx, boolean is return depositTx.encode(); } + /** + * Web 3 j tx to besu tx transaction. + * + * @param tx the tx + * @return the transaction + */ public static Transaction web3jTxToBesuTx(EthBlock.TransactionObject tx) { if (TxType.LEGACY.is(tx.getType())) { return toLegacyTx(tx); diff --git a/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpEthBlock.java b/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpEthBlock.java index 052aa027..e08e4551 100644 --- a/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpEthBlock.java +++ b/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpEthBlock.java @@ -35,16 +35,29 @@ */ public class OpEthBlock extends Response { + /** + * Instantiates a new Op eth block. + */ + public OpEthBlock() {} + @Override @JsonDeserialize(using = ResponseDeserialiser.class) public void setResult(Block result) { super.setResult(result); } + /** + * Gets block. + * + * @return the block + */ public Block getBlock() { return getResult(); } + /** + * The type Block. + */ public static class Block { private String number; private String hash; @@ -75,8 +88,43 @@ public static class Block { private String blobGasUsed; private String excessBlobGas; + /** + * Instantiates a new Block. + */ public Block() {} + /** + * Instantiates a new Block. + * + * @param number the number + * @param hash the hash + * @param parentHash the parent hash + * @param parentBeaconBlockRoot the parent beacon block root + * @param nonce the nonce + * @param sha3Uncles the sha 3 uncles + * @param logsBloom the logs bloom + * @param transactionsRoot the transactions root + * @param stateRoot the state root + * @param receiptsRoot the receipts root + * @param author the author + * @param miner the miner + * @param mixHash the mix hash + * @param difficulty the difficulty + * @param totalDifficulty the total difficulty + * @param extraData the extra data + * @param size the size + * @param gasLimit the gas limit + * @param gasUsed the gas used + * @param timestamp the timestamp + * @param transactions the transactions + * @param uncles the uncles + * @param sealFields the seal fields + * @param baseFeePerGas the base fee per gas + * @param withdrawalsRoot the withdrawals root + * @param withdrawals the withdrawals + * @param blobGasUsed the blob gas used + * @param excessBlobGas the excess blob gas + */ public Block( String number, String hash, @@ -136,6 +184,35 @@ public Block( this.excessBlobGas = excessBlobGas; } + /** + * Instantiates a new Block. + * + * @param number the number + * @param hash the hash + * @param parentHash the parent hash + * @param nonce the nonce + * @param sha3Uncles the sha 3 uncles + * @param logsBloom the logs bloom + * @param transactionsRoot the transactions root + * @param stateRoot the state root + * @param receiptsRoot the receipts root + * @param author the author + * @param miner the miner + * @param mixHash the mix hash + * @param difficulty the difficulty + * @param totalDifficulty the total difficulty + * @param extraData the extra data + * @param size the size + * @param gasLimit the gas limit + * @param gasUsed the gas used + * @param timestamp the timestamp + * @param transactions the transactions + * @param uncles the uncles + * @param sealFields the seal fields + * @param baseFeePerGas the base fee per gas + * @param withdrawalsRoot the withdrawals root + * @param withdrawals the withdrawals + */ public Block( String number, String hash, @@ -189,275 +266,610 @@ public Block( this.withdrawals = withdrawals; } + /** + * Gets number. + * + * @return the number + */ public BigInteger getNumber() { return Numeric.decodeQuantity(number); } + /** + * Gets number raw. + * + * @return the number raw + */ public String getNumberRaw() { return number; } + /** + * Sets number. + * + * @param number the number + */ public void setNumber(String number) { this.number = number; } + /** + * Gets hash. + * + * @return the hash + */ public String getHash() { return hash; } + /** + * Sets hash. + * + * @param hash the hash + */ public void setHash(String hash) { this.hash = hash; } + /** + * Gets parent hash. + * + * @return the parent hash + */ public String getParentHash() { return parentHash; } + /** + * Sets parent hash. + * + * @param parentHash the parent hash + */ public void setParentHash(String parentHash) { this.parentHash = parentHash; } + /** + * Gets parent beacon block root. + * + * @return the parent beacon block root + */ public String getParentBeaconBlockRoot() { return parentBeaconBlockRoot; } + /** + * Sets parent beacon block root. + * + * @param parentBeaconBlockRoot the parent beacon block root + */ public void setParentBeaconBlockRoot(String parentBeaconBlockRoot) { this.parentBeaconBlockRoot = parentBeaconBlockRoot; } + /** + * Gets nonce. + * + * @return the nonce + */ public BigInteger getNonce() { return Numeric.decodeQuantity(nonce); } + /** + * Gets nonce raw. + * + * @return the nonce raw + */ public String getNonceRaw() { return nonce; } + /** + * Sets nonce. + * + * @param nonce the nonce + */ public void setNonce(String nonce) { this.nonce = nonce; } + /** + * Gets sha 3 uncles. + * + * @return the sha 3 uncles + */ public String getSha3Uncles() { return sha3Uncles; } + /** + * Sets sha 3 uncles. + * + * @param sha3Uncles the sha 3 uncles + */ public void setSha3Uncles(String sha3Uncles) { this.sha3Uncles = sha3Uncles; } + /** + * Gets logs bloom. + * + * @return the logs bloom + */ public String getLogsBloom() { return logsBloom; } + /** + * Sets logs bloom. + * + * @param logsBloom the logs bloom + */ public void setLogsBloom(String logsBloom) { this.logsBloom = logsBloom; } + /** + * Gets transactions root. + * + * @return the transactions root + */ public String getTransactionsRoot() { return transactionsRoot; } + /** + * Sets transactions root. + * + * @param transactionsRoot the transactions root + */ public void setTransactionsRoot(String transactionsRoot) { this.transactionsRoot = transactionsRoot; } + /** + * Gets state root. + * + * @return the state root + */ public String getStateRoot() { return stateRoot; } + /** + * Sets state root. + * + * @param stateRoot the state root + */ public void setStateRoot(String stateRoot) { this.stateRoot = stateRoot; } + /** + * Gets receipts root. + * + * @return the receipts root + */ public String getReceiptsRoot() { return receiptsRoot; } + /** + * Sets receipts root. + * + * @param receiptsRoot the receipts root + */ public void setReceiptsRoot(String receiptsRoot) { this.receiptsRoot = receiptsRoot; } + /** + * Gets author. + * + * @return the author + */ public String getAuthor() { return author; } + /** + * Sets author. + * + * @param author the author + */ public void setAuthor(String author) { this.author = author; } + /** + * Gets miner. + * + * @return the miner + */ public String getMiner() { return miner; } + /** + * Sets miner. + * + * @param miner the miner + */ public void setMiner(String miner) { this.miner = miner; } + /** + * Gets mix hash. + * + * @return the mix hash + */ public String getMixHash() { return mixHash; } + /** + * Sets mix hash. + * + * @param mixHash the mix hash + */ public void setMixHash(String mixHash) { this.mixHash = mixHash; } + /** + * Gets difficulty. + * + * @return the difficulty + */ public BigInteger getDifficulty() { return Numeric.decodeQuantity(difficulty); } + /** + * Gets difficulty raw. + * + * @return the difficulty raw + */ public String getDifficultyRaw() { return difficulty; } + /** + * Sets difficulty. + * + * @param difficulty the difficulty + */ public void setDifficulty(String difficulty) { this.difficulty = difficulty; } + /** + * Gets total difficulty. + * + * @return the total difficulty + */ public BigInteger getTotalDifficulty() { return Numeric.decodeQuantity(totalDifficulty); } + /** + * Gets total difficulty raw. + * + * @return the total difficulty raw + */ public String getTotalDifficultyRaw() { return totalDifficulty; } + /** + * Sets total difficulty. + * + * @param totalDifficulty the total difficulty + */ public void setTotalDifficulty(String totalDifficulty) { this.totalDifficulty = totalDifficulty; } + /** + * Gets extra data. + * + * @return the extra data + */ public String getExtraData() { return extraData; } + /** + * Sets extra data. + * + * @param extraData the extra data + */ public void setExtraData(String extraData) { this.extraData = extraData; } + /** + * Gets size. + * + * @return the size + */ public BigInteger getSize() { return size != null ? Numeric.decodeQuantity(size) : BigInteger.ZERO; } + /** + * Gets size raw. + * + * @return the size raw + */ public String getSizeRaw() { return size; } + /** + * Sets size. + * + * @param size the size + */ public void setSize(String size) { this.size = size; } + /** + * Gets gas limit. + * + * @return the gas limit + */ public BigInteger getGasLimit() { return Numeric.decodeQuantity(gasLimit); } + /** + * Gets gas limit raw. + * + * @return the gas limit raw + */ public String getGasLimitRaw() { return gasLimit; } + /** + * Sets gas limit. + * + * @param gasLimit the gas limit + */ public void setGasLimit(String gasLimit) { this.gasLimit = gasLimit; } + /** + * Gets gas used. + * + * @return the gas used + */ public BigInteger getGasUsed() { return Numeric.decodeQuantity(gasUsed); } + /** + * Gets gas used raw. + * + * @return the gas used raw + */ public String getGasUsedRaw() { return gasUsed; } + /** + * Sets gas used. + * + * @param gasUsed the gas used + */ public void setGasUsed(String gasUsed) { this.gasUsed = gasUsed; } + /** + * Gets timestamp. + * + * @return the timestamp + */ public BigInteger getTimestamp() { return Numeric.decodeQuantity(timestamp); } + /** + * Gets timestamp raw. + * + * @return the timestamp raw + */ public String getTimestampRaw() { return timestamp; } + /** + * Sets timestamp. + * + * @param timestamp the timestamp + */ public void setTimestamp(String timestamp) { this.timestamp = timestamp; } + /** + * Gets transactions. + * + * @return the transactions + */ public List getTransactions() { return transactions; } + /** + * Sets transactions. + * + * @param transactions the transactions + */ @JsonDeserialize(using = ResultTransactionDeserialiser.class) public void setTransactions(List transactions) { this.transactions = transactions; } + /** + * Gets uncles. + * + * @return the uncles + */ public List getUncles() { return uncles; } + /** + * Sets uncles. + * + * @param uncles the uncles + */ public void setUncles(List uncles) { this.uncles = uncles; } + /** + * Gets seal fields. + * + * @return the seal fields + */ public List getSealFields() { return sealFields; } + /** + * Sets seal fields. + * + * @param sealFields the seal fields + */ public void setSealFields(List sealFields) { this.sealFields = sealFields; } + /** + * Gets base fee per gas. + * + * @return the base fee per gas + */ public BigInteger getBaseFeePerGas() { return Numeric.decodeQuantity(baseFeePerGas); } + /** + * Sets base fee per gas. + * + * @param baseFeePerGas the base fee per gas + */ public void setBaseFeePerGas(String baseFeePerGas) { this.baseFeePerGas = baseFeePerGas; } + /** + * Gets base fee per gas raw. + * + * @return the base fee per gas raw + */ public String getBaseFeePerGasRaw() { return baseFeePerGas; } + /** + * Gets withdrawals root. + * + * @return the withdrawals root + */ public String getWithdrawalsRoot() { return withdrawalsRoot; } + /** + * Sets withdrawals root. + * + * @param withdrawalsRoot the withdrawals root + */ public void setWithdrawalsRoot(String withdrawalsRoot) { this.withdrawalsRoot = withdrawalsRoot; } + /** + * Gets withdrawals. + * + * @return the withdrawals + */ public List getWithdrawals() { return withdrawals; } + /** + * Sets withdrawals. + * + * @param withdrawals the withdrawals + */ public void setWithdrawals(List withdrawals) { this.withdrawals = withdrawals; } + /** + * Gets blob gas used. + * + * @return the blob gas used + */ public BigInteger getBlobGasUsed() { if (blobGasUsed == null) return BigInteger.ZERO; return Numeric.decodeQuantity(blobGasUsed); } + /** + * Gets blob gas used raw. + * + * @return the blob gas used raw + */ public String getBlobGasUsedRaw() { if (blobGasUsed == null) return "0"; return blobGasUsed; } + /** + * Sets blob gas used. + * + * @param blobGasUsed the blob gas used + */ public void setBlobGasUsed(String blobGasUsed) { this.blobGasUsed = blobGasUsed; } + /** + * Gets excess blob gas. + * + * @return the excess blob gas + */ public BigInteger getExcessBlobGas() { if (excessBlobGas == null) return BigInteger.ZERO; return Numeric.decodeQuantity(excessBlobGas); } + /** + * Gets excess blob gas raw. + * + * @return the excess blob gas raw + */ public String getExcessBlobGasRaw() { if (excessBlobGas == null) return "0"; return excessBlobGas; } + /** + * Sets excess blob gas. + * + * @param excessBlobGas the excess blob gas + */ public void setExcessBlobGas(String excessBlobGas) { this.excessBlobGas = excessBlobGas; } @@ -644,15 +1056,36 @@ public int hashCode() { } } + /** + * The interface Transaction result. + * + * @param the type parameter + */ public interface TransactionResult { + /** + * Get t. + * + * @return the t + */ T get(); } + /** + * The type Transaction hash. + */ public static class TransactionHash implements TransactionResult { private String value; + /** + * Instantiates a new Transaction hash. + */ public TransactionHash() {} + /** + * Instantiates a new Transaction hash. + * + * @param value the value + */ public TransactionHash(String value) { this.value = value; } @@ -662,6 +1095,11 @@ public String get() { return value; } + /** + * Sets value. + * + * @param value the value + */ public void setValue(String value) { this.value = value; } @@ -686,9 +1124,45 @@ public int hashCode() { } } + /** + * The type Transaction object. + */ public static class TransactionObject extends OpTransaction implements TransactionResult { + /** + * Instantiates a new Transaction object. + */ public TransactionObject() {} + /** + * Instantiates a new Transaction object. + * + * @param hash the hash + * @param nonce the nonce + * @param blockHash the block hash + * @param blockNumber the block number + * @param chainId the chain id + * @param transactionIndex the transaction index + * @param from the from + * @param to the to + * @param value the value + * @param gasPrice the gas price + * @param gas the gas + * @param input the input + * @param creates the creates + * @param publicKey the public key + * @param raw the raw + * @param r the r + * @param s the s + * @param v the v + * @param yParity the y parity + * @param type the type + * @param maxFeePerGas the max fee per gas + * @param maxPriorityFeePerGas the max priority fee per gas + * @param accessList the access list + * @param sourceHash the source hash + * @param mint the mint + * @param depositReceiptVersion the deposit receipt version + */ public TransactionObject( String hash, String nonce, @@ -745,6 +1219,38 @@ public TransactionObject( depositReceiptVersion); } + /** + * Instantiates a new Transaction object. + * + * @param hash the hash + * @param nonce the nonce + * @param blockHash the block hash + * @param blockNumber the block number + * @param chainId the chain id + * @param transactionIndex the transaction index + * @param from the from + * @param to the to + * @param value the value + * @param gasPrice the gas price + * @param gas the gas + * @param input the input + * @param creates the creates + * @param publicKey the public key + * @param raw the raw + * @param r the r + * @param s the s + * @param v the v + * @param yParity the y parity + * @param type the type + * @param maxFeePerGas the max fee per gas + * @param maxPriorityFeePerGas the max priority fee per gas + * @param accessList the access list + * @param maxFeePerBlobGas the max fee per blob gas + * @param blobVersionedHashes the blob versioned hashes + * @param sourceHash the source hash + * @param mint the mint + * @param depositReceiptVersion the deposit receipt version + */ public TransactionObject( String hash, String nonce, @@ -808,6 +1314,7 @@ public TransactionObject( /** * Convert this transaction object to a web3j transaction object. * Will ignore sourceHash, mint, and depositReceiptVersion fields. + * * @return the web3j transaction instant */ public EthBlock.TransactionObject toWeb3j() { @@ -845,10 +1352,18 @@ public OpTransaction get() { } } + /** + * The type Result transaction deserialiser. + */ public static class ResultTransactionDeserialiser extends JsonDeserializer> { private ObjectReader objectReader = ObjectMapperFactory.getObjectReader(); + /** + * Instantiates a new Result transaction deserialiser. + */ + public ResultTransactionDeserialiser() {} + @Override public List deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { @@ -876,10 +1391,18 @@ public List deserialize(JsonParser jsonParser, Deserializatio } } + /** + * The type Response deserialiser. + */ public static class ResponseDeserialiser extends JsonDeserializer { private ObjectReader objectReader = ObjectMapperFactory.getObjectReader(); + /** + * Instantiates a new Response deserialiser. + */ + public ResponseDeserialiser() {} + @Override public Block deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { diff --git a/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpTransaction.java b/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpTransaction.java index 4cc13a22..5f9c8de6 100644 --- a/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpTransaction.java +++ b/hildr-utilities/src/main/java/io/optimism/utilities/rpc/response/OpTransaction.java @@ -8,7 +8,9 @@ import org.web3j.protocol.core.methods.response.EthTransaction; import org.web3j.utils.Numeric; -/** Transaction object used by both {@link EthTransaction} and {@link EthBlock}. */ +/** + * Transaction object used by both {@link EthTransaction} and {@link EthBlock}. + */ public class OpTransaction { private String hash; @@ -67,8 +69,41 @@ public class OpTransaction { private String depositReceiptVersion; + /** + * Instantiates a new Op transaction. + */ public OpTransaction() {} + /** + * Instantiates a new Op transaction. + * + * @param hash the hash + * @param nonce the nonce + * @param blockHash the block hash + * @param blockNumber the block number + * @param chainId the chain id + * @param transactionIndex the transaction index + * @param from the from + * @param to the to + * @param value the value + * @param gas the gas + * @param gasPrice the gas price + * @param input the input + * @param creates the creates + * @param publicKey the public key + * @param raw the raw + * @param r the r + * @param s the s + * @param v the v + * @param yParity the y parity + * @param type the type + * @param maxFeePerGas the max fee per gas + * @param maxPriorityFeePerGas the max priority fee per gas + * @param accessList the access list + * @param sourceHash the source hash + * @param mint the mint + * @param depositReceiptVersion the deposit receipt version + */ public OpTransaction( String hash, String nonce, @@ -124,6 +159,38 @@ public OpTransaction( this.depositReceiptVersion = depositReceiptVersion; } + /** + * Instantiates a new Op transaction. + * + * @param hash the hash + * @param nonce the nonce + * @param blockHash the block hash + * @param blockNumber the block number + * @param chainId the chain id + * @param transactionIndex the transaction index + * @param from the from + * @param to the to + * @param value the value + * @param gas the gas + * @param gasPrice the gas price + * @param input the input + * @param creates the creates + * @param publicKey the public key + * @param raw the raw + * @param r the r + * @param s the s + * @param v the v + * @param yParity the y parity + * @param type the type + * @param maxFeePerGas the max fee per gas + * @param maxPriorityFeePerGas the max priority fee per gas + * @param accessList the access list + * @param maxFeePerBlobGas the max fee per blob gas + * @param versionedHashes the versioned hashes + * @param sourceHash the source hash + * @param mint the mint + * @param depositReceiptVersion the deposit receipt version + */ public OpTransaction( String hash, String nonce, @@ -183,166 +250,371 @@ public OpTransaction( this.depositReceiptVersion = depositReceiptVersion; } + /** + * Sets chain id. + * + * @param chainId the chain id + */ public void setChainId(String chainId) { this.chainId = chainId; } + /** + * Gets hash. + * + * @return the hash + */ public String getHash() { return hash; } + /** + * Sets hash. + * + * @param hash the hash + */ public void setHash(String hash) { this.hash = hash; } + /** + * Gets nonce. + * + * @return the nonce + */ public BigInteger getNonce() { return Numeric.decodeQuantity(nonce); } + /** + * Sets nonce. + * + * @param nonce the nonce + */ public void setNonce(String nonce) { this.nonce = nonce; } + /** + * Gets nonce raw. + * + * @return the nonce raw + */ public String getNonceRaw() { return nonce; } + /** + * Gets block hash. + * + * @return the block hash + */ public String getBlockHash() { return blockHash; } + /** + * Sets block hash. + * + * @param blockHash the block hash + */ public void setBlockHash(String blockHash) { this.blockHash = blockHash; } + /** + * Gets block number. + * + * @return the block number + */ public BigInteger getBlockNumber() { return Numeric.decodeQuantity(blockNumber); } + /** + * Sets block number. + * + * @param blockNumber the block number + */ public void setBlockNumber(String blockNumber) { this.blockNumber = blockNumber; } + /** + * Gets block number raw. + * + * @return the block number raw + */ public String getBlockNumberRaw() { return blockNumber; } + /** + * Gets transaction index. + * + * @return the transaction index + */ public BigInteger getTransactionIndex() { return Numeric.decodeQuantity(transactionIndex); } + /** + * Sets transaction index. + * + * @param transactionIndex the transaction index + */ public void setTransactionIndex(String transactionIndex) { this.transactionIndex = transactionIndex; } + /** + * Gets transaction index raw. + * + * @return the transaction index raw + */ public String getTransactionIndexRaw() { return transactionIndex; } + /** + * Gets from. + * + * @return the from + */ public String getFrom() { return from; } + /** + * Sets from. + * + * @param from the from + */ public void setFrom(String from) { this.from = from; } + /** + * Gets to. + * + * @return the to + */ public String getTo() { return to; } + /** + * Sets to. + * + * @param to the to + */ public void setTo(String to) { this.to = to; } + /** + * Gets value. + * + * @return the value + */ public BigInteger getValue() { return Numeric.decodeQuantity(value); } + /** + * Sets value. + * + * @param value the value + */ public void setValue(String value) { this.value = value; } + /** + * Gets value raw. + * + * @return the value raw + */ public String getValueRaw() { return value; } + /** + * Gets gas price. + * + * @return the gas price + */ public BigInteger getGasPrice() { return Numeric.decodeQuantity(gasPrice); } + /** + * Sets gas price. + * + * @param gasPrice the gas price + */ public void setGasPrice(String gasPrice) { this.gasPrice = gasPrice; } + /** + * Gets gas price raw. + * + * @return the gas price raw + */ public String getGasPriceRaw() { return gasPrice; } + /** + * Gets gas. + * + * @return the gas + */ public BigInteger getGas() { return Numeric.decodeQuantity(gas); } + /** + * Sets gas. + * + * @param gas the gas + */ public void setGas(String gas) { this.gas = gas; } + /** + * Gets gas raw. + * + * @return the gas raw + */ public String getGasRaw() { return gas; } + /** + * Gets input. + * + * @return the input + */ public String getInput() { return input; } + /** + * Sets input. + * + * @param input the input + */ public void setInput(String input) { this.input = input; } + /** + * Gets creates. + * + * @return the creates + */ public String getCreates() { return creates; } + /** + * Sets creates. + * + * @param creates the creates + */ public void setCreates(String creates) { this.creates = creates; } + /** + * Gets public key. + * + * @return the public key + */ public String getPublicKey() { return publicKey; } + /** + * Sets public key. + * + * @param publicKey the public key + */ public void setPublicKey(String publicKey) { this.publicKey = publicKey; } + /** + * Gets raw. + * + * @return the raw + */ public String getRaw() { return raw; } + /** + * Sets raw. + * + * @param raw the raw + */ public void setRaw(String raw) { this.raw = raw; } + /** + * Gets r. + * + * @return the r + */ public String getR() { return r; } + /** + * Sets r. + * + * @param r the r + */ public void setR(String r) { this.r = r; } + /** + * Gets s. + * + * @return the s + */ public String getS() { return s; } + /** + * Sets s. + * + * @param s the s + */ public void setS(String s) { this.s = s; } + /** + * Gets v. + * + * @return the v + */ public long getV() { return v; } + /** + * Sets v. + * + * @param v the v + */ // Workaround until Geth & Parity return consistent values. At present // Parity returns a byte value, Geth returns a hex-encoded string // https://github.com/ethereum/go-ethereum/issues/3339 @@ -358,14 +630,29 @@ public void setV(Object v) { } } + /** + * Gets parity. + * + * @return the parity + */ public String getyParity() { return yParity; } + /** + * Sets parity. + * + * @param yParity the y parity + */ public void setyParity(String yParity) { this.yParity = yParity; } + /** + * Gets chain id. + * + * @return the chain id + */ public Long getChainId() { if (chainId != null) { return Numeric.decodeQuantity(chainId).longValue(); @@ -374,91 +661,201 @@ public Long getChainId() { return TransactionUtils.deriveChainId(v); } + /** + * Gets chain id raw. + * + * @return the chain id raw + */ public String getChainIdRaw() { return this.chainId; } + /** + * Gets type. + * + * @return the type + */ public String getType() { return type; } + /** + * Sets type. + * + * @param type the type + */ public void setType(String type) { this.type = type; } + /** + * Gets max fee per gas. + * + * @return the max fee per gas + */ public BigInteger getMaxFeePerGas() { if (maxFeePerGas == null) return null; return Numeric.decodeQuantity(maxFeePerGas); } + /** + * Gets max fee per gas raw. + * + * @return the max fee per gas raw + */ public String getMaxFeePerGasRaw() { return maxFeePerGas; } + /** + * Sets max fee per gas. + * + * @param maxFeePerGas the max fee per gas + */ public void setMaxFeePerGas(String maxFeePerGas) { this.maxFeePerGas = maxFeePerGas; } + /** + * Gets max priority fee per gas raw. + * + * @return the max priority fee per gas raw + */ public String getMaxPriorityFeePerGasRaw() { return maxPriorityFeePerGas; } + /** + * Gets max priority fee per gas. + * + * @return the max priority fee per gas + */ public BigInteger getMaxPriorityFeePerGas() { return Numeric.decodeQuantity(maxPriorityFeePerGas); } + /** + * Sets max priority fee per gas. + * + * @param maxPriorityFeePerGas the max priority fee per gas + */ public void setMaxPriorityFeePerGas(String maxPriorityFeePerGas) { this.maxPriorityFeePerGas = maxPriorityFeePerGas; } + /** + * Gets access list. + * + * @return the access list + */ public List getAccessList() { return accessList; } + /** + * Sets access list. + * + * @param accessList the access list + */ public void setAccessList(List accessList) { this.accessList = accessList; } + /** + * Gets max fee per blob gas raw. + * + * @return the max fee per blob gas raw + */ public String getMaxFeePerBlobGasRaw() { return maxFeePerBlobGas; } + /** + * Gets max fee per blob gas. + * + * @return the max fee per blob gas + */ public BigInteger getMaxFeePerBlobGas() { return Numeric.decodeQuantity(maxFeePerBlobGas); } + /** + * Sets max fee per blob gas. + * + * @param maxFeePerBlobGas the max fee per blob gas + */ public void setMaxFeePerBlobGas(String maxFeePerBlobGas) { this.maxFeePerBlobGas = maxFeePerBlobGas; } + /** + * Gets blob versioned hashes. + * + * @return the blob versioned hashes + */ public List getBlobVersionedHashes() { return blobVersionedHashes; } + /** + * Sets blob versioned hashes. + * + * @param blobVersionedHashes the blob versioned hashes + */ public void setBlobVersionedHashes(List blobVersionedHashes) { this.blobVersionedHashes = blobVersionedHashes; } + /** + * Gets source hash. + * + * @return the source hash + */ public String getSourceHash() { return sourceHash; } + /** + * Sets source hash. + * + * @param sourceHash the source hash + */ public void setSourceHash(String sourceHash) { this.sourceHash = sourceHash; } + /** + * Gets mint. + * + * @return the mint + */ public String getMint() { return mint; } + /** + * Sets mint. + * + * @param mint the mint + */ public void setMint(String mint) { this.mint = mint; } + /** + * Gets deposit receipt version. + * + * @return the deposit receipt version + */ public String getDepositReceiptVersion() { return depositReceiptVersion; } + /** + * Sets deposit receipt version. + * + * @param depositReceiptVersion the deposit receipt version + */ public void setDepositReceiptVersion(String depositReceiptVersion) { this.depositReceiptVersion = depositReceiptVersion; }