Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set correct options when signing with Ledger #461

Merged
merged 2 commits into from
Jan 15, 2025
Merged

Conversation

popenta
Copy link
Collaborator

@popenta popenta commented Jan 9, 2025

No description provided.

@popenta popenta self-assigned this Jan 9, 2025
@@ -96,6 +96,8 @@ def __init__(self, account_index: int = 0, address_index: int = 0) -> None:
def sign_transaction(self, transaction: ITransaction) -> str:
ledger_version = do_get_ledger_version()
should_use_hash_signing = compare_versions(ledger_version, SIGN_USING_HASH_VERSION) >= 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do something (in the next PR) about the mypy / reviewdog warnings shown in PRs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will take a look

tx.signature = bytes.fromhex(account.sign_transaction(tx))
tx = sign_tx_by_guardian(args, tx)
tx = sign_tx_by_guardian(args, tx, guardian_account)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In another PR, maybe we can follow the same pattern as above (as for signature) i.e. tx.guardianSignature =

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

tx.relayer_signature = bytes.fromhex(relayer_account.sign_transaction(tx))
except NoWalletProvided:
logger.warning("Relayer wallet not provided. Transaction will not be signed by relayer.")
except IncorrectWalletError:
raise IncorrectWalletError("Relayer wallet does not match the relayer's address set in the transaction.")

try:
guardian_account = get_guardian_account_from_args(args)
if isinstance(guardian_account, LedgerAccount):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also extract it to a function such as _apply_options_for_hash_signing_if_appropriate(account, tx), since this logic is applied in three places (a bit of duplication).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do in a future PR.

@popenta popenta merged commit ff6dd67 into main Jan 15, 2025
12 checks passed
@popenta popenta deleted the fix-signing-with-ledger branch January 15, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants