Skip to content

Commit

Permalink
Python .pyi file example for type hints/editor completion (kaspanet#72)
Browse files Browse the repository at this point in the history
* Feat: adding pyi file and testing first commit

* Feat: Added py interface file

* fix python IDE autocompletion and imports
  • Loading branch information
cafalchio authored and smartgoo committed Sep 17, 2024
1 parent 289c0a3 commit 9baa7c0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/examples/addresses.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from kaspa import (
PrivateKey,
)
from kaspa import PrivateKey

if __name__ == "__main__":
private_key = PrivateKey('b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfef')
private_key = PrivateKey(
'b7e151628aed2a6abf7158809cf4f3c762e7160f38b4da56a784d9045190cfef')
print(f'Private Key: {private_key.to_hex()}')

public_key = private_key.to_public_key()
print(f'Public Key: {public_key.to_string_impl()}')

address = public_key.to_address('mainnet')
print(f'Address: {address.address_to_string()}')
print(f'Address: {address.address_to_string()}')
62 changes: 62 additions & 0 deletions python/kaspa.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

class Address:

def __init__(self, address: str) -> None: ...

def to_string(self) -> str: ...

def version(self) -> str: ...

def set_prefix(self, prefix: str) -> None: ...

def payload(self) -> str: ...

@staticmethod
def validate(address: str) -> bool: ...


class PrivateKeyGenerator:

def __init__(self, xprv: str, is_multisig: bool,
account_index: int, cosigner_index: int) -> str: ...

def receive_key(self, index: int) -> PrivateKey: ...

def change_key(self, index: int) -> PrivateKey: ...


class PrivateKey:

def __init__(self, secret_key: str) -> None: ...

def to_string(self) -> str: ...

def to_public_key(self) -> PublicKey: ...

def to_address(self, network: str) -> Address: ...

def to_address_ecdsa(self, network: str) -> Address: ...

@staticmethod
def try_new(key: str) -> PrivateKey: ...


class PublicKey:
def __init__(self, key: str) -> None: ...

def to_string(self) -> str: ...

def to_address(self, network: str) -> Address: ...

def to_address_ecdsa(self, network: str) -> Address: ...


class RpcClient:

def __init__(self, url: str) -> None: ...

def is_connected(self) -> bool: ...

def connect(self) -> None: ...

def disconnect(self) -> None: ...
File renamed without changes.

0 comments on commit 9baa7c0

Please sign in to comment.