Skip to content

Commit 00e37d9

Browse files
authored
Merge pull request #37 from corda/featuresrevamp
merge Feature cordapp revamp into Q4 cleanup
2 parents 2d243bd + ef7c12f commit 00e37d9

File tree

203 files changed

+2699
-1510
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+2699
-1510
lines changed

Features/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
1-
## samples-java/feature-specific-cordapps
1+
## Feature Specific Cordapps
22

33
This folder features several sample projects, each of them demonstrates different specific features of corda.
44

5-
### [attachment-blacklist](./attachment-blacklist):
5+
### [Blacklist -- Attachment](./attachment-blacklist):
66
This CorDapp allows nodes to reach agreement over arbitrary strings of text, but only with parties that are not included in the blacklist uploaded to the nodes as an [attachment](https://training.corda.net/corda-details/attachments/).
7-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/attachment-blacklist)
87

9-
### [attachment-sendfile](./attachment-sendfile):
8+
### [Sendfile -- Attachment](./attachment-sendfile):
109
This Cordapp shows how to upload and download an [attachment](https://training.corda.net/corda-details/attachments/) via a flow.
11-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/attachment-sendfile)
10+
<p align="center">
11+
<img src="./attachment-sendfile/graph.png" alt="Corda" width="700">
12+
</p>
1213

13-
### [confidential identity whistleblower](./confidentialidentity-whistleblower):
14+
### [Whistleblower -- Confidential Identity ](./confidentialidentity-whistleblower):
1415
This CorDapp is a simple showcase of [confidential identities](https://docs.corda.net/docs/corda-os/api-identity.html#confidential-identities) (i.e. anonymous public keys).
15-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/confidentialidentity-whistleblower)
1616

17-
### [service autopayroll](./cordaservice-autopayroll):
17+
### [Autopayroll -- CordaService](./cordaservice-autopayroll):
1818
This Cordapp shows how to trigger a flow with vault update(completion of prior flows) using [CordaService](https://training.corda.net/corda-details/automation/#services) & [trackby](https://training.corda.net/corda-details/automation-solution/#track-and-notify).
19-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/cordaservice-autopayroll)
19+
<p align="center">
20+
<img src="./cordaservice-autopayroll/webpic/Business%20Logic.png" alt="Corda" width="500">
21+
</p>
2022

21-
### [observable states trade reporting](./observablestates-tradereporting):
23+
### [Trade Reporting -- ObservableStates](./observablestates-tradereporting):
2224
This CorDapp shows how Corda's [observable states](https://docs.corda.net/docs/corda-os/4.4/tutorial-observer-nodes.html#observer-nodes) feature works. Observable states is the ability for nodes who are not participants in a transaction to still store them if the transactions are sent to them.
23-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/observablestates-tradereporting)
2425

25-
### [oracle prime number](./oracle-primenumber):
26+
### [Prime Number -- Oracle](./oracle-primenumber):
2627
This CorDapp implements an [oracle service](https://training.corda.net/corda-details/oracles) that allows nodes to:
2728

2829
* Request the Nth prime number
2930
* Request the oracle's signature to prove that the number included in their transaction is actually the Nth prime number
3031

31-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/oracle-primenumber)
3232

33-
### [queryable state car insurance](./queryablestate-carinsurance):
33+
### [Car Insurance -- QueryableState](./queryablestate-carinsurance):
3434
This CorDapp demonstrates [QueryableState](https://docs.corda.net/docs/corda-os/api-persistence.html) works in Corda. Corda allows developers to have the ability to expose some or all parts of their states to a custom database table using an ORM tools. To support this feature the state must implement `QueryableState`.
35-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/queryablestate-carinsurance)
3635

