Skip to content
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

Fixed network assignment #16

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions nibiru/sdk.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import logging

from .client import Client
from .common import TxConfig
from .network import Network
from .sdks.tx import TxClient
from .wallet import PrivateKey
from .client import Client
from .network import Network


class Sdk:
def __init__(self, _error_do_not_use_init_directly=None) -> None:
Expand Down Expand Up @@ -36,10 +38,10 @@ def with_network(self, network: Network) -> "Sdk":
self._network = network
self.with_query_client(Client(self._network, True))
return self

def with_query_client(self, client: Client) -> "Sdk":
self.query = client
tx_client = TxClient(client = self.query, network = self._network, priv_key = self._priv_key, config = self.config)
tx_client = TxClient(client=self.query, network=self._network, priv_key=self._priv_key, config=self.config)
self.with_tx_client(tx_client)
return self

Expand All @@ -49,16 +51,16 @@ def with_tx_client(self, client: TxClient) -> "Sdk":

def with_priv_key(self, priv_key: PrivateKey) -> "Sdk":
self._priv_key = priv_key
self._network = self.with_network(Network.local())
self.with_network(Network.local())
return self

def with_config(self, config: TxConfig) -> "Sdk":
self.config = config
tx_client = TxClient(client = self.query, network = self._network, priv_key = self._priv_key, config = self.config)
tx_client = TxClient(client=self.query, network=self._network, priv_key=self._priv_key, config=self.config)
self.with_tx_client(tx_client)
return self

@property
def address(self):
pub_key = self._priv_key.to_public_key()
return pub_key.to_address().to_acc_bech32()
return pub_key.to_address().to_acc_bech32()