Skip to content

Commit 309ff1d

Browse files
Merge pull request #5 from onix-labs/main
2.0.0-rc1
2 parents ff0ca6a + 553fc50 commit 309ff1d

File tree

31 files changed

+714
-186
lines changed

31 files changed

+714
-186
lines changed

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
junit_version = '5.3.1'
1515

1616
onixlabs_group = 'io.onixlabs'
17-
onixlabs_corda_core_release_version = '1.0.0'
17+
onixlabs_corda_core_release_version = '1.2.0'
1818

1919
cordapp_platform_version = 8
2020
cordapp_contract_name = 'ONIXLabs Corda Identity Framework Contract'
@@ -45,7 +45,7 @@ buildscript {
4545
}
4646

4747
group 'io.onixlabs'
48-
version '1.0.0'
48+
version '2.0.0-rc1'
4949

5050
subprojects {
5151
repositories {
@@ -94,10 +94,10 @@ task cleanLocal(type: Exec) {
9494

9595
task releaseLocal(type: GradleBuild) {
9696
startParameter = gradle.startParameter.newInstance()
97-
tasks = ['cleanLocal', 'clean', 'build', 'publishToMavenLocal']
97+
tasks = ['clean', 'build', 'publishToMavenLocal']
9898
}
9999

100100
task releasePublic(type: GradleBuild) {
101101
startParameter = gradle.startParameter.newInstance()
102-
tasks = ['cleanLocal', 'clean', 'build', 'publishToMavenLocal', 'publish']
102+
tasks = ['clean', 'build', 'publishToMavenLocal', 'publish']
103103
}

onixlabs-corda-identity-framework-contract/src/main/kotlin/io/onixlabs/corda/identityframework/contract/Attestation.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ open class Attestation<T : ContractState>(
100100
pointerHash = pointer.hash.toString(),
101101
status = status,
102102
previousStateRef = previousStateRef?.toString(),
103-
hash = hash.toString()
103+
hash = hash.toString(),
104+
attestationClass = javaClass.canonicalName
104105
)
105106
else -> throw IllegalArgumentException("Unrecognised schema: $schema.")
106107
}

onixlabs-corda-identity-framework-contract/src/main/kotlin/io/onixlabs/corda/identityframework/contract/AttestationContract.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package io.onixlabs.corda.identityframework.contract
1818

19+
import io.onixlabs.corda.core.contract.ContractID
1920
import io.onixlabs.corda.core.contract.isPointingTo
2021
import net.corda.core.contracts.*
2122
import net.corda.core.transactions.LedgerTransaction
@@ -26,14 +27,7 @@ import java.security.PublicKey
2627
*/
2728
open class AttestationContract : Contract {
2829

29-
companion object {
30-
31-
/**
32-
* The ID of this contract.
33-
*/
34-
@JvmStatic
35-
val ID: ContractClassName = this::class.java.enclosingClass.canonicalName
36-
}
30+
companion object : ContractID
3731

3832
/**
3933
* Verifies a ledger transaction using a command from this contract.

onixlabs-corda-identity-framework-contract/src/main/kotlin/io/onixlabs/corda/identityframework/contract/AttestationSchema.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ object AttestationSchema {
6161
val previousStateRef: String? = null,
6262

6363
@Column(name = "hash", nullable = false, unique = true)
64-
val hash: String = ""
64+
val hash: String = "",
65+
66+
@Column(name = "attestation_class", nullable = false)
67+
val attestationClass: String = ""
6568
) : PersistentState()
6669
}

onixlabs-corda-identity-framework-contract/src/main/kotlin/io/onixlabs/corda/identityframework/contract/CordaClaim.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ open class CordaClaim<T : Any>(
107107
valueClass = value.javaClass.canonicalName,
108108
previousStateRef = previousStateRef?.toString(),
109109
isSelfIssued = isSelfIssued,
110-
hash = hash.toString()
110+
hash = hash.toString(),
111+
claimClass = javaClass.canonicalName
111112
)
112113
else -> throw IllegalArgumentException("Unrecognised schema: $schema.")
113114
}

onixlabs-corda-identity-framework-contract/src/main/kotlin/io/onixlabs/corda/identityframework/contract/CordaClaimContract.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616

1717
package io.onixlabs.corda.identityframework.contract
1818

19+
import io.onixlabs.corda.core.contract.ContractID
1920
import io.onixlabs.corda.core.contract.isPointingTo
20-
import net.corda.core.contracts.*
21+
import net.corda.core.contracts.CommandData
22+
import net.corda.core.contracts.Contract
23+
import net.corda.core.contracts.requireSingleCommand
24+
import net.corda.core.contracts.requireThat
2125
import net.corda.core.transactions.LedgerTransaction
2226
import java.security.PublicKey
2327

@@ -27,14 +31,7 @@ import java.security.PublicKey
2731
*/
2832
open class CordaClaimContract : Contract {
2933

30-
companion object {
31-
32-
/**
33-
* The ID of this contract.
34-
*/
35-
@JvmStatic
36-
val ID: ContractClassName = this::class.java.enclosingClass.canonicalName
37-
}
34+
companion object : ContractID
3835

3936
/**
4037
* Verifies a ledger transaction using a command from this contract.

onixlabs-corda-identity-framework-contract/src/main/kotlin/io/onixlabs/corda/identityframework/contract/CordaClaimSchema.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ object CordaClaimSchema {
6262
val isSelfIssued: Boolean = false,
6363

6464
@Column(name = "hash", nullable = false, unique = true)
65-
val hash: String = ""
65+
val hash: String = "",
66+
67+
@Column(name = "claim_class", nullable = false)
68+
val claimClass: String = ""
6669
) : PersistentState()
6770
}

onixlabs-corda-identity-framework-contract/src/main/resources/migration/attestation-schema.changelog-v1.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<column name="hash" type="nvarchar(64)">
3535
<constraints nullable="false" unique="true"/>
3636
</column>
37+
<column name="attestation_class" type="nvarchar(1024)">
38+
<constraints nullable="false"/>
39+
</column>
3740
</createTable>
3841
<addPrimaryKey columnNames="output_index, transaction_id"
3942
constraintName="PK_attestation_states"

onixlabs-corda-identity-framework-contract/src/main/resources/migration/corda-claim-schema.changelog-v1.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
<column name="hash" type="nvarchar(64)">
3737
<constraints nullable="false" unique="true"/>
3838
</column>
39+
<column name="claim_class" type="nvarchar(1024)">
40+
<constraints nullable="false"/>
41+
</column>
3942
</createTable>
4043
<addPrimaryKey columnNames="output_index, transaction_id"
4144
constraintName="PK_corda_claim_states"

onixlabs-corda-identity-framework-integration/src/main/kotlin/io/onixlabs/corda/identityframework/integration/AttestationCommandService.kt

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ import net.corda.core.transactions.SignedTransaction
3939
*/
4040
class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
4141

42+
/**
43+
* Issues an attestation.
44+
*
45+
* @param T The [Attestation] type.
46+
* @param attestation The attestation to issue.
47+
* @param notary The notary to use for the transaction.
48+
* @param observers Additional observers of the transaction.
49+
* @return Returns a flow process handle.
50+
*/
51+
fun <T : Attestation<*>> issueAttestation(
52+
attestation: T,
53+
notary: Party? = null,
54+
observers: Set<Party> = emptySet()
55+
): FlowProgressHandle<SignedTransaction> {
56+
return rpc.startTrackedFlow(IssueAttestationFlow::Initiator, attestation, notary, observers)
57+
}
58+
4259
/**
4360
* Issues an attestation.
4461
*
@@ -50,6 +67,7 @@ class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
5067
* @param linearId The unique identifier of the attestation.
5168
* @param notary The notary to use for the transaction.
5269
* @param observers Additional observers of the transaction.
70+
* @return Returns a flow process handle.
5371
*/
5472
fun <T : ContractState> issueAttestation(
5573
state: StateAndRef<T>,
@@ -60,98 +78,97 @@ class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
6078
notary: Party? = null,
6179
observers: Set<Party> = emptySet()
6280
): FlowProgressHandle<SignedTransaction> {
63-
return rpc.startTrackedFlow(
64-
IssueAttestationFlow::Initiator,
65-
state.attest(attestor, status, metadata, linearId),
66-
notary,
67-
observers
68-
)
81+
val attestation = state.attest(attestor, status, metadata, linearId)
82+
return issueAttestation(attestation, notary, observers)
83+
}
84+
85+
/**
86+
* Amends an attestation.
87+
*
88+
* @param T The [Attestation] type.
89+
* @param oldAttestation The old attestation to be consumed.
90+
* @param newAttestation The new attestation to be created.
91+
* @param observers Additional observers of the transaction.
92+
* @return Returns a flow process handle.
93+
*/
94+
fun <T : Attestation<*>> amendAttestation(
95+
oldAttestation: StateAndRef<T>,
96+
newAttestation: T,
97+
observers: Set<Party> = emptySet()
98+
): FlowProgressHandle<SignedTransaction> {
99+
return rpc.startTrackedFlow(AmendAttestationFlow::Initiator, oldAttestation, newAttestation, observers)
69100
}
70101

71102
/**
72103
* Amends an attestation.
73104
*
74105
* @param T The underlying [ContractState] type.
75-
* @param attestation The attestation to be consumed.
106+
* @param oldAttestation The old attestation to be consumed.
76107
* @param status The status of the attestation.
77108
* @param metadata Additional information about the attestation.
78109
* @param observers Additional observers of the transaction.
110+
* @return Returns a flow process handle.
79111
*/
80112
fun <T : ContractState> amendAttestation(
81-
attestation: StateAndRef<Attestation<T>>,
113+
oldAttestation: StateAndRef<Attestation<T>>,
82114
status: AttestationStatus = AttestationStatus.REJECTED,
83115
metadata: Map<String, String> = emptyMap(),
84116
observers: Set<Party> = emptySet()
85117
): FlowProgressHandle<SignedTransaction> {
86-
val amendedAttestation = attestation.amend(status, metadata = metadata)
87-
return rpc.startTrackedFlow(
88-
AmendAttestationFlow::Initiator,
89-
attestation,
90-
amendedAttestation,
91-
observers
92-
)
118+
val newAttestation = oldAttestation.amend(status, metadata = metadata)
119+
return amendAttestation(oldAttestation, newAttestation, observers)
93120
}
94121

95122
/**
96123
* Amends an attestation.
97124
*
98125
* @param T The underlying [ContractState] type.
99-
* @param attestation The attestation to be consumed.
126+
* @param oldAttestation The old attestation to be consumed.
100127
* @param state The state being attested.
101128
* @param status The status of the attestation.
102129
* @param metadata Additional information about the attestation.
103130
* @param observers Additional observers of the transaction.
131+
* @return Returns a flow process handle.
104132
*/
105133
fun <T : ContractState> amendAttestation(
106-
attestation: StateAndRef<Attestation<T>>,
134+
oldAttestation: StateAndRef<Attestation<T>>,
107135
state: StateAndRef<T>,
108136
status: AttestationStatus = AttestationStatus.REJECTED,
109137
metadata: Map<String, String> = emptyMap(),
110138
observers: Set<Party> = emptySet()
111139
): FlowProgressHandle<SignedTransaction> {
112140
val pointer = state.toAttestationPointer()
113-
val amendedAttestation = attestation.amend(status, pointer, metadata)
114-
return rpc.startTrackedFlow(
115-
AmendAttestationFlow::Initiator,
116-
attestation,
117-
amendedAttestation,
118-
observers
119-
)
141+
val newAttestation = oldAttestation.amend(status, pointer, metadata)
142+
return amendAttestation(oldAttestation, newAttestation, observers)
120143
}
121144

122145
/**
123146
* Revokes an attestation.
124147
*
125-
* @param T The underlying [ContractState] type.
148+
* @param T The [Attestation] type.
126149
* @param attestation The attestation to be consumed.
127150
* @param observers Additional observers of the transaction.
151+
* @return Returns a flow process handle.
128152
*/
129-
fun <T : ContractState> revokeAttestation(
130-
attestation: StateAndRef<Attestation<T>>,
153+
fun <T : Attestation<*>> revokeAttestation(
154+
attestation: StateAndRef<T>,
131155
observers: Set<Party> = emptySet()
132156
): FlowProgressHandle<SignedTransaction> {
133-
return rpc.startTrackedFlow(
134-
RevokeAttestationFlow::Initiator,
135-
attestation,
136-
observers
137-
)
157+
return rpc.startTrackedFlow(RevokeAttestationFlow::Initiator, attestation, observers)
138158
}
139159

140160
/**
141161
* Publishes an attestation.
142162
*
143-
* @param T The underlying [ContractState] type.
163+
* @param T The [Attestation] type.
144164
* @param attestation The attestation to be published.
145165
* @param observers Observers of the attestation.
166+
* @return Returns a flow process handle.
146167
*/
147-
fun <T : ContractState> publishAttestation(
148-
attestation: StateAndRef<Attestation<T>>,
168+
fun <T : Attestation<*>> publishAttestation(
169+
attestation: StateAndRef<T>,
149170
observers: Set<Party>
150171
): FlowProgressHandle<SignedTransaction> {
151-
return rpc.startTrackedFlow(
152-
PublishAttestationFlow::Initiator,
153-
attestation,
154-
observers
155-
)
172+
return rpc.startTrackedFlow(PublishAttestationFlow::Initiator, attestation, observers)
156173
}
157174
}

0 commit comments

Comments
 (0)