-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add support for ledger #195
Conversation
7f598e8
to
7eadc69
Compare
Pull Request Test Coverage Report for Build 4153242346
💛 - Coveralls |
Hi! Thanks for this PR - amazing work! We (in Aurora Labs) have tested Is it a known limitation? Is there a possible workaround? |
Good point, I should test it, for now I was only testing one ledger. |
e79fadd
to
4296029
Compare
893a298
to
869b410
Compare
"signTransaction is deprecated in favor of sign_transaction", | ||
category=DeprecationWarning, | ||
) | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass | |
return self.sign_transaction(transaction_dict) |
6d7963a
to
369fe15
Compare
369fe15
to
723daba
Compare
723daba
to
ca57e20
Compare
* add tests
Refactor ledger sign_eip712 to be used in other places
e5facc4
to
208c487
Compare
208c487
to
386d54d
Compare
@vzctl with this new approach you can load more than one owner from ledger but you can only connect one ledger device. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice, some small suggestions
@@ -325,6 +335,34 @@ def load_cli_owners(self, keys: List[str]): | |||
except ValueError: | |||
print_formatted_text(HTML(f"<ansired>Cannot load key={key}</ansired>")) | |||
|
|||
def load_ledger_cli_owners(self, legacy_account: bool = False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for next iteration we should allow people to use a custom derivation path like:
> load_ledger_cli_owners DERIVATION_PATH
safe_cli/utils.py
Outdated
question: str, number_options: int, default_option: int = 0 | ||
) -> bool: | ||
if "PYTEST_CURRENT_TEST" in os.environ: | ||
return 0 # Ignore confirmations when running tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 0 # Ignore confirmations when running tests | |
return default_option # Ignore confirmations when running tests |
safe_cli/utils.py
Outdated
if "PYTEST_CURRENT_TEST" in os.environ: | ||
return 0 # Ignore confirmations when running tests | ||
choices = f" [0-{number_options}] default {default_option}:" | ||
reply = str(input(question + choices)).lower().strip() or str(default_option) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use get_input
so you can easily mock the function for testing. Please add a test for this function
safe_cli/utils.py
Outdated
return 0 # Ignore confirmations when running tests | ||
choices = f" [0-{number_options}] default {default_option}:" | ||
reply = str(input(question + choices)).lower().strip() or str(default_option) | ||
option = int(reply) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if reply cannot be converted to a number?
"tabulate>=0.8", | ||
], | ||
extras_require={"ledger": ["ledgereth==0.9.0"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Co-authored-by: Uxío <[email protected]>
Co-authored-by: Uxío <[email protected]>
@@ -7,25 +7,25 @@ | |||
LedgerNotFound, | |||
) | |||
|
|||
from safe_cli.operators.safe_operator import HwDeviceException | |||
from safe_cli.operators.exceptions import HardwareWalletException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, using a exception file we prevent a posible circular dependency
8973866
to
91a7a9d
Compare
Hola team! Small detail, the command available on the readme for installing ledger support is not the correct one, should be:
Cheers! |
Thanks, but that command is only for local development and using the last version. On the README we only have the command to use the last official release 😉 |
Checking delegation! I see that in order to add or remove a delegate to a safe we need to be on tx-service mode and those commands look to be executed directly (something not possible to do from a ledger at this point).
Here is me trying to do so from a ladger. My guess is that it fails as expected but maybe it is worth it to create a separate improvement to change that owner not loaded message as that is not the case for something referencing that it is not possible to add / remove delegates from a ledger?
(or something more generic for when we implement trezor too). Cheers! |
Other than that Ledger is working nicely for me on the CLI 😄 |
@JagoFigueroa thanks for your review :) |
Description
Closes #269