@@ -39,6 +39,23 @@ import net.corda.core.transactions.SignedTransaction
39
39
*/
40
40
class AttestationCommandService (rpc : CordaRPCOps ) : RPCService(rpc) {
41
41
42
+ /* *
43
+ * Issues an attestation.
44
+ *
45
+ * @param T The [Attestation] type.
46
+ * @param attestation The attestation to issue.
47
+ * @param notary The notary to use for the transaction.
48
+ * @param observers Additional observers of the transaction.
49
+ * @return Returns a flow process handle.
50
+ */
51
+ fun <T : Attestation <* >> issueAttestation (
52
+ attestation : T ,
53
+ notary : Party ? = null,
54
+ observers : Set <Party > = emptySet()
55
+ ): FlowProgressHandle <SignedTransaction > {
56
+ return rpc.startTrackedFlow(IssueAttestationFlow ::Initiator , attestation, notary, observers)
57
+ }
58
+
42
59
/* *
43
60
* Issues an attestation.
44
61
*
@@ -50,6 +67,7 @@ class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
50
67
* @param linearId The unique identifier of the attestation.
51
68
* @param notary The notary to use for the transaction.
52
69
* @param observers Additional observers of the transaction.
70
+ * @return Returns a flow process handle.
53
71
*/
54
72
fun <T : ContractState > issueAttestation (
55
73
state : StateAndRef <T >,
@@ -60,98 +78,97 @@ class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
60
78
notary : Party ? = null,
61
79
observers : Set <Party > = emptySet()
62
80
): FlowProgressHandle <SignedTransaction > {
63
- return rpc.startTrackedFlow(
64
- IssueAttestationFlow ::Initiator ,
65
- state.attest(attestor, status, metadata, linearId),
66
- notary,
67
- observers
68
- )
81
+ val attestation = state.attest(attestor, status, metadata, linearId)
82
+ return issueAttestation(attestation, notary, observers)
83
+ }
84
+
85
+ /* *
86
+ * Amends an attestation.
87
+ *
88
+ * @param T The [Attestation] type.
89
+ * @param oldAttestation The old attestation to be consumed.
90
+ * @param newAttestation The new attestation to be created.
91
+ * @param observers Additional observers of the transaction.
92
+ * @return Returns a flow process handle.
93
+ */
94
+ fun <T : Attestation <* >> amendAttestation (
95
+ oldAttestation : StateAndRef <T >,
96
+ newAttestation : T ,
97
+ observers : Set <Party > = emptySet()
98
+ ): FlowProgressHandle <SignedTransaction > {
99
+ return rpc.startTrackedFlow(AmendAttestationFlow ::Initiator , oldAttestation, newAttestation, observers)
69
100
}
70
101
71
102
/* *
72
103
* Amends an attestation.
73
104
*
74
105
* @param T The underlying [ContractState] type.
75
- * @param attestation The attestation to be consumed.
106
+ * @param oldAttestation The old attestation to be consumed.
76
107
* @param status The status of the attestation.
77
108
* @param metadata Additional information about the attestation.
78
109
* @param observers Additional observers of the transaction.
110
+ * @return Returns a flow process handle.
79
111
*/
80
112
fun <T : ContractState > amendAttestation (
81
- attestation : StateAndRef <Attestation <T >>,
113
+ oldAttestation : StateAndRef <Attestation <T >>,
82
114
status : AttestationStatus = AttestationStatus .REJECTED ,
83
115
metadata : Map <String , String > = emptyMap(),
84
116
observers : Set <Party > = emptySet()
85
117
): FlowProgressHandle <SignedTransaction > {
86
- val amendedAttestation = attestation.amend(status, metadata = metadata)
87
- return rpc.startTrackedFlow(
88
- AmendAttestationFlow ::Initiator ,
89
- attestation,
90
- amendedAttestation,
91
- observers
92
- )
118
+ val newAttestation = oldAttestation.amend(status, metadata = metadata)
119
+ return amendAttestation(oldAttestation, newAttestation, observers)
93
120
}
94
121
95
122
/* *
96
123
* Amends an attestation.
97
124
*
98
125
* @param T The underlying [ContractState] type.
99
- * @param attestation The attestation to be consumed.
126
+ * @param oldAttestation The old attestation to be consumed.
100
127
* @param state The state being attested.
101
128
* @param status The status of the attestation.
102
129
* @param metadata Additional information about the attestation.
103
130
* @param observers Additional observers of the transaction.
131
+ * @return Returns a flow process handle.
104
132
*/
105
133
fun <T : ContractState > amendAttestation (
106
- attestation : StateAndRef <Attestation <T >>,
134
+ oldAttestation : StateAndRef <Attestation <T >>,
107
135
state : StateAndRef <T >,
108
136
status : AttestationStatus = AttestationStatus .REJECTED ,
109
137
metadata : Map <String , String > = emptyMap(),
110
138
observers : Set <Party > = emptySet()
111
139
): FlowProgressHandle <SignedTransaction > {
112
140
val pointer = state.toAttestationPointer()
113
- val amendedAttestation = attestation.amend(status, pointer, metadata)
114
- return rpc.startTrackedFlow(
115
- AmendAttestationFlow ::Initiator ,
116
- attestation,
117
- amendedAttestation,
118
- observers
119
- )
141
+ val newAttestation = oldAttestation.amend(status, pointer, metadata)
142
+ return amendAttestation(oldAttestation, newAttestation, observers)
120
143
}
121
144
122
145
/* *
123
146
* Revokes an attestation.
124
147
*
125
- * @param T The underlying [ContractState ] type.
148
+ * @param T The [Attestation ] type.
126
149
* @param attestation The attestation to be consumed.
127
150
* @param observers Additional observers of the transaction.
151
+ * @return Returns a flow process handle.
128
152
*/
129
- fun <T : ContractState > revokeAttestation (
130
- attestation : StateAndRef <Attestation < T > >,
153
+ fun <T : Attestation < * > > revokeAttestation (
154
+ attestation : StateAndRef <T >,
131
155
observers : Set <Party > = emptySet()
132
156
): FlowProgressHandle <SignedTransaction > {
133
- return rpc.startTrackedFlow(
134
- RevokeAttestationFlow ::Initiator ,
135
- attestation,
136
- observers
137
- )
157
+ return rpc.startTrackedFlow(RevokeAttestationFlow ::Initiator , attestation, observers)
138
158
}
139
159
140
160
/* *
141
161
* Publishes an attestation.
142
162
*
143
- * @param T The underlying [ContractState ] type.
163
+ * @param T The [Attestation ] type.
144
164
* @param attestation The attestation to be published.
145
165
* @param observers Observers of the attestation.
166
+ * @return Returns a flow process handle.
146
167
*/
147
- fun <T : ContractState > publishAttestation (
148
- attestation : StateAndRef <Attestation < T > >,
168
+ fun <T : Attestation < * > > publishAttestation (
169
+ attestation : StateAndRef <T >,
149
170
observers : Set <Party >
150
171
): FlowProgressHandle <SignedTransaction > {
151
- return rpc.startTrackedFlow(
152
- PublishAttestationFlow ::Initiator ,
153
- attestation,
154
- observers
155
- )
172
+ return rpc.startTrackedFlow(PublishAttestationFlow ::Initiator , attestation, observers)
156
173
}
157
174
}
0 commit comments