Search in sources :

Example 31 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class CreateMultiStopAgentProcessor 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<>(2);
    parameters.put("address", args[1]);
    parameters.put("signAddress", args[2]);
    parameters.put("password", password);
    RpcClientResult result = restFul.post("/consensus/multiAccount/agent/stopMultiAgent", parameters);
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    return CommandResult.getResult(CommandResult.dataMultiTransformValue(result));
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 32 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class DepositProcessor 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();
    Long amount = Na.parseNuls(args[3]).getValue();
    Map<String, Object> parameters = new HashMap<>(4);
    parameters.put("address", address);
    parameters.put("agentHash", args[2]);
    parameters.put("deposit", amount);
    parameters.put("password", password);
    RpcClientResult result = restFul.post("/consensus/deposit", parameters);
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    return CommandResult.getResult(CommandResult.dataTransformValue(result));
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 33 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class CreateMultiSigAccountProcessor method execute.

@Override
public CommandResult execute(String[] args) {
    Map<String, Object> parameters = new HashMap<>();
    String pubkeysStr = args[1];
    parameters.put("pubkeys", pubkeysStr.split(","));
    parameters.put("m", args[2]);
    RpcClientResult result = restFul.post("/account/createMultiAccount", parameters);
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    return CommandResult.getResult(result);
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Example 34 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class ClientResource method startUpdate.

@POST
@Path("/upgrade/{version}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "升级")
@ApiResponses(value = { @ApiResponse(code = 200, message = "success", response = Boolean.class) })
public RpcClientResult startUpdate(@PathParam("version") String version) {
    AssertUtil.canNotEmpty(version);
    SyncVersionRunner syncor = SyncVersionRunner.getInstance();
    String newestVersion = syncor.getNewestVersion();
    if (!VersionUtils.higherThan(newestVersion, NulsConfig.VERSION)) {
        Result result = Result.getFailed(KernelErrorCode.NONEWVER);
        return result.toRpcClientResult();
    }
    if (!version.equals(newestVersion)) {
        Result result = Result.getFailed(KernelErrorCode.VERSION_NOT_NEWEST);
        return result.toRpcClientResult();
    }
    URL url = ClientResource.class.getClassLoader().getResource("libs");
    if (null == url) {
        return Result.getFailed(KernelErrorCode.DATA_NOT_FOUND).toRpcClientResult();
    }
    UpgradeThread thread = UpgradeThread.getInstance();
    if (thread.isUpgrading()) {
        return Result.getFailed(KernelErrorCode.UPGRADING).toRpcClientResult();
    }
    boolean result = thread.start();
    if (result) {
        TaskManager.createAndRunThread((short) 1, "upgrade", thread);
        Map<String, Boolean> map = new HashMap<>();
        map.put("value", true);
        return Result.getSuccess().setData(map).toRpcClientResult();
    }
    return Result.getFailed(KernelErrorCode.FAILED).toRpcClientResult();
}
Also used : HashMap(java.util.HashMap) UpgradeThread(io.nuls.client.rpc.resources.thread.UpgradeThread) SyncVersionRunner(io.nuls.client.version.SyncVersionRunner) URL(java.net.URL) RpcClientResult(io.nuls.kernel.model.RpcClientResult) Result(io.nuls.kernel.model.Result) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 35 with RpcClientResult

use of io.nuls.kernel.model.RpcClientResult in project nuls by nuls-io.

the class RemoveAccountProcessor 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("password", password);
    RpcClientResult result = restFul.post("/account/remove/" + address, parameters);
    if (result.isFailed()) {
        return CommandResult.getFailed(result);
    }
    return CommandResult.getSuccess("Success");
}
Also used : HashMap(java.util.HashMap) RpcClientResult(io.nuls.kernel.model.RpcClientResult)

Aggregations

RpcClientResult (io.nuls.kernel.model.RpcClientResult)88 HashMap (java.util.HashMap)49 Map (java.util.Map)24 Date (java.util.Date)14 List (java.util.List)14 Result (io.nuls.kernel.model.Result)7 InputDto (io.nuls.accout.ledger.rpc.dto.InputDto)5 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 NulsException (io.nuls.kernel.exception.NulsException)3 Na (io.nuls.kernel.model.Na)3 Node (io.nuls.network.model.Node)3 Test (org.junit.Test)3 RandomSeedDTO (io.nuls.consensus.poc.rpc.model.RandomSeedDTO)2 Coin (io.nuls.kernel.model.Coin)2 IOException (java.io.IOException)2 AccountKeyStoreDto (io.nuls.account.rpc.model.AccountKeyStoreDto)1