-
Notifications
You must be signed in to change notification settings - Fork 8
Implement Ledger #231
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
base: main
Are you sure you want to change the base?
Implement Ledger #231
Conversation
422e9b0 to
ef69187
Compare
Solution: Implement Ledger use on SDK to allow using them.
ef69187 to
9b8d8b6
Compare
|
Failed to retrieve llama text: POST 503: 503 Service UnavailableNo server is available to handle this request. |
src/aleph/sdk/conf.py
Outdated
| address: Optional[str] = None | ||
|
|
||
| model_config = SettingsConfigDict(use_enum_values=True) | ||
| # model_config = SettingsConfigDict(use_enum_values=True) |
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.
Why comment this?
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.
Not sure, that change was from @nesitor
| def __init__(self, account: LedgerAccount, device: Dongle): | ||
| def __init__( | ||
| self, account: LedgerAccount, device: Dongle, chain: Optional[Chain] = None | ||
| ): |
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.
For some reason you're not calling the __init__ method of ETHAccount (the base class), why? You also re-specify a bunch of constants like CHAIN or CURVE for no clear reason.
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.
The init method of EthAccount expects a private_key to initialize the account.
In our case, since we are interacting with a hardware wallet (Ledger), we don’t have or need access to the private key — the Ledger device handles signing internally.
The goal here is to preserve the interface and behavior of EthAccount so that this Ledger-based account can be used seamlessly like any other account within the SDK, without requiring code changes elsewhere.
As a result, the base class init isn’t called, since it would require a private_key we cannot provide.
And for CHAIN and CURVE aren’t needed, I’ll remove them.
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.
Okay but is it even reusing any method of ETHAccount? If it does, just create a base class for the methods used in both Ledger / non-Ledger accounts and inherit that from both then.
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.
Looks like this needs a refactoring of base classes the class hierarchy make sense.
| def __init__(self, account: LedgerAccount, device: Dongle): | ||
| def __init__( | ||
| self, account: LedgerAccount, device: Dongle, chain: Optional[Chain] = None | ||
| ): |
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.
Okay but is it even reusing any method of ETHAccount? If it does, just create a base class for the methods used in both Ledger / non-Ledger accounts and inherit that from both then.
| def get_accounts( | ||
| device: Optional[Dongle] = None, count: int = 5 | ||
| ) -> List[LedgerAccount]: | ||
| """Initialize an aleph.im account from a LedgerHQ device from |
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.
aleph.im -> Aleph Cloud
| account_type: Optional[Type[AccountFromPrivateKey]] = None, | ||
| chain: Optional[Chain] = None, | ||
| ) -> AccountFromPrivateKey: | ||
| ) -> Union[AccountFromPrivateKey, LedgerETHAccount]: |
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.
Should be a base class instead
|
|
||
| path: Path | ||
| path: Optional[Path] = None | ||
| type: Optional[AccountType] = AccountType.INTERNAL |
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.
Why is it optional?
|
|
||
| class AccountType(str, Enum): | ||
| INTERNAL: str = "internal" | ||
| EXTERNAL: str = "external" |
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.
Internal/External is not really representative. Use Hot/Cold, Imported / Hardware or something like that.
Problem: Ledger wallet users cannot use Aleph to send transactions.
Solution: Implement Ledger use on SDK to allow using them.