MIR: Create function to wrap parameters based on given entrypoint
Problem Statement:
To facilitate seamless integration of MIR with Etherlink, it's essential to refine the method of accessing Michelson contract entrypoints. Currently, the interface lacks a direct instruction that enables the translation of entrypoints into a wrapped parameter, having to rely on contract addresses that are not available on the etherlink side.
Proposed Solution:
Introduce a new instruction within MIR which takes a contract, an entrypoint, and a parameter and returns the wrapped parameter
Example Illustration:
Consider a contract with the parameter type as defined in the Tezos documentation:
parameter (or (or (nat %A) (bool %B)) (or %maybe_C (unit %Z) (string %C)))
We must have the following behaviour:
+------------+-----------+----------------------------------------+
| entrypoint | parameter | wrapped parameter |
+------------+-----------+----------------------------------------+
| %A | 3 | Left (Left 3) |
| %B | False | Left (Right False) |
| %C | "bob" | Right (Right "bob") |
| %Z | Unit | Right (Left Unit) |
| %maybe_C | Right "x" | Right (Right "x") |
| %maybe_C | Left Unit | Right (Left Unit) |
+------------+-----------+----------------------------------------+
| not given | value | value (untouched, the same as default) |
| %BAD | _ | failure, contract not called |
+------------+-----------+----------------------------------------+
Edited by Luciano Freitas