mirror of
https://github.com/corda/corda.git
synced 2025-02-21 09:51:57 +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.Attachment
|
||||||
import net.corda.core.contracts.ContractAttachment
|
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.DEPLOYED_CORDAPP_UPLOADER
|
||||||
|
import net.corda.core.internal.toLtxDjvmInternal
|
||||||
import net.corda.core.node.NetworkParameters
|
import net.corda.core.node.NetworkParameters
|
||||||
import net.corda.core.serialization.CordaSerializable
|
import net.corda.core.serialization.CordaSerializable
|
||||||
import net.corda.core.serialization.SerializedBytes
|
import net.corda.core.serialization.SerializedBytes
|
||||||
@ -25,13 +25,10 @@ class TransactionVerificationRequest(val wtxToVerify: SerializedBytes<WireTransa
|
|||||||
val attachmentMap = attachments
|
val attachmentMap = attachments
|
||||||
.mapNotNull { it as? MockContractAttachment }
|
.mapNotNull { it as? MockContractAttachment }
|
||||||
.associateBy(Attachment::id) { ContractAttachment(it, it.contract, uploader = DEPLOYED_CORDAPP_UPLOADER) }
|
.associateBy(Attachment::id) { ContractAttachment(it, it.contract, uploader = DEPLOYED_CORDAPP_UPLOADER) }
|
||||||
val contractAttachmentMap = emptyMap<ContractClassName, ContractAttachment>()
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
return wtxToVerify.deserialize().toLedgerTransaction(
|
return wtxToVerify.deserialize().toLtxDjvmInternal(
|
||||||
resolveIdentity = { null },
|
|
||||||
resolveAttachment = { attachmentMap[it] },
|
resolveAttachment = { attachmentMap[it] },
|
||||||
resolveStateRef = { deps[it.txhash]?.outputs?.get(it.index) },
|
resolveStateRef = { deps[it.txhash]?.outputs?.get(it.index) },
|
||||||
resolveContractAttachment = { contractAttachmentMap[it.contract]?.id },
|
|
||||||
resolveParameters = { networkParameters.deserialize() }
|
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")
|
@Deprecated("Use toLedgerTransaction(ServicesForTransaction) instead")
|
||||||
@Throws(AttachmentResolutionException::class, TransactionResolutionException::class)
|
@Throws(AttachmentResolutionException::class, TransactionResolutionException::class)
|
||||||
@JvmOverloads
|
|
||||||
fun toLedgerTransaction(
|
fun toLedgerTransaction(
|
||||||
resolveIdentity: (PublicKey) -> Party?,
|
resolveIdentity: (PublicKey) -> Party?,
|
||||||
resolveAttachment: (SecureHash) -> Attachment?,
|
resolveAttachment: (SecureHash) -> Attachment?,
|
||||||
resolveStateRef: (StateRef) -> TransactionState<*>?,
|
resolveStateRef: (StateRef) -> TransactionState<*>?,
|
||||||
@Suppress("UNUSED_PARAMETER") resolveContractAttachment: (TransactionState<ContractState>) -> AttachmentId?,
|
@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.
|
|
||||||
): LedgerTransaction {
|
): LedgerTransaction {
|
||||||
// This reverts to serializing the resolved transaction state.
|
// 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
|
// 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(
|
private fun toLedgerTransactionInternal(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user