Skip to content

Commit 9d6d99f

Browse files
authored
Merge pull request #930 from ergoplatform/v6.0.0
Candidate for 6.0.0 release
2 parents 6d848d1 + 8b18ae6 commit 9d6d99f

File tree

157 files changed

+14092
-2619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+14092
-2619
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*.fdb_latexmk
99
*.gz
1010

11+
yarn.lock
1112
*.log
1213
docs/spec/out/
1314
test-out/

core/js/src/main/scala/sigma/crypto/Platform.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ object Platform {
253253
case _: Boolean => tpe == SBoolean
254254
case _: Byte | _: Short | _: Int | _: Long => tpe.isInstanceOf[SNumericType]
255255
case _: BigInt => tpe == SBigInt
256+
case _: UnsignedBigInt => tpe == SUnsignedBigInt
256257
case _: String => tpe == SString
257258
case _: GroupElement => tpe.isGroupElement
258259
case _: SigmaProp => tpe.isSigmaProp

core/js/src/main/scala/sigma/js/Isos.scala

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sigma.js
22

33
import sigma.{Coll, Colls}
4-
import sigma.data.{CBigInt, Iso, RType}
4+
import sigma.data.{CBigInt, CUnsignedBigInt, Iso, RType}
55

66
import java.math.BigInteger
77
import scala.reflect.ClassTag
@@ -42,6 +42,18 @@ object Isos {
4242
}
4343
}
4444

45+
implicit val isoUnsignedBigInt: Iso[js.BigInt, sigma.UnsignedBigInt] = new Iso[js.BigInt, sigma.UnsignedBigInt] {
46+
override def to(x: js.BigInt): sigma.UnsignedBigInt = {
47+
CUnsignedBigInt(new BigInteger(x.toString(10)))
48+
}
49+
50+
override def from(x: sigma.UnsignedBigInt): js.BigInt = {
51+
val bi = x.asInstanceOf[CUnsignedBigInt].wrappedValue
52+
val s = bi.toString(10)
53+
js.BigInt(s)
54+
}
55+
}
56+
4557
implicit val isoBigIntToLong: Iso[js.BigInt, Long] = new Iso[js.BigInt, Long] {
4658
override def to(x: js.BigInt): Long = java.lang.Long.parseLong(x.toString(10))
4759

core/js/src/main/scala/sigma/js/Type.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ object Type extends js.Object {
3535
/** Descriptor of ErgoScript type BigInt. */
3636
val BigInt = new Type(sigma.BigIntRType)
3737

38+
/** Descriptor of ErgoScript type UnsignedBigInt. */
39+
val UnsignedBigInt = new Type(sigma.UnsignedBigIntRType)
40+
3841
/** Descriptor of ErgoScript type GroupElement. */
3942
val GroupElement = new Type(sigma.GroupElementRType)
4043

core/jvm/src/main/scala/sigma/crypto/Platform.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ object Platform {
185185
case _: Int => tpe == SInt
186186
case _: Long => tpe == SLong
187187
case _: BigInt => tpe == SBigInt
188+
case _: UnsignedBigInt => tpe == SUnsignedBigInt
188189
case _: String => tpe == SString // TODO v6.0: remove this case (see https://github.com/ScorexFoundation/sigmastate-interpreter/issues/905)
189190
case _: GroupElement => tpe.isGroupElement
190191
case _: SigmaProp => tpe.isSigmaProp

core/shared/src/main/scala/sigma/Colls.scala

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ trait Coll[@specialized A] {
4545
*/
4646
def apply(i: Int): A
4747

48+
/** The element at given index or None if there is no such element. Indices start at `0`.
49+
*
50+
* @param i the index
51+
* @return the element at the given index, or None if there is no such element
52+
*/
53+
def get(i: Int): Option[A] = {
54+
if (isDefinedAt(i)) {
55+
Some(apply(i))
56+
} else {
57+
None
58+
}
59+
}
60+
4861
/** Tests whether this $coll contains given index.
4962
*
5063
* The implementations of methods `apply` and `isDefinedAt` turn a `Coll[A]` into
@@ -76,6 +89,18 @@ trait Coll[@specialized A] {
7689
* produces a collection ((x0, y0), ..., (xK, yK)) where K = min(N, M) */
7790
def zip[@specialized B](ys: Coll[B]): Coll[(A, B)]
7891

92+
/**
93+
* @return true if first elements of this collection form given `ys` collection, false otherwise.
94+
* E.g. [1,2,3] starts with [1,2]
95+
*/
96+
def startsWith(ys: Coll[A]): Boolean
97+
98+
/**
99+
* @return true if last elements of this collection form given `ys` collection, false otherwise.
100+
* E.g. [1,2,3] ends with [2,3]
101+
*/
102+
def endsWith(ys: Coll[A]): Boolean
103+
79104
/** Tests whether a predicate holds for at least one element of this collection.
80105
* @param p the predicate used to test elements.
81106
* @return `true` if the given predicate `p` is satisfied by at least one element of this collection, otherwise `false`

core/shared/src/main/scala/sigma/Evaluation.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ object Evaluation {
2525
case SAny => AnyType
2626
case SUnit => UnitType
2727
case SBigInt => BigIntRType
28+
case SUnsignedBigInt => UnsignedBigIntRType
2829
case SBox => BoxRType
2930
case SContext => ContextRType
3031
case SGlobal => SigmaDslBuilderRType
@@ -67,6 +68,7 @@ object Evaluation {
6768
case AnyType => SAny
6869
case UnitType => SUnit
6970
case BigIntRType => SBigInt
71+
case UnsignedBigIntRType => SUnsignedBigInt
7072
case GroupElementRType => SGroupElement
7173
case AvlTreeRType => SAvlTree
7274
case ot: OptionType[_] => SOption(rtypeToSType(ot.tA))

0 commit comments

Comments
 (0)