Skip to content

Commit

Permalink
Merge branch 'master' into fix-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
swcurran committed Jul 16, 2019
2 parents 8493e72 + 0336698 commit 8e23ffb
Show file tree
Hide file tree
Showing 18 changed files with 426 additions and 230 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
*.md text eol=lf
*.json text eol=lf
*.conf text eol=lf
**/s2i/bin/* text eol=lf
**/root/**/* text eol=lf
**/bin/* text eol=lf
1 change: 0 additions & 1 deletion DevReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Most configuration parameters are provided to the the agent at startup. Refer to
| `--no-receive-invites` | `--no-receive-invites` | Disables the receive invitations administration function. | `false` |
| `--help-link` | `--help-link` | Defines the help URL for the administration interface. | `false` |
| `--invite` | `--invite` | Generates and print a new connection invitation URL on start-up. | `false` |
| `--send-invite` | `--send-invite` | Specifies an endpoint to send an invitation to on start-up. | `false` |
| `--timing` | `--timing` | Includes timing information in response messages. | `false` |
| `--protocol` | `--protocol` | Instructs the agent to load an external protocol module. | `false` |
| `--webhook-url` | `--webhook-url` | Instructs the agent to send webhooks containing internal state changes to a URL. This is useful for a controller to monitor changes and prompt new behaviour using the admin API. | `false` |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Hyperledger Aries Cloud Agent - Python <!-- omit in toc -->

[![CircleCI](https://circleci.com/gh/bcgov/aries-cloudagent-python.svg?style=shield)](https://circleci.com/gh/bcgov/aries-cloudagent-python)
[![codecov](https://codecov.io/gh/bcgov/aries-cloudagent-python/branch/master/graph/badge.svg)](https://codecov.io/gh/bcgov/aries-cloudagent-python)
[![Known Vulnerabilities](https://snyk.io/test/github/bcgov/aries-cloudagent-python/badge.svg)](https://snyk.io/test/github/bcgov/aries-cloudagent-python?targetFile=requirements.txt)
[![CircleCI](https://circleci.com/gh/hyperledger/aries-cloudagent-python.svg?style=shield)](https://circleci.com/gh/hyperledger/aries-cloudagent-python)
[![codecov](https://codecov.io/gh/hyperledger/aries-cloudagent-python/branch/master/graph/badge.svg)](https://codecov.io/gh/hyperledger/aries-cloudagent-python)
[![Known Vulnerabilities](https://snyk.io/test/github/hyperledger/aries-cloudagent-python/badge.svg)](https://snyk.io/test/github/hyperledger/aries-cloudagent-python?targetFile=requirements.txt)

<!-- ![logo](/docs/assets/aries-cloudagent-python-logo-bw.png) -->

Expand Down
12 changes: 1 addition & 11 deletions aries_cloudagent/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,7 @@ async def start(self) -> None:
print("Invitation URL:")
print(invite_url)
except Exception:
self.logger.exception("Error sending invitation")

# Auto-send an invitation to another agent
send_invite_to = context.settings.get("debug.send_invitation_to")
if send_invite_to:
try:
mgr = ConnectionManager(self.context)
_connection, invitation = await mgr.create_invitation()
await mgr.send_invitation(invitation, send_invite_to)
except Exception:
self.logger.exception("Error sending invitation")
self.logger.exception("Error creating invitation")

async def stop(self, timeout=0.1):
"""Stop the agent."""
Expand Down
9 changes: 0 additions & 9 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,6 @@
help="Generate and print a new connection invitation URL",
)

PARSER.add_argument(
"--send-invite",
type=str,
metavar="<agent-endpoint>",
help="Specify an endpoint to send an invitation to",
)

PARSER.add_argument(
"--timing",
action="store_true",
Expand Down Expand Up @@ -325,8 +318,6 @@ def get_settings(args):
settings["debug.seed"] = args.debug_seed
if args.invite:
settings["debug.print_invitation"] = True
if args.send_invite:
settings["debug.send_invitation_to"] = args.send_invite

if args.auto_respond_credential_offer:
settings["auto_respond_credential_offer"] = True
Expand Down
14 changes: 11 additions & 3 deletions aries_cloudagent/ledger/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
from ..error import BaseError


class ClosedPoolError(BaseError):
class LedgerError(BaseError):
"""Base class for ledger errors."""


class BadLedgerRequestError(LedgerError):
"""The current request cannot proceed."""


class ClosedPoolError(LedgerError):
"""Indy pool is closed."""


class LedgerTransactionError(BaseError):
class LedgerTransactionError(LedgerError):
"""The ledger rejected the transaction."""


class DuplicateSchemaError(BaseError):
class DuplicateSchemaError(LedgerError):
"""The schema already exists on the ledger."""
32 changes: 21 additions & 11 deletions aries_cloudagent/ledger/indy.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
from ..wallet.base import BaseWallet

from .base import BaseLedger
from .error import ClosedPoolError, LedgerTransactionError, DuplicateSchemaError
from .error import (
BadLedgerRequestError,
ClosedPoolError,
LedgerTransactionError,
DuplicateSchemaError,
)

GENESIS_TRANSACTION_PATH = tempfile.gettempdir()
GENESIS_TRANSACTION_PATH = path.join(
Expand Down Expand Up @@ -160,9 +165,10 @@ async def _submit(self, request_json: str, sign=True) -> str:
"Cannot sign and submit request to closed pool {}".format(self.name)
)

public_did = await self.wallet.get_public_did()

if sign:
public_did = await self.wallet.get_public_did()
if not public_did:
raise BadLedgerRequestError("Cannot sign request without a public DID")
request_result_json = await indy.ledger.sign_and_submit_request(
self.pool_handle, self.wallet.handle, public_did.did, request_json
)
Expand All @@ -177,10 +183,7 @@ async def _submit(self, request_json: str, sign=True) -> str:

# HACK: If only there were a better way to identify this kind
# of rejected request...
if (
"can have one and only one SCHEMA with name"
in request_result_json
):
if "can have one and only one SCHEMA with name" in request_result_json:
raise DuplicateSchemaError()

if operation in ("REQNACK", "REJECT"):
Expand Down Expand Up @@ -210,6 +213,8 @@ async def send_schema(
"""

public_did = await self.wallet.get_public_did()
if not public_did:
raise BadLedgerRequestError("Cannot publish schema without a public DID")

schema_id, schema_json = await indy.anoncreds.issuer_create_schema(
public_did.did, schema_name, schema_version, json.dumps(attribute_names)
Expand Down Expand Up @@ -255,10 +260,10 @@ async def fetch_schema(self, schema_id: str):
public_did = await self.wallet.get_public_did()

request_json = await indy.ledger.build_get_schema_request(
public_did.did, schema_id
public_did.did if public_did else None, schema_id
)

response_json = await self._submit(request_json)
response_json = await self._submit(request_json, sign=bool(public_did))
_, parsed_schema_json = await indy.ledger.parse_get_schema_response(
response_json
)
Expand All @@ -282,6 +287,11 @@ async def send_credential_definition(self, schema_id: str, tag: str = "default")
"""

public_did = await self.wallet.get_public_did()
if not public_did:
raise BadLedgerRequestError(
"Cannot publish credential definition without a public DID"
)

schema = await self.get_schema(schema_id)

# TODO: add support for tag, sig type, and config
Expand Down Expand Up @@ -351,10 +361,10 @@ async def fetch_credential_definition(self, credential_definition_id: str):
public_did = await self.wallet.get_public_did()

request_json = await indy.ledger.build_get_cred_def_request(
public_did.did, credential_definition_id
public_did.did if public_did else None, credential_definition_id
)

response_json = await self._submit(request_json)
response_json = await self._submit(request_json, sign=bool(public_did))

(
_,
Expand Down
Loading

0 comments on commit 8e23ffb

Please sign in to comment.