Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.lfdecentralizedtrust.splice.integration.tests

import com.digitalasset.daml.lf.data.Ref.PackageVersion
import com.daml.ledger.javaapi.data.CreatedEvent
import com.daml.ledger.javaapi.data.{CreatedEvent, ExercisedEvent}
import com.digitalasset.canton.admin.api.client.data.TemplateId
import com.digitalasset.canton.HasExecutionContext
import com.digitalasset.canton.topology.PartyId
Expand All @@ -11,26 +10,21 @@ import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.{
allocationv1,
metadatav1,
}
import org.lfdecentralizedtrust.splice.environment.DarResources
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.{
IntegrationTestWithIsolatedEnvironment,
SpliceTestConsoleEnvironment,
}
import org.lfdecentralizedtrust.splice.util.{
ChoiceContextWithDisclosures,
JavaDecodeUtil,
TriggerTestUtil,
WalletTestUtil,
}

import scala.jdk.CollectionConverters.*
import scala.util.Random
import com.digitalasset.canton.util.ShowUtil.*
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet.{
AppRewardCoupon,
FeaturedAppActivityMarker,
}
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet.{FeaturedAppActivityMarker}
import org.lfdecentralizedtrust.splice.codegen.java.splice.amuletallocation as amuletallocationCodegen
import org.lfdecentralizedtrust.splice.console.WalletAppClientReference
import org.lfdecentralizedtrust.splice.integration.tests.TokenStandardTest.CreateAllocationRequestResult
Expand Down Expand Up @@ -181,30 +175,14 @@ class TokenStandardAllocationIntegrationTest
}
}
val events = tree.getEventsById().asScala.values
forExactly(1, events) {
inside(_) { case c: CreatedEvent =>
if (
PackageVersion.assertFromString(
sv1ScanBackend
.getAmuletRules()
.payload
.configSchedule
.initialValue
.packageConfig
.amulet
) >= DarResources.amulet_0_1_17.metadata.version
) {
val decoded = JavaDecodeUtil
.decodeCreated(FeaturedAppActivityMarker.COMPANION)(c)
.value
decoded.data.provider shouldBe allocatedOtcTrade.venueParty.toProtoPrimitive
} else {
val decoded = JavaDecodeUtil
.decodeCreated(AppRewardCoupon.COMPANION)(c)
.value
decoded.data.featured shouldBe true
decoded.data.provider shouldBe allocatedOtcTrade.venueParty.toProtoPrimitive
}
forAll(events) {
inside(_) {
case c: CreatedEvent =>
Seq(
FeaturedAppActivityMarker.TEMPLATE_ID,
FeaturedAppActivityMarker.TEMPLATE_ID,
) shouldNot contain(c.getTemplateId)
case _: ExercisedEvent => succeed
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package org.lfdecentralizedtrust.splice.scan.admin.http
import cats.data.OptionT
import com.digitalasset.canton.logging.{ErrorLoggingContext, NamedLoggerFactory, NamedLogging}
import com.digitalasset.canton.time.Clock
import com.digitalasset.canton.topology.PartyId
import com.digitalasset.canton.tracing.{Spanning, TraceContext}
import io.opentelemetry.api.trace.Tracer
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet.LockedAmulet
Expand Down Expand Up @@ -61,7 +60,6 @@ class HttpTokenStandardAllocationHandler(
](
allocationId,
requireLockedAmulet = true,
canBeFeatured = true,
synchronizerId =>
new V1ChoiceContextBuilder(synchronizerId, body.excludeDebugFields.getOrElse(false)),
)
Expand All @@ -84,7 +82,6 @@ class HttpTokenStandardAllocationHandler(
](
allocationId,
requireLockedAmulet = false,
canBeFeatured = false,
synchronizerId =>
new V1ChoiceContextBuilder(synchronizerId, body.excludeDebugFields.getOrElse(false)),
)
Expand All @@ -107,7 +104,6 @@ class HttpTokenStandardAllocationHandler(
](
allocationId,
requireLockedAmulet = false,
canBeFeatured = false,
synchronizerId =>
new V1ChoiceContextBuilder(synchronizerId, body.excludeDebugFields.getOrElse(false)),
)
Expand Down Expand Up @@ -243,7 +239,6 @@ class HttpTokenStandardAllocationHandler(
](
allocationId: String,
requireLockedAmulet: Boolean,
canBeFeatured: Boolean,
newBuilder: String => Builder,
)(implicit
tc: TraceContext
Expand Down Expand Up @@ -271,9 +266,6 @@ class HttpTokenStandardAllocationHandler(
Some(amuletAlloc.payload.lockedAmulet),
Some(amuletAlloc.payload.allocation.settlement.settleBefore),
requireLockedAmulet,
Option.when(canBeFeatured)(
PartyId.tryFromProtoPrimitive(amuletAlloc.payload.allocation.settlement.executor)
),
store,
contractFetcher,
clock,
Expand Down Expand Up @@ -334,8 +326,6 @@ class HttpTokenStandardAllocationHandler(
lockedAmulet,
expiry.toScala,
requireLockedAmulet,
featuredProvider =
None, // Not required. Featured app rights are used in bulk, and will go once CIP-104 is live
store,
contractFetcher,
clock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.digitalasset.canton.topology.PartyId
import com.digitalasset.canton.tracing.{Spanning, TraceContext}
import io.opentelemetry.api.trace.Tracer
import org.lfdecentralizedtrust.splice.codegen.java.splice
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet.FeaturedAppRight
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.{
metadatav1,
transferinstructionv1,
Expand Down Expand Up @@ -79,7 +78,7 @@ class HttpTokenStandardTransferInstructionHandler(
PartyId.tryFromProtoPrimitive(transferInstr.transfer.sender),
PartyId.tryFromProtoPrimitive(transferInstr.transfer.receiver),
body.excludeDebugFields.getOrElse(false),
)((optTransferPreapproval, optFeaturedAppRight, externalPartyAmuletRules) => {
)((optTransferPreapproval, externalPartyAmuletRules) => {
val isSelfTransfer = transferInstr.transfer.receiver == transferInstr.transfer.sender
val kind =
if (isSelfTransfer) v1.definitions.TransferFactoryWithChoiceContext.TransferKind.Self
Expand All @@ -92,8 +91,7 @@ class HttpTokenStandardTransferInstructionHandler(
kind,
choiceContext = choiceContextBuilder
.addOptionalContracts(
"featured-app-right" -> optFeaturedAppRight,
"transfer-preapproval" -> optTransferPreapproval,
"transfer-preapproval" -> optTransferPreapproval
)
.disclose(externalPartyAmuletRules.contract)
.build(),
Expand Down Expand Up @@ -191,7 +189,7 @@ class HttpTokenStandardTransferInstructionHandler(
TokenStandardAccount.tryGetRegularAccountOwner(transferInstr.transfer.receiver)
),
body.excludeDebugFields.getOrElse(false),
)((optTransferPreapproval, optFeaturedAppRight, externalPartyAmuletRules) => {
)((optTransferPreapproval, externalPartyAmuletRules) => {
val isSelfTransfer = transferInstr.transfer.receiver == transferInstr.transfer.sender
val kind =
if (isSelfTransfer) v2.definitions.TransferFactoryWithChoiceContext.TransferKind.Self
Expand All @@ -204,8 +202,7 @@ class HttpTokenStandardTransferInstructionHandler(
kind,
choiceContext = choiceContextBuilder
.addOptionalContracts(
"featured-app-right" -> optFeaturedAppRight,
"transfer-preapproval" -> optTransferPreapproval,
"transfer-preapproval" -> optTransferPreapproval
)
.disclose(externalPartyAmuletRules.contract)
.build(),
Expand Down Expand Up @@ -282,7 +279,6 @@ class HttpTokenStandardTransferInstructionHandler(
splice.amuletrules.TransferPreapproval.ContractId,
splice.amuletrules.TransferPreapproval,
]],
Option[ContractWithState[FeaturedAppRight.ContractId, FeaturedAppRight]],
ContractWithState[
splice.externalpartyamuletrules.ExternalPartyAmuletRules.ContractId,
splice.externalpartyamuletrules.ExternalPartyAmuletRules,
Expand All @@ -294,22 +290,14 @@ class HttpTokenStandardTransferInstructionHandler(
for {
choiceContextBuilder <- getAmuletRulesTransferContextV1(excludeDebugFields)
externalPartyAmuletRules <- store.getExternalPartyAmuletRules()
// pre-approval and featured app rights are only provided if they exist and are required
// pre-approval is only provided if they exist and are required
isSelfTransfer = receiver == sender
optTransferPreapproval <-
if (isSelfTransfer) Future.successful(None) // no pre-approval required for self-transfers
else
store.lookupTransferPreapprovalByParty(receiver)
optFeaturedAppRight <- optTransferPreapproval match {
case None => Future.successful(None)
case Some(preapproval) =>
store.lookupFeaturedAppRight(
PartyId.tryFromProtoPrimitive(preapproval.payload.provider)
)
}
} yield build(
optTransferPreapproval,
optFeaturedAppRight,
externalPartyAmuletRules,
)

Expand Down Expand Up @@ -403,7 +391,6 @@ class HttpTokenStandardTransferInstructionHandler(
Some(amuletInstr.payload.lockedAmulet),
Some(amuletInstr.payload.transfer.executeBefore),
requireLockedAmulet,
None,
store,
contractFetcher,
clock,
Expand All @@ -430,7 +417,6 @@ class HttpTokenStandardTransferInstructionHandler(
Some(amuletInstr.payload.lockedAmulet),
Some(amuletInstr.payload.transfer.executeBefore),
requireLockedAmulet,
None,
store,
contractFetcher,
clock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package org.lfdecentralizedtrust.splice.scan.util

import com.digitalasset.canton.data.CantonTimestamp
import com.digitalasset.canton.time.Clock
import com.digitalasset.canton.topology.PartyId
import com.digitalasset.canton.tracing.TraceContext
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet
import org.lfdecentralizedtrust.splice.codegen.java.splice.api.token.metadatav1
Expand Down Expand Up @@ -155,7 +154,6 @@ object ChoiceContextBuilder {
lockedAmuletIdOpt: Option[amulet.LockedAmulet.ContractId],
expiryOpt: Option[Instant],
requireLockedAmulet: Boolean,
featuredProvider: Option[PartyId],
store: ScanStore,
fetcher: ChoiceContextContractFetcher,
clock: Clock,
Expand All @@ -175,15 +173,6 @@ object ChoiceContextBuilder {
ChoiceContext,
Builder,
](store, clock, newBuilder)
featuredAppRightO <- featuredProvider.fold(
Future.successful[Option[
ContractWithState[amulet.FeaturedAppRight.ContractId, amulet.FeaturedAppRight]
]](None)
)(provider =>
store.lookupFeaturedAppRight(
provider
)
)
} yield {
if (optLockedAmulet.isEmpty) {
// the locked amulet did expire and was unlocked
Expand All @@ -205,7 +194,6 @@ object ChoiceContextBuilder {
choiceContextBuilder
// the choice implementation should only attempt to expire the lock if it exists
.addBool(TokenStandardMetadata.expireLockKey, optLockedAmulet.isDefined)
.addOptionalContract("featured-app-right", featuredAppRightO.map(_.contract))
.build()
}
}
Expand Down
Loading