-
Notifications
You must be signed in to change notification settings - Fork 3
Support async key implementations #94
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: staging
Are you sure you want to change the base?
Conversation
Release/1.0.6
Release/1.0.7
Release/1.0.8
Release/1.0.9
Release/1.1.0
Will look at this today. |
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.
Overall I'm happy with this, but just fix the type hints because we support Python 3.9 on this (pipe types were added in 3.10), and update the branch.
... | ||
|
||
@property | ||
def public_key(self) -> bytes | 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.
def public_key(self) -> bytes | None: | |
def public_key(self) -> Optional[bytes]: |
def ss58_format(self) -> int: | ||
... | ||
|
||
def sign(self, data: bytes | str) -> bytes: |
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.
def sign(self, data: bytes | str) -> bytes: | |
def sign(self, data: Union[bytes, str]) -> bytes: |
@@ -0,0 +1,43 @@ | |||
from typing import Protocol |
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.
from typing import Protocol | |
from typing import Protocol, Union, Optional |
This pull request abstracts the Keypair used to sign transactions. This allows the integration of cryptographic backends that require async calls (such as HSMs in cloud environments).
The bittensor_wallet.Keypair type is replaced by a protocol that defines its properties and methods. In
create_signed_extrinsic
it is checked if the result ofsign()
is awaitable, and if so the result isproperly awaited.