diff --git a/src/main/java/org/bdware/sc/ContractProcess.java b/src/main/java/org/bdware/sc/ContractProcess.java index 3a061b6..29cb7ed 100644 --- a/src/main/java/org/bdware/sc/ContractProcess.java +++ b/src/main/java/org/bdware/sc/ContractProcess.java @@ -1,5 +1,6 @@ package org.bdware.sc; +import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; @@ -846,6 +847,21 @@ public class ContractProcess { return logIndex.size(); } + public String executeFunctionWithoutLimit(String arg) { + try { + JsonObject body = JsonUtil.parseString(arg).getAsJsonObject(); + String funcName = body.get("funcName").getAsString(); + JsonArray arr = body.getAsJsonArray("funcArgs"); + Object[] funcArgs = JsonUtil.fromJson(arr, Object[].class); + Object result = engine.invokeFunction(funcName, funcArgs); + return JsonUtil.toJson(result); + } catch (Exception e) { + ByteArrayOutputStream bo = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(bo)); + return bo.toString(); + } + } + public String executeContract(String arg) { // TODO // eventCenter.pub(new EventMsg("executeContract", arg)); diff --git a/src/main/java/org/bdware/sc/handler/ContractHandler.java b/src/main/java/org/bdware/sc/handler/ContractHandler.java index f46ae76..942cdea 100644 --- a/src/main/java/org/bdware/sc/handler/ContractHandler.java +++ b/src/main/java/org/bdware/sc/handler/ContractHandler.java @@ -115,6 +115,11 @@ public class ContractHandler extends MsgHandler implements Runnable { cb.onResult(cs.executeContract(msg.arg)); } + @Description(value = "invoke function without limit") + public void invokeFunctionWithoutLimit(GetMessage msg, ResultCallback cb) { + cb.onResult(cs.executeFunctionWithoutLimit(msg.arg)); + } + @Description("set DesktopPermission") public void setDesktopPermission(GetMessage msg, ResultCallback cb) { String result = cs.setDesktopPermission(msg.arg);