@@ -63,11 +63,13 @@ def __init__(
63
63
utxo_cache_size : int = 10000 ,
64
64
datum_cache_size : int = 10000 ,
65
65
network : Network = Network .TESTNET ,
66
+ additional_headers : Optional [dict ] = None ,
66
67
):
67
68
self .host = host
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,36 @@ 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 (
92
+ self .host , self .port , self .path , self .secure , self .additional_headers
93
+ ) as client :
90
94
return get_current_era (client )
91
95
92
96
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 :
94
100
epoch , _ = client .query_epoch .execute ()
95
101
return epoch
96
102
97
103
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 :
99
107
tip , _ = client .query_network_tip .execute ()
100
108
return tip
101
109
102
110
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 :
104
114
utxos , _ = client .query_utxo .execute ([address ])
105
115
return utxos
106
116
107
117
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 :
109
121
utxos , _ = client .query_utxo .execute (
110
122
[OgmiosTxOutputReference (tx_id , index )]
111
123
)
@@ -135,7 +147,9 @@ def protocol_param(self) -> ProtocolParameters:
135
147
return self ._protocol_param
136
148
137
149
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 :
139
153
protocol_parameters , _ = client .query_protocol_parameters .execute ()
140
154
pyc_protocol_params = ProtocolParameters (
141
155
min_fee_constant = protocol_parameters .min_fee_constant .lovelace ,
@@ -205,7 +219,9 @@ def genesis_param(self) -> GenesisParameters:
205
219
return self ._genesis_param # type: ignore[return-value]
206
220
207
221
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 :
209
225
return OgmiosGenesisParameters (client , self ._query_current_era ())
210
226
211
227
@property
@@ -310,7 +326,9 @@ def utxo_by_tx_id(self, tx_id: str, index: int) -> Optional[UTxO]:
310
326
def query_account_reward_summaries (
311
327
self , scripts : Optional [List [str ]] = None , keys : Optional [List [str ]] = None
312
328
) -> 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 :
314
332
summaries , _ = client .query_reward_account_summaries .execute (
315
333
scripts = scripts , keys = keys
316
334
)
@@ -319,13 +337,17 @@ def query_account_reward_summaries(
319
337
def submit_tx_cbor (self , cbor : Union [bytes , str ]):
320
338
if isinstance (cbor , bytes ):
321
339
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 :
323
343
client .submit_transaction .execute (cbor )
324
344
325
345
def evaluate_tx_cbor (self , cbor : Union [bytes , str ]) -> Dict [str , ExecutionUnits ]:
326
346
if isinstance (cbor , bytes ):
327
347
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 :
329
351
result , _ = client .evaluate_transaction .execute (cbor )
330
352
result_dict = {}
331
353
for res in result :
@@ -380,6 +402,7 @@ def KupoOgmiosV6ChainContext(
380
402
utxo_cache_size : int = 10000 ,
381
403
datum_cache_size : int = 10000 ,
382
404
network : Network = Network .TESTNET ,
405
+ additional_headers : Optional [dict ] = None ,
383
406
kupo_url : Optional [str ] = None ,
384
407
) -> KupoChainContextExtension :
385
408
return KupoChainContextExtension (
@@ -392,6 +415,7 @@ def KupoOgmiosV6ChainContext(
392
415
utxo_cache_size ,
393
416
datum_cache_size ,
394
417
network ,
418
+ additional_headers ,
395
419
),
396
420
kupo_url ,
397
421
)
0 commit comments