Having trouble compiling my KmsDriverFactory implementation
- Jim_ZhangOP
We are developing an implementation of the KmsDriver extension based on this doc: Canton KMS Driver Developer Guide — Daml SDK 2.10.0 documentation
The implementation for the KmsDriver interface was pretty straightforward, but we are having trouble getting the Factory to compile:
[error] -- [E172] Type Error: /Users/jimzhang/workspace.daml/kaleido-canton-kms-scala/src/main/scala/aws/kms/AwsKmsDriverFactory.scala:35:71 [error] 35 | override def configReader = pureconfig.ConfigReader.mapReader[String] [error] | ^ [error] |Cannot find an implicit instance of pureconfig.ConfigReader[String]. [error] |If you are trying to read or write a case class or sealed trait consider using PureConfig's auto derivation by adding `import pureconfig.generic.auto._`. [error] |I found: [error] | [error] | pureconfig.Derivation.materializeDerivation[A] [error] | [error] |But method materializeDerivation in object Derivation does not match type pureconfig.Derivation[pureconfig.ConfigReader[String]].This was after we’ve added the import
import pureconfig.generic.auto._which according to online searches was the recommendation for errors like this.Here’s the
build.sbtfile for the project config:ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / scalaVersion := "3.3.5" lazy val root = (project in file(".")) .settings( name := "kaleido-canton-kms", idePackagePrefix := Some("io.kaleido.canton.kms") ) libraryDependencies += "com.daml" % "canton-community-util-logging_2.13" % "3.3.0-adhoc.20250314.13658.0.v2ae85555" libraryDependencies += "com.github.pureconfig" %% "pureconfig-core" % "0.17.8" libraryDependencies += "io.opentelemetry" % "opentelemetry-context" % "1.48.0" libraryDependencies += "org.scala-lang.modules" % "scala-java8-compat_3" % "1.0.2" libraryDependencies += "software.amazon.awssdk" % "kms" % "2.29.45" scalacOptions += "-explain"Any pointers would be much appreciated!
Jim
- soren 1
Hi Jim
how did you define
ConfigTypein the driver factory?In case of
ConfigType = Stringthe following works for me to just use the built-inStringconfig reader/writer:override def configReader: ConfigReader[String] = ConfigReader[String] override def configWriter(confidential: Boolean): ConfigWriter[String] = ConfigWriter[String]In case of
ConfigType = Map[String, String]you can do use themapReaderandmapWritermethods which apply to the value in the Map:override def configReader: ConfigReader[Map[String, String]] = ConfigReader.mapReader[String] override def configWriter(confidential: Boolean): ConfigWriter[Map[String, String]] = ConfigWriter.mapWriter[String]I noticed that you are building a KMS driver for AWS KMS, note that the Canton enterprise edition has already built-in support for AWS KMS.
- Jim_Zhang
Thanks @soren for your response. Our Scala developer has since resolved the issue by finding the right place to initialize the implicit variable. Yes our goal was to have additional capabilities for signing/encryption as needed by our platform. We were just using the AWS SDK as an exercise to understand the expected behavior of the Canton KmsDriver interface.
Best,
Jim