use of org.web3j.abi.datatypes.Function in project jbpm-work-items by kiegroup.
the class EthereumUtils method queryExistingContract.
public static Object queryExistingContract(Credentials credentials, Web3j web3j, String contractAddress, String contractMethodName, List<Type> contractMethodInputTypes, List<TypeReference<?>> contractMethodOutputTypes) throws Exception {
Function function = getFunction(contractMethodName, contractMethodInputTypes, contractMethodOutputTypes);
Transaction transaction = Transaction.createEthCallTransaction(credentials.getAddress(), contractAddress, getEncodedFunction(function));
EthCall response = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).sendAsync().get();
List<Type> responseTypeList = FunctionReturnDecoder.decode(response.getValue(), function.getOutputParameters());
if (responseTypeList != null && responseTypeList.size() > 0) {
return responseTypeList.get(0).getValue();
} else {
return null;
}
}
use of org.web3j.abi.datatypes.Function in project jbpm-work-items by kiegroup.
the class EthereumUtils method getFunction.
public static Function getFunction(String queryName, List<Type> queryInputTypes, List<TypeReference<?>> queryOutputTypes) {
List<Type> inputParameters;
if (queryInputTypes != null) {
inputParameters = queryInputTypes;
} else {
inputParameters = new ArrayList<>();
}
List<TypeReference<?>> outputTypes;
if (queryOutputTypes != null) {
outputTypes = queryOutputTypes;
} else {
outputTypes = new ArrayList<>();
}
Function function = new Function(queryName, inputParameters, outputTypes);
return function;
}
Aggregations