Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add http scheme support and removed the constraint from public keys table #848

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/db/migration/V1__create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);


Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/io/iohk/atala/prism/node/NodeConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down
Loading