Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PAN-2971] Remove enclave public key from parameter #1777

Merged
merged 2 commits into from
Jul 29, 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
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ blockchainQueries, new TransactionTracer(blockReplay), parameter),
addMethods(
enabledMethods,
new PrivCreatePrivacyGroup(new Enclave(privacyParameters.getEnclaveUri()), parameter),
new PrivDeletePrivacyGroup(new Enclave(privacyParameters.getEnclaveUri()), parameter),
new PrivDeletePrivacyGroup(
new Enclave(privacyParameters.getEnclaveUri()), privacyParameters, parameter),
new PrivFindPrivacyGroup(new Enclave(privacyParameters.getEnclaveUri()), parameter),
new PrivGetPrivacyPrecompileAddress(privacyParameters),
new PrivGetTransactionCount(parameter, privateTransactionHandler),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import tech.pegasys.pantheon.enclave.Enclave;
import tech.pegasys.pantheon.enclave.types.DeletePrivacyGroupRequest;
import tech.pegasys.pantheon.ethereum.core.PrivacyParameters;
import tech.pegasys.pantheon.ethereum.jsonrpc.RpcMethod;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.JsonRpcRequest;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.methods.JsonRpcMethod;
Expand All @@ -30,10 +31,15 @@ public class PrivDeletePrivacyGroup implements JsonRpcMethod {

private static final Logger LOG = getLogger();
private final Enclave enclave;
private PrivacyParameters privacyParameters;
private final JsonRpcParameter parameters;

public PrivDeletePrivacyGroup(final Enclave enclave, final JsonRpcParameter parameters) {
public PrivDeletePrivacyGroup(
final Enclave enclave,
final PrivacyParameters privacyParameters,
final JsonRpcParameter parameters) {
this.enclave = enclave;
this.privacyParameters = privacyParameters;
this.parameters = parameters;
}

Expand All @@ -46,13 +52,15 @@ public String getName() {
public JsonRpcResponse response(final JsonRpcRequest request) {
LOG.trace("Executing {}", RpcMethod.PRIV_DELETE_PRIVACY_GROUP.getMethodName());

final String privacyGroupId = parameters.required(request.getParams(), 1, String.class);
final String from = parameters.required(request.getParams(), 0, String.class);
final String privacyGroupId = parameters.required(request.getParams(), 0, String.class);

LOG.trace("Deleting a privacy group with privacyGroupId {} and from {}", privacyGroupId, from);
LOG.trace(
"Deleting a privacy group with privacyGroupId {} and from {}",
privacyGroupId,
privacyParameters.getEnclavePublicKey());

DeletePrivacyGroupRequest deletePrivacyGroupRequest =
new DeletePrivacyGroupRequest(privacyGroupId, from);
new DeletePrivacyGroupRequest(privacyGroupId, privacyParameters.getEnclavePublicKey());
String response;
try {
response = enclave.deletePrivacyGroup(deletePrivacyGroupRequest);
Expand Down