Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ccellado committed Mar 9, 2024
1 parent 5af8721 commit 8c80776
Show file tree
Hide file tree
Showing 91 changed files with 329 additions and 368 deletions.
23 changes: 18 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@

name := "kiosk"
version := "1.0"
updateOptions := updateOptions.value.withLatestSnapshots(false)
organization := "org.ergoplatform"
version := "1.0.0"
//updateOptions := updateOptions.value.withLatestSnapshots(false)
scalaVersion := "2.13.12"
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode"))
publishTo := sonatypePublishToBundle.value
scmInfo := Some(
ScmInfo(
url("https://github.com/ergoplatform/kiosk"),
"scm:[email protected]:ergoplatform/kiosk.git"
)
)

libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0",
"org.ergoplatform" %% "ergo-appkit" % "5.0.4",
"com.squareup.okhttp3" % "mockwebserver" % "4.12.0" % Test,
"org.scalatest" %% "scalatest" % "3.2.18" % Test,
"com.squareup.okhttp3" % "mockwebserver" % "4.12.0",
"org.scalatest" %% "scalatest" % "3.2.18",
"org.scalatestplus" %% "scalacheck-1-17" % "3.2.18.0" % Test,
"org.scalacheck" %% "scalacheck" % "1.17.0" % Test,
"org.mockito" % "mockito-core" % "5.11.0" % Test
Expand Down Expand Up @@ -42,6 +50,11 @@ pgpSecretRing := file("ci/secring.asc")
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toArray)
usePgpKeyHex("D78982639AD538EF361DEC6BF264D529385A0333")

