mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
CORDA-2361: Split samples into contracts and workflows (#4575)
This commit is contained in:
parent
82f5a756fe
commit
35acbc8107
@ -314,6 +314,9 @@ Version 4.0
|
|||||||
* Finance CorDapp was split into two separate apps: ``corda-finance-contracts`` and ``corda-finance-workflows``,
|
* Finance CorDapp was split into two separate apps: ``corda-finance-contracts`` and ``corda-finance-workflows``,
|
||||||
``corda-finance`` is kept for backward compatibility, it is recommended to use separated jars.
|
``corda-finance`` is kept for backward compatibility, it is recommended to use separated jars.
|
||||||
|
|
||||||
|
* All sample CorDapps were split into separate apps: workflows and contracts to reflect new convention. It is recommended to structure your CorDapps
|
||||||
|
this way, see :doc:`app-upgrade-notes` on upgrading your CorDapp.
|
||||||
|
|
||||||
* The format of the shell commands' output can now be customized via the node shell, using the ``output-format`` command.
|
* The format of the shell commands' output can now be customized via the node shell, using the ``output-format`` command.
|
||||||
|
|
||||||
* The ``node_transaction_mapping`` database table has been folded into the ``node_transactions`` database table as an additional column.
|
* The ``node_transaction_mapping`` database table has been folded into the ``node_transactions`` database table as an additional column.
|
||||||
|
@ -1,50 +1,41 @@
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'net.corda.plugins.quasar-utils'
|
apply plugin: 'net.corda.plugins.quasar-utils'
|
||||||
apply plugin: 'net.corda.plugins.cordapp'
|
|
||||||
apply plugin: 'net.corda.plugins.cordformation'
|
apply plugin: 'net.corda.plugins.cordformation'
|
||||||
|
|
||||||
sourceSets {
|
description 'Corda attachment demo'
|
||||||
integrationTest {
|
|
||||||
kotlin {
|
|
||||||
compileClasspath += main.output + test.output
|
|
||||||
runtimeClasspath += main.output + test.output
|
|
||||||
srcDir file('src/integration-test/kotlin')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
integrationTestCompile.extendsFrom testCompile
|
|
||||||
integrationTestRuntime.extendsFrom testRuntime
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
||||||
testCompile "junit:junit:$junit_version"
|
|
||||||
|
|
||||||
// Corda integration dependencies
|
// Corda integration dependencies
|
||||||
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
||||||
cordaRuntime project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
|
||||||
cordaCompile project(':core')
|
|
||||||
cordaCompile project(':webserver')
|
cordapp project(':samples:attachment-demo:contracts')
|
||||||
cordaCompile project(':node-driver')
|
cordapp project(':samples:attachment-demo:workflows')
|
||||||
}
|
}
|
||||||
|
|
||||||
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
||||||
def webTask = tasks.getByPath(':webserver:webcapsule:assemble')
|
def webTask = tasks.getByPath(':webserver:webcapsule:assemble')
|
||||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
||||||
ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.attachmentdemo.AttachmentDemoFlow",
|
ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.attachmentdemo.AttachmentDemoFlow",
|
||||||
"InvokeRpc.wellKnownPartyFromX500Name",
|
"InvokeRpc.partiesFromName",
|
||||||
"InvokeRpc.attachmentExists",
|
"InvokeRpc.attachmentExists",
|
||||||
"InvokeRpc.openAttachment",
|
"InvokeRpc.openAttachment",
|
||||||
"InvokeRpc.uploadAttachment",
|
"InvokeRpc.uploadAttachment",
|
||||||
"InvokeRpc.internalVerifiedTransactionsFeed"]]]
|
"InvokeRpc.internalVerifiedTransactionsFeed",
|
||||||
|
"InvokeRpc.startTrackedFlowDynamic"]]]
|
||||||
|
|
||||||
directory "./build/nodes"
|
directory "./build/nodes"
|
||||||
|
nodeDefaults {
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
|
cordapp project(':samples:attachment-demo:contracts')
|
||||||
|
cordapp project(':samples:attachment-demo:workflows')
|
||||||
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Notary Service,L=Zurich,C=CH"
|
name "O=Notary Service,L=Zurich,C=CH"
|
||||||
notary = [validating : true]
|
notary = [validating: true]
|
||||||
p2pPort 10002
|
p2pPort 10002
|
||||||
cordapps = []
|
cordapps = []
|
||||||
rpcUsers = ext.rpcUsers
|
rpcUsers = ext.rpcUsers
|
||||||
@ -52,7 +43,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
address "localhost:10003"
|
address "localhost:10003"
|
||||||
adminAddress "localhost:10004"
|
adminAddress "localhost:10004"
|
||||||
}
|
}
|
||||||
extraConfig = ['h2Settings.address' : 'localhost:10012']
|
extraConfig = ['h2Settings.address': 'localhost:10012']
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Bank A,L=London,C=GB"
|
name "O=Bank A,L=London,C=GB"
|
||||||
@ -63,7 +54,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
address "localhost:10006"
|
address "localhost:10006"
|
||||||
adminAddress "localhost:10007"
|
adminAddress "localhost:10007"
|
||||||
}
|
}
|
||||||
extraConfig = ['h2Settings.address' : 'localhost:10013']
|
extraConfig = ['h2Settings.address': 'localhost:10013']
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Bank B,L=New York,C=US"
|
name "O=Bank B,L=New York,C=US"
|
||||||
@ -75,51 +66,20 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
webPort 10010
|
webPort 10010
|
||||||
cordapps = []
|
cordapps = []
|
||||||
rpcUsers = ext.rpcUsers
|
rpcUsers = ext.rpcUsers
|
||||||
extraConfig = ['h2Settings.address' : 'localhost:10014']
|
extraConfig = ['h2Settings.address': 'localhost:10014']
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task integrationTest(type: Test, dependsOn: []) {
|
|
||||||
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
|
||||||
classpath = sourceSets.integrationTest.runtimeClasspath
|
|
||||||
}
|
|
||||||
|
|
||||||
idea {
|
|
||||||
module {
|
|
||||||
downloadJavadoc = true // defaults to false
|
|
||||||
downloadSources = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task runSender(type: JavaExec) {
|
task runSender(type: JavaExec) {
|
||||||
classpath = sourceSets.main.runtimeClasspath
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
main = 'net.corda.attachmentdemo.AttachmentDemoKt'
|
main = 'net.corda.attachmentdemo.workflows.AttachmentDemoKt'
|
||||||
args '--role'
|
args '--role'
|
||||||
args 'SENDER'
|
args 'SENDER'
|
||||||
}
|
}
|
||||||
|
|
||||||
task runRecipient(type: JavaExec) {
|
task runRecipient(type: JavaExec) {
|
||||||
classpath = sourceSets.main.runtimeClasspath
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
main = 'net.corda.attachmentdemo.AttachmentDemoKt'
|
main = 'net.corda.attachmentdemo.workflows.AttachmentDemoKt'
|
||||||
args '--role'
|
args '--role'
|
||||||
args 'RECIPIENT'
|
args 'RECIPIENT'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Automatic-Module-Name': 'net.corda.samples.demos.attachment'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cordapp {
|
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
|
||||||
minimumPlatformVersion 1
|
|
||||||
workflow {
|
|
||||||
name "net/corda/samples/attachment-demo"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
24
samples/attachment-demo/contracts/build.gradle
Normal file
24
samples/attachment-demo/contracts/build.gradle
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
description 'Corda attachment demo - contracts'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
cordaCompile project(':core')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
contract {
|
||||||
|
name "Corda Attachment Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-attachment-demo-contracts'
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package net.corda.attachmentdemo.contracts
|
||||||
|
|
||||||
|
import net.corda.core.contracts.Contract
|
||||||
|
import net.corda.core.contracts.ContractState
|
||||||
|
import net.corda.core.contracts.TypeOnlyCommandData
|
||||||
|
import net.corda.core.crypto.SecureHash
|
||||||
|
import net.corda.core.identity.AbstractParty
|
||||||
|
import net.corda.core.transactions.LedgerTransaction
|
||||||
|
|
||||||
|
class AttachmentContract : Contract {
|
||||||
|
override fun verify(tx: LedgerTransaction) {
|
||||||
|
val state = tx.outputsOfType<State>().single()
|
||||||
|
// we check that at least one has the matching hash, the other will be the contract
|
||||||
|
require(tx.attachments.any { it.id == state.hash }) {"At least one attachment in transaction must match hash ${state.hash}"}
|
||||||
|
}
|
||||||
|
|
||||||
|
object Command : TypeOnlyCommandData()
|
||||||
|
|
||||||
|
data class State(val hash: SecureHash.SHA256) : ContractState {
|
||||||
|
override val participants: List<AbstractParty> = emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const val ATTACHMENT_PROGRAM_ID = "net.corda.attachmentdemo.contracts.AttachmentContract"
|
@ -1,8 +0,0 @@
|
|||||||
The Quasar.jar in this directory is for runtime instrumentation of classes by Quasar.
|
|
||||||
|
|
||||||
When running corda outside of the given gradle building you must add the following flag with the
|
|
||||||
correct path to your call to Java:
|
|
||||||
|
|
||||||
java -javaagent:path-to-quasar-jar.jar ...
|
|
||||||
|
|
||||||
See the Quasar docs for more information: http://docs.paralleluniverse.co/quasar/
|
|
Binary file not shown.
@ -1,20 +0,0 @@
|
|||||||
package net.corda.attachmentdemo
|
|
||||||
|
|
||||||
import net.corda.core.internal.div
|
|
||||||
import net.corda.testing.core.DUMMY_BANK_A_NAME
|
|
||||||
import net.corda.testing.core.DUMMY_BANK_B_NAME
|
|
||||||
import net.corda.testing.driver.DriverParameters
|
|
||||||
import net.corda.testing.driver.driver
|
|
||||||
import net.corda.testing.node.User
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)
|
|
||||||
* Do not use in a production environment.
|
|
||||||
*/
|
|
||||||
fun main(args: Array<String>) {
|
|
||||||
val demoUser = listOf(User("demo", "demo", setOf("StartFlow.net.corda.flows.FinalityFlow")))
|
|
||||||
driver(DriverParameters(driverDirectory = "build" / "attachment-demo-nodes", waitForAllNodesToFinish = true)) {
|
|
||||||
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = demoUser)
|
|
||||||
startNode(providedName = DUMMY_BANK_B_NAME, rpcUsers = demoUser)
|
|
||||||
}
|
|
||||||
}
|
|
58
samples/attachment-demo/workflows/build.gradle
Normal file
58
samples/attachment-demo/workflows/build.gradle
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'net.corda.plugins.quasar-utils'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
description 'Corda attachment demo - workflows'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
integrationTest {
|
||||||
|
kotlin {
|
||||||
|
compileClasspath += main.output + test.output
|
||||||
|
runtimeClasspath += main.output + test.output
|
||||||
|
srcDir file('src/integration-test/kotlin')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
integrationTestCompile.extendsFrom testCompile
|
||||||
|
integrationTestRuntime.extendsFrom testRuntime
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
// Corda integration dependencies
|
||||||
|
cordaCompile project(':core')
|
||||||
|
cordaCompile project(':webserver')
|
||||||
|
cordapp project(':samples:attachment-demo:contracts')
|
||||||
|
testCompile project(':node-driver')
|
||||||
|
testCompile "junit:junit:$junit_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
task integrationTest(type: Test, dependsOn: []) {
|
||||||
|
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
||||||
|
classpath = sourceSets.integrationTest.runtimeClasspath
|
||||||
|
}
|
||||||
|
|
||||||
|
idea {
|
||||||
|
module {
|
||||||
|
downloadJavadoc = true // defaults to false
|
||||||
|
downloadSources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
workflow {
|
||||||
|
name "Corda Attachment Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-attachment-demo-workflows'
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package net.corda.attachmentdemo
|
package net.corda.attachmentdemo
|
||||||
|
|
||||||
|
import net.corda.attachmentdemo.workflows.recipient
|
||||||
|
import net.corda.attachmentdemo.workflows.sender
|
||||||
import net.corda.client.rpc.CordaRPCClient
|
import net.corda.client.rpc.CordaRPCClient
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.node.services.Permissions.Companion.all
|
import net.corda.node.services.Permissions.Companion.all
|
||||||
@ -9,6 +11,7 @@ import net.corda.testing.driver.DriverParameters
|
|||||||
import net.corda.testing.driver.driver
|
import net.corda.testing.driver.driver
|
||||||
import net.corda.testing.driver.internal.incrementalPortAllocation
|
import net.corda.testing.driver.internal.incrementalPortAllocation
|
||||||
import net.corda.testing.node.User
|
import net.corda.testing.node.User
|
||||||
|
import net.corda.testing.node.internal.findCordapp
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.util.concurrent.CompletableFuture.supplyAsync
|
import java.util.concurrent.CompletableFuture.supplyAsync
|
||||||
|
|
||||||
@ -17,7 +20,11 @@ class AttachmentDemoTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `attachment demo using a 10MB zip file`() {
|
fun `attachment demo using a 10MB zip file`() {
|
||||||
val numOfExpectedBytes = 10_000_000
|
val numOfExpectedBytes = 10_000_000
|
||||||
driver(DriverParameters(portAllocation = incrementalPortAllocation(20000), startNodesInProcess = true)) {
|
driver(DriverParameters(
|
||||||
|
portAllocation = incrementalPortAllocation(20000),
|
||||||
|
startNodesInProcess = true,
|
||||||
|
cordappsForAllNodes = listOf(findCordapp("net.corda.attachmentdemo.contracts"), findCordapp("net.corda.attachmentdemo.workflows")))
|
||||||
|
) {
|
||||||
val demoUser = listOf(User("demo", "demo", setOf(all())))
|
val demoUser = listOf(User("demo", "demo", setOf(all())))
|
||||||
val (nodeA, nodeB) = listOf(
|
val (nodeA, nodeB) = listOf(
|
||||||
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = demoUser, maximumHeapSize = "1g"),
|
startNode(providedName = DUMMY_BANK_A_NAME, rpcUsers = demoUser, maximumHeapSize = "1g"),
|
@ -1,30 +1,23 @@
|
|||||||
package net.corda.attachmentdemo
|
package net.corda.attachmentdemo.workflows
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.Suspendable
|
import co.paralleluniverse.fibers.Suspendable
|
||||||
import joptsimple.OptionParser
|
import joptsimple.OptionParser
|
||||||
|
import net.corda.attachmentdemo.contracts.ATTACHMENT_PROGRAM_ID
|
||||||
|
import net.corda.attachmentdemo.contracts.AttachmentContract
|
||||||
import net.corda.client.rpc.CordaRPCClient
|
import net.corda.client.rpc.CordaRPCClient
|
||||||
import net.corda.core.concurrent.CordaFuture
|
|
||||||
import net.corda.core.contracts.Contract
|
|
||||||
import net.corda.core.contracts.ContractState
|
|
||||||
import net.corda.core.contracts.TypeOnlyCommandData
|
|
||||||
import net.corda.core.crypto.SecureHash
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.flows.*
|
import net.corda.core.flows.*
|
||||||
import net.corda.core.identity.AbstractParty
|
|
||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.internal.Emoji
|
import net.corda.core.internal.Emoji
|
||||||
import net.corda.core.internal.InputStreamAndHash
|
import net.corda.core.internal.InputStreamAndHash
|
||||||
import net.corda.core.messaging.CordaRPCOps
|
import net.corda.core.messaging.CordaRPCOps
|
||||||
import net.corda.core.messaging.startTrackedFlow
|
import net.corda.core.messaging.startTrackedFlow
|
||||||
import net.corda.core.node.StatesToRecord
|
import net.corda.core.node.StatesToRecord
|
||||||
import net.corda.core.transactions.LedgerTransaction
|
|
||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.utilities.NetworkHostAndPort
|
import net.corda.core.utilities.NetworkHostAndPort
|
||||||
import net.corda.core.utilities.ProgressTracker
|
import net.corda.core.utilities.ProgressTracker
|
||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.testing.core.DUMMY_BANK_B_NAME
|
|
||||||
import net.corda.testing.core.DUMMY_NOTARY_NAME
|
|
||||||
import net.corda.testing.node.internal.poll
|
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
@ -76,28 +69,23 @@ fun main(args: Array<String>) {
|
|||||||
// DOCSTART 2
|
// DOCSTART 2
|
||||||
fun sender(rpc: CordaRPCOps, numOfClearBytes: Int = 1024) { // default size 1K.
|
fun sender(rpc: CordaRPCOps, numOfClearBytes: Int = 1024) { // default size 1K.
|
||||||
val (inputStream, hash) = InputStreamAndHash.createInMemoryTestZip(numOfClearBytes, 0)
|
val (inputStream, hash) = InputStreamAndHash.createInMemoryTestZip(numOfClearBytes, 0)
|
||||||
val executor = Executors.newScheduledThreadPool(2)
|
sender(rpc, inputStream, hash)
|
||||||
try {
|
|
||||||
sender(rpc, inputStream, hash, executor)
|
|
||||||
} finally {
|
|
||||||
executor.shutdown()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sender(rpc: CordaRPCOps, inputStream: InputStream, hash: SecureHash.SHA256, executor: ScheduledExecutorService) {
|
private fun sender(rpc: CordaRPCOps, inputStream: InputStream, hash: SecureHash.SHA256) {
|
||||||
// Get the identity key of the other side (the recipient).
|
// Get the identity key of the other side (the recipient).
|
||||||
val notaryFuture: CordaFuture<Party> = poll(executor, DUMMY_NOTARY_NAME.toString()) { rpc.wellKnownPartyFromX500Name(DUMMY_NOTARY_NAME) }
|
val notaryParty = rpc.partiesFromName("Notary", false).firstOrNull() ?: throw IllegalArgumentException("Couldn't find notary party")
|
||||||
val otherSideFuture: CordaFuture<Party> = poll(executor, DUMMY_BANK_B_NAME.toString()) { rpc.wellKnownPartyFromX500Name(DUMMY_BANK_B_NAME) }
|
val bankBParty = rpc.partiesFromName("Bank B", false).firstOrNull() ?: throw IllegalArgumentException("Couldn't find Bank B party")
|
||||||
// Make sure we have the file in storage
|
// Make sure we have the file in storage
|
||||||
if (!rpc.attachmentExists(hash)) {
|
if (!rpc.attachmentExists(hash)) {
|
||||||
inputStream.use {
|
inputStream.use {
|
||||||
val id = rpc.uploadAttachment(it)
|
val id = rpc.uploadAttachment(it)
|
||||||
require(hash == id) { "Id was '$id' instead of '$hash'" }
|
require(hash == id) { "Id was '$id' instead of '$hash'" }
|
||||||
}
|
}
|
||||||
require(rpc.attachmentExists(hash)){"Attachment matching hash: $hash does not exist"}
|
require(rpc.attachmentExists(hash)) { "Attachment matching hash: $hash does not exist" }
|
||||||
}
|
}
|
||||||
|
|
||||||
val flowHandle = rpc.startTrackedFlow(::AttachmentDemoFlow, otherSideFuture.get(), notaryFuture.get(), hash)
|
val flowHandle = rpc.startTrackedFlow(::AttachmentDemoFlow, bankBParty, notaryParty, hash)
|
||||||
flowHandle.progress.subscribe(::println)
|
flowHandle.progress.subscribe(::println)
|
||||||
val stx = flowHandle.returnValue.getOrThrow()
|
val stx = flowHandle.returnValue.getOrThrow()
|
||||||
println("Sent ${stx.id}")
|
println("Sent ${stx.id}")
|
||||||
@ -149,7 +137,6 @@ class NoProgressTrackerShellDemo : FlowLogic<String>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
// DOCSTART 1
|
// DOCSTART 1
|
||||||
fun recipient(rpc: CordaRPCOps, webPort: Int) {
|
fun recipient(rpc: CordaRPCOps, webPort: Int) {
|
||||||
@ -159,7 +146,7 @@ fun recipient(rpc: CordaRPCOps, webPort: Int) {
|
|||||||
if (wtx.attachments.isNotEmpty()) {
|
if (wtx.attachments.isNotEmpty()) {
|
||||||
if (wtx.outputs.isNotEmpty()) {
|
if (wtx.outputs.isNotEmpty()) {
|
||||||
val state = wtx.outputsOfType<AttachmentContract.State>().single()
|
val state = wtx.outputsOfType<AttachmentContract.State>().single()
|
||||||
require(rpc.attachmentExists(state.hash)) {"attachment matching hash: ${state.hash} does not exist"}
|
require(rpc.attachmentExists(state.hash)) { "attachment matching hash: ${state.hash} does not exist" }
|
||||||
|
|
||||||
// Download the attachment via the Web endpoint.
|
// Download the attachment via the Web endpoint.
|
||||||
val connection = URL("http://localhost:$webPort/attachments/${state.hash}").openConnection() as HttpURLConnection
|
val connection = URL("http://localhost:$webPort/attachments/${state.hash}").openConnection() as HttpURLConnection
|
||||||
@ -200,19 +187,3 @@ private fun printHelp(parser: OptionParser) {
|
|||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
parser.printHelpOn(System.out)
|
parser.printHelpOn(System.out)
|
||||||
}
|
}
|
||||||
|
|
||||||
const val ATTACHMENT_PROGRAM_ID = "net.corda.attachmentdemo.AttachmentContract"
|
|
||||||
|
|
||||||
class AttachmentContract : Contract {
|
|
||||||
override fun verify(tx: LedgerTransaction) {
|
|
||||||
val state = tx.outputsOfType<AttachmentContract.State>().single()
|
|
||||||
// we check that at least one has the matching hash, the other will be the contract
|
|
||||||
require(tx.attachments.any { it.id == state.hash }) {"At least one attachment in transaction must match hash ${state.hash}"}
|
|
||||||
}
|
|
||||||
|
|
||||||
object Command : TypeOnlyCommandData()
|
|
||||||
|
|
||||||
data class State(val hash: SecureHash.SHA256) : ContractState {
|
|
||||||
override val participants: List<AbstractParty> = emptyList()
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,9 +25,6 @@ dependencies {
|
|||||||
// Javax is required for webapis
|
// Javax is required for webapis
|
||||||
compile "org.glassfish.jersey.core:jersey-server:${jersey_version}"
|
compile "org.glassfish.jersey.core:jersey-server:${jersey_version}"
|
||||||
|
|
||||||
// Cordapp dependencies
|
|
||||||
// Specify your cordapp's dependencies below, including dependent cordapps
|
|
||||||
|
|
||||||
// Test dependencies
|
// Test dependencies
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
}
|
}
|
||||||
@ -121,10 +118,9 @@ jar {
|
|||||||
cordapp {
|
cordapp {
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
minimumPlatformVersion 1
|
minimumPlatformVersion 1
|
||||||
workflow {
|
info {
|
||||||
name "net/corda/samples/bank-of-corda-demo"
|
name "Bank of Corda Demo"
|
||||||
versionId 1
|
version "1"
|
||||||
vendor "R3"
|
vendor "R3"
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'net.corda.plugins.cordapp'
|
|
||||||
apply plugin: 'net.corda.plugins.cordformation'
|
apply plugin: 'net.corda.plugins.cordformation'
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
cordaCompile project(':core')
|
compile project(':node-api')
|
||||||
cordaCompile project(':node-api')
|
|
||||||
runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
|
runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version"
|
||||||
|
|
||||||
// Corda integration dependencies
|
// Corda integration dependencies
|
||||||
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
runtime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
||||||
|
|
||||||
|
cordapp project(':samples:cordapp-configuration:workflows')
|
||||||
}
|
}
|
||||||
|
|
||||||
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
||||||
@ -17,8 +17,11 @@ def webTask = tasks.getByPath(':webserver:webcapsule:assemble')
|
|||||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
||||||
directory file("$buildDir/nodes")
|
directory file("$buildDir/nodes")
|
||||||
nodeDefaults {
|
nodeDefaults {
|
||||||
cordapps = []
|
projectCordapp {
|
||||||
|
deploy = false // TODO This is a bug, project cordapp should be disabled if no cordapp plugin is applied.
|
||||||
|
}
|
||||||
rpcUsers = [['username': "default", 'password': "default", 'permissions': [ 'ALL' ]]]
|
rpcUsers = [['username': "default", 'password': "default", 'permissions': [ 'ALL' ]]]
|
||||||
|
cordapp project(':samples:cordapp-configuration:workflows')
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Notary Service,L=Zurich,C=CH"
|
name "O=Notary Service,L=Zurich,C=CH"
|
||||||
@ -34,7 +37,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
name "O=Bank A,L=London,C=GB"
|
name "O=Bank A,L=London,C=GB"
|
||||||
p2pPort 10006
|
p2pPort 10006
|
||||||
// This configures the default cordapp for this node
|
// This configures the default cordapp for this node
|
||||||
projectCordapp {
|
cordapp (project(':samples:cordapp-configuration:workflows')) {
|
||||||
config "someStringValue=test"
|
config "someStringValue=test"
|
||||||
}
|
}
|
||||||
rpcSettings {
|
rpcSettings {
|
||||||
@ -47,7 +50,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
name "O=Bank B,L=New York,C=US"
|
name "O=Bank B,L=New York,C=US"
|
||||||
p2pPort 10010
|
p2pPort 10010
|
||||||
// This configures the default cordapp for this node
|
// This configures the default cordapp for this node
|
||||||
projectCordapp {
|
cordapp (project(':samples:cordapp-configuration:workflows')){
|
||||||
config project.file("src/config.conf")
|
config project.file("src/config.conf")
|
||||||
}
|
}
|
||||||
rpcSettings {
|
rpcSettings {
|
||||||
@ -57,14 +60,3 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
extraConfig = ['h2Settings.address' : 'localhost:10013']
|
extraConfig = ['h2Settings.address' : 'localhost:10013']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cordapp {
|
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
|
||||||
minimumPlatformVersion 1
|
|
||||||
workflow {
|
|
||||||
name "net/corda/samples/cordapp-configuration"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
19
samples/cordapp-configuration/workflows/build.gradle
Normal file
19
samples/cordapp-configuration/workflows/build.gradle
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
apply plugin: 'net.corda.plugins.cordformation'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
cordaCompile project(':core')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
workflow {
|
||||||
|
name "Cordapp Configuration Sample"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
@ -22,23 +22,4 @@ class GetStringConfigFlow(private val configKey: String) : FlowLogic<String>() {
|
|||||||
val config = serviceHub.getAppContext().config
|
val config = serviceHub.getAppContext().config
|
||||||
return config.getString(configKey)
|
return config.getString(configKey)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@CordaSerializable
|
|
||||||
data class GetStringTestState(val responses: List<String>, val issuer: AbstractParty) : ContractState {
|
|
||||||
override val participants: List<AbstractParty>
|
|
||||||
get() = listOf(issuer)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@CordaSerializable
|
|
||||||
object GetStringTestCommand : CommandData
|
|
||||||
|
|
||||||
|
|
||||||
class GetStringTestContract : Contract {
|
|
||||||
override fun verify(tx: LedgerTransaction) {
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -62,7 +62,6 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile group: 'commons-io', name: 'commons-io', version: '2.5'
|
compile group: 'commons-io', name: 'commons-io', version: '2.5'
|
||||||
compile project(path: ":samples:irs-demo:cordapp", configuration: "demoArtifacts")
|
|
||||||
compile project(":samples:irs-demo:web")
|
compile project(":samples:irs-demo:web")
|
||||||
compile('org.springframework.boot:spring-boot-starter-web') {
|
compile('org.springframework.boot:spring-boot-starter-web') {
|
||||||
exclude module: "spring-boot-starter-logging"
|
exclude module: "spring-boot-starter-logging"
|
||||||
|
@ -17,29 +17,17 @@ sourceSets {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
|
||||||
integrationTestCompile.extendsFrom testCompile
|
|
||||||
integrationTestRuntime.extendsFrom testRuntime
|
|
||||||
demoArtifacts.extendsFrom integrationTestRuntime
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// The irs demo CorDapp depends upon Cash CorDapp features
|
|
||||||
cordapp project(':finance:contracts')
|
cordapp project(':finance:contracts')
|
||||||
cordapp project(':finance:workflows')
|
cordapp project(':finance:workflows')
|
||||||
|
cordapp project(':confidential-identities')
|
||||||
// Corda integration dependencies
|
// Corda integration dependencies
|
||||||
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
||||||
cordaCompile project(':core')
|
cordaCompile project(':core')
|
||||||
cordaRuntime project(':node-api')
|
cordaRuntime project(':node-api')
|
||||||
|
|
||||||
// Cordapp dependencies
|
cordapp project(':samples:irs-demo:cordapp:contracts-irs')
|
||||||
// Specify your cordapp's dependencies below, including dependent cordapps
|
cordapp project(':samples:irs-demo:cordapp:workflows-irs')
|
||||||
compile group: 'commons-io', name: 'commons-io', version: '2.5'
|
|
||||||
|
|
||||||
testCompile project(':node-driver')
|
|
||||||
testCompile "junit:junit:$junit_version"
|
|
||||||
testCompile "org.assertj:assertj-core:${assertj_version}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def rpcUsersList = [
|
def rpcUsersList = [
|
||||||
@ -58,7 +46,14 @@ def rpcUsersList = [
|
|||||||
|
|
||||||
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
||||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask]) {
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask]) {
|
||||||
|
nodeDefaults{
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
|
cordapp project(':samples:irs-demo:cordapp:contracts-irs')
|
||||||
|
cordapp project(':samples:irs-demo:cordapp:workflows-irs')
|
||||||
|
cordapp project(':confidential-identities')
|
||||||
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Notary Service,L=Zurich,C=CH"
|
name "O=Notary Service,L=Zurich,C=CH"
|
||||||
notary = [validating : true]
|
notary = [validating : true]
|
||||||
@ -113,7 +108,11 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask])
|
|||||||
}
|
}
|
||||||
|
|
||||||
task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar', nodeTask]) {
|
task prepareDockerNodes(type: net.corda.plugins.Dockerform, dependsOn: ['jar', nodeTask]) {
|
||||||
|
nodeDefaults{
|
||||||
|
cordapp project(':samples:irs-demo:cordapp:contracts-irs')
|
||||||
|
cordapp project(':samples:irs-demo:cordapp:workflows-irs')
|
||||||
|
cordapp project(':confidential-identities')
|
||||||
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Notary Service,L=Zurich,C=CH"
|
name "O=Notary Service,L=Zurich,C=CH"
|
||||||
notary = [validating : true]
|
notary = [validating : true]
|
||||||
@ -163,35 +162,3 @@ idea {
|
|||||||
downloadSources = true
|
downloadSources = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
from sourceSets.main.output
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
||||||
}
|
|
||||||
|
|
||||||
task testJar(type: Jar) {
|
|
||||||
classifier "test"
|
|
||||||
from sourceSets.main.output
|
|
||||||
from sourceSets.test.output
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
demoArtifacts testJar
|
|
||||||
}
|
|
||||||
|
|
||||||
cordapp {
|
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
|
||||||
minimumPlatformVersion 1
|
|
||||||
contract {
|
|
||||||
name "net/corda/irs-demo/contract"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
workflow {
|
|
||||||
name "net/corda/irs-demo/flows"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
28
samples/irs-demo/cordapp/contracts-irs/build.gradle
Normal file
28
samples/irs-demo/cordapp/contracts-irs/build.gradle
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// The irs demo CorDapp depends upon Cash CorDapp features
|
||||||
|
cordaCompile project(':core')
|
||||||
|
cordaRuntime project(':node-api')
|
||||||
|
|
||||||
|
testCompile project(':node-driver')
|
||||||
|
testCompile "junit:junit:$junit_version"
|
||||||
|
cordapp project(':finance:contracts')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
contract {
|
||||||
|
name "Corda IRS Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-irs-demo-contracts'
|
||||||
|
}
|
52
samples/irs-demo/cordapp/workflows-irs/build.gradle
Normal file
52
samples/irs-demo/cordapp/workflows-irs/build.gradle
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'net.corda.plugins.quasar-utils'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
demoArtifacts.extendsFrom testRuntime
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// The irs demo CorDapp depends upon Cash CorDapp features
|
||||||
|
cordapp project(':finance:contracts')
|
||||||
|
cordapp project(':finance:workflows')
|
||||||
|
|
||||||
|
// Corda integration dependencies
|
||||||
|
cordaCompile project(':core')
|
||||||
|
|
||||||
|
// Cordapp dependencies
|
||||||
|
// Specify your cordapp's dependencies below, including dependent cordapps
|
||||||
|
compile group: 'commons-io', name: 'commons-io', version: '2.5'
|
||||||
|
|
||||||
|
testCompile project(':node-driver')
|
||||||
|
testCompile "junit:junit:$junit_version"
|
||||||
|
testCompile "org.assertj:assertj-core:${assertj_version}"
|
||||||
|
|
||||||
|
cordapp project(':samples:irs-demo:cordapp:contracts-irs')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
workflow {
|
||||||
|
name "Corda IRS Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-irs-demo-workflows'
|
||||||
|
}
|
||||||
|
|
||||||
|
task testJar(type: Jar) {
|
||||||
|
classifier "test"
|
||||||
|
from sourceSets.main.output
|
||||||
|
from sourceSets.test.output
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
demoArtifacts testJar
|
||||||
|
}
|
@ -33,7 +33,6 @@ import net.corda.testing.node.NotarySpec
|
|||||||
import net.corda.testing.node.User
|
import net.corda.testing.node.User
|
||||||
import org.apache.commons.io.IOUtils
|
import org.apache.commons.io.IOUtils
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Ignore
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
|
@ -70,10 +70,12 @@ dependencies {
|
|||||||
compile("com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version")
|
compile("com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version")
|
||||||
compile project(":client:rpc")
|
compile project(":client:rpc")
|
||||||
compile project(":client:jackson")
|
compile project(":client:jackson")
|
||||||
compile project(":samples:irs-demo:cordapp")
|
compile project(":finance:workflows")
|
||||||
|
// TODO In the future remove -irs bit from the directory name. Currently it clashes with :finance:workflows (same for contracts).
|
||||||
|
compile project(":samples:irs-demo:cordapp:workflows-irs")
|
||||||
|
|
||||||
testCompile project(":test-utils")
|
testCompile project(":test-utils")
|
||||||
testCompile project(path: ":samples:irs-demo:cordapp", configuration: "demoArtifacts")
|
testCompile project(path: ":samples:irs-demo:cordapp:workflows-irs", configuration: "demoArtifacts")
|
||||||
|
|
||||||
// JOpt: for command line flags.
|
// JOpt: for command line flags.
|
||||||
compile "net.sf.jopt-simple:jopt-simple:$jopt_simple_version"
|
compile "net.sf.jopt-simple:jopt-simple:$jopt_simple_version"
|
||||||
|
@ -6,17 +6,23 @@ dependencies {
|
|||||||
cordaCompile project(':core')
|
cordaCompile project(':core')
|
||||||
cordaCompile project(':node-api')
|
cordaCompile project(':node-api')
|
||||||
|
|
||||||
testCompile project(":test-utils")
|
|
||||||
testCompile "junit:junit:$junit_version"
|
|
||||||
|
|
||||||
// Corda integration dependencies
|
// Corda integration dependencies
|
||||||
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
||||||
|
|
||||||
|
cordapp project(':samples:network-verifier:contracts')
|
||||||
|
cordapp project(':samples:network-verifier:workflows')
|
||||||
}
|
}
|
||||||
|
|
||||||
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
||||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask]) {
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask]) {
|
||||||
ext.rpcUsers = [['username': "default", 'password': "default", 'permissions': [ 'ALL' ]]]
|
ext.rpcUsers = [['username': "default", 'password': "default", 'permissions': [ 'ALL' ]]]
|
||||||
|
nodeDefaults{
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
|
cordapp project(':samples:network-verifier:contracts')
|
||||||
|
cordapp project(':samples:network-verifier:workflows')
|
||||||
|
}
|
||||||
directory "./build/nodes"
|
directory "./build/nodes"
|
||||||
node {
|
node {
|
||||||
name "O=Notary Service,L=Zurich,C=CH"
|
name "O=Notary Service,L=Zurich,C=CH"
|
||||||
@ -51,14 +57,3 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask])
|
|||||||
extraConfig = ['h2Settings.address' : 'localhost:0']
|
extraConfig = ['h2Settings.address' : 'localhost:0']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cordapp {
|
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
|
||||||
minimumPlatformVersion 1
|
|
||||||
workflow {
|
|
||||||
name "net/corda/samples/network-verifier"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
23
samples/network-verifier/contracts/build.gradle
Normal file
23
samples/network-verifier/contracts/build.gradle
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
description 'Corda Network Verifier - Contracts'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
cordaCompile project(':core')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
contract {
|
||||||
|
name "Corda Network Verifier"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-network-verifier-contracts'
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package net.corda.verification
|
||||||
|
|
||||||
|
import net.corda.core.contracts.BelongsToContract
|
||||||
|
import net.corda.core.contracts.CommandData
|
||||||
|
import net.corda.core.contracts.Contract
|
||||||
|
import net.corda.core.contracts.ContractState
|
||||||
|
import net.corda.core.identity.AbstractParty
|
||||||
|
import net.corda.core.serialization.CordaSerializable
|
||||||
|
import net.corda.core.transactions.LedgerTransaction
|
||||||
|
|
||||||
|
@CordaSerializable
|
||||||
|
@BelongsToContract(CommsTestContract::class)
|
||||||
|
data class CommsTestState(val responses: List<String>, val issuer: AbstractParty) : ContractState {
|
||||||
|
override val participants: List<AbstractParty>
|
||||||
|
get() = listOf(issuer)
|
||||||
|
}
|
||||||
|
|
||||||
|
@CordaSerializable
|
||||||
|
object CommsTestCommand : CommandData
|
||||||
|
|
||||||
|
class CommsTestContract : Contract {
|
||||||
|
override fun verify(tx: LedgerTransaction) {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package net.corda.verification
|
||||||
|
|
||||||
|
import net.corda.core.contracts.CommandData
|
||||||
|
import net.corda.core.contracts.Contract
|
||||||
|
import net.corda.core.contracts.ContractState
|
||||||
|
import net.corda.core.identity.AbstractParty
|
||||||
|
import net.corda.core.serialization.CordaSerializable
|
||||||
|
import net.corda.core.transactions.LedgerTransaction
|
||||||
|
|
||||||
|
@CordaSerializable
|
||||||
|
data class NotaryTestState(val id: String, val issuer: AbstractParty) : ContractState {
|
||||||
|
override val participants: List<AbstractParty>
|
||||||
|
get() = listOf(issuer)
|
||||||
|
}
|
||||||
|
|
||||||
|
@CordaSerializable
|
||||||
|
object NotaryTestCommand : CommandData
|
||||||
|
|
||||||
|
class NotaryTestContract : Contract {
|
||||||
|
override fun verify(tx: LedgerTransaction) {
|
||||||
|
}
|
||||||
|
}
|
27
samples/network-verifier/workflows/build.gradle
Normal file
27
samples/network-verifier/workflows/build.gradle
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
description 'Corda Network Verifier - Workflows'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
cordaCompile project(':core')
|
||||||
|
cordapp project(':samples:network-verifier:contracts')
|
||||||
|
|
||||||
|
testCompile project(":test-utils")
|
||||||
|
testCompile "junit:junit:$junit_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
workflow {
|
||||||
|
name "Corda Network Verifier"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-network-verifier-workflows'
|
||||||
|
}
|
@ -1,16 +1,9 @@
|
|||||||
package net.corda.verification
|
package net.corda.verification
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.Suspendable
|
import co.paralleluniverse.fibers.Suspendable
|
||||||
import net.corda.core.contracts.BelongsToContract
|
|
||||||
import net.corda.core.contracts.CommandData
|
|
||||||
import net.corda.core.contracts.Contract
|
|
||||||
import net.corda.core.contracts.ContractState
|
|
||||||
import net.corda.core.flows.*
|
import net.corda.core.flows.*
|
||||||
import net.corda.core.identity.AbstractParty
|
|
||||||
import net.corda.core.identity.CordaX500Name
|
import net.corda.core.identity.CordaX500Name
|
||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.serialization.CordaSerializable
|
|
||||||
import net.corda.core.transactions.LedgerTransaction
|
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.utilities.ProgressTracker
|
import net.corda.core.utilities.ProgressTracker
|
||||||
import net.corda.core.utilities.unwrap
|
import net.corda.core.utilities.unwrap
|
||||||
@ -61,18 +54,3 @@ class TestCommsFlowResponder(private val otherSideSession: FlowSession) : FlowLo
|
|||||||
otherSideSession.send("Hello from: " + serviceHub.myInfo.legalIdentities.first().name.toString())
|
otherSideSession.send("Hello from: " + serviceHub.myInfo.legalIdentities.first().name.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CordaSerializable
|
|
||||||
@BelongsToContract(CommsTestContract::class)
|
|
||||||
data class CommsTestState(val responses: List<String>, val issuer: AbstractParty) : ContractState {
|
|
||||||
override val participants: List<AbstractParty>
|
|
||||||
get() = listOf(issuer)
|
|
||||||
}
|
|
||||||
|
|
||||||
@CordaSerializable
|
|
||||||
object CommsTestCommand : CommandData
|
|
||||||
|
|
||||||
class CommsTestContract : Contract {
|
|
||||||
override fun verify(tx: LedgerTransaction) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,8 @@
|
|||||||
package net.corda.verification
|
package net.corda.verification
|
||||||
|
|
||||||
import net.corda.core.contracts.CommandData
|
|
||||||
import net.corda.core.contracts.Contract
|
|
||||||
import net.corda.core.contracts.ContractState
|
|
||||||
import net.corda.core.flows.FinalityFlow
|
import net.corda.core.flows.FinalityFlow
|
||||||
import net.corda.core.flows.FlowLogic
|
import net.corda.core.flows.FlowLogic
|
||||||
import net.corda.core.flows.StartableByRPC
|
import net.corda.core.flows.StartableByRPC
|
||||||
import net.corda.core.identity.AbstractParty
|
|
||||||
import net.corda.core.serialization.CordaSerializable
|
|
||||||
import net.corda.core.transactions.LedgerTransaction
|
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
import net.corda.core.utilities.ProgressTracker
|
import net.corda.core.utilities.ProgressTracker
|
||||||
import co.paralleluniverse.fibers.Suspendable
|
import co.paralleluniverse.fibers.Suspendable
|
||||||
@ -45,17 +39,3 @@ class TestNotaryFlow : FlowLogic<String>() {
|
|||||||
return "notarised: ${result.notary}::${result.tx.id}"
|
return "notarised: ${result.notary}::${result.tx.id}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@CordaSerializable
|
|
||||||
data class NotaryTestState(val id: String, val issuer: AbstractParty) : ContractState {
|
|
||||||
override val participants: List<AbstractParty>
|
|
||||||
get() = listOf(issuer)
|
|
||||||
}
|
|
||||||
|
|
||||||
@CordaSerializable
|
|
||||||
object NotaryTestCommand : CommandData
|
|
||||||
|
|
||||||
class NotaryTestContract : Contract {
|
|
||||||
override fun verify(tx: LedgerTransaction) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,21 +7,15 @@ apply plugin: 'net.corda.plugins.quasar-utils'
|
|||||||
apply plugin: 'net.corda.plugins.cordapp'
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
apply plugin: 'net.corda.plugins.cordformation'
|
apply plugin: 'net.corda.plugins.cordformation'
|
||||||
|
|
||||||
configurations {
|
|
||||||
integrationTestCompile.extendsFrom testCompile
|
|
||||||
integrationTestRuntime.extendsFrom testRuntime
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
|
||||||
// Corda integration dependencies
|
// Corda integration dependencies
|
||||||
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
||||||
cordaRuntime project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
|
|
||||||
cordaCompile project(':core')
|
cordaCompile project(':core')
|
||||||
cordaCompile project(':client:jfx')
|
|
||||||
cordaCompile project(':client:rpc')
|
// Notary implementations
|
||||||
cordaCompile project(':test-utils')
|
cordapp project(':samples:notary-demo:contracts')
|
||||||
|
cordapp project(':samples:notary-demo:workflows')
|
||||||
}
|
}
|
||||||
|
|
||||||
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
def nodeTask = tasks.getByPath(':node:capsule:assemble')
|
||||||
@ -32,7 +26,12 @@ task deployNodes(dependsOn: ['deployNodesSingle', 'deployNodesRaft', 'deployNode
|
|||||||
task deployNodesSingle(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
task deployNodesSingle(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
||||||
directory file("$buildDir/nodes/nodesSingle")
|
directory file("$buildDir/nodes/nodesSingle")
|
||||||
nodeDefaults {
|
nodeDefaults {
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
extraConfig = [h2Settings: [address: "localhost:0"]]
|
extraConfig = [h2Settings: [address: "localhost:0"]]
|
||||||
|
cordapp project(':samples:notary-demo:contracts')
|
||||||
|
cordapp project(':samples:notary-demo:workflows')
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Alice Corp,L=Madrid,C=ES"
|
name "O=Alice Corp,L=Madrid,C=ES"
|
||||||
@ -57,7 +56,12 @@ task deployNodesSingle(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
|||||||
task deployNodesCustom(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
task deployNodesCustom(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
||||||
directory file("$buildDir/nodes/nodesCustom")
|
directory file("$buildDir/nodes/nodesCustom")
|
||||||
nodeDefaults {
|
nodeDefaults {
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
extraConfig = [h2Settings: [address: "localhost:0"]]
|
extraConfig = [h2Settings: [address: "localhost:0"]]
|
||||||
|
cordapp project(':samples:notary-demo:contracts')
|
||||||
|
cordapp project(':samples:notary-demo:workflows')
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Alice Corp,L=Madrid,C=ES"
|
name "O=Alice Corp,L=Madrid,C=ES"
|
||||||
@ -83,10 +87,14 @@ task deployNodesCustom(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task deployNodesRaft(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
task deployNodesRaft(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
||||||
def className = ""
|
|
||||||
directory file("$buildDir/nodes/nodesRaft")
|
directory file("$buildDir/nodes/nodesRaft")
|
||||||
nodeDefaults {
|
nodeDefaults {
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
extraConfig = [h2Settings: [address: "localhost:0"]]
|
extraConfig = [h2Settings: [address: "localhost:0"]]
|
||||||
|
cordapp project(':samples:notary-demo:contracts')
|
||||||
|
cordapp project(':samples:notary-demo:workflows')
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Alice Corp,L=Madrid,C=ES"
|
name "O=Alice Corp,L=Madrid,C=ES"
|
||||||
@ -150,7 +158,12 @@ task deployNodesBFT(type: Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
|||||||
def clusterAddresses = ["localhost:11000", "localhost:11010", "localhost:11020", "localhost:11030"]
|
def clusterAddresses = ["localhost:11000", "localhost:11010", "localhost:11020", "localhost:11030"]
|
||||||
directory file("$buildDir/nodes/nodesBFT")
|
directory file("$buildDir/nodes/nodesBFT")
|
||||||
nodeDefaults {
|
nodeDefaults {
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false
|
||||||
|
}
|
||||||
extraConfig = [h2Settings: [address: "localhost:0"]]
|
extraConfig = [h2Settings: [address: "localhost:0"]]
|
||||||
|
cordapp project(':samples:notary-demo:contracts')
|
||||||
|
cordapp project(':samples:notary-demo:workflows')
|
||||||
}
|
}
|
||||||
node {
|
node {
|
||||||
name "O=Alice Corp,L=Madrid,C=ES"
|
name "O=Alice Corp,L=Madrid,C=ES"
|
||||||
@ -231,22 +244,3 @@ task notarise(type: JavaExec) {
|
|||||||
classpath = sourceSets.main.runtimeClasspath
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
main = 'net.corda.notarydemo.NotariseKt'
|
main = 'net.corda.notarydemo.NotariseKt'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Automatic-Module-Name': 'net.corda.samples.demos.notary'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cordapp {
|
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
|
||||||
minimumPlatformVersion 1
|
|
||||||
workflow {
|
|
||||||
name "net/corda/samples/notary-demo"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
23
samples/notary-demo/contracts/build.gradle
Normal file
23
samples/notary-demo/contracts/build.gradle
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
description 'Corda Notary Demo - Contracts'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
cordaCompile project(':core')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
contract {
|
||||||
|
name "Corda Notary Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-notary-demo-contracts'
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package net.corda.notarydemo.contracts
|
||||||
|
|
||||||
|
import net.corda.core.contracts.BelongsToContract
|
||||||
|
import net.corda.core.contracts.CommandData
|
||||||
|
import net.corda.core.contracts.Contract
|
||||||
|
import net.corda.core.contracts.ContractState
|
||||||
|
import net.corda.core.identity.AbstractParty
|
||||||
|
import net.corda.core.transactions.LedgerTransaction
|
||||||
|
|
||||||
|
const val DO_NOTHING_PROGRAM_ID = "net.corda.notarydemo.contracts.DoNothingContract"
|
||||||
|
|
||||||
|
class DoNothingContract : Contract {
|
||||||
|
override fun verify(tx: LedgerTransaction) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
data class DummyCommand(val dummy: Int = 0) : CommandData
|
||||||
|
|
||||||
|
@BelongsToContract(DoNothingContract::class)
|
||||||
|
data class DummyState(override val participants: List<AbstractParty>, val discriminator: Int) : ContractState
|
27
samples/notary-demo/workflows/build.gradle
Normal file
27
samples/notary-demo/workflows/build.gradle
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
description 'Corda Notary Demo - Workflows'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
cordaCompile project(':core')
|
||||||
|
cordaCompile project(':client:rpc')
|
||||||
|
cordaCompile project(':node')
|
||||||
|
|
||||||
|
cordapp project(':samples:notary-demo:contracts')
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
workflow {
|
||||||
|
name "Corda Notary Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-notary-demo-workflows'
|
||||||
|
}
|
@ -2,7 +2,10 @@ package net.corda.notarydemo
|
|||||||
|
|
||||||
import net.corda.client.rpc.CordaRPCClient
|
import net.corda.client.rpc.CordaRPCClient
|
||||||
import net.corda.core.crypto.CompositeKey
|
import net.corda.core.crypto.CompositeKey
|
||||||
|
import net.corda.core.crypto.Crypto
|
||||||
import net.corda.core.crypto.toStringShort
|
import net.corda.core.crypto.toStringShort
|
||||||
|
import net.corda.core.identity.CordaX500Name
|
||||||
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.messaging.CordaRPCOps
|
import net.corda.core.messaging.CordaRPCOps
|
||||||
import net.corda.core.messaging.startFlow
|
import net.corda.core.messaging.startFlow
|
||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
@ -10,8 +13,6 @@ import net.corda.core.utilities.NetworkHostAndPort
|
|||||||
import net.corda.core.utilities.getOrThrow
|
import net.corda.core.utilities.getOrThrow
|
||||||
import net.corda.notarydemo.flows.DummyIssueAndMove
|
import net.corda.notarydemo.flows.DummyIssueAndMove
|
||||||
import net.corda.notarydemo.flows.RPCStartableNotaryFlowClient
|
import net.corda.notarydemo.flows.RPCStartableNotaryFlowClient
|
||||||
import net.corda.testing.core.BOB_NAME
|
|
||||||
import net.corda.testing.core.TestIdentity
|
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
@ -30,7 +31,8 @@ private class NotaryDemoClientApi(val rpc: CordaRPCOps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A dummy identity. */
|
/** A dummy identity. */
|
||||||
private val counterparty = TestIdentity(BOB_NAME).party
|
private val BOB_NAME = CordaX500Name("Bob Plc", "Rome", "IT")
|
||||||
|
private val counterparty = Party(BOB_NAME, Crypto.generateKeyPair(Crypto.DEFAULT_SIGNATURE_SCHEME).public)
|
||||||
|
|
||||||
/** Makes calls to the node rpc to start transaction notarisation. */
|
/** Makes calls to the node rpc to start transaction notarisation. */
|
||||||
fun notarise(count: Int) {
|
fun notarise(count: Int) {
|
@ -1,37 +1,22 @@
|
|||||||
package net.corda.notarydemo.flows
|
package net.corda.notarydemo.flows
|
||||||
|
|
||||||
import co.paralleluniverse.fibers.Suspendable
|
import co.paralleluniverse.fibers.Suspendable
|
||||||
import net.corda.core.contracts.BelongsToContract
|
|
||||||
import net.corda.core.contracts.CommandData
|
|
||||||
import net.corda.core.contracts.Contract
|
|
||||||
import net.corda.core.contracts.ContractState
|
import net.corda.core.contracts.ContractState
|
||||||
import net.corda.core.flows.FlowLogic
|
import net.corda.core.flows.FlowLogic
|
||||||
import net.corda.core.flows.StartableByRPC
|
import net.corda.core.flows.StartableByRPC
|
||||||
import net.corda.core.identity.AbstractParty
|
|
||||||
import net.corda.core.identity.Party
|
import net.corda.core.identity.Party
|
||||||
import net.corda.core.transactions.LedgerTransaction
|
|
||||||
import net.corda.core.transactions.SignedTransaction
|
import net.corda.core.transactions.SignedTransaction
|
||||||
import net.corda.core.transactions.TransactionBuilder
|
import net.corda.core.transactions.TransactionBuilder
|
||||||
|
import net.corda.notarydemo.contracts.DO_NOTHING_PROGRAM_ID
|
||||||
|
import net.corda.notarydemo.contracts.DummyCommand
|
||||||
|
import net.corda.notarydemo.contracts.DummyState
|
||||||
|
|
||||||
@StartableByRPC
|
@StartableByRPC
|
||||||
class DummyIssueAndMove(private val notary: Party, private val counterpartyNode: Party, private val discriminator: Int) : FlowLogic<SignedTransaction>() {
|
class DummyIssueAndMove(private val notary: Party, private val counterpartyNode: Party, private val discriminator: Int) : FlowLogic<SignedTransaction>() {
|
||||||
companion object {
|
|
||||||
private const val DO_NOTHING_PROGRAM_ID = "net.corda.notarydemo.flows.DummyIssueAndMove\$DoNothingContract"
|
|
||||||
}
|
|
||||||
|
|
||||||
class DoNothingContract : Contract {
|
|
||||||
override fun verify(tx: LedgerTransaction) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class DummyCommand(val dummy: Int = 0) : CommandData
|
|
||||||
|
|
||||||
@BelongsToContract(DoNothingContract::class)
|
|
||||||
data class State(override val participants: List<AbstractParty>, val discriminator: Int) : ContractState
|
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call(): SignedTransaction {
|
override fun call(): SignedTransaction {
|
||||||
// Self issue an asset
|
// Self issue an asset
|
||||||
val state = State(listOf(ourIdentity), discriminator)
|
val state = DummyState(listOf(ourIdentity), discriminator)
|
||||||
val issueTx = serviceHub.signInitialTransaction(TransactionBuilder(notary).apply {
|
val issueTx = serviceHub.signInitialTransaction(TransactionBuilder(notary).apply {
|
||||||
addOutputState(state, DO_NOTHING_PROGRAM_ID)
|
addOutputState(state, DO_NOTHING_PROGRAM_ID)
|
||||||
addCommand(DummyCommand(), listOf(ourIdentity.owningKey))
|
addCommand(DummyCommand(), listOf(ourIdentity.owningKey))
|
@ -1,24 +1,8 @@
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'net.corda.plugins.quasar-utils'
|
apply plugin: 'net.corda.plugins.quasar-utils'
|
||||||
apply plugin: 'net.corda.plugins.cordapp'
|
|
||||||
apply plugin: 'net.corda.plugins.cordformation'
|
apply plugin: 'net.corda.plugins.cordformation'
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
integrationTest {
|
|
||||||
kotlin {
|
|
||||||
compileClasspath += main.output + test.output
|
|
||||||
runtimeClasspath += main.output + test.output
|
|
||||||
srcDir file('src/integration-test/kotlin')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
integrationTestCompile.extendsFrom testCompile
|
|
||||||
integrationTestRuntime.extendsFrom testRuntime
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
|
||||||
@ -27,11 +11,11 @@ dependencies {
|
|||||||
cordapp project(':finance:workflows')
|
cordapp project(':finance:workflows')
|
||||||
cordapp project(':confidential-identities')
|
cordapp project(':confidential-identities')
|
||||||
cordapp project(':samples:bank-of-corda-demo')
|
cordapp project(':samples:bank-of-corda-demo')
|
||||||
|
cordapp project(':samples:trader-demo:workflows-trader')
|
||||||
|
|
||||||
// Corda integration dependencies
|
// Corda integration dependencies
|
||||||
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":node:capsule", configuration: 'runtimeArtifacts')
|
||||||
cordaRuntime project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
|
cordaRuntime project(path: ":webserver:webcapsule", configuration: 'runtimeArtifacts')
|
||||||
cordaCompile project(':core')
|
|
||||||
|
|
||||||
testCompile project(':test-utils')
|
testCompile project(':test-utils')
|
||||||
testCompile "junit:junit:$junit_version"
|
testCompile "junit:junit:$junit_version"
|
||||||
@ -43,9 +27,13 @@ def webTask = tasks.getByPath(':webserver:webcapsule:assemble')
|
|||||||
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask, webTask]) {
|
||||||
ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["ALL"]]]
|
ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["ALL"]]]
|
||||||
nodeDefaults {
|
nodeDefaults {
|
||||||
|
projectCordapp {
|
||||||
|
deploy = false // TODO This is a bug, project cordapp should be disabled if no cordapp plugin is applied.
|
||||||
|
}
|
||||||
cordapp project(':finance:workflows')
|
cordapp project(':finance:workflows')
|
||||||
cordapp project(':finance:contracts')
|
cordapp project(':finance:contracts')
|
||||||
cordapp project(':confidential-identities')
|
cordapp project(':confidential-identities')
|
||||||
|
cordapp project(':samples:trader-demo:workflows-trader')
|
||||||
}
|
}
|
||||||
directory "./build/nodes"
|
directory "./build/nodes"
|
||||||
node {
|
node {
|
||||||
@ -103,11 +91,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar', nodeTask,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task integrationTest(type: Test, dependsOn: []) {
|
|
||||||
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
|
||||||
classpath = sourceSets.integrationTest.runtimeClasspath
|
|
||||||
}
|
|
||||||
|
|
||||||
idea {
|
idea {
|
||||||
module {
|
module {
|
||||||
downloadJavadoc = true // defaults to false
|
downloadJavadoc = true // defaults to false
|
||||||
@ -128,22 +111,3 @@ task runSeller(type: JavaExec) {
|
|||||||
args '--role'
|
args '--role'
|
||||||
args 'SELLER'
|
args 'SELLER'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Automatic-Module-Name': 'net.corda.samples.demos.trader'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cordapp {
|
|
||||||
targetPlatformVersion corda_platform_version.toInteger()
|
|
||||||
minimumPlatformVersion 1
|
|
||||||
workflow {
|
|
||||||
name "net/corda/samples/trader-demo"
|
|
||||||
versionId 1
|
|
||||||
vendor "R3"
|
|
||||||
licence "Open Source (Apache 2)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
59
samples/trader-demo/workflows-trader/build.gradle
Normal file
59
samples/trader-demo/workflows-trader/build.gradle
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
apply plugin: 'kotlin'
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'net.corda.plugins.quasar-utils'
|
||||||
|
apply plugin: 'net.corda.plugins.cordapp'
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
integrationTest {
|
||||||
|
kotlin {
|
||||||
|
compileClasspath += main.output + test.output
|
||||||
|
runtimeClasspath += main.output + test.output
|
||||||
|
srcDir file('src/integration-test/kotlin')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
integrationTestCompile.extendsFrom testCompile
|
||||||
|
integrationTestRuntime.extendsFrom testRuntime
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
|
|
||||||
|
// The trader demo CorDapp depends upon Cash CorDapp features
|
||||||
|
cordapp project(':finance:contracts')
|
||||||
|
cordapp project(':finance:workflows')
|
||||||
|
cordapp project(':confidential-identities')
|
||||||
|
cordapp project(':samples:bank-of-corda-demo')
|
||||||
|
|
||||||
|
// Corda integration dependencies
|
||||||
|
cordaCompile project(':core')
|
||||||
|
|
||||||
|
testCompile project(':test-utils')
|
||||||
|
testCompile "junit:junit:$junit_version"
|
||||||
|
testCompile "org.assertj:assertj-core:${assertj_version}"
|
||||||
|
|
||||||
|
integrationTestCompile project(':finance:workflows')
|
||||||
|
integrationTestCompile project(':finance:contracts')
|
||||||
|
}
|
||||||
|
|
||||||
|
task integrationTest(type: Test, dependsOn: []) {
|
||||||
|
testClassesDirs = sourceSets.integrationTest.output.classesDirs
|
||||||
|
classpath = sourceSets.integrationTest.runtimeClasspath
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName 'corda-trader-demo-workflows'
|
||||||
|
}
|
||||||
|
|
||||||
|
cordapp {
|
||||||
|
targetPlatformVersion corda_platform_version.toInteger()
|
||||||
|
minimumPlatformVersion 1
|
||||||
|
workflow {
|
||||||
|
name "Trader Demo"
|
||||||
|
versionId 1
|
||||||
|
vendor "R3"
|
||||||
|
licence "Open Source (Apache 2)"
|
||||||
|
}
|
||||||
|
}
|
@ -14,7 +14,6 @@ import net.corda.testing.driver.DriverParameters
|
|||||||
import net.corda.testing.driver.InProcess
|
import net.corda.testing.driver.InProcess
|
||||||
import net.corda.testing.driver.OutOfProcess
|
import net.corda.testing.driver.OutOfProcess
|
||||||
import net.corda.testing.driver.driver
|
import net.corda.testing.driver.driver
|
||||||
import net.corda.testing.node.NotarySpec
|
|
||||||
import net.corda.testing.node.TestCordapp
|
import net.corda.testing.node.TestCordapp
|
||||||
import net.corda.testing.node.User
|
import net.corda.testing.node.User
|
||||||
import net.corda.testing.node.internal.FINANCE_CORDAPPS
|
import net.corda.testing.node.internal.FINANCE_CORDAPPS
|
@ -48,18 +48,22 @@ include 'tools:network-bootstrapper'
|
|||||||
include 'tools:cliutils'
|
include 'tools:cliutils'
|
||||||
include 'example-code'
|
include 'example-code'
|
||||||
project(':example-code').projectDir = file("$settingsDir/docs/source/example-code")
|
project(':example-code').projectDir = file("$settingsDir/docs/source/example-code")
|
||||||
include 'samples:attachment-demo'
|
include 'samples:attachment-demo:contracts'
|
||||||
include 'samples:trader-demo'
|
include 'samples:attachment-demo:workflows'
|
||||||
|
include 'samples:trader-demo:workflows-trader'
|
||||||
include 'samples:irs-demo'
|
include 'samples:irs-demo'
|
||||||
include 'samples:irs-demo:cordapp'
|
include 'samples:irs-demo:cordapp:contracts-irs'
|
||||||
|
include 'samples:irs-demo:cordapp:workflows-irs'
|
||||||
include 'samples:irs-demo:web'
|
include 'samples:irs-demo:web'
|
||||||
include 'samples:simm-valuation-demo'
|
include 'samples:simm-valuation-demo'
|
||||||
include 'samples:simm-valuation-demo:flows'
|
include 'samples:simm-valuation-demo:flows'
|
||||||
include 'samples:simm-valuation-demo:contracts-states'
|
include 'samples:simm-valuation-demo:contracts-states'
|
||||||
include 'samples:notary-demo'
|
include 'samples:notary-demo:contracts'
|
||||||
|
include 'samples:notary-demo:workflows'
|
||||||
include 'samples:bank-of-corda-demo'
|
include 'samples:bank-of-corda-demo'
|
||||||
include 'samples:cordapp-configuration'
|
include 'samples:cordapp-configuration:workflows'
|
||||||
include 'samples:network-verifier'
|
include 'samples:network-verifier:contracts'
|
||||||
|
include 'samples:network-verifier:workflows'
|
||||||
include 'serialization'
|
include 'serialization'
|
||||||
|
|
||||||
// Common libraries - start
|
// Common libraries - start
|
||||||
|
Loading…
Reference in New Issue
Block a user