Skip to content

Commit

Permalink
Fix contract invocation (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
phearnot authored Sep 4, 2024
1 parent 5639545 commit b110ff5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
pull: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.IMAGE_NAME}}
Expand Down
65 changes: 54 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
enablePlugins(UniversalDeployPlugin, JavaAppPackaging, GitVersioning)
enablePlugins(UniversalDeployPlugin, GitVersioning)

git.useGitDescribe := true
git.baseVersion := "1.0.0"
git.useGitDescribe := true
git.baseVersion := "1.0.0"
git.uncommittedSignifier := Some("DIRTY")

scalaVersion := "2.13.14"
organization := "network.units"
scalaVersion := "2.13.14"
organization := "network.units"
organizationName := "Units Network"
name := "consensus-client"
name := "consensus-client"
maintainer := "Units Network Team"
resolvers ++= Resolver.sonatypeOssRepos("releases") ++ Resolver.sonatypeOssRepos("snapshots") ++ Seq(Resolver.mavenLocal)
libraryDependencies ++= Seq(
"com.wavesplatform" % "node" % "1.5.7" % "provided",
"com.softwaremill.sttp.client3" % "core_2.13" % "3.9.8",
"com.softwaremill.sttp.client3" %% "play-json" % "3.9.8",
"com.github.jwt-scala" %% "jwt-play-json" % "10.0.1"
"com.wavesplatform" % "node" % "1.5.7" % "provided",
"com.softwaremill.sttp.client3" % "core_2.13" % "3.9.8",
"com.softwaremill.sttp.client3" %% "play-json" % "3.9.8",
"com.github.jwt-scala" %% "jwt-play-json" % "10.0.1"
)

scalacOptions ++= Seq(
Expand All @@ -28,7 +29,49 @@ scalacOptions ++= Seq(
"-Xlint"
)

lazy val buildTarballsForDocker = taskKey[Unit]("Package node and grpc-server tarballs and copy them to docker/target")
Compile / packageDoc / publishArtifact := false

def makeJarName(
org: String,
name: String,
revision: String,
artifactName: String,
artifactClassifier: Option[String]
): String =
org + "." +
name + "-" +
Option(artifactName.replace(name, "")).filterNot(_.isEmpty).map(_ + "-").getOrElse("") +
revision +
artifactClassifier.filterNot(_.isEmpty).map("-" + _).getOrElse("") +
".jar"

def getJarFullFilename(dep: Attributed[File]): String = {
val filename: Option[String] = for {
module <- dep.metadata.get(AttributeKey[ModuleID]("moduleID"))
artifact <- dep.metadata.get(AttributeKey[Artifact]("artifact"))
} yield makeJarName(module.organization, module.name, module.revision, artifact.name, artifact.classifier)
filename.getOrElse(dep.data.getName)
}

def universalDepMappings(deps: Seq[Attributed[File]]): Seq[(File, String)] =
for {
dep <- deps
} yield dep.data -> ("lib/" + getJarFullFilename(dep))

Universal / mappings += {
val jar = (Compile / packageBin).value
val id = projectID.value
val art = (Compile / packageBin / artifact).value
jar -> ("lib/" + makeJarName(id.organization, id.name, id.revision, art.name, art.classifier))
}
Universal / mappings ++= universalDepMappings((Runtime / dependencyClasspath).value.filterNot { p =>
p.get(AttributeKey[ModuleID]("moduleID")).exists { m =>
m.organization == "org.scala-lang" ||
m.organization.startsWith("com.fasterxml.jackson")
}
})

lazy val buildTarballsForDocker = taskKey[Unit]("Package consensus-client tarball and copy it to docker/target")
buildTarballsForDocker := {
IO.copyFile(
(Universal / packageZipTarball).value,
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/units/client/contract/ContractFunction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import com.wavesplatform.lang.v1.compiler.Terms.{CONST_BYTESTR, CONST_LONG, CONS
import units.{BlockHash, ClientError, Job}
import units.util.HexBytesConverter.toHexNoPrefix
import cats.syntax.either.*
import org.web3j.utils.Numeric.cleanHexPrefix

abstract class ContractFunction(name: String, reference: BlockHash, extraArgs: Either[CommonError, List[EVALUATED]]) {
def toFunctionCall(blockHash: BlockHash, transfersRootHash: Digest, lastClToElTransferIndex: Long): Job[FUNCTION_CALL] = (for {
hash <- CONST_STRING(blockHash)
ref <- CONST_STRING(reference)
hash <- CONST_STRING(cleanHexPrefix(blockHash))
ref <- CONST_STRING(cleanHexPrefix(reference))
trh <- CONST_STRING(toHexNoPrefix(transfersRootHash))
xtra <- extraArgs
} yield FUNCTION_CALL(
Expand Down

0 comments on commit b110ff5

Please sign in to comment.