bcdhub icon indicating copy to clipboard operation
bcdhub copied to clipboard

BCD does not display contract's entrypoint name

Open rognierbenoit opened this issue 3 years ago • 3 comments

Hi, when an entrypoint has one parameter of type OR, BCD does not find the entrypoint name.

For example : https://better-call.dev/florencenet/KT1DHT7AQog7Ybnxm3yHSGUk2B1oY75zuKym/code

The entrypoint's name is displayed as entrypoint_2 while it should be second (this is because its argument type OR nat string is confused with the OR structure that describes entrypoints).

The archetype source code of this contract :

archetype test
entry first() {
  ()
}
entry second(a : or<nat, string>) {
  ()
}

Regards, Ben

rognierbenoit avatar Jun 26 '21 13:06 rognierbenoit

Hey @rognierbenoit, BCD does not display intermediate entrypoints indeed, only the terminating ones, and moreover tries to "normalize" transaction parameters in case a contract is called with default/intermediate entrypoint.

m-kus avatar Jun 27 '21 10:06 m-kus

thank you Michael for your feedback.

I don't know what an "intermediate endpoint" is.

The parameter type is or (unit %first) (or %second nat string):

I think that the algo that searchs for entrypoints should stop when an annotation is met: here it should consider the second branch of the first or as an entrypoint because it has the annotation %second. I believe this is the purpose of annotations, otherwise it would mean that an entrypoint cannot have one or typed parameter.

rognierbenoit avatar Jun 28 '21 16:06 rognierbenoit

In your case you have the following nested sum type:

      or %default unit (or nat string)
     /                                               \
  unit %first                               or %second nat string
                                                /                                   \  
                                             nat                                 string

There is a root (you can call your contract with the following params: (entrypoint: default, value: Left Unit) There are three terminal nodes, but only one named (entrypoint first, value: Unit) And one intermediate node (entrypoint second, value: Left 42)

BCD recognizes only terminal nodes and since they are not named it will use inferred names entrypoint_1, entrypoint_2, etc

m-kus avatar Jul 07 '21 12:07 m-kus