Kotlin Beta 2

This commit is contained in:
Mike Hearn 2015-11-16 18:40:19 +01:00
parent e3e674658d
commit 6c66eee712
3 changed files with 8 additions and 10 deletions

View File

@ -6,7 +6,7 @@ apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'
buildscript {
ext.kotlin_version = '1.0.0-beta-1103'
ext.kotlin_version = '1.0.0-beta-2423'
repositories {
mavenCentral()
jcenter()

View File

@ -82,8 +82,7 @@ class TransactionForTest() {
fun output(label: String? = null, s: () -> ContractState) = outStates.add(LabeledOutput(label, s()))
fun arg(vararg key: PublicKey, c: () -> Command) {
val keys = listOf(*key)
// TODO: replace map->filterNotNull once upgraded to next Kotlin
args.add(AuthenticatedObject(keys, keys.map { TEST_KEYS_TO_CORP_MAP[it] }.filterNotNull(), c()))
args.add(AuthenticatedObject(keys, keys.mapNotNull { TEST_KEYS_TO_CORP_MAP[it] }, c()))
}
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
// the next.
fun chain(vararg outputLabels: String, body: TransactionForTest.() -> Unit) {
val states = outStates.filter {
val states = outStates.mapNotNull {
val l = it.label
if (l != null)
outputLabels.contains(l)
if (l != null && outputLabels.contains(l))
it.state
else
false
}.map { it.state } // TODO: replace with mapNotNull after next Kotlin upgrade
null
}
val tx = TransactionForTest()
tx.inStates.addAll(states)
tx.body()

View File

@ -60,8 +60,7 @@ data class WireTransaction(val inputStates: List<ContractStateRef>,
fun toLedgerTransaction(timestamp: Instant, institutionKeyMap: Map<PublicKey, Institution>): LedgerTransaction {
val authenticatedArgs = args.map {
// TODO: Replace map/filterNotNull with mapNotNull on next Kotlin upgrade.
val institutions = it.pubkeys.map { pk -> institutionKeyMap[pk] }.filterNotNull()
val institutions = it.pubkeys.mapNotNull { pk -> institutionKeyMap[pk] }
AuthenticatedObject(it.pubkeys, institutions, it.command)
}
return LedgerTransaction(inputStates, outputStates, authenticatedArgs, timestamp)