Configurable reader
This commit is contained in:
parent
fd9ccb48fa
commit
8dff57c4e3
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user