Support `[%of_file]` and string code injection in `[%michelson]`
Motivation and Context
We are discussing removing the preprocessor. One of the (ab)uses of the preprocessor was to include a .tz
file in the middle of a Michelson embedding with a CREATE_CONTRACT
:
[%Michelson ( {| {
UNPAIR ;
UNPAIR ;
CREATE_CONTRACT
#include "generic_fa2/compiled/fa2_nft.tz"
;
PAIR } |}
: lambda_create_contract)]
Description
In this MR we add two things in order to prevent this hack:
- An injection
[%of_file "foo.txt"]
that pastes the contents offoo.txt
as a verbatim string in that place. - A helper for
[%michelson]
of the formcodestr
that allows to embed Michelson argument.
We could write an embedding like that above as:
[%michelson ({| { PUSH unit Unit ; PUSH mutez 300000000 ; NONE key_hash ; CREATE_CONTRACT (codestr $0) ; PAIR } |} [%of_file "./interpreter_tests/contract_under_test/compiled.tz"] : operation * address)]
Component
-
compiler -
website -
webide -
vscode-plugin -
debugger
Types of changes
-
Bug fix (non-breaking change which fixes an issue) -
New feature (non-breaking change which adds functionality) -
Breaking change (fix or feature that would cause existing functionality to not work as expected) -
Performance improvement (non-breaking change that improves performance) -
None (change with no changelog)
Changelog
Checklist:
-
Changes follow the existing coding style (use dune @fmt
to check). -
Tests for the changes have been added (for bug fixes / feature). -
Documentation has been updated. -
Changelog description has been added (if appropriate). -
Start titles under ## Changelog
section with #### (if appropriate). -
There is no image or uploaded file in changelog -
Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas