mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Kotlin Beta 2
This commit is contained in:
parent
e3e674658d
commit
6c66eee712
@ -6,7 +6,7 @@ apply plugin: 'kotlin'
|
|||||||
apply plugin: 'org.jetbrains.dokka'
|
apply plugin: 'org.jetbrains.dokka'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.0.0-beta-1103'
|
ext.kotlin_version = '1.0.0-beta-2423'
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
@ -82,8 +82,7 @@ class TransactionForTest() {
|
|||||||
fun output(label: String? = null, s: () -> ContractState) = outStates.add(LabeledOutput(label, s()))
|
fun output(label: String? = null, s: () -> ContractState) = outStates.add(LabeledOutput(label, s()))
|
||||||
fun arg(vararg key: PublicKey, c: () -> Command) {
|
fun arg(vararg key: PublicKey, c: () -> Command) {
|
||||||
val keys = listOf(*key)
|
val keys = listOf(*key)
|
||||||
// TODO: replace map->filterNotNull once upgraded to next Kotlin
|
args.add(AuthenticatedObject(keys, keys.mapNotNull { TEST_KEYS_TO_CORP_MAP[it] }, c()))
|
||||||
args.add(AuthenticatedObject(keys, keys.map { TEST_KEYS_TO_CORP_MAP[it] }.filterNotNull(), c()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun run(time: Instant) = TransactionForVerification(inStates, outStates.map { it.state }, args, time).verify(TEST_PROGRAM_MAP)
|
private fun run(time: Instant) = TransactionForVerification(inStates, outStates.map { it.state }, args, time).verify(TEST_PROGRAM_MAP)
|
||||||
@ -121,13 +120,13 @@ class TransactionForTest() {
|
|||||||
// Use this to create transactions where the output of this transaction is automatically used as an input of
|
// Use this to create transactions where the output of this transaction is automatically used as an input of
|
||||||
// the next.
|
// the next.
|
||||||
fun chain(vararg outputLabels: String, body: TransactionForTest.() -> Unit) {
|
fun chain(vararg outputLabels: String, body: TransactionForTest.() -> Unit) {
|
||||||
val states = outStates.filter {
|
val states = outStates.mapNotNull {
|
||||||
val l = it.label
|
val l = it.label
|
||||||
if (l != null)
|
if (l != null && outputLabels.contains(l))
|
||||||
outputLabels.contains(l)
|
it.state
|
||||||
else
|
else
|
||||||
false
|
null
|
||||||
}.map { it.state } // TODO: replace with mapNotNull after next Kotlin upgrade
|
}
|
||||||
val tx = TransactionForTest()
|
val tx = TransactionForTest()
|
||||||
tx.inStates.addAll(states)
|
tx.inStates.addAll(states)
|
||||||
tx.body()
|
tx.body()
|
||||||
|
@ -60,8 +60,7 @@ data class WireTransaction(val inputStates: List<ContractStateRef>,
|
|||||||
|
|
||||||
fun toLedgerTransaction(timestamp: Instant, institutionKeyMap: Map<PublicKey, Institution>): LedgerTransaction {
|
fun toLedgerTransaction(timestamp: Instant, institutionKeyMap: Map<PublicKey, Institution>): LedgerTransaction {
|
||||||
val authenticatedArgs = args.map {
|
val authenticatedArgs = args.map {
|
||||||
// TODO: Replace map/filterNotNull with mapNotNull on next Kotlin upgrade.
|
val institutions = it.pubkeys.mapNotNull { pk -> institutionKeyMap[pk] }
|
||||||
val institutions = it.pubkeys.map { pk -> institutionKeyMap[pk] }.filterNotNull()
|
|
||||||
AuthenticatedObject(it.pubkeys, institutions, it.command)
|
AuthenticatedObject(it.pubkeys, institutions, it.command)
|
||||||
}
|
}
|
||||||
return LedgerTransaction(inputStates, outputStates, authenticatedArgs, timestamp)
|
return LedgerTransaction(inputStates, outputStates, authenticatedArgs, timestamp)
|
||||||
|
Loading…
Reference in New Issue
Block a user