feat: support jsontype in executeContract

This commit is contained in:
CaiHQ 2021-12-03 11:17:57 +08:00
parent 022b1d3902
commit 42745687ab
3 changed files with 19 additions and 8 deletions

View File

@ -1,6 +1,8 @@
package org.bdware.sc.redo; package org.bdware.sc.redo;
import com.google.gson.JsonElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -11,16 +13,16 @@ public class TransRecord implements Serializable,Comparable<TransRecord>{
boolean needSeq = false; boolean needSeq = false;
int seq; int seq;
String functionName; String functionName;
String arg; JsonElement arg;
public Map<String,String> executes = new HashMap<String,String>(); //<innvokdeID,(flag1<seperate>flag<seperate>result)> public Map<String,String> executes = new HashMap<String,String>(); //<innvokdeID,(flag1<seperate>flag<seperate>result)>
public TransRecord(String s1,String s2,int sequence) { public TransRecord(String s1,JsonElement s2,int sequence) {
this.functionName = s1; this.functionName = s1;
this.arg = s2; this.arg = s2;
seq = sequence; seq = sequence;
needSeq = true; needSeq = true;
} }
public TransRecord(String s1,String s2) { public TransRecord(String s1,JsonElement s2) {
this.functionName = s1; this.functionName = s1;
this.arg = s2; this.arg = s2;
} }
@ -29,7 +31,7 @@ public class TransRecord implements Serializable,Comparable<TransRecord>{
return functionName; return functionName;
} }
public String getArg() { public JsonElement getArg() {
return arg; return arg;
} }

View File

@ -40,7 +40,9 @@ public class JsonUtil {
public static JsonObject parseStringAsJsonObject(String json) { public static JsonObject parseStringAsJsonObject(String json) {
return JsonParser.parseString(json).getAsJsonObject(); return JsonParser.parseString(json).getAsJsonObject();
} }
public static JsonElement parseString(String json) {
return JsonParser.parseString(json);
}
public static JsonObject parseReaderAsJsonObject(Reader reader) { public static JsonObject parseReaderAsJsonObject(Reader reader) {
return JsonParser.parseReader(reader).getAsJsonObject(); return JsonParser.parseReader(reader).getAsJsonObject();
} }

View File

@ -1,5 +1,8 @@
package org.bdware.sc.bean; package org.bdware.sc.bean;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import java.io.*; import java.io.*;
public class ContractRequest extends SM2Verifiable public class ContractRequest extends SM2Verifiable
@ -15,13 +18,13 @@ public class ContractRequest extends SM2Verifiable
String contractID; String contractID;
String contractDOI; String contractDOI;
// requester = reqPubKey // requester = reqPubKey
String requester; String requester;
// DOI of requester // DOI of requester
String requesterDOI; String requesterDOI;
// action = rsaPrivKeyEncoded(aesKey); // action = rsaPrivKeyEncoded(aesKey);
String action; String action;
// arg = aesKeyEncoded({action,arg}); // arg = aesKeyEncoded({action,arg});
String arg; JsonElement arg;
String requestID; String requestID;
boolean fromDebug = false; boolean fromDebug = false;
@ -71,11 +74,15 @@ public class ContractRequest extends SM2Verifiable
this.requesterDOI = requesterDOI; this.requesterDOI = requesterDOI;
} }
public String getArg() { public JsonElement getArg() {
return arg; return arg;
} }
public ContractRequest setArg(String arg) { public ContractRequest setArg(String arg) {
return setArg(new JsonPrimitive(arg));
}
public ContractRequest setArg(JsonElement arg) {
this.arg = arg; this.arg = arg;
return this; return this;
} }