public List<String> getCompilers() { return getResult(); } }
@Test public void testEthGetCompilers() { buildResponse( "{\n" + " \"id\":1,\n" + " \"jsonrpc\": \"2.0\",\n" + " \"result\": [\"solidity\", \"lll\", \"serpent\"]\n" + "}" ); EthGetCompilers ethGetCompilers = deserialiseResponse(EthGetCompilers.class); assertThat(ethGetCompilers.getCompilers(), equalTo(Arrays.asList( "solidity", "lll", "serpent" ))); }
@Test public void testEthGetCompilers() throws Exception { EthGetCompilers ethGetCompilers = web3j.ethGetCompilers().send(); assertNotNull(ethGetCompilers.getCompilers()); }
@InvokeOnHeader(Web3jConstants.ETH_GET_COMPILERS) void ethGetCompilers(Message message) throws IOException { Request<?, EthGetCompilers> request = web3j.ethGetCompilers(); setRequestId(message, request); EthGetCompilers response = request.send(); boolean hasError = checkForError(message, response); if (!hasError) { message.setBody(response.getCompilers()); } }
@Override public void run() throws Exception { super.run(); // get and print installed compilers EthGetCompilers compilers = web3j .ethGetCompilers() .sendAsync() .get(); System.out.println("Available compilers:"); for(String compiler: compilers.getResult()) { System.out.println("- " + compiler); } System.out.println(); // compile solidity code String sourceFile = String.format("%s/%s.%s", FOLDER_SOURCE, CONTRACT, Web3jConstants.EXT_SOLIDITY); String sourceCode = Web3jUtils.readSolidityFile(sourceFile); compileSolidity(sourceCode, CONTRACT, FOLDER_SOURCE); // generate java wrapper class String binaryFile = getBinaryFileName(CONTRACT, FOLDER_SOURCE); String abiFile = getAbiFileName(CONTRACT, FOLDER_SOURCE); String [] cmdLine = {binaryFile, abiFile, "-p", BASE_PACKAGE, "-o", FOLDER_TARGET}; System.out.printf("Running SolidityFunctionWrapperGenerator " + String.join(" ", cmdLine) + " ... "); SolidityFunctionWrapperGenerator.main(cmdLine); }