37-
### [reference states and sanctionsbody](./referencestates-sanctionsbody):
36+
### [Sanctionsbody -- ReferenceStates](./referencestates-sanctionsbody):
3837
This CorDapp demonstrates the use of [reference states](https://training.corda.net/corda-details/reference-states/) in a transaction and in the verification method of a contract.
3938

4039
This CorDapp allows two nodes to enter into an IOU agreement, but enforces that both parties belong to a list of sanctioned entities. This list of sanctioned entities is taken from a referenced SanctionedEntities state.
41-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/referencestates-sanctionsbody)
4240

43-
### [heartbeat schedulable state](./schedulablestate-heartbeat):
41+
### [Heartbeat -- SchedulableState](./schedulablestate-heartbeat):
4442
This CorDapp is a simple showcase of [scheduled activities](https://docs.corda.net/docs/corda-os/event-scheduling.html#how-to-implement-scheduled-events) (i.e. activities started by a node at a specific time without direct input from the node owner).
45-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/schedulablestate-heartbeat)
46-
43+
<p align="center">
44+
<img src="./schedulablestate-heartbeat/heart.jpg" alt="Corda" width="500">
45+
</p>

Features/attachment-blacklist/README.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# blacklist cordapp [<img src="../../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Features/attachment-blacklist)
1+
# Blacklist -- Attachment
22

