Skip to content

Commit 131161e

Browse files
committed
func(http,util): add new rule-3 validation
1 parent 7af6488 commit 131161e

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • framework/src/main/java/org/tron/core/services/http

framework/src/main/java/org/tron/core/services/http/Util.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ public static List<Log> convertLogAddressToTronAddress(TransactionInfo transacti
554554
* Validate parameters for trigger constant and estimate energy
555555
* - Rule-1: owner address must be set
556556
* - Rule-2: either contract address is set or call data is set
557+
* - Rule-3: if try to deploy, function selector and call data can not be both set
557558
* @param contract parameters in json format
558559
* @throws InvalidParameterException if validation is not passed, this kind of exception is thrown
559560
*/
@@ -567,6 +568,12 @@ public static void validateParameter(String contract) throws InvalidParameterExc
567568
throw new InvalidParameterException("At least one of "
568569
+ CONTRACT_ADDRESS + " and " + CALL_DATA + " must be set.");
569570
}
571+
if (StringUtils.isEmpty(jsonObject.getString(CONTRACT_ADDRESS))
572+
&& !StringUtils.isEmpty(jsonObject.getString(FUNCTION_SELECTOR))
573+
&& !StringUtils.isEmpty(jsonObject.getString(CALL_DATA))) {
574+
throw new InvalidParameterException("While trying to deploy, "
575+
+ FUNCTION_SELECTOR + " and " + CALL_DATA + " can not be both set.");
576+
}
570577
}
571578

572579
}

0 commit comments

Comments
 (0)