GnosisSafe { public JSONObject getSafeTxData(String to, String verifyingContract ,String value, String data, String operation, String safeTxGas, String dataGas, String gasPrice, String gasToken, String refundReceiver, String nonce) { try { JSONObject typedDataInput = new JSONObject("{\n" + " types: {\n" + " EIP712Domain: [{ name: 'verifyingContract', type: 'address' }],\n" + " SafeTx: [\n" + " { name: 'to', type: 'address' },\n" + " { name: 'value', type: 'uint256' },\n" + " { name: 'data', type: 'bytes' },\n" + " { name: 'operation', type: 'uint8' },\n" + " { name: 'safeTxGas', type: 'uint256' },\n" + " { name: 'dataGas', type: 'uint256' },\n" + " { name: 'gasPrice', type: 'uint256' },\n" + " { name: 'gasToken', type: 'address' },\n" + " { name: 'refundReceiver', type: 'address' },\n" + " { name: 'nonce', type: 'uint256' }\n" + " ]\n" + " },\n" + " primaryType: 'SafeTx',\n" + " domain: {\n" + " verifyingContract: "+ verifyingContract +"\n" + " },\n" + " message: {\n" + " to: " + to + ",\n" + " value: " + value + ",\n" + " data: '" + data + "',\n" + " operation: " + operation + ",\n" + " safeTxGas: " + safeTxGas + ",\n" + " dataGas: " + dataGas + ",\n" + " gasPrice: " + gasPrice + ",\n" + " gasToken: '" + gasToken + "',\n" + " refundReceiver: '" + refundReceiver + "',\n" + " nonce: " + nonce + "\n" + " }\n" + " }"); return typedDataInput; } catch (JSONException e) { e.printStackTrace(); } return null; } GnosisSafe(); String getAuthorizeSessionExecutableData(String sessionAddress, String spendingLimit, String expirationHeight); String getAuthorizeSessionData(String sessionAddress, String spendingLimit, String expirationHeight); String getAddOwnerWithThresholdExecutableData(String ownerAddress, String threshHold); String transactionHash(String deviceManagerAddress, String data, String nonce); JSONObject getSafeTxData(String to, String verifyingContract ,String value, String data, String operation, String safeTxGas, String dataGas, String gasPrice, String gasToken, String refundReceiver, String nonce); String getRemoveOwnerWithThresholdExecutableData(String prevOwner, String ownerToRemove); String getRemoveOwnerWithThresholdCallData(String prevOwner, String ownerToRemove); String getAddOwnerWithThresholdCallData(String ownerAddress); String getAddOwnerWithThresholdCallData(String ownerAddress, String threshHold); String getAddOwnerWithThresholdExecutableData(String ownerAddress);  }
@Test public void testGetSafeTxData() { String expectedOutput = "0x4fd9d0aed661d3993b562981a1cc2f5670723bab7bb45e3ff0c42fc021fa30b4"; String addOwnerExecutableData = "0x0d582f1300000000000000000000000098443ba43e5a55ff9c0ebeddfd" + "1db32d7b1a949a0000000000000000000000000000000000000000000000000000000000000001"; String NULL_ADDRESS = "0x0000000000000000000000000000000000000000"; JSONObject safeTxData = new GnosisSafe().getSafeTxData("0x98443bA43e5a55fF9c0EbeDdfd1db32d7b1A949A", "0x98443bA43e5a55fF9c0EbeDdfd1db32d7b1A949A" , "0", addOwnerExecutableData, "0", "0", "0", "0", NULL_ADDRESS, NULL_ADDRESS, "0"); String hashString = null; try { hashString = new EIP712(safeTxData).toEIP712TransactionHash(); } catch (Exception e) { e.printStackTrace(); } assertEquals(expectedOutput, hashString); }