mirror of
https://github.com/corda/corda.git
synced 2025-02-20 01:16:42 +00:00
CORDA-1942: Removed new deprecated overload of toLedgerTransaction (#4492)
This commit is contained in:
parent
8355c286cf
commit
ad1a96fefb
@ -2,8 +2,8 @@ package net.corda.deterministic.verifier
|
||||
|
||||
import net.corda.core.contracts.Attachment
|
||||
import net.corda.core.contracts.ContractAttachment
|
||||
import net.corda.core.contracts.ContractClassName
|
||||
import net.corda.core.internal.DEPLOYED_CORDAPP_UPLOADER
|
||||
import net.corda.core.internal.toLtxDjvmInternal
|
||||
import net.corda.core.node.NetworkParameters
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.SerializedBytes
|
||||
@ -25,13 +25,10 @@ class TransactionVerificationRequest(val wtxToVerify: SerializedBytes<WireTransa
|
||||
val attachmentMap = attachments
|
||||
.mapNotNull { it as? MockContractAttachment }
|
||||
.associateBy(Attachment::id) { ContractAttachment(it, it.contract, uploader = DEPLOYED_CORDAPP_UPLOADER) }
|
||||
val contractAttachmentMap = emptyMap<ContractClassName, ContractAttachment>()
|
||||
@Suppress("DEPRECATION")
|
||||
return wtxToVerify.deserialize().toLedgerTransaction(
|
||||
resolveIdentity = { null },
|
||||
return wtxToVerify.deserialize().toLtxDjvmInternal(
|
||||
resolveAttachment = { attachmentMap[it] },
|
||||
resolveStateRef = { deps[it.txhash]?.outputs?.get(it.index) },
|
||||
resolveContractAttachment = { contractAttachmentMap[it.contract]?.id },
|
||||
resolveParameters = { networkParameters.deserialize() }
|
||||
)
|
||||
}
|
||||
|
20
core/src/main/kotlin/net/corda/core/internal/DjvmUtils.kt
Normal file
20
core/src/main/kotlin/net/corda/core/internal/DjvmUtils.kt
Normal file
@ -0,0 +1,20 @@
|
||||
@file:KeepForDJVM
|
||||
|
||||
package net.corda.core.internal
|
||||
|
||||
import net.corda.core.KeepForDJVM
|
||||
import net.corda.core.contracts.Attachment
|
||||
import net.corda.core.contracts.StateRef
|
||||
import net.corda.core.contracts.TransactionState
|
||||
import net.corda.core.crypto.SecureHash
|
||||
import net.corda.core.node.NetworkParameters
|
||||
import net.corda.core.transactions.LedgerTransaction
|
||||
import net.corda.core.transactions.WireTransaction
|
||||
|
||||
fun WireTransaction.toLtxDjvmInternal(
|
||||
resolveAttachment: (SecureHash) -> Attachment?,
|
||||
resolveStateRef: (StateRef) -> TransactionState<*>?,
|
||||
resolveParameters: (SecureHash?) -> NetworkParameters?
|
||||
): LedgerTransaction {
|
||||
return toLtxDjvmInternalBridge(resolveAttachment, resolveStateRef, resolveParameters)
|
||||
}
|
@ -130,18 +130,37 @@ class WireTransaction(componentGroups: List<ComponentGroup>, val privacySalt: Pr
|
||||
*/
|
||||
@Deprecated("Use toLedgerTransaction(ServicesForTransaction) instead")
|
||||
@Throws(AttachmentResolutionException::class, TransactionResolutionException::class)
|
||||
@JvmOverloads
|
||||
fun toLedgerTransaction(
|
||||
resolveIdentity: (PublicKey) -> Party?,
|
||||
resolveAttachment: (SecureHash) -> Attachment?,
|
||||
resolveStateRef: (StateRef) -> TransactionState<*>?,
|
||||
@Suppress("UNUSED_PARAMETER") resolveContractAttachment: (TransactionState<ContractState>) -> AttachmentId?,
|
||||
resolveParameters: (SecureHash?) -> NetworkParameters? = { null } // TODO This { null } is left here only because of API stability. It doesn't make much sense anymore as it will fail on transaction verification.
|
||||
@Suppress("UNUSED_PARAMETER") resolveContractAttachment: (TransactionState<ContractState>) -> AttachmentId?
|
||||
): LedgerTransaction {
|
||||
// This reverts to serializing the resolved transaction state.
|
||||
return toLedgerTransactionInternal(resolveIdentity, resolveAttachment, { stateRef -> resolveStateRef(stateRef)?.serialize() }, resolveParameters,
|
||||
return toLedgerTransactionInternal(
|
||||
resolveIdentity,
|
||||
resolveAttachment,
|
||||
{ stateRef -> resolveStateRef(stateRef)?.serialize() },
|
||||
{ null },
|
||||
// Returning a dummy `missingAttachment` Attachment allows this deprecated method to work and it disables "contract version no downgrade rule" as a dummy Attachment returns version 1
|
||||
{ it -> resolveAttachment(it.txhash) ?: missingAttachment })
|
||||
{ it -> resolveAttachment(it.txhash) ?: missingAttachment }
|
||||
)
|
||||
}
|
||||
|
||||
// Especially crafted for TransactionVerificationRequest
|
||||
@CordaInternal
|
||||
internal fun toLtxDjvmInternalBridge(
|
||||
resolveAttachment: (SecureHash) -> Attachment?,
|
||||
resolveStateRef: (StateRef) -> TransactionState<*>?,
|
||||
resolveParameters: (SecureHash?) -> NetworkParameters?
|
||||
): LedgerTransaction {
|
||||
return toLedgerTransactionInternal(
|
||||
{ null },
|
||||
resolveAttachment,
|
||||
{ stateRef -> resolveStateRef(stateRef)?.serialize() },
|
||||
resolveParameters,
|
||||
{ it -> resolveAttachment(it.txhash) ?: missingAttachment }
|
||||
)
|
||||
}
|
||||
|
||||
private fun toLedgerTransactionInternal(
|
||||
|
Loading…
x
Reference in New Issue
Block a user