@@ -19,56 +19,128 @@ package io.onixlabs.corda.bnms.contract.membership
19
19
import io.onixlabs.corda.identityframework.contract.attestations.AttestationStatus
20
20
import io.onixlabs.corda.identityframework.contract.toStaticAttestationPointer
21
21
import net.corda.core.contracts.StateAndRef
22
+ import net.corda.core.contracts.StateRef
22
23
import net.corda.core.contracts.UniqueIdentifier
23
24
import net.corda.core.identity.AbstractParty
24
25
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
+ */
25
31
fun StateAndRef<Membership>.getNextOutput (): Membership {
26
32
return state.data.copy(previousStateRef = ref)
27
33
}
28
34
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
+ */
29
44
fun StateAndRef<Membership>.attest (
30
45
attestor : AbstractParty ,
31
46
status : AttestationStatus ,
32
47
metadata : Map <String , String > = emptyMap(),
33
48
linearId : UniqueIdentifier = UniqueIdentifier ()
34
49
) = MembershipAttestation (attestor, this , status, metadata, linearId)
35
50
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
+ */
36
59
fun StateAndRef<Membership>.accept (
37
60
attestor : AbstractParty ,
38
61
metadata : Map <String , String > = emptyMap(),
39
62
linearId : UniqueIdentifier = UniqueIdentifier ()
40
63
) = attest(attestor, AttestationStatus .ACCEPTED , metadata, linearId)
41
64
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
+ */
42
73
fun StateAndRef<Membership>.reject (
43
74
attestor : AbstractParty ,
44
75
metadata : Map <String , String > = emptyMap(),
45
76
linearId : UniqueIdentifier = UniqueIdentifier ()
46
77
) = attest(attestor, AttestationStatus .REJECTED , metadata, linearId)
47
78
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
+ */
48
86
fun StateAndRef<MembershipAttestation>.amend (
49
87
status : AttestationStatus ,
50
88
metadata : Map <String , String > = this.state.data.metadata
51
89
) = this .state.data.amend(ref, status, state.data.pointer, metadata)
52
90
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
+ */
53
99
fun StateAndRef<MembershipAttestation>.amend (
54
100
membership : StateAndRef <Membership >,
55
101
status : AttestationStatus ,
56
102
metadata : Map <String , String > = this.state.data.metadata
57
103
) = this .state.data.amend(ref, status, membership.toStaticAttestationPointer(), metadata)
58
104
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
+ */
59
111
fun StateAndRef<MembershipAttestation>.accept (
60
112
metadata : Map <String , String > = this.state.data.metadata
61
113
) = amend(AttestationStatus .ACCEPTED , metadata)
62
114
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
+ */
63
122
fun StateAndRef<MembershipAttestation>.accept (
64
123
membership : StateAndRef <Membership >,
65
124
metadata : Map <String , String > = this.state.data.metadata
66
125
) = amend(membership, AttestationStatus .ACCEPTED , metadata)
67
126
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
+ */
68
133
fun StateAndRef<MembershipAttestation>.reject (
69
134
metadata : Map <String , String > = this.state.data.metadata
70
135
) = amend(AttestationStatus .REJECTED , metadata)
71
136
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
+ */
72
144
fun StateAndRef<MembershipAttestation>.reject (
73
145
membership : StateAndRef <Membership >,
74
146
metadata : Map <String , String > = this.state.data.metadata
0 commit comments