mirror of
https://github.com/corda/corda.git
synced 2024-12-30 01:39:04 +00:00
CORDA-2403: Flagged API issues between 4.0 and 3.3. (#4541)
This commit is contained in:
parent
22388d812c
commit
31d799f636
@ -1057,7 +1057,7 @@ public interface net.corda.core.cordapp.Cordapp
|
||||
public abstract java.util.List<Class<? extends net.corda.core.serialization.SerializeAsToken>> getServices()
|
||||
##
|
||||
public final class net.corda.core.cordapp.CordappContext extends java.lang.Object
|
||||
public <init>(net.corda.core.cordapp.Cordapp, net.corda.core.crypto.SecureHash, ClassLoader, net.corda.core.cordapp.CordappConfig)
|
||||
public <init>(net.corda.core.cordapp.Cordapp, net.corda.core.crypto.SecureHash, ClassLoader)
|
||||
@Nullable
|
||||
public final net.corda.core.crypto.SecureHash getAttachmentId()
|
||||
@NotNull
|
||||
@ -3463,10 +3463,6 @@ public static final class net.corda.core.node.services.vault.AttachmentQueryCrit
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>)
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<String>)
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<java.time.Instant>)
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<java.time.Instant>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<String>>)
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<java.time.Instant>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<String>>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<java.security.PublicKey>>)
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<java.time.Instant>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<String>>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<java.security.PublicKey>>, net.corda.core.node.services.vault.ColumnPredicate<Boolean>)
|
||||
public <init>(net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<String>, net.corda.core.node.services.vault.ColumnPredicate<java.time.Instant>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<String>>, net.corda.core.node.services.vault.ColumnPredicate<java.util.List<java.security.PublicKey>>, net.corda.core.node.services.vault.ColumnPredicate<Boolean>, net.corda.core.node.services.vault.ColumnPredicate<Integer>)
|
||||
@Nullable
|
||||
public final net.corda.core.node.services.vault.ColumnPredicate<String> component1()
|
||||
@Nullable
|
||||
|
@ -1,12 +1,13 @@
|
||||
package net.corda.core.contracts
|
||||
|
||||
import net.corda.core.CordaInternal
|
||||
import net.corda.core.KeepForDJVM
|
||||
import net.corda.core.internal.cordapp.CordappImpl.Companion.DEFAULT_CORDAPP_VERSION
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import java.security.PublicKey
|
||||
|
||||
/**
|
||||
* Wrap an attachment in this if it is to be used as an executable contract attachment
|
||||
* An [Attachment] which represents a contract JAR.
|
||||
*
|
||||
* @property attachment The attachment representing the contract JAR
|
||||
* @property contract The contract name contained within the JAR. A Contract attachment has to contain at least 1 contract.
|
||||
@ -14,13 +15,31 @@ import java.security.PublicKey
|
||||
*/
|
||||
@KeepForDJVM
|
||||
@CordaSerializable
|
||||
class ContractAttachment @JvmOverloads constructor(
|
||||
class ContractAttachment private constructor(
|
||||
val attachment: Attachment,
|
||||
val contract: ContractClassName,
|
||||
val additionalContracts: Set<ContractClassName> = emptySet(),
|
||||
val uploader: String? = null,
|
||||
override val signerKeys: List<PublicKey> = emptyList(),
|
||||
val version: Int = DEFAULT_CORDAPP_VERSION) : Attachment by attachment {
|
||||
val additionalContracts: Set<ContractClassName>,
|
||||
val uploader: String?,
|
||||
override val signerKeys: List<PublicKey>,
|
||||
val version: Int
|
||||
) : Attachment by attachment {
|
||||
@JvmOverloads
|
||||
constructor(attachment: Attachment,
|
||||
contract: ContractClassName,
|
||||
additionalContracts: Set<ContractClassName> = emptySet(),
|
||||
uploader: String? = null) : this(attachment, contract, additionalContracts, uploader, emptyList(), DEFAULT_CORDAPP_VERSION)
|
||||
|
||||
companion object {
|
||||
@CordaInternal
|
||||
fun create(attachment: Attachment,
|
||||
contract: ContractClassName,
|
||||
additionalContracts: Set<ContractClassName> = emptySet(),
|
||||
uploader: String? = null,
|
||||
signerKeys: List<PublicKey> = emptyList(),
|
||||
version: Int = DEFAULT_CORDAPP_VERSION): ContractAttachment {
|
||||
return ContractAttachment(attachment, contract, additionalContracts, uploader, signerKeys, version)
|
||||
}
|
||||
}
|
||||
|
||||
val allContracts: Set<ContractClassName> get() = additionalContracts + contract
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.corda.core.cordapp
|
||||
|
||||
import net.corda.core.CordaInternal
|
||||
import net.corda.core.DeleteForDJVM
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import java.lang.UnsupportedOperationException
|
||||
|
||||
/**
|
||||
* An app context provides information about where an app was loaded from, access to its classloader,
|
||||
@ -17,9 +19,45 @@ import net.corda.core.crypto.SecureHash
|
||||
* @property config Configuration for this CorDapp
|
||||
*/
|
||||
@DeleteForDJVM
|
||||
class CordappContext internal constructor(
|
||||
class CordappContext private constructor(
|
||||
val cordapp: Cordapp,
|
||||
val attachmentId: SecureHash?,
|
||||
val classLoader: ClassLoader,
|
||||
val config: CordappConfig
|
||||
)
|
||||
) {
|
||||
companion object {
|
||||
@CordaInternal
|
||||
fun create(cordapp: Cordapp, attachmentId: SecureHash?, classLoader: ClassLoader, config: CordappConfig): CordappContext {
|
||||
return CordappContext(cordapp, attachmentId, classLoader, config)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("CordappContexts should not be created. Instead retrieve them using `CordappProvider.getAppContext()`.")
|
||||
constructor(
|
||||
cordapp: Cordapp,
|
||||
attachmentId: SecureHash?,
|
||||
classLoader: ClassLoader
|
||||
) : this(cordapp, attachmentId, classLoader, EmptyCordappConfig)
|
||||
|
||||
private object EmptyCordappConfig : CordappConfig {
|
||||
override fun exists(path: String): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun get(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getInt(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getLong(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getFloat(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getDouble(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getNumber(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getString(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
|
||||
override fun getBoolean(path: String) = throw CordappConfigException("Cordapp configuration is incorrect", UnsupportedOperationException())
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,6 @@ package net.corda.core.internal
|
||||
import net.corda.core.DeleteForDJVM
|
||||
import net.corda.core.contracts.ContractAttachment
|
||||
import net.corda.core.contracts.ContractClassName
|
||||
import net.corda.core.cordapp.Cordapp
|
||||
import net.corda.core.cordapp.CordappConfig
|
||||
import net.corda.core.cordapp.CordappContext
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.flows.DataVendingFlow
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.node.NetworkParameters
|
||||
@ -19,16 +15,12 @@ import net.corda.core.node.services.vault.Builder
|
||||
import net.corda.core.node.services.vault.Sort
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.SerializationContext
|
||||
import net.corda.core.serialization.internal.AttachmentsClassLoaderBuilder
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.transactions.WireTransaction
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.slf4j.MDC
|
||||
import java.security.PublicKey
|
||||
import java.util.jar.JarEntry
|
||||
import java.util.jar.JarInputStream
|
||||
|
||||
// *Internal* Corda-specific utilities.
|
||||
@ -61,10 +53,6 @@ fun TransactionBuilder.toLedgerTransaction(services: ServicesForResolution, seri
|
||||
return toLedgerTransactionWithContext(services, serializationContext)
|
||||
}
|
||||
|
||||
fun createCordappContext(cordapp: Cordapp, attachmentId: SecureHash?, classLoader: ClassLoader, config: CordappConfig): CordappContext {
|
||||
return CordappContext(cordapp, attachmentId, classLoader, config)
|
||||
}
|
||||
|
||||
/** Checks if this flow is an idempotent flow. */
|
||||
fun Class<out FlowLogic<*>>.isIdempotentFlow(): Boolean {
|
||||
return IdempotentFlow::class.java.isAssignableFrom(this)
|
||||
|
@ -162,28 +162,39 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
/**
|
||||
* LinearStateQueryCriteria: provides query by attributes defined in [VaultSchema.VaultLinearState]
|
||||
*/
|
||||
data class LinearStateQueryCriteria @JvmOverloads constructor(
|
||||
override val participants: List<AbstractParty>? = null,
|
||||
data class LinearStateQueryCriteria(
|
||||
override val participants: List<AbstractParty>?,
|
||||
val uuid: List<UUID>? = null,
|
||||
val externalId: List<String>? = null,
|
||||
override val status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
override val contractStateTypes: Set<Class<out ContractState>>? = null,
|
||||
override val relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
|
||||
) : CommonQueryCriteria() {
|
||||
// V3 c'tor
|
||||
@JvmOverloads
|
||||
constructor(
|
||||
participants: List<AbstractParty>? = null,
|
||||
linearId: List<UniqueIdentifier>? = null,
|
||||
uuid: List<UUID>? = null,
|
||||
externalId: List<String>? = null,
|
||||
status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null,
|
||||
relevancyStatus: Vault.RelevancyStatus
|
||||
) : this(participants, linearId?.map { it.id }, linearId?.mapNotNull { it.externalId }, status, contractStateTypes, relevancyStatus)
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null
|
||||
) : this(participants, uuid, externalId, status, contractStateTypes, Vault.RelevancyStatus.ALL)
|
||||
|
||||
constructor(
|
||||
participants: List<AbstractParty>? = null,
|
||||
linearId: List<UniqueIdentifier>? = null,
|
||||
status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null,
|
||||
relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
|
||||
) : this(participants, linearId?.map { it.id }, linearId?.mapNotNull { it.externalId }, status, contractStateTypes, relevancyStatus)
|
||||
|
||||
// V3 c'tor
|
||||
constructor(
|
||||
participants: List<AbstractParty>? = null,
|
||||
linearId: List<UniqueIdentifier>? = null,
|
||||
status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null
|
||||
) : this(participants, linearId?.map { it.id }, linearId?.mapNotNull { it.externalId }, status, contractStateTypes)
|
||||
) : this(participants, linearId, status, contractStateTypes, Vault.RelevancyStatus.ALL)
|
||||
|
||||
override fun visit(parser: IQueryCriteriaParser): Collection<Predicate> {
|
||||
super.visit(parser)
|
||||
@ -202,7 +213,8 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
uuid,
|
||||
externalId,
|
||||
status,
|
||||
contractStateTypes
|
||||
contractStateTypes,
|
||||
relevancyStatus
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -226,7 +238,7 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
/**
|
||||
* FungibleStateQueryCriteria: provides query by attributes defined in [VaultSchema.VaultFungibleStates]
|
||||
*/
|
||||
data class FungibleAssetQueryCriteria @JvmOverloads constructor(
|
||||
data class FungibleAssetQueryCriteria constructor(
|
||||
override val participants: List<AbstractParty>? = null,
|
||||
val owner: List<AbstractParty>? = null,
|
||||
val quantity: ColumnPredicate<Long>? = null,
|
||||
@ -234,8 +246,18 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
val issuerRef: List<OpaqueBytes>? = null,
|
||||
override val status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
override val contractStateTypes: Set<Class<out ContractState>>? = null,
|
||||
override val relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
|
||||
override val relevancyStatus: Vault.RelevancyStatus
|
||||
) : CommonQueryCriteria() {
|
||||
@JvmOverloads constructor(
|
||||
participants: List<AbstractParty>? = null,
|
||||
owner: List<AbstractParty>? = null,
|
||||
quantity: ColumnPredicate<Long>? = null,
|
||||
issuer: List<AbstractParty>? = null,
|
||||
issuerRef: List<OpaqueBytes>? = null,
|
||||
status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null
|
||||
) : this(participants, owner, quantity, issuer, issuerRef, status, contractStateTypes, Vault.RelevancyStatus.ALL)
|
||||
|
||||
override fun visit(parser: IQueryCriteriaParser): Collection<Predicate> {
|
||||
super.visit(parser)
|
||||
return parser.parseCriteria(this)
|
||||
@ -257,7 +279,8 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
issuer,
|
||||
issuerRef,
|
||||
status,
|
||||
contractStateTypes
|
||||
contractStateTypes,
|
||||
relevancyStatus
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -270,23 +293,17 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
* Params
|
||||
* [expression] refers to a (composable) type safe [CriteriaExpression]
|
||||
*/
|
||||
data class VaultCustomQueryCriteria<L : StatePersistable> @JvmOverloads constructor(
|
||||
data class VaultCustomQueryCriteria<L : StatePersistable> constructor(
|
||||
val expression: CriteriaExpression<L, Boolean>,
|
||||
override val status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
override val contractStateTypes: Set<Class<out ContractState>>? = null
|
||||
override val contractStateTypes: Set<Class<out ContractState>>? = null,
|
||||
override val relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
|
||||
) : CommonQueryCriteria() {
|
||||
// These extra field is handled this way to preserve Kotlin wire compatibility wrt additional parameters with default values.
|
||||
constructor(
|
||||
@JvmOverloads constructor(
|
||||
expression: CriteriaExpression<L, Boolean>,
|
||||
status: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null,
|
||||
relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
|
||||
) : this(expression, status, contractStateTypes) {
|
||||
this.relevancyStatus = relevancyStatus
|
||||
}
|
||||
|
||||
override var relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL
|
||||
private set
|
||||
contractStateTypes: Set<Class<out ContractState>>? = null
|
||||
) : this(expression, status, contractStateTypes, Vault.RelevancyStatus.ALL)
|
||||
|
||||
override fun visit(parser: IQueryCriteriaParser): Collection<Predicate> {
|
||||
super.visit(parser)
|
||||
@ -296,8 +313,7 @@ sealed class QueryCriteria : GenericQueryCriteria<QueryCriteria, IQueryCriteriaP
|
||||
fun copy(
|
||||
expression: CriteriaExpression<L, Boolean> = this.expression,
|
||||
status: Vault.StateStatus = this.status,
|
||||
contractStateTypes: Set<Class<out ContractState>>? = this.contractStateTypes,
|
||||
relevancyStatus: Vault.RelevancyStatus = this.relevancyStatus
|
||||
contractStateTypes: Set<Class<out ContractState>>? = this.contractStateTypes
|
||||
): VaultCustomQueryCriteria<L> {
|
||||
return VaultCustomQueryCriteria(
|
||||
expression,
|
||||
@ -326,13 +342,20 @@ sealed class AttachmentQueryCriteria : GenericQueryCriteria<AttachmentQueryCrite
|
||||
/**
|
||||
* AttachmentsQueryCriteria:
|
||||
*/
|
||||
data class AttachmentsQueryCriteria @JvmOverloads constructor(val uploaderCondition: ColumnPredicate<String>? = null,
|
||||
val filenameCondition: ColumnPredicate<String>? = null,
|
||||
val uploadDateCondition: ColumnPredicate<Instant>? = null,
|
||||
val contractClassNamesCondition: ColumnPredicate<List<ContractClassName>>? = null,
|
||||
val signersCondition: ColumnPredicate<List<PublicKey>>? = null,
|
||||
val isSignedCondition: ColumnPredicate<Boolean>? = null,
|
||||
val versionCondition: ColumnPredicate<Int>? = null) : AttachmentQueryCriteria() {
|
||||
data class AttachmentsQueryCriteria(val uploaderCondition: ColumnPredicate<String>? = null,
|
||||
val filenameCondition: ColumnPredicate<String>? = null,
|
||||
val uploadDateCondition: ColumnPredicate<Instant>? = null,
|
||||
val contractClassNamesCondition: ColumnPredicate<List<ContractClassName>>? = null,
|
||||
val signersCondition: ColumnPredicate<List<PublicKey>>? = null,
|
||||
val isSignedCondition: ColumnPredicate<Boolean>? = null,
|
||||
val versionCondition: ColumnPredicate<Int>? = null) : AttachmentQueryCriteria() {
|
||||
// V3 c'tors
|
||||
constructor(uploaderCondition: ColumnPredicate<String>? = null,
|
||||
filenameCondition: ColumnPredicate<String>? = null,
|
||||
uploadDateCondition: ColumnPredicate<Instant>? = null) : this(uploaderCondition, filenameCondition, uploadDateCondition, null)
|
||||
constructor(uploaderCondition: ColumnPredicate<String>?) : this(uploaderCondition, null)
|
||||
constructor(uploaderCondition: ColumnPredicate<String>?, filenameCondition: ColumnPredicate<String>?) : this(uploaderCondition, filenameCondition, null)
|
||||
|
||||
override fun visit(parser: AttachmentsQueryCriteriaParser): Collection<Predicate> {
|
||||
return parser.parseCriteria(this)
|
||||
}
|
||||
@ -342,7 +365,15 @@ sealed class AttachmentQueryCriteria : GenericQueryCriteria<AttachmentQueryCrite
|
||||
filenameCondition: ColumnPredicate<String>? = this.filenameCondition,
|
||||
uploadDateCondition: ColumnPredicate<Instant>? = this.uploadDateCondition
|
||||
): AttachmentsQueryCriteria {
|
||||
return AttachmentsQueryCriteria(uploaderCondition, filenameCondition, uploadDateCondition)
|
||||
return AttachmentsQueryCriteria(
|
||||
uploaderCondition,
|
||||
filenameCondition,
|
||||
uploadDateCondition,
|
||||
contractClassNamesCondition,
|
||||
signersCondition,
|
||||
isSignedCondition,
|
||||
versionCondition
|
||||
)
|
||||
}
|
||||
|
||||
fun withUploader(uploaderPredicate: ColumnPredicate<String>) = copy(uploaderCondition = uploaderPredicate)
|
||||
|
@ -264,7 +264,7 @@ data class ContractUpgradeLedgerTransaction(
|
||||
private fun verifyConstraints() {
|
||||
val attachmentForConstraintVerification = AttachmentWithContext(
|
||||
legacyContractAttachment as? ContractAttachment
|
||||
?: ContractAttachment(legacyContractAttachment, legacyContractClassName, signerKeys = legacyContractAttachment.signerKeys),
|
||||
?: ContractAttachment.create(legacyContractAttachment, legacyContractClassName, signerKeys = legacyContractAttachment.signerKeys),
|
||||
upgradedContract.legacyContract,
|
||||
networkParameters)
|
||||
|
||||
|
@ -40,7 +40,7 @@ import kotlin.collections.component2
|
||||
* [TransactionState] with this notary specified will be generated automatically.
|
||||
*/
|
||||
@DeleteForDJVM
|
||||
open class TransactionBuilder @JvmOverloads constructor(
|
||||
open class TransactionBuilder(
|
||||
var notary: Party? = null,
|
||||
var lockId: UUID = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID(),
|
||||
protected val inputs: MutableList<StateRef> = arrayListOf(),
|
||||
@ -48,39 +48,17 @@ open class TransactionBuilder @JvmOverloads constructor(
|
||||
protected val outputs: MutableList<TransactionState<ContractState>> = arrayListOf(),
|
||||
protected val commands: MutableList<Command<*>> = arrayListOf(),
|
||||
protected var window: TimeWindow? = null,
|
||||
protected var privacySalt: PrivacySalt = PrivacySalt()
|
||||
protected var privacySalt: PrivacySalt = PrivacySalt(),
|
||||
protected val references: MutableList<StateRef> = arrayListOf(),
|
||||
protected val serviceHub: ServiceHub? = (Strand.currentStrand() as? FlowStateMachine<*>)?.serviceHub
|
||||
) {
|
||||
constructor(notary: Party) : this(notary, window = null)
|
||||
|
||||
private companion object {
|
||||
private val log = contextLogger()
|
||||
|
||||
private fun defaultReferencesList(): MutableList<StateRef> = arrayListOf()
|
||||
|
||||
private fun defaultServiceHub(): ServiceHub? = (Strand.currentStrand() as? FlowStateMachine<*>)?.serviceHub
|
||||
|
||||
private const val CORDA_VERSION_THAT_INTRODUCED_FLATTENED_COMMANDS = 4
|
||||
}
|
||||
|
||||
constructor(
|
||||
notary: Party? = null,
|
||||
lockId: UUID = (Strand.currentStrand() as? FlowStateMachine<*>)?.id?.uuid ?: UUID.randomUUID(),
|
||||
inputs: MutableList<StateRef> = arrayListOf(),
|
||||
attachments: MutableList<SecureHash> = arrayListOf(),
|
||||
outputs: MutableList<TransactionState<ContractState>> = arrayListOf(),
|
||||
commands: MutableList<Command<*>> = arrayListOf(),
|
||||
window: TimeWindow? = null,
|
||||
privacySalt: PrivacySalt = PrivacySalt(),
|
||||
references: MutableList<StateRef> = defaultReferencesList(),
|
||||
serviceHub: ServiceHub? = defaultServiceHub()
|
||||
) : this(notary, lockId, inputs, attachments, outputs, commands, window, privacySalt) {
|
||||
this.references = references
|
||||
this.serviceHub = serviceHub
|
||||
}
|
||||
|
||||
protected var references: MutableList<StateRef> = defaultReferencesList()
|
||||
private set
|
||||
protected var serviceHub: ServiceHub? = defaultServiceHub()
|
||||
private set
|
||||
|
||||
private val inputsWithTransactionState = arrayListOf<StateAndRef<ContractState>>()
|
||||
private val referencesWithTransactionState = arrayListOf<TransactionState<ContractState>>()
|
||||
|
||||
@ -196,8 +174,8 @@ open class TransactionBuilder @JvmOverloads constructor(
|
||||
|
||||
addAttachment(attachment.id)
|
||||
return true
|
||||
// Ignore these exceptions as they will break unit tests.
|
||||
// The point here is only to detect missing dependencies. The other exceptions are irrelevant.
|
||||
// Ignore these exceptions as they will break unit tests.
|
||||
// The point here is only to detect missing dependencies. The other exceptions are irrelevant.
|
||||
} catch (tve: TransactionVerificationException) {
|
||||
} catch (tre: TransactionResolutionException) {
|
||||
} catch (ise: IllegalStateException) {
|
||||
|
@ -48,7 +48,7 @@ import java.util.function.Predicate
|
||||
*/
|
||||
@CordaSerializable
|
||||
@KeepForDJVM
|
||||
class WireTransaction(componentGroups: List<ComponentGroup>, val privacySalt: PrivacySalt) : TraversableTransaction(componentGroups) {
|
||||
class WireTransaction(componentGroups: List<ComponentGroup>, val privacySalt: PrivacySalt = PrivacySalt()) : TraversableTransaction(componentGroups) {
|
||||
@DeleteForDJVM
|
||||
constructor(componentGroups: List<ComponentGroup>) : this(componentGroups, PrivacySalt())
|
||||
|
||||
|
@ -164,7 +164,7 @@ class TransactionBuilderTest {
|
||||
override val signerKeys: List<PublicKey> get() = emptyList()
|
||||
}, DummyContract.PROGRAM_ID)
|
||||
|
||||
private fun signedAttachment(vararg parties: Party) = ContractAttachment(object : AbstractAttachment({ byteArrayOf() }) {
|
||||
private fun signedAttachment(vararg parties: Party) = ContractAttachment.create(object : AbstractAttachment({ byteArrayOf() }) {
|
||||
override val id: SecureHash get() = throw UnsupportedOperationException()
|
||||
|
||||
override val signerKeys: List<PublicKey> get() = parties.map { it.owningKey }
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.corda.node.internal.cordapp
|
||||
|
||||
import com.google.common.collect.HashBiMap
|
||||
import net.corda.core.contracts.ContractAttachment
|
||||
import net.corda.core.contracts.ContractClassName
|
||||
import net.corda.core.cordapp.Cordapp
|
||||
import net.corda.core.cordapp.CordappContext
|
||||
@ -9,7 +8,6 @@ import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.internal.DEPLOYED_CORDAPP_UPLOADER
|
||||
import net.corda.core.internal.cordapp.CordappImpl
|
||||
import net.corda.core.internal.createCordappContext
|
||||
import net.corda.core.node.services.AttachmentId
|
||||
import net.corda.core.node.services.AttachmentStorage
|
||||
import net.corda.core.serialization.SingletonSerializeAsToken
|
||||
@ -96,7 +94,7 @@ open class CordappProviderImpl(val cordappLoader: CordappLoader,
|
||||
*/
|
||||
fun getAppContext(cordapp: Cordapp): CordappContext {
|
||||
return contextCache.computeIfAbsent(cordapp) {
|
||||
createCordappContext(
|
||||
CordappContext.create(
|
||||
cordapp,
|
||||
getCordappAttachmentId(cordapp),
|
||||
cordappLoader.appClassLoader,
|
||||
|
@ -235,7 +235,7 @@ object DefaultKryoCustomizer {
|
||||
override val id = attachmentHash
|
||||
}
|
||||
|
||||
return ContractAttachment(lazyAttachment, contract, additionalContracts, uploader, signers, version)
|
||||
return ContractAttachment.create(lazyAttachment, contract, additionalContracts, uploader, signers, version)
|
||||
} else {
|
||||
val attachment = GeneratedAttachment(input.readBytesWithLength())
|
||||
val contract = input.readString()
|
||||
@ -243,7 +243,7 @@ object DefaultKryoCustomizer {
|
||||
val uploader = input.readString()
|
||||
val signers = kryo.readClassAndObject(input) as List<PublicKey>
|
||||
val version = input.readInt()
|
||||
return ContractAttachment(attachment, contract, additionalContracts, uploader, signers, version)
|
||||
return ContractAttachment.create(attachment, contract, additionalContracts, uploader, signers, version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ class NodeAttachmentService(
|
||||
val attachmentImpl = AttachmentImpl(id, { attachment.content }, checkAttachmentsOnLoad).let {
|
||||
val contracts = attachment.contractClassNames
|
||||
if (contracts != null && contracts.isNotEmpty()) {
|
||||
ContractAttachment(it, contracts.first(), contracts.drop(1).toSet(), attachment.uploader, attachment.signers?.toList()
|
||||
ContractAttachment.create(it, contracts.first(), contracts.drop(1).toSet(), attachment.uploader, attachment.signers?.toList()
|
||||
?: emptyList(), attachment.version)
|
||||
} else {
|
||||
it
|
||||
|
@ -28,7 +28,7 @@ class ContractAttachmentSerializer(factory: SerializerFactory) : CustomSerialize
|
||||
}
|
||||
|
||||
override fun fromProxy(proxy: ContractAttachmentProxy): ContractAttachment {
|
||||
return ContractAttachment(proxy.attachment, proxy.contract, proxy.contracts, proxy.uploader, proxy.signers, proxy.version)
|
||||
return ContractAttachment.create(proxy.attachment, proxy.contract, proxy.contracts, proxy.uploader, proxy.signers, proxy.version)
|
||||
}
|
||||
|
||||
@KeepForDJVM
|
||||
|
@ -106,7 +106,7 @@ class MockAttachmentStorage : AttachmentStorage, SingletonSerializeAsToken() {
|
||||
val contractClassMetadata = ContractAttachmentMetadata(contractClassName, version, signers.isNotEmpty())
|
||||
_contractClasses[contractClassMetadata] = sha256
|
||||
}
|
||||
ContractAttachment(baseAttachment, contractClassNames.first(), contractClassNames.toSet(), uploader, signers, version)
|
||||
ContractAttachment.create(baseAttachment, contractClassNames.first(), contractClassNames.toSet(), uploader, signers, version)
|
||||
}
|
||||
_files[sha256] = Pair(attachment, bytes)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user