Skip to content

[#613] [#602] [#584] Refactor Cleveland's originate* and transfer/call functions

Nikolay Yakimov requested to merge lierdakil/#613-refactor-originate into master

Note: this is partially based on and (arguably) supersedes !1102 (closed).

Quirks:

  • Can't specify parameter/storage/view descriptors as type arguments to originate. In most cases this is arguably not needed, the only case where it makes sense is typed Michelson contracts.
  • With typed Michelson contracts, a wrapper TypedContract is introduced, which makes a typed Michelson contract seem like a Lorentz contract for the purposes of origination.

There is a way to avoid both of these quirks, but the implementation becomes somewhat unwieldy as the result.

  • Initial balance in originate and transfer amount in transfer needs to be monomorphic Mutez. Getting polymorphic literals to work is technically not impossible via incoherent instances, but that creates other issues (like type inference not always working as it should). This is not a huge deal since we can just use the tz quasi-quoter; simply adding a type annotation is also an option.

Questions:

  • Should we perhaps use TypedContract in Test.Cleveland.Michelson.Import to reduce friction with typed contracts?

    Tried to prototype this concept, the inability to specify explicit Michelson types for contracts gets pretty annoying, so ultimately not worth it IMO.

  • Can we just straight up remove various originate* functions, or do we need to deprecate those properly?

TODO:

  • Apparently I can't count, because the commit message says we had 6 originate* functions, but actually we had 9.

Description

Problem: We have 9 originate* functions. This is too much.

Solution: Replace those 9 with two, one of which is considered low-level and not a part of the public API.

Problem: We have transfer, which is general enough, transferMoney, which is occasionally convenient but awkward, and call which is a typed version of transfer, but without the money. We'd like to have a more concise API.

Solution: Overload transfer with the "printf trick", accepting an optional amount and an optional calling specification. Two ways to specify the call: checked and unchecked; both work with typed addresses (and 'ContractHandle'), but only unchecked works with untyped addresses.

This also splits Test.Cleveland.Internal.Actions into several sub-modules (the file was over 1000 lines long, it's simply unwieldy)

Related issue(s)

Resolves #613 (closed), #602 (closed), #584 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Nikolay Yakimov

Merge request reports