Skip to content

[#928] Support implicit account tickets

Nikolay Yakimov requested to merge lierdakil/#928-implicit-account-tickets into mumbai

Based on top of !1330 (merged) because those touch the same code, plus !1330 (merged) simplifies testing.

The implementation has one curious quirk: transferring raw tickets using Cleveland's transfer will be rejected by the network, but accepted by the emulator. This was the case before this MR, actually. The quirk is that the emulator will interpret transfers with ticket parameter as ticket transfers. We could do the legwork of forbidding ticket parameters for Cleveland transfers, and that would mostly solve this, but TBH I don't see a compelling reason for doing so.

Description

Problem: Mumbai introduced new manager operation transfer_ticket. We need to support it in morley-client to transfer tickets from implicit accounts.

Solution: Add support to morley-client.

Problem: Mumbai allows ticket transfers to/from implicit accounts.

Solution: Make similar allowance in the morley emulator. We don't in fact want to introduce a separate type of operation in the emulator, because that would duplicate a lot of code. Furthermore, morley emulator allows manually sending transactions from contracts, which would have to use regular transactions, and that would complicate the matters even more. Hence, ticket transfers are handled as a variation of regular transfers when sender is an implicit contract and parameter is a typed ticket. It is still possible to transfer forged tickets to contracts by supplying untyped parameter in the shape of a ticket.

Problem: ToTAddress assumes implicit contract parameter is unit. Since Mumbai, it can also be ticket 'a. We would still like to default to unit.

Solution: Since we'd still like to default to unit, but also allow ticket when explicitly required, introduce a class ImplicitContractParameter with an incoherent catchall instance forcing the parameter into unit, but also a separate regular instance for tickets. Thus, when parameter is ambiguous, it will be assumed to be unit, and when it's unambiguously ticket, whether due to type inference or explicitly specified, the specific instance would be selected.

Problem: Mumbai allows implicit accounts to own and transfer tickets, but Cleveland doesn't do ticket transfers yet.

Solution: Support ticket transfers in Cleveland using special functions.

Related issue(s)

Resolves #928 (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)

Merge request reports