Skip to content

Commit e2cee37

Browse files
Version bump and code fixes for major release 4.0.0
1 parent 5444fa5 commit e2cee37

File tree

16 files changed

+49
-152
lines changed

16 files changed

+49
-152
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
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 = '4.0.0-rc3'
17+
onixlabs_corda_core_release_version = '4.0.0'
1818

1919
cordapp_platform_version = 10
2020
cordapp_contract_name = 'ONIXLabs Corda Identity Framework Contract'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=onixlabs-corda-identity-framework
22
group=io.onixlabs
3-
version=4.0.0-rc5
3+
version=4.0.0
44
onixlabs.development.jarsign.keystore=../lib/onixlabs.development.pkcs12
55
onixlabs.development.jarsign.password=5891f47942424d2acbe108691fdb5ba258712fca7e4762be4327241ebf3dbfa3

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ inline fun <reified T : ContractState, reified U : Attestation<T>> StateAndRef<U
5353
status: AttestationStatus,
5454
stateAndRef: StateAndRef<T>,
5555
metadata: Map<String, String> = emptyMap()
56-
): U = amendAttestation(status, stateAndRef.toStaticAttestationPointer(state.data.pointer.identifier), metadata)
56+
): U = amendAttestation(status, stateAndRef.toStaticAttestationPointer(), metadata)
5757

