Skip to content

Commit d8a6f5d

Browse files
author
joeldudleyr3
committed
Cosmetic changes.
1 parent c099471 commit d8a6f5d

File tree

7 files changed

+40
-43
lines changed

7 files changed

+40
-43
lines changed

TRADEMARK

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Corda and the Corda logo are trademarks of R3CEV LLC and its affiliates.
2-
All rights reserved.
1+
Corda and the Corda logo are trademarks of R3CEV LLC and its affiliates. All rights reserved.
32

4-
For R3CEV LLC's trademark and logo usage information, please consult our Trademark Usage Policy available at https://www.r3.com/trademark-usage-policy
3+
For R3CEV LLC's trademark and logo usage information, please consult our Trademark Usage Policy at
4+
https://www.r3.com/trademark-policy/.

build.gradle

+2-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ repositories {
2727
}
2828

2929
apply plugin: 'kotlin'
30-
apply plugin: 'idea'
3130
apply plugin: 'net.corda.plugins.cordformation'
3231
apply plugin: 'net.corda.plugins.quasar-utils'
3332

@@ -73,14 +72,9 @@ dependencies {
7372

7473
testCompile "net.corda:corda-node-driver:$corda_release_version"
7574

76-
// GraphStream: For visualisation (required by TemplateClientRPC app)
77-
compile "org.graphstream:gs-core:1.3"
78-
compile("org.graphstream:gs-ui:1.3") {
79-
exclude group: "bouncycastle"
80-
}
81-
8275
// CorDapp dependencies
83-
// Specify your cordapp's dependencies below, including dependent cordapps
76+
// Specify your CorDapp's dependencies below, including dependent CorDapps.
77+
// We've defined Cash as a dependent CorDapp as an example.
8478
cordapp "net.corda:corda-finance:$corda_release_version"
8579
}
8680

gradle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name = Test
2-
group = com.template
3-
version = 0.1
1+
name=Test
2+
group=com.template
3+
version=0.1
44
kotlin.incremental=false

src/main/kotlin/com/template/App.kt

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package com.template
22

