CORDA-1942: Removed new deprecated overload of toLedgerTransaction (#4492)

This commit is contained in:
Shams Asari
2019-01-03 17:45:26 +00:00
committed by GitHub
parent 8355c286cf
commit ad1a96fefb
3 changed files with 46 additions and 10 deletions

View 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)
}

View File

@ -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(