Skip to content

Commit

Permalink
Keys / signatures constants + fix timestamps
Browse files Browse the repository at this point in the history
- Timestamps have to be in iso8691 format like michelson
- No checks are performed on keys / signatures at the moment
  • Loading branch information
mebsout committed Oct 6, 2017
1 parent b3d075e commit cc91a1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/liquidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ As in Michelson, there are different types of integers:
a `tz` suffix (`1.00tz`, etc.) or as a string with type coercion
(`("1.00" : tez)`).

Timestamps are written in ISO 8601 format or integer seconds since epoch, the
following are equivalent:
Timestamps are written in ISO 8601 format, like in Michelson:
* `("2015-12-01T10:01:00+01:00" : timestamp)`
* `("1448960460" : timestamp)`
* `(1448960460 : timestamp)`

Keys and signatures constants are the same as the ones in Michelson:
* `("tz1hxLtJnSYCVabeGio3M87Yp8ChLF9LFmCM" : key)`

There are also three types of collections: lists, sets and
maps. Constants collections can be created directly:
Expand Down
7 changes: 1 addition & 6 deletions tools/liquidity/liquidCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1371,16 +1371,11 @@ let check_const_type ~to_tez loc ty cst =
| Ttez, CString s -> CTez (to_tez s)

| Tkey, CKey s
| Tkey, CString s -> CKey s

| Ttimestamp, CInt { integer = s }
| Ttimestamp, CNat { integer = s } -> CTimestamp s
| Tkey, CString s -> CKey s

| Ttimestamp, CString s
| Ttimestamp, CTimestamp s ->
begin (* approximation of correct tezos timestamp *)
try Scanf.sscanf s "%_d%!" ()
with _ ->
try Scanf.sscanf s "%_d-%_d-%_dT%_d:%_d:%_dZ%!" ()
with _ ->
try Scanf.sscanf s "%_d-%_d-%_d %_d:%_d:%_dZ%!" ()
Expand Down
3 changes: 3 additions & 0 deletions tools/liquidity/with-tezos/liquidToTezos.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ let rec convert_const expr =
| CSignature _|CLeft _|CRight _)
*)
| CTimestamp s -> Script_repr.String (0, s)
| CKey s -> Script_repr.String (0, s)
| CSignature s -> Script_repr.String (0, s)

| _ ->
LiquidLoc.raise_error "to-tezos: unimplemented const:\n%s%!"
(LiquidPrinter.Michelson.string_of_const expr)
Expand Down

0 comments on commit cc91a1e

Please sign in to comment.