Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAN-3111] Renames EeaGetTransactionReceipt to PrivGetTransactionReceipt #1025

Merged
merged 3 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions eea/src/main/java/org/web3j/protocol/eea/Eea.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
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) {
return new JsonRpc2_0Eea(web3jService);
}

Request<?, EthSendTransaction> eeaSendRawTransaction(final String signedTransactionData);

Request<?, EeaGetTransactionReceipt> eeaGetTransactionReceipt(final String transactionHash);
}
11 changes: 0 additions & 11 deletions eea/src/main/java/org/web3j/protocol/eea/JsonRpc2_0Eea.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -34,14 +33,4 @@ public Request<?, EthSendTransaction> eeaSendRawTransaction(
web3jService,
EthSendTransaction.class);
}

@Override
public Request<?, EeaGetTransactionReceipt> eeaGetTransactionReceipt(
final String transactionHash) {
return new Request<>(
"eea_getTransactionReceipt",
Collections.singletonList(transactionHash),
web3jService,
EeaGetTransactionReceipt.class);
}
}
9 changes: 0 additions & 9 deletions eea/src/test/java/org/web3j/protocol/eea/RequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
60 changes: 0 additions & 60 deletions eea/src/test/java/org/web3j/protocol/eea/ResponseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -167,4 +168,14 @@ public Request<?, BooleanResponse> privDeletePrivacyGroup(final Base64String pri
web3jService,
BooleanResponse.class);
}

@Override
public Request<?, PrivGetTransactionReceipt> privGetTransactionReceipt(
final String transactionHash) {
return new Request<>(
"priv_getTransactionReceipt",
Collections.singletonList(transactionHash),
web3jService,
PrivGetTransactionReceipt.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -81,4 +82,6 @@ Request<?, PrivCreatePrivacyGroup> privCreatePrivacyGroup(
Request<?, PrivFindPrivacyGroup> privFindPrivacyGroup(final List<Base64String> addresses);

Request<?, BooleanResponse> privDeletePrivacyGroup(final Base64String privacyGroupId);

Request<?, PrivGetTransactionReceipt> privGetTransactionReceipt(final String transactionHash);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<PrivateTransactionReceipt> {
public class PrivGetTransactionReceipt extends Response<PrivateTransactionReceipt> {
public Optional<PrivateTransactionReceipt> getTransactionReceipt() {
return Optional.ofNullable(getResult());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,8 +31,8 @@ public PrivateTransactionReceiptProcessor(Pantheon pantheon) {
@Override
Optional<PrivateTransactionReceipt> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@
package org.web3j.protocol.pantheon;

import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;

import org.junit.Test;

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;
Expand Down Expand Up @@ -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));
}
}