mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Minor: remove ambiguous c'tor in PartialTransaction and rename addItems -> withItems
This commit is contained in:
parent
ab9e026053
commit
4cec5dac02
@ -119,7 +119,7 @@ class CommercialPaper : Contract {
|
||||
*/
|
||||
fun craftIssue(issuance: PartyReference, faceValue: Amount, maturityDate: Instant): PartialTransaction {
|
||||
val state = State(issuance, issuance.party.owningKey, faceValue, maturityDate)
|
||||
return PartialTransaction(state, WireCommand(Commands.Issue(), issuance.party.owningKey))
|
||||
return PartialTransaction().withItems(state, WireCommand(Commands.Issue(), issuance.party.owningKey))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +146,7 @@ class CrowdFund : Contract {
|
||||
fun craftRegister(owner: PartyReference, fundingTarget: Amount, fundingName: String, closingTime: Instant): PartialTransaction {
|
||||
val campaign = Campaign(owner = owner.party.owningKey, name = fundingName, target = fundingTarget, closingTime = closingTime)
|
||||
val state = State(campaign)
|
||||
return PartialTransaction(state, WireCommand(Commands.Register(), owner.party.owningKey))
|
||||
return PartialTransaction().withItems(state, WireCommand(Commands.Register(), owner.party.owningKey))
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,14 +68,8 @@ data class WireTransaction(val inputStates: List<ContractStateRef>,
|
||||
class PartialTransaction(private val inputStates: MutableList<ContractStateRef> = arrayListOf(),
|
||||
private val outputStates: MutableList<ContractState> = arrayListOf(),
|
||||
private val commands: MutableList<WireCommand> = arrayListOf()) {
|
||||
|
||||
/** A more convenient way to add items to this transaction that calls the add* methods for you based on type */
|
||||
constructor(vararg items: Any) : this() {
|
||||
addItems(*items)
|
||||
}
|
||||
|
||||
/** A more convenient way to add items to this transaction that calls the add* methods for you based on type */
|
||||
public fun addItems(vararg items: Any) {
|
||||
public fun withItems(vararg items: Any): PartialTransaction {
|
||||
for (t in items) {
|
||||
when (t) {
|
||||
is ContractStateRef -> inputStates.add(t)
|
||||
@ -84,6 +78,7 @@ class PartialTransaction(private val inputStates: MutableList<ContractStateRef>
|
||||
else -> throw IllegalArgumentException("Wrong argument type: ${t.javaClass}")
|
||||
}
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
/** The signatures that have been collected so far - might be incomplete! */
|
||||
|
@ -30,7 +30,7 @@ class TransactionSerializationTests {
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
tx = PartialTransaction(
|
||||
tx = PartialTransaction().withItems(
|
||||
fakeStateRef, outputState, changeState, WireCommand(Cash.Commands.Move(), arrayListOf(TestUtils.keypair.public))
|
||||
)
|
||||
}
|
||||
@ -76,7 +76,7 @@ class TransactionSerializationTests {
|
||||
|
||||
// If the signature was replaced in transit, we don't like it.
|
||||
assertFailsWith(SignatureException::class) {
|
||||
val tx2 = PartialTransaction(fakeStateRef, outputState, changeState,
|
||||
val tx2 = PartialTransaction().withItems(fakeStateRef, outputState, changeState,
|
||||
WireCommand(Cash.Commands.Move(), arrayListOf(TestUtils.keypair2.public)))
|
||||
tx2.signWith(TestUtils.keypair2)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user