mirror of
https://github.com/corda/corda.git
synced 2025-05-02 16:53:22 +00:00
Address review comments.
This commit is contained in:
parent
7b40be8361
commit
d500bf8f50
@ -304,11 +304,13 @@ data class ErrorOr<out A> private constructor(val value: A?, val error: Throwabl
|
||||
|
||||
companion object {
|
||||
/** Runs the given lambda and wraps the result. */
|
||||
inline fun <T : Any> catch(body: () -> T): ErrorOr<T> = try {
|
||||
inline fun <T : Any> catch(body: () -> T): ErrorOr<T> {
|
||||
return try {
|
||||
ErrorOr(body())
|
||||
} catch (t: Throwable) {
|
||||
ErrorOr.of(t)
|
||||
}
|
||||
}
|
||||
|
||||
fun of(t: Throwable) = ErrorOr(null, t)
|
||||
}
|
||||
|
@ -464,12 +464,9 @@ data class UniqueIdentifier(val externalId: String? = null, val id: UUID = UUID.
|
||||
override fun toString(): String = if (externalId != null) "${externalId}_$id" else id.toString()
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Helper function for unit tests where the UUID needs to be manually initialised for consistency.
|
||||
*/
|
||||
/** Helper function for unit tests where the UUID needs to be manually initialised for consistency. */
|
||||
@VisibleForTesting
|
||||
fun fromString(name: String): UniqueIdentifier
|
||||
= UniqueIdentifier(null, UUID.fromString(name))
|
||||
fun fromString(name: String): UniqueIdentifier = UniqueIdentifier(null, UUID.fromString(name))
|
||||
}
|
||||
|
||||
override fun compareTo(other: UniqueIdentifier): Int = id.compareTo(other.id)
|
||||
|
@ -79,12 +79,11 @@ sealed class TransactionType {
|
||||
}
|
||||
|
||||
// Validate that all encumbrances exist within the set of input states.
|
||||
tx.inputs.filter { it.state.data.encumbrance != null }.forEach {
|
||||
encumberedInput ->
|
||||
if (tx.inputs.none {
|
||||
it.ref.txhash == encumberedInput.ref.txhash &&
|
||||
it.ref.index == encumberedInput.state.data.encumbrance
|
||||
}) {
|
||||
tx.inputs.filter { it.state.data.encumbrance != null }.forEach { encumberedInput ->
|
||||
val isMissing = tx.inputs.none {
|
||||
it.ref.txhash == encumberedInput.ref.txhash && it.ref.index == encumberedInput.state.data.encumbrance
|
||||
}
|
||||
if (isMissing) {
|
||||
throw TransactionVerificationException.TransactionMissingEncumbranceException(
|
||||
tx, encumberedInput.state.data.encumbrance!!,
|
||||
TransactionVerificationException.Direction.INPUT
|
||||
|
@ -485,11 +485,12 @@ class TwoPartyTradeFlowTests {
|
||||
// Issued money to itself.
|
||||
output("elbonian money 1", notary = notary) { 800.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY }
|
||||
output("elbonian money 2", notary = notary) { 1000.DOLLARS.CASH `issued by` issuer `owned by` MEGA_CORP_PUBKEY }
|
||||
if (!withError)
|
||||
if (!withError) {
|
||||
command(DUMMY_CASH_ISSUER_KEY.public.composite) { Cash.Commands.Issue() }
|
||||
else
|
||||
} else {
|
||||
// Put a broken command on so at least a signature is created
|
||||
command(DUMMY_CASH_ISSUER_KEY.public.composite) { Cash.Commands.Move() }
|
||||
}
|
||||
timestamp(TEST_TX_TIME)
|
||||
if (withError) {
|
||||
this.fails()
|
||||
|
@ -504,9 +504,10 @@ class InterestRateSwap() : Contract {
|
||||
}
|
||||
|
||||
class Group : GroupClauseVerifier<State, Commands, UniqueIdentifier>(AnyComposition(Agree(), Fix(), Pay(), Mature())) {
|
||||
override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<State, UniqueIdentifier>>
|
||||
// Group by Trade ID for in / out states
|
||||
= tx.groupStates() { state -> state.linearId }
|
||||
override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<State, UniqueIdentifier>> {
|
||||
return tx.groupStates() { state -> state.linearId }
|
||||
}
|
||||
}
|
||||
|
||||
class Timestamped : Clause<ContractState, Commands, Unit>() {
|
||||
|
@ -17,6 +17,7 @@ class ReportingCurrencyModel {
|
||||
private val exchangeRate: ObservableValue<ExchangeRate> by observableValue(ExchangeRateModel::exchangeRate)
|
||||
val reportingCurrency by observableValue(SettingsModel::reportingCurrencyProperty)
|
||||
val supportedCurrencies = setOf(USD, GBP, CHF).toList().observable()
|
||||
|
||||
/**
|
||||
* This stream provides a stream of exchange() functions that updates when either the reporting currency or the
|
||||
* exchange rates change
|
||||
|
Loading…
x
Reference in New Issue
Block a user