Skip to content

Commit 761fb8b

Browse files
committed
Extend backend to pass ExternalPartyConfigState in choice context
[ci] Signed-off-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
1 parent f19898b commit 761fb8b

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package org.lfdecentralizedtrust.splice.store
5+
6+
import org.lfdecentralizedtrust.splice.codegen.java.splice.externalpartyconfigstate.ExternalPartyConfigState
7+
import org.lfdecentralizedtrust.splice.util.Contract
8+
import com.digitalasset.canton.logging.pretty.{Pretty, PrettyPrinting}
9+
import com.digitalasset.canton.tracing.TraceContext
10+
11+
import scala.concurrent.{ExecutionContext, Future}
12+
13+
trait ExternalPartyConfigStateStore extends AppStore {
14+
15+
def lookupExternalPartyConfigStatesPair()(implicit
16+
ec: ExecutionContext,
17+
tc: TraceContext,
18+
): Future[Option[ExternalPartyConfigStateStore.ExternalPartyConfigStatePair]] =
19+
for {
20+
configStates <- multiDomainAcsStore.listContracts(
21+
ExternalPartyConfigState.COMPANION
22+
)
23+
} yield for {
24+
Seq(oldest, newest) <- Some(
25+
configStates
26+
.sortBy(_.payload.targetArchiveAfter)
27+
)
28+
} yield ExternalPartyConfigStateStore.ExternalPartyConfigStatePair(
29+
oldest = oldest.contract,
30+
newest = newest.contract,
31+
)
32+
33+
def lookupLatestExternalPartyConfigState()(implicit ec: ExecutionContext, tc: TraceContext): Future[Option[Contract[ExternalPartyConfigState.ContractId, ExternalPartyConfigState]]] =
34+
lookupExternalPartyConfigStatesPair().map(_.map(_.newest))
35+
}
36+
37+
object ExternalPartyConfigStateStore {
38+
case class ExternalPartyConfigStatePair(
39+
oldest: Contract[ExternalPartyConfigState.ContractId, ExternalPartyConfigState],
40+
newest: Contract[ExternalPartyConfigState.ContractId, ExternalPartyConfigState],
41+
) extends PrettyPrinting {
42+
override def pretty: Pretty[this.type] =
43+
prettyOfClass(
44+
param("oldest", _.oldest),
45+
param("newest", _.newest),
46+
)
47+
}
48+
49+
}

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/admin/http/HttpTokenStandardTransferInstructionHandler.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class HttpTokenStandardTransferInstructionHandler(
174174
.asRuntimeException()
175175
)
176176
)
177+
// TODO(#3630) Don't include amulet rules and newest open round when informees all have vetted the newest version.
178+
externalPartyConfigStateO <- store.lookupLatestExternalPartyConfigState()
177179
} yield {
178180
val choiceContextBuilder = new ChoiceContextBuilder(
179181
AmuletConfigSchedule(amuletRules.payload.configSchedule)
@@ -187,7 +189,7 @@ class HttpTokenStandardTransferInstructionHandler(
187189
choiceContextBuilder.addContracts(
188190
"amulet-rules" -> amuletRules,
189191
"open-round" -> newestOpenRound.contract,
190-
),
192+
).addOptionalContract("external-party-config-state" -> externalPartyConfigStateO),
191193
newestOpenRound.contract.payload,
192194
)
193195
}

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/store/ScanStore.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import org.lfdecentralizedtrust.splice.store.{
3434
AppStore,
3535
DsoRulesStore,
3636
Limit,
37+
ExternalPartyConfigStateStore,
3738
MiningRoundsStore,
3839
MultiDomainAcsStore,
3940
PageLimit,
@@ -57,7 +58,8 @@ trait ScanStore
5758
with PackageIdResolver.HasAmuletRules
5859
with DsoRulesStore
5960
with MiningRoundsStore
60-
with VotesStore {
61+
with VotesStore
62+
with ExternalPartyConfigStateStore {
6163

6264
def aggregate()(implicit
6365
tc: TraceContext
@@ -520,6 +522,13 @@ object ScanStore {
520522
Some(Timestamp.assertFromInstant(contract.payload.transfer.executeBefore)),
521523
)
522524
},
525+
mkFilter(splice.externalpartyconfigstate.ExternalPartyConfigState.COMPANION)(co =>
526+
co.payload.dso == dso
527+
) { contract =>
528+
ScanAcsStoreRowData(
529+
contract = contract,
530+
)
531+
}
523532
),
524533
)
525534
}

0 commit comments

Comments
 (0)