class PrivGetTransactionReceipt implements JsonRpcMethod {

  @Override
  public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
    LOG.trace("Executing {}", RpcMethod.PRIV_GET_TRANSACTION_RECEIPT.getMethodName());
    final Hash pmtTransactionHash = requestContext.getRequiredParameter(0, Hash.class);
    final String enclaveKey = enclavePublicKeyProvider.getEnclaveKey(requestContext.getUser());

    final ExecutedPrivateTransaction privateTransaction;
    try {
      privateTransaction =
          privacyController
              .findPrivateTransactionByPmtHash(pmtTransactionHash, enclaveKey)
              .orElse(null);
    } catch (final EnclaveClientException e) {
      return handleEnclaveException(requestContext, e);
    }

    if (privateTransaction == null) {
      return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), null);
    }

    final String contractAddress = calculateContractAddress(privateTransaction);

    LOG.trace("Calculated contractAddress: {}", contractAddress);

    final Hash blockHash = privateTransaction.getBlockHash();

    final PrivateTransactionReceipt privateTransactionReceipt =
        privateStateStorage
            .getTransactionReceipt(blockHash, pmtTransactionHash)
            // backwards compatibility - private receipts indexed by private transaction hash key
            .or(
                () ->
                    findPrivateReceiptByPrivateTxHash(
                        privateStateStorage, blockHash, privateTransaction))
            .orElse(PrivateTransactionReceipt.FAILED);

    LOG.trace("Processed private transaction receipt");

    final PrivateTransactionReceiptResult result =
        buildPrivateTransactionReceiptResult(privateTransaction, privateTransactionReceipt);

    LOG.trace(
        "Created Private Transaction Receipt Result from given Transaction Hash {}",
        privateTransaction.getPmtHash());

    return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result);
  }

  public  PrivGetTransactionReceipt(
      final PrivateStateStorage privateStateStorage,
      final PrivacyController privacyController,
      final EnclavePublicKeyProvider enclavePublicKeyProvider);

}