|
33 | 33 | STATE_FINISHED, |
34 | 34 | ) |
35 | 35 | from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG |
36 | | -from .events import CredDefFinishedEvent |
| 36 | +from .events import CredDefFinishedEvent, SchemaFinishedEvent |
37 | 37 | from .models.credential_definition import CredDef, CredDefResult |
38 | 38 | from .models.schema import AnonCredsSchema, GetSchemaResult, SchemaResult, SchemaState |
39 | 39 | from .registry import AnonCredsRegistry |
@@ -156,6 +156,18 @@ async def store_schema( |
156 | 156 | "state": result.schema_state.state, |
157 | 157 | }, |
158 | 158 | ) |
| 159 | + |
| 160 | + if result.schema_state.state == STATE_FINISHED: |
| 161 | + await self.notify( |
| 162 | + SchemaFinishedEvent.with_payload( |
| 163 | + schema_id=result.schema_state.schema_id, |
| 164 | + issuer_id=result.schema_state.schema.issuer_id, |
| 165 | + name=result.schema_state.schema.name, |
| 166 | + version=result.schema_state.schema.version, |
| 167 | + attr_names=result.schema_state.schema.attr_names, |
| 168 | + options={}, |
| 169 | + ) |
| 170 | + ) |
159 | 171 | except DBError as err: |
160 | 172 | raise AnonCredsIssuerError("Error storing schema") from err |
161 | 173 |
|
@@ -240,9 +252,25 @@ async def create_and_register_schema( |
240 | 252 | async def finish_schema(self, job_id: str, schema_id: str) -> None: |
241 | 253 | """Mark a schema as finished.""" |
242 | 254 | async with self.profile.transaction() as txn: |
243 | | - await self._finish_registration(txn, CATEGORY_SCHEMA, job_id, schema_id) |
| 255 | + entry = await self._finish_registration( |
| 256 | + txn, CATEGORY_SCHEMA, job_id, schema_id |
| 257 | + ) |
244 | 258 | await txn.commit() |
245 | 259 |
|
| 260 | + from .models.schema import AnonCredsSchema |
| 261 | + |
| 262 | + schema = AnonCredsSchema.from_json(entry.value) |
| 263 | + await self.notify( |
| 264 | + SchemaFinishedEvent.with_payload( |
| 265 | + schema_id=schema_id, |
| 266 | + issuer_id=schema.issuer_id, |
| 267 | + name=schema.name, |
| 268 | + version=schema.version, |
| 269 | + attr_names=schema.attr_names, |
| 270 | + options={}, |
| 271 | + ) |
| 272 | + ) |
| 273 | + |
246 | 274 | async def get_created_schemas( |
247 | 275 | self, |
248 | 276 | name: Optional[str] = None, |
@@ -434,13 +462,17 @@ async def store_credential_definition( |
434 | 462 | await txn.commit() |
435 | 463 |
|
436 | 464 | if cred_def_result.credential_definition_state.state == STATE_FINISHED: |
| 465 | + cred_def = ( |
| 466 | + cred_def_result.credential_definition_state.credential_definition |
| 467 | + ) |
437 | 468 | await self.notify( |
438 | 469 | CredDefFinishedEvent.with_payload( |
439 | 470 | schema_id=schema_result.schema_id, |
440 | 471 | cred_def_id=identifier, |
441 | | - issuer_id=cred_def_result.credential_definition_state.credential_definition.issuer_id, |
| 472 | + issuer_id=cred_def.issuer_id, |
442 | 473 | support_revocation=support_revocation, |
443 | 474 | max_cred_num=max_cred_num, |
| 475 | + tag=cred_def.tag, |
444 | 476 | options=options, |
445 | 477 | ) |
446 | 478 | ) |
@@ -477,6 +509,7 @@ async def finish_cred_def( |
477 | 509 | issuer_id=cred_def.issuer_id, |
478 | 510 | support_revocation=support_revocation, |
479 | 511 | max_cred_num=max_cred_num, |
| 512 | + tag=cred_def.tag, |
480 | 513 | options=options, |
481 | 514 | ) |
482 | 515 | ) |
|
0 commit comments