Skip to content

Commit

Permalink
solution: annotation-based json mapping for Tx Receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
splix committed Apr 29, 2024
1 parent 67d50c8 commit 270ea99
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.util.List;
import java.util.Objects;

@JsonDeserialize(using = TransactionLogJsonDeserializer.class)
@JsonSerialize(using = TransactionLogJsonSerializer.class)
public class TransactionLogJson implements TransactionRef, Serializable {

/**
Expand All @@ -42,11 +40,15 @@ public class TransactionLogJson implements TransactionRef, Serializable {
/**
* log index position in the block. null when its pending log.
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long logIndex;

/**
* transactions index position log was created from. null when its pending log.
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long transactionIndex;

/**
Expand All @@ -62,6 +64,8 @@ public class TransactionLogJson implements TransactionRef, Serializable {
/**
* the block number where this log was in. null when its pending. null when its pending log.
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long blockNumber;

/**
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import java.util.List;
import java.util.Objects;

@JsonDeserialize(using = TransactionReceiptJsonDeserializer.class)
@JsonSerialize(using = TransactionReceiptJsonSerializer.class)
public class TransactionReceiptJson implements TransactionRef, Serializable {

/**
Expand All @@ -37,6 +35,8 @@ public class TransactionReceiptJson implements TransactionRef, Serializable {
/**
* position in the block
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long transactionIndex;

/**
Expand All @@ -47,11 +47,15 @@ public class TransactionReceiptJson implements TransactionRef, Serializable {
/**
* block number where this transaction was in
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long blockNumber;

/**
* total amount of gas used when this transaction was executed in the block.
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long cumulativeGasUsed;

/**
Expand All @@ -67,6 +71,8 @@ public class TransactionReceiptJson implements TransactionRef, Serializable {
/**
* amount of gas used by this specific transaction alone.
*/
@JsonDeserialize(using = HexLongDeserializer.class)
@JsonSerialize(using = HexLongSerializer.class)
private Long gasUsed;

/**
Expand All @@ -82,8 +88,10 @@ public class TransactionReceiptJson implements TransactionRef, Serializable {
private Bloom logsBloom;

/**
* Optinal tx status. 0 if failed, 1 if successfull
* Optional tx status. 0 if failed, 1 if successfull
*/
@JsonDeserialize(using = HexIntDeserializer.class)
@JsonSerialize(using = HexIntSerializer.class)
private Integer status;

private Wei effectiveGasPrice;
Expand All @@ -93,7 +101,9 @@ public class TransactionReceiptJson implements TransactionRef, Serializable {
*
* @see <a href="https://eips.ethereum.org/EIPS/eip-2718">EIP-2718: Typed Transaction Envelope</a>
*/
private int type = 0;
@JsonDeserialize(using = HexIntDeserializer.class)
@JsonSerialize(using = HexIntSerializer.class)
private Integer type = 0;

public TransactionId getTransactionHash() {
return transactionHash;
Expand Down Expand Up @@ -200,6 +210,9 @@ public void setEffectiveGasPrice(Wei effectiveGasPrice) {
}

public int getType() {
if (type == null) {
return 0;
}
return type;
}

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 270ea99

Please sign in to comment.