Skip to content

Commit

Permalink
Merge c0fe2b0 into e79d1d4
Browse files Browse the repository at this point in the history
  • Loading branch information
moisses89 committed Nov 8, 2023
2 parents e79d1d4 + c0fe2b0 commit 2154b11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions safe_cli/operators/hw_accounts/ledger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def add_account(self, derivation_path: str) -> ChecksumAddress:
:param derivation_path:
:return:
"""
# we should accept m/ or m'/ starting derivation paths
if derivation_path[0:2] == "m/":
derivation_path = derivation_path.replace("m/", "")

if not is_bip32_path(derivation_path):
raise InvalidDerivationPath()

Expand Down
5 changes: 5 additions & 0 deletions tests/test_ledger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def test_add_account(self, mock_get_account_by_path: MagicMock):
ledger_account = list(ledger_manager.accounts)[0]
self.assertEqual(ledger_account.address, account_address)
self.assertEqual(ledger_account.path, derivation_path)
# Should accept derivation paths started with master
master_derivation_path = "m/44'/60'/0'/0"
self.assertEqual(
ledger_manager.add_account(master_derivation_path), account_address
)

def test_delete_account(self):
ledger_manager = LedgerManager()
Expand Down

0 comments on commit 2154b11

Please sign in to comment.