Skip to content

Commit 4365528

Browse files
committed
Add http scheme support and removed the contraint from publickeys table
Signed-off-by: mineme0110 <[email protected]>
1 parent 9279bfe commit 4365528

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

src/main/resources/application.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ cardano {
8787
wallet {
8888
host = "localhost"
8989
port = 8090
90+
scheme = http
9091

92+
scheme = ${?NODE_CARDANO_WALLET_API_HTTP_SCHEME}
9193
host = ${?NODE_CARDANO_WALLET_API_HOST}
9294
port = ${?NODE_CARDANO_WALLET_API_PORT}
9395

src/main/resources/db/migration/V1__create_tables.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ CREATE TABLE public.public_keys
143143
ledger varchar(32) NOT NULL,
144144
compressed BYTEA NOT NULL,
145145
CONSTRAINT public_keys_pk PRIMARY KEY (did_suffix,
146-
key_id),
147-
CONSTRAINT x_compressed_length CHECK ((length(compressed) = 33))
146+
key_id)
148147
);
149148

150149

src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ object NodeConfig {
4040
}
4141

4242
def cardanoWalletConfig(config: Config): CardanoWalletApiClient.Config = {
43+
val scheme = config.getString("scheme")
4344
val host = config.getString("host")
4445
val port = config.getInt("port")
4546
val routingHeaderName = Try("routingHeaderName").map(config.getString).toOption
4647
val routingHeaderValue = Try("routingHeaderValue").map(config.getString).toOption
4748
val routingHeader = Applicative[Option]
4849
.map2(routingHeaderName, routingHeaderValue)((headerName, headerValue) => Header(headerName, headerValue))
49-
CardanoWalletApiClient.Config(host, port, routingHeader)
50+
CardanoWalletApiClient.Config(scheme, host, port, routingHeader)
5051
}
5152
}

src/main/scala/io/iohk/atala/prism/node/cardano/wallet/api/ApiClient.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private[wallet] class ApiClient[F[_]: Functor](
8080
.headers(config.routingHeader.toList: _*)
8181
.method(
8282
method.httpMethod,
83-
Uri.apply(config.host, config.port).withWholePath(method.path)
83+
Uri.apply(config.scheme, config.host, config.port).withWholePath(method.path)
8484
)
8585
.body(method.requestBody.map(_.noSpaces).getOrElse(""))
8686
.send(backend)
@@ -97,7 +97,7 @@ private[wallet] class ApiClient[F[_]: Functor](
9797

9898
private[wallet] object ApiClient {
9999

100-
case class Config(host: String, port: Int, routingHeader: Option[Header])
100+
case class Config(scheme:String, host: String, port: Int, routingHeader: Option[Header])
101101

102102
private[wallet] def defaultBackend[F[_]: Async]: Resource[F, SttpBackend[F, Any]] =
103103
AsyncHttpClientCatsBackend.resource[F]()

src/test/scala/io/iohk/atala/prism/node/cardano/wallet/testing/FakeCardanoWalletApiClient.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object FakeCardanoWalletApiClient {
5353
*/
5454
object NotFound {
5555
def apply[F[_]: Async](): CardanoWalletApiClient[F] = {
56-
val config = ApiClient.Config("localhost", 8090, Option.empty)
56+
val config = ApiClient.Config("http", "localhost", 8090, Option.empty)
5757
val backend = AsyncHttpClientCatsBackend.stub
5858
new ApiClient(config, backend)
5959
}
@@ -66,7 +66,7 @@ object FakeCardanoWalletApiClient {
6666
responseBody: String,
6767
maybeRoutingHeader: Option[Header]
6868
): CardanoWalletApiClient[F] = {
69-
val config = ApiClient.Config("localhost", 8090, maybeRoutingHeader)
69+
val config = ApiClient.Config("http", "localhost", 8090, maybeRoutingHeader)
7070
val backend = AsyncHttpClientCatsBackend.stub
7171
.whenRequestMatches(request =>
7272
request.uri.host.contains(config.host)

0 commit comments

Comments
 (0)