@@ -58,6 +58,7 @@ def __init__(
58
58
host : str = "localhost" ,
59
59
port : int = 1337 ,
60
60
path : str = "" ,
61
+ additional_headers : Optional [dict ] = None ,
61
62
secure : bool = False ,
62
63
refetch_chain_tip_interval : Optional [float ] = None ,
63
64
utxo_cache_size : int = 10000 ,
@@ -68,6 +69,7 @@ def __init__(
68
69
self .port = port
69
70
self .path = path
70
71
self .secure = secure
72
+ self .additional_headers = additional_headers or {}
71
73
self ._network = network
72
74
self ._service_name = "ogmios"
73
75
self ._last_known_block_slot = 0
@@ -86,26 +88,26 @@ def __init__(
86
88
self ._datum_cache = LRUCache (maxsize = datum_cache_size )
87
89
88
90
def _query_current_era (self ) -> OgmiosEra :
89
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
91
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
90
92
return get_current_era (client )
91
93
92
94
def _query_current_epoch (self ) -> int :
93
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
95
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
94
96
epoch , _ = client .query_epoch .execute ()
95
97
return epoch
96
98
97
99
def _query_chain_tip (self ) -> OgmiosTip :
98
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
100
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
99
101
tip , _ = client .query_network_tip .execute ()
100
102
return tip
101
103
102
104
def _query_utxos_by_address (self , address : Address ) -> List [OgmiosUtxo ]:
103
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
105
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
104
106
utxos , _ = client .query_utxo .execute ([address ])
105
107
return utxos
106
108
107
109
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 :
110
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
109
111
utxos , _ = client .query_utxo .execute (
110
112
[OgmiosTxOutputReference (tx_id , index )]
111
113
)
@@ -135,7 +137,7 @@ def protocol_param(self) -> ProtocolParameters:
135
137
return self ._protocol_param
136
138
137
139
def _fetch_protocol_param (self ) -> ProtocolParameters :
138
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
140
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
139
141
protocol_parameters , _ = client .query_protocol_parameters .execute ()
140
142
pyc_protocol_params = ProtocolParameters (
141
143
min_fee_constant = protocol_parameters .min_fee_constant .lovelace ,
@@ -205,7 +207,7 @@ def genesis_param(self) -> GenesisParameters:
205
207
return self ._genesis_param # type: ignore[return-value]
206
208
207
209
def _fetch_genesis_param (self ) -> OgmiosGenesisParameters :
208
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
210
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
209
211
return OgmiosGenesisParameters (client , self ._query_current_era ())
210
212
211
213
@property
@@ -310,7 +312,7 @@ def utxo_by_tx_id(self, tx_id: str, index: int) -> Optional[UTxO]:
310
312
def query_account_reward_summaries (
311
313
self , scripts : Optional [List [str ]] = None , keys : Optional [List [str ]] = None
312
314
) -> List [dict ]:
313
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
315
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
314
316
summaries , _ = client .query_reward_account_summaries .execute (
315
317
scripts = scripts , keys = keys
316
318
)
@@ -319,13 +321,13 @@ def query_account_reward_summaries(
319
321
def submit_tx_cbor (self , cbor : Union [bytes , str ]):
320
322
if isinstance (cbor , bytes ):
321
323
cbor = cbor .hex ()
322
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
324
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
323
325
client .submit_transaction .execute (cbor )
324
326
325
327
def evaluate_tx_cbor (self , cbor : Union [bytes , str ]) -> Dict [str , ExecutionUnits ]:
326
328
if isinstance (cbor , bytes ):
327
329
cbor = cbor .hex ()
328
- with OgmiosClient (self .host , self .port , self .path , self .secure ) as client :
330
+ with OgmiosClient (self .host , self .port , self .path , self .secure , self . additional_headers ) as client :
329
331
result , _ = client .evaluate_transaction .execute (cbor )
330
332
result_dict = {}
331
333
for res in result :
0 commit comments