Skip to content

Commit

Permalink
Fix simple scripts for correct script context type
Browse files Browse the repository at this point in the history
  • Loading branch information
nielstron committed Mar 5, 2023
1 parent 879af1e commit 510794f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions examples/smart_contracts/simple_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,31 @@ def validate_script(
>= script.num
)
elif isinstance(script, RequireBefore):
res = valid_range.upper_bound < script.unixtimestamp
upper_bound = valid_range.upper_bound
upper_limit = upper_bound.limit
if isinstance(upper_limit, FinitePOSIXTime):
upper_closed = upper_bound.closed
if isinstance(upper_closed, TrueData):
res = upper_limit.time <= script.unixtimestamp
else:
res = upper_limit.time < script.unixtimestamp
elif isinstance(upper_limit, PosInfPOSIXTime):
res = False
elif isinstance(upper_limit, NegInfPOSIXTime):
res = True
elif isinstance(script, RequireAfter):
res = valid_range.lower_bound > script.unixtimestamp
lower_bound = valid_range.lower_bound
lower_limit = lower_bound.limit
if isinstance(lower_limit, FinitePOSIXTime):
lower_closed = lower_bound.closed
if isinstance(lower_closed, TrueData):
res = lower_limit.time >= script.unixtimestamp
else:
res = lower_limit.time > script.unixtimestamp
elif isinstance(lower_limit, PosInfPOSIXTime):
res = True
elif isinstance(lower_limit, NegInfPOSIXTime):
res = False
else:
assert False, "Invalid simple script passed"
return res
Expand Down

0 comments on commit 510794f

Please sign in to comment.