5858
/**
5959
* Amends an attestation of a [LinearState].
@@ -69,7 +69,7 @@ inline fun <reified T : LinearState, reified U : Attestation<T>> StateAndRef<U>.
6969
status: AttestationStatus,
7070
stateAndRef: StateAndRef<T>,
7171
metadata: Map<String, String> = emptyMap()
72-
): U = amendAttestation(status, stateAndRef.toLinearAttestationPointer(state.data.pointer.identifier), metadata)
72+
): U = amendAttestation(status, stateAndRef.toLinearAttestationPointer(), metadata)
7373

7474
/**
7575
* Accepts an attestation.
@@ -97,7 +97,7 @@ inline fun <T : ContractState, reified U : Attestation<T>> StateAndRef<U>.accept
9797
inline fun <T : ContractState, reified U : Attestation<T>> StateAndRef<U>.acceptStaticAttestation(
9898
stateAndRef: StateAndRef<T>,
9999
metadata: Map<String, String> = emptyMap()
100-
): U = amendAttestation(AttestationStatus.ACCEPTED, stateAndRef.toStaticAttestationPointer(state.data.pointer.identifier), metadata)
100+
): U = amendAttestation(AttestationStatus.ACCEPTED, stateAndRef.toStaticAttestationPointer(), metadata)
101101

102102
/**
103103
* Accepts an attestation of a [LinearState].
@@ -111,7 +111,7 @@ inline fun <T : ContractState, reified U : Attestation<T>> StateAndRef<U>.accept
111111
inline fun <T : LinearState, reified U : Attestation<T>> StateAndRef<U>.acceptLinearAttestation(
112112
stateAndRef: StateAndRef<T>,
113113
metadata: Map<String, String> = emptyMap()
114-
): U = amendAttestation(AttestationStatus.ACCEPTED, stateAndRef.toLinearAttestationPointer(state.data.pointer.identifier), metadata)
114+
): U = amendAttestation(AttestationStatus.ACCEPTED, stateAndRef.toLinearAttestationPointer(), metadata)
115115

116116
/**
117117
* Rejects an attestation.
@@ -139,7 +139,7 @@ inline fun <T : ContractState, reified U : Attestation<T>> StateAndRef<U>.reject
139139
inline fun <T : ContractState, reified U : Attestation<T>> StateAndRef<U>.rejectStaticAttestation(
140140
stateAndRef: StateAndRef<T>,
141141
metadata: Map<String, String> = emptyMap()
142-
): U = amendAttestation(AttestationStatus.REJECTED, stateAndRef.toStaticAttestationPointer(state.data.pointer.identifier), metadata)
142+
): U = amendAttestation(AttestationStatus.REJECTED, stateAndRef.toStaticAttestationPointer(), metadata)
143143

144144
/**
145145
* Rejects an attestation of a [LinearState].
@@ -153,4 +153,4 @@ inline fun <T : ContractState, reified U : Attestation<T>> StateAndRef<U>.reject
153153
inline fun <T : LinearState, reified U : Attestation<T>> StateAndRef<U>.rejectLinearAttestation(
154154
stateAndRef: StateAndRef<T>,
155155
metadata: Map<String, String> = emptyMap()
156-
): U = amendAttestation(AttestationStatus.REJECTED, stateAndRef.toLinearAttestationPointer(state.data.pointer.identifier), metadata)
156+
): U = amendAttestation(AttestationStatus.REJECTED, stateAndRef.toLinearAttestationPointer(), metadata)

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

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,20 @@ import net.corda.core.identity.AbstractParty
3030
* Creates a static attestation pointer from a [StateAndRef].
3131
*
3232
* @param T The underlying [ContractState] type.
33-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
3433
* @return Returns a static attestation pointer for the specified [StateAndRef].
3534
*/
36-
fun <T : ContractState> StateAndRef<T>.toStaticAttestationPointer(identifier: String? = null): StaticAttestationPointer<T> {
37-
return StaticAttestationPointer(this, identifier)
35+
fun <T : ContractState> StateAndRef<T>.toStaticAttestationPointer(): StaticAttestationPointer<T> {
36+
return StaticAttestationPointer(this)
3837
}
3938

4039
/**
4140
* Creates a linear attestation pointer from a [StateAndRef].
4241
*
4342
* @param T The underlying [LinearState] type.
44-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
4543
* @return Returns a linear attestation pointer for the specified [StateAndRef].
4644
*/
47-
fun <T : LinearState> StateAndRef<T>.toLinearAttestationPointer(identifier: String? = state.data.linearId.toString()): LinearAttestationPointer<T> {
48-
return LinearAttestationPointer(this, identifier)
45+
fun <T : LinearState> StateAndRef<T>.toLinearAttestationPointer(): LinearAttestationPointer<T> {
46+
return LinearAttestationPointer(this)
4947
}
5048

5149
/**
@@ -56,19 +54,17 @@ fun <T : LinearState> StateAndRef<T>.toLinearAttestationPointer(identifier: Stri
5654
* @param status The status of the attestation.
5755
* @param metadata Additional information about the attestation.
5856
* @param linearId The unique identifier of the attestation.
59-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
6057
* @return Returns an attestation for the specified [StateAndRef].
6158
*/
6259
fun <T : ContractState> StateAndRef<T>.createStaticAttestation(
6360
attestor: AbstractParty,
6461
status: AttestationStatus,
6562
metadata: Map<String, String> = emptyMap(),
66-
linearId: UniqueIdentifier = UniqueIdentifier(),
67-
identifier: String? = null
63+
linearId: UniqueIdentifier = UniqueIdentifier()
6864
): Attestation<T> = Attestation(
6965
attestor,
7066
state.data.participants.toSet(),
71-
toStaticAttestationPointer(identifier),
67+
toStaticAttestationPointer(),
7268
status,
7369
metadata,
7470
linearId,
@@ -82,15 +78,13 @@ fun <T : ContractState> StateAndRef<T>.createStaticAttestation(
8278
* @param attestor The attestor of the witnessed state.
8379
* @param metadata Additional information about the attestation.
8480
* @param linearId The unique identifier of the attestation.
85-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
8681
* @return Returns an accepted attestation for the specified [StateAndRef].
8782
*/
8883
fun <T : ContractState> StateAndRef<T>.createAcceptedStaticAttestation(
8984
attestor: AbstractParty,
9085
metadata: Map<String, String> = emptyMap(),
91-
linearId: UniqueIdentifier = UniqueIdentifier(),
92-
identifier: String? = null
93-
): Attestation<T> = createStaticAttestation(attestor, AttestationStatus.ACCEPTED, metadata, linearId, identifier)
86+
linearId: UniqueIdentifier = UniqueIdentifier()
87+
): Attestation<T> = createStaticAttestation(attestor, AttestationStatus.ACCEPTED, metadata, linearId)
9488

9589
/**
9690
* Creates a rejected attestation from the specified [StateAndRef].
@@ -99,15 +93,13 @@ fun <T : ContractState> StateAndRef<T>.createAcceptedStaticAttestation(
9993
* @param attestor The attestor of the witnessed state.
10094
* @param metadata Additional information about the attestation.
10195
* @param linearId The unique identifier of the attestation.
102-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
10396
* @return Returns an rejected attestation for the specified [StateAndRef].
10497
*/
10598
fun <T : ContractState> StateAndRef<T>.createRejectedStaticAttestation(
10699
attestor: AbstractParty,
107100
metadata: Map<String, String> = emptyMap(),
108-
linearId: UniqueIdentifier = UniqueIdentifier(),
109-
identifier: String? = null
110-
): Attestation<T> = createStaticAttestation(attestor, AttestationStatus.REJECTED, metadata, linearId, identifier)
101+
linearId: UniqueIdentifier = UniqueIdentifier()
102+
): Attestation<T> = createStaticAttestation(attestor, AttestationStatus.REJECTED, metadata, linearId)
111103

112104
/**
113105
* Creates an attestation from the specified [StateAndRef].
@@ -117,19 +109,17 @@ fun <T : ContractState> StateAndRef<T>.createRejectedStaticAttestation(
117109
* @param status The status of the attestation.
118110
* @param metadata Additional information about the attestation.
119111
* @param linearId The unique identifier of the attestation.
120-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
121112
* @return Returns an attestation for the specified [StateAndRef].
122113
*/
123114
fun <T : LinearState> StateAndRef<T>.createLinearAttestation(
124115
attestor: AbstractParty,
125116
status: AttestationStatus,
126117
metadata: Map<String, String> = emptyMap(),
127-
linearId: UniqueIdentifier = UniqueIdentifier(),
128-
identifier: String? = state.data.linearId.toString()
118+
linearId: UniqueIdentifier = UniqueIdentifier()
129119
): Attestation<T> = Attestation(
130120
attestor,
131121
state.data.participants.toSet(),
132-
toLinearAttestationPointer(identifier),
122+
toLinearAttestationPointer(),
133123
status,
134124
metadata,
135125
linearId,
@@ -143,15 +133,13 @@ fun <T : LinearState> StateAndRef<T>.createLinearAttestation(
143133
* @param attestor The attestor of the witnessed state.
144134
* @param metadata Additional information about the attestation.
145135
* @param linearId The unique identifier of the attestation.
146-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
147136
* @return Returns an accepted attestation for the specified [StateAndRef].
148137
*/
149138
fun <T : LinearState> StateAndRef<T>.createAcceptedLinearAttestation(
150139
attestor: AbstractParty,
151140
metadata: Map<String, String> = emptyMap(),
152-
linearId: UniqueIdentifier = UniqueIdentifier(),
153-
identifier: String? = state.data.linearId.toString()
154-
): Attestation<T> = createLinearAttestation(attestor, AttestationStatus.ACCEPTED, metadata, linearId, identifier)
141+
linearId: UniqueIdentifier = UniqueIdentifier()
142+
): Attestation<T> = createLinearAttestation(attestor, AttestationStatus.ACCEPTED, metadata, linearId)
155143

156144
/**
157145
* Creates a rejected attestation from the specified [StateAndRef].
@@ -160,12 +148,10 @@ fun <T : LinearState> StateAndRef<T>.createAcceptedLinearAttestation(
160148
* @param attestor The attestor of the witnessed state.
161149
* @param metadata Additional information about the attestation.
162150
* @param linearId The unique identifier of the attestation.
163-
* @param identifier Provides an additional, external identifier which can be used to track states across state transitions.
164151
* @return Returns an rejected attestation for the specified [StateAndRef].
165152
*/
166153
fun <T : LinearState> StateAndRef<T>.createRejectedLinearAttestation(
167154
attestor: AbstractParty,
168155
metadata: Map<String, String> = emptyMap(),
169-
linearId: UniqueIdentifier = UniqueIdentifier(),
170-
identifier: String? = state.data.linearId.toString()
171-
): Attestation<T> = createLinearAttestation(attestor, AttestationStatus.REJECTED, metadata, linearId, identifier)
156+
linearId: UniqueIdentifier = UniqueIdentifier()
157+
): Attestation<T> = createLinearAttestation(attestor, AttestationStatus.REJECTED, metadata, linearId)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ open class AttestationContract : Contract {
7878
"On attestation amending, only one attestation state must be created."
7979

8080
internal const val CONTRACT_RULE_CHANGES =
81-
"On attestation amending, the attestor, linear ID, pointer class and pointer identifier must not change."
81+
"On attestation amending, the attestor, linear ID and pointer class must not change."
8282

8383
internal const val CONTRACT_RULE_STATE_REF =
8484
"On attestation amending, the created attestation state must point to the consumed attestation state."

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

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package io.onixlabs.corda.identityframework.contract.attestations
1818

1919
import io.onixlabs.corda.core.contract.Hashable
2020
import io.onixlabs.corda.core.contract.SingularResolvable
21-
import io.onixlabs.corda.core.contract.TransactionResolution
21+
import io.onixlabs.corda.core.contract.StatePosition
2222
import io.onixlabs.corda.core.services.vaultQuery
2323
import io.onixlabs.corda.identityframework.contract.toDataClassString
2424
import net.corda.core.contracts.*
@@ -37,7 +37,6 @@ import java.util.*
3737
* @param T The underlying [ContractState] type.
3838
* @property stateType The [Class] of the witnessed state being attested.
3939
* @property statePointer The pointer to the witnessed state being attested.
40-
* @property identifier Provides an additional, external identifier which can be used to track states across state transitions.
4140
* @property hash The hash of the attestation pointer.
4241
*
4342
* Note that attestation pointer hashes should be unique for static attestation pointers since they point to the
@@ -48,10 +47,9 @@ import java.util.*
4847
sealed class AttestationPointer<T : ContractState> : SingularResolvable<T>, Hashable {
4948
abstract val stateType: Class<T>
5049
abstract val statePointer: Any
51-
abstract val identifier: String?
5250

5351
final override val hash: SecureHash
54-
get() = SecureHash.sha256("$stateType$statePointer$identifier")
52+
get() = SecureHash.sha256("$stateType$statePointer")
5553

5654
/**
5755
* Determines whether the specified object is equal to the current object.
@@ -123,20 +121,15 @@ sealed class AttestationPointer<T : ContractState> : SingularResolvable<T>, Hash
123121
* @param T The underlying [LinearState] type.
124122
* @property stateType The [Class] of the witnessed state being attested.
125123
* @property statePointer The pointer to the witnessed state being attested.
126-
* @property identifier Provides an additional, external identifier which can be used to track states across state transitions.
127124
* @property hash The hash of the attestation pointer.
128125
*/
129126
class LinearAttestationPointer<T : LinearState> internal constructor(
130127
override val stateType: Class<T>,
131-
override val statePointer: UniqueIdentifier,
132-
override val identifier: String?
128+
override val statePointer: UniqueIdentifier
133129
) : AttestationPointer<T>() {
134130

135-
constructor(stateAndRef: StateAndRef<T>, identifier: String?) : this(
136-
stateType = stateAndRef.state.data.javaClass,
137-
statePointer = stateAndRef.state.data.linearId,
138-
identifier = identifier
139-
)
131+
constructor(state: T) : this(state.javaClass, state.linearId)
132+
constructor(stateAndRef: StateAndRef<T>) : this(stateAndRef.state.data)
140133

141134
private val criteria: QueryCriteria = vaultQuery(stateType) {
142135
stateStatus(Vault.StateStatus.UNCONSUMED)
@@ -178,16 +171,11 @@ class LinearAttestationPointer<T : LinearState> internal constructor(
178171
* Resolves a [ContractState] using a [LedgerTransaction] instance.
179172
*
180173
* @param transaction The [LedgerTransaction] instance to use to resolve the state.
181-
* @param resolution The transaction resolution method to use to resolve the [ContractState] instance.
174+
* @param position The position of the [ContractState] instance to resolve in the transaction.
182175
* @return Returns the resolved [ContractState], or null if no matching state is found.
183176
*/
184-
override fun resolve(transaction: LedgerTransaction, resolution: TransactionResolution): StateAndRef<T>? {
185-
val states: List<StateAndRef<T>> = when (resolution) {
186-
TransactionResolution.INPUT -> transaction.inRefsOfType(stateType)
187-
TransactionResolution.OUTPUT -> transaction.outRefsOfType(stateType)
188-
TransactionResolution.REFERENCE -> transaction.referenceInputRefsOfType(stateType)
189-
}
190-
177+
override fun resolve(transaction: LedgerTransaction, position: StatePosition): StateAndRef<T>? {
178+
val states = position.getStateAndRefs(transaction, stateType)
191179
return getOrThrow(states.singleOrNull { isPointingTo(it) })
192180
}
193181

@@ -201,7 +189,6 @@ class LinearAttestationPointer<T : LinearState> internal constructor(
201189
return other is LinearAttestationPointer<*>
202190
&& other.stateType == stateType
203191
&& other.statePointer == statePointer
204-
&& other.identifier == identifier
205192
}
206193
}
207194

@@ -218,20 +205,14 @@ class LinearAttestationPointer<T : LinearState> internal constructor(
218205
* @param T The underlying [LinearState] type.
219206
* @property stateType The [Class] of the witnessed state being attested.
220207
* @property statePointer The pointer to the witnessed state being attested.
221-
* @property identifier Provides an additional, external identifier which can be used to track states across state transitions.
222208
* @property hash The hash of the attestation pointer.
223209
*/
224210
class StaticAttestationPointer<T : ContractState> internal constructor(
225211
override val stateType: Class<T>,
226-
override val statePointer: StateRef,
227-
override val identifier: String?
212+
override val statePointer: StateRef
228213
) : AttestationPointer<T>() {
229214

230-
constructor(stateAndRef: StateAndRef<T>, identifier: String?) : this(
231-
stateType = stateAndRef.state.data.javaClass,
232-
statePointer = stateAndRef.ref,
233-
identifier = identifier
234-
)
215+
constructor(stateAndRef: StateAndRef<T>) : this(stateAndRef.state.data.javaClass, stateAndRef.ref)
235216

236217
private val criteria: QueryCriteria = vaultQuery(stateType) {
237218
stateStatus(Vault.StateStatus.ALL)
@@ -273,16 +254,11 @@ class StaticAttestationPointer<T : ContractState> internal constructor(
273254
* Resolves a [ContractState] using a [LedgerTransaction] instance.
274255
*
275256
* @param transaction The [LedgerTransaction] instance to use to resolve the state.
276-
* @param resolution The transaction resolution method to use to resolve the [ContractState] instance.
257+
* @param position The position of the [ContractState] instance to resolve in the transaction.
277258
* @return Returns the resolved [ContractState], or null if no matching state is found.
278259
*/
279-
override fun resolve(transaction: LedgerTransaction, resolution: TransactionResolution): StateAndRef<T>? {
280-
val states: List<StateAndRef<T>> = when (resolution) {
281-
TransactionResolution.INPUT -> transaction.inRefsOfType(stateType)
282-
TransactionResolution.OUTPUT -> transaction.outRefsOfType(stateType)
283-
TransactionResolution.REFERENCE -> transaction.referenceInputRefsOfType(stateType)
284-
}
285-
260+
override fun resolve(transaction: LedgerTransaction, position: StatePosition): StateAndRef<T>? {
261+
val states = position.getStateAndRefs(transaction, stateType)
286262
return getOrThrow(states.singleOrNull { isPointingTo(it) })
287263
}
288264

@@ -293,8 +269,6 @@ class StaticAttestationPointer<T : ContractState> internal constructor(
293269
* @return Returns true if the immutable properties remain unchanged; otherwise, false.
294270
*/
295271
override fun immutableEquals(other: AttestationPointer<T>): Boolean {
296-
return other is StaticAttestationPointer<*>
297-
&& other.stateType == stateType
298-
&& other.identifier == identifier
272+
return other is StaticAttestationPointer<*> && other.stateType == stateType
299273
}
300274
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ object AttestationSchema {
5454
@Column(name = "pointer_state_type", nullable = false)
5555
val pointerStateType: String = "",
5656

57-
@Column(name = "pointer_identifier", nullable = true)
58-
val pointerIdentifier: String? = null,
59-
6057
@Column(name = "pointer_hash", nullable = false)
6158
val pointerHash: String = "",
6259

@@ -81,7 +78,6 @@ object AttestationSchema {
8178
attestorAccountExternalId = attestation.attestor.accountLinearId?.externalId,
8279
pointer = attestation.pointer.statePointer.toString(),
8380
pointerStateType = attestation.pointer.stateType.canonicalName,
84-
pointerIdentifier = attestation.pointer.identifier,
8581
pointerHash = attestation.pointer.hash.toString(),
8682
status = attestation.status,
8783
previousStateRef = attestation.previousStateRef?.toString(),

0 commit comments

Comments
 (0)