@@ -19,56 +19,128 @@ package io.onixlabs.corda.bnms.contract.membership
1919import io.onixlabs.corda.identityframework.contract.attestations.AttestationStatus
2020import io.onixlabs.corda.identityframework.contract.toStaticAttestationPointer
2121import net.corda.core.contracts.StateAndRef
22+ import net.corda.core.contracts.StateRef
2223import net.corda.core.contracts.UniqueIdentifier
2324import net.corda.core.identity.AbstractParty
2425
26+ /* *
27+ * Gets the next [Membership] output, appending the previous [Membership] state's [StateRef].
28+ *
29+ * @return Returns the next [Membership] output, appending the previous [Membership] state's [StateRef].
30+ */
2531fun StateAndRef<Membership>.getNextOutput (): Membership {
2632 return state.data.copy(previousStateRef = ref)
2733}
2834
35+ /* *
36+ * Creates a [MembershipAttestation] for the specified [Membership].
37+ *
38+ * @param attestor The attestor who is attesting to the [Membership].
39+ * @param status The status of the attestation.
40+ * @param metadata Any extra metadata that should be applied to the attestation.
41+ * @param linearId The linear ID of the attestation.
42+ * @return Returns a [MembershipAttestation] for the specified [Membership].
43+ */
2944fun StateAndRef<Membership>.attest (
3045 attestor : AbstractParty ,
3146 status : AttestationStatus ,
3247 metadata : Map <String , String > = emptyMap(),
3348 linearId : UniqueIdentifier = UniqueIdentifier ()
3449) = MembershipAttestation (attestor, this , status, metadata, linearId)
3550
51+ /* *
52+ * Creates an accepted [MembershipAttestation] for the specified [Membership].
53+ *
54+ * @param attestor The attestor who is attesting to the [Membership].
55+ * @param metadata Any extra metadata that should be applied to the attestation.
56+ * @param linearId The linear ID of the attestation.
57+ * @return Returns an accepted [MembershipAttestation] for the specified [Membership].
58+ */
3659fun StateAndRef<Membership>.accept (
3760 attestor : AbstractParty ,
3861 metadata : Map <String , String > = emptyMap(),
3962 linearId : UniqueIdentifier = UniqueIdentifier ()
4063) = attest(attestor, AttestationStatus .ACCEPTED , metadata, linearId)
4164
65+ /* *
66+ * Creates a rejected [MembershipAttestation] for the specified [Membership].
67+ *
68+ * @param attestor The attestor who is attesting to the [Membership].
69+ * @param metadata Any extra metadata that should be applied to the attestation.
70+ * @param linearId The linear ID of the attestation.
71+ * @return Returns a rejected [MembershipAttestation] for the specified [Membership].
72+ */
4273fun StateAndRef<Membership>.reject (
4374 attestor : AbstractParty ,
4475 metadata : Map <String , String > = emptyMap(),
4576 linearId : UniqueIdentifier = UniqueIdentifier ()
4677) = attest(attestor, AttestationStatus .REJECTED , metadata, linearId)
4778
79+ /* *
80+ * Amends a [MembershipAttestation] pointing to the existing [Membership] state.
81+ *
82+ * @param status The amended status of the [MembershipAttestation].
83+ * @param metadata Any extra metadata that should be applied to the attestation.
84+ * @return Returns an amended [MembershipAttestation] pointing to the existing [Membership] state.
85+ */
4886fun StateAndRef<MembershipAttestation>.amend (
4987 status : AttestationStatus ,
5088 metadata : Map <String , String > = this.state.data.metadata
5189) = this .state.data.amend(ref, status, state.data.pointer, metadata)
5290
91+ /* *
92+ * Amends a [MembershipAttestation] pointing to an evolved [Membership] state.
93+ *
94+ * @param status The amended status of the [MembershipAttestation].
95+ * @param membership The evolved [Membership] state that the amended [MembershipAttestation] will point to.
96+ * @param metadata Any extra metadata that should be applied to the attestation.
97+ * @return Returns an amended [MembershipAttestation] pointing to an evolved [Membership] state.
98+ */
5399fun StateAndRef<MembershipAttestation>.amend (
54100 membership : StateAndRef <Membership >,
55101 status : AttestationStatus ,
56102 metadata : Map <String , String > = this.state.data.metadata
57103) = this .state.data.amend(ref, status, membership.toStaticAttestationPointer(), metadata)
58104
105+ /* *
106+ * Amends and accepts a [MembershipAttestation] pointing to the existing [Membership] state.
107+ *
108+ * @param metadata Any extra metadata that should be applied to the attestation.
109+ * @return Returns an amended and accepted [MembershipAttestation] pointing to the existing [Membership] state.
110+ */
59111fun StateAndRef<MembershipAttestation>.accept (
60112 metadata : Map <String , String > = this.state.data.metadata
61113) = amend(AttestationStatus .ACCEPTED , metadata)
62114
115+ /* *
116+ * Amends and accepts a [MembershipAttestation] pointing to an evolved [Membership] state.
117+ *
118+ * @param membership The evolved [Membership] state that the amended [MembershipAttestation] will point to.
119+ * @param metadata Any extra metadata that should be applied to the attestation.
120+ * @return Returns an amended and accepted [MembershipAttestation] pointing to an evolved [Membership] state.
121+ */
63122fun StateAndRef<MembershipAttestation>.accept (
64123 membership : StateAndRef <Membership >,
65124 metadata : Map <String , String > = this.state.data.metadata
66125) = amend(membership, AttestationStatus .ACCEPTED , metadata)
67126
127+ /* *
128+ * Amends and rejects a [MembershipAttestation] pointing to the existing [Membership] state.
129+ *
130+ * @param metadata Any extra metadata that should be applied to the attestation.
131+ * @return Returns an amended and rejected [MembershipAttestation] pointing to the existing [Membership] state.
132+ */
68133fun StateAndRef<MembershipAttestation>.reject (
69134 metadata : Map <String , String > = this.state.data.metadata
70135) = amend(AttestationStatus .REJECTED , metadata)
71136
137+ /* *
138+ * Amends and rejects a [MembershipAttestation] pointing to an evolved [Membership] state.
139+ *
140+ * @param membership The evolved [Membership] state that the amended [MembershipAttestation] will point to.
141+ * @param metadata Any extra metadata that should be applied to the attestation.
142+ * @return Returns an amended and rejected [MembershipAttestation] pointing to an evolved [Membership] state.
143+ */
72144fun StateAndRef<MembershipAttestation>.reject (
73145 membership : StateAndRef <Membership >,
74146 metadata : Map <String , String > = this.state.data.metadata
0 commit comments