Skip to content

Commit

Permalink
Added shorthand on OpResult to get underlying value of tryOp,
Browse files Browse the repository at this point in the history
Updated to 5.0 Appkit Snapshot
  • Loading branch information
K-Singh committed Oct 13, 2022
1 parent 1afd4ab commit be05b46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
7 changes: 4 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import xerial.sbt.Sonatype.GitHubHosting

name := "getblok_plasma"
organization := "io.github.getblok-io"
version := "1.0.0"
version := "1.0.1"
//idePackagePrefix := Some("io.getblok.getblok_plasma")
scalaVersion := "2.12.10"
ThisBuild / version := "1.0.0"
ThisBuild / version := "1.0.1"
libraryDependencies ++= Seq(
"org.ergoplatform" %% "ergo-appkit" % "4.0.10",
"org.ergoplatform" %% "ergo-appkit" % "ac116c85-SNAPSHOT",
"org.scalatest" %% "scalatest" % "3.2.12" % "test",
"io.swaydb" %% "swaydb" % "0.16.2",
"io.swaydb" %% "boopickle" % "0.16.2",
Expand All @@ -31,6 +31,7 @@ resolvers ++= Seq(
"Bintray" at "https://jcenter.bintray.com/"
)


assemblyMergeStrategy in assembly := {
case "logback.xml" => MergeStrategy.first
case x if x.endsWith("module-info.class") => MergeStrategy.discard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import scala.util.Try
case class OpResult[V](tryOp: Try[Option[V]])(implicit converter: ByteConversion[V]) {
lazy val ergoType: ErgoType[java.lang.Byte] = ErgoType.byteType()

/**
* Shorthand for opResult.tryOp.get.get
* Will throw an exception if either the Try or the Option failed to return successfully.
* @return
* The underlying value returned by the operation
*/
def get: V = tryOp.get.get

def ergoValue: ErgoValue[Coll[java.lang.Byte]] = {
ErgoValue.of(Colls.fromArray(
converter.convertToBytes(tryOp.getOrElse(throw new NoResultException).getOrElse(throw new NoResultException)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ package io.getblok.getblok_plasma.collections
* @param proof The `Proof` associated with the applied operation.
* @tparam V The Value type associated with the PlasmaMap the operation was applied to
*/
case class ProvenResult[V](response: Seq[OpResult[V]], proof: Proof)
case class ProvenResult[V](response: Seq[OpResult[V]], proof: Proof)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.getblok.getblok_plasma.other_tests.PlasmaMapLevelDBSuite.{TestLong, co
import io.getblok.getblok_plasma.{ByteConversion, PlasmaParameters}
import org.bouncycastle.util.encoders.Hex
import org.ergoplatform.appkit.impl.ErgoTreeContract
import org.ergoplatform.appkit.{Address, InputBox, Parameters}
import org.ergoplatform.appkit.{Address, Eip4Token, InputBox, Parameters}
import org.scalatest.funsuite.AnyFunSuite
import scorex.crypto.authds.avltree.batch.VersionedLDBAVLStorage
import scorex.crypto.hash.{Blake2b256, Digest32}
Expand Down

0 comments on commit be05b46

Please sign in to comment.