Skip to content

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

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from

Conversation

immortalizzy
Copy link

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 of sign() is awaitable, and if so the result is
properly awaited.

@thewhaleking thewhaleking changed the base branch from main to staging April 15, 2025 16:34
@thewhaleking
Copy link
Collaborator

Will look at this today.

Copy link
Collaborator

@thewhaleking thewhaleking left a 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:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def public_key(self) -> bytes | None:
def public_key(self) -> Optional[bytes]:

def ss58_format(self) -> int:
...

def sign(self, data: bytes | str) -> bytes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def sign(self, data: bytes | str) -> bytes:
def sign(self, data: Union[bytes, str]) -> bytes:

@@ -0,0 +1,43 @@
from typing import Protocol
Copy link
Collaborator

@thewhaleking thewhaleking Apr 16, 2025

Choose a reason for hiding this comment

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

Suggested change
from typing import Protocol
from typing import Protocol, Union, Optional

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