use of com.citahub.cita.abi.datatypes.Function in project PCNGateway-Java-SDK by BSNDA.
the class TransactionService method getAddFuncData.
/**
* Get FuncData
*
* @param req
* @return
*/
@NotNull
private static String getAddFuncData(@NotNull ReqKeyUpload req) {
// params
List<Type> inputs = new ArrayList<>();
switch(req.getFuncName()) {
case "insert":
case "update":
inputs.add(new Bytes32(Common.getByte32String(req.getArgs()[0])));
inputs.add(new DynamicBytes(req.getArgs()[1].getBytes()));
break;
case "retrieve":
case "remove":
inputs.add(new Bytes32(Common.getByte32String(req.getArgs()[0])));
break;
case "keyAtIndex":
inputs.add(new Uint256(Long.parseLong(req.getArgs()[0])));
break;
default:
}
if (inputs.size() == 0) {
throw new GlobalException(ResultInfoEnum.FUNCTION_ERROR);
}
// Function
Function addFunc = new Function(req.getFuncName(), inputs, Collections.emptyList());
return FunctionEncoder.encode(addFunc);
}
Aggregations