EIP712 { public String encodeDataType(String dataType) throws JSONException { List<String> deps = this.getDataTypeDependencies(dataType); List<String> tempDeps = new ArrayList<>(); for (String dep : deps) { if (!dep.equals(dataType)) { tempDeps.add(dep); } } Collections.sort(tempDeps); deps = new ArrayList<>(); deps.add(dataType); deps.addAll(tempDeps); StringBuilder result = new StringBuilder(); for (String type : deps) { result.append(type); result.append("("); JSONArray jsonArray = this.getDataType(type); for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObject = jsonArray.getJSONObject(i); result.append(jsonObject.getString("type")); result.append(" "); result.append(jsonObject.getString("name")); if (i < jsonArray.length() - 1) { result.append(","); } } result.append(")"); } return result.toString(); } EIP712(JSONObject txnObject); String encodeDataType(String dataType); String hashDataType(String dataType); String encodeData(String dataType, JSONObject data); String toEIP712TransactionHash(); static boolean validateData(JSONObject data);  }
@Test public void testEncodeDataType() { try { String encodeDataType = new EIP712(TypedDataInput).encodeDataType("Mail"); assertEquals(EncodedMailType, encodeDataType); } catch (Exception e) { e.printStackTrace(); } }