From b99d1fe732f79dcb8bca13205faac9488d0ad03c Mon Sep 17 00:00:00 2001 From: mikera Date: Tue, 6 Aug 2024 15:20:09 +0100 Subject: [PATCH] More updates for CLI client commands --- .../java/convex/cli/account/AAccountCommand.java | 12 +----------- .../java/convex/cli/account/AccountBalance.java | 2 +- .../convex/cli/account/AccountInformation.java | 2 +- .../java/convex/cli/client/AClientCommand.java | 13 ++++--------- .../src/main/java/convex/cli/client/Query.java | 2 +- .../java/convex/cli/mixins/RemotePeerMixin.java | 8 +++++--- convex-peer/src/main/java/convex/api/Convex.java | 16 +--------------- .../main/java/convex/restapi/api/ChainAPI.java | 4 ---- 8 files changed, 14 insertions(+), 45 deletions(-) diff --git a/convex-cli/src/main/java/convex/cli/account/AAccountCommand.java b/convex-cli/src/main/java/convex/cli/account/AAccountCommand.java index 371dc7f6d..1f311fa74 100644 --- a/convex-cli/src/main/java/convex/cli/account/AAccountCommand.java +++ b/convex-cli/src/main/java/convex/cli/account/AAccountCommand.java @@ -1,11 +1,7 @@ package convex.cli.account; -import java.io.IOException; -import java.util.concurrent.TimeoutException; - import convex.api.Convex; import convex.cli.ACommand; -import convex.cli.CLIError; import convex.cli.Main; import convex.cli.mixins.RemotePeerMixin; import picocli.CommandLine.Mixin; @@ -20,13 +16,7 @@ public abstract class AAccountCommand extends ACommand { protected RemotePeerMixin peerMixin; protected Convex connect() { - try { - return peerMixin.connect(); - } catch (IOException e) { - throw new CLIError("Unable to connect to Convex network",e); - } catch (TimeoutException e) { - throw new CLIError("Timout connecting to Convex network",e); - } + return peerMixin.connect(); } @Override diff --git a/convex-cli/src/main/java/convex/cli/account/AccountBalance.java b/convex-cli/src/main/java/convex/cli/account/AccountBalance.java index 9f5d36966..6465e560f 100644 --- a/convex-cli/src/main/java/convex/cli/account/AccountBalance.java +++ b/convex-cli/src/main/java/convex/cli/account/AccountBalance.java @@ -60,7 +60,7 @@ public void run() { Convex convex = peerMixin.connect(); String queryCommand = "(balance "+address+")"; ACell message = Reader.read(queryCommand); - Result result = convex.querySync(message, timeout); + Result result = convex.querySync(message); mainParent.printResult(result); } catch (Exception e) { throw new CLIError("Error executing query",e); diff --git a/convex-cli/src/main/java/convex/cli/account/AccountInformation.java b/convex-cli/src/main/java/convex/cli/account/AccountInformation.java index da63a54b7..0393ad34b 100644 --- a/convex-cli/src/main/java/convex/cli/account/AccountInformation.java +++ b/convex-cli/src/main/java/convex/cli/account/AccountInformation.java @@ -64,7 +64,7 @@ public void run() { ACell message = Reader.read(queryCommand); Result result; try { - result = convex.querySync(message, timeout); + result = convex.querySync(message); mainParent.printResult(result); } catch (TimeoutException e) { throw new CLIError("Timeout",e); diff --git a/convex-cli/src/main/java/convex/cli/client/AClientCommand.java b/convex-cli/src/main/java/convex/cli/client/AClientCommand.java index ca650cbba..01dccb45f 100644 --- a/convex-cli/src/main/java/convex/cli/client/AClientCommand.java +++ b/convex-cli/src/main/java/convex/cli/client/AClientCommand.java @@ -32,21 +32,16 @@ public abstract class AClientCommand extends ATopCommand { description="Timeout in miliseconds.") protected Long timeout; - /** * Connect as a client to the convex network * @return */ protected Convex clientConnect() { - try { - Convex convex= peerMixin.connect(); - if (timeout!=null) { - convex.setTimeout(timeout); - } - return convex; - } catch (Exception ex) { - throw new CLIError("Unable to connect to Convex: "+ex.getMessage(),ex); + Convex convex= peerMixin.connect(); + if (timeout!=null) { + convex.setTimeout(timeout); } + return convex; } /** diff --git a/convex-cli/src/main/java/convex/cli/client/Query.java b/convex-cli/src/main/java/convex/cli/client/Query.java index 6305ad55b..0f146053f 100644 --- a/convex-cli/src/main/java/convex/cli/client/Query.java +++ b/convex-cli/src/main/java/convex/cli/client/Query.java @@ -40,7 +40,7 @@ public void run() { Convex convex = connectQuery(); for (int i=0; i cf = query(query, address); Result result; try { diff --git a/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java b/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java index bf37b60cf..841a6ca90 100644 --- a/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java +++ b/convex-restapi/src/main/java/convex/restapi/api/ChainAPI.java @@ -56,7 +56,6 @@ public ChainAPI(RESTServer restServer) { private static final String ROUTE = "/api/v1/"; - @Override public void addRoutes(Javalin app) { String prefix=ROUTE; @@ -171,9 +170,6 @@ public void queryAccount(Context ctx) { } boolean isUser=!as.isActor(); - // TODO: consider if isLibrary is useful? - // boolean isLibrary=as.getCallableFunctions().isEmpty(); - HashMap hm=new HashMap<>(); hm.put("address",addr.longValue());