diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 28af2087a1..0a4abd3c50 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -87,7 +87,9 @@ cardano { wallet { host = "localhost" port = 8090 + scheme = http + scheme = ${?NODE_CARDANO_WALLET_API_HTTP_SCHEME} host = ${?NODE_CARDANO_WALLET_API_HOST} port = ${?NODE_CARDANO_WALLET_API_PORT} diff --git a/src/main/resources/db/migration/V1__create_tables.sql b/src/main/resources/db/migration/V1__create_tables.sql index b302cb7450..b73819db65 100644 --- a/src/main/resources/db/migration/V1__create_tables.sql +++ b/src/main/resources/db/migration/V1__create_tables.sql @@ -143,8 +143,7 @@ CREATE TABLE public.public_keys ledger varchar(32) NOT NULL, compressed BYTEA NOT NULL, CONSTRAINT public_keys_pk PRIMARY KEY (did_suffix, - key_id), - CONSTRAINT x_compressed_length CHECK ((length(compressed) = 33)) + key_id) ); diff --git a/src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala b/src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala index 0c9dfab0c8..ee0d14988f 100644 --- a/src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala +++ b/src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala @@ -40,12 +40,13 @@ object NodeConfig { } def cardanoWalletConfig(config: Config): CardanoWalletApiClient.Config = { + val scheme = config.getString("scheme") val host = config.getString("host") val port = config.getInt("port") val routingHeaderName = Try("routingHeaderName").map(config.getString).toOption val routingHeaderValue = Try("routingHeaderValue").map(config.getString).toOption val routingHeader = Applicative[Option] .map2(routingHeaderName, routingHeaderValue)((headerName, headerValue) => Header(headerName, headerValue)) - CardanoWalletApiClient.Config(host, port, routingHeader) + CardanoWalletApiClient.Config(scheme, host, port, routingHeader) } } diff --git a/src/main/scala/io/iohk/atala/prism/node/cardano/wallet/api/ApiClient.scala b/src/main/scala/io/iohk/atala/prism/node/cardano/wallet/api/ApiClient.scala index 2e46368917..361e09b69a 100644 --- a/src/main/scala/io/iohk/atala/prism/node/cardano/wallet/api/ApiClient.scala +++ b/src/main/scala/io/iohk/atala/prism/node/cardano/wallet/api/ApiClient.scala @@ -80,7 +80,7 @@ private[wallet] class ApiClient[F[_]: Functor]( .headers(config.routingHeader.toList: _*) .method( method.httpMethod, - Uri.apply(config.host, config.port).withWholePath(method.path) + Uri.apply(config.scheme, config.host, config.port).withWholePath(method.path) ) .body(method.requestBody.map(_.noSpaces).getOrElse("")) .send(backend) @@ -97,7 +97,7 @@ private[wallet] class ApiClient[F[_]: Functor]( private[wallet] object ApiClient { - case class Config(host: String, port: Int, routingHeader: Option[Header]) + case class Config(scheme: String, host: String, port: Int, routingHeader: Option[Header]) private[wallet] def defaultBackend[F[_]: Async]: Resource[F, SttpBackend[F, Any]] = AsyncHttpClientCatsBackend.resource[F]() diff --git a/src/test/scala/io/iohk/atala/prism/node/cardano/wallet/testing/FakeCardanoWalletApiClient.scala b/src/test/scala/io/iohk/atala/prism/node/cardano/wallet/testing/FakeCardanoWalletApiClient.scala index c191a1b538..50a4377b89 100644 --- a/src/test/scala/io/iohk/atala/prism/node/cardano/wallet/testing/FakeCardanoWalletApiClient.scala +++ b/src/test/scala/io/iohk/atala/prism/node/cardano/wallet/testing/FakeCardanoWalletApiClient.scala @@ -53,7 +53,7 @@ object FakeCardanoWalletApiClient { */ object NotFound { def apply[F[_]: Async](): CardanoWalletApiClient[F] = { - val config = ApiClient.Config("localhost", 8090, Option.empty) + val config = ApiClient.Config("http", "localhost", 8090, Option.empty) val backend = AsyncHttpClientCatsBackend.stub new ApiClient(config, backend) } @@ -66,7 +66,7 @@ object FakeCardanoWalletApiClient { responseBody: String, maybeRoutingHeader: Option[Header] ): CardanoWalletApiClient[F] = { - val config = ApiClient.Config("localhost", 8090, maybeRoutingHeader) + val config = ApiClient.Config("http", "localhost", 8090, maybeRoutingHeader) val backend = AsyncHttpClientCatsBackend.stub .whenRequestMatches(request => request.uri.host.contains(config.host)