Skip to content

Commit

Permalink
Implement scenario when author role not set
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <[email protected]>
  • Loading branch information
jamshale committed Jan 18, 2024
1 parent b5cfee0 commit ef2b031
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
34 changes: 18 additions & 16 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,26 @@ async def register_schema(
}
LOGGER.debug("schema value: %s", indy_schema)

# No endorser did then don't need endorsement
endorser_did = None
if is_author_role(profile):
create_transaction = options.get("create_transaction_for_endorser", False)

if is_author_role(profile) or create_transaction:
endorser_did, endorser_connection_id = await get_endorser_info(
profile, options
)

write_ledger = (
True if endorser_did is None and not create_transaction else False
)

# Get either the transaction or the seq_no or the created schema
async with ledger:
try:
result = await shield(
ledger.send_schema_anoncreds(
schema_id,
indy_schema,
write_ledger=True if endorser_did is None else False,
write_ledger=write_ledger,
endorser_did=endorser_did,
)
)
Expand All @@ -245,13 +251,8 @@ async def register_schema(
except (AnonCredsIssuerError, LedgerError) as err:
raise AnonCredsRegistrationError("Failed to register schema") from err

meta_data = {
"context": {"schema_id": schema_id, "schema": schema.serialize()},
"processing": {},
}

# Don't need endorsement, so return schema result
if not endorser_did:
# Didn't need endorsement, so return schema result
if write_ledger:
return SchemaResult(
job_id=None,
schema_state=SchemaState(
Expand All @@ -263,6 +264,12 @@ async def register_schema(
schema_metadata={"seqNo": result},
)

# Need endorsement, so execute transaction flow
meta_data = {
"context": {"schema_id": schema_id, "schema": schema.serialize()},
"processing": {},
}

(schema_id, schema_def) = result
transaction_manager = TransactionManager(profile)
try:
Expand All @@ -279,12 +286,7 @@ async def register_schema(
(
transaction,
transaction_request,
) = await transaction_manager.create_request(
transaction=transaction,
# TODO see if we need to parameterize these params
# expires_time=expires_time,
# endorser_write_txn=endorser_write_txn,
)
) = await transaction_manager.create_request(transaction=transaction)
except (StorageError, TransactionManagerError) as err:
raise AnonCredsRegistrationError(
"Transaction manager failed to create request: " + err.roll_up
Expand Down
4 changes: 3 additions & 1 deletion demo/features/0586-sign-transaction.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ Feature: RFC 0586 Aries sign (endorse) transactions functions
@WalletType_Askar_AnonCreds
Examples:
| Acme_capabilities | Bob_capabilities | Schema_name |
| --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | anoncreds-testing |
| --wallet-type askar-anoncreds | --wallet-type askar-anoncreds | anoncreds-testing |
| --wallet-type askar-anoncreds | | driverslicense |
| | --wallet-type askar-anoncreds | anoncreds-testing |


@T001.1-RFC0586 @GHA
Expand Down
9 changes: 6 additions & 3 deletions demo/features/steps/0586-sign-transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def step_impl(context, agent_name, schema_name):
)
else:
schema_info["schema"]["issuerId"] = context.public_dids["AUTHOR"]
schema_info["options"]["create_transaction_for_endorser"] = True
schema_info["options"]["endorser_connection_id"] = connection_id
created_txn = agent_container_POST(
agent["agent"],
"/anoncreds/schema",
Expand Down Expand Up @@ -197,8 +199,6 @@ def step_impl(context, agent_name):
def step_impl(context, agent_name, schema_name):
agent = context.active_agents[agent_name]

schema_info = read_schema_data(schema_name)

schemas = {"schema_ids": []}
i = 5
while 0 == len(schemas["schema_ids"]) and i > 0:
Expand All @@ -208,7 +208,10 @@ def step_impl(context, agent_name, schema_name):
assert len(schemas["schema_ids"]) == 1

schema_id = schemas["schema_ids"][0]
schema = agent_container_GET(agent["agent"], "/schemas/" + schema_id)
if agent["agent"].wallet_type != "askar-anoncreds":
agent_container_GET(agent["agent"], "/schemas/" + schema_id)
else:
agent_container_GET(agent["agent"], "/anoncreds/schema/" + schema_id)

context.schema_name = schema_name

Expand Down

0 comments on commit ef2b031

Please sign in to comment.