Skip to content

[#241] Distinguish implicit/contract aliases and addresses on the type level

Nikolay Yakimov requested to merge lierdakil/#241-distinguish-aliases into master

One unfortunate quirk is we can't use Cleveland's call with TAddress any more, the reason being that TAddress is isomorphic to Michelson address, which means it can contain txr1 address, and only smart contracts are allowed to call txr1 addresses.

Description

Very much still WIP, want to see if I broke a lot of network tests, and running those locally is a bit of a chore.

That said, the diff is huge, but it kinda works okay. Wrapping/unwrapping is kinda annoying tho.

Problem: Operations we can perform on addresses and address aliases depend on what "kind" they are. Currently, we're handling this by erroring out. It would be nice to use a more type-safe approach. Using a type-safe approach would also fix some bugs related to handling of aliases of different kinds in tezos-client.

Solution: Introduce 'KindedAddress' -- a datakind-parametrized GADT; implement 'ConstrainedAddress' existential over 'KindedAddress' limited to only some possible constructors; implement 'Address' as 'ConstrainedAddress' allowing all possible constructors. Add corresponding singleton instances and type synonyms. Use the new more type-safe address types where possible.

Related issue(s)

Resolves #241 (closed), resolves #729 (closed), supersedes !1132 (closed) and !1064 (closed) (eventually), partially based on !1064 (closed).

Arguably resolves #577 (closed), but uses a very different approach.

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 Pinto Pasquale

Merge request reports