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

Add path to Ogmios v6 backend #398

Merged
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
22 changes: 13 additions & 9 deletions pycardano/backend/ogmios_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
self,
host: str = "localhost",
port: int = 1337,
path: str = "",
secure: bool = False,
refetch_chain_tip_interval: Optional[float] = None,
utxo_cache_size: int = 10000,
Expand All @@ -67,6 +68,7 @@
):
self.host = host
self.port = port
self.path = path

Check warning on line 71 in pycardano/backend/ogmios_v6.py

View check run for this annotation

Codecov / codecov/patch

pycardano/backend/ogmios_v6.py#L71

Added line #L71 was not covered by tests
self.secure = secure
self._network = network
self._service_name = "ogmios"
Expand All @@ -86,26 +88,26 @@
self._datum_cache = LRUCache(maxsize=datum_cache_size)

def _query_current_era(self) -> OgmiosEra:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
return get_current_era(client)

def _query_current_epoch(self) -> int:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
epoch, _ = client.query_epoch.execute()
return epoch

def _query_chain_tip(self) -> OgmiosTip:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
tip, _ = client.query_network_tip.execute()
return tip

def _query_utxos_by_address(self, address: Address) -> List[OgmiosUtxo]:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
utxos, _ = client.query_utxo.execute([address])
return utxos

def _query_utxos_by_tx_id(self, tx_id: str, index: int) -> List[OgmiosUtxo]:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
utxos, _ = client.query_utxo.execute(
[OgmiosTxOutputReference(tx_id, index)]
)
Expand Down Expand Up @@ -135,7 +137,7 @@
return self._protocol_param

def _fetch_protocol_param(self) -> ProtocolParameters:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
protocol_parameters, _ = client.query_protocol_parameters.execute()
pyc_protocol_params = ProtocolParameters(
min_fee_constant=protocol_parameters.min_fee_constant.lovelace,
Expand Down Expand Up @@ -205,7 +207,7 @@
return self._genesis_param # type: ignore[return-value]

def _fetch_genesis_param(self) -> OgmiosGenesisParameters:
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
return OgmiosGenesisParameters(client, self._query_current_era())

@property
Expand Down Expand Up @@ -311,13 +313,13 @@
def submit_tx_cbor(self, cbor: Union[bytes, str]):
if isinstance(cbor, bytes):
cbor = cbor.hex()
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
client.submit_transaction.execute(cbor)

def evaluate_tx_cbor(self, cbor: Union[bytes, str]) -> Dict[str, ExecutionUnits]:
if isinstance(cbor, bytes):
cbor = cbor.hex()
with OgmiosClient(self.host, self.port, self.secure) as client:
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
result, _ = client.evaluate_transaction.execute(cbor)
result_dict = {}
for res in result:
Expand Down Expand Up @@ -366,6 +368,7 @@
def KupoOgmiosV6ChainContext(
host: str,
port: int,
path: str,
secure: bool,
refetch_chain_tip_interval: Optional[float] = None,
utxo_cache_size: int = 10000,
Expand All @@ -377,6 +380,7 @@
OgmiosV6ChainContext(
host,
port,
path,
secure,
refetch_chain_tip_interval,
utxo_cache_size,
Expand Down
Loading