morley-1.12.0: Developer tools for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Michelson.Untyped.Entrypoints

Synopsis

Documentation

newtype EpName Source #

Entrypoint name.

There are two properties we care about:

  1. Special treatment of the default entrypoint name. default is prohibited in the CONTRACT instruction and in values of address and contract types. However, it is not prohibited in the SELF instruction. Hence, the value inside EpName can be "default", so that we can distinguish SELF and SELF %default. It is important to distinguish them because their binary representation that is inserted into blockchain is different. For example, typechecking SELF %default consumes more gas than SELF. In this module, we provide several smart constructors with different handling of default, please use the appropriate one for your use case.
  2. The set of permitted characters. Intuitively, an entrypoint name should be valid only if it is a valid annotation (because entrypoints are defined using field annotations). However, it is not enforced in Tezos. It is not clear whether this behavior is intended. There is an upstream issue which received bug label, so probably it is considered a bug. Currently we treat it as a bug and deviate from upstream implementation by probiting entrypoint names that are not valid annotations. If Tezos developers fix it soon, we will be happy. If they don't, we should (maybe temporarily) remove this limitation from our code. There is an issue in our repo as well.

Constructors

EpNameUnsafe 

Fields

Instances

Instances details
Eq EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

Methods

(==) :: EpName -> EpName -> Bool #

(/=) :: EpName -> EpName -> Bool #

Ord EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

Show EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

Generic EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

Associated Types

type Rep EpName :: Type -> Type #

Methods

from :: EpName -> Rep EpName x #

to :: Rep EpName x -> EpName #

ToJSON EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

FromJSON EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

NFData EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

Methods

rnf :: EpName -> () #

Buildable EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

Methods

build :: EpName -> Builder #

HasCLReader EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

type Rep EpName Source # 
Instance details

Defined in Michelson.Untyped.Entrypoints

type Rep EpName = D1 ('MetaData "EpName" "Michelson.Untyped.Entrypoints" "morley-1.12.0-inplace" 'True) (C1 ('MetaCons "EpNameUnsafe" 'PrefixI 'True) (S1 ('MetaSel ('Just "unEpName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

pattern DefEpName :: EpName Source #

This is a bidirectional pattern that can be used for two purposes:

  1. Construct an EpName referring to the default entrypoint.
  2. Use it in pattern-matching or in equality comparison to check whether EpName refers to the default entrypoint. This is trickier because there are two possible EpName values referring to the default entrypoints. DefEpName will match only the most common one (no entrypoint). However, there is a special case: SELF instruction can have explicit %default reference. For this reason, it is recommended to use isDefEpName instead. Pattern-matching on DefEpName is still permitted for backwards compatibility and for the cases when you are sure that EpName does not come from the SELF instruction.

isDefEpName :: EpName -> Bool Source #

Check whether given EpName refers to the default entrypoint. Unlike DefEpName pattern, this function correctly handles all cases, including the SELF instruction.

epNameFromParamAnn :: FieldAnn -> Maybe EpName Source #

Make up EpName from annotation in parameter type declaration.

Returns Nothing if no entrypoint is assigned here.

epNameToParamAnn :: EpName -> FieldAnn Source #

Turn entrypoint name into annotation for contract parameter declaration.

epNameFromRefAnn :: FieldAnn -> Either EpNameFromRefAnnError EpName Source #

Make up EpName from annotation which is reference to an entrypoint. Note that it's more common for Michelson to prohibit explicit default entrypoint reference.

Specifically, %default annotation is probitited in values of address and contract types. It's also prohibited in the CONTRACT instruction. However, there is an exception: SELF %default is a perfectly valid instruction. Hence, when you construct an EpName from an annotation that's part of SELF, you should use epNameFromSelfAnn instead.

epNameFromSelfAnn :: FieldAnn -> EpName Source #

Make up an EpName from an annotation which is part of the SELF instruction.

epNameToRefAnn :: EpName -> FieldAnn Source #

Turn entrypoint name into annotation used as reference to entrypoint.

data EpNameFromRefAnnError Source #

buildEpName :: Text -> Either String EpName Source #

Make a valid entrypoint name from an arbitrary text. This function prohibits explicit default entrypoint name which is permitted by Michelson inside the SELF instruction. This limitation shouldn't be restrictive because SELF is equivalent to SELF %default.

mkEntrypointsMap :: ParameterType -> Map EpName Type Source #

Given an untyped parameter type, extract a map that maps entrypoint names to the their parameter types. If there are duplicate entrypoints in the given Type then the duplicate entrypoints at a deeper nesting level will get overwritten with the ones that are on top.