private void buildTransactionFunction( AbiDefinition functionDefinition, MethodSpec.Builder methodBuilder, String inputParams) throws ClassNotFoundException { if (functionDefinition.hasOutputs()) { //CHECKSTYLE:OFF reporter.report(String.format( "Definition of the function %s returns a value but is not defined as a view function. " + "Please ensure it contains the view modifier if you want to read the return value", functionDefinition.getName())); //CHECKSTYLE:ON } if (functionDefinition.isPayable()) { methodBuilder.addParameter(BigInteger.class, WEI_VALUE); } String functionName = functionDefinition.getName(); methodBuilder.returns(buildRemoteCall(TypeName.get(TransactionReceipt.class))); methodBuilder.addStatement("final $T function = new $T(\n$N, \n$T.<$T>asList($L), \n$T" + ".<$T<?>>emptyList())", Function.class, Function.class, funcNameToConst(functionName), Arrays.class, Type.class, inputParams, Collections.class, TypeReference.class); if (functionDefinition.isPayable()) { methodBuilder.addStatement( "return executeRemoteCallTransaction(function, $N)", WEI_VALUE); } else { methodBuilder.addStatement("return executeRemoteCallTransaction(function)"); } }
private void buildTransactionFunction( AbiDefinition functionDefinition, MethodSpec.Builder methodBuilder, String inputParams) throws ClassNotFoundException { if (functionDefinition.hasOutputs()) { //CHECKSTYLE:OFF reporter.report(String.format( "Definition of the function %s returns a value but is not defined as a view function. " + "Please ensure it contains the view modifier if you want to read the return value", functionDefinition.getName())); //CHECKSTYLE:ON } if (functionDefinition.isPayable()) { methodBuilder.addParameter(BigInteger.class, WEI_VALUE); } String functionName = functionDefinition.getName(); methodBuilder.returns(buildRemoteCall(TypeName.get(TransactionReceipt.class))); methodBuilder.addStatement("final $T function = new $T(\n$N, \n$T.<$T>asList($L), \n$T" + ".<$T<?>>emptyList())", Function.class, Function.class, funcNameToConst(functionName), Arrays.class, Type.class, inputParams, Collections.class, TypeReference.class); if (functionDefinition.isPayable()) { methodBuilder.addStatement( "return executeRemoteCallTransaction(function, $N)", WEI_VALUE); } else { methodBuilder.addStatement("return executeRemoteCallTransaction(function)"); } }