Skip to content

Commit

Permalink
fixing JS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kushti committed Oct 3, 2024
1 parent 19c752d commit f77be78
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions data/js/src/main/scala/sigma/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@ object Platform {
private[sigma] def liftToConstant(obj: Any, builder: SigmaBuilder): Nullable[Constant[SType]] = {
import builder._
obj match {
case arr: Array[Boolean] => Nullable(mkCollectionConstant[SBoolean.type](arr, SBoolean))
case arr: Array[Byte] => Nullable(mkCollectionConstant[SByte.type](arr, SByte))
case arr: Array[Short] => Nullable(mkCollectionConstant[SShort.type](arr, SShort))
case arr: Array[Int] => Nullable(mkCollectionConstant[SInt.type](arr, SInt))
case arr: Array[Long] => Nullable(mkCollectionConstant[SLong.type](arr, SLong))
case arr: Array[BigInteger] => Nullable(mkCollectionConstant[SBigInt.type](arr.map[BigInt](n => CBigInt(n)), SBigInt))
case arr: Array[String] => Nullable(mkCollectionConstant[SString.type](arr, SString))
case arr: Array[Boolean] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SBoolean.type](arr, SBoolean))
case arr: Array[Byte] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SByte.type](arr, SByte))
case arr: Array[Short] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SShort.type](arr, SShort))
case arr: Array[Int] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SInt.type](arr, SInt))
case arr: Array[Long] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SLong.type](arr, SLong))
case arr: Array[BigInteger] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SBigInt.type](arr.map[BigInt](n => CBigInt(n)), SBigInt))
case arr: Array[String] if !VersionContext.current.isV6SoftForkActivated => Nullable(mkCollectionConstant[SString.type](arr, SString))
case v: AnyValue =>
val tpe = Evaluation.rtypeToSType(v.tVal)
Nullable(mkConstant[tpe.type](v.value.asInstanceOf[tpe.WrappedType], tpe))
case v: Int => Nullable(mkConstant[SInt.type](v, SInt))
case v: Long => Nullable(mkConstant[SLong.type](v, SLong))
case v: BigInteger => Nullable(mkConstant[SBigInt.type](CBigInt(v), SBigInt))
case v: BigInteger if !VersionContext.current.isV6SoftForkActivated => Nullable(mkConstant[SBigInt.type](CBigInt(v), SBigInt))
case n: sigma.BigInt => Nullable(mkConstant[SBigInt.type](n, SBigInt))
case ge: GroupElement => Nullable(mkConstant[SGroupElement.type](ge, SGroupElement))
case b: Boolean => Nullable(if (b) TrueLeaf else FalseLeaf)
case v: String => Nullable(mkConstant[SString.type](v, SString))
case v: String if !VersionContext.current.isV6SoftForkActivated => Nullable(mkConstant[SString.type](v, SString))
case h: Header if VersionContext.current.isV6SoftForkActivated => Nullable(mkConstant[SHeader.type](h, SHeader))

// The Box lifting was broken in v4.x. `SigmaDsl.Box(b)` was missing which means the
// isCorrectType requirement would fail in ConstantNode constructor.
// This method is used as part of consensus in SubstConstants operation, however
// ErgoBox cannot be passed as argument as it is never valid value during evaluation.
// Thus we can use activation-based versioning and fix this code when v5.0 is activated.
case b: ErgoBox =>
case b: ErgoBox if !VersionContext.current.isV6SoftForkActivated =>
Nullable(mkConstant[SBox.type](CBox(b), SBox)) // fixed in v5.0

// this case is added in v5.0 and it can be useful when the box value comes from a
Expand Down

0 comments on commit f77be78

Please sign in to comment.