9
9
IssuerCredRevRecord ,
10
10
IssuerRevRegRecord ,
11
11
PublishRevocations ,
12
+ PublishRevocationsOptions ,
13
+ PublishRevocationsResultSchemaAnoncreds ,
12
14
PublishRevocationsSchemaAnoncreds ,
13
15
RevokeRequest ,
14
16
RevokeRequestSchemaAnoncreds ,
@@ -200,7 +202,7 @@ async def revoke_credential(
200
202
201
203
async def publish_pending_revocations (
202
204
controller : AcaPyClient , revocation_registry_credential_map : Dict [str , List [str ]]
203
- ) -> TxnOrPublishRevocationsResult :
205
+ ) -> Optional [ TxnOrPublishRevocationsResult ] :
204
206
"""
205
207
Publish pending revocations
206
208
@@ -226,7 +228,8 @@ async def publish_pending_revocations(
226
228
if wallet_type == "askar-anoncreds" :
227
229
acapy_call = controller .anoncreds_revocation .publish_revocations
228
230
body = PublishRevocationsSchemaAnoncreds (
229
- rrid2crid = revocation_registry_credential_map
231
+ rrid2crid = revocation_registry_credential_map ,
232
+ options = PublishRevocationsOptions (create_transaction_for_endorser = True ),
230
233
)
231
234
else : # wallet_type == "askar":
232
235
acapy_call = controller .revocation .publish_revocations
@@ -242,20 +245,37 @@ async def publish_pending_revocations(
242
245
f"Failed to publish pending revocations: { e .detail } " , e .status_code
243
246
) from e
244
247
245
- if not result .txn or not result .txn [0 ].transaction_id :
248
+ if isinstance (result , TxnOrPublishRevocationsResult ):
249
+ if not result .txn or not result .txn [0 ].transaction_id :
250
+ bound_logger .warning (
251
+ "Published pending revocations but received no endorser transaction id. Got result: {}" ,
252
+ result ,
253
+ )
254
+ return
255
+
256
+ bound_logger .debug (
257
+ "Successfully published pending Indy revocations. Endorser transaction ids: {}." ,
258
+ [txn .transaction_id for txn in result .txn ],
259
+ )
260
+ return result
261
+ elif isinstance (result , PublishRevocationsResultSchemaAnoncreds ):
262
+ bound_logger .info (
263
+ "Successfully published pending AnonCreds revocations: {}." , result
264
+ )
265
+ # Cast integer cred_rev_ids to string
266
+ rrid2crid = result .rrid2crid if result .rrid2crid else {}
267
+ rrid2crid = {k : [str (i ) for i in v ] for k , v in result .rrid2crid .items ()}
268
+ return TxnOrPublishRevocationsResult (
269
+ rrid2crid = rrid2crid ,
270
+ txn = None ,
271
+ )
272
+ else :
246
273
bound_logger .warning (
247
- "Published pending revocations but received no endorser transaction id. Got result: {} " ,
274
+ "Unexpected response from publish_revocations: `{}`. Perhaps empty publish request? " ,
248
275
result ,
249
276
)
250
277
return
251
278
252
- endorse_transaction_ids = [txn .transaction_id for txn in result .txn ]
253
- bound_logger .debug (
254
- "Successfully published pending revocations. Endorser transaction ids: {}." ,
255
- endorse_transaction_ids ,
256
- )
257
- return result
258
-
259
279
260
280
async def clear_pending_revocations (
261
281
controller : AcaPyClient , revocation_registry_credential_map : Dict [str , List [str ]]
0 commit comments