Skip to content

Commit fee93b3

Browse files
Merge branch 'main' into release
2 parents 0b096ed + d35c396 commit fee93b3

File tree

144 files changed

+704
-289
lines changed

Some content is hidden

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

144 files changed

+704
-289
lines changed

.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
max_line_length = 140

HEADER

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2020-2021 ONIXLabs
1+
Copyright 2020-2022 ONIXLabs
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

build.gradle

+1-1
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 = '3.2.0'
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=onixlabs-corda-identity-framework
22
group=io.onixlabs
3-
version=3.3.0
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/Expirable.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,6 +64,12 @@ open class AccountContract : Contract {
6464
internal const val CONTRACT_RULE_OUTPUTS =
6565
"On account issuing, at least one account state must be created."
6666

67+
internal const val CONTRACT_RULE_OWNER_DELIMITER =
68+
"On account issuing, the account owner name must not contain an @ symbol."
69+
70+
internal const val CONTRACT_RULE_LINEAR_ID_DELIMITER =
71+
"On account issuing, the account linear ID must not contain an @ symbol."
72+
6773
internal const val CONTRACT_RULE_PARTICIPANTS =
6874
"On account issuing, the owner of each created account must be a participant."
6975

@@ -81,6 +87,12 @@ open class AccountContract : Contract {
8187
internal const val CONTRACT_RULE_OUTPUTS =
8288
"On account amending, at least one account state must be created."
8389

90+
internal const val CONTRACT_RULE_OWNER_DELIMITER =
91+
"On account amending, the account owner name must not contain an @ symbol."
92+
93+
internal const val CONTRACT_RULE_LINEAR_ID_DELIMITER =
94+
"On account amending, the account linear ID must not contain an @ symbol."
95+
8496
internal const val CONTRACT_RULE_PARTICIPANTS =
8597
"On account amending, the owner of each created account must be a participant."
8698

@@ -138,6 +150,8 @@ open class AccountContract : Contract {
138150

139151
Issue.CONTRACT_RULE_INPUTS using (accountInputs.isEmpty())
140152
Issue.CONTRACT_RULE_OUTPUTS using (accountOutputs.isNotEmpty())
153+
Issue.CONTRACT_RULE_OWNER_DELIMITER using (accountOutputs.all { AccountParty.DELIMITER !in it.owner.toString() })
154+
Issue.CONTRACT_RULE_LINEAR_ID_DELIMITER using (accountOutputs.all { AccountParty.DELIMITER !in it.linearId.toString() })
141155
Issue.CONTRACT_RULE_PARTICIPANTS using (accountOutputs.all { it.owner in it.participants })
142156
Issue.CONTRACT_RULE_SIGNERS using (accountOutputs.all { it.owner.owningKey in signers })
143157

@@ -156,6 +170,8 @@ open class AccountContract : Contract {
156170

157171
Amend.CONTRACT_RULE_INPUTS using (accountInputs.isNotEmpty())
158172
Amend.CONTRACT_RULE_OUTPUTS using (accountOutputs.isNotEmpty())
173+
Amend.CONTRACT_RULE_OWNER_DELIMITER using (accountOutputs.all { AccountParty.DELIMITER !in it.owner.toString() })
174+
Amend.CONTRACT_RULE_LINEAR_ID_DELIMITER using (accountOutputs.all { AccountParty.DELIMITER !in it.linearId.toString() })
159175
Amend.CONTRACT_RULE_PARTICIPANTS using (accountOutputs.all { it.owner in it.participants })
160176
Amend.CONTRACT_RULE_SIGNERS using (accountOutputs.all { it.owner.owningKey in signers })
161177

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

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,12 +34,29 @@ import java.util.*
3434
* @property accountLinearId The linear ID of the account associated with this party.
3535
* @property accountType The type of the account associated with this party.
3636
*/
37-
class AccountParty internal constructor(
37+
class AccountParty(
3838
val owner: AbstractParty,
3939
val accountLinearId: UniqueIdentifier,
4040
val accountType: Class<out Account>
4141
) : AbstractParty(owner.owningKey) {
4242

43+
/**
44+
* @property DELIMITER The delimiter that will be used to format the account party.
45+
*/
46+
companion object {
47+
const val DELIMITER = '@'
48+
}
49+
50+
/**
51+
* Determines whether this [AccountParty] owns the specified [Account].
52+
*
53+
* @param account The account for which to determine ownership.
54+
* @return Returns true if this [AccountParty] owns the specified [Account]; otherwise, false.
55+
*/
56+
fun owns(account: Account): Boolean {
57+
return this == account.toAccountParty()
58+
}
59+
4360
/**
4461
* Gets an account resolver to resolve this [AccountParty] back to the associated [Account].
4562
*
@@ -90,8 +107,10 @@ class AccountParty internal constructor(
90107
* @return Returns true if the specified object is equal to the current object; otherwise, false.
91108
*/
92109
override fun equals(other: Any?): Boolean {
93-
return if (other !is AccountParty) super.equals(other)
94-
else other.owner == owner && other.accountLinearId == accountLinearId && other.accountType == accountType
110+
return this === other || (other is AccountParty
111+
&& other.owner == owner
112+
&& other.accountLinearId == accountLinearId
113+
&& other.accountType == accountType)
95114
}
96115

97116
/**
@@ -109,7 +128,7 @@ class AccountParty internal constructor(
109128
* @return Returns a string that represents the current object.
110129
*/
111130
override fun toString(): String {
112-
return "$accountLinearId@$owner"
131+
return "$accountLinearId$DELIMITER$owner"
113132
}
114133

115134
/**

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

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

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package io.onixlabs.corda.identityframework.contract.attestations
1818

1919
import io.onixlabs.corda.core.contract.ChainState
2020
import io.onixlabs.corda.core.contract.Hashable
21-
import io.onixlabs.corda.identityframework.contract.accountLinearId
2221
import io.onixlabs.corda.identityframework.contract.attestations.AttestationSchema.AttestationEntity
2322
import io.onixlabs.corda.identityframework.contract.attestations.AttestationSchema.AttestationSchemaV1
2423
import io.onixlabs.corda.identityframework.contract.toDataClassString
@@ -92,20 +91,7 @@ open class Attestation<T : ContractState>(
9291
* @return Returns a persistent state entity.
9392
*/
9493
override fun generateMappedObject(schema: MappedSchema): PersistentState = when (schema) {
95-
is AttestationSchemaV1 -> AttestationEntity(
96-
linearId = linearId.id,
97-
externalId = linearId.externalId,
98-
attestor = attestor,
99-
attestorAccountLinearId = attestor.accountLinearId?.id,
100-
attestorAccountExternalId = attestor.accountLinearId?.externalId,
101-
pointer = pointer.statePointer.toString(),
102-
pointerStateType = pointer.stateType.canonicalName,
103-
pointerHash = pointer.hash.toString(),
104-
status = status,
105-
previousStateRef = previousStateRef?.toString(),
106-
hash = hash.toString(),
107-
attestationType = javaClass.canonicalName
108-
)
94+
is AttestationSchemaV1 -> AttestationEntity(this)
10995
else -> throw IllegalArgumentException("Unrecognised schema: $schema.")
11096
}
11197

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,10 @@ package io.onixlabs.corda.identityframework.contract.attestations
1818

1919
import io.onixlabs.corda.core.contract.ContractID
2020
import io.onixlabs.corda.core.contract.isPointingTo
21-
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
2225
import net.corda.core.transactions.LedgerTransaction
2326
import java.security.PublicKey
2427

@@ -75,7 +78,7 @@ open class AttestationContract : Contract {
7578
"On attestation amending, only one attestation state must be created."
7679

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

8083
internal const val CONTRACT_RULE_STATE_REF =
8184
"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

+11-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -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.*
@@ -128,7 +128,8 @@ class LinearAttestationPointer<T : LinearState> internal constructor(
128128
override val statePointer: UniqueIdentifier
129129
) : AttestationPointer<T>() {
130130

131-
constructor(stateAndRef: StateAndRef<T>) : this(stateAndRef.state.data.javaClass, stateAndRef.state.data.linearId)
131+
constructor(state: T) : this(state.javaClass, state.linearId)
132+
constructor(stateAndRef: StateAndRef<T>) : this(stateAndRef.state.data)
132133

133134
private val criteria: QueryCriteria = vaultQuery(stateType) {
134135
stateStatus(Vault.StateStatus.UNCONSUMED)
@@ -170,16 +171,11 @@ class LinearAttestationPointer<T : LinearState> internal constructor(
170171
* Resolves a [ContractState] using a [LedgerTransaction] instance.
171172
*
172173
* @param transaction The [LedgerTransaction] instance to use to resolve the state.
173-
* @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.
174175
* @return Returns the resolved [ContractState], or null if no matching state is found.
175176
*/
176-
override fun resolve(transaction: LedgerTransaction, resolution: TransactionResolution): StateAndRef<T>? {
177-
val states: List<StateAndRef<T>> = when (resolution) {
178-
TransactionResolution.INPUT -> transaction.inRefsOfType(stateType)
179-
TransactionResolution.OUTPUT -> transaction.outRefsOfType(stateType)
180-
TransactionResolution.REFERENCE -> transaction.referenceInputRefsOfType(stateType)
181-
}
182-
177+
override fun resolve(transaction: LedgerTransaction, position: StatePosition): StateAndRef<T>? {
178+
val states = position.getStateAndRefs(transaction, stateType)
183179
return getOrThrow(states.singleOrNull { isPointingTo(it) })
184180
}
185181

@@ -258,16 +254,11 @@ class StaticAttestationPointer<T : ContractState> internal constructor(
258254
* Resolves a [ContractState] using a [LedgerTransaction] instance.
259255
*
260256
* @param transaction The [LedgerTransaction] instance to use to resolve the state.
261-
* @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.
262258
* @return Returns the resolved [ContractState], or null if no matching state is found.
263259
*/
264-
override fun resolve(transaction: LedgerTransaction, resolution: TransactionResolution): StateAndRef<T>? {
265-
val states: List<StateAndRef<T>> = when (resolution) {
266-
TransactionResolution.INPUT -> transaction.inRefsOfType(stateType)
267-
TransactionResolution.OUTPUT -> transaction.outRefsOfType(stateType)
268-
TransactionResolution.REFERENCE -> transaction.referenceInputRefsOfType(stateType)
269-
}
270-
260+
override fun resolve(transaction: LedgerTransaction, position: StatePosition): StateAndRef<T>? {
261+
val states = position.getStateAndRefs(transaction, stateType)
271262
return getOrThrow(states.singleOrNull { isPointingTo(it) })
272263
}
273264

@@ -278,7 +269,6 @@ class StaticAttestationPointer<T : ContractState> internal constructor(
278269
* @return Returns true if the immutable properties remain unchanged; otherwise, false.
279270
*/
280271
override fun immutableEquals(other: AttestationPointer<T>): Boolean {
281-
return other is StaticAttestationPointer<*>
282-
&& other.stateType == stateType
272+
return other is StaticAttestationPointer<*> && other.stateType == stateType
283273
}
284274
}

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

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

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

19+
import io.onixlabs.corda.identityframework.contract.accountLinearId
1920
import net.corda.core.crypto.NullKeys.NULL_PARTY
2021
import net.corda.core.identity.AbstractParty
2122
import net.corda.core.schemas.MappedSchema
@@ -68,5 +69,20 @@ object AttestationSchema {
6869

6970
@Column(name = "attestation_type", nullable = false)
7071
val attestationType: String = ""
71-
) : PersistentState()
72+
) : PersistentState() {
73+
internal constructor(attestation: Attestation<*>) : this(
74+
linearId = attestation.linearId.id,
75+
externalId = attestation.linearId.externalId,
76+
attestor = attestation.attestor,
77+
attestorAccountLinearId = attestation.attestor.accountLinearId?.id,
78+
attestorAccountExternalId = attestation.attestor.accountLinearId?.externalId,
79+
pointer = attestation.pointer.statePointer.toString(),
80+
pointerStateType = attestation.pointer.stateType.canonicalName,
81+
pointerHash = attestation.pointer.hash.toString(),
82+
status = attestation.status,
83+
previousStateRef = attestation.previousStateRef?.toString(),
84+
hash = attestation.hash.toString(),
85+
attestationType = attestation.javaClass.canonicalName
86+
)
87+
}
7288
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 ONIXLabs
2+
* Copyright 2020-2022 ONIXLabs
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)