use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class CreateMultiAgentProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String signAddress = args[3];
RpcClientResult res = CommandHelper.getPassword(signAddress, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>();
parameters.put("agentAddress", args[1]);
parameters.put("packingAddress", args[2]);
parameters.put("signAddress", args[3]);
parameters.put("commissionRate", Double.valueOf(args[4]));
Long deposit = null;
try {
Na na = Na.parseNuls(args[5]);
deposit = na.getValue();
} catch (Exception e) {
return CommandResult.getFailed("Parameter deposit error");
}
parameters.put("deposit", deposit);
parameters.put("password", password);
if (args.length == 7) {
parameters.put("rewardAddress", args[6]);
}
RpcClientResult result = restFul.post("/consensus/multiAccount/createMultiAgent", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataMultiTransformValue(result));
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class GetAgentsProcessor method execute.
@Override
public CommandResult execute(String[] args) {
int pageNumber = Integer.parseInt(args[1]);
int pageSize = Integer.parseInt(args[2]);
Map<String, Object> parameters = new HashMap<>();
parameters.put("pageNumber", pageNumber);
parameters.put("pageSize", pageSize);
RpcClientResult result = restFul.get("/consensus/agent/list", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
List<Map<String, Object>> list = (List<Map<String, Object>>) ((Map) result.getData()).get("list");
for (Map<String, Object> map : list) {
map.put("deposit", CommandHelper.naToNuls(map.get("deposit")));
map.put("totalDeposit", CommandHelper.naToNuls(map.get("totalDeposit")));
map.put("time", DateUtil.convertDate(new Date((Long) map.get("time"))));
map.put("status", CommandHelper.consensusExplain((Integer) map.get("status")));
}
result.setData(list);
return CommandResult.getResult(result);
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class WithdrawMultiProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String signAddress = args[2];
RpcClientResult res = CommandHelper.getPassword(signAddress, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>();
parameters.put("address", args[1]);
parameters.put("signAddress", args[2]);
if (args.length == 4) {
parameters.put("txdata", args[3]);
} else {
String[] pubkeys = args[3].split(",");
parameters.put("pubkeys", Arrays.asList(pubkeys));
parameters.put("m", Integer.parseInt(args[4]));
parameters.put("txHash", Integer.parseInt(args[5]));
}
RpcClientResult result = restFul.post("/consensus/withdrawMutil", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class CreateAgentProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String address = args[1];
RpcClientResult res = CommandHelper.getPassword(address, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Map<String, Object> parameters = new HashMap<>();
parameters.put("agentAddress", address);
parameters.put("packingAddress", args[2]);
parameters.put("commissionRate", Double.valueOf(args[3]));
Long deposit = null;
try {
Na na = Na.parseNuls(args[4]);
deposit = na.getValue();
} catch (Exception e) {
return CommandResult.getFailed("Parameter deposit error");
}
parameters.put("deposit", deposit);
parameters.put("password", password);
if (args.length == 6) {
parameters.put("rewardAddress", args[5]);
}
RpcClientResult result = restFul.post("/consensus/agent", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.
the class CreateMultiDepositProcessor method execute.
@Override
public CommandResult execute(String[] args) {
String signAddress = args[2];
RpcClientResult res = CommandHelper.getPassword(signAddress, restFul);
if (!res.isSuccess()) {
return CommandResult.getFailed(res);
}
String password = (String) res.getData();
Long amount = Na.parseNuls(args[4]).getValue();
Map<String, Object> parameters = new HashMap<>(4);
parameters.put("address", args[1]);
parameters.put("signAddress", args[2]);
parameters.put("agentHash", args[3]);
parameters.put("deposit", amount);
parameters.put("password", password);
RpcClientResult result = restFul.post("/consensus/multiAccount/createMultiDeposit", parameters);
if (result.isFailed()) {
return CommandResult.getFailed(result);
}
return CommandResult.getResult(CommandResult.dataMultiTransformValue(result));
}
Aggregations