Add netting support structures

Add NetType enum for use in contracts which deal with netting
Add BilateralNettingState interface
Add support for more complex issued things
This commit is contained in:
Ross Nicoll
2016-06-21 11:47:37 +01:00
parent 7ee6bd05ce
commit d24ec06b40
6 changed files with 50 additions and 9 deletions

View File

@ -62,6 +62,9 @@ class Cash : FungibleAsset<Currency>() {
override val participants: List<PublicKey>
get() = listOf(owner)
override fun move(amount: Amount<Issued<Currency>>, owner: PublicKey): FungibleAsset.State<Currency>
= copy(amount = amount, owner = owner)
override fun toString() = "${Emoji.bagOfCash}Cash($amount at $deposit owned by ${owner.toStringShort()})"
override fun withNewOwner(newOwner: PublicKey) = Pair(Commands.Move(), copy(owner = newOwner))

View File

@ -31,9 +31,9 @@ class InsufficientBalanceException(val amountMissing: Amount<Currency>) : Except
*/
abstract class FungibleAsset<T> : Contract {
/** A state representing a cash claim against some party */
interface State<T> : FungibleAssetState<T> {
interface State<T> : FungibleAssetState<T, Issued<T>> {
/** Where the underlying currency backing this ledger entry can be found (propagated) */
override val deposit: PartyAndReference
val deposit: PartyAndReference
override val amount: Amount<Issued<T>>
/** There must be a MoveCommand signed by this key to claim the amount */
override val owner: PublicKey

View File

@ -1,16 +1,15 @@
package com.r3corda.contracts.cash
import com.r3corda.core.contracts.Amount
import com.r3corda.core.contracts.OwnableState
import com.r3corda.core.contracts.PartyAndReference
import com.r3corda.core.contracts.Issued
import com.r3corda.core.contracts.OwnableState
import java.security.PublicKey
/**
* Common elements of cash contract states.
*/
interface FungibleAssetState<T> : OwnableState {
val issuanceDef: Issued<T>
/** Where the underlying currency backing this ledger entry can be found (propagated) */
val deposit: PartyAndReference
interface FungibleAssetState<T, I> : OwnableState {
val issuanceDef: I
val amount: Amount<Issued<T>>
fun move(amount: Amount<Issued<T>>, owner: PublicKey): FungibleAssetState<T, I>
}