Skip to content

Commit

Permalink
add parentBeaconBlockRoot field
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkAfCod committed Mar 4, 2024
1 parent b54cfa4 commit 93c6e5d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static class Block {
private String number;
private String hash;
private String parentHash;
private String parentBeaconBlockRoot;
private String nonce;
private String sha3Uncles;
private String logsBloom;
Expand Down Expand Up @@ -93,6 +94,7 @@ public Block(
String number,
String hash,
String parentHash,
String parentBeaconBlockRoot,
String nonce,
String sha3Uncles,
String logsBloom,
Expand Down Expand Up @@ -120,6 +122,7 @@ public Block(
this.number = number;
this.hash = hash;
this.parentHash = parentHash;
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
this.nonce = nonce;
this.sha3Uncles = sha3Uncles;
this.logsBloom = logsBloom;
Expand Down Expand Up @@ -227,6 +230,14 @@ public void setParentHash(String parentHash) {
this.parentHash = parentHash;
}

public String getParentBeaconBlockRoot() {
return parentBeaconBlockRoot;
}

public void setParentBeaconBlockRoot(String parentBeaconBlockRoot) {
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
}

public BigInteger getNonce() {
return Numeric.decodeQuantity(nonce);
}
Expand Down Expand Up @@ -488,6 +499,11 @@ public boolean equals(Object o) {
: block.getParentHash() != null) {
return false;
}
if (getParentBeaconBlockRoot() != null
? !getParentBeaconBlockRoot().equals(block.getParentBeaconBlockRoot())
: block.getParentBeaconBlockRoot() != null) {
return false;
}
if (getNonceRaw() != null
? !getNonceRaw().equals(block.getNonceRaw())
: block.getNonceRaw() != null) {
Expand Down Expand Up @@ -619,6 +635,7 @@ public int hashCode() {
int result = getNumberRaw() != null ? getNumberRaw().hashCode() : 0;
result = 31 * result + (getHash() != null ? getHash().hashCode() : 0);
result = 31 * result + (getParentHash() != null ? getParentHash().hashCode() : 0);
result = 31 * result + (getParentBeaconBlockRoot() != null ? getParentBeaconBlockRoot().hashCode() : 0);
result = 31 * result + (getNonceRaw() != null ? getNonceRaw().hashCode() : 0);
result = 31 * result + (getSha3Uncles() != null ? getSha3Uncles().hashCode() : 0);
result = 31 * result + (getLogsBloom() != null ? getLogsBloom().hashCode() : 0);
Expand Down
4 changes: 4 additions & 0 deletions core/src/test/java/org/web3j/protocol/core/ResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ public void testEthBlockTransactionHashes() {
+ " \"number\": \"0x1b4\",\n"
+ " \"hash\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
+ " \"parentHash\": \"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5\",\n"
+ " \"parentBeaconBlockRoot\": \"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169\",\n"
+ " \"nonce\": \"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2\",\n"
+ " \"sha3Uncles\": \"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\n"
+ " \"logsBloom\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
Expand Down Expand Up @@ -675,6 +676,7 @@ public void testEthBlockTransactionHashes() {
"0x1b4",
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169",
"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
Expand Down Expand Up @@ -872,6 +874,7 @@ public void testEthBlockFullTransactionsWithBlob() {
+ " \"number\": \"0x1b4\",\n"
+ " \"hash\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
+ " \"parentHash\": \"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5\",\n"
+ " \"parentBeaconBlockRoot\": \"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169\",\n"
+ " \"nonce\": \"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2\",\n"
+ " \"sha3Uncles\": \"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347\",\n"
+ " \"logsBloom\": \"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331\",\n"
Expand Down Expand Up @@ -950,6 +953,7 @@ public void testEthBlockFullTransactionsWithBlob() {
"0x1b4",
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"0x87996eeac031318cd38ee5de92b630676da7263b697a93ff55d0ad88c142e169",
"0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testEthBlockNullSize() {
new EthBlock.Block(
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null);
null, null, null, null);

assertEquals(ethBlock.getSize(), BigInteger.ZERO);
}
Expand All @@ -36,8 +36,8 @@ public void testEthBlockNotNullSize() {
EthBlock.Block ethBlock =
new EthBlock.Block(
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, "0x3e8", null, null, null, null, null, null, null, null,
null, null, null);
null, null, null, null, "0x3e8", null, null, null, null, null, null, null,
null, null, null, null);

assertEquals(ethBlock.getSize(), BigInteger.valueOf(1000));
}
Expand Down

0 comments on commit 93c6e5d

Please sign in to comment.