Skip to content

Commit 2124e9a

Browse files
Merge pull request #3 from onix-labs/bugfix-query-flows
Bugfixing find claim flows.
2 parents 46ef5f6 + 41aedb9 commit 2124e9a

File tree

29 files changed

+612
-121
lines changed

29 files changed

+612
-121
lines changed

build.gradle

Lines changed: 2 additions & 2 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'
4949

5050
subprojects {
5151
repositories {

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/AttestationQueryService.kt

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,66 @@ import java.time.Instant
4444
*/
4545
class AttestationQueryService(rpc: CordaRPCOps) : RPCService(rpc) {
4646

47+
/**
48+
* Finds a single attestation.
49+
*
50+
* @param T The underlying [Attestation] type.
51+
* @param attestationClass The class of the underlying attestation.
52+
* @param linearId The linear ID to include in the query.
53+
* @param externalId The external ID to include in the query.
54+
* @param attestor The attestor to include in the query.
55+
* @param pointer The attestation pointer to include in the query.
56+
* @param pointerStateRef The pointer state reference to include in the query.
57+
* @param pointerStateClass The pointer state class to include in the query.
58+
* @param pointerStateLinearId The pointer state linear ID to include in the query.
59+
* @param pointerHash The pointer hash to include in the query.
60+
* @param status The attestation status to include in the query.
61+
* @param timestamp The timestamp to include in the query.
62+
* @param hash The hash to include in the query.
63+
* @param stateStatus The state status to include in the query.
64+
* @param relevancyStatus The relevancy status to include in the query.
65+
* @property pageSpecification The page specification of the query.
66+
* @param flowTimeout The amount of time that the flow will be allowed to execute before failing.
67+
* @return Returns an attestation that matches the query, or null if no attestation was found.
68+
*/
69+
fun <T : Attestation<*>> findAttestation(
70+
attestationClass: Class<T>,
71+
linearId: UniqueIdentifier? = null,
72+
externalId: String? = null,
73+
attestor: AbstractParty? = null,
74+
pointer: AttestationPointer<*>? = null,
75+
pointerStateRef: StateRef? = null,
76+
pointerStateClass: Class<out ContractState>? = null,
77+
pointerStateLinearId: UniqueIdentifier? = null,
78+
pointerHash: SecureHash? = null,
79+
status: AttestationStatus? = null,
80+
timestamp: Instant? = null,
81+
hash: SecureHash? = null,
82+
stateStatus: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
83+
relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL,
84+
pageSpecification: PageSpecification = DEFAULT_PAGE_SPECIFICATION,
85+
flowTimeout: Duration = Duration.ofSeconds(30)
86+
): StateAndRef<T>? {
87+
return rpc.startFlowDynamic(
88+
FindAttestationFlow::class.java,
89+
attestationClass,
90+
linearId,
91+
externalId,
92+
attestor,
93+
pointer,
94+
pointerStateRef,
95+
pointerStateClass,
96+
pointerStateLinearId,
97+
pointerHash,
98+
status,
99+
timestamp,
100+
hash,
101+
stateStatus,
102+
relevancyStatus,
103+
pageSpecification
104+
).returnValue.getOrThrow(flowTimeout)?.cast(attestationClass)
105+
}
106+
47107
/**
48108
* Finds a single attestation.
49109
*
@@ -84,6 +144,7 @@ class AttestationQueryService(rpc: CordaRPCOps) : RPCService(rpc) {
84144
): StateAndRef<T>? {
85145
return rpc.startFlowDynamic(
86146
FindAttestationFlow::class.java,
147+
T::class.java,
87148
linearId,
88149
externalId,
89150
attestor,
@@ -101,6 +162,66 @@ class AttestationQueryService(rpc: CordaRPCOps) : RPCService(rpc) {
101162
).returnValue.getOrThrow(flowTimeout)?.cast()
102163
}
103164

165+
/**
166+
* Finds multiple attestations.
167+
*
168+
* @param T The underlying [Attestation] type.
169+
* @param attestationClass The class of the underlying attestation.
170+
* @param linearId The linear ID to include in the query.
171+
* @param externalId The external ID to include in the query.
172+
* @param attestor The attestor to include in the query.
173+
* @param pointer The attestation pointer to include in the query.
174+
* @param pointerStateRef The pointer state reference to include in the query.
175+
* @param pointerStateClass The pointer state class to include in the query.
176+
* @param pointerStateLinearId The pointer state linear ID to include in the query.
177+
* @param pointerHash The pointer hash to include in the query.
178+
* @param status The attestation status to include in the query.
179+
* @param timestamp The timestamp to include in the query.
180+
* @param hash The hash to include in the query.
181+
* @param stateStatus The state status to include in the query.
182+
* @param relevancyStatus The relevancy status to include in the query.
183+
* @property pageSpecification The page specification of the query.
184+
* @param flowTimeout The amount of time that the flow will be allowed to execute before failing.
185+
* @return Returns attestations that match the query, or null if no attestations are found.
186+
*/
187+
fun <T : Attestation<*>> findAttestations(
188+
attestationClass: Class<T>,
189+
linearId: UniqueIdentifier? = null,
190+
externalId: String? = null,
191+
attestor: AbstractParty? = null,
192+
pointer: AttestationPointer<*>? = null,
193+
pointerStateRef: StateRef? = null,
194+
pointerStateClass: Class<out ContractState>? = null,
195+
pointerStateLinearId: UniqueIdentifier? = null,
196+
pointerHash: SecureHash? = null,
197+
status: AttestationStatus? = null,
198+
timestamp: Instant? = null,
199+
hash: SecureHash? = null,
200+
stateStatus: Vault.StateStatus = Vault.StateStatus.UNCONSUMED,
201+
relevancyStatus: Vault.RelevancyStatus = Vault.RelevancyStatus.ALL,
202+
pageSpecification: PageSpecification = DEFAULT_PAGE_SPECIFICATION,
203+
flowTimeout: Duration = Duration.ofSeconds(30)
204+
): List<StateAndRef<T>> {
205+
return rpc.startFlowDynamic(
206+
FindAttestationsFlow::class.java,
207+
attestationClass,
208+
linearId,
209+
externalId,
210+
attestor,
211+
pointer,
212+
pointerStateRef,
213+
pointerStateClass,
214+
pointerStateLinearId,
215+
pointerHash,
216+
status,
217+
timestamp,
218+
hash,
219+
stateStatus,
220+
relevancyStatus,
221+
pageSpecification
222+
).returnValue.getOrThrow(flowTimeout).cast(attestationClass)
223+
}
224+
104225
/**
105226
* Finds multiple attestations.
106227
*
@@ -141,6 +262,7 @@ class AttestationQueryService(rpc: CordaRPCOps) : RPCService(rpc) {
141262
): List<StateAndRef<T>> {
142263
return rpc.startFlowDynamic(
143264
FindAttestationsFlow::class.java,
265+
T::class.java,
144266
linearId,
145267
externalId,
146268
attestor,
@@ -155,6 +277,6 @@ class AttestationQueryService(rpc: CordaRPCOps) : RPCService(rpc) {
155277
stateStatus,
156278
relevancyStatus,
157279
pageSpecification
158-
).returnValue.getOrThrow(flowTimeout).map { it.cast<T>() }
280+
).returnValue.getOrThrow(flowTimeout).cast()
159281
}
160282
}

0 commit comments

Comments
 (0)