Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for endorser support to update endpoints on ledger. #1616

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aries_cloudagent/ledger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ async def update_endpoint_for_did(
did: str,
endpoint: str,
endpoint_type: EndpointType = EndpointType.ENDPOINT,
write_ledger: bool = True,
endorser_did: str = None,
) -> bool:
"""Check and update the endpoint on the ledger.

Expand Down
27 changes: 26 additions & 1 deletion aries_cloudagent/ledger/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,12 @@ async def get_endpoint_for_did(
return address
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to make these same changes in the indy_vdr.py version of the ledger

(this is enabled when you use --wallet-type askar)


async def update_endpoint_for_did(
self, did: str, endpoint: str, endpoint_type: EndpointType = None
self,
did: str,
endpoint: str,
endpoint_type: EndpointType = None,
write_ledger: bool = True,
endorser_did: str = None,
) -> bool:
"""Check and update the endpoint on the ledger.

Expand All @@ -895,6 +900,12 @@ async def update_endpoint_for_did(
endpoint: The endpoint address
endpoint_type: The type of the endpoint
"""
public_info = await self.get_wallet_public_did()
if not public_info:
raise BadLedgerRequestError(
"Cannot update endpoint at ledger without a public DID"
)

if not endpoint_type:
endpoint_type = EndpointType.ENDPOINT

Expand Down Expand Up @@ -923,6 +934,20 @@ async def update_endpoint_for_did(
request_json = await indy.ledger.build_attrib_request(
nym, nym, None, attr_json, None
)

if endorser_did and not write_ledger:
request_json = await indy.ledger.append_request_endorser(
request_json, endorser_did
)
resp = await self._submit(
request_json,
True,
sign_did=public_info,
write_ledger=write_ledger,
)
if not write_ledger:
return {"signed_txn": resp}

await self._submit(request_json, True, True)
return True
return False
Expand Down
12 changes: 11 additions & 1 deletion aries_cloudagent/wallet/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ async def set_did_endpoint(
endpoint: str,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to make these same changes in the askar.py version of the ledger

(this is enabled when you use --wallet-type askar)

ledger: BaseLedger,
endpoint_type: EndpointType = None,
write_ledger: bool = True,
endorser_did: str = None,
):
"""
Update the endpoint for a DID in the wallet, send to ledger if public or posted.
Expand Down Expand Up @@ -738,7 +740,15 @@ async def set_did_endpoint(
)
if not ledger.read_only:
async with ledger:
await ledger.update_endpoint_for_did(did, endpoint, endpoint_type)
attrib_def = await ledger.update_endpoint_for_did(
did,
endpoint,
endpoint_type,
write_ledger=write_ledger,
endorser_did=endorser_did,
)
if not write_ledger:
return attrib_def

await self.replace_local_did_metadata(did, metadata)

Expand Down
Loading