ConseilJS icon indicating copy to clipboard operation
ConseilJS copied to clipboard

Michelson Lambda parameter support

Open simonmcl opened this issue 5 years ago • 2 comments

In your code there is a comment that states Michelson Lambda parameters are currently not supported, when converting Michelson to Micheline.

Is there any timeline on implementing that? I'm building an app at the minute that will require a lot of Michelson Lambda functions and would love to not have to try hardcode the conversions into my app.

simonmcl avatar Apr 08 '20 16:04 simonmcl

hi, it would be helpful if you provided some known-good samples for me to test against.

anonymoussprocket avatar Apr 26 '20 20:04 anonymoussprocket

@anonymoussprocket sorry I thought you'd have some given the comment said it wasn't supported. Heres a few:

Example 1: Michelson:

{DROP; PUSH address "tz1abc123"; CONTRACT unit; IF_SOME {PUSH mutez 1000000; UNIT; TRANSFER_TOKENS;} {PUSH string ""; FAILWITH;};}

Example 1: Micheline:

[
        {
            "prim": "DROP"
        },
        {
            "prim": "PUSH",
            "args": [
                {
                    "prim": "address"
                },
                {
                    "string": "tz1abc123"
                }
            ]
        },
        {
            "prim": "CONTRACT",
            "args": [
                {
                    "prim": "unit"
                }
            ]
        },
        [
            {
                "prim": "IF_NONE",
                "args": [
                    [
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "string"
                                },
                                {
                                    "string": ""
                                }
                            ]
                        },
                        {
                            "prim": "FAILWITH"
                        }
                    ],
                    [
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "mutez"
                                },
                                {
                                    "int": "1000000"
                                }
                            ]
                        },
                        {
                            "prim": "UNIT"
                        },
                        {
                            "prim": "TRANSFER_TOKENS"
                        }
                    ]
                ]
            }
        ]
    ]

Example 2: Michelson:

{DROP; PUSH address "kt1def123"; CONTRACT %transfer (pair (pair address address) nat); IF_SOME {PUSH mutez 0; PUSH nat 100; PUSH address "tz1abc123"; PUSH address "kt1def123"; PAIR; PAIR; TRANSFER_TOKENS;} {PUSH string ""; FAILWITH;}}

Example 2: Micheline:

[
        {
            "prim": "DROP"
        },
        {
            "prim": "PUSH",
            "args": [
                {
                    "prim": "address"
                },
                {
                    "string": "kt1def123"
                }
            ]
        },
        {
            "prim": "CONTRACT",
            "args": [
                {
                    "prim": "pair",
                    "args": [
                        {
                            "prim": "pair",
                            "args": [
                                {
                                    "prim": "address"
                                },
                                {
                                    "prim": "address"
                                }
                            ]
                        },
                        {
                            "prim": "nat"
                        }
                    ]
                }
            ],
            "annots": [
                "%transfer"
            ]
        },
        [
            {
                "prim": "IF_NONE",
                "args": [
                    [
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "string"
                                },
                                {
                                    "string": ""
                                }
                            ]
                        },
                        {
                            "prim": "FAILWITH"
                        }
                    ],
                    [
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "mutez"
                                },
                                {
                                    "int": "0"
                                }
                            ]
                        },
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "nat"
                                },
                                {
                                    "int": "100"
                                }
                            ]
                        },
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "address"
                                },
                                {
                                    "string": "tz1abc123"
                                }
                            ]
                        },
                        {
                            "prim": "PUSH",
                            "args": [
                                {
                                    "prim": "address"
                                },
                                {
                                    "string": "kt1def123"
                                }
                            ]
                        },
                        {
                            "prim": "PAIR"
                        },
                        {
                            "prim": "PAIR"
                        },
                        {
                            "prim": "TRANSFER_TOKENS"
                        }
                    ]
                ]
            }
        ]
    ]

simonmcl avatar Apr 27 '20 09:04 simonmcl