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;
import com.google.gson.JsonElement;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
@ -11,16 +13,16 @@ public class TransRecord implements Serializable,Comparable<TransRecord>{
boolean needSeq = false;
int seq;
String functionName;
String arg;
JsonElement arg;
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.arg = s2;
seq = sequence;
needSeq = true;
}
public TransRecord(String s1,String s2) {
public TransRecord(String s1,JsonElement s2) {
this.functionName = s1;
this.arg = s2;
}
@ -29,7 +31,7 @@ public class TransRecord implements Serializable,Comparable<TransRecord>{
return functionName;
}
public String getArg() {
public JsonElement getArg() {
return arg;
}

View File

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

View File

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