Skip to content

Commit

Permalink
add receive type to support solidity 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
neo hong committed Nov 17, 2020
1 parent b0319f0 commit 30e27df
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Tron protobuf protocol document.md
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI`
Function = 2;
Event = 3;
Fallback = 4;
Receive = 5;
}
```

Expand Down Expand Up @@ -1617,6 +1618,7 @@ message `SmartContract` has mutiple attributes and nested message `ABI`
Function = 2;
Event = 3;
Fallback = 4;
Receive = 5;
}
message Param {
bool indexed = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,20 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

boolean isFunctionSelectorSet = jsonObject.containsKey(functionSelector)
&& !StringUtil.isNullOrEmpty(jsonObject.getString(functionSelector));

boolean isDataSet = jsonObject.containsKey("data")
&& !StringUtil.isNullOrEmpty(jsonObject.getString("data"));
String data;

if (isFunctionSelectorSet) {
String selector = jsonObject.getString(functionSelector);
String parameter = jsonObject.getString("parameter");
data = Util.parseMethod(selector, parameter);
} else {
data = jsonObject.getString("data");
}

build.setData(ByteString.copyFrom(ByteArray.fromHexString(data)));
if (!isFunctionSelectorSet && !isDataSet) {
build.setData(ByteString.copyFrom(new byte[0]));
}
long feeLimit = Util.getJsonLongValue(jsonObject, "fee_limit");

TransactionCapsule trxCap = wallet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ protected void validateParameter(String contract) {
if (isFunctionSelectorSet && isDataSet) {
throw new InvalidParameterException("set either function_selector or data but not both");
}
if (!isFunctionSelectorSet && !isDataSet) {
throw new InvalidParameterException("function_selector or data isn't set.");
}
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
Expand All @@ -74,18 +71,21 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

boolean isFunctionSelectorSet = jsonObject.containsKey(functionSelector)
&& !StringUtil.isNullOrEmpty(jsonObject.getString(functionSelector));

boolean isDataSet = jsonObject.containsKey("data")
&& !StringUtil.isNullOrEmpty(jsonObject.getString("data"));
String data;

if (isFunctionSelectorSet) {
String selector = jsonObject.getString(functionSelector);
String parameter = jsonObject.getString("parameter");
data = Util.parseMethod(selector, parameter);
} else {
data = jsonObject.getString("data");
}

build.setData(ByteString.copyFrom(ByteArray.fromHexString(data)));
if (!isFunctionSelectorSet && !isDataSet) {
build.setData(ByteString.copyFrom(new byte[0]));
}

build.setCallTokenValue(Util.getJsonLongValue(jsonObject, "call_token_value"));
build.setTokenId(Util.getJsonLongValue(jsonObject, "token_id"));
build.setCallValue(Util.getJsonLongValue(jsonObject, "call_value"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ message SmartContract {
Function = 2;
Event = 3;
Fallback = 4;
Receive = 5;
}
message Param {
bool indexed = 1;
Expand Down

0 comments on commit 30e27df

Please sign in to comment.