MCPcopy Index your code
hub / github.com/ccxt/ccxt / encodeType

Method encodeType

java/lib/src/main/java/io/github/ccxt/Exchange.java:2506–2525  ·  view source on GitHub ↗
(String primaryType, Map<String, List<Map<String, String>>> types)

Source from the content-addressed store, hash-verified

2504
2505 // encodeType per EIP-712: primaryType followed by sorted dependent struct types.
2506 private static String encodeType(String primaryType, Map<String, List<Map<String, String>>> types) {
2507 LinkedHashSet<String> deps = new LinkedHashSet<>();
2508 collectDependencies(primaryType, types, deps);
2509 deps.remove(primaryType);
2510 List<String> sortedDeps = new ArrayList<>(deps);
2511 java.util.Collections.sort(sortedDeps);
2512 sortedDeps.add(0, primaryType);
2513 StringBuilder sb = new StringBuilder();
2514 for (String typeName : sortedDeps) {
2515 sb.append(typeName).append("(");
2516 List<Map<String, String>> fields = types.get(typeName);
2517 for (int i = 0; i < fields.size(); i++) {
2518 if (i > 0) sb.append(",");
2519 Map<String, String> field = fields.get(i);
2520 sb.append(field.get("type")).append(" ").append(field.get("name"));
2521 }
2522 sb.append(")");
2523 }
2524 return sb.toString();
2525 }
2526
2527 private static void collectDependencies(String typeName, Map<String, List<Map<String, String>>> types, LinkedHashSet<String> deps) {
2528 if (!types.containsKey(typeName) || deps.contains(typeName)) return;

Callers 1

hashStructMethod · 0.95

Calls 7

collectDependenciesMethod · 0.95
removeMethod · 0.45
sortMethod · 0.45
addMethod · 0.45
appendMethod · 0.45
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected