mirror of
https://github.com/corda/corda.git
synced 2025-05-04 17:53:05 +00:00
Reformat files in finance
This commit is contained in:
parent
b1fb321230
commit
7a372bed59
@ -8,12 +8,18 @@ import net.corda.core.contracts.PartyAndReference
|
|||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@JvmField val USD: Currency = Currency.getInstance("USD")
|
@JvmField
|
||||||
@JvmField val GBP: Currency = Currency.getInstance("GBP")
|
val USD: Currency = Currency.getInstance("USD")
|
||||||
@JvmField val EUR: Currency = Currency.getInstance("EUR")
|
@JvmField
|
||||||
@JvmField val CHF: Currency = Currency.getInstance("CHF")
|
val GBP: Currency = Currency.getInstance("GBP")
|
||||||
@JvmField val JPY: Currency = Currency.getInstance("JPY")
|
@JvmField
|
||||||
@JvmField val RUB: Currency = Currency.getInstance("RUB")
|
val EUR: Currency = Currency.getInstance("EUR")
|
||||||
|
@JvmField
|
||||||
|
val CHF: Currency = Currency.getInstance("CHF")
|
||||||
|
@JvmField
|
||||||
|
val JPY: Currency = Currency.getInstance("JPY")
|
||||||
|
@JvmField
|
||||||
|
val RUB: Currency = Currency.getInstance("RUB")
|
||||||
|
|
||||||
fun <T : Any> AMOUNT(amount: Int, token: T): Amount<T> = AMOUNT(amount.toLong(), token)
|
fun <T : Any> AMOUNT(amount: Int, token: T): Amount<T> = AMOUNT(amount.toLong(), token)
|
||||||
fun <T : Any> AMOUNT(amount: Long, token: T): Amount<T> = Amount.fromDecimal(BigDecimal.valueOf(amount), token)
|
fun <T : Any> AMOUNT(amount: Long, token: T): Amount<T> = Amount.fromDecimal(BigDecimal.valueOf(amount), token)
|
||||||
|
@ -49,6 +49,7 @@ class CommercialPaper : Contract {
|
|||||||
companion object {
|
companion object {
|
||||||
const val CP_PROGRAM_ID: ContractClassName = "net.corda.finance.contracts.CommercialPaper"
|
const val CP_PROGRAM_ID: ContractClassName = "net.corda.finance.contracts.CommercialPaper"
|
||||||
}
|
}
|
||||||
|
|
||||||
data class State(
|
data class State(
|
||||||
val issuance: PartyAndReference,
|
val issuance: PartyAndReference,
|
||||||
override val owner: AbstractParty,
|
override val owner: AbstractParty,
|
||||||
@ -89,7 +90,8 @@ class CommercialPaper : Contract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @suppress */ infix fun `owned by`(owner: AbstractParty) = copy(owner = owner)
|
/** @suppress */
|
||||||
|
infix fun `owned by`(owner: AbstractParty) = copy(owner = owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Commands : CommandData {
|
interface Commands : CommandData {
|
||||||
|
@ -401,10 +401,17 @@ class Cash : OnLedgerAsset<Currency, Cash.Commands, Cash.State>() {
|
|||||||
|
|
||||||
// Small DSL extensions.
|
// Small DSL extensions.
|
||||||
|
|
||||||
/** @suppress */ infix fun Cash.State.`owned by`(owner: AbstractParty) = ownedBy(owner)
|
/** @suppress */
|
||||||
/** @suppress */ infix fun Cash.State.`issued by`(party: AbstractParty) = issuedBy(party)
|
infix fun Cash.State.`owned by`(owner: AbstractParty) = ownedBy(owner)
|
||||||
/** @suppress */ infix fun Cash.State.`issued by`(deposit: PartyAndReference) = issuedBy(deposit)
|
|
||||||
/** @suppress */ infix fun Cash.State.`with deposit`(deposit: PartyAndReference): Cash.State = withDeposit(deposit)
|
/** @suppress */
|
||||||
|
infix fun Cash.State.`issued by`(party: AbstractParty) = issuedBy(party)
|
||||||
|
|
||||||
|
/** @suppress */
|
||||||
|
infix fun Cash.State.`issued by`(deposit: PartyAndReference) = issuedBy(deposit)
|
||||||
|
|
||||||
|
/** @suppress */
|
||||||
|
infix fun Cash.State.`with deposit`(deposit: PartyAndReference): Cash.State = withDeposit(deposit)
|
||||||
|
|
||||||
// Unit testing helpers. These could go in a separate file but it's hardly worth it for just a few functions.
|
// Unit testing helpers. These could go in a separate file but it's hardly worth it for just a few functions.
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ class CommodityContract : OnLedgerAsset<Commodity, CommodityContract.Commands, C
|
|||||||
) : FungibleAsset<Commodity> {
|
) : FungibleAsset<Commodity> {
|
||||||
constructor(deposit: PartyAndReference, amount: Amount<Commodity>, owner: AbstractParty)
|
constructor(deposit: PartyAndReference, amount: Amount<Commodity>, owner: AbstractParty)
|
||||||
: this(Amount(amount.quantity, Issued(deposit, amount.token)), owner)
|
: this(Amount(amount.quantity, Issued(deposit, amount.token)), owner)
|
||||||
|
|
||||||
override val exitKeys: Set<PublicKey> = Collections.singleton(owner.owningKey)
|
override val exitKeys: Set<PublicKey> = Collections.singleton(owner.owningKey)
|
||||||
override val participants = listOf(owner)
|
override val participants = listOf(owner)
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ class Obligation<P : Any> : Contract {
|
|||||||
companion object {
|
companion object {
|
||||||
const val PROGRAM_ID: ContractClassName = "net.corda.finance.contracts.asset.Obligation"
|
const val PROGRAM_ID: ContractClassName = "net.corda.finance.contracts.asset.Obligation"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents where in its lifecycle a contract state is, which in turn controls the commands that can be applied
|
* Represents where in its lifecycle a contract state is, which in turn controls the commands that can be applied
|
||||||
* to the state. Most states will not leave the [NORMAL] lifecycle. Note that settled (as an end lifecycle) is
|
* to the state. Most states will not leave the [NORMAL] lifecycle. Note that settled (as an end lifecycle) is
|
||||||
@ -785,9 +786,11 @@ infix fun <T : Any> Obligation.State<T>.between(parties: Pair<AbstractParty, Abs
|
|||||||
infix fun <T : Any> Obligation.State<T>.`owned by`(owner: AbstractParty) = copy(beneficiary = owner)
|
infix fun <T : Any> Obligation.State<T>.`owned by`(owner: AbstractParty) = copy(beneficiary = owner)
|
||||||
infix fun <T : Any> Obligation.State<T>.`issued by`(party: AbstractParty) = copy(obligor = party)
|
infix fun <T : Any> Obligation.State<T>.`issued by`(party: AbstractParty) = copy(obligor = party)
|
||||||
// For Java users:
|
// For Java users:
|
||||||
@Suppress("unused") fun <T : Any> Obligation.State<T>.ownedBy(owner: AbstractParty) = copy(beneficiary = owner)
|
@Suppress("unused")
|
||||||
|
fun <T : Any> Obligation.State<T>.ownedBy(owner: AbstractParty) = copy(beneficiary = owner)
|
||||||
|
|
||||||
@Suppress("unused") fun <T : Any> Obligation.State<T>.issuedBy(party: AnonymousParty) = copy(obligor = party)
|
@Suppress("unused")
|
||||||
|
fun <T : Any> Obligation.State<T>.issuedBy(party: AnonymousParty) = copy(obligor = party)
|
||||||
|
|
||||||
/** A randomly generated key. */
|
/** A randomly generated key. */
|
||||||
val DUMMY_OBLIGATION_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
|
val DUMMY_OBLIGATION_ISSUER_KEY by lazy { entropyToKeyPair(BigInteger.valueOf(10)) }
|
||||||
|
@ -32,6 +32,7 @@ class CashIssueAndPaymentFlow(val amount: Amount<Currency>,
|
|||||||
recipient: Party,
|
recipient: Party,
|
||||||
anonymous: Boolean,
|
anonymous: Boolean,
|
||||||
notary: Party) : this(amount, issueRef, recipient, anonymous, notary, tracker())
|
notary: Party) : this(amount, issueRef, recipient, anonymous, notary, tracker())
|
||||||
|
|
||||||
constructor(request: IssueAndPaymentRequest) : this(request.amount, request.issueRef, request.recipient, request.anonymous, request.notary, tracker())
|
constructor(request: IssueAndPaymentRequest) : this(request.amount, request.issueRef, request.recipient, request.anonymous, request.notary, tracker())
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
|
@ -31,6 +31,7 @@ class CashIssueFlow(private val amount: Amount<Currency>,
|
|||||||
constructor(amount: Amount<Currency>,
|
constructor(amount: Amount<Currency>,
|
||||||
issuerBankPartyRef: OpaqueBytes,
|
issuerBankPartyRef: OpaqueBytes,
|
||||||
notary: Party) : this(amount, issuerBankPartyRef, notary, tracker())
|
notary: Party) : this(amount, issuerBankPartyRef, notary, tracker())
|
||||||
|
|
||||||
constructor(request: IssueRequest) : this(request.amount, request.issueRef, request.notary, tracker())
|
constructor(request: IssueRequest) : this(request.amount, request.issueRef, request.notary, tracker())
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
|
@ -31,8 +31,10 @@ open class CashPaymentFlow(
|
|||||||
val issuerConstraint: Set<Party> = emptySet()) : AbstractCashFlow<AbstractCashFlow.Result>(progressTracker) {
|
val issuerConstraint: Set<Party> = emptySet()) : AbstractCashFlow<AbstractCashFlow.Result>(progressTracker) {
|
||||||
/** A straightforward constructor that constructs spends using cash states of any issuer. */
|
/** A straightforward constructor that constructs spends using cash states of any issuer. */
|
||||||
constructor(amount: Amount<Currency>, recipient: Party) : this(amount, recipient, true, tracker())
|
constructor(amount: Amount<Currency>, recipient: Party) : this(amount, recipient, true, tracker())
|
||||||
|
|
||||||
/** A straightforward constructor that constructs spends using cash states of any issuer. */
|
/** A straightforward constructor that constructs spends using cash states of any issuer. */
|
||||||
constructor(amount: Amount<Currency>, recipient: Party, anonymous: Boolean) : this(amount, recipient, anonymous, tracker())
|
constructor(amount: Amount<Currency>, recipient: Party, anonymous: Boolean) : this(amount, recipient, anonymous, tracker())
|
||||||
|
|
||||||
constructor(request: PaymentRequest) : this(request.amount, request.recipient, request.anonymous, tracker(), request.issuerConstraint)
|
constructor(request: PaymentRequest) : this(request.amount, request.recipient, request.anonymous, tracker(), request.issuerConstraint)
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
|
@ -43,6 +43,7 @@ object TwoPartyDealFlow {
|
|||||||
companion object {
|
companion object {
|
||||||
object GENERATING_ID : ProgressTracker.Step("Generating anonymous identities")
|
object GENERATING_ID : ProgressTracker.Step("Generating anonymous identities")
|
||||||
object SENDING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal.")
|
object SENDING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal.")
|
||||||
|
|
||||||
fun tracker() = ProgressTracker(GENERATING_ID, SENDING_PROPOSAL)
|
fun tracker() = ProgressTracker(GENERATING_ID, SENDING_PROPOSAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,6 +149,7 @@ object TwoPartyDealFlow {
|
|||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
protected abstract fun validateHandshake(handshake: Handshake<U>): Handshake<U>
|
protected abstract fun validateHandshake(handshake: Handshake<U>): Handshake<U>
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
protected abstract fun assembleSharedTX(handshake: Handshake<U>): Triple<TransactionBuilder, List<PublicKey>, List<TransactionSignature>>
|
protected abstract fun assembleSharedTX(handshake: Handshake<U>): Triple<TransactionBuilder, List<PublicKey>, List<TransactionSignature>>
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,7 @@ object TwoPartyTradeFlow {
|
|||||||
private val anonymous: Boolean) : FlowLogic<SignedTransaction>() {
|
private val anonymous: Boolean) : FlowLogic<SignedTransaction>() {
|
||||||
constructor(otherSideSession: FlowSession, notary: Party, acceptablePrice: Amount<Currency>, typeToBuy: Class<out OwnableState>) :
|
constructor(otherSideSession: FlowSession, notary: Party, acceptablePrice: Amount<Currency>, typeToBuy: Class<out OwnableState>) :
|
||||||
this(otherSideSession, notary, acceptablePrice, typeToBuy, true)
|
this(otherSideSession, notary, acceptablePrice, typeToBuy, true)
|
||||||
|
|
||||||
// DOCSTART 2
|
// DOCSTART 2
|
||||||
object RECEIVING : ProgressTracker.Step("Waiting for seller trading info")
|
object RECEIVING : ProgressTracker.Step("Waiting for seller trading info")
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
@file:JvmName("StateSumming")
|
@file:JvmName("StateSumming")
|
||||||
|
|
||||||
package net.corda.finance.utils
|
package net.corda.finance.utils
|
||||||
|
|
||||||
import net.corda.core.contracts.Amount
|
import net.corda.core.contracts.Amount
|
||||||
|
@ -80,7 +80,8 @@ class KotlinCommercialPaperLegacyTest : ICommercialPaperTestTemplate {
|
|||||||
@RunWith(Parameterized::class)
|
@RunWith(Parameterized::class)
|
||||||
class CommercialPaperTestsGeneric {
|
class CommercialPaperTestsGeneric {
|
||||||
companion object {
|
companion object {
|
||||||
@Parameterized.Parameters @JvmStatic
|
@Parameterized.Parameters
|
||||||
|
@JvmStatic
|
||||||
fun data() = listOf(JavaCommercialPaperTest(), KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
fun data() = listOf(JavaCommercialPaperTest(), KotlinCommercialPaperTest(), KotlinCommercialPaperLegacyTest())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user