33
This CorDapp allows nodes to reach agreement over arbitrary strings of text, but only with parties that are not included in the blacklist uploaded to the nodes as an [attachment](https://training.corda.net/corda-details/attachments/).
44

@@ -15,22 +15,15 @@ parties as being banned from entering into agreements:
1515
* Tifton Banking Company
1616

1717
The blacklist jar is uploaded as an attachment when building a transaction, and used in the `AgreementContract` to
18-
check that the parties to the `AgreementState` are not blacklisted.
19-
20-
### Flows
21-
22-
There aren't many flows here, so it's quick to cover.
23-
24-
There's a [proposal](./workflows/src/main/java/net/corda/examples/attachments/ProposeFlow.java) and [acceptance](./workflows/src/main/java/net/corda/examples/attachments/AgreeFlow.java) flow, and the blacklist is added as an attachment [here](./workflows/src/main/java/net/corda/examples/attachments/ProposeFlow.java#L47-L50).
18+
check that the parties to the `AgreementState` are not blacklisted. There aren't many flows here, so it's quick to cover. There's a proposal and acceptance flow, and the blacklist is added as an attachment.
2519

2620

2721

2822
## Usage
2923

24+
## Pre-Requisites
3025

31-
### Pre-requisites:
32-
33-
See https://docs.corda.net/getting-set-up.html.
26+
For development environment setup, please refer to: [Setup Guide](https://docs.corda.net/getting-set-up.html).
3427

3528

3629
### Running the CorDapp
@@ -54,8 +47,8 @@ be able to *initiate* an agreement. The blacklist can be uploaded via [RPC](http
5447
project's root folder:
5548

5649
Java version
57-
* Unix/Mac OSX: ` ./gradlew clients-java:uploadBlacklist`
58-
* Windows: `gradlew clients-java:uploadBlacklist`
50+
* Unix/Mac OSX: ` ./gradlew uploadBlacklist`
51+
* Windows: `gradlew uploadBlacklist`
5952

6053
Or by running the `Upload blacklist` run configuration from IntelliJ.
6154

@@ -71,7 +64,7 @@ the shell of Monogram Bank:
7164

7265
start ProposeFlow agreementTxt: "A and B agree Y", counterparty: "Hiseville Deposit Bank", untrustedPartiesAttachment: "4CEC607599723D7E0393EB5F05F24562732CD1B217DEAEDEABD4C25AFE5B333A"
7366

74-
If you now run `run vaultQuery contractStateType: net.corda.examples.attachments.states.AgreementState` on either the
67+
If you now run `run vaultQuery contractStateType: net.corda.samples.blacklist.states.AgreementState` on either the
7568
Monogram Bank or Hiseville Deposit Bank node, you should see the agreement stored:
7669

7770
data: !<net.corda.examples.attachments.state.AgreementState>

Features/attachment-blacklist/build.gradle

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ buildscript {
44

55
ext {
66
corda_release_group = constants.getProperty("cordaReleaseGroup")
7+
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
78
corda_release_version = constants.getProperty("cordaVersion")
9+
corda_core_release_version = constants.getProperty("cordaCoreVersion")
810
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
11+
kotlin_version = constants.getProperty("kotlinVersion")
912
junit_version = constants.getProperty("junitVersion")
1013
quasar_version = constants.getProperty("quasarVersion")
1114
log4j_version = constants.getProperty("log4jVersion")
1215
slf4j_version = constants.getProperty("slf4jVersion")
13-
corda_platform_version = constants.getProperty("platformVersion")
16+
corda_platform_version = constants.getProperty("platformVersion").toInteger()
1417
spring_boot_version = '2.0.2.RELEASE'
1518
ext.spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
1619
}
@@ -31,6 +34,8 @@ buildscript {
3134
}
3235

3336
allprojects {
37+
apply from: "${rootProject.projectDir}/repositories.gradle"
38+
apply plugin: 'java'
3439

3540
repositories {
3641
mavenLocal()
@@ -53,4 +58,86 @@ allprojects {
5358
options.compilerArgs << "-parameters" // Required for shell commands.
5459
}
5560

56-
}
61+
jar {
62+
// This makes the JAR's SHA-256 hash repeatable.
63+
preserveFileTimestamps = false
64+
reproducibleFileOrder = true
65+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
66+
}
67+
}
68+
69+
apply plugin: 'net.corda.plugins.cordapp'
70+
apply plugin: 'net.corda.plugins.quasar-utils'
71+
apply plugin: 'net.corda.plugins.cordformation'
72+
73+
sourceSets {
74+
main {
75+
resources {
76+
srcDir rootProject.file("config/dev")
77+
}
78+
}
79+
}
80+
81+
//Module dependencis
82+
dependencies {
83+
// Corda dependencies.
84+
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
85+
cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
86+
cordaRuntime "$corda_release_group:corda:$corda_release_version"
87+
88+
// CorDapp dependencies.
89+
cordapp project(":workflows")
90+
cordapp project(":contracts")
91+
92+
cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
93+
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
94+
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
95+
}
96+
97+
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
98+
nodeDefaults {
99+
cordapp project(':workflows')
100+
cordapp project(':contracts')
101+
runSchemaMigration = true
102+
}
103+
104+
node {
105+
name "O=Notary,L=London,C=GB"
106+
notary = [validating: false]
107+
p2pPort 10002
108+
rpcSettings {
109+
address("localhost:10003")
110+
adminAddress("localhost:10043")
111+
}
112+
}
113+
114+
node {
115+
name "O=Monogram Bank,L=London,C=GB"
116+
p2pPort 10005
117+
rpcSettings {
118+
address("localhost:10006")
119+
adminAddress("localhost:10046")
120+
}
121+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
122+
}
123+
124+
node {
125+
name "O=Hiseville Deposit Bank,L=Sao Paulo,C=BR"
126+
p2pPort 10008
127+
rpcSettings {
128+
address("localhost:10009")
129+
adminAddress("localhost:10049")
130+
}
131+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
132+
}
133+
134+
node {
135+
name "O=George State Bank,L=New York,C=US"
136+
p2pPort 10011
137+
rpcSettings {
138+
address("localhost:10012")
139+
adminAddress("localhost:10052")
140+
}
141+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
142+
}
143+
}

Features/attachment-blacklist/clients/build.gradle

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,11 @@ dependencies {
2727
}
2828

2929
springBoot {
30-
mainClassName = "net.corda.examples.attachments.webserver.Server"
31-
}
32-
33-
task runWebServer(type: JavaExec, dependsOn: assemble) {
34-
classpath = sourceSets.main.runtimeClasspath
35-
main = 'net.corda.examples.attachments.webserver.Starter'
36-
args '--server.port=10050', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test'
30+
mainClassName = "net.corda.samples.blacklist.webserver.Server"
3731
}
3832

3933
task uploadBlacklist(type: JavaExec, dependsOn: assemble) {
4034
classpath = sourceSets.main.runtimeClasspath
41-
main = 'net.corda.examples.attachments.client.Client'
35+
main = 'net.corda.samples.blacklist.client.Client'
4236
args 'localhost:10006', 'localhost:10009', 'localhost:10012'
4337
}

Features/attachment-blacklist/clients/src/main/java/net/corda/examples/attachments/client/Client.java renamed to Features/attachment-blacklist/clients/src/main/java/net/corda/samples/blacklist/client/Client.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package net.corda.examples.attachments.client;
1+
package net.corda.samples.blacklist.client;
22

33
import com.google.common.base.Charsets;
44
import net.corda.client.rpc.CordaRPCClient;
55
import net.corda.client.rpc.CordaRPCConnection;
66
import net.corda.core.crypto.SecureHash;
77
import net.corda.core.messaging.CordaRPCOps;
88
import net.corda.core.utilities.NetworkHostAndPort;
9+
import net.corda.samples.blacklist.Constants;
910
import org.slf4j.Logger;
1011
import org.slf4j.LoggerFactory;
1112

@@ -15,8 +16,6 @@
1516
import java.util.jar.JarInputStream;
1617
import java.util.stream.Collectors;
1718

18-
import static net.corda.examples.attachments.Constants.*;
19-
2019
public class Client {
2120

2221
private static class Companion {
@@ -37,13 +36,13 @@ public static void main(String[] args) throws IOException {
3736
CordaRPCConnection rpcConnection = new CordaRPCClient(nodeAddress).start("user1", "test");
3837
CordaRPCOps proxy = rpcConnection.getProxy();
3938

40-
SecureHash attachmentHash = BLACKLIST_JAR_HASH;
39+
SecureHash attachmentHash = Constants.BLACKLIST_JAR_HASH;
4140

4241
// take relative path using substring of constant BLACKLIST_JAR_PATH, check if node contains blacklist already
4342
if (!proxy.attachmentExists(attachmentHash)) {
4443
System.out.println("Working Directory = " +
4544
System.getProperty("user.dir"));
46-
attachmentHash = uploadAttachment(proxy, BLACKLIST_JAR_PATH);
45+
attachmentHash = uploadAttachment(proxy, Constants.BLACKLIST_JAR_PATH);
4746
Companion.logger.info("Blacklist uploaded to node at " + nodeAddress);
4847
} else {
4948
Companion.logger.info("Node already contains Blacklist, skipping upload at " + nodeAddress);
@@ -52,7 +51,7 @@ public static void main(String[] args) throws IOException {
5251
JarInputStream attachmentJar = downloadAttachment(proxy, attachmentHash);
5352
Companion.logger.info("Blacklist downloaded from node at " + nodeAddress);
5453

55-
checkAttachment(attachmentJar, ATTACTMENT_FILE_NAME, ATTACHMENT_EXPECTED_CONTENTS);
54+
checkAttachment(attachmentJar, Constants.ATTACTMENT_FILE_NAME, Constants.ATTACHMENT_EXPECTED_CONTENTS);
5655
Companion.logger.info("Attachment contents checked on node at " + nodeAddress);
5756
}
5857

@@ -83,7 +82,7 @@ private static void checkAttachment(JarInputStream attachmentJar, String expecte
8382
name = attachmentJar.getNextEntry().getName();
8483
}
8584

86-
BufferedInputStream bisAttachmentJar = new BufferedInputStream(attachmentJar, (8*1024));
85+
BufferedInputStream bisAttachmentJar = new BufferedInputStream(attachmentJar, (8 * 1024));
8786
InputStreamReader isrAttachmentJar = new InputStreamReader(bisAttachmentJar, Charsets.UTF_8);
8887
BufferedReader brAttachmentJar = new BufferedReader(isrAttachmentJar);
8988

Features/attachment-blacklist/contracts/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cordapp {
1010
targetPlatformVersion corda_platform_version.toInteger()
1111
minimumPlatformVersion corda_platform_version.toInteger()
1212
contract {
13-
name "Blacklist"
13+
name "Attachments Blacklist"
1414
vendor "Corda Open Source"
1515
licence "Apache License, Version 2.0"
1616
versionId 1
@@ -28,4 +28,4 @@ dependencies {
2828
cordaCompile "$corda_release_group:corda-rpc:$corda_release_version"
2929
cordaRuntime "$corda_release_group:corda:$corda_release_version"
3030

31-
}
31+
}

Features/attachment-blacklist/contracts/src/main/java/net/corda/examples/attachments/Constants.java renamed to Features/attachment-blacklist/contracts/src/main/java/net/corda/samples/blacklist/Constants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.attachments;
1+
package net.corda.samples.blacklist;
22

33
import net.corda.core.crypto.SecureHash;
44

@@ -25,4 +25,4 @@ public interface Constants {
2525
);
2626
// This jar exists, but does not meet the constraints imposed by AttachmentContract.
2727
String INCORRECT_JAR_PATH = "src/test/resources/invalid.jar";
28-
}
28+
}

Features/attachment-blacklist/contracts/src/main/java/net/corda/examples/attachments/contracts/AgreementContract.java renamed to Features/attachment-blacklist/contracts/src/main/java/net/corda/samples/blacklist/contracts/AgreementContract.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
package net.corda.examples.attachments.contracts;
1+
package net.corda.samples.blacklist.contracts;
22

33
import com.google.common.base.Charsets;
44
import net.corda.core.contracts.*;
55
import net.corda.core.crypto.SecureHash;
66
import net.corda.core.identity.AbstractParty;
77
import net.corda.core.identity.Party;
88
import net.corda.core.transactions.LedgerTransaction;
9-
import net.corda.examples.attachments.states.AgreementState;
9+
import net.corda.samples.blacklist.states.AgreementState;
1010

1111
import java.io.BufferedReader;
1212
import java.io.IOException;
@@ -20,7 +20,7 @@
2020
import java.util.stream.Collectors;
2121

2222
public class AgreementContract implements Contract {
23-
public static final String AGREEMENT_CONTRACT_ID = "net.corda.examples.attachments.contracts.AgreementContract";
23+
public static final String AGREEMENT_CONTRACT_ID = "net.corda.samples.blacklist.contracts.AgreementContract";
2424
private static SecureHash BLACKLIST_JAR_HASH = SecureHash.parse("4CEC607599723D7E0393EB5F05F24562732CD1B217DEAEDEABD4C25AFE5B333A");
2525

2626
@Override
@@ -40,7 +40,7 @@ public void verify(LedgerTransaction tx) {
4040
return null;
4141
});
4242

43-
// Constraints on the included attachments.
43+
// Constraints on the included blacklist.
4444
List<Attachment> nonContractAttachments = tx.getAttachments()
4545
.stream()
4646
.filter(p -> !(p instanceof ContractAttachment))
@@ -55,7 +55,7 @@ public void verify(LedgerTransaction tx) {
5555

5656
// TODO: Switch to constraint on the jar's signer.
5757
// In the future, Corda will support singing of jars. We will then be able to restrict
58-
// the attachments used to just those signed by party X.
58+
// the blacklist used to just those signed by party X.
5959
req.using("The jar's hash should be correct", attached.getId().equals(BLACKLIST_JAR_HASH));
6060
return null;
6161
});
@@ -118,6 +118,7 @@ public void verify(LedgerTransaction tx) {
118118
}
119119

120120
public interface Commands extends CommandData {
121-
class Agree extends TypeOnlyCommandData implements Commands {}
121+
class Agree extends TypeOnlyCommandData implements Commands {
122+
}
122123
}
123124
}

0 commit comments

Comments
 (0)