diff --git a/core/src/main/java/org/web3j/protocol/core/Ethereum.java b/core/src/main/java/org/web3j/protocol/core/Ethereum.java index 49a405251..c7028973f 100644 --- a/core/src/main/java/org/web3j/protocol/core/Ethereum.java +++ b/core/src/main/java/org/web3j/protocol/core/Ethereum.java @@ -39,6 +39,7 @@ import org.web3j.protocol.core.methods.response.EthGetBlockTransactionCountByNumber; import org.web3j.protocol.core.methods.response.EthGetCode; import org.web3j.protocol.core.methods.response.EthGetCompilers; +import org.web3j.protocol.core.methods.response.EthGetProof; import org.web3j.protocol.core.methods.response.EthGetStorageAt; import org.web3j.protocol.core.methods.response.EthGetTransactionCount; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; @@ -202,6 +203,8 @@ Request ethGetUncleByBlockNumberAndIndex( Request ethGetLogs(org.web3j.protocol.core.methods.request.EthFilter ethFilter); + Request ethGetProof(String address, List storageKeys, String quantity); + Request ethGetWork(); Request ethSubmitWork(String nonce, String headerPowHash, String mixDigest); diff --git a/core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java b/core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java index c08086414..9a36b9873 100644 --- a/core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java +++ b/core/src/main/java/org/web3j/protocol/core/JsonRpc2_0Web3j.java @@ -51,6 +51,7 @@ import org.web3j.protocol.core.methods.response.EthGetBlockTransactionCountByNumber; import org.web3j.protocol.core.methods.response.EthGetCode; import org.web3j.protocol.core.methods.response.EthGetCompilers; +import org.web3j.protocol.core.methods.response.EthGetProof; import org.web3j.protocol.core.methods.response.EthGetStorageAt; import org.web3j.protocol.core.methods.response.EthGetTransactionCount; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; @@ -568,6 +569,16 @@ public Request ethGetLogs( return new Request<>("eth_getLogs", Arrays.asList(ethFilter), web3jService, EthLog.class); } + @Override + public Request ethGetProof( + String address, List storageKeys, String quantity) { + return new Request<>( + "eth_getProof", + Arrays.asList(address, storageKeys, quantity), + web3jService, + EthGetProof.class); + } + @Override public Request ethGetWork() { return new Request<>( diff --git a/core/src/main/java/org/web3j/protocol/core/methods/response/EthGetProof.java b/core/src/main/java/org/web3j/protocol/core/methods/response/EthGetProof.java new file mode 100644 index 000000000..9906c9843 --- /dev/null +++ b/core/src/main/java/org/web3j/protocol/core/methods/response/EthGetProof.java @@ -0,0 +1,432 @@ +/* + * Copyright 2023 Web3 Labs Ltd. + * + * 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 org.web3j.protocol.core.methods.response; + +import java.io.IOException; +import java.math.BigInteger; +import java.util.List; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +import org.web3j.protocol.ObjectMapperFactory; +import org.web3j.protocol.core.Response; +import org.web3j.utils.Numeric; + +/** + * eth_getProof api response. + * + * @author thinkAfCod + * @since 2023.06 + */ +public class EthGetProof extends Response { + + @Override + @JsonDeserialize(using = EthGetProof.ResponseDeserializer.class) + public void setResult(EthGetProof.Proof result) { + super.setResult(result); + } + + /** + * get proof result. + * + * @return proof result + */ + public EthGetProof.Proof getProof() { + return getResult(); + } + + /** Instantiates a new Eth get proof. */ + public EthGetProof() {} + + /** json rpc result of object. */ + public static class Proof { + + private String address; + + private String balance; + + private String codeHash; + + private String nonce; + + private String storageHash; + + private List accountProof; + + private List storageProof; + + /** Instantiates a new Proof. */ + public Proof() {} + + /** + * Instantiates a new Proof. + * + * @param address the address + * @param balance the balance + * @param codeHash the code hash + * @param nonce the nonce + * @param storageHash the storage hash + * @param accountProof the account proof + * @param storageProof the storage proof + */ + public Proof( + String address, + String balance, + String codeHash, + String nonce, + String storageHash, + List accountProof, + List storageProof) { + this.address = address; + this.balance = balance; + this.codeHash = codeHash; + this.nonce = nonce; + this.storageHash = storageHash; + this.accountProof = accountProof; + this.storageProof = storageProof; + } + + /** + * Gets address. + * + * @return the address + */ + public String getAddress() { + return address; + } + + /** + * Sets address. + * + * @param address the address + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * Gets balance raw. + * + * @return the balance raw + */ + public String getBalanceRaw() { + return this.balance; + } + + /** + * Gets balance. + * + * @return the balance + */ + public BigInteger getBalance() { + return Numeric.decodeQuantity(balance); + } + + /** + * Sets balance. + * + * @param balance the balance + */ + public void setBalance(String balance) { + this.balance = balance; + } + + /** + * Gets code hash. + * + * @return the code hash + */ + public String getCodeHash() { + return codeHash; + } + + /** + * Sets code hash. + * + * @param codeHash the code hash + */ + public void setCodeHash(String codeHash) { + this.codeHash = codeHash; + } + + /** + * Gets nonce. + * + * @return the nonce + */ + public String getNonce() { + return nonce; + } + + /** + * Sets nonce. + * + * @param nonce the nonce + */ + public void setNonce(String nonce) { + this.nonce = nonce; + } + + /** + * Gets storage hash. + * + * @return the storage hash + */ + public String getStorageHash() { + return storageHash; + } + + /** + * Sets storage hash. + * + * @param storageHash the storage hash + */ + public void setStorageHash(String storageHash) { + this.storageHash = storageHash; + } + + /** + * Gets account proof. + * + * @return the account proof + */ + public List getAccountProof() { + return accountProof; + } + + /** + * Sets account proof. + * + * @param accountProof the account proof + */ + public void setAccountProof(List accountProof) { + this.accountProof = accountProof; + } + + /** + * Gets storage proof. + * + * @return the storage proof + */ + public List getStorageProof() { + return storageProof; + } + + /** + * Sets storage proof. + * + * @param storageProof the storage proof + */ + public void setStorageProof(List storageProof) { + this.storageProof = storageProof; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof EthGetProof.Proof)) { + return false; + } + EthGetProof.Proof proof = (EthGetProof.Proof) o; + + if (getAddress() != null + ? !getAddress().equals(proof.getAddress()) + : proof.getAddress() != null) { + return false; + } + + if (getBalanceRaw() != null + ? !getBalanceRaw().equals(proof.getBalanceRaw()) + : proof.getBalanceRaw() != null) { + return false; + } + + if (getCodeHash() != null + ? !getCodeHash().equals(proof.getCodeHash()) + : proof.getCodeHash() != null) { + return false; + } + if (getNonce() != null + ? !getNonce().equals(proof.getNonce()) + : proof.getNonce() != null) { + return false; + } + + if (getStorageHash() != null + ? !getStorageHash().equals(proof.getStorageHash()) + : proof.getStorageHash() != null) { + return false; + } + + if (getAccountProof() != null + ? !getAccountProof().equals(proof.getAccountProof()) + : proof.getAccountProof() != null) { + return false; + } + + return getStorageProof() != null + ? getStorageProof().equals(proof.getStorageProof()) + : proof.getStorageProof() == null; + } + + @Override + public int hashCode() { + int result = getAddress() != null ? getAddress().hashCode() : 0; + result = 31 * result + (getBalanceRaw() != null ? getBalanceRaw().hashCode() : 0); + result = 31 * result + (getCodeHash() != null ? getCodeHash().hashCode() : 0); + result = 31 * result + (getNonce() != null ? getNonce().hashCode() : 0); + result = 31 * result + (getStorageHash() != null ? getStorageHash().hashCode() : 0); + result = 31 * result + (getAccountProof() != null ? getAccountProof().hashCode() : 0); + result = 31 * result + (getStorageProof() != null ? getStorageProof().hashCode() : 0); + return result; + } + } + + /** storage proof. */ + public static class StorageProof { + private String key; + + private String value; + + private List proof; + + /** Storage proof. */ + public StorageProof() {} + + /** + * Instantiates a new Storage proof. + * + * @param key the key + * @param value the value + * @param proof the proof + */ + public StorageProof(String key, String value, List proof) { + this.key = key; + this.value = value; + this.proof = proof; + } + + /** + * Gets key. + * + * @return the key + */ + public String getKey() { + return key; + } + + /** + * Sets key. + * + * @param key the key + */ + public void setKey(String key) { + this.key = key; + } + + /** + * Gets value. + * + * @return the value + */ + public String getValue() { + return value; + } + + /** + * Sets value. + * + * @param value the value + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets proof. + * + * @return the proof + */ + public List getProof() { + return proof; + } + + /** + * Sets proof. + * + * @param proof the proof + */ + public void setProof(List proof) { + this.proof = proof; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof StorageProof)) { + return false; + } + + StorageProof proof = (EthGetProof.StorageProof) o; + + if (getKey() != null ? !getKey().equals(proof.getKey()) : proof.getKey() != null) { + return false; + } + if (getValue() != null + ? !getValue().equals(proof.getValue()) + : proof.getValue() != null) { + return false; + } + return getProof() != null + ? getProof().equals(proof.getProof()) + : proof.getProof() == null; + } + + @Override + public int hashCode() { + int result = getKey() != null ? getKey().hashCode() : 0; + result = 31 * result + (getValue() != null ? getValue().hashCode() : 0); + result = 31 * result + (getProof() != null ? getProof().hashCode() : 0); + return result; + } + } + + /** Json Deserializer of Proof. */ + public static class ResponseDeserializer extends JsonDeserializer { + + /** Instantiates a new Response deserializer. */ + public ResponseDeserializer() {} + + private ObjectReader objectReader = ObjectMapperFactory.getObjectReader(); + + @Override + public EthGetProof.Proof deserialize( + JsonParser jsonParser, DeserializationContext deserializationContext) + throws IOException { + if (jsonParser.getCurrentToken() != JsonToken.VALUE_NULL) { + return objectReader.readValue(jsonParser, EthGetProof.Proof.class); + } else { + return null; // null is wrapped by Optional in above getter + } + } + } +} diff --git a/core/src/test/java/org/web3j/protocol/core/RequestTest.java b/core/src/test/java/org/web3j/protocol/core/RequestTest.java index 09d5efe21..3bc44c4ca 100644 --- a/core/src/test/java/org/web3j/protocol/core/RequestTest.java +++ b/core/src/test/java/org/web3j/protocol/core/RequestTest.java @@ -605,6 +605,22 @@ public void testEthGetLogsWithBlockHash() throws Exception { + "\"address\":[\"\"]}],\"id\":}"); } + @Test + public void testEthGetProof() throws Exception { + web3j.ethGetProof( + "0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842", + Arrays.asList( + "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), + "latest") + .send(); + verifyResult( + "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getProof\"," + + "\"params\":[\"0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842\"," + + "[\"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\"]," + + "\"latest\"]," + + "\"id\":0}"); + } + @Test public void testEthGetWork() throws Exception { web3j.ethGetWork().send(); diff --git a/core/src/test/java/org/web3j/protocol/core/ResponseTest.java b/core/src/test/java/org/web3j/protocol/core/ResponseTest.java index 921d5571a..6588e2d69 100644 --- a/core/src/test/java/org/web3j/protocol/core/ResponseTest.java +++ b/core/src/test/java/org/web3j/protocol/core/ResponseTest.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.math.BigInteger; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -47,6 +48,7 @@ import org.web3j.protocol.core.methods.response.EthGetBlockTransactionCountByNumber; import org.web3j.protocol.core.methods.response.EthGetCode; import org.web3j.protocol.core.methods.response.EthGetCompilers; +import org.web3j.protocol.core.methods.response.EthGetProof; import org.web3j.protocol.core.methods.response.EthGetStorageAt; import org.web3j.protocol.core.methods.response.EthGetTransactionCount; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; @@ -1501,6 +1503,62 @@ public void testEthLog() { assertEquals(ethLog.getLogs(), (logs)); } + @Test + public void testEthGetProof() { + buildResponse( + "{\n" + + " \"jsonrpc\": \"2.0\",\n" + + " \"id\": 1,\n" + + " \"result\": {\n" + + " \"address\": \"0x7f0d15c7faae65896648c8273b6d7e43f58fa842\",\n" + + " \"accountProof\": [\n" + + " \"0xf90211a08245f766623948f962b9f277955e4be3868d107042195746e5bb9b60e45c4a35a0f95891987a66390224caca18cf15d40288e85a58fee02b61b4e235a95844678ca04c783e1622a91a7cd4d06e82e654cc8bcd5b00a545889ff729f35ccd8387f5e3a08e28b463ee2ada55e1647c4c502976e5c09dcd94828e78d0ad09ab94db80a14aa0a41aaedbede9a14677796971bbe97ac152c4101471d62786208cf54bb7763818a02bc95a8f57339e1262460c02e885ab2fc03762a7a646693b659e64889522ca3aa075772fb16c66643216c7ab93eb2c96d28142b8c99573f4fcdce41b9064a303d1a0da840a0f8f62bf404e1241139fb6d6eedf56e5ea7fed9e79001bbc31806d7168a0550099050860af73557452539c5bd055324400969f76b4643b531a8fef7c4ad2a02de16af6ab3f4205295bdd828e81c97930413ee3dd8e0aa76268909492c0f646a0ab2f8ba58a07310e12c7140427278f5715cbf975b735bac5d2338c487b2b615ca004725301c50e47bfa03c8495b5f009ee5aac8b15581dc6e9f5870c63e8fcc118a0cbd9efe9133d519ca35327c90c3b102972967e35e4432e4d0ce8416311267b7ca04e8d4cd1b3d110571ed885ccd470458a86e2dcf1fd083f1c2b9118001d4fc89ea03c6135b75f89e3b5c24c1354638e1a10c2248e5d7bc87df2d8230910660d3d84a0186eea2111408bc02272677443c21e2533146a56785a6bc34f9180e2ba4b567880\",\n" + + " \"0xf90211a0ebfa45ac468954fd9f1e4d5c8b5b0015500b7e9f083e1626e05a03069d2d7b67a077e18486d90836a1816056a6fa8ed0339e15cf937ea87841e035ab26fd39057ea06e8c3b073ed5d7e86a205f0011f726b0a87f011b4e6e0521a287d378eda627a5a0b1decdb542bf89924e1022d9ab05e3dd9e2aca2f32f43489ce5723ddbe8b7a4fa0223dd0aa6c255a7b5a1e4b9753eacf599db92476baf674136f39b808d084991da0cbd89f24d151b9b23b147bf1bb71006d8661b19a8171cf26bb20842944a25ff1a0a380efa4b380cf41b0af35bb7a4f68c1a3988f9aa62c1a4c3c0bfd72d6c588c2a0c76f535a14cd7d869f5f01054cc72b827bd1c7b11df30138b98421a7c331d5a8a0d5b25d3d8a6c82f60c6eab724afed222f575824789d2d9f0768d46be39b7cbd1a0e2b2326a7ee7c454bde59d682367af495756b3c11408b7d97e3e84936ef4c5a1a00bb7e8a57023a0926c6683cd2a9a530b29d26d75d38872aeec1a21100b77fecba0288d0834990caaf30d2c6dfff07e52615e16c463e7256fab04ede25899d032f9a0dbb8748605aeb933068490238594afa7d93e018d04712d3d6af29fac9c81620fa0bae1aa9abe2c40e45f3274edeaba95f81a7e91da98c746bf31b21c280f100682a0c726027419c64dba7e2aeb5d1423b1fad6e773cb604668dc044671d5d5b18430a0cacd3a2b6c933e9a2148c7314d294d2f7356bb17900ac3b4faccd7f561cd6f1d80\",\n" + + " \"0xf90211a0d26a9a18bdeb7e2387f9d9375bbc1b987c45a58f3eaaa4d29df611f0618c17d4a0839e8f34f581129bf52277d6aab412bc9794866fa22e93938fffbf85896b067ba008d315b1fbb99070a424b7efdeb3a8a90d631e325dc48f5f8c36b67ca0244081a0c1436f0a1e74a33600455326571d9549e904724d2646c0c86bed0e226a687bd1a05699909cad5f4b507001ce88a887af4148fb7ee14ed0f93c7aa9635b66407f9da0cb5f6eb1cc89cef0e221aeef566c891fa46f456370d52a8b322e4917c2f9ad87a0da1425f08bbf9d0368d159cd810f33c2b19a6e5d0b15043dfac565cf03b57c77a0b26393ad5305e312a3e388deb50bec841bbcbec45317ffb7753114f3d6d37ff9a0c24f396b4ae01cb32a72880baff2db25843979103c3a4d1116698416e29439c4a0d6738cafb3d29dd438a2bf074d9b991636535b83b41f589189801ce75e94c5b7a02f2c355b91c78a6d5386a874a092b1d8e1c740408afb532721c1af0e905de5e3a01511013c45279c74536a5e538251c4dfd7594848ed570b48615b094ca83849dda05e12cb9b86dc6c2c1e0dd68f8c2a93c83d2eedb5dbba3969a2b6c7032e26fc7ca0cfa01a6943b11ca2be19dfa3b23d535395f17db6ac1fe1dd5172643e8ccd68f7a002ae61b52a9a0b09c4ca9866b69e4f10765c1f7778e2d4f2300183868f5fd151a039dc21a690fbeed9ea699959be8b2e76eed93b9da21d12ee4254d0a1c51dc87380\",\n" + + " \"0xf90211a05b44d7409dc085529b33905d01eb00210fb1c787998b88df5619fb6e3b860181a03bb3e5e3e8d979fd3bc86c602d6e6a57b1fc4c7f5f6a774b7e91af001cdef664a0a8fd61cceed0f8a639beca30fcd32411c0fcca5a102ff4a2656cde8c7eb858b4a0052e56ef09a9139a58d80329870ddc961e8ed112c8edc1325f71903fba84275ba0729ff34831623850f26d3601d7db1af2da69f115e9be8f9fa8454cc006b51403a09e56b2a68595be5b215cbc173a6e810137be55a748587eb81d172439018ee7aaa0fa5b27319522283b38e2d1abec5941b2d78e78fc40aa5a4b4476e36a0443311fa05b5f6d0058c46ea701f4ba42aabedb7b12e664a91f4b35c5519797df4c623f55a0947a7cbc568c23382aacbe508353c7f8ad299f3ea3eb471506c6b4291868b3e5a0f2313976f5c85685f419fc3022cf28fb9696c05ca27c44437f717f02e0154fbda01a96e6375ed8e8dc0749b2d45f93207d9219168a9eea142053a5e23e7a47232aa06f9d9145b92865e970f60dd81aa55ced05698090e9e23f341729be2a90ce7b96a01b6c084aad02ab8cfc5bdc0800b956db46853cfa8b9b47ff35867f02718f8130a0d7493eefde332cd1de8898096e9e8916cc7e320a6eb0ede2dc165fc5ed8803a1a0f0c6e212824552eee4b2479dae9b570041441e0cb0244d8bf045a73268aefda6a01e9045c2bc23b1610f20c3501862a067bfc80af7908344527c62faf1129fb43d80\",\n" + + " \"0xf90211a056e7736ac44b0a6d46f4a6e40abf6426866f7f29ab0637bc89c390b4f0dc7807a07aec46d6e64a9847c400021f5e0f0373592e676b11d15cdf22765addf1033f01a09c356f78e4889e626568761468ca4e44ce0cc78f08a40035fc9be23b1c1990a0a0d18cfe2360f9559b663f4a8864995420b54e0c4c6c7f33019d2467b67080fed5a08b3d08ef8de3638edabb423c901a6c1ca8b1ef93b41427b2d409be7198a89225a0df689118041c8f4b2751afbf3cb7be36540e52742362df3ded6f67e3a8024feea0a7e5e17854690d418ef89eb6753e1d36e96cadc4a186bcd8ce71f8665fbe6814a0367bc2399eee7dffeaf8aea140a3973cbced2ed904aa7e6c69443a4877bb7115a0b1f51cb2cb73acdce7ee790854c03d59940e415b6598bda7fa753c0ae0e129dda021f400618bbd2b1ac65d863146f3497feaca7e73df4a3cf211b0a95ec5f39b5ea0494ec6c1615466d244e80992aee4b2496b4c8adda7f7b989e776a715a7a72b4aa03d64c83151b47fdf8c16ce7845306575108c3b8c6b3f9ce8032b65f05fb5d017a0c68bc1b17e6a32dd438aec2ca6c8beea5dd53a3192971bbc484036c9431ead88a0580a8ef71765615a19afd214553866e2215f94eb72631335fa8ec0c5ad450e19a04eda5daea47af109418ad18cae8c124e790d66046ce9389376c4a965f919c725a0a0a6553d3fc52e639eac9c20dbb7cd8930eacaa8b35f8b8f3bb23afb53cc966580\",\n" + + " \"0xf90211a0597493b2845e511c876b84fad3925bb78c3922b3734208f20aff5461c7078e7ca0eb3723d662049847561ea31922b2ea5ab7a641ce7c14b5fa0ec346975d16c187a00e5c88ea26113f0295d8c682f1526f2fa7906bc422bfe9cc8b8f869686e179d4a0b94a30e2218afad53a0eacc505ea552a8288457847fcae72555aac638b52c46ea0d6430dd23ef9889e1272e494530d6ec89f080c49bf09f8a6ac634b153fa8ce5ca0e8c4de149f9b385e51fb66516a4d91b62dbd80ddedd4522e14d370da47f63e5aa0fa40fc95a8bdd7126c4db03b0c1a20c654aa22cf6f72024c4a0925d6f29fc9baa005c16a67b6ee21b8e9371064570b2f30342add57d7c45bc43df25fc680132186a0c2ed9529b58b672abd733db30ccac4e5ebeeedeb38418a5925e57b0f822df814a0d18e42474e815b62da57cf67bcd8ed1c90d4f8ecf8f6d0b2e66b9656be2686ada0e4dc3683f731f21c0c34a10d7ffac39b20a64ac326269433a5cacaeb90a8a17da0e3f8b04c275387c6222b6536967f2f1e6fc76dc6ee0e705d3e505f3d07e8bdd4a0deaf89533b13c20ff50ff3f03ff3a2daa8d1329a6a6d17a58c422cbe5ee2f80aa022b542269e108a24dc0ed74e62fc571185dcf398acfbf15a7fb6ce3e8aba50d6a0f29369f8c3d70bc9f472c2175ab5495edcf35a65527f67d391068c0275284307a0c93bd89abbea5ae96496a12d236323d11d2da9cde7a3b9fdb15d504f4ea1eda680\",\n" + + " \"0xf90151a000595129cf1c67ce97ed615df7184fb47a0d018d9147a2a7952a639e464cdfd380a052081f67d885b439bee62a1c4e09c02a1ec729aef4d92be6584a29141a79c5c7a0d99cae2bc3b6fc3e8e2767b4d7a5884b9b2d9d20da7890318beefcdb9c7346d58080a0f63571735d99e763dafadb03d1abe3a93a98740ecddc8514d13df46a35a8d94680a081870f4697e57436ccdd8bdc1d624d7bc07861748ff8b3a352334df68f2c03ada0f0252504ee8753335ecf0ca1f73cf13d4505783ed5110bf4e9b384a68ad88f69a0d38a18ef7b993c9ad2d848453e7722c26998ff3d63e243b99cdab0dabf84157ea06e5ad479dbda7f1647ed613e35d837f5d2c697ef34160f3665173186553ee9c280a0bf8371cac505b6ea0cb0f67ef744713f306a2455f3f8844cfa527c62db59c69980a0d6d689405b1cf73786c5fdabb55ec22f9b5712d1ba9c0bfcd46d4b93721fcac780\",\n" + + " \"0xf8669d37f29e142d49f8824d4e7f1735ec3da219687387629b5fccd86812df84b846f8440180a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a01d93f60f105899172f7255c030301c3af4564edd4a48577dbdc448aec7ddb0ac\"],\n" + + " \"balance\": \"0x0\",\n" + + " \"codeHash\": \"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470\",\n" + + " \"nonce\": \"0x0\",\n" + + " \"storageHash\": \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\n" + + " \"storageProof\": [{\n" + + " \"key\": \"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421\",\n" + + " \"value\": \"0x0\",\n" + + " \"proof\": []\n" + + " }]\n" + + " }\n" + + "}"); + + EthGetProof ethGetProof = deserialiseResponse(EthGetProof.class); + + EthGetProof.Proof proof = + new EthGetProof.Proof( + "0x7f0d15c7faae65896648c8273b6d7e43f58fa842", + "0x0", + "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", + "0x0", + "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + Arrays.asList( + "0xf90211a08245f766623948f962b9f277955e4be3868d107042195746e5bb9b60e45c4a35a0f95891987a66390224caca18cf15d40288e85a58fee02b61b4e235a95844678ca04c783e1622a91a7cd4d06e82e654cc8bcd5b00a545889ff729f35ccd8387f5e3a08e28b463ee2ada55e1647c4c502976e5c09dcd94828e78d0ad09ab94db80a14aa0a41aaedbede9a14677796971bbe97ac152c4101471d62786208cf54bb7763818a02bc95a8f57339e1262460c02e885ab2fc03762a7a646693b659e64889522ca3aa075772fb16c66643216c7ab93eb2c96d28142b8c99573f4fcdce41b9064a303d1a0da840a0f8f62bf404e1241139fb6d6eedf56e5ea7fed9e79001bbc31806d7168a0550099050860af73557452539c5bd055324400969f76b4643b531a8fef7c4ad2a02de16af6ab3f4205295bdd828e81c97930413ee3dd8e0aa76268909492c0f646a0ab2f8ba58a07310e12c7140427278f5715cbf975b735bac5d2338c487b2b615ca004725301c50e47bfa03c8495b5f009ee5aac8b15581dc6e9f5870c63e8fcc118a0cbd9efe9133d519ca35327c90c3b102972967e35e4432e4d0ce8416311267b7ca04e8d4cd1b3d110571ed885ccd470458a86e2dcf1fd083f1c2b9118001d4fc89ea03c6135b75f89e3b5c24c1354638e1a10c2248e5d7bc87df2d8230910660d3d84a0186eea2111408bc02272677443c21e2533146a56785a6bc34f9180e2ba4b567880", + "0xf90211a0ebfa45ac468954fd9f1e4d5c8b5b0015500b7e9f083e1626e05a03069d2d7b67a077e18486d90836a1816056a6fa8ed0339e15cf937ea87841e035ab26fd39057ea06e8c3b073ed5d7e86a205f0011f726b0a87f011b4e6e0521a287d378eda627a5a0b1decdb542bf89924e1022d9ab05e3dd9e2aca2f32f43489ce5723ddbe8b7a4fa0223dd0aa6c255a7b5a1e4b9753eacf599db92476baf674136f39b808d084991da0cbd89f24d151b9b23b147bf1bb71006d8661b19a8171cf26bb20842944a25ff1a0a380efa4b380cf41b0af35bb7a4f68c1a3988f9aa62c1a4c3c0bfd72d6c588c2a0c76f535a14cd7d869f5f01054cc72b827bd1c7b11df30138b98421a7c331d5a8a0d5b25d3d8a6c82f60c6eab724afed222f575824789d2d9f0768d46be39b7cbd1a0e2b2326a7ee7c454bde59d682367af495756b3c11408b7d97e3e84936ef4c5a1a00bb7e8a57023a0926c6683cd2a9a530b29d26d75d38872aeec1a21100b77fecba0288d0834990caaf30d2c6dfff07e52615e16c463e7256fab04ede25899d032f9a0dbb8748605aeb933068490238594afa7d93e018d04712d3d6af29fac9c81620fa0bae1aa9abe2c40e45f3274edeaba95f81a7e91da98c746bf31b21c280f100682a0c726027419c64dba7e2aeb5d1423b1fad6e773cb604668dc044671d5d5b18430a0cacd3a2b6c933e9a2148c7314d294d2f7356bb17900ac3b4faccd7f561cd6f1d80", + "0xf90211a0d26a9a18bdeb7e2387f9d9375bbc1b987c45a58f3eaaa4d29df611f0618c17d4a0839e8f34f581129bf52277d6aab412bc9794866fa22e93938fffbf85896b067ba008d315b1fbb99070a424b7efdeb3a8a90d631e325dc48f5f8c36b67ca0244081a0c1436f0a1e74a33600455326571d9549e904724d2646c0c86bed0e226a687bd1a05699909cad5f4b507001ce88a887af4148fb7ee14ed0f93c7aa9635b66407f9da0cb5f6eb1cc89cef0e221aeef566c891fa46f456370d52a8b322e4917c2f9ad87a0da1425f08bbf9d0368d159cd810f33c2b19a6e5d0b15043dfac565cf03b57c77a0b26393ad5305e312a3e388deb50bec841bbcbec45317ffb7753114f3d6d37ff9a0c24f396b4ae01cb32a72880baff2db25843979103c3a4d1116698416e29439c4a0d6738cafb3d29dd438a2bf074d9b991636535b83b41f589189801ce75e94c5b7a02f2c355b91c78a6d5386a874a092b1d8e1c740408afb532721c1af0e905de5e3a01511013c45279c74536a5e538251c4dfd7594848ed570b48615b094ca83849dda05e12cb9b86dc6c2c1e0dd68f8c2a93c83d2eedb5dbba3969a2b6c7032e26fc7ca0cfa01a6943b11ca2be19dfa3b23d535395f17db6ac1fe1dd5172643e8ccd68f7a002ae61b52a9a0b09c4ca9866b69e4f10765c1f7778e2d4f2300183868f5fd151a039dc21a690fbeed9ea699959be8b2e76eed93b9da21d12ee4254d0a1c51dc87380", + "0xf90211a05b44d7409dc085529b33905d01eb00210fb1c787998b88df5619fb6e3b860181a03bb3e5e3e8d979fd3bc86c602d6e6a57b1fc4c7f5f6a774b7e91af001cdef664a0a8fd61cceed0f8a639beca30fcd32411c0fcca5a102ff4a2656cde8c7eb858b4a0052e56ef09a9139a58d80329870ddc961e8ed112c8edc1325f71903fba84275ba0729ff34831623850f26d3601d7db1af2da69f115e9be8f9fa8454cc006b51403a09e56b2a68595be5b215cbc173a6e810137be55a748587eb81d172439018ee7aaa0fa5b27319522283b38e2d1abec5941b2d78e78fc40aa5a4b4476e36a0443311fa05b5f6d0058c46ea701f4ba42aabedb7b12e664a91f4b35c5519797df4c623f55a0947a7cbc568c23382aacbe508353c7f8ad299f3ea3eb471506c6b4291868b3e5a0f2313976f5c85685f419fc3022cf28fb9696c05ca27c44437f717f02e0154fbda01a96e6375ed8e8dc0749b2d45f93207d9219168a9eea142053a5e23e7a47232aa06f9d9145b92865e970f60dd81aa55ced05698090e9e23f341729be2a90ce7b96a01b6c084aad02ab8cfc5bdc0800b956db46853cfa8b9b47ff35867f02718f8130a0d7493eefde332cd1de8898096e9e8916cc7e320a6eb0ede2dc165fc5ed8803a1a0f0c6e212824552eee4b2479dae9b570041441e0cb0244d8bf045a73268aefda6a01e9045c2bc23b1610f20c3501862a067bfc80af7908344527c62faf1129fb43d80", + "0xf90211a056e7736ac44b0a6d46f4a6e40abf6426866f7f29ab0637bc89c390b4f0dc7807a07aec46d6e64a9847c400021f5e0f0373592e676b11d15cdf22765addf1033f01a09c356f78e4889e626568761468ca4e44ce0cc78f08a40035fc9be23b1c1990a0a0d18cfe2360f9559b663f4a8864995420b54e0c4c6c7f33019d2467b67080fed5a08b3d08ef8de3638edabb423c901a6c1ca8b1ef93b41427b2d409be7198a89225a0df689118041c8f4b2751afbf3cb7be36540e52742362df3ded6f67e3a8024feea0a7e5e17854690d418ef89eb6753e1d36e96cadc4a186bcd8ce71f8665fbe6814a0367bc2399eee7dffeaf8aea140a3973cbced2ed904aa7e6c69443a4877bb7115a0b1f51cb2cb73acdce7ee790854c03d59940e415b6598bda7fa753c0ae0e129dda021f400618bbd2b1ac65d863146f3497feaca7e73df4a3cf211b0a95ec5f39b5ea0494ec6c1615466d244e80992aee4b2496b4c8adda7f7b989e776a715a7a72b4aa03d64c83151b47fdf8c16ce7845306575108c3b8c6b3f9ce8032b65f05fb5d017a0c68bc1b17e6a32dd438aec2ca6c8beea5dd53a3192971bbc484036c9431ead88a0580a8ef71765615a19afd214553866e2215f94eb72631335fa8ec0c5ad450e19a04eda5daea47af109418ad18cae8c124e790d66046ce9389376c4a965f919c725a0a0a6553d3fc52e639eac9c20dbb7cd8930eacaa8b35f8b8f3bb23afb53cc966580", + "0xf90211a0597493b2845e511c876b84fad3925bb78c3922b3734208f20aff5461c7078e7ca0eb3723d662049847561ea31922b2ea5ab7a641ce7c14b5fa0ec346975d16c187a00e5c88ea26113f0295d8c682f1526f2fa7906bc422bfe9cc8b8f869686e179d4a0b94a30e2218afad53a0eacc505ea552a8288457847fcae72555aac638b52c46ea0d6430dd23ef9889e1272e494530d6ec89f080c49bf09f8a6ac634b153fa8ce5ca0e8c4de149f9b385e51fb66516a4d91b62dbd80ddedd4522e14d370da47f63e5aa0fa40fc95a8bdd7126c4db03b0c1a20c654aa22cf6f72024c4a0925d6f29fc9baa005c16a67b6ee21b8e9371064570b2f30342add57d7c45bc43df25fc680132186a0c2ed9529b58b672abd733db30ccac4e5ebeeedeb38418a5925e57b0f822df814a0d18e42474e815b62da57cf67bcd8ed1c90d4f8ecf8f6d0b2e66b9656be2686ada0e4dc3683f731f21c0c34a10d7ffac39b20a64ac326269433a5cacaeb90a8a17da0e3f8b04c275387c6222b6536967f2f1e6fc76dc6ee0e705d3e505f3d07e8bdd4a0deaf89533b13c20ff50ff3f03ff3a2daa8d1329a6a6d17a58c422cbe5ee2f80aa022b542269e108a24dc0ed74e62fc571185dcf398acfbf15a7fb6ce3e8aba50d6a0f29369f8c3d70bc9f472c2175ab5495edcf35a65527f67d391068c0275284307a0c93bd89abbea5ae96496a12d236323d11d2da9cde7a3b9fdb15d504f4ea1eda680", + "0xf90151a000595129cf1c67ce97ed615df7184fb47a0d018d9147a2a7952a639e464cdfd380a052081f67d885b439bee62a1c4e09c02a1ec729aef4d92be6584a29141a79c5c7a0d99cae2bc3b6fc3e8e2767b4d7a5884b9b2d9d20da7890318beefcdb9c7346d58080a0f63571735d99e763dafadb03d1abe3a93a98740ecddc8514d13df46a35a8d94680a081870f4697e57436ccdd8bdc1d624d7bc07861748ff8b3a352334df68f2c03ada0f0252504ee8753335ecf0ca1f73cf13d4505783ed5110bf4e9b384a68ad88f69a0d38a18ef7b993c9ad2d848453e7722c26998ff3d63e243b99cdab0dabf84157ea06e5ad479dbda7f1647ed613e35d837f5d2c697ef34160f3665173186553ee9c280a0bf8371cac505b6ea0cb0f67ef744713f306a2455f3f8844cfa527c62db59c69980a0d6d689405b1cf73786c5fdabb55ec22f9b5712d1ba9c0bfcd46d4b93721fcac780", + "0xf8669d37f29e142d49f8824d4e7f1735ec3da219687387629b5fccd86812df84b846f8440180a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a01d93f60f105899172f7255c030301c3af4564edd4a48577dbdc448aec7ddb0ac"), + // String key, String value, List proof + Arrays.asList( + new EthGetProof.StorageProof( + "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "0x0", + new ArrayList<>()))); + assertEquals(proof, ethGetProof.getProof()); + } + @Test public void testEthGetWork() { diff --git a/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java b/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java index c31f02dbe..07616dde2 100644 --- a/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java +++ b/integration-tests/src/test/java/org/web3j/protocol/core/CoreIT.java @@ -13,6 +13,7 @@ package org.web3j.protocol.core; import java.math.BigInteger; +import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.BeforeAll; @@ -39,6 +40,7 @@ import org.web3j.protocol.core.methods.response.EthGetBlockTransactionCountByNumber; import org.web3j.protocol.core.methods.response.EthGetCode; import org.web3j.protocol.core.methods.response.EthGetCompilers; +import org.web3j.protocol.core.methods.response.EthGetProof; import org.web3j.protocol.core.methods.response.EthGetStorageAt; import org.web3j.protocol.core.methods.response.EthGetTransactionCount; import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt; @@ -501,6 +503,19 @@ public void testEthGetLogs() throws Exception { assertFalse(logs.isEmpty()); } + @Disabled // Not available + @Test + public void testEthGetProof() throws Exception { + EthGetProof ethGetProof = + web3j.ethGetProof( + "0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842", + Arrays.asList( + "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"), + "latest") + .send(); + assertNotNull(ethGetProof.getResult()); + } + @Disabled // Not available @Test public void testEthGetWork() throws Exception {