Skip to content

Commit 4ea5925

Browse files
committed
Add a language and version marker
1 parent 7c31009 commit 4ea5925

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

opshin/__main__.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
import uplc
2323
import uplc.ast
24+
import uplc.flat_encoder
25+
from uplc.ast import Program
2426
from uplc.cost_model import PlutusVersion
2527

2628
from . import (
@@ -377,12 +379,23 @@ def perform_command(args):
377379
return
378380
code = pluthon.compile(code, config=compiler_config)
379381

382+
# Add a marker for OpShin/version
383+
code = uplc.ast.Program(
384+
code.version,
385+
uplc.ast.Apply(
386+
uplc.ast.Lambda("_", code.term),
387+
uplc.ast.BuiltinByteString(
388+
bytes([ord("o"), *(int(x) for x in __version__.split("."))])
389+
),
390+
),
391+
)
392+
380393
# apply parameters from the command line to the contract (instantiates parameterized contract!)
381394
code = code.term
382395
# UPLC lambdas may only take one argument at a time, so we evaluate by repeatedly applying
383396
for d in uplc_params:
384397
code = uplc.ast.Apply(code, d)
385-
code = uplc.ast.Program((1, 0, 0), code)
398+
code = uplc.ast.Program((1, 1, 0), code)
386399

387400
if command == Command.compile:
388401
print(code.dumps())

0 commit comments

Comments
 (0)