|
21 | 21 | MultiAsset,
|
22 | 22 | TransactionInput,
|
23 | 23 | TransactionOutput,
|
| 24 | + TransactionId, |
24 | 25 | UTxO,
|
25 | 26 | Value,
|
26 | 27 | )
|
@@ -197,6 +198,8 @@ def _utxos_kupo(self, address: str) -> List[UTxO]:
|
197 | 198 | )
|
198 | 199 | if datum_hash and result.get("datum_type", "inline"):
|
199 | 200 | datum = self._get_datum_from_kupo(result["datum_hash"])
|
| 201 | + if datum: |
| 202 | + datum_hash = None |
200 | 203 |
|
201 | 204 | if not result["value"]["assets"]:
|
202 | 205 | tx_out = TransactionOutput(
|
@@ -247,9 +250,34 @@ def evaluate_tx_cbor(self, cbor: Union[bytes, str]) -> Dict[str, ExecutionUnits]
|
247 | 250 | cbor (Union[bytes, str]): The serialized transaction to be evaluated.
|
248 | 251 |
|
249 | 252 | Returns:
|
250 |
| - Dict[str, ExecutionUnits]: A list of execution units calculated for each of the transaction's redeemers |
| 253 | + Dict[str, ExecutionUnits]: A list of execution units calculated for |
| 254 | + each of the transaction's redeemers |
251 | 255 |
|
252 | 256 | Raises:
|
253 | 257 | :class:`TransactionFailedException`: When fails to evaluate the transaction.
|
254 | 258 | """
|
255 | 259 | return self._wrapped_backend.evaluate_tx_cbor(cbor)
|
| 260 | + |
| 261 | + def get_metadata_cbor( |
| 262 | + self, tx_id: TransactionId, slot: int |
| 263 | + ) -> Optional[RawCBOR]: |
| 264 | + """Get metadata cbor from Kupo. |
| 265 | +
|
| 266 | + Args: |
| 267 | + tx_id (TransactionId): Transaction id for metadata to query. |
| 268 | + slot (int): Slot number. |
| 269 | +
|
| 270 | + Returns: |
| 271 | + Optional[RawCBOR]: Metadata cbor.""" |
| 272 | + if self._kupo_url is None: |
| 273 | + raise AssertionError( |
| 274 | + "kupo_url object attribute has not been assigned properly." |
| 275 | + ) |
| 276 | + |
| 277 | + kupo_metadata_url = self._kupo_url + f"/metadata/{slot}?transaction_id={tx_id}" |
| 278 | + metadata_result = requests.get(kupo_metadata_url).json() |
| 279 | + |
| 280 | + if metadata_result and metadata_result[0]["transaction_id"] == tx_id: |
| 281 | + return RawCBOR(bytes.fromhex(metadata_result[0]["raw"])) |
| 282 | + |
| 283 | + return None |
0 commit comments