Skip to content

Commit

Permalink
v5.0-finalize: descriptions for fromBase** predefined operations
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Oct 11, 2022
1 parent b55ec75 commit ac86fcb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ErgoLikeContext(val lastBlockUtxoRoot: AvlTreeData,
Examined ergo code: all that leads to ErgoLikeContext creation.
*/
require(spendingTransaction.dataInputs.length == dataBoxes.length &&
spendingTransaction.dataInputs.forall(dataInput => dataBoxes.exists(b => util.Arrays.equals(b.id, dataInput.boxId))),
spendingTransaction.dataInputs.forall(dataInput => dataBoxes.exists(b => java.util.Arrays.equals(b.id, dataInput.boxId))),
"dataBoxes do not correspond to spendingTransaction.dataInputs")

// TODO assert boxesToSpend correspond to spendingTransaction.inputs
Expand Down
28 changes: 20 additions & 8 deletions sigmastate/src/main/scala/sigmastate/lang/SigmaPredef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import scalan.Nullable
import scorex.util.encode.{Base64, Base58, Base16}
import sigmastate.SCollection.{SIntArray, SByteArray}
import sigmastate.SOption._
import sigmastate.Values.{StringConstant, Constant, EvaluatedValue, SValue, IntValue, SigmaPropConstant, ConstantPlaceholder, BoolValue, Value, ByteArrayConstant, SigmaPropValue, ValueCompanion}
import sigmastate.Values.{StringConstant, SValue, IntValue, SigmaPropConstant, Value, ByteArrayConstant, SigmaPropValue, ValueCompanion, Constant, EvaluatedValue, ConstantPlaceholder, BoolValue}
import sigmastate._
import sigmastate.lang.Terms._
import sigmastate.lang.exceptions.InvalidArguments
import sigmastate.serialization.ValueSerializer
import sigmastate.utxo.{GetVar, DeserializeContext, DeserializeRegister, SelectField}
import sigmastate.utxo.{DeserializeRegister, SelectField, DeserializeContext, GetVar}

object SigmaPredef {

Expand Down Expand Up @@ -44,7 +44,7 @@ object SigmaPredef {
import builder._

/** Type variable used in the signatures of global functions below. */
import SType.{tT, tR, tK, tL, tO, paramT, paramR}
import SType.{tT, tO, tR, tL, paramR, paramT, tK}

private val undefined: IrBuilderFunc =
PartialFunction.empty[(SValue, Seq[SValue]), SValue]
Expand Down Expand Up @@ -176,7 +176,7 @@ object SigmaPredef {
throw new InvalidArguments(s"Wrong type after deserialization, expected $tpe, got ${res.tpe}")
res
}),
OperationInfo(Constant, "",
OperationInfo(Constant, "Deserializes values from Base58 encoded binary data at compile time into a value of type T.",
Seq(ArgInfo("", "")))
)

Expand All @@ -186,7 +186,11 @@ object SigmaPredef {
{ case (_, Seq(arg: EvaluatedValue[SString.type]@unchecked)) =>
ByteArrayConstant(Base16.decode(arg.value).get)
}),
OperationInfo(Constant, "",
OperationInfo(Constant,
"""Transforms Base16 encoded string literal into constant of type Coll[Byte].
|It is a compile-time operation and only string literal (constant) can be its
|argument.
""".stripMargin,
Seq(ArgInfo("", "")))
)

Expand All @@ -196,8 +200,12 @@ object SigmaPredef {
{ case (_, Seq(arg: EvaluatedValue[SString.type]@unchecked)) =>
ByteArrayConstant(Base58.decode(arg.value).get)
}),
OperationInfo(Constant, "",
Seq(ArgInfo("", "")))
OperationInfo(Constant,
"""Transforms Base58 encoded string literal into constant of type Coll[Byte].
|It is a compile-time operation and only string literal (constant) can be its
|argument.
""".stripMargin,
Seq(ArgInfo("", "")))
)

val FromBase64Func = PredefinedFunc("fromBase64",
Expand All @@ -206,7 +214,11 @@ object SigmaPredef {
{ case (_, Seq(arg: EvaluatedValue[SString.type]@unchecked)) =>
ByteArrayConstant(Base64.decode(arg.value).get)
}),
OperationInfo(Constant, "",
OperationInfo(Constant,
"""Transforms Base64 encoded string literal into constant of type Coll[Byte].
|It is a compile-time operation and only string literal (constant) can be its
|argument.
""".stripMargin,
Seq(ArgInfo("", "")))
)

Expand Down

0 comments on commit ac86fcb

Please sign in to comment.