Skip to content

Commit

Permalink
🚸 Produce readable AtomicalsValidationError
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Mar 27, 2024
1 parent 5ba2a07 commit f6f29c0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions electrumx/server/block_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
is_event_operation,
encode_atomical_ids_hex,
is_mint_pow_valid,
is_txid_valid_for_perpetual_bitwork
is_txid_valid_for_perpetual_bitwork,
auto_encode_bytes_items
)

from electrumx.lib.atomicals_blueprint_builder import AtomicalsTransferBlueprintBuilder
Expand Down Expand Up @@ -546,8 +547,15 @@ def validate_ft_rules_raw_tx(self, raw_tx):
# Log that there were tokens burned due to not being cleanly assigned
if blueprint_builder.get_are_fts_burned() or not blueprint_builder.cleanly_assigned:
encoded_atomicals_spent_at_inputs = encode_atomical_ids_hex(atomicals_spent_at_inputs)
encoded_ft_output_blueprint = encode_atomical_ids_hex(ft_output_blueprint)
raise AtomicalsValidationError(f'detected invalid ft token inputs and outputs for tx_hash={hash_to_hex_str(tx_hash)}, operations_found_at_inputs={operations_found_at_inputs}, atomicals_spent_at_inputs={encoded_atomicals_spent_at_inputs}, ft_output_blueprint.outputs={encoded_ft_output_blueprint.outputs} ft_output_blueprint.fts_burned={encoded_ft_output_blueprint.fts_burned}')
encoded_ft_output_blueprint = auto_encode_bytes_items(encode_atomical_ids_hex(ft_output_blueprint))
raise AtomicalsValidationError(
f'Invalid FT token inputs/outputs:\n'
f'tx_hash={hash_to_hex_str(tx_hash)}\n'
f'operations_found_at_inputs={operations_found_at_inputs}\n'
f'atomicals_spent_at_inputs={encoded_atomicals_spent_at_inputs}\n'
f'ft_output_blueprint.outputs={encoded_ft_output_blueprint['outputs']}\n'
f'ft_output_blueprint.fts_burned={encoded_ft_output_blueprint['fts_burned']}'
)

# Query general data including the cache
def get_general_data_with_cache(self, key):
Expand Down

0 comments on commit f6f29c0

Please sign in to comment.