33
import co.paralleluniverse.fibers.Suspendable
4+
import net.corda.core.contracts.CommandData
45
import net.corda.core.contracts.Contract
56
import net.corda.core.contracts.ContractState
6-
import net.corda.core.flows.FlowLogic
7-
import net.corda.core.flows.InitiatedBy
8-
import net.corda.core.flows.InitiatingFlow
9-
import net.corda.core.flows.StartableByRPC
7+
import net.corda.core.flows.*
108
import net.corda.core.identity.AbstractParty
11-
import net.corda.core.identity.Party
129
import net.corda.core.messaging.CordaRPCOps
1310
import net.corda.core.serialization.SerializationWhitelist
1411
import net.corda.core.transactions.LedgerTransaction
@@ -24,13 +21,13 @@ import javax.ws.rs.core.Response
2421
// * API Endpoints *
2522
// *****************
2623
@Path("template")
27-
class TemplateApi(val services: CordaRPCOps) {
24+
class TemplateApi(val rpcOps: CordaRPCOps) {
2825
// Accessible at /api/template/templateGetEndpoint.
2926
@GET
3027
@Path("templateGetEndpoint")
3128
@Produces(MediaType.APPLICATION_JSON)
3229
fun templateGetEndpoint(): Response {
33-
return Response.ok(mapOf("message" to "Template GET endpoint.")).build()
30+
return Response.ok("Template GET endpoint.").build()
3431
}
3532
}
3633

@@ -41,17 +38,22 @@ class TemplateApi(val services: CordaRPCOps) {
4138
val TEMPLATE_CONTRACT_ID = "com.template.TemplateContract"
4239

4340
open class TemplateContract : Contract {
44-
// The verify() function of the contract for each of the transaction's input and output states must not throw an
45-
// exception for a transaction to be considered valid.
41+
// A transaction is considered valid if the verify() function of the contract of each of the transaction's input
42+
// and output states does not throw an exception.
4643
override fun verify(tx: LedgerTransaction) {
4744
// Verification logic goes here.
4845
}
46+
47+
// Used to indicate the transaction's intent.
48+
interface Commands : CommandData {
49+
class Action : Commands
50+
}
4951
}
5052

5153
// *********
5254
// * State *
5355
// *********
54-
class TemplateState(val data: String) : ContractState {
56+
data class TemplateState(val data: String) : ContractState {
5557
override val participants: List<AbstractParty> get() = listOf()
5658
}
5759

@@ -68,21 +70,13 @@ class Initiator : FlowLogic<Unit>() {
6870
}
6971

7072
@InitiatedBy(Initiator::class)
71-
class Responder(val otherParty: Party) : FlowLogic<Unit>() {
73+
class Responder(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
7274
@Suspendable
7375
override fun call() {
7476
return Unit
7577
}
7678
}
7779

78-
// Serialization whitelist (only needed for 3rd party classes, but we use a local example here).
79-
class TemplateSerializationWhitelist : SerializationWhitelist {
80-
override val whitelist: List<Class<*>> = listOf(TemplateData::class.java)
81-
}
82-
83-
// Not annotated with @CordaSerializable just for use with manual whitelisting above.
84-
data class TemplateData(val payload: String)
85-
8680
class TemplateWebPlugin : WebServerPluginRegistry {
8781
// A list of classes that expose web JAX-RS REST APIs.
8882
override val webApis: List<Function<CordaRPCOps, out Any>> = listOf(Function(::TemplateApi))
@@ -93,3 +87,12 @@ class TemplateWebPlugin : WebServerPluginRegistry {
9387
"template" to javaClass.classLoader.getResource("templateWeb").toExternalForm()
9488
)
9589
}
90+
91+
// Serialization whitelist.
92+
class TemplateSerializationWhitelist : SerializationWhitelist {
93+
override val whitelist: List<Class<*>> = listOf(TemplateData::class.java)
94+
}
95+
96+
// This class is not annotated with @CordaSerializable, so it must be added to the serialization whitelist, above, if
97+
// we want to send it to other nodes within a flow.
98+
data class TemplateData(val payload: String)

src/main/kotlin/com/template/Client.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import org.slf4j.Logger
88

99
/**
1010
* Demonstration of how to use the CordaRPCClient to connect to a Corda Node and
11-
* stream some State data from the node.
11+
* stream the contents of the node's vault.
1212
*/
1313
fun main(args: Array<String>) {
1414
TemplateClient().main(args)
@@ -28,7 +28,7 @@ private class TemplateClient {
2828
// Can be amended in the com.template.MainKt file.
2929
val proxy = client.start("user1", "test").proxy
3030

31-
// Grab all signed transactions and all future signed transactions.
31+
// Grab all existing TemplateStates and all future TemplateStates.
3232
val (snapshot, updates) = proxy.vaultTrack(TemplateState::class.java)
3333

3434
// Log the existing TemplateStates and listen for new ones.

src/test/kotlin/com/template/Main.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import net.corda.nodeapi.internal.ServiceInfo
88
import net.corda.testing.driver.driver
99

1010
/**
11-
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)
11+
* This file is exclusively for being able to run your nodes through an IDE (as opposed to using deployNodes)
1212
* Do not use in a production environment.
1313
*
1414
* To debug your CorDapp:
@@ -24,8 +24,8 @@ fun main(args: Array<String>) {
2424
// No permissions required as we are not invoking flows.
2525
val user = User("user1", "test", permissions = setOf())
2626
driver(isDebug = true) {
27-
startNode(providedName = CordaX500Name("Controller", "London", "GB"), advertisedServices = setOf(ServiceInfo(ValidatingNotaryService.type)))
28-
val (nodeA, nodeB) = listOf(
27+
val (_, nodeA, nodeB) = listOf(
28+
startNode(providedName = CordaX500Name("Controller", "London", "GB"), advertisedServices = setOf(ServiceInfo(ValidatingNotaryService.type))),
2929
startNode(providedName = CordaX500Name("PartyA", "London", "GB"), rpcUsers = listOf(user)),
3030
startNode(providedName = CordaX500Name("PartyB", "New York", "US"), rpcUsers = listOf(user))).map { it.getOrThrow() }
3131

src/test/kotlin/com/template/flow/FlowTests.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ import org.junit.Before
99
import org.junit.Test
1010

1111
class FlowTests {
12-
lateinit var net: MockNetwork
12+
lateinit var network: MockNetwork
1313
lateinit var a: StartedNode<MockNode>
1414
lateinit var b: StartedNode<MockNode>
1515

1616
@Before
1717
fun setup() {
18-
net = MockNetwork()
19-
val nodes = net.createSomeNodes(2)
18+
network = MockNetwork()
19+
val nodes = network.createSomeNodes(2)
2020
a = nodes.partyNodes[0]
2121
b = nodes.partyNodes[1]
2222
nodes.partyNodes.forEach {
2323
it.registerInitiatedFlow(Responder::class.java)
2424
}
25-
net.runNetwork()
25+
network.runNetwork()
2626
}
2727

2828
@After
2929
fun tearDown() {
30-
net.stopNodes()
30+
network.stopNodes()
3131
}
3232

3333
@Test

0 commit comments

Comments
 (0)