Skip to content

Commit f5ecb6b

Browse files
authored
🐛 Fix auto_encode_bytes_elements
1 parent 5783a27 commit f5ecb6b

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

electrumx/lib/util_atomicals.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,31 +1282,32 @@ def encode_tx_hash_hex(state):
12821282
cloned_state[encode_tx_hash_hex(key)] = encode_tx_hash_hex(value)
12831283
return cloned_state
12841284

1285-
# Auto detect any bytes data and encoded it
1285+
1286+
# Auto encodes data into structured bytes data.
12861287
def auto_encode_bytes_elements(state):
12871288
if isinstance(state, bytes):
12881289
return {
12891290
'$b': state.hex(),
12901291
'$len': sys.getsizeof(state),
12911292
'$auto': True
12921293
}
1293-
1294+
12941295
if isinstance(state, CBORTag):
1295-
return dumps(state)
1296-
1297-
if not isinstance(state, dict) and not isinstance(state, list):
1298-
return state
1299-
1296+
dumped_bytes = dumps(state)
1297+
return auto_encode_bytes_elements(dumped_bytes)
1298+
13001299
if isinstance(state, list):
13011300
reformatted_list = []
13021301
for item in state:
13031302
reformatted_list.append(auto_encode_bytes_elements(item))
13041303
return reformatted_list
1305-
1306-
for key, value in state.items():
1307-
state[key] = auto_encode_bytes_elements(value)
1308-
return state
1309-
1304+
1305+
if isinstance(state, dict):
1306+
for key, value in state.items():
1307+
state[key] = auto_encode_bytes_elements(value)
1308+
1309+
return state
1310+
13101311

13111312
# Base atomical commit to reveal delay allowed
13121313
def is_within_acceptable_blocks_for_general_reveal(commit_height, reveal_location_height):

electrumx/server/block_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ def put_or_delete_init_state_updates(self, mint_info, data_payload, Delete):
16191619
# Make a deep copy of the data payload and remove the reserved sections
16201620
copied_data_state = {}
16211621
for k, v in data_payload.items():
1622-
if k != "args":
1622+
if k != 'args':
16231623
copied_data_state[k] = v
16241624
init_payload_bytes = dumps(copied_data_state)
16251625
op_struct = {

0 commit comments

Comments
 (0)