@@ -47,9 +47,6 @@ def build_reverse_output_to_atomical_id_exponent_map(atomical_id_to_output_index
47
47
48
48
def get_nominal_token_value (value ):
49
49
return value
50
- # assert(value >= 0)
51
- # assert(exponent >= 0)
52
- # return value / (10**exponent)
53
50
54
51
def calculate_outputs_to_color_for_ft_atomical_ids (tx , ft_atomicals , sort_by_fifo , is_split_activated ) -> FtColoringSummary :
55
52
num_fts = len (ft_atomicals .keys ())
@@ -64,15 +61,26 @@ def calculate_outputs_to_color_for_ft_atomical_ids(tx, ft_atomicals, sort_by_fif
64
61
for item in atomical_list :
65
62
atomical_id = item .atomical_id
66
63
# If a target exponent was provided, then use that instead
67
- cleanly_assigned , expected_outputs , remaining_value_from_assign = AtomicalsTransferBlueprintBuilder .assign_expected_outputs_basic (item .total_tokenvalue , tx , next_start_out_idx , False )
68
- if cleanly_assigned and len (expected_outputs ) > 0 :
69
- next_start_out_idx = expected_outputs [- 1 ] + 1
70
- potential_atomical_ids_to_output_idxs_map [atomical_id ] = ExpectedOutputSet (expected_outputs , item .total_tokenvalue )
64
+ cleanly_assigned , expected_outputs , remaining_value_from_assign = AtomicalsTransferBlueprintBuilder .assign_expected_outputs_basic (item .total_tokenvalue , tx , next_start_out_idx , is_split_activated )
65
+ if not is_split_activated :
66
+ if cleanly_assigned and len (expected_outputs ) > 0 :
67
+ next_start_out_idx = expected_outputs [- 1 ] + 1
68
+ potential_atomical_ids_to_output_idxs_map [atomical_id ] = ExpectedOutputSet (expected_outputs , item .total_tokenvalue )
69
+ else :
70
+ # Erase the potential for safety
71
+ potential_atomical_ids_to_output_idxs_map = {}
72
+ non_clean_output_slots = True
73
+ break
71
74
else :
72
- # Erase the potential for safety
73
- potential_atomical_ids_to_output_idxs_map = {}
74
- non_clean_output_slots = True
75
- break
75
+ # no need cleanly_assigned
76
+ if len (expected_outputs ) > 0 :
77
+ next_start_out_idx = expected_outputs [- 1 ] + 1
78
+ potential_atomical_ids_to_output_idxs_map [atomical_id ] = ExpectedOutputSet (expected_outputs , item .total_tokenvalue )
79
+ else :
80
+ # if no enable uxto
81
+ potential_atomical_ids_to_output_idxs_map = {}
82
+ non_clean_output_slots = True
83
+ break
76
84
77
85
# If the output slots did not fit cleanly, then default to just assigning everything from the 0'th output index
78
86
if non_clean_output_slots :
@@ -81,9 +89,8 @@ def calculate_outputs_to_color_for_ft_atomical_ids(tx, ft_atomicals, sort_by_fif
81
89
atomical_id = item .atomical_id
82
90
cleanly_assigned , expected_outputs , remaining_value_from_assign = AtomicalsTransferBlueprintBuilder .assign_expected_outputs_basic (item .total_tokenvalue , tx , 0 , is_split_activated )
83
91
potential_atomical_ids_to_output_idxs_map [atomical_id ] = ExpectedOutputSet (expected_outputs , item .total_tokenvalue )
84
- if not is_split_activated :
85
- if not cleanly_assigned and remaining_value_from_assign > 0 :
86
- fts_burned [atomical_id ] = get_nominal_token_value (remaining_value_from_assign )
92
+ if remaining_value_from_assign > 0 :
93
+ fts_burned [atomical_id ] = remaining_value_from_assign
87
94
return FtColoringSummary (potential_atomical_ids_to_output_idxs_map , fts_burned , not non_clean_output_slots , atomical_list )
88
95
return FtColoringSummary (potential_atomical_ids_to_output_idxs_map , fts_burned , not non_clean_output_slots , atomical_list )
89
96
@@ -307,15 +314,14 @@ def calculate_output_blueprint_fts(cls, tx, ft_atomicals, operations_found_at_in
307
314
# Split apart multiple NFT/FT from a UTXO
308
315
should_split_ft_atomicals = is_split_operation (operations_found_at_inputs )
309
316
if should_split_ft_atomicals :
310
- return AtomicalsTransferBlueprintBuilder .color_ft_atomicals_split (ft_atomicals , operations_found_at_inputs , tx )
311
-
317
+ return AtomicalsTransferBlueprintBuilder .color_ft_atomicals_split (ft_atomicals , operations_found_at_inputs , tx , is_split_activated )
312
318
# Normal assignment in all cases including fall through of failure to provide a target exponent in the above resubstantiation
313
319
return AtomicalsTransferBlueprintBuilder .color_ft_atomicals_regular (ft_atomicals , tx , sort_fifo , is_split_activated )
314
320
315
321
@classmethod
316
- def color_ft_atomicals_split (cls , ft_atomicals , operations_found_at_inputs , tx ):
317
- output_colored_map = {}
318
- fts_burned = {}
322
+ def color_ft_atomicals_split (cls , ft_atomicals , operations_found_at_inputs , tx , is_split_activated ):
323
+ output_colored_map = {}
324
+ fts_burned = {}
319
325
cleanly_assigned = True
320
326
for atomical_id , atomical_info in sorted (ft_atomicals .items ()):
321
327
expected_output_indexes = []
@@ -331,31 +337,58 @@ def color_ft_atomicals_split(cls, ft_atomicals, operations_found_at_inputs, tx):
331
337
if isinstance (total_amount_to_skip_potential , int ) and total_amount_to_skip_potential >= 0 :
332
338
total_amount_to_skip = total_amount_to_skip_potential
333
339
total_skipped_so_far = 0
334
- for out_idx , txout in enumerate (tx .outputs ):
335
- # If the first output should be skipped and we have not yet done so, then skip/ignore it
336
- if total_amount_to_skip > 0 and total_skipped_so_far < total_amount_to_skip :
337
- total_skipped_so_far += txout .value
338
- continue
339
- # For all remaining outputs attach colors as long as there is adequate remaining_value left to cover the entire output value
340
- if txout .value <= remaining_value :
340
+ if is_split_activated :
341
+ for out_idx , txout in enumerate (tx .outputs ):
342
+ # If the first output should be skipped and we have not yet done so, then skip/ignore it
343
+ if total_amount_to_skip > 0 and total_skipped_so_far < total_amount_to_skip :
344
+ total_skipped_so_far += txout .value
345
+ continue
346
+ # For all remaining outputs attach colors as long as there is adequate remaining_value left to cover the entire output value
347
+ # if txout.value <= remaining_value:
341
348
expected_output_indexes .append (out_idx )
349
+ if txout .value <= remaining_value :
350
+ expected_value = txout .value
351
+ else :
352
+ expected_value = remaining_value
342
353
remaining_value -= txout .value
343
354
output_colored_map [out_idx ] = output_colored_map .get (out_idx ) or {'atomicals' : {}}
344
- output_colored_map [out_idx ]['atomicals' ][atomical_id ] = AtomicalColoredOutputFt (txout .value , get_nominal_token_value ( txout . value ) , atomical_info )
355
+ output_colored_map [out_idx ]['atomicals' ][atomical_id ] = AtomicalColoredOutputFt (txout .value , expected_value , atomical_info )
345
356
# We are done assigning all remaining values
346
357
if remaining_value == 0 :
347
358
break
348
- # Exit case when we have no more remaining_value to assign or the next output is greater than what we have in remaining_value
349
- if txout .value > remaining_value or remaining_value < 0 :
350
- cleanly_assigned = False # Used to indicate that all was cleanly assigned
351
- fts_burned [atomical_id ] = get_nominal_token_value (remaining_value )
352
- break
353
- # Used to indicate that all was cleanly assigned
354
- if remaining_value != 0 :
355
- cleanly_assigned = False
356
- fts_burned [atomical_id ] = get_nominal_token_value (remaining_value )
357
-
358
- return AtomicalFtOutputBlueprintAssignmentSummary (output_colored_map , fts_burned , cleanly_assigned , None )
359
+ # Exit case when we have no more remaining_value to assign or the next output is greater than what we have in remaining_value
360
+ if remaining_value < 0 :
361
+ remaining_value = 0
362
+ cleanly_assigned = False # Used to indicate that all was cleanly assigned
363
+ break
364
+ if remaining_value != 0 :
365
+ cleanly_assigned = False
366
+ fts_burned [atomical_id ] = remaining_value
367
+ else :
368
+ # is_split_activated logic
369
+ # use if else keep it simple
370
+ for out_idx , txout in enumerate (tx .outputs ):
371
+ if total_amount_to_skip > 0 and total_skipped_so_far < total_amount_to_skip :
372
+ total_skipped_so_far += txout .value
373
+ continue
374
+ # For all remaining outputs attach colors as long as there is adequate remaining_value left to cover the entire output value
375
+ if txout .value <= remaining_value :
376
+ expected_output_indexes .append (out_idx )
377
+ remaining_value -= txout .value
378
+ output_colored_map [out_idx ] = output_colored_map .get (out_idx ) or {'atomicals' : {}}
379
+ output_colored_map [out_idx ]['atomicals' ][atomical_id ] = AtomicalColoredOutputFt (txout .value , txout .value , atomical_info )
380
+ # We are done assigning all remaining values
381
+ if remaining_value == 0 :
382
+ break
383
+ # Exit case when we have no more remaining_value to assign or the next output is greater than what we have in remaining_value
384
+ if txout .value > remaining_value or remaining_value < 0 :
385
+ cleanly_assigned = False # Used to indicate that all was cleanly assigned
386
+ fts_burned [atomical_id ] = remaining_value
387
+ break
388
+ if remaining_value != 0 :
389
+ cleanly_assigned = False
390
+ fts_burned [atomical_id ] = remaining_value
391
+ return AtomicalFtOutputBlueprintAssignmentSummary (output_colored_map , fts_burned , cleanly_assigned , None )
359
392
360
393
@classmethod
361
394
def color_ft_atomicals_regular (cls , ft_atomicals , tx , sort_fifo , is_split_activated ):
0 commit comments