Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move DataJsonEncoder and JsonCodecs to the sdk module #867

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ lazy val sc = (project in file("sc"))

lazy val sdk = crossProject(JVMPlatform, JSPlatform)
.in(file("sdk"))
.dependsOn(corelib % allConfigDependency, interpreter % allConfigDependency)
.dependsOn(corelib % allConfigDependency, interpreter % allConfigDependency, parsers % allConfigDependency)
.settings(commonSettings ++ testSettings2,
commonDependenies2,
testingDependencies2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sigmastate.serialization
package org.ergoplatform.sdk

import java.math.BigInteger
import io.circe._
Expand All @@ -10,14 +10,18 @@ import scalan.RType
import scorex.util._
import sigmastate.Values.{Constant, EvaluatedValue}
import sigmastate._
import sigmastate.eval._
import sigmastate.lang.SigmaParser
import sigmastate.eval._
import special.collection.Coll
import special.sigma._
import debox.cfor
import sigmastate.exceptions.SerializerException
import scala.collection.compat.immutable.ArraySeq
import scala.collection.mutable
import fastparse.{Parsed, parse}
import sigmastate.serialization.SigmaSerializer
import sigmastate.serialization.DataSerializer
import sigmastate.serialization.ErgoTreeSerializer

object DataJsonEncoder {
def encode[T <: SType](v: T#WrappedType, tpe: T): Json = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.ergoplatform
package org.ergoplatform.sdk

import java.math.BigInteger

Expand All @@ -16,12 +16,22 @@ import sigmastate.eval.Extensions._
import sigmastate.eval.{CPreHeader, WrapperOf, _}
import sigmastate.exceptions.SigmaException
import sigmastate.interpreter.{ContextExtension, ProverResult}
import sigmastate.serialization.{DataJsonEncoder, ErgoTreeSerializer, ValueSerializer}
import sigmastate.{AvlTreeData, AvlTreeFlags, SType}
import special.collection.Coll
import special.sigma.{AnyValue, Header, PreHeader}
import scala.util.Try
import sigmastate.utils.Helpers._ // required for Scala 2.11
import org.ergoplatform.ErgoBox
import sigmastate.serialization.ValueSerializer
import org.ergoplatform.DataInput
import org.ergoplatform.Input
import org.ergoplatform.UnsignedInput
import sigmastate.serialization.ErgoTreeSerializer
import org.ergoplatform.ErgoLikeTransaction
import org.ergoplatform.UnsignedErgoLikeTransaction
import org.ergoplatform.ErgoLikeTransactionTemplate
import org.ergoplatform.ErgoBoxCandidate
import org.ergoplatform.ErgoLikeContext

trait JsonCodecs {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package sigmastate.serialization
package org.ergoplatform.sdk


import java.math.BigInteger

import org.ergoplatform.JsonCodecs
import org.scalacheck.Arbitrary._
import scalan.RType
import sigmastate.SCollection.SByteArray
Expand All @@ -15,6 +14,7 @@ import sigmastate.eval.{Evaluation, _}
import sigmastate.basics.CryptoConstants.EcPointType
import sigmastate.exceptions.SerializerException
import special.sigma.{Box, AvlTree}
import sigmastate.serialization.SerializationSpecification

class DataJsonEncoderSpecification extends SerializationSpecification {
object JsonCodecs extends JsonCodecs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package org.ergoplatform
package org.ergoplatform.sdk


import io.circe._
import io.circe.syntax._
Expand All @@ -13,14 +14,21 @@ import sigmastate.Values.{ByteArrayConstant, ByteConstant, ErgoTree, EvaluatedVa
import sigmastate.basics.CryptoConstants
import sigmastate.basics.DLogProtocol.ProveDlog
import sigmastate.eval.Digest32Coll
import sigmastate.helpers.CompilerTestingCommons
import sigmastate.interpreter.{ContextExtension, ProverResult}
import sigmastate.serialization.SerializationSpecification
import sigmastate.utils.Helpers._
import special.collection.Coll
import special.sigma.{Header, PreHeader}

class JsonSerializationSpec extends CompilerTestingCommons with SerializationSpecification with JsonCodecs {
import org.ergoplatform.ErgoLikeContext
import org.ergoplatform.DataInput
import org.ergoplatform.Input
import org.ergoplatform.UnsignedInput
import org.ergoplatform.ErgoBox
import org.ergoplatform.ErgoLikeTransaction
import org.ergoplatform.UnsignedErgoLikeTransaction
import org.ergoplatform.ErgoLikeTransactionTemplate

class JsonSerializationSpec extends SerializationSpecification with JsonCodecs {

def jsonRoundTrip[T](v: T)(implicit encoder: Encoder[T], decoder: Decoder[T]): Unit = {
val json = v.asJson
Expand Down