@@ -33,14 +33,18 @@ async def fetch_genesis_transactions(genesis_url: str) -> str:
3333 # https://github.com/openwallet-foundation/acapy/issues/1745
3434 return await fetch (genesis_url , headers = headers , max_attempts = 20 )
3535 except FetchError as e :
36+ LOGGER .error ("Error retrieving genesis transactions from %s: %s" , genesis_url , e )
3637 raise ConfigError ("Error retrieving ledger genesis transactions" ) from e
3738
3839
3940async def get_genesis_transactions (settings : Settings ) -> str :
4041 """Fetch genesis transactions if necessary."""
4142
43+ LOGGER .debug ("Getting genesis transactions from settings" )
4244 txns = settings .get ("ledger.genesis_transactions" )
45+ LOGGER .debug ("Genesis transactions from settings: %s" , "found" if txns else "absent" )
4346 if not txns :
47+ LOGGER .debug ("No genesis transactions found in settings" )
4448 if settings .get ("ledger.genesis_url" ):
4549 txns = await fetch_genesis_transactions (settings ["ledger.genesis_url" ])
4650 elif settings .get ("ledger.genesis_file" ):
@@ -50,8 +54,10 @@ async def get_genesis_transactions(settings: Settings) -> str:
5054 with open (genesis_path , "r" ) as genesis_file :
5155 txns = genesis_file .read ()
5256 except IOError as e :
57+ LOGGER .error ("Failed to read genesis file: %s" , str (e ))
5358 raise ConfigError ("Error reading ledger genesis transactions" ) from e
5459 if txns :
60+ LOGGER .debug ("Storing genesis transactions in settings" )
5561 settings ["ledger.genesis_transactions" ] = txns
5662 return txns
5763
@@ -62,6 +68,8 @@ async def load_multiple_genesis_transactions_from_config(settings: Settings):
6268 ledger_config_list = settings .get ("ledger.ledger_config_list" )
6369 ledger_txns_list = []
6470 write_ledger_set = False
71+ LOGGER .debug ("Processing %d ledger configs" , len (ledger_config_list ))
72+
6573 for config in ledger_config_list :
6674 txns = None
6775 if "genesis_transactions" in config :
@@ -73,11 +81,12 @@ async def load_multiple_genesis_transactions_from_config(settings: Settings):
7381 try :
7482 genesis_path = config .get ("genesis_file" )
7583 LOGGER .info (
76- "Reading ledger genesis transactions from: %s" , genesis_path
84+ "Reading ledger genesis transactions from file : %s" , genesis_path
7785 )
7886 with open (genesis_path , "r" ) as genesis_file :
7987 txns = genesis_file .read ()
8088 except IOError as e :
89+ LOGGER .error ("Failed to read genesis file: %s" , str (e ))
8190 raise ConfigError ("Error reading ledger genesis transactions" ) from e
8291 is_write_ledger = (
8392 False if config .get ("is_write" ) is None else config .get ("is_write" )
@@ -118,13 +127,18 @@ async def load_multiple_genesis_transactions_from_config(settings: Settings):
118127 " genesis_file and genesis_transactions provided."
119128 )
120129 settings ["ledger.ledger_config_list" ] = ledger_txns_list
130+ LOGGER .debug ("Processed %d ledger configs successfully" , len (ledger_txns_list ))
121131
122132
123133async def ledger_config (
124134 profile : Profile , public_did : str , provision : bool = False
125135) -> bool :
126136 """Perform Indy ledger configuration."""
127137
138+ LOGGER .debug (
139+ "Configuring ledger for profile %s and public_did %s" , profile .name , public_did
140+ )
141+
128142 session = await profile .session ()
129143
130144 ledger = session .inject_or (BaseLedger )
@@ -135,32 +149,46 @@ async def ledger_config(
135149 async with ledger :
136150 # Check transaction author agreement acceptance
137151 if not ledger .read_only :
152+ LOGGER .debug ("Checking transaction author agreement" )
138153 taa_info = await ledger .get_txn_author_agreement ()
139154 if taa_info ["taa_required" ] and public_did :
155+ LOGGER .debug ("TAA acceptance required" )
140156 taa_accepted = await ledger .get_latest_txn_author_acceptance ()
141157 if (
142158 not taa_accepted
143159 or taa_info ["taa_record" ]["digest" ] != taa_accepted ["digest" ]
144160 ):
161+ LOGGER .info ("TAA acceptance needed - performing acceptance" )
145162 if not await accept_taa (ledger , profile , taa_info , provision ):
163+ LOGGER .warning ("TAA acceptance failed" )
146164 return False
165+ LOGGER .info ("TAA acceptance completed" )
147166
148167 # Publish endpoints if necessary - skipped if TAA is required but not accepted
149168 endpoint = session .settings .get ("default_endpoint" )
150169 if public_did :
151170 wallet = session .inject (BaseWallet )
152171 try :
172+ LOGGER .debug ("Setting DID endpoint to: %s" , endpoint )
153173 await wallet .set_did_endpoint (public_did , endpoint , ledger )
154174 except LedgerError as x_ledger :
175+ LOGGER .error ("Error setting DID endpoint: %s" , x_ledger .message )
155176 raise ConfigError (x_ledger .message ) from x_ledger # e.g., read-only
156177
157178 # Publish profile endpoint if ledger is NOT read-only
158179 profile_endpoint = session .settings .get ("profile_endpoint" )
159180 if profile_endpoint and not ledger .read_only :
181+ LOGGER .debug (
182+ "Publishing profile endpoint: %s for DID: %s" ,
183+ profile_endpoint ,
184+ public_did ,
185+ )
160186 await ledger .update_endpoint_for_did (
161187 public_did , profile_endpoint , EndpointType .PROFILE
162188 )
189+ LOGGER .info ("Profile endpoint published successfully" )
163190
191+ LOGGER .info ("Ledger configuration complete" )
164192 return True
165193
166194
0 commit comments