Skip to content

Commit

Permalink
quick fix for disclosures, needs porting
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbrauner-da committed Oct 24, 2024
1 parent 2d9103f commit f1c7112
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.Materializer
import org.scalacheck.{Gen, Prop}

import scala.annotation.nowarn

//import scala.annotation.nowarn
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, ExecutionContext}
Expand Down Expand Up @@ -87,7 +89,7 @@ object Demo {

// val workers = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(1))

// @nowarn("cat=unused")
@nowarn("cat=unused")
val bad = Parser.parseScenario("""
|Scenario
| Topology
Expand All @@ -101,8 +103,8 @@ object Demo {

implicit val pretty: Ledgers.Scenario => org.scalacheck.util.Pretty =
(s: Ledgers.Scenario) => org.scalacheck.util.Pretty(_ => Pretty.prettyScenario(s))
// validSymScenarios
List(bad)
validSymScenarios
// List(bad)
.foreach(scenario => {
// workers.execute(() =>
if (scenario.ledger.nonEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.digitalasset.daml.lf.speedy.Speedy.Machine
import com.digitalasset.daml.lf.speedy.{Pretty, SError, SValue, TraceLog, WarningLog}
import com.digitalasset.daml.lf.transaction.{
FatContractInstance,
FatContractInstanceImpl,
GlobalKey,
IncompleteTransaction,
Node,
Expand All @@ -39,7 +40,6 @@ import com.digitalasset.daml.lf.transaction.{
import com.digitalasset.daml.lf.value.Value
import com.digitalasset.daml.lf.value.Value.ContractId
import com.daml.nonempty.NonEmpty

import com.digitalasset.canton.logging.{LoggingContextWithTrace, NamedLoggerFactory}
import com.digitalasset.canton.ledger.localstore.InMemoryUserManagementStore
import scalaz.OneAnd
Expand Down Expand Up @@ -119,8 +119,24 @@ class IdeLedgerClient(
private val userManagementStore =
new InMemoryUserManagementStore(createAdmin = false, namedLoggerFactory)

private[this] def blob(contract: FatContractInstance): Bytes =
Bytes.fromByteString(TransactionCoder.encodeFatContractInstance(contract).toOption.get)
private[this] def blob(contract: FatContractInstance): Bytes = {
val valueTranslator =
new ValueTranslator(compiledPackages.pkgInterface, requireV1ContractIdSuffix = false)
valueTranslator.translateValue(TTyCon(contract.templateId), contract.createArg) match {
case Left(_) =>
sys.error("blob: translateValue failed")
case Right(sArg) =>
val normalizedArg = sArg.toNormalizedValue(contract.version)
val normalizedContract =
contract.asInstanceOf[FatContractInstanceImpl].copy(createArg = normalizedArg)
Bytes.fromByteString(
TransactionCoder
.encodeFatContractInstance(normalizedContract)
.toOption
.get
)
}
}

private[this] def blob(create: Node.Create, createAt: Time.Timestamp): Bytes =
blob(FatContractInstance.fromCreateNode(create, createAt, Bytes.Empty))
Expand Down

0 comments on commit f1c7112

Please sign in to comment.