Skip to content

Commit

Permalink
Raise error if could not resolve attached datum
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Apr 11, 2023
1 parent 8897aa5 commit 0f23048
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions opshin/prelude.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ def resolve_datum(
Otherwise it returns NoOutputDatum.
"""
attached_datum = txout.datum
res: Union[SomeOutputDatum, NoOutputDatum] = NoOutputDatum()
if isinstance(attached_datum, SomeOutputDatumHash):
if attached_datum.datum_hash in tx_info.data.keys():
res = SomeOutputDatum(
res: Union[SomeOutputDatum, NoOutputDatum] = SomeOutputDatum(
tx_info.data.get(attached_datum.datum_hash, Nothing())
)
else:
assert (
False
), "Could not resolve attached datum from datum hash, because it was not embedded in the transaction"
else:
res = attached_datum
res: Union[SomeOutputDatum, NoOutputDatum] = attached_datum
return res

0 comments on commit 0f23048

Please sign in to comment.