Skip to content

Commit 103525d

Browse files
committed
Merge branch 'master' of github.com:corda/samples-java
2 parents 72ea215 + 0cfe97a commit 103525d

File tree

35 files changed

+1381
-103
lines changed

35 files changed

+1381
-103
lines changed

Accounts/constants.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cordaReleaseGroup=net.corda
22
cordaCoreReleaseGroup=net.corda
3-
cordaVersion=4.5-RC02
4-
cordaCoreVersion=4.5-RC02
3+
cordaVersion=4.5
4+
cordaCoreVersion=4.5
55
gradlePluginsVersion=5.0.10
66
kotlinVersion=1.2.71
77
junitVersion=4.12

Accounts/worldcupticketbooking/build.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ buildscript {
2525
confidential_id_release_version = "1.0"
2626

2727
//tokens
28-
tokens_release_version = '1.1'
28+
tokens_release_version = '1.2'
2929
tokens_release_group = 'com.r3.corda.lib.tokens'
3030

3131
//springboot
@@ -116,8 +116,6 @@ dependencies {
116116
//tokens
117117
cordapp "$tokens_release_group:tokens-contracts:$tokens_release_version"
118118
cordapp "$tokens_release_group:tokens-workflows:$tokens_release_version"
119-
cordapp "$tokens_release_group:tokens-money:$tokens_release_version"
120-
cordapp "$tokens_release_group:tokens-selection:$tokens_release_version"
121119

122120

123121
}
@@ -161,8 +159,6 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
161159
//tokens
162160
cordapp("$tokens_release_group:tokens-contracts:$tokens_release_version")
163161
cordapp("$tokens_release_group:tokens-workflows:$tokens_release_version")
164-
cordapp("$tokens_release_group:tokens-money:$tokens_release_version")
165-
cordapp("$tokens_release_group:tokens-selection:$tokens_release_version")
166162
}
167163
node {
168164
name "O=Notary,L=London,C=GB"

Accounts/worldcupticketbooking/workflows/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ dependencies {
6565

6666

6767
// Token SDK dependencies.
68-
cordaCompile "$tokens_release_group:tokens-money:$tokens_release_version"
6968
cordaCompile "$tokens_release_group:tokens-workflows:$tokens_release_version"
7069
cordaCompile "$tokens_release_group:tokens-contracts:$tokens_release_version"
71-
cordapp "$tokens_release_group:tokens-selection:$tokens_release_version"
7270

7371
}
7472

Accounts/worldcupticketbooking/workflows/src/main/java/com/t20worldcup/flows/DVPAccountsHostedOnDifferentNodes.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
import co.paralleluniverse.fibers.Suspendable;
55
import com.r3.corda.lib.tokens.contracts.states.NonFungibleToken;
6-
import com.r3.corda.lib.tokens.workflows.utilities.QueryUtilitiesKt;
6+
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilities;
7+
import com.r3.corda.lib.tokens.workflows.utilities.QueryUtilities;
78
import com.t20worldcup.states.T20CricketTicket;
89
import com.r3.corda.lib.accounts.contracts.states.AccountInfo;
910
import com.r3.corda.lib.accounts.workflows.UtilitiesKt;
@@ -17,7 +18,6 @@
1718
import com.r3.corda.lib.tokens.selection.TokenQueryBy;
1819
import com.r3.corda.lib.tokens.selection.database.config.DatabaseSelectionConfigKt;
1920
import com.r3.corda.lib.tokens.selection.database.selector.DatabaseTokenSelection;
20-
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilitiesKt;
2121
import kotlin.Pair;
2222
import net.corda.core.contracts.*;
2323
import net.corda.core.flows.*;
@@ -94,7 +94,7 @@ public String call() throws FlowException {
9494
Amount<FiatCurrency> amount = new Amount(costOfTicket, FiatCurrency.Companion.getInstance(currency));
9595

9696
//Buyer Query for token balance.
97-
QueryCriteria queryCriteria = QueryUtilitiesKt.heldTokenAmountCriteria(this.getInstance(currency), buyerAccount).and(QueryUtilitiesKt.sumTokenCriteria());
97+
QueryCriteria queryCriteria = QueryUtilities.heldTokenAmountCriteria(this.getInstance(currency), buyerAccount).and(QueryUtilities.sumTokenCriteria());
9898
List<Object> sum = getServiceHub().getVaultService().queryBy(FungibleToken.class, queryCriteria).component5();
9999
if(sum.size() == 0)
100100
throw new FlowException(buyerAccountName + " has 0 token balance. Please ask the Bank to issue some cash.");
@@ -240,10 +240,10 @@ public Void call() throws FlowException {
240240
TransactionBuilder transactionBuilder = new TransactionBuilder(notary);
241241

242242
//part1 of DVP is to transfer the non fungible token from seller to buyer
243-
MoveTokensUtilitiesKt.addMoveNonFungibleTokens(transactionBuilder, getServiceHub(), tokenPointer, buyerAccount);
243+
MoveTokensUtilities.addMoveNonFungibleTokens(transactionBuilder, getServiceHub(), tokenPointer, buyerAccount);
244244

245245
//part2 of DVP is to transfer cash - fungible token from buyer to seller and return the change to buyer
246-
MoveTokensUtilitiesKt.addMoveTokens(transactionBuilder, inputs, moneyReceived);
246+
MoveTokensUtilities.addMoveTokens(transactionBuilder, inputs, moneyReceived);
247247

248248
//sync keys with buyer, again sync for similar members
249249

Accounts/worldcupticketbooking/workflows/src/main/java/com/t20worldcup/flows/DVPAccountsOnSameNode.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import com.r3.corda.lib.tokens.contracts.states.FungibleToken;
66
import com.r3.corda.lib.tokens.contracts.states.NonFungibleToken;
77
import com.r3.corda.lib.tokens.contracts.types.TokenType;
8-
import com.r3.corda.lib.tokens.workflows.utilities.QueryUtilitiesKt;
8+
import com.r3.corda.lib.tokens.workflows.utilities.QueryUtilities;
99
import com.t20worldcup.states.T20CricketTicket;
1010
import com.r3.corda.lib.accounts.contracts.states.AccountInfo;
1111
import com.r3.corda.lib.accounts.workflows.UtilitiesKt;
1212
import com.r3.corda.lib.accounts.workflows.flows.RequestKeyForAccount;
1313
import com.r3.corda.lib.tokens.contracts.types.TokenPointer;
1414
import com.r3.corda.lib.tokens.money.FiatCurrency;
15-
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilitiesKt;
15+
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilities;
1616
import com.r3.corda.lib.tokens.workflows.internal.flows.finality.ObserverAwareFinalityFlow;
1717
import com.r3.corda.lib.tokens.workflows.types.PartyAndAmount;
1818
import net.corda.core.contracts.Amount;
@@ -21,6 +21,7 @@
2121
import net.corda.core.identity.AnonymousParty;
2222
import net.corda.core.identity.Party;
2323
import net.corda.core.node.services.Vault;
24+
import net.corda.core.node.services.VaultService;
2425
import net.corda.core.node.services.vault.QueryCriteria;
2526
import net.corda.core.transactions.SignedTransaction;
2627
import net.corda.core.transactions.TransactionBuilder;
@@ -31,6 +32,8 @@
3132
import java.util.List;
3233
import java.util.UUID;
3334

35+
import static com.r3.corda.lib.tokens.workflows.utilities.QueryUtilities.rowsToAmount;
36+
3437
/**
3538
* This is the DVP flow, where the buyer account buys the ticket token from the dealer account and in turn transfers him cash worth of the ticket.
3639
* Once buyer1 buys the token from the dealer, he can further sell this ticket to other buyers.
@@ -118,22 +121,26 @@ public String call() throws FlowException {
118121

119122
//first part of DVP is to transfer the non fungible token from seller to buyer
120123
//this add inputs and outputs to transactionBuilder
121-
MoveTokensUtilitiesKt.addMoveNonFungibleTokens(transactionBuilder, getServiceHub(), tokenPointer, buyerAccount);
124+
MoveTokensUtilities.addMoveNonFungibleTokens(transactionBuilder, getServiceHub(), tokenPointer, buyerAccount);
122125

123126
//Part2 : Move fungible token - cash from buyer to seller
127+
QueryCriteria queryCriteriaForTokenBalance = QueryUtilities.heldTokenAmountCriteria(this.getInstance(currency), buyerAccount)
128+
.and(QueryUtilities.sumTokenCriteria());
129+
130+
VaultService vaultService = getServiceHub().getVaultService();
131+
Amount<TokenType> rot = rowsToAmount(this.getInstance(currency), vaultService.queryBy(FungibleToken.class,queryCriteriaForTokenBalance));
132+
int fundsAvailable = rot.compareTo(new Amount<TokenType>(this.costOfTicket,this.getInstance(currency)));
124133

125-
QueryCriteria queryCriteriaForTokenBalance = QueryUtilitiesKt.heldTokenAmountCriteria(this.getInstance(currency), buyerAccount).and(QueryUtilitiesKt.sumTokenCriteria());
126134

127-
List<Object> sum = getServiceHub().getVaultService().
128-
queryBy(FungibleToken.class, queryCriteriaForTokenBalance).component5();
135+
//List<Object> sum = getServiceHub().getVaultService().queryBy(FungibleToken.class, queryCriteriaForTokenBalance).component5();
129136

130-
if(sum.size() == 0)
137+
if(fundsAvailable < 0)
131138
throw new FlowException(buyerAccountName + "has 0 token balance. Please ask the Bank to issue some cash.");
132-
else {
133-
Long tokenBalance = (Long) sum.get(0);
134-
if(tokenBalance < costOfTicket)
135-
throw new FlowException("Available token balance of " + buyerAccountName+ " is less than the cost of the ticket. Please ask the Bank to issue some cash if you wish to buy the ticket ");
136-
}
139+
// else {
140+
// Long tokenBalance = (Long) sum.get(0);
141+
// if(tokenBalance < costOfTicket)
142+
// throw new FlowException("Available token balance of " + buyerAccountName+ " is less than the cost of the ticket. Please ask the Bank to issue some cash if you wish to buy the ticket ");
143+
// }
137144

138145
Amount<FiatCurrency> amount = new Amount(costOfTicket, FiatCurrency.Companion.getInstance(currency));
139146

@@ -147,7 +154,7 @@ public String call() throws FlowException {
147154
//call utility function to move the fungible token from buyer to seller account
148155
//this also adds inputs and outputs to the transactionBuilder
149156
//till now we have only 1 transaction with 2 inputs and 2 outputs - one moving fungible tokens other moving non fungible tokens between accounts
150-
MoveTokensUtilitiesKt.addMoveFungibleTokens(transactionBuilder, getServiceHub(), Arrays.asList(partyAndAmount), buyerAccount, criteria);
157+
MoveTokensUtilities.addMoveFungibleTokens(transactionBuilder, getServiceHub(), Arrays.asList(partyAndAmount), buyerAccount, criteria);
151158

152159
//self sign the transaction. note : the host party will first self sign the transaction.
153160
SignedTransaction selfSignedTransaction = getServiceHub().signInitialTransaction(transactionBuilder,

Accounts/worldcupticketbooking/workflows/src/main/java/com/t20worldcup/flows/MoveTokensBetweenAccounts.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import com.r3.corda.lib.tokens.selection.TokenQueryBy;
1010
import com.r3.corda.lib.tokens.selection.database.config.DatabaseSelectionConfigKt;
1111
import com.r3.corda.lib.tokens.selection.database.selector.DatabaseTokenSelection;
12-
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilitiesKt;
13-
import com.r3.corda.lib.tokens.workflows.utilities.QueryUtilitiesKt;
12+
import com.r3.corda.lib.tokens.workflows.flows.move.MoveTokensUtilities;
13+
import com.r3.corda.lib.tokens.workflows.utilities.QueryUtilities;
1414
import kotlin.Pair;
1515
import net.corda.core.contracts.Amount;
1616
import net.corda.core.contracts.CommandData;
@@ -62,7 +62,7 @@ public String call() throws FlowException {
6262
Amount<TokenType> amount = new Amount(costOfTicket, getInstance(currency));
6363

6464
//Buyer Query for token balance.
65-
QueryCriteria queryCriteria = QueryUtilitiesKt.heldTokenAmountCriteria(this.getInstance(currency), buyerAccount).and(QueryUtilitiesKt.sumTokenCriteria());
65+
QueryCriteria queryCriteria = QueryUtilities.heldTokenAmountCriteria(this.getInstance(currency), buyerAccount).and(QueryUtilities.sumTokenCriteria());
6666
List<Object> sum = getServiceHub().getVaultService().queryBy(FungibleToken.class, queryCriteria).component5();
6767
if(sum.size() == 0)
6868
throw new FlowException(buyerAccountName + " has 0 token balance. Please ask the Bank to issue some cash.");
@@ -92,7 +92,7 @@ public String call() throws FlowException {
9292

9393
TransactionBuilder transactionBuilder = new TransactionBuilder(notary);
9494

95-
MoveTokensUtilitiesKt.addMoveTokens(transactionBuilder, inputsAndOutputs.getFirst(), inputsAndOutputs.getSecond());
95+
MoveTokensUtilities.addMoveTokens(transactionBuilder, inputsAndOutputs.getFirst(), inputsAndOutputs.getSecond());
9696

9797
Set<PublicKey> mySigners = new HashSet<>();
9898

Advanced/constants.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cordaReleaseGroup=net.corda
22
cordaCoreReleaseGroup=net.corda
3-
cordaVersion=4.5-RC02
4-
cordaCoreVersion=4.5-RC02
3+
cordaVersion=4.5
4+
cordaCoreVersion=4.5
55
gradlePluginsVersion=5.0.10
66
kotlinVersion=1.2.71
77
junitVersion=4.12

Advanced/negotiation-cordapp/build.gradle

Lines changed: 109 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,154 @@ buildscript {
33
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
44

55
ext {
6+
67
corda_release_group = constants.getProperty("cordaReleaseGroup")
7-
corda_release_version = constants.getProperty("cordaVersion")
88
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
9+
corda_release_version = constants.getProperty("cordaVersion")
910
corda_core_release_version = constants.getProperty("cordaCoreVersion")
1011
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
12+
kotlin_version = constants.getProperty("kotlinVersion")
1113
junit_version = constants.getProperty("junitVersion")
1214
quasar_version = constants.getProperty("quasarVersion")
1315
log4j_version = constants.getProperty("log4jVersion")
1416
slf4j_version = constants.getProperty("slf4jVersion")
15-
corda_platform_version = constants.getProperty("platformVersion")
17+
corda_platform_version = constants.getProperty("platformVersion").toInteger()
18+
//springboot
19+
spring_boot_version = '2.0.2.RELEASE'
20+
spring_boot_gradle_plugin_version = '2.0.2.RELEASE'
1621
}
1722

1823
repositories {
1924
mavenLocal()
2025
mavenCentral()
2126
jcenter()
22-
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-releases' }
27+
maven { url 'http://ci-artifactory.corda.r3cev.com/artifactory/corda-lib-dev' }
28+
maven { url 'http://ci-artifactory.corda.r3cev.com/artifactory/corda-lib' }
29+
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda' }
30+
// Corda dependencies for the patched Quasar version
31+
maven { url "https://software.r3.com/artifactory/corda-dependencies" } // access to the patched Quasar version
2332
}
2433

2534
dependencies {
2635
classpath "net.corda.plugins:cordapp:$corda_gradle_plugins_version"
2736
classpath "net.corda.plugins:cordformation:$corda_gradle_plugins_version"
2837
classpath "net.corda.plugins:quasar-utils:$corda_gradle_plugins_version"
38+
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_gradle_plugin_version"
39+
2940
}
3041
}
3142

3243
allprojects {
44+
apply from: "${rootProject.projectDir}/repositories.gradle"
3345
apply plugin: 'java'
3446

3547
repositories {
3648
mavenLocal()
3749
jcenter()
3850
mavenCentral()
39-
maven { url 'https://jitpack.io' }
4051
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda' }
41-
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
52+
// Can be removed post-release - used to get nightly snapshot build.
53+
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib' }
54+
maven { url 'https://ci-artifactory.corda.r3cev.com/artifactory/corda-lib-dev' }
55+
maven { url 'https://jitpack.io' }
56+
maven { url "https://repo.gradle.org/gradle/libs-releases-local" }
4257
}
4358

4459
tasks.withType(JavaCompile) {
45-
options.compilerArgs << "-parameters" // Required for shell commands.
60+
options.compilerArgs << "-parameters" // Required by Corda's serialisation framework.
61+
}
62+
63+
jar {
64+
// This makes the JAR's SHA-256 hash repeatable.
65+
preserveFileTimestamps = false
66+
reproducibleFileOrder = true
67+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
4668
}
69+
}
4770

71+
apply plugin: 'net.corda.plugins.cordapp'
72+
apply plugin: 'net.corda.plugins.cordformation'
73+
apply plugin: 'net.corda.plugins.quasar-utils'
4874

49-
configurations {
50-
compile {
51-
// We want to use SLF4J's version of these bindings: jcl-over-slf4j
52-
// Remove any transitive dependency on Apache's version.
53-
exclude group: 'commons-logging', module: 'commons-logging'
75+
sourceSets {
76+
main {
77+
resources {
78+
srcDir rootProject.file("config/dev")
5479
}
5580
}
81+
}
5682

57-
jar {
58-
// CorDapps do not configure a Node's logging.
59-
exclude '**/log4j2*.xml'
83+
dependencies {
84+
// Corda dependencies.
85+
cordaCompile "$corda_core_release_group:corda-core:$corda_core_release_version"
86+
cordaCompile "$corda_release_group:corda-node-api:$corda_release_version"
87+
cordaRuntime "$corda_release_group:corda:$corda_release_version"
88+
89+
// CorDapp dependencies.
90+
cordapp project(":workflows")
91+
cordapp project(":contracts")
92+
93+
cordaCompile "org.apache.logging.log4j:log4j-slf4j-impl:${log4j_version}"
94+
cordaCompile "org.apache.logging.log4j:log4j-web:${log4j_version}"
95+
cordaCompile "org.slf4j:jul-to-slf4j:$slf4j_version"
96+
}
97+
98+
cordapp {
99+
targetPlatformVersion corda_platform_version.toInteger()
100+
minimumPlatformVersion corda_platform_version.toInteger()
101+
workflow {
102+
name "Negotiation CorDapp"
103+
vendor "Corda Open Source"
104+
licence "Apache License, Version 2.0"
105+
versionId 1
106+
}
107+
}
108+
109+
task ganache {
110+
subprojects {
111+
if (it.project.name != "clients") {
112+
dependsOn jar
113+
doLast {
114+
copy {
115+
from "${buildDir}/libs"
116+
into "${rootDir}/build/libs"
117+
}
118+
}
119+
}
120+
}
121+
}
122+
123+
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
124+
nodeDefaults {
125+
126+
cordapp project(':contracts')
127+
}
128+
node {
129+
name "O=Notary,L=London,C=GB"
130+
notary = [validating : false]
131+
p2pPort 10002
132+
rpcSettings {
133+
address("localhost:10003")
134+
adminAddress("localhost:10043")
135+
}
136+
}
137+
node {
138+
name "O=PartyA,L=London,C=GB"
139+
p2pPort 10005
140+
rpcSettings {
141+
address("localhost:10006")
142+
adminAddress("localhost:10046")
143+
}
144+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
145+
}
146+
node {
147+
name "O=PartyB,L=New York,C=US"
148+
p2pPort 10008
149+
rpcSettings {
150+
address("localhost:10009")
151+
adminAddress("localhost:10049")
152+
}
153+
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
60154
}
61155
}
156+

Advanced/negotiation-cordapp/contracts/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cordapp {
77
targetPlatformVersion corda_platform_version.toInteger()
88
minimumPlatformVersion corda_platform_version.toInteger()
99
contract {
10-
name "Negotiation Cordapp"
10+
name "Negotiation Contract"
1111
vendor "Corda Open Source"
1212
licence "Apache License, Version 2.0"
1313
versionId 1

0 commit comments

Comments
 (0)