-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from spectrum-finance/remove-explorer-deps
Remove explorer deps from bots
- Loading branch information
Showing
24 changed files
with
431 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
modules/dex-core/src/main/scala/org/ergoplatform/ergo/domain/sigma.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.ergoplatform.ergo.domain | ||
|
||
import cats.Eval | ||
import cats.data.OptionT | ||
import cats.syntax.traverse._ | ||
import scorex.util.encode.Base16 | ||
import sigmastate.Values.{Constant, ConstantNode, EvaluatedValue, SigmaPropConstant} | ||
import sigmastate._ | ||
import sigmastate.basics.DLogProtocol.ProveDlogProp | ||
|
||
object sigma { | ||
|
||
@inline def renderEvaluatedValue[T <: SType](ev: EvaluatedValue[T]): Option[(SigmaType, String)] = { | ||
def goRender[T0 <: SType](ev0: EvaluatedValue[T0]): OptionT[Eval, (SigmaType, String)] = | ||
ev0.tpe match { | ||
case SSigmaProp | SGroupElement => | ||
ev0 match { | ||
case SigmaPropConstant(ProveDlogProp(dlog)) => | ||
OptionT.some(SigmaType.SimpleKindSigmaType.SSigmaProp -> Base16.encode(dlog.pkBytes)) | ||
case ConstantNode(groupElem, SGroupElement) => | ||
OptionT.some( | ||
SigmaType.SimpleKindSigmaType.SGroupElement -> | ||
Base16.encode(groupElem.asInstanceOf[SGroupElement.WrappedType].getEncoded.toArray) | ||
) | ||
case _ => OptionT.none | ||
} | ||
case prim: SPrimType => | ||
val typeTerm = prim.toString.replaceAll("\\$", "") | ||
OptionT.fromOption[Eval](SigmaType.parse(typeTerm)).map(_ -> ev0.value.toString) | ||
case tuple: STuple => | ||
val typeTerm = tuple.toString.replaceAll("\\$", "") | ||
OptionT.fromOption[Eval](SigmaType.parse(typeTerm)).flatMap { tp => | ||
val untypedElems = ev0.value match { | ||
case (a, b) => List(a, b) | ||
case _ => ev0.value.asInstanceOf[tuple.WrappedType].toArray.toList | ||
} | ||
val elems = | ||
untypedElems.zip(tuple.items).map { case (vl, tp) => | ||
Constant[SType](vl.asInstanceOf[tp.WrappedType], tp) | ||
} | ||
elems.traverse(e => goRender(e).map(_._2)).map { xs => | ||
tp -> ("[" + xs.mkString(",") + "]") | ||
} | ||
} | ||
case SCollectionType(SByte) => | ||
OptionT.some( | ||
SigmaType.SCollection(SigmaType.SimpleKindSigmaType.SByte) -> | ||
Base16.encode(ev0.value.asInstanceOf[SCollection[SByte.type]#WrappedType].toArray) | ||
) | ||
case coll: SCollection[_] => | ||
val typeTerm = coll.toString.replaceAll("\\$", "") | ||
OptionT.fromOption[Eval](SigmaType.parse(typeTerm)).flatMap { tp => | ||
val elems = ev0.value.asInstanceOf[coll.WrappedType].toArray.toList.map(Constant(_, coll.elemType)) | ||
elems.traverse(e => goRender(e).map(_._2)).map { xs => | ||
tp -> ("[" + xs.mkString(",") + "]") | ||
} | ||
} | ||
case option: SOption[_] => | ||
OptionT.fromOption[Eval](SigmaType.parse(option.toTermString)).flatMap { tp => | ||
val elem = ev0.value.asInstanceOf[option.WrappedType].map(Constant(_, option.elemType)) | ||
elem match { | ||
case Some(value) => OptionT(Eval.defer(goRender(value).value)).map(r => tp -> r._2) | ||
case None => OptionT.some(tp -> "null") | ||
} | ||
} | ||
case _ => OptionT.none | ||
} | ||
|
||
goRender(ev).value.value | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.