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

Do not fail with an error when no ledger is configured #145

Merged
Merged
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
6 changes: 4 additions & 2 deletions aries_cloudagent/config/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ async def ledger_config(
taa_info = await ledger.get_txn_author_agreement()
if taa_info["taa_required"] and public_did:
taa_accepted = await ledger.get_latest_txn_author_acceptance()
if not taa_accepted \
or taa_info["taa_record"]["digest"] != taa_accepted["digest"]:
if (
not taa_accepted
or taa_info["taa_record"]["digest"] != taa_accepted["digest"]
):
if not await accept_taa(ledger, taa_info, provision):
return False

Expand Down
24 changes: 14 additions & 10 deletions aries_cloudagent/ledger/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ async def provide(self, settings: BaseSettings, injector: BaseInjector):
pool_name = settings.get("ledger.pool_name", "default")
keepalive = int(settings.get("ledger.keepalive", 5))
wallet = await injector.inject(BaseWallet)
IndyLedger = ClassLoader.load_class(self.LEDGER_CLASSES["indy"])
cache = await injector.inject(BaseCache, required=False)
ledger = IndyLedger(pool_name, wallet, keepalive=keepalive, cache=cache)

genesis_transactions = settings.get("ledger.genesis_transactions")
if genesis_transactions:
await ledger.create_pool_config(genesis_transactions, True)
elif not await ledger.check_pool_config():
LOGGER.info("Ledger pool configuration has not been created")
ledger = None
ledger = None

if wallet.WALLET_TYPE == "indy":
IndyLedger = ClassLoader.load_class(self.LEDGER_CLASSES["indy"])
cache = await injector.inject(BaseCache, required=False)
ledger = IndyLedger(pool_name, wallet, keepalive=keepalive, cache=cache)

genesis_transactions = settings.get("ledger.genesis_transactions")
if genesis_transactions:
await ledger.create_pool_config(genesis_transactions, True)
elif not await ledger.check_pool_config():
LOGGER.info("Ledger pool configuration has not been created")
ledger = None

return ledger