Skip to content

Commit

Permalink
Merge pull request #226 from ergoplatform/develop
Browse files Browse the repository at this point in the history
Release v5.0.3 (with Sigma v5.0.8 and ergo-wallet v5.0.12)
  • Loading branch information
aslesarenko authored Jun 20, 2023
2 parents 3a12987 + 5804527 commit e0ba3dd
Show file tree
Hide file tree
Showing 99 changed files with 1,064 additions and 1,730 deletions.
4 changes: 4 additions & 0 deletions MIGRATION
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[5.0.3]
- ErgoId, ErgoToken, ExtendedInputBox, SecretString moved from package org.ergoplatform.appkit to org.ergoplatform.sdk
The org.ergoplatform.sdk package is part of sigmastate library.

[5.0.0]
- block version now required to construct ColdErgoClient
- getBoxById(String boxId) was replaced by getBoxById(String boxId, boolean findInPool, boolean findInSpent)
Expand Down
15 changes: 10 additions & 5 deletions appkit/src/main/scala/org/ergoplatform/appkit/ColdErgoClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import org.ergoplatform.restapi.client
import org.ergoplatform.appkit.impl.{ColdBlockchainContext, NodeInfoParameters}
import org.ergoplatform.restapi.client.NodeInfo

class ColdErgoClient(networkType: NetworkType, params: BlockchainParameters) extends ErgoClient {
class ColdErgoClient(networkType: NetworkType, val params: BlockchainParameters) extends ErgoClient {

/**
* Convenience constructor for giving maxBlockCost
*/
def this(networkType: NetworkType, maxBlockCost: Int, blockVersion: Byte) {
this(networkType, new NodeInfoParameters(
new NodeInfo().parameters(new client.Parameters()
.maxBlockCost(Integer.valueOf(maxBlockCost))
.blockVersion(Integer.valueOf(blockVersion)))))
this(networkType,
new NodeInfoParameters(
new NodeInfo()
.parameters(new client.Parameters()
.maxBlockCost(Integer.valueOf(maxBlockCost))
.blockVersion(Integer.valueOf(blockVersion))
)
)
)
}

override def execute[T](action: function.Function[BlockchainContext, T]): T = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.ergoplatform.appkit.cli

import java.io.{BufferedReader, PrintStream}

import org.ergoplatform.appkit.SecretString
import org.ergoplatform.sdk.SecretString
import org.ergoplatform.appkit.commands.UsageException

/** Abstract interface for Console interactions (print and read operations).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.ergoplatform.appkit.commands

import java.io.File

import org.ergoplatform.appkit._
import org.ergoplatform.appkit.config.ErgoToolConfig
import org.ergoplatform.appkit.cli.{Console, AppContext, CmdLineParser}
import org.ergoplatform.appkit.cli.Console.readNewPassword
import org.ergoplatform.appkit.cli.{AppContext, CmdLineParser, Console}
import org.ergoplatform.appkit.config.ErgoToolConfig
import org.ergoplatform.sdk.{ErgoId, SecretString}

import java.io.File

/** Base class for all commands which can be executed by ErgoTool.
* Inherit this class to implement a new command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"minValuePerByte": 360,
"maxBlockSize": 524288,
"maxBlockCost": 1000000,
"blockVersion": 1,
"blockVersion": 3,
"tokenAccessCost": 100,
"inputCost": 2000,
"dataInputCost": 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.ergoplatform.appkit
import org.ergoplatform.appkit.examples.RunMockedScala
import org.ergoplatform.appkit.examples.RunMockedScala.createMockedErgoClient
import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.SecretString
import org.ergoplatform.{ErgoAddressEncoder, Pay2SAddress}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package org.ergoplatform.appkit

import org.ergoplatform.appkit.BoxOperations.createProver
import org.ergoplatform.appkit.Parameters.MinFee
import org.ergoplatform.appkit.impl.{NodeAndExplorerDataSourceImpl, NodeDataSourceImpl}
import org.ergoplatform.appkit.testing.AppkitTesting
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.basics.CryptoConstants
import sigmastate.eval._
import sigmastate.helpers.NegativeTesting
import sigmastate.interpreter.CryptoConstants
import special.sigma.GroupElement

class AnonymousAccessSpec extends AnyPropSpec with Matchers
Expand Down Expand Up @@ -41,10 +42,8 @@ class AnonymousAccessSpec extends AnyPropSpec with Matchers

ergoClient.execute { ctx: BlockchainContext =>
ctx shouldNot be (null)
assertExceptionThrown(
ctx.getDataSource.getUnspentBoxesFor(Address.create(addr1), 0, BlockchainContext.DEFAULT_LIMIT_FOR_API),
exceptionLike[NullPointerException](ErgoClient.explorerUrlNotSpecifiedMessage)
)
ctx.getDataSource.isInstanceOf[NodeDataSourceImpl] shouldBe true
ctx.getDataSource.isInstanceOf[NodeAndExplorerDataSourceImpl] shouldBe false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.ergoplatform.appkit

import org.ergoplatform.appkit.examples.ExampleScenarios
import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.{JavaHelpers, SecretString}
import org.ergoplatform.settings.ErgoAlgos
import org.ergoplatform.validation.ValidationRules
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.JavaHelpers._
import org.ergoplatform.{ErgoScriptPredef, ErgoBox, UnsignedErgoLikeTransaction}
import org.ergoplatform.appkit.impl.{BlockchainContextImpl, InputBoxImpl, UnsignedTransactionBuilderImpl, UnsignedTransactionImpl}
import org.ergoplatform.sdk.JavaHelpers._
import org.ergoplatform.sdk._
import org.ergoplatform.settings.ErgoAlgos
import org.ergoplatform.{ErgoBox, ErgoTreePredef, UnsignedErgoLikeTransaction}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import sigmastate.helpers.NegativeTesting
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.TestsBase
import sigmastate.eval.Colls
import sigmastate.eval.Extensions.ArrayByteOps
import sigmastate.helpers.NegativeTesting
import sigmastate.helpers.TestingHelpers.createBox

import java.util
import java.util.Collections
import util.{List => JList}
import java.util.{Collections, List => JList}

class AppkitProvingInterpreterSpec extends AnyPropSpec
with Matchers
Expand Down Expand Up @@ -73,10 +73,10 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
val prover = ctx.newProverBuilder()
.withMnemonic(mnemonic, SecretString.empty(), false)
.build()
val tree1 = ErgoScriptPredef.TrueProp(ergoTreeHeaderInTests)
val tree2 = ErgoScriptPredef.FalseProp(ergoTreeHeaderInTests)
val token1 = (ErgoAlgos.hash("id1"), 10L)
val token2 = (ErgoAlgos.hash("id2"), 20L)
val tree1 = ErgoTreePredef.TrueProp(ergoTreeHeaderInTests)
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)

Expand Down Expand Up @@ -106,7 +106,7 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
{
case e: TokenBalanceException =>
val cond1 = exceptionLike[TokenBalanceException]("Transaction tries to burn tokens when no burning was requested")
cond1(e) && e.tokensDiff.exists(t => t == (Colls.fromArray(token2._1), -token2._2))
cond1(e) && e.tokensDiff.exists(t => t == (token2._1, -token2._2))
case _ => false
}
)
Expand All @@ -121,7 +121,7 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
{
case e: TokenBalanceException =>
val cond1 = exceptionLike[TokenBalanceException]("Transaction tries to burn tokens when no burning was requested")
cond1(e) && e.tokensDiff.exists(t => t == (Colls.fromArray(token2._1), -10))
cond1(e) && e.tokensDiff.exists(t => t == (token2._1, -10))
case _ => false
}
)
Expand All @@ -148,7 +148,7 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
{
case e: TokenBalanceException =>
val cond1 = exceptionLike[TokenBalanceException]("Transaction tries to burn tokens when no burning was requested")
cond1(e) && e.tokensDiff.exists(t => t == (Colls.fromArray(token1._1), -20))
cond1(e) && e.tokensDiff.exists(t => t == (token1._1, -20))
case _ => false
}
)
Expand All @@ -167,8 +167,8 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
val cond1 = exceptionLike[TokenBalanceException](
"Transaction tries to burn tokens, but not how it was requested")
val ok = cond1(e)
val token2_BurningWasNotRequested = e.tokensDiff.exists(t => t == (Colls.fromArray(token2._1), 10))
val token1_WasRequestedButNotBurned = e.tokensDiff.exists(t => t == (Colls.fromArray(token1._1), -10))
val token2_BurningWasNotRequested = e.tokensDiff.exists(t => t == (token2._1, 10))
val token1_WasRequestedButNotBurned = e.tokensDiff.exists(t => t == (token1._1, -10))
ok && token2_BurningWasNotRequested && token1_WasRequestedButNotBurned
case _ => false
}
Expand All @@ -188,8 +188,8 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
val cond1 = exceptionLike[TokenBalanceException](
"Only one token can be minted in a transaction")
val ok = cond1(e)
val token1_mint_attempted = e.tokensDiff.exists(t => t == (Colls.fromArray(token1._1), token1._2))
val token2_mint_attempted = e.tokensDiff.exists(t => t == (Colls.fromArray(token2._1), token2._2))
val token1_mint_attempted = e.tokensDiff.exists(t => t == (token1._1, token1._2))
val token2_mint_attempted = e.tokensDiff.exists(t => t == (token2._1, token2._2))
ok && token1_mint_attempted && token2_mint_attempted && e.tokensDiff.length == 2
case _ => false
}
Expand All @@ -209,7 +209,7 @@ class AppkitProvingInterpreterSpec extends AnyPropSpec
val cond1 = exceptionLike[TokenBalanceException](
"Cannot mint a token with invalid id")
val ok = cond1(e)
val token1_mint_attempted = e.tokensDiff.exists(t => t == (Colls.fromArray(token1._1), token1._2))
val token1_mint_attempted = e.tokensDiff.exists(t => t == (token1._1, token1._2))
ok && token1_mint_attempted && e.tokensDiff.length == 1
case _ => false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.babelfee.{BabelFeeOperations, BabelFeeBoxContract, BabelFeeBoxState}
import org.ergoplatform.appkit.babelfee.{BabelFeeBoxContract, BabelFeeBoxState, BabelFeeOperations}
import org.ergoplatform.sdk.{ErgoId, ErgoToken, SecretString}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.{JavaHelpers, SecretString}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.Parameters.MinFee
import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.JavaHelpers.UniversalConverter
import org.ergoplatform.sdk.{ErgoToken, JavaHelpers}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.basics.CryptoConstants
import sigmastate.eval._
import sigmastate.interpreter.CryptoConstants
import special.sigma.GroupElement
import JavaHelpers._

import java.util.{Arrays, List => JList}
import org.ergoplatform.appkit.Parameters.MinFee
import org.ergoplatform.appkit.testing.AppkitTesting
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec

class ChangeOutputSpec extends AnyPropSpec with Matchers
with ScalaCheckDrivenPropertyChecks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.JavaHelpers
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.basics.CryptoConstants
import sigmastate.eval._
import sigmastate.interpreter.CryptoConstants
import special.sigma.GroupElement

class DHTProverSpec extends AnyPropSpec with Matchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ergoplatform.appkit

import org.ergoplatform.sdk.SecretString
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import okhttp3.mockwebserver.MockWebServer;
import org.ergoplatform.appkit.impl.BlockchainContextBuilderImpl;
import org.ergoplatform.appkit.impl.NodeAndExplorerDataSourceImpl;
import org.ergoplatform.appkit.impl.NodeDataSourceImpl;
import org.ergoplatform.explorer.client.ExplorerApiClient;
import org.ergoplatform.restapi.client.ApiClient;

Expand Down Expand Up @@ -65,7 +66,12 @@ public <T> T execute(Function<BlockchainContext, T> action) {
HttpUrl explorerBaseUrl = explorer.url("/");
ExplorerApiClient explorerClient = new ExplorerApiClient(explorerBaseUrl.toString());

NodeAndExplorerDataSourceImpl dataSource = new NodeAndExplorerDataSourceImpl(client, _nodeOnlyMode ? null : explorerClient);
BlockchainDataSource dataSource;
if (_nodeOnlyMode)
dataSource = new NodeDataSourceImpl(client);
else
dataSource = new NodeAndExplorerDataSourceImpl(client, explorerClient);

BlockchainContext ctx = new BlockchainContextBuilderImpl(
dataSource,
NetworkType.MAINNET).build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.ergoplatform.appkit

import scalan.util.{FileUtil => SFileUtil}
import JavaHelpers._
import org.ergoplatform.appkit
import org.ergoplatform.sdk.JavaHelpers.UniversalConverter

import java.util.{List => JList}
import java.lang.{String => JString}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package org.ergoplatform.appkit

import org.ergoplatform.ErgoBox
import org.ergoplatform.appkit.testing.AppkitTesting
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.Values.{EvaluatedValue, ByteArrayConstant, IntConstant}
import sigmastate.{SType, TrivialProp}
import sigmastate.helpers.TestingHelpers._
import org.ergoplatform.sdk.JavaHelpers
import org.ergoplatform.sdk.JavaHelpers.UniversalConverter
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 sigmastate.helpers.TestingHelpers._
import sigmastate.{SType, TrivialProp}

class JavaHelpersSpec extends AnyPropSpec with Matchers
with ScalaCheckDrivenPropertyChecks
with AppkitTesting {
import ErgoBox._
import Iso._
import JavaHelpers.UniversalConverter

type Registers = Map[NonMandatoryRegisterId, _ <: EvaluatedValue[_ <: SType]]

Expand All @@ -25,7 +25,7 @@ class JavaHelpersSpec extends AnyPropSpec with Matchers

def check(regs: Registers, expRegs: IndexedSeq[ErgoValue[_]]) = {
val box = boxWithRegs(regs)
val res = JavaHelpers.getBoxRegisters(box).convertTo[IndexedSeq[ErgoValue[_]]]
val res = AppkitHelpers.getBoxRegisters(box).convertTo[IndexedSeq[ErgoValue[_]]]
res shouldBe expRegs
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.ergoplatform.appkit
import java.util
import org.ergoplatform.appkit.Mnemonic._
import org.ergoplatform.appkit.MnemonicValidationException.{MnemonicWrongListSizeException, MnemonicChecksumException, MnemonicWordException, MnemonicEmptyException}
import org.ergoplatform.sdk.{JavaHelpers, SecretString}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.ergoplatform.appkit;

import org.ergoplatform.sdk.ErgoToken;

import java.util.Collections;
import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.JavaHelpers
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.basics.CryptoConstants
import sigmastate.eval._
import sigmastate.interpreter.CryptoConstants
import special.sigma.GroupElement

import scala.util.Try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.ergoplatform.appkit

import org.ergoplatform.appkit.testing.AppkitTesting
import org.ergoplatform.sdk.JavaHelpers
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks
import sigmastate.basics.CryptoConstants
import sigmastate.eval._
import sigmastate.interpreter.CryptoConstants
import special.sigma.GroupElement

import scala.util.Try
Expand Down
Loading

0 comments on commit e0ba3dd

Please sign in to comment.