Skip to content

Commit

Permalink
Fix a potential race in creating the ouput folder during exit-transac…
Browse files Browse the repository at this point in the history
…tion-mnemonic command
  • Loading branch information
remyroy committed May 28, 2024
1 parent b59b060 commit c35380e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions staking_deposit/cli/exit_transaction_keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ def exit_transaction_keystore(
)

folder = os.path.join(output_folder, DEFAULT_EXIT_TRANSACTION_FOLDER_NAME)
if not os.path.exists(folder):
os.mkdir(folder)

click.echo(load_text(['msg_exit_transaction_creation']))
saved_folder = export_exit_transaction_json(folder=folder, signed_exit=signed_exit)
Expand Down
3 changes: 3 additions & 0 deletions staking_deposit/cli/exit_transaction_mnemonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def exit_transaction_mnemonic(
credentials.append(credential)
bar.update(1)

if not os.path.exists(folder):
os.mkdir(folder)

transaction_filefolders = []
with click.progressbar(length=num_keys, label=load_text(['msg_exit_transaction_creation']),
show_percent=False, show_pos=True) as bar:
Expand Down
3 changes: 0 additions & 3 deletions staking_deposit/exit_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ def export_exit_transaction_json(folder: str, signed_exit: SignedVoluntaryExit)
signed_exit_json.update({'message': message})
signed_exit_json.update({'signature': '0x' + signed_exit.signature.hex()}) # type: ignore[attr-defined]

if not os.path.exists(folder):
os.mkdir(folder)

filefolder = os.path.join(
folder,
'signed_exit_transaction-%s-%i.json' % (
Expand Down

0 comments on commit c35380e

Please sign in to comment.