Code review of HTLC contract on Sophia

I would like to ask you for help.

Are there any volunteers that can do a brief code review of our HTLC contract written on sophia:

If you are interested you can check our monorepo as well:

Our team have prepared a small award for the volunteers :wink:

3 Likes

I’ve already had a look at an earlier draft of this contract I believe, but some small comments that (still) apply:

  • public is not a necessary keyword. A function is either a function (private) or an entrypoint (public).
  • You don’t need List.aes anymore, it is part of the compiler.
  • is_active can be simplified into:
    function is_active(x : status) : bool =
      x == ACTIVE
    
  • String handling is a bit ugly in Sophia but you could use functions like:
    // Just concatenate a list of strings
    function cc(ss : list(string)) =
      switch(ss)
        s :: ss => List.foldl(String.concat, s, ss)
    
    // Concatenate a list of strings, interspersed with ","
    function concat(ss : list(string)) =
      cc(List.intersperse(",", ss))
    
    to simplify it a bit…
5 Likes