diff --git a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJson.java b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJson.java index 384be83..cb3008e 100644 --- a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJson.java +++ b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionJson.java @@ -240,6 +240,7 @@ public void setInput(HexData input) { this.input = input; } + @JsonIgnore public TransactionSignature getSignature() { if (signature != null) { return signature; @@ -256,6 +257,7 @@ public TransactionSignature getSignature() { return created; } + @JsonIgnore public void setSignature(TransactionSignature signature) { this.signature = signature; } diff --git a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionLogJson.java b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionLogJson.java index bc12389..6e47ebf 100644 --- a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionLogJson.java +++ b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionLogJson.java @@ -17,6 +17,7 @@ package io.emeraldpay.etherjar.rpc.json; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -163,6 +164,7 @@ public void setTopics(List topics) { } @Override + @JsonIgnore public TransactionId getHash() { return transactionHash; } diff --git a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionReceiptJson.java b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionReceiptJson.java index fff4a19..30b9943 100644 --- a/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionReceiptJson.java +++ b/etherjar-rpc-json/src/main/java/io/emeraldpay/etherjar/rpc/json/TransactionReceiptJson.java @@ -17,6 +17,7 @@ package io.emeraldpay.etherjar.rpc.json; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -253,6 +254,7 @@ public void setRoot(Hex32 root) { } @Override + @JsonIgnore public TransactionId getHash() { return transactionHash; } diff --git a/etherjar-rpc-json/src/test/groovy/io/emeraldpay/etherjar/rpc/json/TransactionLogJsonSpec.groovy b/etherjar-rpc-json/src/test/groovy/io/emeraldpay/etherjar/rpc/json/TransactionLogJsonSpec.groovy index 07cea6b..de3207e 100644 --- a/etherjar-rpc-json/src/test/groovy/io/emeraldpay/etherjar/rpc/json/TransactionLogJsonSpec.groovy +++ b/etherjar-rpc-json/src/test/groovy/io/emeraldpay/etherjar/rpc/json/TransactionLogJsonSpec.groovy @@ -1,10 +1,18 @@ package io.emeraldpay.etherjar.rpc.json +import com.fasterxml.jackson.databind.ObjectMapper +import io.emeraldpay.etherjar.domain.Address +import io.emeraldpay.etherjar.domain.TransactionId import io.emeraldpay.etherjar.hex.Hex32 +import io.emeraldpay.etherjar.hex.HexData +import io.emeraldpay.etherjar.rpc.JacksonRpcConverter import spock.lang.Specification class TransactionLogJsonSpec extends Specification { + JacksonRpcConverter jacksonRpcConverter = new JacksonRpcConverter() + ObjectMapper objectMapper = jacksonRpcConverter.getObjectMapper() + def "Equals with topics values"() { setup: // val1 and val2 topics are both lists, but different implementations @@ -75,4 +83,26 @@ class TransactionLogJsonSpec extends Specification { equals33 !equals34 } + + def "Should not generate extra hash field"() { + setup: + + def tx = new TransactionLogJson() + tx.transactionHash = TransactionId.from("0xc765d3a679254d60a519d83f33059f882875ad67d4114fb3de4c87a446fd0e52") + tx.setTopics([ + Hex32.from("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"), + Hex32.from("0x00000000000000000000000009b77fda4f5d9016d2cbe1d9fd12d465df8f96d5"), + Hex32.from("0x000000000000000000000000ef8801eaf234ff82801821ffe2d78d60a0237f97"), + ]) + tx.data = HexData.from("0x0000000000000000000000000000000000000000000000000000000012113a25") + tx.address = Address.from("0xdAC17F958D2ee523a2206206994597C13D831ec7") + + when: + def json = objectMapper.writeValueAsString(tx) + + then: + json.contains("\"transactionHash\":") + !json.contains("\"hash\":") + json.findAll("0xc765d3a679254d60a519d83f33059f882875ad67d4114fb3de4c87a446fd0e52").size() == 1 + } }