Skip to content

Commit

Permalink
CheckAndGetMethod/CheckAndGetMethodV6, versioned methodById
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Oct 15, 2024
1 parent 83ba4a4 commit ac11237
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ object ValidationRules {
// }
}

object CheckAndGetMethod extends ValidationRule(1011,
class CheckAndGetMethodTemplate(ruleId: Short) extends ValidationRule(ruleId,
"Check the type has the declared method.") {
override protected lazy val settings: SigmaValidationSettings = currentSettings

Expand All @@ -128,6 +128,9 @@ object ValidationRules {
}
}

object CheckAndGetMethod extends CheckAndGetMethodTemplate(1011)
object CheckAndGetMethodV6 extends CheckAndGetMethodTemplate(1016)

object CheckHeaderSizeBit extends ValidationRule(1012,
"For version greater then 0, size bit should be set.") with SoftForkWhenReplaced {
override protected lazy val settings: SigmaValidationSettings = currentSettings
Expand Down Expand Up @@ -171,7 +174,9 @@ object ValidationRules {
CheckHeaderSizeBit,
CheckCostFuncOperation,
CheckPositionLimit,
CheckLoopLevelInCostFunction
CheckLoopLevelInCostFunction,
// v6 validation rules below
CheckAndGetMethodV6
)

/** Validation settings that correspond to the current version of the ErgoScript implementation.
Expand Down
6 changes: 5 additions & 1 deletion data/shared/src/main/scala/sigma/ast/methods.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ sealed trait MethodsContainer {
* @see getMethodById
*/
def methodById(methodId: Byte): SMethod = {
ValidationRules.CheckAndGetMethod(this, methodId)
if (VersionContext.current.isV6SoftForkActivated) {
ValidationRules.CheckAndGetMethodV6(this, methodId)
} else {
ValidationRules.CheckAndGetMethod(this, methodId)
}
}

/** Finds a method descriptor [[SMethod]] for the given name. */
Expand Down

0 comments on commit ac11237

Please sign in to comment.