From 78e5e95da0d13a7d4cf179aba529e683d28cf5ab Mon Sep 17 00:00:00 2001 From: Igor Artamonov Date: Mon, 29 Apr 2024 14:15:58 +0100 Subject: [PATCH] problem: unused classes --- .../rpc/json/TransactionJsonDeserializer.java | 105 ------------------ .../rpc/json/TransactionJsonSerializer.java | 89 --------------- 2 files changed, 194 deletions(-) delete mode 100644 etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonDeserializer.java delete mode 100644 etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonSerializer.java diff --git a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonDeserializer.java b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonDeserializer.java deleted file mode 100644 index 7c13474..0000000 --- a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonDeserializer.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved. - * Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved. - * - * 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 io.emeraldpay.etherjar.rpc.json; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonNode; -import io.emeraldpay.etherjar.domain.Address; -import io.emeraldpay.etherjar.domain.ChainId; -import io.emeraldpay.etherjar.domain.TransactionId; -import io.emeraldpay.etherjar.domain.TransactionSignature; -import io.emeraldpay.etherjar.hex.Hex32; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class TransactionJsonDeserializer extends EtherJsonDeserializer { - - @Override - public TransactionJson deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - JsonNode node = jp.readValueAsTree(); - return deserialize(node); - } - - public TransactionJson deserialize(JsonNode node) { - TransactionJson tx = new TransactionJson(); - tx.setHash(getTxHash(node, "hash")); - tx.setNonce(getLong(node, "nonce")); - tx.setBlockHash(getBlockHash(node, "blockHash")); - Integer type = getInt(node, "type"); - if (type != null) { - tx.setType(type); - } - Integer chainId = getInt(node, "chainId"); - if (chainId != null) { - tx.setChainId(chainId); - } - Long blockNumber = getLong(node, "blockNumber"); - if (blockNumber != null) { - tx.setBlockNumber(blockNumber); - } - Long txIndex = getLong(node, "transactionIndex"); - if (txIndex != null) { - tx.setTransactionIndex(txIndex); - } - tx.setFrom(getAddress(node, "from")); - tx.setTo(getAddress(node, "to")); - tx.setValue(getWei(node, "value")); - tx.setGasPrice(getWei(node, "gasPrice")); - tx.setMaxFeePerGas(getWei(node, "maxFeePerGas")); - tx.setMaxPriorityFeePerGas(getWei(node, "maxPriorityFeePerGas")); - tx.setGas(getLong(node, "gas")); - tx.setInput(getData(node, "input")); - - if (node.has("r") && node.has("v") && node.has("s")) { - TransactionSignature signature = new TransactionSignature(); - - if (node.hasNonNull("networkId")) { - signature.setChainId(new ChainId(node.get("networkId").intValue())); - } - signature.setR(getData(node, "r")); - signature.setS(getData(node, "s")); - signature.setV(getLong(node, "v").intValue()); -// signature.setPublicKey(getData(node, "publicKey")); - - tx.setSignature(signature); - } - - if (node.has("accessList")) { - List accessList = new ArrayList<>(); - for (JsonNode access : node.get("accessList")) { - Address address = getAddress(access, "address"); - if (access.has("storageKeys")) { - List storageKeys = new ArrayList<>(); - for (JsonNode storageKey : access.get("storageKeys")) { - storageKeys.add(Hex32.from(storageKey.textValue())); - } - accessList.add(new TransactionJson.Access(address, storageKeys)); - } else { - accessList.add(new TransactionJson.Access(address)); - } - } - tx.setAccessList(accessList); - } - - return tx; - } -} diff --git a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonSerializer.java b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonSerializer.java deleted file mode 100644 index bf9fb9f..0000000 --- a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJsonSerializer.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved. - * - * 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 io.emeraldpay.etherjar.rpc.json; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.SerializerProvider; -import io.emeraldpay.etherjar.domain.TransactionSignature; -import io.emeraldpay.etherjar.domain.Wei; -import io.emeraldpay.etherjar.hex.Hex32; - -import java.io.IOException; -import java.util.List; - -public class TransactionJsonSerializer extends EtherJsonSerializer { - @Override - public void serialize(TransactionJson value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - gen.writeStartObject(); - writeField(gen, "hash", value.getHash()); - writeField(gen, "nonce", value.getNonce()); - writeField(gen, "blockHash", value.getBlockHash()); - writeField(gen, "blockNumber", value.getBlockNumber()); - if (value.getType() != 0) { - writeField(gen, "type", value.getType()); - } - writeField(gen, "chainId", value.getChainId()); - writeField(gen, "maxFeePerGas", value.getMaxFeePerGas()); - writeField(gen, "maxPriorityFeePerGas", value.getMaxPriorityFeePerGas()); - if (value.getTransactionIndex() != null) { - writeField(gen, "transactionIndex", value.getTransactionIndex().intValue()); - } - writeField(gen, "from", value.getFrom()); - if (value.getTo() == null) { - gen.writeNullField("to"); - } else { - writeField(gen, "to", value.getTo()); - } - writeField(gen, "creates", value.getCreates()); - writeField(gen, "value", value.getValue()); - writeField(gen, "gasPrice", value.getGasPrice()); - writeField(gen, "gas", value.getGas()); - writeField(gen, "input", value.getInput()); - TransactionSignature signature = value.getSignature(); - if (signature != null) { - if (signature.getChainId() != null) { - writeField(gen, "networkId", signature.getChainId().getValue()); - } - writeField(gen, "r", signature.getR()); - writeField(gen, "s", signature.getS()); - if (signature.getV() != null) { - writeField(gen, "v", signature.getV().longValue()); - } -// writeField(gen, "publicKey", signature.getPublicKey()); - } - List accessList = value.getAccessList(); - if (accessList != null) { - gen.writeFieldName("accessList"); - gen.writeStartArray(); - for (TransactionJson.Access access : accessList) { - gen.writeStartObject(); - writeField(gen, "address", access.getAddress()); - gen.writeFieldName("storageKeys"); - gen.writeStartArray(); - List storageKeys = access.getStorageKeys(); - if (storageKeys != null) { - for (Hex32 key : storageKeys) { - gen.writeString(key.toHex()); - } - } - gen.writeEndArray(); - gen.writeEndObject(); - } - gen.writeEndArray(); - } - gen.writeEndObject(); - } -}