diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala index 1fe8a209..ee30e233 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/AddressSpec.scala @@ -9,7 +9,8 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import scorex.util.encode.Base16 -import sigmastate.serialization.ErgoTreeSerializer +import sigma.ast.ErgoTree +import sigma.serialization.ErgoTreeSerializer @@ -97,7 +98,7 @@ class AddressSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropert val ergoTree = ErgoTreeSerializer.DefaultSerializer.deserializeErgoTree(Base16.decode(tree).get) val addr = Address.fromErgoTree(ergoTree, NetworkType.MAINNET) val addr2 = encoder.fromProposition(ergoTree).get - val addr3 = encoder.fromProposition(ergoTree.proposition).get + val addr3 = encoder.fromProposition(ErgoTree.fromProposition(ergoTree.toProposition(ergoTree.isConstantSegregation))).get val addr4 = Address.fromPropositionBytes(NetworkType.MAINNET, Base16.decode(tree).get) addr.getErgoAddress shouldBe addr2 addr.getErgoAddress shouldBe addr3 diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala index d8c914dc..70669093 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/AnonymousAccessSpec.scala @@ -7,10 +7,12 @@ import org.ergoplatform.appkit.testing.AppkitTesting import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.crypto.CryptoConstants -import sigmastate.eval._ +import sigma.crypto.CryptoConstants import sigmastate.helpers.NegativeTesting import sigma.GroupElement +import sigma.data.{CGroupElement, CBigInt} + +import java.math.BigInteger class AnonymousAccessSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks @@ -63,9 +65,9 @@ class AnonymousAccessSpec extends AnyPropSpec with Matchers ) val firstTxSenderStorage = "storage/E2.json" val secondTxSenderStorage = "storage/E1.json" - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator) + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val g_x:GroupElement = g.exp(x) val g_y:GroupElement = g.exp(y) val g_xy = g_x.exp(y) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala index 223f3ba6..53c26469 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/ApiClientSpec.scala @@ -8,8 +8,8 @@ import org.ergoplatform.validation.ValidationRules import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.Values.SigmaPropConstant -import sigmastate.serialization.ErgoTreeSerializer +import sigma.ast.SigmaPropConstant +import sigma.serialization.ErgoTreeSerializer class ApiClientSpec extends AnyPropSpec diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala index b9d162e4..86a9da76 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/AppkitProvingInterpreterSpec.scala @@ -1,9 +1,9 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.impl.{BlockchainContextImpl, InputBoxImpl, UnsignedTransactionBuilderImpl, UnsignedTransactionImpl} -import org.ergoplatform.sdk.{ErgoToken, ExtendedInputBox, Iso, JavaHelpers, SecretString, TokenBalanceException} +import org.ergoplatform.sdk.{ErgoToken, ExtendedInputBox, SdkIsos, JavaHelpers, SecretString, TokenBalanceException} import org.ergoplatform.sdk.JavaHelpers._ -import org.ergoplatform.sdk.Iso._ +import sigma.data.Iso._ import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.{ErgoBox, ErgoTreePredef, UnsignedErgoLikeTransaction} import org.scalatest.matchers.should.Matchers @@ -15,6 +15,7 @@ import sigmastate.helpers.NegativeTesting import sigmastate.helpers.TestingHelpers.createBox import java.util import java.util.{Collections, List => JList} +import SdkIsos._ class AppkitProvingInterpreterSpec extends AnyPropSpec with Matchers @@ -79,8 +80,8 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec val tree2 = ErgoTreePredef.FalseProp(ergoTreeHeaderInTests) val token1 = (ErgoAlgos.hash("id1").toTokenId, 10L) val token2 = (ErgoAlgos.hash("id2").toTokenId, 20L) - val ergoToken1 = Iso.isoErgoTokenToPair.from(token1) - val ergoToken2 = Iso.isoErgoTokenToPair.from(token2) + val ergoToken1 = SdkIsos.isoErgoTokenToPair.from(token1) + val ergoToken2 = SdkIsos.isoErgoTokenToPair.from(token2) val input1 = createBox(oneErg + Parameters.MinFee, tree1, additionalTokens = Seq(token1)) val input2 = createBox(oneErg, tree2, additionalTokens = Seq(token2)) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala index aa26750f..1877a356 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/ChangeOutputSpec.scala @@ -7,10 +7,13 @@ import org.ergoplatform.sdk.{ErgoToken, JavaHelpers} import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.crypto.CryptoConstants -import sigmastate.eval._ +import sigma.crypto.CryptoConstants import sigma.GroupElement +import sigma.data.{CGroupElement, CBigInt} +import sigma.util.Extensions.{BigIntegerOps, BigIntOps} +import org.ergoplatform.sdk.SdkIsos._ +import java.math.BigInteger import java.util.{Arrays, List => JList} class ChangeOutputSpec extends AnyPropSpec with Matchers @@ -20,9 +23,9 @@ class ChangeOutputSpec extends AnyPropSpec with Matchers property("YesChangeOutput") { val ergoClient = createMockedErgoClient(MockData(Nil, Nil)) - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator) + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val gX:GroupElement = g.exp(x) val gY:GroupElement = g.exp(y) val gXY:GroupElement = gX.exp(y) @@ -68,9 +71,9 @@ class ChangeOutputSpec extends AnyPropSpec with Matchers property("NoChangeOutput") { val ergoClient = createMockedErgoClient(MockData(Nil, Nil)) - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator) + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val gX:GroupElement = g.exp(x) val gY:GroupElement = g.exp(y) val gXY:GroupElement = gX.exp(y) @@ -117,9 +120,9 @@ class ChangeOutputSpec extends AnyPropSpec with Matchers property("NoTokenChangeOutput + token burning") { val ergoClient = createMockedErgoClient(MockData(Nil, Nil)) - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator) + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val gX:GroupElement = g.exp(x) val gY:GroupElement = g.exp(y) val gXY:GroupElement = gX.exp(y) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala index 8f773995..6a5b8499 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/DHTProverSpec.scala @@ -5,9 +5,12 @@ import org.ergoplatform.sdk.JavaHelpers import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.crypto.CryptoConstants -import sigmastate.eval._ +import sigma.crypto.CryptoConstants import sigma.GroupElement +import sigma.data.CBigInt +import sigma.util.Extensions.{BigIntegerOps, BigIntOps, EcpOps} + +import java.math.BigInteger class DHTProverSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks @@ -16,9 +19,9 @@ class DHTProverSpec extends AnyPropSpec with Matchers property("DHTProver") { val ergoClient = createMockedErgoClient(MockData(Nil, Nil)) - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CryptoConstants.dlogGroup.generator.toGroupElement + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val gX:GroupElement = g.exp(x) val gY:GroupElement = g.exp(y) val gXY:GroupElement = gX.exp(y) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/ErgoValueTest.java b/appkit/src/test/scala/org/ergoplatform/appkit/ErgoValueTest.java index ead148f7..9afe5604 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/ErgoValueTest.java +++ b/appkit/src/test/scala/org/ergoplatform/appkit/ErgoValueTest.java @@ -6,7 +6,7 @@ import java.math.BigInteger; -import sigmastate.eval.CBigInt; +import sigma.data.CBigInt; import sigma.Coll; import sigma.BigInt; diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala b/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala index 9c70807e..b0d39edc 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/HttpClientTesting.scala @@ -3,7 +3,7 @@ package org.ergoplatform.appkit import sigma.util.{FileUtil => SFileUtil} import org.ergoplatform.appkit import org.ergoplatform.sdk.JavaHelpers.UniversalConverter - +import org.ergoplatform.sdk.SdkIsos._ import java.util.{List => JList} import java.lang.{String => JString} diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala index 5f46a86f..aca39950 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/JavaHelpersSpec.scala @@ -8,9 +8,10 @@ import org.ergoplatform.wallet.mnemonic.{Mnemonic => WMnemonic} import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.Values.{ByteArrayConstant, EvaluatedValue, IntConstant} +import sigma.ast.{EvaluatedValue, ByteArrayConstant, SType, IntConstant, ErgoTree} +import sigma.data.TrivialProp import sigmastate.helpers.TestingHelpers._ -import sigmastate.{SType, TrivialProp} +import org.ergoplatform.sdk.SdkIsos._ class JavaHelpersSpec extends AnyPropSpec with Matchers with ScalaCheckDrivenPropertyChecks @@ -20,7 +21,7 @@ class JavaHelpersSpec extends AnyPropSpec with Matchers type Registers = Map[NonMandatoryRegisterId, _ <: EvaluatedValue[_ <: SType]] def boxWithRegs(regs: Registers) = { - testBox(10, TrivialProp.TrueProp, 100, Nil, regs) + testBox(10, ErgoTree.fromSigmaBoolean(TrivialProp.TrueProp), 100, Nil, regs) } def check(regs: Registers, expRegs: IndexedSeq[ErgoValue[_]]) = { diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala index 8b516ef8..74000c64 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDHTSpec.scala @@ -5,10 +5,11 @@ import org.ergoplatform.sdk.JavaHelpers import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.crypto.CryptoConstants -import sigmastate.eval._ +import sigma.crypto.CryptoConstants import sigma.GroupElement +import sigma.data.{CGroupElement, CBigInt} +import java.math.BigInteger import scala.util.Try class MultiProveDHTSpec extends AnyPropSpec with Matchers @@ -18,15 +19,15 @@ class MultiProveDHTSpec extends AnyPropSpec with Matchers property("Multi DHTProver") { val ergoClient = createMockedErgoClient(MockData(Nil, Nil)) - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator) + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val gX:GroupElement = g.exp(x) val gY:GroupElement = g.exp(y) val gXY:GroupElement = gX.exp(y) - val x1 = BigInt("287235612876647164378132684712638457").bigInteger - val y1 = BigInt("640956873409567839086738967389673896").bigInteger + val x1 = CBigInt(new BigInteger("287235612876647164378132684712638457")) + val y1 = CBigInt(new BigInteger("640956873409567839086738967389673896")) val gX1:GroupElement = g.exp(x1) val gY1:GroupElement = g.exp(y1) diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala index 9422ea84..7baafe7a 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/MultiProveDlogSpec.scala @@ -5,10 +5,11 @@ import org.ergoplatform.sdk.JavaHelpers import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.crypto.CryptoConstants -import sigmastate.eval._ +import sigma.crypto.CryptoConstants import sigma.GroupElement +import sigma.data.{CGroupElement, CBigInt} +import java.math.BigInteger import scala.util.Try class MultiProveDlogSpec extends AnyPropSpec with Matchers @@ -18,9 +19,9 @@ class MultiProveDlogSpec extends AnyPropSpec with Matchers property("Multi DlogProver") { val ergoClient = createMockedErgoClient(MockData(Nil, Nil)) - val g: GroupElement = CryptoConstants.dlogGroup.generator - val x = BigInt("187235612876647164378132684712638457631278").bigInteger - val y = BigInt("340956873409567839086738967389673896738906").bigInteger + val g: GroupElement = CGroupElement(CryptoConstants.dlogGroup.generator) + val x = CBigInt(new BigInteger("187235612876647164378132684712638457631278")) + val y = CBigInt(new BigInteger("340956873409567839086738967389673896738906")) val gX:GroupElement = g.exp(x) val gY:GroupElement = g.exp(y) @@ -55,10 +56,16 @@ class MultiProveDlogSpec extends AnyPropSpec with Matchers val unsigned = txB.boxesToSpend(inputs).outputs(output).fee(10000000).sendChangeTo(changeAddr).build() // Dlog with two different secrets - Try(ctx.newProverBuilder().withDLogSecret(x).withDLogSecret(y).build().sign(unsigned)).isSuccess shouldBe true + Try(ctx.newProverBuilder() + .withDLogSecret(x) + .withDLogSecret(y) + .build().sign(unsigned)).isSuccess shouldBe true // Dlog with wrong secret(s) - Try(ctx.newProverBuilder().withDLogSecret(x).withDLogSecret(BigInt(1).bigInteger).build().sign(unsigned)).isSuccess shouldBe false + Try(ctx.newProverBuilder() + .withDLogSecret(x) + .withDLogSecret(BigInt(1).bigInteger) + .build().sign(unsigned)).isSuccess shouldBe false // Dlog with duplicate secrets Try(ctx.newProverBuilder().withDLogSecret(x).withDLogSecret(y).withDLogSecret(x).build().sign(unsigned)).isSuccess shouldBe false diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala b/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala index ef942418..4bef3a34 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/TxBuilderSpec.scala @@ -3,20 +3,20 @@ package org.ergoplatform.appkit import com.google.gson.Gson import com.google.gson.reflect.TypeToken import org.ergoplatform.appkit.AppkitHelpers._ -import org.ergoplatform.appkit.InputBoxesSelectionException.{InputBoxLimitExceededException, NotEnoughCoinsForChangeException, NotEnoughErgsException} +import org.ergoplatform.appkit.InputBoxesSelectionException.{InputBoxLimitExceededException, NotEnoughErgsException, NotEnoughCoinsForChangeException} import org.ergoplatform.appkit.impl.{Eip4TokenBuilder, ErgoTreeContract} import org.ergoplatform.appkit.testing.AppkitTesting import org.ergoplatform.explorer.client.model.{Items, TokenInfo} import org.ergoplatform.sdk.JavaHelpers._ import org.ergoplatform.sdk.{ErgoToken, SecretString} -import org.ergoplatform.{ErgoBox, ErgoTreePredef, appkit} +import org.ergoplatform.sdk.SdkIsos._ +import org.ergoplatform.{appkit, ErgoBox, ErgoTreePredef} import org.scalacheck.Gen import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigma.util.{FileUtil => SFileUtil} import scorex.util.ModifierId -import sigmastate.eval.CBigInt import sigmastate.helpers.NegativeTesting import sigmastate.interpreter.HintsBag @@ -112,7 +112,7 @@ class TxBuilderSpec extends AnyPropSpec with Matchers ergoClient.execute { ctx: BlockchainContext => val contextVars = Seq( ContextVar.of(1.toByte, 100), - ContextVar.of(10.toByte, CBigInt(BigInteger.valueOf(100))) + ContextVar.of(10.toByte, BigInteger.valueOf(100)) ) val input = createTestInput(ctx) .withContextVars(contextVars:_*) @@ -133,7 +133,7 @@ class TxBuilderSpec extends AnyPropSpec with Matchers // alice signing bob's box. Does not work here but works in other cases. val prover = ctx.newProverBuilder().build() val signed = prover.sign(unsigned) - signed.getCost shouldBe 14565 + signed.getCost shouldBe 12310 // check the signed transaction contains all the context variables // we attached to the input box diff --git a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala index 2862cfef..589586fa 100644 --- a/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala +++ b/appkit/src/test/scala/org/ergoplatform/appkit/cli/CommandsTesting.scala @@ -3,7 +3,7 @@ package org.ergoplatform.appkit.cli import org.ergoplatform.appkit import sigma.util.{FileUtil => SFileUtil} import org.ergoplatform.sdk.JavaHelpers._ - +import org.ergoplatform.sdk.SdkIsos._ import java.util.{List => JList} import java.lang.{String => JString} import org.ergoplatform.appkit.FileMockedErgoClient diff --git a/build.sbt b/build.sbt index 298401d2..edd1f519 100644 --- a/build.sbt +++ b/build.sbt @@ -134,8 +134,8 @@ assemblyMergeStrategy in assembly := { lazy val allConfigDependency = "compile->compile;test->test" -val sigmaStateVersion = "5.0.12" -val ergoWalletVersion = "5.0.15" +val sigmaStateVersion = "5.0.14" +val ergoWalletVersion = "5.0.19-4-9f5a24bf-SNAPSHOT" lazy val sigmaState = ("org.scorexfoundation" %% "sigma-state" % sigmaStateVersion).force() .exclude("ch.qos.logback", "logback-classic") .exclude("org.scorexfoundation", "scrypto") diff --git a/common/src/main/java/org/ergoplatform/appkit/Address.java b/common/src/main/java/org/ergoplatform/appkit/Address.java index 707b94be..0ee1b367 100644 --- a/common/src/main/java/org/ergoplatform/appkit/Address.java +++ b/common/src/main/java/org/ergoplatform/appkit/Address.java @@ -14,11 +14,13 @@ import scala.MatchError; import scala.util.Try; import scorex.util.encode.Base58; -import sigmastate.Values; -import sigmastate.crypto.DLogProtocol; -import sigmastate.crypto.Platform; -import sigmastate.eval.CostingSigmaDslBuilder$; -import sigmastate.serialization.ErgoTreeSerializer; +import sigma.ast.ErgoTree; +import sigma.data.CGroupElement; +import sigma.data.ProveDlog; +import sigma.data.SigmaBoolean; + +import sigma.crypto.Platform; +import sigma.serialization.ErgoTreeSerializer; import sigmastate.utils.Helpers; import sigma.GroupElement; @@ -116,14 +118,14 @@ public ErgoAddress getErgoAddress() { /** * Extract public key from P2PKAddress. */ - public DLogProtocol.ProveDlog getPublicKey() { return asP2PK().pubkey(); } + public ProveDlog getPublicKey() { return asP2PK().pubkey(); } /** * Extract public key from P2PKAddress and return its group element */ public GroupElement getPublicKeyGE() { Platform.Ecp point = getPublicKey().value(); - return CostingSigmaDslBuilder$.MODULE$.GroupElement(point); + return new CGroupElement(point); } /** @@ -157,9 +159,14 @@ public boolean isSigmaBoolean() { * @return SigmaBoolean value of this address. Throws an error if * {@link #isSigmaBoolean()} is false */ - public Values.SigmaBoolean getSigmaBoolean() { - Values.ErgoTree ergoTree = getErgoAddress().script(); - return JavaHelpers.toSigmaBoolean(ergoTree); + public SigmaBoolean getSigmaBoolean() { + ErgoTree ergoTree = getErgoAddress().script(); + scala.Option sbOpt = ergoTree.toSigmaBooleanOpt(); + if (sbOpt.isDefined()) + return sbOpt.get(); + else + throw new IllegalStateException( + "Cannot extract SigmaBoolean from ErgoTree: " + ergoTree); } /** @@ -203,7 +210,7 @@ public static Address fromMnemonic(NetworkType networkType, Mnemonic mnemonic, B public static Address fromMnemonic( NetworkType networkType, SecretString mnemonic, SecretString mnemonicPass, Boolean usePre1627KeyDerivation) { ExtendedSecretKey masterKey = JavaHelpers.seedToMasterKey(mnemonic, mnemonicPass, usePre1627KeyDerivation); - DLogProtocol.ProveDlog pk = masterKey.publicImage(); + ProveDlog pk = masterKey.publicImage(); P2PKAddress p2pkAddress = JavaHelpers.createP2PKAddress(pk, networkType.networkPrefix); return new Address(p2pkAddress); } @@ -260,15 +267,15 @@ public static Address createEip3Address( return new Address(p2pkAddress); } - public static Address fromErgoTree(Values.ErgoTree ergoTree, NetworkType networkType) { + public static Address fromErgoTree(ErgoTree ergoTree, NetworkType networkType) { ErgoAddressEncoder encoder = ErgoAddressEncoder.apply(networkType.networkPrefix); ErgoAddress ergoAddress = encoder.fromProposition(ergoTree).get(); return new Address(ergoAddress); } - public static Address fromSigmaBoolean(Values.SigmaBoolean sigmaBoolean, NetworkType networkType) { - Values.ErgoTree ergoTree = JavaHelpers.toErgoTree(sigmaBoolean); + public static Address fromSigmaBoolean(SigmaBoolean sigmaBoolean, NetworkType networkType) { + ErgoTree ergoTree = JavaHelpers.toErgoTree(sigmaBoolean); return fromErgoTree(ergoTree, networkType); } diff --git a/common/src/main/java/org/ergoplatform/appkit/Constants.java b/common/src/main/java/org/ergoplatform/appkit/Constants.java index 5cacfaae..2ced37fd 100644 --- a/common/src/main/java/org/ergoplatform/appkit/Constants.java +++ b/common/src/main/java/org/ergoplatform/appkit/Constants.java @@ -1,6 +1,6 @@ package org.ergoplatform.appkit; -import sigmastate.lang.SigmaBuilder; +import sigma.ast.SigmaBuilder; import java.util.LinkedHashMap; diff --git a/common/src/main/java/org/ergoplatform/appkit/ContextVar.java b/common/src/main/java/org/ergoplatform/appkit/ContextVar.java index 9e450963..a32f24de 100644 --- a/common/src/main/java/org/ergoplatform/appkit/ContextVar.java +++ b/common/src/main/java/org/ergoplatform/appkit/ContextVar.java @@ -2,9 +2,10 @@ import org.bouncycastle.math.ec.ECPoint; import org.ergoplatform.ErgoBox; -import sigmastate.AvlTreeData; -import sigmastate.Values; +import sigma.data.AvlTreeData; + import sigma.GroupElement; +import sigma.data.SigmaBoolean; import java.math.BigInteger; import java.util.Objects; @@ -13,7 +14,7 @@ * Represents one context variable binding (id -> value), where * id is in range [0 .. Byte.MaxValue]. * Can be attached to each input box of the unsigned transaction. - * @see sigmastate.interpreter.ContextExtension + * @see sigma.interpreter.ContextExtension */ public class ContextVar { /** Minimal valid id of a context variable. */ @@ -28,9 +29,9 @@ public class ContextVar { /** * Construct a new instance * - * @param id identifier of the variable in range [0 .. Byte.MaxValue]. + * @param id identifier of the variable in range `[0 .. Byte.MaxValue]`. * @param value value of the variable - * @see sigmastate.interpreter.ContextExtension + * @see sigma.interpreter.ContextExtension * @see ErgoValue */ public ContextVar(byte id, ErgoValue value) { @@ -94,7 +95,7 @@ static public ContextVar of(byte id, GroupElement value) { return new ContextVar(id, ErgoValue.of(value)); } - static public ContextVar of(byte id, Values.SigmaBoolean value) { + static public ContextVar of(byte id, SigmaBoolean value) { return new ContextVar(id, ErgoValue.of(value)); } diff --git a/common/src/main/java/org/ergoplatform/appkit/ErgoContract.java b/common/src/main/java/org/ergoplatform/appkit/ErgoContract.java index 64e863cf..b8b4bbf8 100644 --- a/common/src/main/java/org/ergoplatform/appkit/ErgoContract.java +++ b/common/src/main/java/org/ergoplatform/appkit/ErgoContract.java @@ -1,10 +1,11 @@ package org.ergoplatform.appkit; -import sigmastate.Values; +import sigma.ast.ErgoTree; + /** * Representation of ErgoScript contract using source code and named constants. - * This information is enough to compile contract into {@link Values.ErgoTree}. + * This information is enough to compile contract into {@link ErgoTree}. * Once constructed the instances are immutable. * Methods which do transformations produce new instances. */ @@ -27,7 +28,7 @@ public interface ErgoContract { /** * Returns the underlying ErgoTree used by this contract */ - Values.ErgoTree getErgoTree(); + ErgoTree getErgoTree(); /** * Get the base58 encoded address that represents this contract diff --git a/common/src/main/java/org/ergoplatform/appkit/ErgoTreeTemplate.java b/common/src/main/java/org/ergoplatform/appkit/ErgoTreeTemplate.java index 86d2386c..8fa82b39 100644 --- a/common/src/main/java/org/ergoplatform/appkit/ErgoTreeTemplate.java +++ b/common/src/main/java/org/ergoplatform/appkit/ErgoTreeTemplate.java @@ -8,10 +8,11 @@ import org.ergoplatform.sdk.JavaHelpers; import scala.collection.IndexedSeq; import scorex.util.encode.Base16; -import sigmastate.SType; -import sigmastate.Values; -import sigmastate.Values.Constant; -import sigmastate.serialization.ErgoTreeSerializer; +import sigma.ast.ErgoTree; +import sigma.ast.SType; + +import sigma.ast.Constant; +import sigma.serialization.ErgoTreeSerializer; /** * Represents ErgoTree template, which is an ErgoTree instance with placeholders. @@ -21,11 +22,11 @@ public class ErgoTreeTemplate { private static int[] _noParameters = new int[0]; // immutable and shared by all instances - private final Values.ErgoTree _tree; + private final ErgoTree _tree; private final byte[] _templateBytes; private int[] _parameterPositions = _noParameters; - private ErgoTreeTemplate(Values.ErgoTree tree) { + private ErgoTreeTemplate(ErgoTree tree) { _tree = tree; _templateBytes = JavaHelpers.ergoTreeTemplateBytes(_tree); } @@ -37,7 +38,7 @@ private ErgoTreeTemplate(Values.ErgoTree tree) { * @param positions zero-based indexes in `ErgoTree.constants` array which can be * substituted as parameters using * {@link ErgoTreeTemplate#applyParameters(ErgoValue[])} method. - * @see sigmastate.Values.ErgoTree + * @see ErgoTree */ public ErgoTreeTemplate withParameterPositions(int[] positions) { HashSet integerHashSet = new HashSet<>(positions.length); @@ -140,7 +141,7 @@ public ErgoValue getParameterValue(int paramIndex) { * @return new ErgoTree with the same template as this but with all it's parameters * replaced with `newValues` */ - public Values.ErgoTree applyParameters(ErgoValue... newValues) { + public ErgoTree applyParameters(ErgoValue... newValues) { if (newValues.length != _parameterPositions.length) throw new IllegalArgumentException( "Wrong number of newValues. Expected " + _parameterPositions.length + @@ -148,12 +149,12 @@ public Values.ErgoTree applyParameters(ErgoValue... newValues) { return AppkitHelpers.substituteErgoTreeConstants(_tree.bytes(), _parameterPositions, newValues); } - public static ErgoTreeTemplate fromErgoTree(Values.ErgoTree tree) { + public static ErgoTreeTemplate fromErgoTree(ErgoTree tree) { return new ErgoTreeTemplate(tree); } public static ErgoTreeTemplate fromErgoTreeBytes(byte[] treeBytes) { - Values.ErgoTree ergoTree = + ErgoTree ergoTree = ErgoTreeSerializer.DefaultSerializer().deserializeErgoTree(treeBytes); return fromErgoTree(ergoTree); } diff --git a/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java b/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java index 4e01c2ae..0fe70c1f 100644 --- a/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java +++ b/common/src/main/java/org/ergoplatform/appkit/ErgoValue.java @@ -2,16 +2,17 @@ import org.bouncycastle.math.ec.ECPoint; import org.ergoplatform.ErgoBox; -import org.ergoplatform.sdk.Iso; +import org.ergoplatform.sdk.SdkIsos; +import sigma.ast.EvaluatedValue; import org.ergoplatform.sdk.JavaHelpers; import scala.Tuple2; import scorex.util.encode.Base16; -import sigmastate.AvlTreeData; -import sigmastate.SType; -import sigmastate.Values; -import sigmastate.crypto.Platform; -import sigmastate.serialization.ValueSerializer; -import sigmastate.serialization.ValueSerializer$; +import sigma.data.AvlTreeData; +import sigma.ast.SType; +import sigma.crypto.Platform; +import sigma.data.SigmaBoolean; +import sigma.serialization.ValueSerializer; +import sigma.serialization.ValueSerializer$; import sigma.Coll; import sigma.AvlTree; import sigma.BigInt; @@ -44,13 +45,13 @@ public ErgoType getType() { /** * Encode this value as Base16 hex string. - * 1) it transforms this value into {@link Values.ConstantNode} of sigma. - * 2) it serializes the constant into byte array using {@link sigmastate.serialization.ConstantSerializer} + * 1) it transforms this value into {@link sigma.ast.ConstantNode} of sigma. + * 2) it serializes the constant into byte array using {@link sigma.serialization.ConstantSerializer} * 3) the bytes are encoded using Base16 encoder into string * @return hex string of serialized bytes */ public String toHex() { - Values.EvaluatedValue c = AppkitIso.isoErgoValueToSValue().to(this); + EvaluatedValue c = AppkitIso.isoErgoValueToSValue().to(this); byte[] bytes = ValueSerializer$.MODULE$.serialize(c); return Base16.encode(bytes); } @@ -76,23 +77,23 @@ public String toString() { } static public ErgoValue of(byte value) { - return new ErgoValue(Iso.jbyteToByte().to(Byte.valueOf(value)), ErgoType.byteType()); + return new ErgoValue(SdkIsos.jbyteToByte().to(Byte.valueOf(value)), ErgoType.byteType()); } static public ErgoValue of(short value) { - return new ErgoValue(Iso.jshortToShort().to(Short.valueOf(value)), ErgoType.shortType()); + return new ErgoValue(SdkIsos.jshortToShort().to(Short.valueOf(value)), ErgoType.shortType()); } static public ErgoValue of(int value) { - return new ErgoValue(Iso.jintToInt().to(value), ErgoType.integerType()); + return new ErgoValue(SdkIsos.jintToInt().to(value), ErgoType.integerType()); } static public ErgoValue of(long value) { - return new ErgoValue(Iso.jlongToLong().to(Long.valueOf(value)), ErgoType.longType()); + return new ErgoValue(SdkIsos.jlongToLong().to(Long.valueOf(value)), ErgoType.longType()); } static public ErgoValue of(boolean value) { - return new ErgoValue(Iso.jboolToBool().to(Boolean.valueOf(value)), ErgoType.booleanType()); + return new ErgoValue(SdkIsos.jboolToBool().to(Boolean.valueOf(value)), ErgoType.booleanType()); } static public ErgoValue unit() { @@ -112,7 +113,7 @@ static public ErgoValue of(GroupElement ge) { return new ErgoValue<>(ge, ErgoType.groupElementType()); } - static public ErgoValue of(Values.SigmaBoolean value) { + static public ErgoValue of(SigmaBoolean value) { return new ErgoValue<>(JavaHelpers.SigmaDsl().SigmaProp(value), ErgoType.sigmaPropType()); } @@ -191,7 +192,7 @@ static public ErgoValue of(T value, ErgoType tT) { */ static public ErgoValue fromHex(String hex) { byte[] bytes = JavaHelpers.decodeStringToBytes(hex); - Values.EvaluatedValue c = (Values.EvaluatedValue)ValueSerializer.deserialize(bytes, 0); + EvaluatedValue c = (EvaluatedValue)ValueSerializer.deserialize(bytes, 0); ErgoValue res = AppkitIso.isoErgoValueToSValue().from(c); return res; } diff --git a/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala b/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala index c96d825e..7602931e 100644 --- a/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala +++ b/common/src/main/java/org/ergoplatform/appkit/JavaHelpers.scala @@ -4,26 +4,24 @@ import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform.ErgoBox.TokenId import org.ergoplatform.ErgoScriptPredef.compileWithCosting import org.ergoplatform._ -import org.ergoplatform.sdk.Iso._ -import org.ergoplatform.sdk.JavaHelpers.{UniversalConverter, collRType} -import org.ergoplatform.sdk.{ErgoToken, Iso, LowPriorityIsos} -import sigma.Colls -import sigma.data.RType -import sigmastate.SType -import sigmastate.Values.{Constant, ErgoTree, EvaluatedValue} -import sigmastate.eval.CostingSigmaDslBuilder.validationSettings -import sigmastate.eval.{CompiletimeIRContext, Evaluation} -import sigmastate.interpreter.ContextExtension -import sigmastate.lang.Terms.ValueOps -import sigmastate.serialization.ErgoTreeSerializer - +import org.ergoplatform.sdk.JavaHelpers.{collRType, UniversalConverter} +import org.ergoplatform.sdk.{ErgoToken, SdkIsos, LowPriorityIsos} +import sigma.{Evaluation, Colls} +import sigma.data.{Iso, RType} +import sigma.ast.SType +import sigma.ast.syntax.ValueOps +import sigma.ast.{EvaluatedValue, Constant, ErgoTree} +import sigma.data.CSigmaDslBuilder.validationSettings +import sigma.interpreter.ContextExtension +import sigma.serialization.ErgoTreeSerializer +import sigmastate.eval.CompiletimeIRContext +import org.ergoplatform.sdk.SdkIsos._ import java.util import java.util.{List => JList} import scala.collection.JavaConverters import scala.collection.compat.immutable.ArraySeq object AppkitIso extends LowPriorityIsos { - import org.ergoplatform.sdk.Iso._ implicit val isoErgoTypeToSType: Iso[ErgoType[_], SType] = new Iso[ErgoType[_], SType] { override def to(et: ErgoType[_]): SType = Evaluation.rtypeToSType(et.getRType) override def from(st: SType): ErgoType[_] = new ErgoType(Evaluation.stypeToRType(st)) @@ -51,7 +49,7 @@ object AppkitIso extends LowPriorityIsos { ContextExtension(values) } override def from(b: ContextExtension): JList[ContextVar] = { - val iso = JListToIndexedSeq[ContextVar, ContextVar] + val iso = SdkIsos.JListToIndexedSeq[ContextVar, ContextVar] val vars = iso.from(b.values .map { case (id, v) => new ContextVar(id, isoErgoValueToSValue.from(v)) } .toIndexedSeq) @@ -62,6 +60,7 @@ object AppkitIso extends LowPriorityIsos { } object AppkitHelpers { + implicit class ListOps[A](val xs: JList[A]) extends AnyVal { def map[B](f: A => B): JList[B] = { xs.convertTo[IndexedSeq[A]].map(f).convertTo[JList[B]] diff --git a/common/src/main/java/org/ergoplatform/appkit/Mnemonic.java b/common/src/main/java/org/ergoplatform/appkit/Mnemonic.java index b84db8ed..13354a1d 100644 --- a/common/src/main/java/org/ergoplatform/appkit/Mnemonic.java +++ b/common/src/main/java/org/ergoplatform/appkit/Mnemonic.java @@ -1,6 +1,6 @@ package org.ergoplatform.appkit; -import org.ergoplatform.sdk.Iso; +import org.ergoplatform.sdk.SdkIsos; import org.ergoplatform.sdk.JavaHelpers; import org.ergoplatform.sdk.SecretString; import org.ergoplatform.wallet.mnemonic.WordList; @@ -88,7 +88,7 @@ public SecretString getPassword() { } public byte[] toSeed() { - Option passOpt = Iso.arrayCharToOptionString().to(getPassword()); + Option passOpt = SdkIsos.arrayCharToOptionString().to(getPassword()); return JavaHelpers.mnemonicToSeed(String.valueOf(_phrase), passOpt); } diff --git a/common/src/main/java/org/ergoplatform/appkit/SecretStorage.java b/common/src/main/java/org/ergoplatform/appkit/SecretStorage.java index 2b02e801..9d340e81 100644 --- a/common/src/main/java/org/ergoplatform/appkit/SecretStorage.java +++ b/common/src/main/java/org/ergoplatform/appkit/SecretStorage.java @@ -11,7 +11,7 @@ import scala.runtime.BoxedUnit; import scala.util.Failure; import scala.util.Try; -import sigmastate.crypto.DLogProtocol; +import sigma.data.ProveDlog; import java.io.File; @@ -45,7 +45,7 @@ public ExtendedSecretKey getSecret() { } public Address getAddressFor(NetworkType networkType) { - DLogProtocol.ProveDlog pk = _jsonStorage.secret().get().publicImage(); + ProveDlog pk = _jsonStorage.secret().get().publicImage(); P2PKAddress p2pk = JavaHelpers.createP2PKAddress(pk, networkType.networkPrefix); return new Address(p2pk); } @@ -66,7 +66,7 @@ public void unlock(String encryptionPass) { /** * Initializes storage with the seed derived from an existing mnemonic phrase. * @param mnemonic - mnemonic phase - * @param encryptionPass - encryption password + * @param encryptionPassword - encryption password * @param usePre1627KeyDerivation use incorrect(previous) BIP32 derivation, expected to be false for new * wallets, and true for old pre-1627 wallets (see https://github.com/ergoplatform/ergo/issues/1627 for details) */ diff --git a/common/src/main/java/org/ergoplatform/appkit/SigmaProp.java b/common/src/main/java/org/ergoplatform/appkit/SigmaProp.java index 0478ab38..3726fc73 100644 --- a/common/src/main/java/org/ergoplatform/appkit/SigmaProp.java +++ b/common/src/main/java/org/ergoplatform/appkit/SigmaProp.java @@ -1,16 +1,16 @@ package org.ergoplatform.appkit; -import org.ergoplatform.sdk.Iso; +import org.ergoplatform.sdk.SdkIsos; import org.ergoplatform.sdk.JavaHelpers; -import sigmastate.Values; +import sigma.data.SigmaBoolean; /** * Proposition which can be proven and verified by sigma protocol. */ public class SigmaProp { - private final Values.SigmaBoolean sigmaBoolean; + private final SigmaBoolean sigmaBoolean; - public SigmaProp(Values.SigmaBoolean sigmaBoolean) { + public SigmaProp(SigmaBoolean sigmaBoolean) { this.sigmaBoolean = sigmaBoolean; } @@ -18,7 +18,7 @@ public SigmaProp(sigma.SigmaProp sigmaProp) { this(JavaHelpers.SigmaDsl().toSigmaBoolean(sigmaProp)); } - public Values.SigmaBoolean getSigmaBoolean() { + public SigmaBoolean getSigmaBoolean() { return sigmaBoolean; } @@ -26,7 +26,7 @@ public Values.SigmaBoolean getSigmaBoolean() { * Serializes this SigmaProp. */ public byte[] toBytes() { - return Iso.isoSigmaBooleanToByteArray().to(sigmaBoolean); + return SdkIsos.isoSigmaBooleanToByteArray().to(sigmaBoolean); } public Address toAddress(NetworkType networkType) { @@ -37,7 +37,7 @@ public Address toAddress(NetworkType networkType) { * @return SigmaProp equal to the one that was serialized with {@link #toBytes()} */ public static SigmaProp parseFromBytes(byte[] serializedBytes) { - return new SigmaProp(Iso.isoSigmaBooleanToByteArray().from(serializedBytes)); + return new SigmaProp(SdkIsos.isoSigmaBooleanToByteArray().from(serializedBytes)); } /** diff --git a/common/src/main/java/org/ergoplatform/appkit/impl/ErgoScriptContract.java b/common/src/main/java/org/ergoplatform/appkit/impl/ErgoScriptContract.java index 9a8a793d..3924faa9 100644 --- a/common/src/main/java/org/ergoplatform/appkit/impl/ErgoScriptContract.java +++ b/common/src/main/java/org/ergoplatform/appkit/impl/ErgoScriptContract.java @@ -1,8 +1,7 @@ package org.ergoplatform.appkit.impl; import org.ergoplatform.appkit.*; -import sigmastate.Values; - +import sigma.ast.ErgoTree; public class ErgoScriptContract implements ErgoContract { final private Constants _constants; @@ -41,8 +40,8 @@ public ErgoScriptContract substConstant(String name, Object value) { } @Override - public Values.ErgoTree getErgoTree() { - Values.ErgoTree ergoTree = AppkitHelpers.compile( + public ErgoTree getErgoTree() { + ErgoTree ergoTree = AppkitHelpers.compile( _constants, _code, _networkType.networkPrefix); return ergoTree; } diff --git a/common/src/main/java/org/ergoplatform/appkit/impl/ErgoTreeContract.java b/common/src/main/java/org/ergoplatform/appkit/impl/ErgoTreeContract.java index dca3f66b..5726628e 100644 --- a/common/src/main/java/org/ergoplatform/appkit/impl/ErgoTreeContract.java +++ b/common/src/main/java/org/ergoplatform/appkit/impl/ErgoTreeContract.java @@ -5,12 +5,12 @@ import org.ergoplatform.appkit.Constants; import org.ergoplatform.appkit.ErgoContract; import org.ergoplatform.appkit.NetworkType; -import sigmastate.Values; +import sigma.ast.ErgoTree; public class ErgoTreeContract implements ErgoContract { - private final Values.ErgoTree _ergoTree; + private final ErgoTree _ergoTree; private final NetworkType _networkType; - public ErgoTreeContract(Values.ErgoTree ergoTree, NetworkType networkType) { + public ErgoTreeContract(ErgoTree ergoTree, NetworkType networkType) { _ergoTree = ergoTree; _networkType = networkType; } @@ -31,7 +31,7 @@ public ErgoTreeContract substConstant(String name, Object value) { } @Override - public Values.ErgoTree getErgoTree() { + public ErgoTree getErgoTree() { return _ergoTree; } diff --git a/common/src/test/scala/org/ergoplatform/appkit/AppkitTestingCommon.scala b/common/src/test/scala/org/ergoplatform/appkit/AppkitTestingCommon.scala index 1749faa7..7feccb8e 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/AppkitTestingCommon.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/AppkitTestingCommon.scala @@ -2,7 +2,6 @@ package org.ergoplatform.appkit import org.ergoplatform.sdk.SecretString import sigma.data.RType -import sigmastate.eval.SigmaDsl trait AppkitTestingCommon { /** The mnemonic used in tests and test vectors. */ @@ -30,5 +29,5 @@ trait AppkitTestingCommon { false) /** Helper method to construct a collection from items. */ - def Coll[T](items: T*)(implicit cT: RType[T]) = SigmaDsl.Colls.fromItems(items:_*) + def Coll[T](items: T*)(implicit cT: RType[T]) = sigma.Colls.fromItems(items:_*) } diff --git a/common/src/test/scala/org/ergoplatform/appkit/ErgoTreeTemplateSpec.scala b/common/src/test/scala/org/ergoplatform/appkit/ErgoTreeTemplateSpec.scala index bad7272d..1370fa6b 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/ErgoTreeTemplateSpec.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/ErgoTreeTemplateSpec.scala @@ -2,18 +2,19 @@ package org.ergoplatform.appkit import org.ergoplatform.appkit.AppkitIso.isoErgoTypeToSType import org.ergoplatform.sdk.JavaHelpers.UniversalConverter -import sigmastate.Values.{ErgoTree, IntConstant} +import sigma.ast.{IntConstant, ErgoTree} import sigmastate.helpers.NegativeTesting -import sigmastate.serialization.generators.ObjectGenerators -import sigmastate.{EQ, Plus, SInt, SType} - +import sigma.serialization.generators.ObjectGenerators +import sigma.ast.{SType, SInt, EQ} +import sigmastate.Plus +import org.ergoplatform.sdk.SdkIsos._ import java.util.{List => JList} class ErgoTreeTemplateSpec extends TestingBase with AppkitTestingCommon with ObjectGenerators with NegativeTesting { - val tree = ErgoTree.fromProposition(EQ(IntConstant(10), Plus(IntConstant(9), IntConstant(1)))) + val tree = ErgoTree.fromProposition(EQ(IntConstant(10), Plus(IntConstant(9), IntConstant(1))).toSigmaProp) property("should create template without parameters") { tree.constants.length shouldBe 3 @@ -35,7 +36,7 @@ class ErgoTreeTemplateSpec extends TestingBase .withParameterPositions(Array(0)) val newTree = template.applyParameters(ErgoValue.of(11)) val expectedTree = ErgoTree.fromProposition( - EQ(IntConstant(11), Plus(IntConstant(9), IntConstant(1))) + EQ(IntConstant(11), Plus(IntConstant(9), IntConstant(1))).toSigmaProp ) newTree shouldBe expectedTree diff --git a/common/src/test/scala/org/ergoplatform/appkit/ErgoValueSpec.scala b/common/src/test/scala/org/ergoplatform/appkit/ErgoValueSpec.scala index 54f2e7db..1ec27038 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/ErgoValueSpec.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/ErgoValueSpec.scala @@ -1,14 +1,13 @@ package org.ergoplatform.appkit import scorex.util.encode.Base16 -import sigmastate._ -import sigmastate.Values.Constant -import sigmastate.serialization.ValueSerializer -import sigmastate.serialization.generators.ObjectGenerators +import sigma.ast._ +import sigma.serialization.ValueSerializer +import sigma.serialization.generators.ObjectGenerators import org.ergoplatform.sdk.JavaHelpers._ +import org.ergoplatform.sdk.SdkIsos._ import org.ergoplatform.sdk.JavaHelpers.UniversalConverter -import sigmastate.eval.Evaluation.fromDslTuple -import sigma.Coll +import sigma.{Coll, Evaluation} class ErgoValueSpec extends TestingBase with AppkitTestingCommon with ObjectGenerators { @@ -43,7 +42,7 @@ class ErgoValueSpec extends TestingBase with AppkitTestingCommon with ObjectGene property("ErgoValue with pair (hex test vector)") { val tuple = (10.toByte, 20L) val tupSType = STuple(SByte, SLong) - val c = Constant[STuple](fromDslTuple(tuple, tupSType), tupSType) + val c = Constant[STuple](Evaluation.fromDslTuple(tuple, tupSType), tupSType) val hex = constToHex(c) hex shouldBe "3e050a28" diff --git a/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala b/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala index 82169f5f..a88033de 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/ReducedErgoLikeTransactionSpec.scala @@ -7,10 +7,10 @@ import org.scalatest.Assertion import org.scalatest.matchers.should.Matchers import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import sigmastate.CrossVersionProps -import sigmastate.interpreter.ContextExtension +import sigma.interpreter.ContextExtension import sigmastate.interpreter.Interpreter.ReductionResult -import sigmastate.serialization.SigmaSerializer -import sigmastate.serialization.generators.ObjectGenerators +import sigma.serialization.SigmaSerializer +import sigma.serialization.generators.ObjectGenerators class ReducedErgoLikeTransactionSpec extends CrossVersionProps with Matchers with ScalaCheckDrivenPropertyChecks with ObjectGenerators { diff --git a/common/src/test/scala/org/ergoplatform/appkit/scalaapi/ErgoValueBuilderSpec.scala b/common/src/test/scala/org/ergoplatform/appkit/scalaapi/ErgoValueBuilderSpec.scala index c0685df0..2bb694fb 100644 --- a/common/src/test/scala/org/ergoplatform/appkit/scalaapi/ErgoValueBuilderSpec.scala +++ b/common/src/test/scala/org/ergoplatform/appkit/scalaapi/ErgoValueBuilderSpec.scala @@ -1,13 +1,13 @@ package org.ergoplatform.appkit.scalaapi -import org.ergoplatform.appkit.{AppkitTestingCommon, BoxAttachment, BoxAttachmentGeneric, ErgoType, ErgoValue, TestingBase} +import org.ergoplatform.appkit.{BoxAttachment, BoxAttachmentGeneric, ErgoValue, TestingBase, ErgoType, AppkitTestingCommon} import org.ergoplatform.sdk.JavaHelpers import sigma.data.{CollType, RType} -import sigmastate.eval.SigmaDsl +import sigma.eval.SigmaDsl import sigma.Coll import sigma.Box -import java.lang.{Boolean => JBoolean, Byte => JByte, Integer => JInt, Long => JLong, Short => JShort} +import java.lang.{Boolean => JBoolean, Short => JShort, Integer => JInt, Long => JLong, Byte => JByte} import java.math.BigInteger class ErgoValueBuilderSpec extends TestingBase with AppkitTestingCommon { diff --git a/lib-api/src/main/java/org/ergoplatform/appkit/BlockchainContext.java b/lib-api/src/main/java/org/ergoplatform/appkit/BlockchainContext.java index e6d2b5ed..956483b2 100644 --- a/lib-api/src/main/java/org/ergoplatform/appkit/BlockchainContext.java +++ b/lib-api/src/main/java/org/ergoplatform/appkit/BlockchainContext.java @@ -1,14 +1,15 @@ package org.ergoplatform.appkit; import org.ergoplatform.sdk.ErgoToken; -import sigmastate.Values; + import java.util.List; import java.util.function.Function; +import sigma.ast.ErgoTree; /** * This interface represent a specific context of blockchain for execution - * of transaction transaction building scenario. + * of transaction building scenario. * It contains methods for accessing blockchain data, current blockchain state, * node information etc. * An instance of this interface can also be used to create new builders @@ -78,7 +79,7 @@ public interface BlockchainContext { */ String sendTransaction(SignedTransaction tx); - ErgoContract newContract(Values.ErgoTree ergoTree); + ErgoContract newContract(ErgoTree ergoTree); ErgoContract compileContract(Constants constants, String ergoScript); diff --git a/lib-api/src/main/java/org/ergoplatform/appkit/ErgoProverBuilder.java b/lib-api/src/main/java/org/ergoplatform/appkit/ErgoProverBuilder.java index d9b07f3d..898e45f4 100644 --- a/lib-api/src/main/java/org/ergoplatform/appkit/ErgoProverBuilder.java +++ b/lib-api/src/main/java/org/ergoplatform/appkit/ErgoProverBuilder.java @@ -1,6 +1,7 @@ package org.ergoplatform.appkit; import org.ergoplatform.sdk.SecretString; +import sigma.BigInt; import sigma.GroupElement; import java.math.BigInteger; @@ -71,6 +72,9 @@ public interface ErgoProverBuilder { */ ErgoProverBuilder withDHTData(GroupElement g, GroupElement h, GroupElement u, GroupElement v, BigInteger x); + /** See the other overload for detailed description. */ + ErgoProverBuilder withDHTData(GroupElement g, GroupElement h, GroupElement u, GroupElement v, sigma.BigInt x); + /** * This allows adding additional secret for use in proveDlog, when the secret is not * part of the wallet. @@ -82,6 +86,17 @@ public interface ErgoProverBuilder { */ ErgoProverBuilder withDLogSecret(BigInteger x); + /** + * This allows adding additional secret for use in proveDlog, when the secret is not + * part of the wallet. + * + * Multiple secrets can be added by calling this method multiple times. + * + * Multiple secrets are necessary for statements that need multiple proveDlogs, such + * as proveDlog(a) && proveDlog(b), where a and b are two group elements. + */ + ErgoProverBuilder withDLogSecret(BigInt x); + /** * Builds a new prover using provided configuration. */ diff --git a/lib-api/src/main/java/org/ergoplatform/appkit/InputBoxesValidatorJavaHelper.scala b/lib-api/src/main/java/org/ergoplatform/appkit/InputBoxesValidatorJavaHelper.scala index a69af461..2fa85c40 100644 --- a/lib-api/src/main/java/org/ergoplatform/appkit/InputBoxesValidatorJavaHelper.scala +++ b/lib-api/src/main/java/org/ergoplatform/appkit/InputBoxesValidatorJavaHelper.scala @@ -3,7 +3,6 @@ package org.ergoplatform.appkit import org.ergoplatform.ErgoBoxAssets import org.ergoplatform.appkit.InputBoxesSelectionException.{NotEnoughErgsException, NotEnoughTokensException} import org.ergoplatform.sdk.ErgoToken -import org.ergoplatform.sdk.Iso._ import org.ergoplatform.sdk.JavaHelpers._ import org.ergoplatform.sdk.wallet.AssetUtils import org.ergoplatform.wallet.boxes.DefaultBoxSelector.{NotEnoughCoinsForChangeBoxesError, NotEnoughErgsError, NotEnoughTokensError} @@ -15,8 +14,8 @@ import scala.collection.mutable object InputBoxesValidatorJavaHelper { - - final case class InputBoxWrapper(val inputBox: InputBox) extends ErgoBoxAssets { + import org.ergoplatform.sdk.SdkIsos._ + final case class InputBoxWrapper(inputBox: InputBox) extends ErgoBoxAssets { override def value: Long = inputBox.getValue override def tokens: Map[ModifierId, Long] = { diff --git a/lib-api/src/main/java/org/ergoplatform/appkit/OutBoxBuilder.java b/lib-api/src/main/java/org/ergoplatform/appkit/OutBoxBuilder.java index 6c190e11..f254d51a 100644 --- a/lib-api/src/main/java/org/ergoplatform/appkit/OutBoxBuilder.java +++ b/lib-api/src/main/java/org/ergoplatform/appkit/OutBoxBuilder.java @@ -1,6 +1,5 @@ package org.ergoplatform.appkit; -import org.ergoplatform.SigmaConstants; import org.ergoplatform.sdk.ErgoToken; /** @@ -29,7 +28,7 @@ public interface OutBoxBuilder { OutBoxBuilder contract(ErgoContract contract); /** - * Configures amounts for one or more tokens (up to {@link SigmaConstants.MaxTokens}). + * Configures amounts for one or more tokens (up to {@link sigma.data.SigmaConstants.MaxTokens}). * Each Ergo box can store zero or more tokens (aka assets). * * @param tokens one or more tokens to be added to the constructed output box. diff --git a/lib-api/src/main/java/org/ergoplatform/appkit/TransactionBox.java b/lib-api/src/main/java/org/ergoplatform/appkit/TransactionBox.java index f582f59f..108f975c 100644 --- a/lib-api/src/main/java/org/ergoplatform/appkit/TransactionBox.java +++ b/lib-api/src/main/java/org/ergoplatform/appkit/TransactionBox.java @@ -3,7 +3,7 @@ import java.util.List; import org.ergoplatform.sdk.ErgoToken; -import sigmastate.Values; +import sigma.ast.ErgoTree; /** * This interface represents a box on a transaction, either an InputBox or an OutBox. @@ -37,7 +37,7 @@ public interface TransactionBox { /** * Returns the ErgoTree of the script guarding the box */ - Values.ErgoTree getErgoTree(); + ErgoTree getErgoTree(); /** Returns {@link BoxAttachment} stored in this box or null. */ BoxAttachment getAttachment(); diff --git a/lib-api/src/main/java/org/ergoplatform/appkit/babelfee/BabelFeeBoxContract.java b/lib-api/src/main/java/org/ergoplatform/appkit/babelfee/BabelFeeBoxContract.java index 21d20d36..32c94723 100644 --- a/lib-api/src/main/java/org/ergoplatform/appkit/babelfee/BabelFeeBoxContract.java +++ b/lib-api/src/main/java/org/ergoplatform/appkit/babelfee/BabelFeeBoxContract.java @@ -6,8 +6,9 @@ import org.ergoplatform.appkit.ScalaHelpers; import scorex.util.encode.Base16; -import sigmastate.Values; + import sigma.Coll; +import sigma.ast.ErgoTree; public class BabelFeeBoxContract { @@ -26,7 +27,7 @@ public class BabelFeeBoxContract { } private final ErgoId tokenId; - private final Values.ErgoTree ergoTree; + private final ErgoTree ergoTree; public BabelFeeBoxContract(ErgoId tokenId) { this.tokenId = tokenId; @@ -36,7 +37,7 @@ public BabelFeeBoxContract(ErgoId tokenId) { .applyParameters(new ErgoValue[]{ErgoValue.of(idBytes)}); } - public BabelFeeBoxContract(Values.ErgoTree ergoTree) { + public BabelFeeBoxContract(ErgoTree ergoTree) { this.ergoTree = ergoTree; tokenId = new ErgoId(ScalaHelpers.collByteToByteArray( (Coll) ErgoTreeTemplate.fromErgoTree(ergoTree) @@ -45,7 +46,7 @@ public BabelFeeBoxContract(Values.ErgoTree ergoTree) { )); } - public Values.ErgoTree getErgoTree() { + public ErgoTree getErgoTree() { return ergoTree; } diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/BlockchainContextBase.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/BlockchainContextBase.java index 66a5b2d9..9c2d2a8a 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/BlockchainContextBase.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/BlockchainContextBase.java @@ -5,9 +5,10 @@ import org.ergoplatform.appkit.*; import org.ergoplatform.sdk.ReducedErgoLikeTransaction; import org.ergoplatform.sdk.ReducedErgoLikeTransactionSerializer; -import sigmastate.Values; -import sigmastate.serialization.SigmaSerializer; -import sigmastate.utils.SigmaByteReader; + +import sigma.ast.ErgoTree; +import sigma.serialization.SigmaByteReader; +import sigma.serialization.SigmaSerializer; public abstract class BlockchainContextBase implements BlockchainContext { protected final NetworkType _networkType; @@ -17,7 +18,7 @@ public BlockchainContextBase(NetworkType networkType) { } @Override - public ErgoContract newContract(Values.ErgoTree ergoTree) { + public ErgoContract newContract(ErgoTree ergoTree) { return new ErgoTreeContract(ergoTree, _networkType); } diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverBuilderImpl.scala b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverBuilderImpl.scala index 2ae68891..c275f5e7 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverBuilderImpl.scala +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverBuilderImpl.scala @@ -3,10 +3,12 @@ package org.ergoplatform.appkit.impl import org.ergoplatform.appkit._ import org.ergoplatform.sdk.JavaHelpers.UniversalConverter import org.ergoplatform.sdk.wallet.secrets.ExtendedSecretKey -import org.ergoplatform.sdk.{AppkitProvingInterpreter, JavaHelpers, SecretString} +import org.ergoplatform.sdk.{AppkitProvingInterpreter, SecretString, JavaHelpers} +import sigma.GroupElement import sigmastate.crypto.DLogProtocol.DLogProverInput import sigmastate.crypto.{DLogProtocol, DiffieHellmanTupleProverInput} -import sigma.GroupElement +import org.ergoplatform.sdk.SdkIsos._ +import sigma.util.Extensions.BigIntOps import java.math.BigInteger import java.util @@ -61,6 +63,13 @@ class ErgoProverBuilderImpl(_ctx: BlockchainContextBase) extends ErgoProverBuild this } + override def withDHTData( + g: GroupElement, + h: GroupElement, + u: GroupElement, + v: GroupElement, + x: sigma.BigInt): ErgoProverBuilder = withDHTData(g, h, u, v, x.toBigInteger) + override def withDLogSecret(x: BigInteger): ErgoProverBuilder = { val dLog = new DLogProtocol.DLogProverInput(x) if (_dLogSecrets.contains(dLog)) @@ -69,6 +78,10 @@ class ErgoProverBuilderImpl(_ctx: BlockchainContextBase) extends ErgoProverBuild this } + override def withDLogSecret(x: sigma.BigInt): ErgoProverBuilder = { + withDLogSecret(x.toBigInteger) + } + override def build: ErgoProver = { val parameters = new org.ergoplatform.sdk.BlockchainParameters() { private[impl] val _params = _ctx.getParameters diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverImpl.scala b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverImpl.scala index 6e9d2172..e3057141 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverImpl.scala +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ErgoProverImpl.scala @@ -2,13 +2,13 @@ package org.ergoplatform.appkit.impl import org.ergoplatform.appkit._ import org.ergoplatform.sdk.JavaHelpers.UniversalConverter -import org.ergoplatform.sdk.wallet.secrets.ExtendedSecretKey -import org.ergoplatform.sdk.{AppkitProvingInterpreter, JavaHelpers, UnreducedTransaction} -import org.ergoplatform.{P2PKAddress, sdk} -import sigmastate.eval.CostingSigmaDslBuilder +import org.ergoplatform.sdk.{AppkitProvingInterpreter, UnreducedTransaction, JavaHelpers} +import org.ergoplatform.{sdk, P2PKAddress} import sigmastate.interpreter.HintsBag import sigmastate.utils.Helpers._ import sigma.BigInt +import sigma.eval.SigmaDsl +import org.ergoplatform.sdk.SdkIsos._ import java.util @@ -24,17 +24,16 @@ class ErgoProverImpl(_ctx: BlockchainContextBase, override def getAddress = new Address(getP2PKAddress) override def getSecretKey: BigInt = - CostingSigmaDslBuilder.BigInt(_prover.secretKeys(0).privateInput.w) + SigmaDsl.BigInt(_prover.secretKeys(0).privateInput.w) override def getEip3Addresses: util.List[Address] = { val addresses = _prover.secretKeys - .convertTo[IndexedSeq[ExtendedSecretKey]] .drop(1) .map { k => val p2pkAddress = JavaHelpers.createP2PKAddress(k.publicImage, networkPrefix) new Address(p2pkAddress) } - addresses.convertTo[util.List[Address]] + addresses.convertTo[java.util.List[Address]] } override def sign(tx: UnsignedTransaction): SignedTransaction = diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/InputBoxImpl.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/InputBoxImpl.java index 420d6ac3..2ea1dd58 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/InputBoxImpl.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/InputBoxImpl.java @@ -13,10 +13,11 @@ import org.ergoplatform.sdk.ErgoId; import org.ergoplatform.sdk.ErgoToken; -import org.ergoplatform.sdk.Iso; +import org.ergoplatform.sdk.SdkIsos; +import sigma.ast.ErgoTree; import org.ergoplatform.sdk.JavaHelpers; -import sigmastate.Values; -import sigmastate.interpreter.ContextExtension; + +import sigma.interpreter.ContextExtension; import sigma.Box; public class InputBoxImpl implements InputBox { @@ -63,7 +64,7 @@ public int getCreationHeight() { @Override public List getTokens() { - List tokens = Iso.isoTokensListToPairsColl().from(_ergoBox.additionalTokens()); + List tokens = SdkIsos.isoTokensListToPairsColl().from(_ergoBox.additionalTokens()); return tokens; } @@ -73,7 +74,7 @@ public List> getRegisters() { } @Override - public Values.ErgoTree getErgoTree() { + public ErgoTree getErgoTree() { return _ergoBox.ergoTree(); } diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/NodeDataSourceImpl.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/NodeDataSourceImpl.java index 417a4bcd..b2041785 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/NodeDataSourceImpl.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/NodeDataSourceImpl.java @@ -7,7 +7,7 @@ import org.ergoplatform.appkit.BlockchainParameters; import org.ergoplatform.appkit.ErgoClientException; import org.ergoplatform.appkit.InputBox; -import org.ergoplatform.sdk.Iso; +import org.ergoplatform.sdk.SdkIsos; import org.ergoplatform.appkit.OutBox; import org.ergoplatform.appkit.SignedTransaction; import org.ergoplatform.appkit.Transaction; @@ -175,11 +175,11 @@ public InputBox getBoxByIdNode(String boxId) { public String sendTransaction(SignedTransaction tx) { ErgoLikeTransaction ergoTx = ((SignedTransactionImpl) tx).getTx(); List dataInputsData = - Iso.JListToIndexedSeq(ScalaBridge.isoErgoTransactionDataInput()).from(ergoTx.dataInputs()); + SdkIsos.JListToIndexedSeq(ScalaBridge.isoErgoTransactionDataInput()).from(ergoTx.dataInputs()); List inputsData = - Iso.JListToIndexedSeq(ScalaBridge.isoErgoTransactionInput()).from(ergoTx.inputs()); + SdkIsos.JListToIndexedSeq(ScalaBridge.isoErgoTransactionInput()).from(ergoTx.inputs()); List outputsData = - Iso.JListToIndexedSeq(ScalaBridge.isoErgoTransactionOutput()).from(ergoTx.outputs()); + SdkIsos.JListToIndexedSeq(ScalaBridge.isoErgoTransactionOutput()).from(ergoTx.outputs()); ErgoTransaction txData = new ErgoTransaction() .id(ergoTx.id()) .dataInputs(dataInputsData) diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxBuilderImpl.scala b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxBuilderImpl.scala index 7c119425..825d40b4 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxBuilderImpl.scala +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxBuilderImpl.scala @@ -2,7 +2,7 @@ package org.ergoplatform.appkit.impl import com.google.common.base.Preconditions import com.google.common.base.Preconditions.checkState -import org.ergoplatform.SigmaConstants +import sigma.data.SigmaConstants import org.ergoplatform.appkit._ import org.ergoplatform.sdk.ErgoToken diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxImpl.scala b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxImpl.scala index 65e409b9..9d70f1cf 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxImpl.scala +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/OutBoxImpl.scala @@ -2,9 +2,9 @@ package org.ergoplatform.appkit.impl import org.ergoplatform.ErgoBoxCandidate import org.ergoplatform.appkit._ -import org.ergoplatform.sdk.{ErgoToken, Iso} +import org.ergoplatform.sdk.{ErgoToken, SdkIsos} import scorex.util.ModifierId -import sigmastate.Values +import sigma.ast.ErgoTree import java.util @@ -13,13 +13,13 @@ class OutBoxImpl(_ergoBoxCandidate: ErgoBoxCandidate) extends OutBox { override def getCreationHeight: Int = _ergoBoxCandidate.creationHeight - override def getTokens: util.List[ErgoToken] = Iso.isoTokensListToPairsColl.from(_ergoBoxCandidate.additionalTokens) + override def getTokens: util.List[ErgoToken] = SdkIsos.isoTokensListToPairsColl.from(_ergoBoxCandidate.additionalTokens) override def getRegisters: util.List[ErgoValue[_]] = AppkitHelpers.getBoxRegisters(_ergoBoxCandidate) override def getBytesWithNoRef: Array[Byte] = _ergoBoxCandidate.bytesWithNoRef - override def getErgoTree: Values.ErgoTree = _ergoBoxCandidate.ergoTree + override def getErgoTree: ErgoTree = _ergoBoxCandidate.ergoTree /** Returns {@link BoxAttachment} stored in this box of null. */ override def getAttachment: BoxAttachment = diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ReducedTransactionImpl.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ReducedTransactionImpl.java index 7d5ccf8c..45b0ed42 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ReducedTransactionImpl.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ReducedTransactionImpl.java @@ -3,21 +3,19 @@ import org.ergoplatform.ErgoBox; import org.ergoplatform.ErgoBoxCandidate; import org.ergoplatform.UnsignedInput; -import org.ergoplatform.appkit.*; +import org.ergoplatform.appkit.AppkitHelpers; +import org.ergoplatform.appkit.OutBox; +import org.ergoplatform.appkit.ReducedTransaction; +import org.ergoplatform.sdk.ErgoId; +import org.ergoplatform.sdk.ReducedErgoLikeTransaction; +import org.ergoplatform.sdk.ReducedErgoLikeTransactionSerializer; +import sigma.serialization.SigmaByteWriter; +import sigma.serialization.SigmaSerializer; import java.util.ArrayList; import java.util.List; import java.util.Objects; -import org.ergoplatform.sdk.ErgoId; -import org.ergoplatform.sdk.ReducedErgoLikeTransaction; -import org.ergoplatform.sdk.ReducedErgoLikeTransactionSerializer; -import org.ergoplatform.sdk.ReducedErgoLikeTransactionSerializer$; -import scala.collection.JavaConverters; -import sigmastate.serialization.SigmaSerializer; -import sigmastate.serialization.SigmaSerializer$; -import sigmastate.utils.SigmaByteWriter; - public class ReducedTransactionImpl implements ReducedTransaction { private final BlockchainContextBase _ctx; private final ReducedErgoLikeTransaction _tx; diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ScalaBridge.scala b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ScalaBridge.scala index 3cdaff84..bf8e781f 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ScalaBridge.scala +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/ScalaBridge.scala @@ -1,24 +1,24 @@ package org.ergoplatform.appkit.impl import _root_.org.ergoplatform.restapi.client._ -import org.ergoplatform.ErgoBox.{AdditionalRegisters, NonMandatoryRegisterId, Token, TokenId} -import org.ergoplatform.explorer.client.model.{AdditionalRegister, AssetInstanceInfo, OutputInfo, AdditionalRegisters => ERegisters, AssetInfo => EAsset} +import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, Token, AdditionalRegisters, TokenId} +import org.ergoplatform.explorer.client.model.{OutputInfo, AssetInstanceInfo, AdditionalRegister, AssetInfo => EAsset, AdditionalRegisters => ERegisters} import org.ergoplatform.sdk.JavaHelpers.UniversalConverter -import org.ergoplatform.sdk.{ErgoToken, Iso} +import org.ergoplatform.sdk.{ErgoToken, SdkIsos} import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.wallet.interpreter.ErgoInterpreter import org.ergoplatform.{ErgoLikeTransaction, _} -import scorex.crypto.authds.{ADDigest, ADKey} +import scorex.crypto.authds.ADKey import scorex.util.ModifierId -import sigmastate.SType -import sigmastate.Values.{ErgoTree, EvaluatedValue} +import sigma.ast.{EvaluatedValue, SType, ErgoTree} import sigmastate.eval.Extensions.ArrayByteOps -import sigmastate.eval.{CAvlTree, CHeader, SigmaDsl} -import sigmastate.interpreter.{ContextExtension, ProverResult} -import sigmastate.serialization.ErgoTreeSerializer.{DefaultSerializer => TreeSerializer} -import sigmastate.serialization.ValueSerializer -import sigma.Coll -import sigma.Header +import sigmastate.eval.CHeader +import sigma.interpreter.{ContextExtension, ProverResult} +import sigma.serialization.ErgoTreeSerializer.{DefaultSerializer => TreeSerializer} +import sigma.serialization.ValueSerializer +import sigma.{Header, Coll} +import sigma.data.{Iso, CAvlTree} +import sigma.eval.SigmaDsl import java.lang.{Byte => JByte} import java.util @@ -26,7 +26,7 @@ import java.util.{List => JList} import scala.collection.JavaConverters._ object ScalaBridge { - import org.ergoplatform.sdk.Iso.JListToIndexedSeq + import org.ergoplatform.sdk.SdkIsos._ import org.ergoplatform.sdk.JavaHelpers.StringExtensions implicit val isoSpendingProof: Iso[SpendingProof, ProverResult] = new Iso[SpendingProof, ProverResult] { @@ -164,7 +164,7 @@ object ScalaBridge { } override def from(box: ErgoBox): ErgoTransactionOutput = { - val assets = Iso.JListToColl[Asset, (TokenId, Long)].from(box.additionalTokens) + val assets = SdkIsos.JListToColl[Asset, (TokenId, Long)].from(box.additionalTokens) val regs = isoRegistersToMap.from(box.additionalRegisters) val out = new ErgoTransactionOutput() .boxId(ErgoAlgos.encode(box.id)) @@ -193,7 +193,7 @@ object ScalaBridge { } override def from(box: ErgoBox): OutputInfo = { - val assets = Iso.JListToColl[Asset, (TokenId, Long)].from(box.additionalTokens) + val assets = SdkIsos.JListToColl[Asset, (TokenId, Long)].from(box.additionalTokens) val regs = isoExplRegistersToMap.from(box.additionalRegisters) val out = new OutputInfo() .boxId(ErgoAlgos.encode(box.id)) @@ -237,19 +237,19 @@ object ScalaBridge { CHeader( id = h.getId.toColl, version = h.getVersion, - parentId = h.getParentId.map(Iso.jbyteToByte.to), - ADProofsRoot = h.getAdProofsRoot.map(Iso.jbyteToByte.to), + parentId = h.getParentId.map(SdkIsos.jbyteToByte.to), + ADProofsRoot = h.getAdProofsRoot.map(SdkIsos.jbyteToByte.to), stateRoot = h.getStateRoot, - transactionsRoot = h.getTransactionsRoot.map(Iso.jbyteToByte.to), + transactionsRoot = h.getTransactionsRoot.map(SdkIsos.jbyteToByte.to), timestamp = h.getTimestamp, nBits = h.getNBits, height = h.getHeight, - extensionRoot = h.getExtensionHash.map(Iso.jbyteToByte.to), + extensionRoot = h.getExtensionHash.map(SdkIsos.jbyteToByte.to), minerPk = h.getPowSolutionsPk, powOnetimePk = h.getPowSolutionsW, - powNonce = h.getPowSolutionsN.map(Iso.jbyteToByte.to), + powNonce = h.getPowSolutionsN.map(SdkIsos.jbyteToByte.to), powDistance = SigmaDsl.BigInt(h.getPowSolutionsD), - votes = h.getVotes.map(Iso.jbyteToByte.to) + votes = h.getVotes.map(SdkIsos.jbyteToByte.to) ) implicit val isoErgoTransaction: Iso[ErgoTransaction, ErgoLikeTransaction] = new Iso[ErgoTransaction, ErgoLikeTransaction] { diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedInputImpl.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedInputImpl.java index ed8d6430..b23ee87d 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedInputImpl.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedInputImpl.java @@ -3,9 +3,11 @@ import org.ergoplatform.Input; import org.ergoplatform.appkit.*; import org.ergoplatform.sdk.ErgoId; -import org.ergoplatform.sdk.Iso; -import sigmastate.SType; -import sigmastate.Values; +import org.ergoplatform.sdk.SdkIsos; +import sigma.ast.EvaluatedValue; +import sigma.data.Iso; +import sigma.ast.SType; + import java.util.Map; @@ -27,8 +29,8 @@ public byte[] getProofBytes() { @Override public Map> getContextVars() { - Iso>, scala.collection.Map>> iso = Iso.isoJMapToMap(AppkitIso.isoErgoValueToSValue()); - scala.collection.Map> map = (scala.collection.Map>)(Object)_input.spendingProof().extension().values(); + Iso>, scala.collection.Map>> iso = SdkIsos.isoJMapToMap(AppkitIso.isoErgoValueToSValue()); + scala.collection.Map> map = (scala.collection.Map>)(Object)_input.spendingProof().extension().values(); return iso.from(map); } diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedTransactionImpl.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedTransactionImpl.java index 51aa2c48..0829c3fd 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedTransactionImpl.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/SignedTransactionImpl.java @@ -13,10 +13,12 @@ import org.ergoplatform.restapi.client.ErgoTransactionOutput; import org.ergoplatform.restapi.client.JSON; import org.ergoplatform.sdk.ErgoId; -import org.ergoplatform.sdk.Iso; -import sigmastate.Values; -import sigmastate.serialization.SigmaSerializer; -import sigmastate.utils.SigmaByteWriter; +import org.ergoplatform.sdk.SdkIsos; +import sigma.ast.ErgoTree; +import sigma.data.Iso; + +import sigma.serialization.SigmaByteWriter; +import sigma.serialization.SigmaSerializer; import java.util.ArrayList; import java.util.List; @@ -61,7 +63,7 @@ public String toJson(boolean prettyPrint, boolean formatJson) { ErgoTransaction tx = ScalaBridge.isoErgoTransaction().from(_tx); if (prettyPrint) { for (ErgoTransactionOutput o : tx.getOutputs()) { - Values.ErgoTree tree = ScalaBridge.isoStringToErgoTree().to(o.getErgoTree()); + ErgoTree tree = ScalaBridge.isoStringToErgoTree().to(o.getErgoTree()); o.ergoTree(tree.toString()); } } @@ -72,7 +74,7 @@ public String toJson(boolean prettyPrint, boolean formatJson) { @Override public List getSignedInputs() { - List inputs = Iso.JListToIndexedSeq(Iso.identityIso()).from(_tx.inputs()); + List inputs = SdkIsos.JListToIndexedSeq(Iso.identityIso()).from(_tx.inputs()); List res = new ArrayList<>(inputs.size()); for (Input input : inputs) { res.add(new SignedInputImpl(this, input)); @@ -82,7 +84,7 @@ public List getSignedInputs() { @Override public List getOutputsToSpend() { - List outputs = Iso.JListToIndexedSeq(Iso.identityIso()).from(_tx.outputs()); + List outputs = SdkIsos.JListToIndexedSeq(Iso.identityIso()).from(_tx.outputs()); List res = new ArrayList<>(outputs.size()); for (ErgoBox ergoBox : outputs) { res.add(new InputBoxImpl(ergoBox)); @@ -92,7 +94,7 @@ public List getOutputsToSpend() { @Override public List getInputBoxesIds() { - List inputs = Iso.JListToIndexedSeq(Iso.identityIso()).from(_tx.inputs()); + List inputs = SdkIsos.JListToIndexedSeq(Iso.identityIso()).from(_tx.inputs()); List res = new ArrayList<>(inputs.size()); for (Input input : inputs) { res.add(new ErgoId(input.boxId()).toString()); @@ -102,7 +104,7 @@ public List getInputBoxesIds() { @Override public List getOutputs() { - List outputs = Iso.JListToIndexedSeq(Iso.identityIso()).from(_tx.outputs()); + List outputs = SdkIsos.JListToIndexedSeq(Iso.identityIso()).from(_tx.outputs()); List res = new ArrayList<>(outputs.size()); for (ErgoBox ergoBox : outputs) { res.add(new OutBoxImpl(ergoBox)); diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionBuilderImpl.scala b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionBuilderImpl.scala index 69a3e971..28290360 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionBuilderImpl.scala +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionBuilderImpl.scala @@ -7,10 +7,10 @@ import org.ergoplatform.appkit._ import org.ergoplatform.sdk.Extensions.HeaderOps import org.ergoplatform.sdk.JavaHelpers.UniversalConverter import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext -import org.ergoplatform.sdk.{ErgoToken, ExtendedInputBox, Iso, JavaHelpers} +import org.ergoplatform.sdk.{ErgoToken, ExtendedInputBox, SdkIsos, JavaHelpers} import org.ergoplatform.wallet.transactions.TransactionBuilder import sigma.{Coll, Colls, Header} - +import SdkIsos._ import java.util import java.util._ import scala.collection.JavaConverters._ @@ -129,7 +129,7 @@ class UnsignedTransactionBuilderImpl(val _ctx: BlockchainContextImpl) extends Un val inputBoxesSeq = boxesToSpendSeq.map(eb => eb.box) val requestedToBurn = _tokensToBurn.getOrElse(new ArrayList[ErgoToken]) val burnTokens = JavaHelpers.createTokensMap( - Iso.isoErgoTokenSeqToLinkedMap.to(requestedToBurn.convertTo[IndexedSeq[ErgoToken]]) + SdkIsos.isoErgoTokenSeqToLinkedMap.to(requestedToBurn.convertTo[IndexedSeq[ErgoToken]]) ) val rewardDelay = if (_ctx.getNetworkType == NetworkType.MAINNET) Parameters.MinerRewardDelay_Mainnet diff --git a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionImpl.java b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionImpl.java index 90f6104e..1c11e547 100644 --- a/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionImpl.java +++ b/lib-impl/src/main/java/org/ergoplatform/appkit/impl/UnsignedTransactionImpl.java @@ -19,7 +19,7 @@ import java.util.List; import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext; -import sigmastate.Values; +import sigma.ast.ErgoTree; import javax.annotation.Nonnull; @@ -126,7 +126,7 @@ public String toJson(boolean prettyPrint, boolean formatJson) { UnsignedErgoTransaction tx = ScalaBridge.isoUnsignedErgoTransaction().from(_tx); if (prettyPrint) { for (ErgoTransactionOutput o : tx.getOutputs()) { - Values.ErgoTree tree = ScalaBridge.isoStringToErgoTree().to(o.getErgoTree()); + ErgoTree tree = ScalaBridge.isoStringToErgoTree().to(o.getErgoTree()); o.ergoTree(tree.toString()); } } diff --git a/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala b/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala index 39ca64c9..df661391 100644 --- a/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala +++ b/lib-impl/src/test/java/org/ergoplatform/appkit/impl/ScalaBridgeTest.scala @@ -5,9 +5,9 @@ import org.ergoplatform.restapi.client.SpendingProof import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.Values.{ByteArrayConstant, IntConstant} -import sigmastate.interpreter.{ContextExtension, ProverResult} -import sigmastate.serialization.generators.ObjectGenerators +import sigma.ast.{ByteArrayConstant, IntConstant} +import sigma.interpreter.{ContextExtension, ProverResult} +import sigma.serialization.generators.ObjectGenerators import scala.collection.JavaConverters import JavaConverters._