@@ -63,11 +63,13 @@ def __init__(
6363 utxo_cache_size : int = 10000 ,
6464 datum_cache_size : int = 10000 ,
6565 network : Network = Network .TESTNET ,
66+ additional_headers : Optional [dict ] = None ,
6667 ):
6768 self .host = host
6869 self .port = port
6970 self .path = path
7071 self .secure = secure
72+ self .additional_headers = additional_headers or {}
7173 self ._network = network
7274 self ._service_name = "ogmios"
7375 self ._last_known_block_slot = 0
@@ -86,26 +88,36 @@ 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 .path , self .secure ) as client :
91+ with OgmiosClient (
92+ self .host , self .port , self .path , self .secure , self .additional_headers
93+ ) as client :
9094 return get_current_era (client )
9195
9296 def _query_current_epoch (self ) -> int :
93- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
97+ with OgmiosClient (
98+ self .host , self .port , self .path , self .secure , self .additional_headers
99+ ) as client :
94100 epoch , _ = client .query_epoch .execute ()
95101 return epoch
96102
97103 def _query_chain_tip (self ) -> OgmiosTip :
98- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
104+ with OgmiosClient (
105+ self .host , self .port , self .path , self .secure , self .additional_headers
106+ ) as client :
99107 tip , _ = client .query_network_tip .execute ()
100108 return tip
101109
102110 def _query_utxos_by_address (self , address : Address ) -> List [OgmiosUtxo ]:
103- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
111+ with OgmiosClient (
112+ self .host , self .port , self .path , self .secure , self .additional_headers
113+ ) as client :
104114 utxos , _ = client .query_utxo .execute ([address ])
105115 return utxos
106116
107117 def _query_utxos_by_tx_id (self , tx_id : str , index : int ) -> List [OgmiosUtxo ]:
108- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
118+ with OgmiosClient (
119+ self .host , self .port , self .path , self .secure , self .additional_headers
120+ ) as client :
109121 utxos , _ = client .query_utxo .execute (
110122 [OgmiosTxOutputReference (tx_id , index )]
111123 )
@@ -135,7 +147,9 @@ def protocol_param(self) -> ProtocolParameters:
135147 return self ._protocol_param
136148
137149 def _fetch_protocol_param (self ) -> ProtocolParameters :
138- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
150+ with OgmiosClient (
151+ self .host , self .port , self .path , self .secure , self .additional_headers
152+ ) as client :
139153 protocol_parameters , _ = client .query_protocol_parameters .execute ()
140154 pyc_protocol_params = ProtocolParameters (
141155 min_fee_constant = protocol_parameters .min_fee_constant .lovelace ,
@@ -205,7 +219,9 @@ def genesis_param(self) -> GenesisParameters:
205219 return self ._genesis_param # type: ignore[return-value]
206220
207221 def _fetch_genesis_param (self ) -> OgmiosGenesisParameters :
208- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
222+ with OgmiosClient (
223+ self .host , self .port , self .path , self .secure , self .additional_headers
224+ ) as client :
209225 return OgmiosGenesisParameters (client , self ._query_current_era ())
210226
211227 @property
@@ -310,7 +326,9 @@ def utxo_by_tx_id(self, tx_id: str, index: int) -> Optional[UTxO]:
310326 def query_account_reward_summaries (
311327 self , scripts : Optional [List [str ]] = None , keys : Optional [List [str ]] = None
312328 ) -> List [dict ]:
313- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
329+ with OgmiosClient (
330+ self .host , self .port , self .path , self .secure , self .additional_headers
331+ ) as client :
314332 summaries , _ = client .query_reward_account_summaries .execute (
315333 scripts = scripts , keys = keys
316334 )
@@ -319,13 +337,17 @@ def query_account_reward_summaries(
319337 def submit_tx_cbor (self , cbor : Union [bytes , str ]):
320338 if isinstance (cbor , bytes ):
321339 cbor = cbor .hex ()
322- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
340+ with OgmiosClient (
341+ self .host , self .port , self .path , self .secure , self .additional_headers
342+ ) as client :
323343 client .submit_transaction .execute (cbor )
324344
325345 def evaluate_tx_cbor (self , cbor : Union [bytes , str ]) -> Dict [str , ExecutionUnits ]:
326346 if isinstance (cbor , bytes ):
327347 cbor = cbor .hex ()
328- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
348+ with OgmiosClient (
349+ self .host , self .port , self .path , self .secure , self .additional_headers
350+ ) as client :
329351 result , _ = client .evaluate_transaction .execute (cbor )
330352 result_dict = {}
331353 for res in result :
@@ -380,6 +402,7 @@ def KupoOgmiosV6ChainContext(
380402 utxo_cache_size : int = 10000 ,
381403 datum_cache_size : int = 10000 ,
382404 network : Network = Network .TESTNET ,
405+ additional_headers : Optional [dict ] = None ,
383406 kupo_url : Optional [str ] = None ,
384407) -> KupoChainContextExtension :
385408 return KupoChainContextExtension (
@@ -392,6 +415,7 @@ def KupoOgmiosV6ChainContext(
392415 utxo_cache_size ,
393416 datum_cache_size ,
394417 network ,
418+ additional_headers ,
395419 ),
396420 kupo_url ,
397421 )
0 commit comments