pypergraph.keyring.accounts package

Submodules

pypergraph.keyring.accounts.dag_account module

class pypergraph.keyring.accounts.dag_account.DagAccount(*, tokens: ~typing.Dict[str, dict] = <factory>, wallet: ~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey | None = None, assets: ~typing.List[~typing.Any] = <factory>, bip44_index: int | None = None, provider: ~typing.Any = None, label: str | None = None)[source]

Bases: EcdsaAccount

assets: List[Any]
bip44_index: int | None
property decimals: int
get_address() str[source]
get_address_from_public_key(public_key_hex: str) str[source]
Parameters:

public_key_hex – The private key as a hexadecimal string.

Returns:

The DAG address corresponding to the public key (node ID).

get_public_key() str[source]
property has_token_support: bool
label: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property network_id: str
provider: Any
static sha256(data: bytes) str[source]
property supported_assets: List[str]
tokens: Dict[str, dict]
static validate_address(address: str) bool[source]
verify_message(msg: str, signature: str, says_address: str) bool[source]
wallet: ec.EllipticCurvePrivateKey | None

pypergraph.keyring.accounts.ecdsa_account module

class pypergraph.keyring.accounts.ecdsa_account.EcdsaAccount(*, tokens: ~typing.Dict[str, dict] = <factory>, wallet: ~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey | None = None, assets: ~typing.List[~typing.Any] = <factory>, bip44_index: int | None = None, provider: ~typing.Any = None, label: str | None = None)[source]

Bases: BaseModel, ABC

assets: List[Any]
bip44_index: int | None
create(private_key: str | None)[source]
abstract property decimals: int
deserialize(bip44_index: int | None = None, label: str | None = None, private_key: str | None = None, public_key: str | None = None, tokens: List[str] | None = None)[source]
get_address() str[source]
get_bip44_index() int | None[source]
get_decimals() int[source]
get_label() str[source]
get_network_id()[source]
get_private_key() str[source]
get_private_key_buffer()[source]
get_public_key() str[source]
get_state() Dict[str, Any][source]
get_tokens() List[str] | None[source]
get_web3_provider()[source]
abstract property has_token_support: bool
label: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

abstract property network_id: str
provider: Any
recover_signed_msg_public_key(msg: str, signature: str) str[source]
save_token_info(address: str)[source]
serialize(include_private_key: bool = True) Dict[str, Any][source]
set_tokens(tokens: Dict[str, dict])[source]
set_web3_provider(provider)[source]
abstract property supported_assets: List[str]
tokens: Dict[str, dict]
abstractmethod verify_message(msg: str, signature: str, says_address: str) bool[source]
wallet: EllipticCurvePrivateKey | None

pypergraph.keyring.accounts.eth_account module

class pypergraph.keyring.accounts.eth_account.EthAccount(*, tokens: ~typing.List[str] = ['0xa393473d64d2F9F026B60b6Df7859A689715d092'], wallet: ~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey | None = None, assets: ~typing.List[~typing.Any] = <factory>, bip44_index: int | None = None, provider: ~typing.Any = None, label: str | None = None)[source]

Bases: EcdsaAccount

assets: List[Any]
bip44_index: int | None
property decimals: int
get_address_from_public_key(public_key: str) str[source]

Derive the Ethereum address from the public key.

get_encryption_public_key() str[source]

Get the public key for encryption.

property has_token_support: bool
label: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property network_id: str
provider: Any
save_token_info(address: str)[source]

Save the token info if not already present in the tokens list.

sign_transaction(tx)[source]

Sign an Ethereum transaction with the account’s private key.

tx is an instance of the transaction object from a library like web3.eth.account.

property supported_assets: List[str]
tokens: List[str]
static validate_address(address: str) bool[source]

Validate an Ethereum address.

verify_message(msg: str, signature: str, says_address: str) bool[source]

Verify if a signed message matches the provided address.

wallet: ec.EllipticCurvePrivateKey | None

Module contents

class pypergraph.keyring.accounts.AssetLibrary[source]

Bases: ABC

abstract property default_assets: List[str]

Returns a list of default asset symbols.

abstract property default_assets_map: Dict[str, KeyringAssetInfo]

Returns the default asset map (i.e., a dict mapping symbols to asset info).

deserialize(assets: Dict[str, KeyringAssetInfo]) None[source]

Loads a previously saved asset map.

get_asset_by_symbol(symbol: str) KeyringAssetInfo | None[source]

Looks up an asset by symbol. First checks the default assets, then any imported tokens.

get_default_assets() List[str][source]

