Skip to content

Commit 9284cdd

Browse files
committed
restructure of blacklist cordapp
1 parent 3b62376 commit 9284cdd

File tree

26 files changed

+180
-128
lines changed

26 files changed

+180
-128
lines changed

Features/attachment-blacklist/build.gradle

+100-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.3.31'
2+
// ext.kotlin_version = '1.3.31'
33
Properties constants = new Properties()
44
file("$projectDir/../constants.properties").withInputStream { constants.load(it) }
55

@@ -34,6 +34,8 @@ buildscript {
3434
}
3535

3636
allprojects {
37+
apply from: "${rootProject.projectDir}/repositories.gradle"
38+
apply plugin: 'kotlin'
3739

3840
repositories {
3941
mavenLocal()
@@ -44,13 +46,14 @@ allprojects {
4446
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
4547
}
4648

47-
configurations {
48-
compile {
49-
// We want to use SLF4J's version of these bindings: jcl-over-slf4j
50-
// Remove any transitive dependency on Apache's version.
51-
exclude group: 'commons-logging', module: 'commons-logging'
52-
}
53-
}
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'
54+
// }
55+
// }
56+
5457

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

Features/attachment-blacklist/clients-kotlin/build.gradle renamed to Features/attachment-blacklist/clients/build.gradle

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ dependencies {
1414
compile "$corda_release_group:corda-rpc:$corda_release_version"
1515

1616
// CorDapp dependencies.
17-
compile project(":contracts-kotlin")
18-
compile project(":workflows-kotlin")
17+
compile project(":contracts")
18+
compile project(":workflows")
1919

2020
compile("org.springframework.boot:spring-boot-starter-websocket:$spring_boot_version") {
2121
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
@@ -27,17 +27,17 @@ dependencies {
2727
}
2828

2929
springBoot {
30-
mainClassName = "net.corda.examples.attachments.webserver.Server"
30+
mainClassName = "net.corda.samples.blacklist.webserver.Server"
3131
}
3232

3333
task runWebServer(type: JavaExec, dependsOn: assemble) {
3434
classpath = sourceSets.main.runtimeClasspath
35-
main = 'net.corda.examples.attachments.webserver.Starter'
35+
main = 'net.corda.samples.blacklist.webserver.Starter'
3636
args '--server.port=10050', '--config.rpc.host=localhost', '--config.rpc.port=10006', '--config.rpc.username=user1', '--config.rpc.password=test'
3737
}
3838

3939
task uploadBlacklist(type: JavaExec, dependsOn: assemble) {
4040
classpath = sourceSets.main.runtimeClasspath
41-
main = 'net.corda.examples.attachments.client.ClientKt'
41+
main = 'net.corda.samples.blacklist.clients.ClientKt'
4242
args 'localhost:10006', 'localhost:10009', 'localhost:10012'
4343
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.attachments.client
1+
package net.corda.samples.blacklist.clients
22

33
import net.corda.client.rpc.CordaRPCClient
44
import net.corda.core.crypto.SecureHash
@@ -69,7 +69,7 @@ private fun checkAttachment(attachmentJar: JarInputStream, expectedFileName: Str
6969
while (name != expectedFileName) {
7070
name = attachmentJar.nextEntry.name
7171
}
72-
72+
7373
val contents = attachmentJar.bufferedReader().readLines()
7474

7575
if (contents != expectedContents) {

Features/attachment-blacklist/contracts-kotlin/build.gradle renamed to Features/attachment-blacklist/contracts/build.gradle

+2-2
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 "Attachment Blacklist"
1414
vendor "Corda Open Source"
1515
licence "Apache License, Version 2.0"
1616
versionId 1
@@ -32,4 +32,4 @@ dependencies {
3232
// Corda dependencies.
3333
cordaCompile "$corda_release_group:corda-core:$corda_release_version"
3434
testCompile "$corda_release_group:corda-node-driver:$corda_release_version"
35-
}
35+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.corda.examples.attachments
22

3-
const val BLACKLIST_JAR_PATH = "../contracts-kotlin/src/main/resources/blacklist.jar"
3+
const val BLACKLIST_JAR_PATH = "../contracts/src/main/resources/blacklist.jar"
44
const val ATTACHMENT_FILE_NAME = "blacklist.txt"
55
val ATTACHMENT_EXPECTED_CONTENTS = listOf(
66
"Crossland Savings",
@@ -15,5 +15,6 @@ val BLACKLISTED_PARTIES = listOf(
1515
"The James Polk Stone Community Bank",
1616
"Tifton Banking Company"
1717
)
18+
1819
// This jar exists, but does not meet the constraints imposed by AttachmentContract.
19-
const val INCORRECT_JAR_PATH = "src/test/resources/invalid.jar"
20+
const val INCORRECT_JAR_PATH = "src/test/resources/invalid.jar"
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package net.corda.examples.attachments.contracts
1+
package net.corda.samples.blacklist.contracts
22

33
import net.corda.core.contracts.Contract
44
import net.corda.core.contracts.ContractAttachment
55
import net.corda.core.contracts.TypeOnlyCommandData
66
import net.corda.core.contracts.requireThat
77
import net.corda.core.crypto.SecureHash
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
open class AgreementContract : Contract {
1212
companion object {
13-
const val AGREEMENT_CONTRACT_ID = "net.corda.examples.attachments.contracts.AgreementContract"
13+
const val AGREEMENT_CONTRACT_ID = "net.corda.samples.blacklist.contracts.AgreementContract"
1414
val BLACKLIST_JAR_HASH = SecureHash.parse("4CEC607599723D7E0393EB5F05F24562732CD1B217DEAEDEABD4C25AFE5B333A")
1515
}
1616

@@ -22,14 +22,14 @@ open class AgreementContract : Contract {
2222
"The transaction should have an Agree command" using (tx.commandsOfType<Commands.Agree>().size == 1)
2323
"The transaction should have no other commands" using (tx.commands.size == 1)
2424

25-
// Constraints on the included attachments.
25+
// Constraints on the included blacklist.
2626
val nonContractAttachments = tx.attachments.filter { it !is ContractAttachment }
2727
"The transaction should have a single non-contract attachment" using (nonContractAttachments.size == 1)
2828
val attachment = nonContractAttachments.single()
2929

3030
// TODO: Switch to constraint on the jar's signer.
3131
// In the future, Corda will support the signing of jars. We will then be able to restrict
32-
// the attachments used to just those signed by party X.
32+
// the blacklist used to just those signed by party X.
3333
"The jar's hash should be correct" using (attachment.id == BLACKLIST_JAR_HASH)
3434

3535
// We extract the blacklisted company names from the JAR.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package net.corda.examples.attachments.states
1+
package net.corda.samples.blacklist.states
22

33
import net.corda.core.contracts.BelongsToContract
44
import net.corda.core.contracts.ContractState
55
import net.corda.core.identity.Party
6-
import net.corda.examples.attachments.contracts.AgreementContract
6+
import net.corda.samples.blacklist.contracts.AgreementContract
77

88
@BelongsToContract(AgreementContract::class)
99
data class AgreementState(val partyA: Party, val partyB: Party, val txt: String) : ContractState {
1010
override val participants get() = listOf(partyA, partyB)
11-
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
package net.corda.examples.attachments.contracts
1+
package net.corda.samples.blacklist.contracts
22

33
import net.corda.core.crypto.generateKeyPair
44
import net.corda.core.identity.CordaX500Name
55
import net.corda.examples.attachments.BLACKLISTED_PARTIES
66
import net.corda.examples.attachments.BLACKLIST_JAR_PATH
7-
import net.corda.examples.attachments.contracts.AgreementContract
8-
import net.corda.examples.attachments.contracts.AgreementContract.Companion.AGREEMENT_CONTRACT_ID
9-
import net.corda.examples.attachments.states.AgreementState
7+
import net.corda.samples.blacklist.contracts.AgreementContract.Companion.AGREEMENT_CONTRACT_ID
8+
import net.corda.samples.blacklist.states.AgreementState
109
import net.corda.testing.core.TestIdentity
1110
import net.corda.testing.core.getTestPartyAndCertificate
1211
import net.corda.testing.node.MockServices
@@ -16,7 +15,7 @@ import org.junit.Test
1615
import java.io.File
1716

1817
class ContractTests {
19-
private val ledgerServices = MockServices(listOf("net.corda.examples.attachments.contracts"), identityService = makeTestIdentityService(), initialIdentity = TestIdentity(CordaX500Name("TestIdentity", "", "GB")))
18+
private val ledgerServices = MockServices(listOf("net.corda.samples.blacklist.contracts"), identityService = makeTestIdentityService(), initialIdentity = TestIdentity(CordaX500Name("TestIdentity", "", "GB")))
2019
private val megaCorpName = CordaX500Name("MegaCorp", "London", "GB")
2120
private val miniCorpName = CordaX500Name("MiniCorp", "London", "GB")
2221
private val megaCorp = TestIdentity(megaCorpName)
@@ -68,4 +67,4 @@ class ContractTests {
6867
}
6968
}
7069
}
71-
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.corda.examples.attachments.states
1+
package net.corda.samples.blacklist.states
22

33
import net.corda.core.identity.CordaX500Name
44
import net.corda.testing.core.TestIdentity
@@ -31,4 +31,4 @@ class StateTests {
3131
assertTrue(agreementState.participants.contains(alice))
3232
assertTrue(agreementState.participants.contains(bob))
3333
}
34-
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name=AttachmentsExample
2-
group=com.corda.example.attachments
1+
name=Attachment Blacklist
2+
group=com.blacklist
33
version=1.0
4-
kotlin.incremental=false
4+
kotlin.incremental=false

Features/attachment-blacklist/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
33
zipStoreBase=GRADLE_USER_HOME
44
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
5+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repositories {
2+
mavenLocal()
3+
mavenCentral()
4+
jcenter()
5+
maven { url 'https://jitpack.io' }
6+
maven { url 'https://software.r3.com/artifactory/corda' }
7+
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
8+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include 'workflows-kotlin'
2-
include 'contracts-kotlin'
3-
include 'clients-kotlin'
1+
include 'workflows'
2+
include 'contracts'
3+
include 'clients'
44

0 commit comments

Comments
 (0)