Skip to content

Commit

Permalink
Add 0x prefix to the bytes type fields of the output JSON file
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Jan 15, 2023
1 parent d68a1c7 commit 6a4ba11
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions staking_deposit/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ def get_bls_to_execution_change_dict(self, validator_index: int) -> Dict[str, by
signed_bls_to_execution_change = self.get_bls_to_execution_change(validator_index)
message = {
'validator_index': signed_bls_to_execution_change.message.validator_index,
'from_bls_pubkey': signed_bls_to_execution_change.message.from_bls_pubkey.hex(),
'to_execution_address': signed_bls_to_execution_change.message.to_execution_address.hex(),
'from_bls_pubkey': '0x' + signed_bls_to_execution_change.message.from_bls_pubkey.hex(),
'to_execution_address': '0x' + signed_bls_to_execution_change.message.to_execution_address.hex(),
}
result_dict.update({'message': message})
result_dict.update({'signature': signed_bls_to_execution_change.signature})
result_dict.update({'signature': '0x' + signed_bls_to_execution_change.signature.hex()})

# meta
result_dict.update({'network_name': self.chain_setting.NETWORK_NAME})
result_dict.update({'genesis_validators_root': self.chain_setting.GENESIS_VALIDATORS_ROOT})
result_dict.update({'genesis_validators_root': '0x' + self.chain_setting.GENESIS_VALIDATORS_ROOT.hex()})
result_dict.update({'deposit_cli_version': DEPOSIT_CLI_VERSION})
return result_dict

Expand Down Expand Up @@ -259,7 +259,7 @@ def export_bls_to_execution_change_json(self, folder: str, validator_index: int)

filefolder = os.path.join(folder, 'bls_to_execution_change-%i.json' % time.time())
with open(filefolder, 'w') as f:
json.dump(bls_to_execution_changes, f, default=lambda x: x.hex())
json.dump(bls_to_execution_changes, f)
if os.name == 'posix':
os.chmod(filefolder, int('440', 8)) # Read for owner & group
return filefolder

0 comments on commit 6a4ba11

Please sign in to comment.