|
12 | 12 | from web3.middleware import geth_poa_middleware |
13 | 13 | from web3.types import TxReceipt |
14 | 14 |
|
| 15 | +from ....anoncreds.events import RevListFinishedEvent |
15 | 16 | from ....cache.base import BaseCache |
16 | 17 | from ....config.injection_context import InjectionContext |
| 18 | +from ....core.event_bus import EventBus |
17 | 19 | from ....core.profile import Profile |
18 | 20 | from ....ledger.base import BaseLedger |
19 | 21 | from ....ledger.error import ( |
@@ -258,8 +260,8 @@ async def send_transaction_tx(self, call_function) -> TxReceipt: |
258 | 260 |
|
259 | 261 | if tx_receipt["status"] == 0: |
260 | 262 | LOGGER.debug("Receipt of the reverted transaction: %s", tx_receipt) |
261 | | - raise AnonCredsRegistrationError(f"Transaction reverted: %s", send_tx) |
262 | | - |
| 263 | + raise AnonCredsRegistrationError("Transaction reverted: %s", send_tx) |
| 264 | + |
263 | 265 | return tx_receipt |
264 | 266 |
|
265 | 267 | async def register_revocation( |
@@ -629,7 +631,9 @@ async def register_revocation_registry_definition( |
629 | 631 | try: |
630 | 632 | contract.functions.resolveRevocation(rev_reg_def_id).call() |
631 | 633 | except ContractCustomError as e: |
632 | | - raise AnonCredsRegistrationError("Error searching for newly created revocation") from e |
| 634 | + raise AnonCredsRegistrationError( |
| 635 | + "Error searching for newly created revocation" |
| 636 | + ) from e |
633 | 637 |
|
634 | 638 | seq_no = self.REVOCATION_ADDRESS |
635 | 639 | except LedgerError as err: |
@@ -673,7 +677,7 @@ async def _get_or_fetch_rev_reg_def_max_cred_num( |
673 | 677 |
|
674 | 678 | def _indexes_to_bit_array(self, indexes: List[int], size: int) -> List[int]: |
675 | 679 | """Turn a sequence of indexes into a full state bit array.""" |
676 | | - return [1 if index in indexes else 0 for index in range(1, size + 1)] |
| 680 | + return [1 if index in indexes else 0 for index in range(0, size + 1)] |
677 | 681 |
|
678 | 682 | async def _get_ledger(self, profile: Profile, rev_reg_def_id: str): |
679 | 683 | async with profile.session() as session: |
@@ -864,20 +868,33 @@ async def update_revocation_list( |
864 | 868 | options: Optional[dict] = None, |
865 | 869 | ) -> RevListResult: |
866 | 870 | """Update a revocation list.""" |
| 871 | + delta, _ = await self.get_revocation_registry_delta( |
| 872 | + profile, curr_list.rev_reg_def_id, 0 |
| 873 | + ) |
| 874 | + delta_list = delta["value"]["revoked"] if delta["value"].get("revoked") else [] |
867 | 875 | newly_revoked_indices = list(revoked) |
| 876 | + full_revoked_list = newly_revoked_indices + delta_list |
868 | 877 | rev_reg_entry = { |
869 | 878 | "ver": "1.0", |
870 | 879 | "value": { |
871 | 880 | "accum": curr_list.current_accumulator, |
872 | 881 | "prevAccum": prev_list.current_accumulator, |
873 | | - "revoked": newly_revoked_indices, |
| 882 | + "revoked": full_revoked_list, |
874 | 883 | }, |
875 | 884 | } |
876 | 885 |
|
877 | 886 | await self._revoc_reg_entry_with_fix( |
878 | 887 | profile, curr_list, rev_reg_def.type, rev_reg_entry |
879 | 888 | ) |
880 | 889 |
|
| 890 | + event_bus = profile.inject(EventBus) |
| 891 | + await event_bus.notify( |
| 892 | + profile, |
| 893 | + RevListFinishedEvent.with_payload( |
| 894 | + curr_list.rev_reg_def_id, newly_revoked_indices |
| 895 | + ), |
| 896 | + ) |
| 897 | + |
881 | 898 | return RevListResult( |
882 | 899 | job_id=None, |
883 | 900 | revocation_list_state=RevListState( |
|
0 commit comments