ligo/src/test/contracts/time-lock.ligo

29 lines
811 B
Plaintext
Raw Normal View History

2019-12-19 16:10:09 +01:00
type storage_t is timestamp
2020-02-27 17:51:29 +01:00
type message_t is unit -> list (operation)
2019-12-19 16:10:09 +01:00
type default_pt is unit
type call_pt is message_t
2020-02-27 17:51:29 +01:00
type contract_return_t is list (operation) * storage_t
2019-12-19 16:10:09 +01:00
type entry_point_t is
| Call of call_pt
| Default of default_pt
2020-02-27 17:51:29 +01:00
function call (const p : call_pt; const s : storage_t) : contract_return_t is
block {
if s >= now then failwith ("Contract is still time locked") else skip;
const message : message_t = p;
const ret_ops : list (operation) = message (unit)
} with (ret_ops, s)
2019-12-19 16:10:09 +01:00
2020-02-27 17:51:29 +01:00
function default (const p : default_pt; const s : storage_t) :
contract_return_t is
((nil : list (operation)), s)
2019-12-19 16:10:09 +01:00
2020-02-27 17:51:29 +01:00
function main(const param : entry_point_t; const s : storage_t) :
contract_return_t is
2019-12-19 16:10:09 +01:00
case param of
2020-02-27 17:51:29 +01:00
Call (p) -> call (p,s)
| Default (p) -> default (p,s)
end