Returns a copy of the default asset symbols.

import_token(token: KeyringAssetInfo) bool[source]

Imports a new token. Returns True if the token was added (i.e. did not exist before), otherwise returns False.

serialize() Dict[str, dict][source]

Serializes (or exports) the imported assets for saving state.

class pypergraph.keyring.accounts.DagAccount(*, tokens: ~typing.Dict[str, dict] = <factory>, wallet: ~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey | None = None, assets: ~typing.List[~typing.Any] = <factory>, bip44_index: int | None = None, provider: ~typing.Any = None, label: str | None = None)[source]

Bases: EcdsaAccount

assets: List[Any]
bip44_index: int | None
property decimals: int
get_address() str[source]
get_address_from_public_key(public_key_hex: str) str[source]
Parameters:

public_key_hex – The private key as a hexadecimal string.

Returns:

The DAG address corresponding to the public key (node ID).

get_public_key() str[source]
property has_token_support: bool
label: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property network_id: str
provider: Any
static sha256(data: bytes) str[source]
property supported_assets: List[str]
tokens: Dict[str, dict]
static validate_address(address: str) bool[source]
verify_message(msg: str, signature: str, says_address: str) bool[source]
wallet: ec.EllipticCurvePrivateKey | None
class pypergraph.keyring.accounts.DagAssetLibrary[source]

Bases: AssetLibrary

property default_assets: List[str]

Returns a list of default asset symbols.

property default_assets_map: Dict[str, KeyringAssetInfo]

Returns the default asset map (i.e., a dict mapping symbols to asset info).

class pypergraph.keyring.accounts.EcdsaAccount(*, tokens: ~typing.Dict[str, dict] = <factory>, wallet: ~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey | None = None, assets: ~typing.List[~typing.Any] = <factory>, bip44_index: int | None = None, provider: ~typing.Any = None, label: str | None = None)[source]

Bases: BaseModel, ABC

assets: List[Any]
bip44_index: int | None
create(private_key: str | None)[source]
abstract property decimals: int
deserialize(bip44_index: int | None = None, label: str | None = None, private_key: str | None = None, public_key: str | None = None, tokens: List[str] | None = None)[source]
get_address() str[source]
get_bip44_index() int | None[source]
get_decimals() int[source]
get_label() str[source]
get_network_id()[source]
get_private_key() str[source]
get_private_key_buffer()[source]
get_public_key() str[source]
get_state() Dict[str, Any][source]
get_tokens() List[str] | None[source]
get_web3_provider()[source]
abstract property has_token_support: bool
label: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

abstract property network_id: str
provider: Any
recover_signed_msg_public_key(msg: str, signature: str) str[source]
save_token_info(address: str)[source]
serialize(include_private_key: bool = True) Dict[str, Any][source]
set_tokens(tokens: Dict[str, dict])[source]
set_web3_provider(provider)[source]
abstract property supported_assets: List[str]
tokens: Dict[str, dict]
abstractmethod verify_message(msg: str, signature: str, says_address: str) bool[source]
wallet: EllipticCurvePrivateKey | None
class pypergraph.keyring.accounts.EthAccount(*, tokens: ~typing.List[str] = ['0xa393473d64d2F9F026B60b6Df7859A689715d092'], wallet: ~cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePrivateKey | None = None, assets: ~typing.List[~typing.Any] = <factory>, bip44_index: int | None = None, provider: ~typing.Any = None, label: str | None = None)[source]

Bases: EcdsaAccount

assets: List[Any]
bip44_index: int | None
property decimals: int
get_address_from_public_key(public_key: str) str[source]

Derive the Ethereum address from the public key.

get_encryption_public_key() str[source]

Get the public key for encryption.

property has_token_support: bool
label: str | None
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

property network_id: str
provider: Any
save_token_info(address: str)[source]

Save the token info if not already present in the tokens list.

sign_transaction(tx)[source]

Sign an Ethereum transaction with the account’s private key.

tx is an instance of the transaction object from a library like web3.eth.account.

property supported_assets: List[str]
tokens: List[str]
static validate_address(address: str) bool[source]

Validate an Ethereum address.

verify_message(msg: str, signature: str, says_address: str) bool[source]

Verify if a signed message matches the provided address.

wallet: ec.EllipticCurvePrivateKey | None
class pypergraph.keyring.accounts.EthAssetLibrary[source]

Bases: AssetLibrary

property default_assets: List[str]

Returns a list of default asset symbols.

property default_assets_map: Dict[str, KeyringAssetInfo]

Returns the default asset map (i.e., a dict mapping symbols to asset info).