Skip to content

Commit

Permalink
fix: Check for "endpoint" attr
Browse files Browse the repository at this point in the history
  • Loading branch information
peacekeeper committed Oct 24, 2024
1 parent b87282a commit 24bca6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public ResolveDataModelResult resolve(DID did, Map<String, Object> resolveOption
throw new ResolutionException("Cannot send GET_ATTR request: " + ex.getMessage(), ex);
}

if (getAttrResponse == null) {
if (! TransactionData.hasData(getAttrResponse)) {
try {
synchronized (indyConnection) {
Pool.setProtocolVersion(indyConnection.getPoolVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ public static TransactionData fromGetAttrResponse(Map<String, Object> getAttrRes
}
}

public static boolean hasData(String getAttrResponse) {
try {
Map<String, Object> getTxnResponseMap = objectMapper.readValue(getAttrResponse, Map.class);
Object jsonGetAttrResult = getTxnResponseMap == null ? null : getTxnResponseMap.get("result");
Object jsonGetAttrResultDataString = !(jsonGetAttrResult instanceof Map) ? null : ((Map) jsonGetAttrResult).get("data");
return jsonGetAttrResultDataString != null;
} catch (JsonProcessingException ex) {
throw new IllegalArgumentException("Cannot parse transaction " + getAttrResponse + ": " + ex.getMessage(), ex);
}
}

public boolean isNym() {
return "1".equals(this.getType());
}
Expand Down

0 comments on commit 24bca6f

Please sign in to comment.