mirror of
https://github.com/corda/corda.git
synced 2025-06-19 23:53:52 +00:00
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:
@ -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))
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
}
|
Reference in New Issue
Block a user