From 7ea2d61810ccc1c23342f7ce6c3356078e0f3226 Mon Sep 17 00:00:00 2001 From: Josh Richardson Date: Fri, 13 Sep 2019 09:41:14 +0100 Subject: [PATCH] [PAN-3111] Renames EeaGetTransactionReceipt to PrivGetTransactionReceipt (#1025) * Renames eea_getTransactionReceipt to priv_getTransactionReceipt * Moves requests and tests to the correct namespace --- .../main/java/org/web3j/protocol/eea/Eea.java | 3 - .../org/web3j/protocol/eea/JsonRpc2_0Eea.java | 11 ---- .../org/web3j/protocol/eea/RequestTest.java | 9 --- .../org/web3j/protocol/eea/ResponseTest.java | 60 ----------------- .../PantheonQuickstartIntegrationTest.java | 2 +- .../protocol/pantheon/JsonRpc2_0Pantheon.java | 11 ++++ .../org/web3j/protocol/pantheon/Pantheon.java | 3 + .../privacy/PrivGetTransactionReceipt.java | 4 +- .../privacy}/PrivateTransactionReceipt.java | 2 +- .../web3j/tx/PrivateTransactionManager.java | 2 +- ...ingPrivateTransactionReceiptProcessor.java | 2 +- .../PrivateTransactionReceiptProcessor.java | 8 +-- .../web3j/protocol/pantheon/RequestTest.java | 9 +++ .../web3j/protocol/pantheon/ResponseTest.java | 64 +++++++++++++++++-- 14 files changed, 90 insertions(+), 100 deletions(-) rename eea/src/main/java/org/web3j/protocol/eea/response/EeaGetTransactionReceipt.java => pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivGetTransactionReceipt.java (84%) rename {eea/src/main/java/org/web3j/protocol/eea/response => pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy}/PrivateTransactionReceipt.java (98%) diff --git a/eea/src/main/java/org/web3j/protocol/eea/Eea.java b/eea/src/main/java/org/web3j/protocol/eea/Eea.java index a37afec17..4f1edf989 100644 --- a/eea/src/main/java/org/web3j/protocol/eea/Eea.java +++ b/eea/src/main/java/org/web3j/protocol/eea/Eea.java @@ -16,7 +16,6 @@ import org.web3j.protocol.Web3jService; import org.web3j.protocol.core.Request; import org.web3j.protocol.core.methods.response.EthSendTransaction; -import org.web3j.protocol.eea.response.EeaGetTransactionReceipt; public interface Eea extends Web3j { static Eea build(Web3jService web3jService) { @@ -24,6 +23,4 @@ static Eea build(Web3jService web3jService) { } Request eeaSendRawTransaction(final String signedTransactionData); - - Request eeaGetTransactionReceipt(final String transactionHash); } diff --git a/eea/src/main/java/org/web3j/protocol/eea/JsonRpc2_0Eea.java b/eea/src/main/java/org/web3j/protocol/eea/JsonRpc2_0Eea.java index c890f7f5b..84b0aa263 100644 --- a/eea/src/main/java/org/web3j/protocol/eea/JsonRpc2_0Eea.java +++ b/eea/src/main/java/org/web3j/protocol/eea/JsonRpc2_0Eea.java @@ -18,7 +18,6 @@ import org.web3j.protocol.core.JsonRpc2_0Web3j; import org.web3j.protocol.core.Request; import org.web3j.protocol.core.methods.response.EthSendTransaction; -import org.web3j.protocol.eea.response.EeaGetTransactionReceipt; public class JsonRpc2_0Eea extends JsonRpc2_0Web3j implements Eea { public JsonRpc2_0Eea(Web3jService web3jService) { @@ -34,14 +33,4 @@ public Request eeaSendRawTransaction( web3jService, EthSendTransaction.class); } - - @Override - public Request eeaGetTransactionReceipt( - final String transactionHash) { - return new Request<>( - "eea_getTransactionReceipt", - Collections.singletonList(transactionHash), - web3jService, - EeaGetTransactionReceipt.class); - } } diff --git a/eea/src/test/java/org/web3j/protocol/eea/RequestTest.java b/eea/src/test/java/org/web3j/protocol/eea/RequestTest.java index 30cb4a059..cb8a458ed 100644 --- a/eea/src/test/java/org/web3j/protocol/eea/RequestTest.java +++ b/eea/src/test/java/org/web3j/protocol/eea/RequestTest.java @@ -35,13 +35,4 @@ public void testEthSendRawTransaction() throws Exception { verifyResult( "{\"jsonrpc\":\"2.0\",\"method\":\"eea_sendRawTransaction\",\"params\":[\"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675\"],\"id\":1}"); } - - @Test - public void testEeaGetTransactionReceipt() throws Exception { - web3j.eeaGetTransactionReceipt("0x123").send(); - - verifyResult( - "{\"jsonrpc\":\"2.0\",\"method\":\"eea_getTransactionReceipt\"," - + "\"params\":[\"0x123\"],\"id\":1}"); - } } diff --git a/eea/src/test/java/org/web3j/protocol/eea/ResponseTest.java b/eea/src/test/java/org/web3j/protocol/eea/ResponseTest.java index b17da9436..1be0d8388 100644 --- a/eea/src/test/java/org/web3j/protocol/eea/ResponseTest.java +++ b/eea/src/test/java/org/web3j/protocol/eea/ResponseTest.java @@ -12,17 +12,11 @@ */ package org.web3j.protocol.eea; -import java.util.Collections; - import org.junit.Test; import org.web3j.protocol.ResponseTester; import org.web3j.protocol.core.methods.response.EthSendTransaction; -import org.web3j.protocol.core.methods.response.Log; -import org.web3j.protocol.eea.response.EeaGetTransactionReceipt; -import org.web3j.protocol.eea.response.PrivateTransactionReceipt; -import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; @@ -43,58 +37,4 @@ public void testEeaSendRawTransaction() { ethSendTransaction.getTransactionHash(), is("0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331")); } - - @Test - public void testEeaGetTransactionReceipt() { - - buildResponse( - "{\n" - + " \"id\":1,\n" - + " \"jsonrpc\":\"2.0\",\n" - + " \"result\": {\n" - + " \"contractAddress\": \"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\n" - + " \"from\":\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\n" - + " \"to\":\"0x85h43d8a49eeb85d32cf465507dd71d507100c1\",\n" - + " \"output\":\"myRlpEncodedOutputFromPrivateContract\",\n" - + " \"logs\": [{\n" - + " \"removed\": false,\n" - + " \"logIndex\": \"0x1\",\n" - + " \"transactionIndex\": \"0x0\",\n" - + " \"transactionHash\": \"0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf\",\n" - + " \"blockHash\": \"0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d\",\n" - + " \"blockNumber\":\"0x1b4\",\n" - + " \"address\": \"0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d\",\n" - + " \"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\n" - + " \"type\":\"mined\",\n" - + " \"topics\": [\"0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5\"]" - + " }]\n" - + " }\n" - + "}"); - - PrivateTransactionReceipt transactionReceipt = - new PrivateTransactionReceipt( - "0xb60e8dd61c5d32be8058bb8eb970870f07233155", - "0x407d73d8a49eeb85d32cf465507dd71d507100c1", - "0x85h43d8a49eeb85d32cf465507dd71d507100c1", - "myRlpEncodedOutputFromPrivateContract", - Collections.singletonList( - new Log( - false, - "0x1", - "0x0", - "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf", - "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d", - "0x1b4", - "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d", - "0x0000000000000000000000000000000000000000000000000000000000000000", - "mined", - Collections.singletonList( - "0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")))); - - EeaGetTransactionReceipt eeaGetTransactionReceipt = - deserialiseResponse(EeaGetTransactionReceipt.class); - assertThat( - eeaGetTransactionReceipt.getTransactionReceipt().get(), - equalTo(transactionReceipt)); - } } diff --git a/integration-tests/src/test/java/org/web3j/protocol/pantheon/PantheonQuickstartIntegrationTest.java b/integration-tests/src/test/java/org/web3j/protocol/pantheon/PantheonQuickstartIntegrationTest.java index ead9654ea..bc69241ee 100644 --- a/integration-tests/src/test/java/org/web3j/protocol/pantheon/PantheonQuickstartIntegrationTest.java +++ b/integration-tests/src/test/java/org/web3j/protocol/pantheon/PantheonQuickstartIntegrationTest.java @@ -26,8 +26,8 @@ import org.web3j.generated.HumanStandardToken; import org.web3j.protocol.eea.crypto.PrivateTransactionEncoder; import org.web3j.protocol.eea.crypto.RawPrivateTransaction; -import org.web3j.protocol.eea.response.PrivateTransactionReceipt; import org.web3j.protocol.http.HttpService; +import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionReceipt; import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionWithPrivacyGroup; import org.web3j.tx.LegacyPrivateTransactionManager; import org.web3j.tx.PantheonPrivateTransactionManager; diff --git a/pantheon/src/main/java/org/web3j/protocol/pantheon/JsonRpc2_0Pantheon.java b/pantheon/src/main/java/org/web3j/protocol/pantheon/JsonRpc2_0Pantheon.java index 491dfd1df..06033eb28 100644 --- a/pantheon/src/main/java/org/web3j/protocol/pantheon/JsonRpc2_0Pantheon.java +++ b/pantheon/src/main/java/org/web3j/protocol/pantheon/JsonRpc2_0Pantheon.java @@ -32,6 +32,7 @@ import org.web3j.protocol.pantheon.response.privacy.PrivFindPrivacyGroup; import org.web3j.protocol.pantheon.response.privacy.PrivGetPrivacyPrecompileAddress; import org.web3j.protocol.pantheon.response.privacy.PrivGetPrivateTransaction; +import org.web3j.protocol.pantheon.response.privacy.PrivGetTransactionReceipt; import org.web3j.utils.Base64String; import static java.util.Objects.requireNonNull; @@ -167,4 +168,14 @@ public Request privDeletePrivacyGroup(final Base64String pri web3jService, BooleanResponse.class); } + + @Override + public Request privGetTransactionReceipt( + final String transactionHash) { + return new Request<>( + "priv_getTransactionReceipt", + Collections.singletonList(transactionHash), + web3jService, + PrivGetTransactionReceipt.class); + } } diff --git a/pantheon/src/main/java/org/web3j/protocol/pantheon/Pantheon.java b/pantheon/src/main/java/org/web3j/protocol/pantheon/Pantheon.java index 0dc51a8d0..a5152515d 100644 --- a/pantheon/src/main/java/org/web3j/protocol/pantheon/Pantheon.java +++ b/pantheon/src/main/java/org/web3j/protocol/pantheon/Pantheon.java @@ -29,6 +29,7 @@ import org.web3j.protocol.pantheon.response.privacy.PrivFindPrivacyGroup; import org.web3j.protocol.pantheon.response.privacy.PrivGetPrivacyPrecompileAddress; import org.web3j.protocol.pantheon.response.privacy.PrivGetPrivateTransaction; +import org.web3j.protocol.pantheon.response.privacy.PrivGetTransactionReceipt; import org.web3j.utils.Base64String; public interface Pantheon extends Eea { @@ -81,4 +82,6 @@ Request privCreatePrivacyGroup( Request privFindPrivacyGroup(final List addresses); Request privDeletePrivacyGroup(final Base64String privacyGroupId); + + Request privGetTransactionReceipt(final String transactionHash); } diff --git a/eea/src/main/java/org/web3j/protocol/eea/response/EeaGetTransactionReceipt.java b/pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivGetTransactionReceipt.java similarity index 84% rename from eea/src/main/java/org/web3j/protocol/eea/response/EeaGetTransactionReceipt.java rename to pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivGetTransactionReceipt.java index a6f0a9238..acd7b3e66 100644 --- a/eea/src/main/java/org/web3j/protocol/eea/response/EeaGetTransactionReceipt.java +++ b/pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivGetTransactionReceipt.java @@ -10,13 +10,13 @@ * 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.eea.response; +package org.web3j.protocol.pantheon.response.privacy; import java.util.Optional; import org.web3j.protocol.core.Response; -public class EeaGetTransactionReceipt extends Response { +public class PrivGetTransactionReceipt extends Response { public Optional getTransactionReceipt() { return Optional.ofNullable(getResult()); } diff --git a/eea/src/main/java/org/web3j/protocol/eea/response/PrivateTransactionReceipt.java b/pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivateTransactionReceipt.java similarity index 98% rename from eea/src/main/java/org/web3j/protocol/eea/response/PrivateTransactionReceipt.java rename to pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivateTransactionReceipt.java index 25a1d3ea0..f7db36156 100644 --- a/eea/src/main/java/org/web3j/protocol/eea/response/PrivateTransactionReceipt.java +++ b/pantheon/src/main/java/org/web3j/protocol/pantheon/response/privacy/PrivateTransactionReceipt.java @@ -10,7 +10,7 @@ * 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.eea.response; +package org.web3j.protocol.pantheon.response.privacy; import java.util.List; import java.util.Objects; diff --git a/pantheon/src/main/java/org/web3j/tx/PrivateTransactionManager.java b/pantheon/src/main/java/org/web3j/tx/PrivateTransactionManager.java index f6ec668ab..3908b657f 100644 --- a/pantheon/src/main/java/org/web3j/tx/PrivateTransactionManager.java +++ b/pantheon/src/main/java/org/web3j/tx/PrivateTransactionManager.java @@ -25,9 +25,9 @@ import org.web3j.protocol.core.methods.response.TransactionReceipt; import org.web3j.protocol.eea.crypto.PrivateTransactionEncoder; import org.web3j.protocol.eea.crypto.RawPrivateTransaction; -import org.web3j.protocol.eea.response.PrivateTransactionReceipt; import org.web3j.protocol.exceptions.TransactionException; import org.web3j.protocol.pantheon.Pantheon; +import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionReceipt; import org.web3j.tx.gas.PantheonPrivacyGasProvider; import org.web3j.tx.response.PollingPrivateTransactionReceiptProcessor; import org.web3j.tx.response.PrivateTransactionReceiptProcessor; diff --git a/pantheon/src/main/java/org/web3j/tx/response/PollingPrivateTransactionReceiptProcessor.java b/pantheon/src/main/java/org/web3j/tx/response/PollingPrivateTransactionReceiptProcessor.java index 8071b89e9..001d89a7a 100644 --- a/pantheon/src/main/java/org/web3j/tx/response/PollingPrivateTransactionReceiptProcessor.java +++ b/pantheon/src/main/java/org/web3j/tx/response/PollingPrivateTransactionReceiptProcessor.java @@ -15,9 +15,9 @@ import java.io.IOException; import java.util.Optional; -import org.web3j.protocol.eea.response.PrivateTransactionReceipt; import org.web3j.protocol.exceptions.TransactionException; import org.web3j.protocol.pantheon.Pantheon; +import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionReceipt; public class PollingPrivateTransactionReceiptProcessor extends PrivateTransactionReceiptProcessor { private final long sleepDuration; diff --git a/pantheon/src/main/java/org/web3j/tx/response/PrivateTransactionReceiptProcessor.java b/pantheon/src/main/java/org/web3j/tx/response/PrivateTransactionReceiptProcessor.java index 5cb000f6d..796934eeb 100644 --- a/pantheon/src/main/java/org/web3j/tx/response/PrivateTransactionReceiptProcessor.java +++ b/pantheon/src/main/java/org/web3j/tx/response/PrivateTransactionReceiptProcessor.java @@ -15,10 +15,10 @@ import java.io.IOException; import java.util.Optional; -import org.web3j.protocol.eea.response.EeaGetTransactionReceipt; -import org.web3j.protocol.eea.response.PrivateTransactionReceipt; import org.web3j.protocol.exceptions.TransactionException; import org.web3j.protocol.pantheon.Pantheon; +import org.web3j.protocol.pantheon.response.privacy.PrivGetTransactionReceipt; +import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionReceipt; public abstract class PrivateTransactionReceiptProcessor extends TransactionReceiptProcessor { private Pantheon pantheon; @@ -31,8 +31,8 @@ public PrivateTransactionReceiptProcessor(Pantheon pantheon) { @Override Optional sendTransactionReceiptRequest(String transactionHash) throws IOException, TransactionException { - EeaGetTransactionReceipt transactionReceipt = - pantheon.eeaGetTransactionReceipt(transactionHash).send(); + PrivGetTransactionReceipt transactionReceipt = + pantheon.privGetTransactionReceipt(transactionHash).send(); if (transactionReceipt.hasError()) { throw new TransactionException( "Error processing request: " + transactionReceipt.getError().getMessage()); diff --git a/pantheon/src/test/java/org/web3j/protocol/pantheon/RequestTest.java b/pantheon/src/test/java/org/web3j/protocol/pantheon/RequestTest.java index 180c42970..7afd5b9f4 100644 --- a/pantheon/src/test/java/org/web3j/protocol/pantheon/RequestTest.java +++ b/pantheon/src/test/java/org/web3j/protocol/pantheon/RequestTest.java @@ -188,4 +188,13 @@ public void testPrivDeletePrivacyGroup() throws Exception { + "\"params\":[\"DyAOiF/ynpc+JXa2YAGB0bCitSlOMNm+ShmB/7M6C4w=\"]," + "\"id\":1}"); } + + @Test + public void testPrivGetTransactionReceipt() throws Exception { + web3j.privGetTransactionReceipt("0x123").send(); + + verifyResult( + "{\"jsonrpc\":\"2.0\",\"method\":\"priv_getTransactionReceipt\"," + + "\"params\":[\"0x123\"],\"id\":1}"); + } } diff --git a/pantheon/src/test/java/org/web3j/protocol/pantheon/ResponseTest.java b/pantheon/src/test/java/org/web3j/protocol/pantheon/ResponseTest.java index f8aeec57a..966e67343 100644 --- a/pantheon/src/test/java/org/web3j/protocol/pantheon/ResponseTest.java +++ b/pantheon/src/test/java/org/web3j/protocol/pantheon/ResponseTest.java @@ -13,6 +13,7 @@ package org.web3j.protocol.pantheon; import java.util.Arrays; +import java.util.Collections; import java.util.Optional; import org.junit.Test; @@ -20,14 +21,9 @@ import org.web3j.protocol.ResponseTester; import org.web3j.protocol.admin.methods.response.BooleanResponse; import org.web3j.protocol.core.methods.response.EthAccounts; +import org.web3j.protocol.core.methods.response.Log; import org.web3j.protocol.pantheon.response.PantheonEthAccountsMapResponse; -import org.web3j.protocol.pantheon.response.privacy.PrivCreatePrivacyGroup; -import org.web3j.protocol.pantheon.response.privacy.PrivFindPrivacyGroup; -import org.web3j.protocol.pantheon.response.privacy.PrivGetPrivacyPrecompileAddress; -import org.web3j.protocol.pantheon.response.privacy.PrivGetPrivateTransaction; -import org.web3j.protocol.pantheon.response.privacy.PrivacyGroup; -import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionLegacy; -import org.web3j.protocol.pantheon.response.privacy.PrivateTransactionWithPrivacyGroup; +import org.web3j.protocol.pantheon.response.privacy.*; import org.web3j.utils.Base64String; import static org.hamcrest.CoreMatchers.equalTo; @@ -270,4 +266,58 @@ public void testPrivFindPrivacyGroup() { assertThat( privFindPrivacyGroup.getGroups(), is(Arrays.asList(privacyGroup1, privacyGroup2))); } + + @Test + public void testPrivGetTransactionReceipt() { + + buildResponse( + "{\n" + + " \"id\":1,\n" + + " \"jsonrpc\":\"2.0\",\n" + + " \"result\": {\n" + + " \"contractAddress\": \"0xb60e8dd61c5d32be8058bb8eb970870f07233155\",\n" + + " \"from\":\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\n" + + " \"to\":\"0x85h43d8a49eeb85d32cf465507dd71d507100c1\",\n" + + " \"output\":\"myRlpEncodedOutputFromPrivateContract\",\n" + + " \"logs\": [{\n" + + " \"removed\": false,\n" + + " \"logIndex\": \"0x1\",\n" + + " \"transactionIndex\": \"0x0\",\n" + + " \"transactionHash\": \"0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf\",\n" + + " \"blockHash\": \"0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d\",\n" + + " \"blockNumber\":\"0x1b4\",\n" + + " \"address\": \"0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d\",\n" + + " \"data\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\n" + + " \"type\":\"mined\",\n" + + " \"topics\": [\"0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5\"]" + + " }]\n" + + " }\n" + + "}"); + + PrivateTransactionReceipt transactionReceipt = + new PrivateTransactionReceipt( + "0xb60e8dd61c5d32be8058bb8eb970870f07233155", + "0x407d73d8a49eeb85d32cf465507dd71d507100c1", + "0x85h43d8a49eeb85d32cf465507dd71d507100c1", + "myRlpEncodedOutputFromPrivateContract", + Collections.singletonList( + new Log( + false, + "0x1", + "0x0", + "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf", + "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d", + "0x1b4", + "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "mined", + Collections.singletonList( + "0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5")))); + + PrivGetTransactionReceipt privGetTransactionReceipt = + deserialiseResponse(PrivGetTransactionReceipt.class); + assertThat( + privGetTransactionReceipt.getTransactionReceipt().get(), + equalTo(transactionReceipt)); + } }