@@ -39,6 +39,23 @@ import net.corda.core.transactions.SignedTransaction
3939 */
4040class AttestationCommandService (rpc : CordaRPCOps ) : RPCService(rpc) {
4141
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+
4259 /* *
4360 * Issues an attestation.
4461 *
@@ -50,6 +67,7 @@ class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
5067 * @param linearId The unique identifier of the attestation.
5168 * @param notary The notary to use for the transaction.
5269 * @param observers Additional observers of the transaction.
70+ * @return Returns a flow process handle.
5371 */
5472 fun <T : ContractState > issueAttestation (
5573 state : StateAndRef <T >,
@@ -60,98 +78,97 @@ class AttestationCommandService(rpc: CordaRPCOps) : RPCService(rpc) {
6078 notary : Party ? = null,
6179 observers : Set <Party > = emptySet()
6280 ): 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)
69100 }
70101
71102 /* *
72103 * Amends an attestation.
73104 *
74105 * @param T The underlying [ContractState] type.
75- * @param attestation The attestation to be consumed.
106+ * @param oldAttestation The old attestation to be consumed.
76107 * @param status The status of the attestation.
77108 * @param metadata Additional information about the attestation.
78109 * @param observers Additional observers of the transaction.
110+ * @return Returns a flow process handle.
79111 */
80112 fun <T : ContractState > amendAttestation (
81- attestation : StateAndRef <Attestation <T >>,
113+ oldAttestation : StateAndRef <Attestation <T >>,
82114 status : AttestationStatus = AttestationStatus .REJECTED ,
83115 metadata : Map <String , String > = emptyMap(),
84116 observers : Set <Party > = emptySet()
85117 ): 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)
93120 }
94121
95122 /* *
96123 * Amends an attestation.
97124 *
98125 * @param T The underlying [ContractState] type.
99- * @param attestation The attestation to be consumed.
126+ * @param oldAttestation The old attestation to be consumed.
100127 * @param state The state being attested.
101128 * @param status The status of the attestation.
102129 * @param metadata Additional information about the attestation.
103130 * @param observers Additional observers of the transaction.
131+ * @return Returns a flow process handle.
104132 */
105133 fun <T : ContractState > amendAttestation (
106- attestation : StateAndRef <Attestation <T >>,
134+ oldAttestation : StateAndRef <Attestation <T >>,
107135 state : StateAndRef <T >,
108136 status : AttestationStatus = AttestationStatus .REJECTED ,
109137 metadata : Map <String , String > = emptyMap(),
110138 observers : Set <Party > = emptySet()
111139 ): FlowProgressHandle <SignedTransaction > {
112140 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)
120143 }
121144
122145 /* *
123146 * Revokes an attestation.
124147 *
125- * @param T The underlying [ContractState ] type.
148+ * @param T The [Attestation ] type.
126149 * @param attestation The attestation to be consumed.
127150 * @param observers Additional observers of the transaction.
151+ * @return Returns a flow process handle.
128152 */
129- fun <T : ContractState > revokeAttestation (
130- attestation : StateAndRef <Attestation < T > >,
153+ fun <T : Attestation < * > > revokeAttestation (
154+ attestation : StateAndRef <T >,
131155 observers : Set <Party > = emptySet()
132156 ): FlowProgressHandle <SignedTransaction > {
133- return rpc.startTrackedFlow(
134- RevokeAttestationFlow ::Initiator ,
135- attestation,
136- observers
137- )
157+ return rpc.startTrackedFlow(RevokeAttestationFlow ::Initiator , attestation, observers)
138158 }
139159
140160 /* *
141161 * Publishes an attestation.
142162 *
143- * @param T The underlying [ContractState ] type.
163+ * @param T The [Attestation ] type.
144164 * @param attestation The attestation to be published.
145165 * @param observers Observers of the attestation.
166+ * @return Returns a flow process handle.
146167 */
147- fun <T : ContractState > publishAttestation (
148- attestation : StateAndRef <Attestation < T > >,
168+ fun <T : Attestation < * > > publishAttestation (
169+ attestation : StateAndRef <T >,
149170 observers : Set <Party >
150171 ): FlowProgressHandle <SignedTransaction > {
151- return rpc.startTrackedFlow(
152- PublishAttestationFlow ::Initiator ,
153- attestation,
154- observers
155- )
172+ return rpc.startTrackedFlow(PublishAttestationFlow ::Initiator , attestation, observers)
156173 }
157174}
0 commit comments