Skip to content

Commit 3f72869

Browse files
committed
Move grantValidatorLicense to HttpSvOperatorHandler
Signed-off-by: Divam <dfordivam@gmail.com>
1 parent 9331dc5 commit 3f72869

File tree

6 files changed

+58
-58
lines changed

6 files changed

+58
-58
lines changed

apps/app/src/main/scala/org/lfdecentralizedtrust/splice/console/SvAppReference.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class SvAppBackendReference(
363363
def grantValidatorLicense(partyId: PartyId): Unit =
364364
consoleEnvironment.run {
365365
httpCommand(
366-
HttpSvAdminAppClient.GrantValidatorLicense(partyId)
366+
HttpSvOperatorAppClient.GrantValidatorLicense(partyId)
367367
)
368368
}
369369

apps/sv/src/main/openapi/sv-internal.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ paths:
7575
/v0/admin/validator/licenses/grant:
7676
post:
7777
tags: [sv]
78-
x-jvm-package: sv_admin
78+
x-jvm-package: sv_operator
7979
operationId: "grantValidatorLicense"
8080
requestBody:
8181
required: true

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/admin/api/client/commands/HttpSvAdminAppClient.scala

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import org.apache.pekko.stream.Materializer
88
import cats.data.EitherT
99
import org.lfdecentralizedtrust.splice.admin.api.client.commands.{HttpClientBuilder, HttpCommand}
1010
import org.lfdecentralizedtrust.splice.http.HttpClient
11-
import org.lfdecentralizedtrust.splice.http.v0.definitions
1211
import org.lfdecentralizedtrust.splice.http.v0.definitions.TriggerDomainMigrationDumpRequest
1312
import org.lfdecentralizedtrust.splice.http.v0.sv_admin.TriggerDomainMigrationDumpResponse
1413
import org.lfdecentralizedtrust.splice.http.v0.sv_admin as http
@@ -40,25 +39,6 @@ object HttpSvAdminAppClient {
4039
)
4140
}
4241

