diff --git a/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala b/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala index 1936bbcd9a..fcd8885664 100644 --- a/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala +++ b/core/shared/src/main/scala/sigma/serialization/TypeSerializer.scala @@ -5,7 +5,7 @@ import sigma.VersionContext import sigma.ast.SCollectionType.{CollectionTypeCode, NestedCollectionTypeCode} import sigma.ast._ import sigma.util.safeNewArray -import sigma.validation.ValidationRules.{CheckPrimitiveTypeCode, CheckTypeCode} +import sigma.validation.ValidationRules.{CheckPrimitiveTypeCode, CheckTypeCode, CheckTypeCodeV6} import java.nio.charset.StandardCharsets @@ -14,6 +14,8 @@ class TypeSerializer { import TypeSerializer._ def getEmbeddableType(code: Int): SType = { + // todo : add versioning to the check like done for other rules + // todo : add unsigned bit int to embeddable id to type CheckPrimitiveTypeCode(code.toByte) embeddableIdToType(code) } @@ -215,9 +217,13 @@ class TypeSerializer { } SFunc(tDom, tRange, tpeParams) case _ => - // todo: 6.0: replace 1008 check with identical behavior but other opcode, to activate - // ReplacedRule(1008 -> new opcode) during 6.0 activation - CheckTypeCode(c.toByte) + // the #1008 check replaced with one with identical behavior but different opcode (1018), to activate + // ReplacedRule(1008 -> 1018) during 6.0 activation + if (VersionContext.current.isV6SoftForkActivated) { + CheckTypeCodeV6(c.toByte) + } else { + CheckTypeCode(c.toByte) + } NoType } } diff --git a/core/shared/src/main/scala/sigma/validation/ValidationRules.scala b/core/shared/src/main/scala/sigma/validation/ValidationRules.scala index 249e2fce0a..7cc552b140 100644 --- a/core/shared/src/main/scala/sigma/validation/ValidationRules.scala +++ b/core/shared/src/main/scala/sigma/validation/ValidationRules.scala @@ -77,7 +77,7 @@ object ValidationRules { /** The id of the first validation rule. Can be used as the beginning of the rules id range. */ val FirstRuleId = 1000.toShort - object CheckPrimitiveTypeCode extends ValidationRule(1007, + class CheckPrimitiveTypeCodeTemplate(ruleId: Short) extends ValidationRule(ruleId, "Check the primitive type code is supported or is added via soft-fork") with SoftForkWhenCodeAdded { override protected lazy val settings: SigmaValidationSettings = coreSettings @@ -93,7 +93,11 @@ object ValidationRules { } } - object CheckTypeCode extends ValidationRule(1008, + object CheckPrimitiveTypeCode extends CheckPrimitiveTypeCodeTemplate(1007) + + object CheckPrimitiveTypeCodeV6 extends CheckPrimitiveTypeCodeTemplate(1017) + + class CheckTypeCodeTemplate(ruleId: Short) extends ValidationRule(ruleId, "Check the non-primitive type code is supported or is added via soft-fork") with SoftForkWhenCodeAdded { override protected lazy val settings: SigmaValidationSettings = coreSettings @@ -109,6 +113,10 @@ object ValidationRules { } } + object CheckTypeCode extends CheckTypeCodeTemplate(1008) + + object CheckTypeCodeV6 extends CheckTypeCodeTemplate(1018) + object CheckSerializableTypeCode extends ValidationRule(1009, "Check the data values of the type (given by type code) can be serialized") with SoftForkWhenReplaced { diff --git a/data/shared/src/main/scala/sigma/ast/methods.scala b/data/shared/src/main/scala/sigma/ast/methods.scala index 052d0bac48..f3fa1785fb 100644 --- a/data/shared/src/main/scala/sigma/ast/methods.scala +++ b/data/shared/src/main/scala/sigma/ast/methods.scala @@ -77,7 +77,7 @@ sealed trait MethodsContainer { /** Lookup method in this type by method's id or throw ValidationException. * This method can be used in trySoftForkable section to either obtain valid method - * or catch ValidatioinException which can be checked for soft-fork condition. + * or catch ValidationException which can be checked for soft-fork condition. * It delegate to getMethodById to lookup method. * * @see getMethodById