Skip to content

Commit 783966b

Browse files
authored
Fetch schemaId on legacy cred def (#3988)
* fix schemaId for legacy resolver Signed-off-by: Patrick St-Louis <[email protected]> * linting Signed-off-by: Patrick St-Louis <[email protected]> --------- Signed-off-by: Patrick St-Louis <[email protected]>
1 parent 2963ba3 commit 783966b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

acapy_agent/anoncreds/default/legacy_indy/registry.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,25 @@ async def get_credential_definition(
358358
{"ledger_id": ledger_id},
359359
)
360360

361+
# Convert seqNo to schema_id if needed
362+
schema_id_from_cred_def = cred_def["schemaId"]
363+
if schema_id_from_cred_def.isdigit():
364+
# schemaId is a seqNo, fetch the actual schema to get its ID
365+
try:
366+
schema = await ledger.fetch_schema_by_seq_no(
367+
int(schema_id_from_cred_def)
368+
)
369+
if schema and schema.get("id"):
370+
schema_id_from_cred_def = schema["id"]
371+
# If schema is None or missing id, fall back to seqNo
372+
except LedgerError:
373+
# If fetching fails, fall back to using seqNo as schemaId
374+
pass
375+
361376
cred_def_value = CredDefValue.deserialize(cred_def["value"])
362377
anoncreds_credential_definition = CredDef(
363378
issuer_id=cred_def["id"].split(":")[0],
364-
schema_id=cred_def["schemaId"],
379+
schema_id=schema_id_from_cred_def,
365380
type=cred_def["type"],
366381
tag=cred_def["tag"],
367382
value=cred_def_value,

0 commit comments

Comments
 (0)