From 732dc8ca76aef133b3b6e47048b9bf50c47b7b4e Mon Sep 17 00:00:00 2001 From: Andrew Whitehead Date: Wed, 14 Aug 2019 14:46:26 -0700 Subject: [PATCH] do not fail with an error when no ledger is configured Signed-off-by: Andrew Whitehead --- aries_cloudagent/config/ledger.py | 6 ++++-- aries_cloudagent/ledger/provider.py | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/aries_cloudagent/config/ledger.py b/aries_cloudagent/config/ledger.py index 6bca354c26..1c1ab23862 100644 --- a/aries_cloudagent/config/ledger.py +++ b/aries_cloudagent/config/ledger.py @@ -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 diff --git a/aries_cloudagent/ledger/provider.py b/aries_cloudagent/ledger/provider.py index 0c09aac0b4..29dac6ecd6 100644 --- a/aries_cloudagent/ledger/provider.py +++ b/aries_cloudagent/ledger/provider.py @@ -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