Skip to content

Commit 9938b37

Browse files
Add path to Ogmios v6 backend
1 parent b9829ee commit 9938b37

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pycardano/backend/ogmios_v6.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(
5959
self,
6060
host: str = "localhost",
6161
port: int = 1337,
62+
path: str = "",
6263
secure: bool = False,
6364
refetch_chain_tip_interval: Optional[float] = None,
6465
utxo_cache_size: int = 10000,
@@ -67,6 +68,7 @@ def __init__(
6768
):
6869
self.host = host
6970
self.port = port
71+
self.path = path
7072
self.secure = secure
7173
self._network = network
7274
self._service_name = "ogmios"
@@ -86,26 +88,26 @@ def __init__(
8688
self._datum_cache = LRUCache(maxsize=datum_cache_size)
8789

8890
def _query_current_era(self) -> OgmiosEra:
89-
with OgmiosClient(self.host, self.port, self.secure) as client:
91+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
9092
return get_current_era(client)
9193

9294
def _query_current_epoch(self) -> int:
93-
with OgmiosClient(self.host, self.port, self.secure) as client:
95+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
9496
epoch, _ = client.query_epoch.execute()
9597
return epoch
9698

9799
def _query_chain_tip(self) -> OgmiosTip:
98-
with OgmiosClient(self.host, self.port, self.secure) as client:
100+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
99101
tip, _ = client.query_network_tip.execute()
100102
return tip
101103

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

107109
def _query_utxos_by_tx_id(self, tx_id: str, index: int) -> List[OgmiosUtxo]:
108-
with OgmiosClient(self.host, self.port, self.secure) as client:
110+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
109111
utxos, _ = client.query_utxo.execute(
110112
[OgmiosTxOutputReference(tx_id, index)]
111113
)
@@ -135,7 +137,7 @@ def protocol_param(self) -> ProtocolParameters:
135137
return self._protocol_param
136138

137139
def _fetch_protocol_param(self) -> ProtocolParameters:
138-
with OgmiosClient(self.host, self.port, self.secure) as client:
140+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
139141
protocol_parameters, _ = client.query_protocol_parameters.execute()
140142
pyc_protocol_params = ProtocolParameters(
141143
min_fee_constant=protocol_parameters.min_fee_constant.lovelace,
@@ -205,7 +207,7 @@ def genesis_param(self) -> GenesisParameters:
205207
return self._genesis_param # type: ignore[return-value]
206208

207209
def _fetch_genesis_param(self) -> OgmiosGenesisParameters:
208-
with OgmiosClient(self.host, self.port, self.secure) as client:
210+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
209211
return OgmiosGenesisParameters(client, self._query_current_era())
210212

211213
@property
@@ -263,7 +265,7 @@ def _utxo_from_ogmios_result(self, utxo: OgmiosUtxo) -> UTxO:
263265
# TODO: Need to test with native scripts
264266
if script["language"] == "plutus:v3":
265267
script = PlutusV3Script(bytes.fromhex(script["cbor"]))
266-
elif script["language"] == "plutus:v2":
268+
if script["language"] == "plutus:v2":
267269
script = PlutusV2Script(bytes.fromhex(script["cbor"]))
268270
elif script["language"] == "plutus:v1":
269271
script = PlutusV1Script(bytes.fromhex(script["cbor"]))
@@ -311,13 +313,13 @@ def utxo_by_tx_id(self, tx_id: str, index: int) -> Optional[UTxO]:
311313
def submit_tx_cbor(self, cbor: Union[bytes, str]):
312314
if isinstance(cbor, bytes):
313315
cbor = cbor.hex()
314-
with OgmiosClient(self.host, self.port, self.secure) as client:
316+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
315317
client.submit_transaction.execute(cbor)
316318

317319
def evaluate_tx_cbor(self, cbor: Union[bytes, str]) -> Dict[str, ExecutionUnits]:
318320
if isinstance(cbor, bytes):
319321
cbor = cbor.hex()
320-
with OgmiosClient(self.host, self.port, self.secure) as client:
322+
with OgmiosClient(self.host, self.port, self.path, self.secure) as client:
321323
result, _ = client.evaluate_transaction.execute(cbor)
322324
result_dict = {}
323325
for res in result:

0 commit comments

Comments
 (0)