Configurable reader
Some checks failed
Run Python tests (through Pytest) / Test (push) Failing after 24s
Verify Python project can be installed, loaded and have version checked / Test (push) Failing after 22s

This commit is contained in:
Jon Michael Aanes 2025-04-03 23:24:56 +02:00
parent fd9ccb48fa
commit 8dff57c4e3

View File

@ -13,11 +13,8 @@ from frozendict import frozendict
logger = logging.getLogger(__name__)
# mainnet: https://reader.partisiablockchain.com
# testnet: https://node1.testnet.partisiablockchain.com
HOSTNAME = 'reader.partisiablockchain.com'
HOSTNAME_MAINNET = 'reader.partisiablockchain.com'
HOSTNAME_TESTNET = 'node1.testnet.partisiablockchain.com'
URL_ACCOUNT_PLUGIN = 'https://{hostname}/{shard}blockchain/accountPlugin/local'
URL_ACCOUNT_PLUGIN_GLOBAL = 'https://{hostname}/{shard}blockchain/accountPlugin/global'
@ -49,6 +46,7 @@ class Balances:
@dataclasses.dataclass(frozen=True)
class PbcClient:
session: requests.Session
hostname: str = HOSTNAME_MAINNET
def get_json(
self,
@ -82,7 +80,7 @@ class PbcClient:
data: dict = {'path': []}
url: str = URL_ACCOUNT_PLUGIN_GLOBAL.format(
hostname=HOSTNAME,
hostname=self.hostname,
shard='',
)
@ -93,7 +91,7 @@ class PbcClient:
coins = self.determine_coins()
url = URL_ACCOUNT_PLUGIN.format(
hostname=HOSTNAME,
hostname=self.hostname,
shard=shard_id_for_address(address),
)
@ -120,10 +118,9 @@ class PbcClient:
def get_contract_state(self, address: str) -> tuple[dict, datetime.datetime]:
url = URL_CONTRACT_STATE.format(
hostname=HOSTNAME,
hostname=self.hostname,
shard=shard_id_for_address(address),
address=address,
)
data: dict = {'path': []}
return self.get_json(url, data=data)