Skip to content

Commit fc94563

Browse files
authored
Merge pull request #38 from corda/2020Q4CodeCleanUp
2020 Q4 code clean up
2 parents c434d5a + 77f6fbb commit fc94563

File tree

791 files changed

+29357
-9891
lines changed

Some content is hidden

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

791 files changed

+29357
-9891
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
**/.vscode/*
99
**/out/
1010
**/logs/
11+
**/node_modules/
1112
corda-nodeinfo/corda-nodeinfo.iml
1213
*~*

Accounts/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
## samples-java/Accounts
1+
## Accounts CorDapp Samples
22

33
This folder features Corda Accounts sample projects. Learn more about [Accounts](https://training.corda.net/libraries/accounts-lib/).
44

55
### [Supply Chain](./supplychain):
66

77
This CorDapp mimics a supply chain transaction, where the deal is incorporated among different teams in the companies on both side of the trade.
8-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Accounts/supplychain)
8+
<p align="center">
9+
<img src="./supplychain/Business%20Flow.png" alt="Corda" width="700">
10+
</p>
911

1012
### [Tic Tac Thor](./tictacthor):
1113

12-
This CorDapp recreates the game of Tic Tac Toe via Corda. It primarily demonstrates how you can have [LinearState](https://docs.corda.net/docs/corda-os/api-states.html#linearstate) transactions between cross-node accounts.
13-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Accounts/tictacthor)
14-
15-
### [Worldcup Ticket Booking](./worldcupticketbooking):
16-
This CorDapp demonstrates an ticket booking system with a collaboration of Corda [Accounts](https://training.corda.net/libraries/accounts-lib/) and [Tokens](https://training.corda.net/libraries/tokens-sdk/).
17-
[<img src="../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Accounts/worldcupticketbooking)
18-
14+
This CorDapp recreates the game of Tic Tac Toe via Corda. It primarily demonstrates how you can have LinearState transactions between cross-node accounts.
15+
<p align="center">
16+
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/32/Tic_tac_toe.svg/1024px-Tic_tac_toe.svg.png" alt="Corda" width="200">
17+
</p>

Accounts/supplychain/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Accounts_SupplyChain [<img src="../../webIDE.png" height=25 />](https://ide.corda.net/?folder=/home/coder/samples-java/Accounts/supplychain)
1+
# Accounts_SupplyChain
22

33
For More information regarding the Accounts Library, please read at: https://github.com/corda/accounts/blob/master/docs.md
44

@@ -89,7 +89,7 @@ Navigate to Seller's node terminal and type in
8989
```
9090
flow start SendShippingRequest whoAmI: SellerInventory, whereTo: BuyerWarehouse, shipper: ShippingCo, Cargo: 10 boxes of Books
9191
```
92-
[Optional verification]: run ```run vaultQuery contractStateType: com.supplychain.states.ShippingRequestState``` at ShippingCo's node terminal
92+
[Optional verification]: run ```run vaultQuery contractStateType: ShippingRequestState``` at ShippingCo's node terminal
9393

9494
## Step 6: Shipping company sends the cargo to Buyer's warehouse
9595
Navigate to ShippingCo's node terminal and type in

Accounts/supplychain/build.gradle

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

55
ext {
6-
76
corda_release_group = constants.getProperty("cordaReleaseGroup")
87
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
98
corda_release_version = constants.getProperty("cordaVersion")
@@ -15,9 +14,11 @@ buildscript {
1514
log4j_version = constants.getProperty("log4jVersion")
1615
slf4j_version = constants.getProperty("slf4jVersion")
1716
corda_platform_version = constants.getProperty("platformVersion").toInteger()
18-
//accounts
19-
accounts_release_version = '1.0'
17+
18+
//account
2019
accounts_release_group = 'com.r3.corda.lib.accounts'
20+
accounts_release_version = '1.0'
21+
//CI
2122
confidential_id_release_group = "com.r3.corda.lib.ci"
2223
confidential_id_release_version = "1.0"
2324
}
@@ -45,9 +46,11 @@ allprojects {
4546
jcenter()
4647
mavenCentral()
4748
maven { url 'https://software.r3.com/artifactory/corda' }
49+
maven { url 'https://jitpack.io' }
50+
//SDK lib
4851
maven { url 'https://software.r3.com/artifactory/corda-lib' }
49-
maven { url 'https://software.r3.com/artifactory/corda-lib-dev' }
50-
maven { url "https://repo.gradle.org/gradle/libs-releases-local" }
52+
//Gradle Plugins
53+
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
5154
}
5255

5356
tasks.withType(JavaCompile) {
@@ -62,9 +65,6 @@ allprojects {
6265
}
6366
}
6467

65-
66-
67-
6868
apply plugin: 'net.corda.plugins.cordapp'
6969
apply plugin: 'net.corda.plugins.cordformation'
7070
apply plugin: 'net.corda.plugins.quasar-utils'
@@ -97,29 +97,6 @@ dependencies {
9797
cordapp "$accounts_release_group:accounts-workflows:$accounts_release_version"
9898
}
9999

100-
cordapp {
101-
info {
102-
name "CorDapp supplychain"
103-
vendor "Corda Open Source"
104-
targetPlatformVersion corda_platform_version
105-
minimumPlatformVersion corda_platform_version
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-
123100
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
124101
nodeDefaults {
125102
projectCordapp {

Accounts/supplychain/contracts/src/main/java/com/supplychain/contracts/InvoiceStateContract.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

Accounts/supplychain/contracts/src/main/java/com/supplychain/contracts/CargoStateContract.java renamed to Accounts/supplychain/contracts/src/main/java/net/corda/samples/supplychain/contracts/CargoStateContract.java

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

33
import net.corda.core.contracts.CommandData;
44
import net.corda.core.contracts.Contract;
@@ -9,7 +9,7 @@
99
// ************
1010
public class CargoStateContract implements Contract {
1111
// This is used to identify our contract when building a transaction.
12-
public static final String ID = "com.supplychain.contracts.CargoStateContract";
12+
public static final String ID = "net.corda.samples.supplychain.contracts.CargoStateContract";
1313

1414
// A transaction is valid if the verify() function of the contract of all the transaction's input and output states
1515
// does not throw an exception.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.supplychain.contracts;
1+
package net.corda.samples.supplychain.contracts;
22

33
import net.corda.core.contracts.CommandData;
44
import net.corda.core.contracts.Contract;
@@ -9,7 +9,7 @@
99
// ************
1010
public class InternalMessageStateContract implements Contract {
1111
// This is used to identify our contract when building a transaction.
12-
public static final String ID = "com.supplychain.contracts.InternalMessageStateContract";
12+
public static final String ID = "net.corda.samples.supplychain.contracts.InternalMessageStateContract";
1313

1414
// A transaction is valid if the verify() function of the contract of all the transaction's input and output states
1515
// does not throw an exception.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package net.corda.samples.supplychain.contracts;
2+
3+
import net.corda.core.contracts.CommandData;
4+
import net.corda.core.contracts.CommandWithParties;
5+
import net.corda.core.contracts.Contract;
6+
import net.corda.core.contracts.ContractState;
7+
import net.corda.core.transactions.LedgerTransaction;
8+
import net.corda.samples.supplychain.states.InvoiceState;
9+
10+
import java.util.List;
11+
12+
import static net.corda.core.contracts.ContractsDSL.requireSingleCommand;
13+
import static net.corda.core.contracts.ContractsDSL.requireThat;
14+
15+
// ************
16+
// * Contract *
17+
// ************
18+
public class InvoiceStateContract implements Contract {
19+
// This is used to identify our contract when building a transaction.
20+
public static final String ID = "net.corda.samples.supplychain.contracts.InvoiceStateContract";
21+
22+
// A transaction is valid if the verify() function of the contract of all the transaction's input and output states
23+
// does not throw an exception.
24+
@Override
25+
public void verify(LedgerTransaction tx) throws IllegalArgumentException {
26+
/*
27+
* We can use the requireSingleCommand function to extract command data from transaction.
28+
* However, it is possible to have multiple commands in a signle transaction.
29+
*/
30+
final CommandWithParties<InvoiceStateContract.Commands> command = requireSingleCommand(tx.getCommands(), InvoiceStateContract.Commands.class);
31+
32+
List<ContractState> inputs = tx.getInputStates();
33+
List<ContractState> outputs = tx.getOutputStates();
34+
35+
if (command.getValue() instanceof InvoiceStateContract.Commands.Create) {
36+
37+
// Using Corda DSL function requireThat to replicate conditions-checks
38+
requireThat(require -> {
39+
require.using("No inputs should be consumed when creating a new Invoice State.", inputs.isEmpty());
40+
require.using("Transaction must have exactly one output.", outputs.size() == 1);
41+
InvoiceState output = (InvoiceState) outputs.get(0);
42+
require.using("Invoice amount must be a valid number (Greater than zero)", output.getAmount() > 0);
43+
return null;
44+
});
45+
46+
} else {
47+
throw new IllegalArgumentException("Command not found!");
48+
}
49+
50+
}
51+
52+
// Used to indicate the transaction's intent.
53+
public interface Commands extends CommandData {
54+
class Create implements Commands {}
55+
}
56+
}

Accounts/supplychain/contracts/src/main/java/com/supplychain/contracts/PaymentStateContract.java renamed to Accounts/supplychain/contracts/src/main/java/net/corda/samples/supplychain/contracts/PaymentStateContract.java

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

33
import net.corda.core.contracts.CommandData;
44
import net.corda.core.contracts.Contract;
@@ -9,7 +9,7 @@
99
// ************
1010
public class PaymentStateContract implements Contract {
1111
// This is used to identify our contract when building a transaction.
12-
public static final String ID = "com.supplychain.contracts.PaymentStateContract";
12+
public static final String ID = "net.corda.samples.supplychain.contracts.PaymentStateContract";
1313

1414
// A transaction is valid if the verify() function of the contract of all the transaction's input and output states
1515
// does not throw an exception.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.supplychain.contracts;
1+
package net.corda.samples.supplychain.contracts;
22

33
import net.corda.core.contracts.CommandData;
44
import net.corda.core.contracts.Contract;
@@ -9,7 +9,7 @@
99
// ************
1010
public class ShippingRequestStateContract implements Contract {
1111
// This is used to identify our contract when building a transaction.
12-
public static final String ID = "com.supplychain.contracts.ShippingRequestStateContract";
12+
public static final String ID = "net.corda.samples.supplychain.contracts.ShippingRequestStateContract";
1313

1414
// A transaction is valid if the verify() function of the contract of all the transaction's input and output states
1515
// does not throw an exception.

0 commit comments

Comments
 (0)