Skip to content

Commit 92ccddb

Browse files
Refactor to use corda identity framework.
1 parent 316e82b commit 92ccddb

File tree

119 files changed

+1758
-6286
lines changed

Some content is hidden

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

119 files changed

+1758
-6286
lines changed

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55

66
corda_artifactory_url = 'https://ci-artifactory.corda.r3cev.com/artifactory'
77
corda_group = 'net.corda'
8-
corda_release_version = '4.3'
8+
corda_release_version = '4.5'
99

1010
corda_gradle_plugin_group = 'net.corda.plugins'
1111
corda_gradle_plugin_version = '5.0.4'
@@ -14,7 +14,7 @@ buildscript {
1414
junit_version = '5.3.1'
1515

1616
onixlabs_group = 'io.onixlabs'
17-
onixlabs_claims_release_version = '1.0.0-rc1'
17+
onixlabs_idfx_release_version = '0.0.9-beta'
1818

1919
cordapp_platform_version = 5
2020
cordapp_signing_enabled = true
@@ -30,6 +30,7 @@ buildscript {
3030
mavenCentral()
3131
jcenter()
3232
maven { url "$corda_artifactory_url/corda-releases" }
33+
maven { url "$corda_artifactory_url/corda-dependencies" }
3334
}
3435

3536
dependencies {
@@ -48,6 +49,7 @@ subprojects {
4849
jcenter()
4950
maven { url "https://jitpack.io" }
5051
maven { url "$corda_artifactory_url/corda-releases" }
52+
maven { url "$corda_artifactory_url/corda-dependencies" }
5153
maven { url "https://repo.gradle.org/gradle/libs-releases" }
5254
}
5355

onixlabs-corda-bnms-contract/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818

1919
// Corda Development Dependencies
2020
cordaCompile "$corda_group:corda-core:$corda_release_version"
21-
cordaCompile "$onixlabs_group:onixlabs-corda-claims-contract:$onixlabs_claims_release_version"
21+
cordaCompile "$onixlabs_group:onixlabs-corda-identity-framework-contract:$onixlabs_idfx_release_version"
2222

2323
// Test Dependencies
2424
testRuntimeOnly "$junit_group:junit-jupiter-engine:$junit_version"

onixlabs-corda-bnms-contract/src/main/kotlin/io/onixlabs/corda/bnms/contract/AttestationPointer.kt

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

onixlabs-corda-bnms-contract/src/main/kotlin/io/onixlabs/corda/bnms/contract/AttestationState.kt

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

onixlabs-corda-bnms-contract/src/main/kotlin/io/onixlabs/corda/bnms/contract/AttestationStatus.kt

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

onixlabs-corda-bnms-contract/src/main/kotlin/io/onixlabs/corda/bnms/contract/Extensions.kt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
11
package io.onixlabs.corda.bnms.contract
22

3-
import io.onixlabs.corda.bnms.contract.membership.Membership
4-
import io.onixlabs.corda.bnms.contract.relationship.Relationship
5-
import net.corda.core.contracts.*
63
import net.corda.core.crypto.SecureHash
74
import net.corda.core.identity.AbstractParty
8-
import net.corda.core.transactions.LedgerTransaction
9-
import java.security.PublicKey
10-
import java.util.*
11-
import kotlin.reflect.KClass
12-
13-
interface VerifiedCommand : CommandData {
14-
fun verify(tx: LedgerTransaction, signers: Set<PublicKey>)
15-
}
165

176
val Iterable<AbstractParty>.identityHash: SecureHash
187
get() = SecureHash.sha256(toSortedSet(IdentityComparator).joinToString())
198

20-
internal inline fun <reified T : VerifiedCommand> Contract.verifySingleCommand(tx: LedgerTransaction) {
21-
val command = tx.commands.requireSingleCommand<T>()
22-
if (command.value.javaClass.enclosingClass != this.javaClass) {
23-
throw IllegalArgumentException("Unknown contract command.")
24-
}
25-
command.value.verify(tx, command.signers.toSet())
26-
}
27-
28-
internal val KClass<*>.contractClassName: ContractClassName
29-
get() {
30-
return if (!this.isCompanion) {
31-
throw IllegalArgumentException("Must be called from a companion object.")
32-
} else this.java.enclosingClass.canonicalName
33-
}
34-
35-
fun StateAndRef<Membership>.getNextOutput() = state.data.copy(previousStateRef = ref)
36-
37-
fun StateAndRef<Relationship>.getNextOutput() = state.data.copy(previousStateRef = ref)
38-
399
private object IdentityComparator : Comparator<AbstractParty> {
4010
override fun compare(p0: AbstractParty?, p1: AbstractParty?): Int {
4111
return (p0?.hashCode() ?: 0).compareTo(p1?.hashCode() ?: 0)

onixlabs-corda-bnms-contract/src/main/kotlin/io/onixlabs/corda/bnms/contract/Grant.kt

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

onixlabs-corda-bnms-contract/src/main/kotlin/io/onixlabs/corda/bnms/contract/Hashable.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
package io.onixlabs.corda.bnms.contract
22

3+
import io.onixlabs.corda.identity.framework.contract.Claim
4+
import io.onixlabs.corda.identity.framework.contract.Hashable
35
import net.corda.core.crypto.SecureHash
46
import net.corda.core.identity.AbstractParty
5-
import net.corda.core.serialization.CordaSerializable
67
import java.util.*
78

89
/**
9-
* Represents the identity of a network.
10+
* Represents a claim that describes the identity of a business network.
1011
*
11-
* @property name The name of the network.
12-
* @property operator The identity of the network operator, or null if the network is decentralized.
13-
* @property normalizedName The normalized name of the network.
14-
* @property hash A SHA-256 hashed representation of the identity of a network.
12+
* @property property The property of the Network claim, which is set to "Network".
13+
* @property value The value of the Network claim, which is the name of the business network.
14+
* @property normalizedValue The normalized value of the Network claim.
15+
* @property operator The identity of the business network operator.
16+
* @property hash The hash that uniquely identifies the identity of the business network.
1517
*/
16-
@CordaSerializable
17-
class Network(val name: String, val operator: AbstractParty? = null) : Hashable {
18+
class Network(value: String, val operator: AbstractParty? = null) : Claim<String>("Network", value), Hashable {
1819

19-
val normalizedName: String
20-
get() = name.toLowerCase()
20+
val normalizedValue: String
21+
get() = value.toLowerCase()
2122

2223
override val hash: SecureHash
23-
get() = SecureHash.sha256("$normalizedName$operator")
24+
get() = SecureHash.sha256("$normalizedValue$operator")
2425

2526
/**
2627
* Compares this object for equality with the specified object.
@@ -29,21 +30,14 @@ class Network(val name: String, val operator: AbstractParty? = null) : Hashable
2930
* @return Returns true if the objects are considered equal; otherwise, false.
3031
*/
3132
override fun equals(other: Any?): Boolean {
32-
return other === this || (other != null
33-
&& other is Network
34-
&& other.operator == operator
35-
&& other.normalizedName == normalizedName)
33+
return this === other || (other is Network && other.hash == hash)
3634
}
3735

3836
/**
3937
* Serves as the default hash code implementation.
4038
* @return Returns a unique hash code for this object instance.
4139
*/
42-
override fun hashCode() = Objects.hash(normalizedName, operator)
43-
44-
/**
45-
* Gets a string representation of this object instance.
46-
* @return Returns a string representation of this object instance.
47-
*/
48-
override fun toString() = "Network: name = $name, normalized name = $normalizedName, operator = $operator"
40+
override fun hashCode(): Int {
41+
return Objects.hash(hash)
42+
}
4943
}

0 commit comments

Comments
 (0)