credentials ++= (for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq

// prefix version with "-SNAPSHOT" for builds without a git tag
ThisBuild / dynverSonatypeSnapshots := true
// use "-" instead of default "+"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package org.ergoplatform.appkit;
package org.ergoplatform.kiosk.appkit;

import okhttp3.HttpUrl;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.ergoplatform.appkit.*;
import org.ergoplatform.appkit.impl.BlockchainContextBuilderImpl;
import org.ergoplatform.appkit.impl.NodeAndExplorerDataSourceImpl;
import org.ergoplatform.explorer.client.ExplorerApiClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.ergoplatform.appkit;
package org.ergoplatform.kiosk.appkit;

import org.ergoplatform.appkit.ErgoClient;

import java.util.List;

Expand Down
5 changes: 0 additions & 5 deletions src/main/scala/kiosk/offchain/readme.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kiosk
package org.ergoplatform.kiosk

import kiosk.encoding.ScalaErgoConverters
import kiosk.ergo._
import kiosk.explorer.Explorer
import org.ergoplatform.kiosk.ergo._
import org.ergoplatform.kiosk.encoding.ScalaErgoConverters
import org.ergoplatform.kiosk.explorer.Explorer
import scorex.util.encode.Base58
import sigmastate.crypto.SecP256K1Group
import sigmastate.eval.{SigmaDsl, _}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiosk.appkit
package org.ergoplatform.kiosk.appkit

import org.ergoplatform.appkit.{BlockchainContext, ErgoClient, NetworkType, RestApiErgoClient}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package org.ergoplatform.appkit
package org.ergoplatform.kiosk.appkit

import org.ergoplatform.appkit.{FileUtil, NetworkType}
import org.ergoplatform.kiosk.appkit

import java.io.File
import scala.jdk.CollectionConverters.SeqHasAsJava
Expand Down Expand Up @@ -30,7 +33,7 @@ object HttpClientTesting {
def empty = MockData()
}

def createMockedErgoClient(data: MockData): FileMockedErgoClient = {
def createMockedErgoClient(data: MockData): appkit.FileMockedErgoClient = {
val nodeResponses = Seq(
loadNodeResponse("response_NodeInfo.json"),
loadNodeResponse("response_LastHeaders.json")) ++ data.nodeResponses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.ergoplatform.appkit
package org.ergoplatform.kiosk.appkit

import org.ergoplatform.appkit.HttpClientTesting.{MockData, createMockedErgoClient, networkType}
import org.ergoplatform.appkit.NetworkType
import org.ergoplatform.kiosk.appkit
import org.ergoplatform.kiosk.appkit.HttpClientTesting.{MockData, createMockedErgoClient, networkType}
import org.scalatest.matchers.should.Matchers
import org.scalatest.propspec.FixtureAnyPropSpec

abstract class MockErgoClient extends FixtureAnyPropSpec with Matchers {
case class FixtureParam(client: FileMockedErgoClient)
case class FixtureParam(client: appkit.FileMockedErgoClient)
val _networkType: NetworkType = networkType
val ergoClient: FileMockedErgoClient = createMockedErgoClient(MockData(Nil, Nil))
val ergoClient: appkit.FileMockedErgoClient = createMockedErgoClient(MockData(Nil, Nil))

def withFixture(test: OneArgTest) = {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiosk.appkit
package org.ergoplatform.kiosk.appkit

object Nodes {
val urls = Seq(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package kiosk.encoding
package org.ergoplatform.kiosk.encoding

import java.math.BigInteger
import kiosk.ergo._
import kiosk.script.ScriptUtil
import org.ergoplatform.kiosk.ergo._
import org.ergoplatform.ErgoAddress
import org.ergoplatform.kiosk.script.ScriptUtil
import sigmastate.Values.{ConstantNode, ErgoTree}
import sigmastate._
import sigmastate.crypto.CryptoConstants.EcPointType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kiosk.ergo
package org.ergoplatform.kiosk.ergo

import kiosk.encoding.ScalaErgoConverters
import org.ergoplatform.kiosk.encoding.ScalaErgoConverters

// Used in JDE and ErgoScriptCompiler
object DataType extends MyEnum {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package kiosk
package org.ergoplatform.kiosk

import kiosk.encoding.ScalaErgoConverters
import org.ergoplatform.kiosk.encoding.ScalaErgoConverters
import org.bouncycastle.util.encoders.Hex
import org.ergoplatform.appkit.{BlockchainContext, ErgoType, ErgoValue, InputBox, OutBox}
import org.ergoplatform.sdk.ErgoToken
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kiosk.explorer
package org.ergoplatform.kiosk.explorer

import java.io.InputStream
import java.net.HttpURLConnection
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package kiosk.explorer
package org.ergoplatform.kiosk.explorer

import kiosk.encoding.ScalaErgoConverters
import kiosk.ergo.{KioskBox, KioskType, Token}
import org.ergoplatform.kiosk.encoding.ScalaErgoConverters
import org.ergoplatform.kiosk.ergo.{KioskBox, KioskType, Token}
import io.circe.Json
import kiosk.appkit.{Client, Nodes}
import org.ergoplatform.kiosk.appkit.{Client, Nodes}
import org.ergoplatform.kiosk.appkit.{Client, Nodes}
import org.ergoplatform.kiosk.encoding.ScalaErgoConverters

import scala.util.Try

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kiosk.script
package org.ergoplatform.kiosk.script

import kiosk.ergo._
import org.ergoplatform.ErgoAddressEncoder
import org.ergoplatform.kiosk.ergo._
import org.ergoplatform.{ErgoAddress, ErgoAddressEncoder}
import org.ergoplatform.ErgoAddressEncoder.MainnetNetworkPrefix
import sigmastate.Values.ErgoTree
import sigmastate.eval.CompiletimeIRContext
Expand All @@ -16,8 +16,6 @@ object ScriptUtil {
private val compiler = SigmaCompiler(CompilerSettings(networkPrefix, TransformingSigmaBuilder, lowerMethodCalls = true))

implicit val ergoAddressEncoder: ErgoAddressEncoder = new ErgoAddressEncoder(networkPrefix)


def addIfNotExist(envMap: MMap[String, KioskType[_]], name: String, kioskType: KioskType[_]) = {
envMap
.get(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kiosk.tx
package org.ergoplatform.kiosk.tx

import kiosk.encoding.ScalaErgoConverters.getAddressFromString
import kiosk.ergo.{DhtData, KioskBox, KioskType, Token, decodeBigInt}
import org.ergoplatform.kiosk.encoding.ScalaErgoConverters.getAddressFromString
import org.ergoplatform.kiosk.ergo.{DhtData, KioskBox, KioskType, Token, decodeBigInt}
import org.ergoplatform.appkit.{Address, BlockchainContext, InputBox, OutBox, OutBoxBuilder, SignedTransaction}
import org.ergoplatform.appkit.impl.ErgoTreeContract
import org.ergoplatform.sdk.ErgoToken
Expand Down
7 changes: 0 additions & 7 deletions src/test/scala/kiosk/offchain/readme.md

This file was deleted.

1 change: 0 additions & 1 deletion src/test/scala/kiosk/offchain/timestamp.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

trait Auction {
val source =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

import kiosk.ErgoUtil
import kiosk.ergo._
import kiosk.script.ScriptUtil
import org.ergoplatform.Pay2SAddress
import org.ergoplatform.kiosk.ErgoUtil
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import org.ergoplatform.kiosk.script.ScriptUtil
import org.ergoplatform.kiosk.script.ScriptUtil._
import scala.collection.mutable.{Map => MMap}

class AuctionSpec extends AnyWordSpec with Matchers with Auction {

import kiosk.script.ScriptUtil._

"Auction script" should {
"compile correctly" in {
// seller
Expand All @@ -23,8 +21,6 @@ class AuctionSpec extends AnyWordSpec with Matchers with Auction {
val ergoTree = ScriptUtil.compile(env.toMap, source)

ergoTree.bytes.encodeHex shouldBe "100b04904e04000400040004020480897a040004000400040208cd02adee2f931b2e011fc44c9ece6ad6ad2e2dafe6506114755f20bad7268b191a3dd802d601c1a7d602e4c6a70407958fa37300d805d603b2a5730100d604b2db63087203730200d605b2db6308a7730300d606c17203d607b2a5730400ededededed938c7204018c720501938c7204028c7205029272069a72017e730505927206720693c27207d0cd720292c172077201d804d603b2a5730600d604b2db63087203730700d605b2db6308a7730800d606b2a5730900edededed938c7204018c720501938c7204028c72050293c27203d0cd720292c17206720193c27206d0730a"

import ScriptUtil.ergoAddressEncoder
Pay2SAddress(ergoTree).toString shouldBe "dEnpB3TwiN24zJ6u2mDgShn2PBB11ZMr1GLGpsTDx8BJnY2RfkuB8nYMKkuhzaN83zJ8bbDFv3vV4xH8zrWFVbpjPJ7Evu4xsfMQmnReHaZCuCAoWKPkzeSXRiL3DnK26ZkFoxso6TNuoYCkCDNXFuU4CTqjQzCB1bMYxeGxybCVUZWzMHBFqGZFkFuYcsxtBFabipgedhVjGcrCtQfdPNqz7ZUZ5mrSSzALdRJ8SgfvESnzM3eHSYRc21GEf9P3HzjgFWuhtyX3KuYfiPjDx3tZfTsrA9RsHJGvtGmkPVSwgoahWCQ6YnZZf888HkDbsCmv9QM877YPvhVKkdnbaans6Pu2LG"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

trait ErgoMix {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

import kiosk.ergo._
import kiosk.script.ScriptUtil
import org.ergoplatform.Pay2SAddress
import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer
import org.ergoplatform.kiosk.script.ScriptUtil
import org.ergoplatform.kiosk.script.ScriptUtil._
import scala.collection.mutable.{Map => MMap}

class ErgoMixSpec extends AnyWordSpec with Matchers with ErgoMix {

import kiosk.script.ScriptUtil._

"ErgoMix script" should {
"compile correctly" in {
val env = MMap[String, KioskType[_]]()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

trait InterestFreeLoan {
/* using the description at https://www.ergoforum.org/t/interest-free-loan-contract/67
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

import kiosk.ErgoUtil
import kiosk.ergo._
import kiosk.script.ScriptUtil
import org.ergoplatform.Pay2SAddress
import scorex.crypto.hash.Blake2b256
import org.ergoplatform.kiosk.ErgoUtil
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import scorex.crypto.hash.Blake2b256
import org.ergoplatform.kiosk.script.ScriptUtil
import org.ergoplatform.kiosk.script.ScriptUtil._

import scala.collection.mutable.{Map => MMap}

class InterestFreeLoanSpec extends AnyWordSpec with Matchers with InterestFreeLoan {
Expand All @@ -18,8 +19,6 @@ class InterestFreeLoanSpec extends AnyWordSpec with Matchers with InterestFreeLo

val env = MMap[String, KioskType[_]]()

import ScriptUtil._

env.setCollByte("rateOracleTokenID", rateOracleTokenID)
env.setCollByte("usdTokenID", usdTokenID)

Expand All @@ -44,8 +43,6 @@ class InterestFreeLoanSpec extends AnyWordSpec with Matchers with InterestFreeLo

val ergoTree = ScriptUtil.compile(env.toMap, src)
ergoTree.bytes.encodeHex shouldBe "101404000518051405040400040208cd02b4257a90a74d2c596aad692454533e265d30b5ac5cba7503e950f3aa98aa39a80702adee2f931b2e011fc44c9ece6ad6ad2e2dafe6506114755f20bad7268b191a3d05d00f04000e20ef3a6cba7fae67bdef5c7acf35658e22c3768c5d282771c61f5675f4a283c41904a00b040005000500040404040e2013080243c81647060bf7c8ebb7df10fc0aee16274810abf91f8c85f5c819d88805d00f04e08903d813d601c1a7d602e4c6a70405d603b2db6501fe730000d604e4c672030405d6059c72027204d6069d9c720573017302d6079d99720172067303d608b2a5730400d60993c27208c2a7d60ac17208d60b997202e4c672080405d60cb2a5730500d60d7306d60e93c2720cd0720dd60f7307d610e4c6a70504d611e4c672080504d612d1edededed93720b7308939c720b7204997201720a7209938cb2db6308720373090001730aeded907211a392721199a3730b9172117210d613b2db6308720c730c00eb02d1edededededededed917207730d720993720a720693720b730e720e93c1720c720793c2b2a5730f00d0cd720f93c1b2a573100072079372107211eb03ea02d19172057201720dea02ea027212cd720fd1eded938c7213017311938c7213027312720eea02ea027212720dd19199a372107313"

import ScriptUtil.ergoAddressEncoder
Pay2SAddress(ergoTree).toString shouldBe "A9esikT7NVU4Epn4JCG6Jq2CMht7YttLszCx6UtjDvoam5czQNP1NnqgFqb7i5Yw8DFsUuqBAumixiYa7uyc8s2Rf3DZPuZ3s22qHnitM5U3ajq5oSTvN2JKDir2cctWpkxVqVWQXCC9yafuorma6t7RQwr6CecfuTSnimwsvrJVfoYNVmpEdVCaiqxPdHMsM3XW7oxmRsVjRqwna3xWbqQ1Fb8uEuHgteGYzkdwBUKjEDg2FtygQzsv5dw5S4ncs5miYe8mS2zCy5KgzCbD8mCAmHBDANCJ3ZdPB55iSYhNWnmAqkQANdyRArHNjaV7QZSAmJ8AXFheRJvsAk8b8TNi97A6avKRJAuLTA5osR7f5pvXc1nD94eUz6F8VHxANBgkvjZkc6We85971MikjnvwAtMzgKvszvjEsWCZb5tmUXXZYZMLfgEhwKqUeCQjt8Dgz74xt5RW7RDBTnKM3LUcux3tpf9w3mUDfiufBjQXRZoZ7T5F9nbau4fySe7frWz232t7zG72JA8K4NvkVz53V3Brie55Ufyuo9dmW1WgnvdxxbSLVYZmDzD6hTbMeapYX1GkCFLsn5UVNrJWN4KTuPt6LQCCtkdrzWf1XfSGd2p4jVXszLCCNUKbNm1ARrxUPGwApBL5pFzfF8WPL7BTYw8i2tPmVy"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
package org.sh.kiosk.ergo

import kiosk.ErgoUtil
import kiosk.ergo.{KioskErgoTree, _}
import kiosk.script.ScriptUtil
import org.ergoplatform.Pay2SAddress
import scorex.crypto.hash.Blake2b256

import scala.collection.mutable.{Map => MMap}
package org.ergoplatform.kiosk.ergo

trait OneWayUSDToken {
/* using the description at https://www.ergoforum.org/t/tethering-a-token-to-usd-using-the-rate-oracle/118/4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package org.sh.kiosk.ergo
package org.ergoplatform.kiosk.ergo

import kiosk.ErgoUtil
import kiosk.ergo._
import kiosk.script.ScriptUtil
import org.ergoplatform.Pay2SAddress
import scorex.crypto.hash.Blake2b256
import org.ergoplatform.kiosk.ErgoUtil
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import scorex.crypto.hash.Blake2b256
import org.ergoplatform.kiosk.script.ScriptUtil
import org.ergoplatform.kiosk.script.ScriptUtil._

import scala.collection.mutable.{Map => MMap}

class OneWayUSDTokenSpec extends AnyWordSpec with Matchers with OneWayUSDToken {
Expand All @@ -17,8 +18,6 @@ class OneWayUSDTokenSpec extends AnyWordSpec with Matchers with OneWayUSDToken {

val env = MMap[String, KioskType[_]]()

import ScriptUtil._

env.setCollByte("rateTokenID", rateOracleTokenID)

// lender
Expand All @@ -30,8 +29,6 @@ class OneWayUSDTokenSpec extends AnyWordSpec with Matchers with OneWayUSDToken {
val ergoTree = ScriptUtil.compile(env.toMap, source)

ergoTree.bytes.encodeHex shouldBe "10080400040004000402040004000e20ef3a6cba7fae67bdef5c7acf35658e22c3768c5d282771c61f5675f4a283c41908cd02adee2f931b2e011fc44c9ece6ad6ad2e2dafe6506114755f20bad7268b191a3dd805d601b2db6308a7730000d602b2a5730100d603b2db63087202730200d604b2a5730300d605b2db6501fe730400ededed90998c7201028c7203029dc17204e4c672050405938cb2db63087205730500017306ed938c7201018c72030193c27202c2a793c27204d07307"

import ScriptUtil.ergoAddressEncoder
Pay2SAddress(ergoTree).toString shouldBe "3Nvu37NpxyjZ4ppVxRBuxMdM2Z9m34KHAds1fr4WTm39XJNXnbLrffMfzzQNZTec6tsKGqDKXg3RFfLRASYRmkaM36nf9McJF1GLG72krbTfL64XadZ53aeNK6NWHTpyQMkrcVrQPiooaBm4aYfXnfyroFdCJPwmAaCL6RgCq7RrVXfyUZcuuaspTJ8hmiECn4Ke7Eio7u2JvLJRaHKQ4mXHSHZtjFQETSMJRDsYDQv67QBXGYfwc7hiEFfeTP2B31BaUPdCTc"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
package org.sh.kiosk.ergo

import kiosk.ErgoUtil
import kiosk.ergo.KioskType
import kiosk.script.ScriptUtil
import scorex.crypto.hash.Blake2b256
import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer

import scala.collection.mutable.{Map => MMap}
package org.ergoplatform.kiosk.ergo

/*
Using the idea from http://research.paradigm.xyz/Yield.pdf
Expand Down
Loading

0 comments on commit 8c80776

Please sign in to comment.