43-
case class GrantValidatorLicense(partyId: PartyId)
44-
extends BaseCommand[http.GrantValidatorLicenseResponse, Unit] {
45-
46-
override def submitRequest(
47-
client: Client,
48-
headers: List[HttpHeader],
49-
): EitherT[Future, Either[Throwable, HttpResponse], http.GrantValidatorLicenseResponse] =
50-
client.grantValidatorLicense(
51-
body = definitions.GrantValidatorLicenseRequest(partyId.toProtoPrimitive),
52-
headers = headers,
53-
)
54-
55-
override def handleOk()(implicit
56-
decoder: TemplateJsonDecoder
57-
) = { case http.GrantValidatorLicenseResponse.OK =>
58-
Right(())
59-
}
60-
}
61-
6242
case class PauseDecentralizedSynchronizer()
6343
extends BaseCommand[http.PauseDecentralizedSynchronizerResponse, Unit] {
6444

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/admin/api/client/commands/HttpSvOperatorAppClient.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.lfdecentralizedtrust.splice.http.v0.{definitions, sv_operator as http
2424
import org.lfdecentralizedtrust.splice.util.{Codec, Contract, TemplateJsonDecoder}
2525
import org.lfdecentralizedtrust.splice.sv.util.ValidatorOnboarding
2626
import com.digitalasset.canton.admin.api.client.data.NodeStatus
27+
import com.digitalasset.canton.topology.PartyId
2728
import com.digitalasset.canton.daml.lf.value.json.ApiCodecCompressed
2829
import com.digitalasset.canton.logging.ErrorLoggingContext
2930
import com.digitalasset.canton.tracing.TraceContext
@@ -99,6 +100,25 @@ object HttpSvOperatorAppClient {
99100
}
100101
}
101102

103+
case class GrantValidatorLicense(partyId: PartyId)
104+
extends BaseCommand[http.GrantValidatorLicenseResponse, Unit] {
105+
106+
override def submitRequest(
107+
client: Client,
108+
headers: List[HttpHeader],
109+
): EitherT[Future, Either[Throwable, HttpResponse], http.GrantValidatorLicenseResponse] =
110+
client.grantValidatorLicense(
111+
body = definitions.GrantValidatorLicenseRequest(partyId.toProtoPrimitive),
112+
headers = headers,
113+
)
114+
115+
override def handleOk()(implicit
116+
decoder: TemplateJsonDecoder
117+
) = { case http.GrantValidatorLicenseResponse.OK =>
118+
Right(())
119+
}
120+
}
121+
102122
case object ListAmuletPriceVotes
103123
extends BaseCommand[http.ListAmuletPriceVotesResponse, Seq[
104124
Contract[AmuletPriceVote.ContractId, AmuletPriceVote]

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/admin/http/HttpSvAdminHandler.scala

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -51,42 +51,6 @@ class HttpSvAdminHandler(
5151
protected val workflowId: String = this.getClass.getSimpleName
5252
private val dsoStore = dsoStoreWithIngestion.store
5353

54-
override def grantValidatorLicense(
55-
respond: r0.GrantValidatorLicenseResponse.type
56-
)(
57-
body: definitions.GrantValidatorLicenseRequest
58-
)(tuser: AdminUserRequest): Future[r0.GrantValidatorLicenseResponse] = {
59-
implicit val AdminUserRequest(traceContext) = tuser
60-
withSpan(s"$workflowId.grantValidatorLicense") { implicit traceContext => _ =>
61-
Codec.decode(Codec.Party)(body.partyId) match {
62-
case Left(error) =>
63-
Future.failed(
64-
HttpErrorHandler.badRequest(s"Invalid party ID '${body.partyId}': $error")
65-
)
66-
case Right(validatorParty) =>
67-
for {
68-
dsoRules <- dsoStore.getDsoRules()
69-
svParty = dsoStore.key.svParty
70-
dsoParty = dsoStore.key.dsoParty
71-
cmd = dsoRules.exercise(
72-
_.exerciseDsoRules_GrantValidatorLicense(
73-
svParty.toProtoPrimitive,
74-
validatorParty.toProtoPrimitive,
75-
)
76-
)
77-
_ <- dsoStoreWithIngestion
78-
.connection(SpliceLedgerConnectionPriority.Low)
79-
.submit(Seq(svParty), Seq(dsoParty), cmd)
80-
.withSynchronizerId(dsoRules.domain)
81-
.noDedup
82-
.yieldUnit()
83-
} yield {
84-
r0.GrantValidatorLicenseResponseOK
85-
}
86-
}
87-
}
88-
}
89-
9054
override def pauseDecentralizedSynchronizer(
9155
respond: r0.PauseDecentralizedSynchronizerResponse.type
9256
)()(

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/admin/http/HttpSvOperatorHandler.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,42 @@ class HttpSvOperatorHandler(
169169
.map(r0.ListValidatorLicensesResponse.OK)
170170
}
171171

172+
override def grantValidatorLicense(
173+
respond: r0.GrantValidatorLicenseResponse.type
174+
)(
175+
body: definitions.GrantValidatorLicenseRequest
176+
)(extracted: ActAsKnownUserRequest): Future[r0.GrantValidatorLicenseResponse] = {
177+
implicit val ActAsKnownUserRequest(traceContext) = extracted
178+
withSpan(s"$workflowId.grantValidatorLicense") { implicit traceContext => _ =>
179+
Codec.decode(Codec.Party)(body.partyId) match {
180+
case Left(error) =>
181+
Future.failed(
182+
HttpErrorHandler.badRequest(s"Invalid party ID '${body.partyId}': $error")
183+
)
184+
case Right(validatorParty) =>
185+
for {
186+
dsoRules <- dsoStore.getDsoRules()
187+
svParty = dsoStore.key.svParty
188+
dsoParty = dsoStore.key.dsoParty
189+
cmd = dsoRules.exercise(
190+
_.exerciseDsoRules_GrantValidatorLicense(
191+
svParty.toProtoPrimitive,
192+
validatorParty.toProtoPrimitive,
193+
)
194+
)
195+
_ <- dsoStoreWithIngestion
196+
.connection(AppStoreWithIngestion.SpliceLedgerConnectionPriority.Low)
197+
.submit(Seq(svParty), Seq(dsoParty), cmd)
198+
.withSynchronizerId(dsoRules.domain)
199+
.noDedup
200+
.yieldUnit()
201+
} yield {
202+
r0.GrantValidatorLicenseResponseOK
203+
}
204+
}
205+
}
206+
}
207+
172208
def listOngoingValidatorOnboardings(
173209
respond: r0.ListOngoingValidatorOnboardingsResponse.type
174210
)()(

0 commit comments

Comments
 (0)