From 9781a1c8ff6b669fe481f2cba7cfd80a091251f2 Mon Sep 17 00:00:00 2001 From: John David Pressman Date: Wed, 22 Jan 2020 03:01:21 -0800 Subject: [PATCH] Add rough draft of repeating timelock contract --- src/test/contracts/timelock_repeat.mligo | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/contracts/timelock_repeat.mligo diff --git a/src/test/contracts/timelock_repeat.mligo b/src/test/contracts/timelock_repeat.mligo new file mode 100644 index 000000000..a647a47a9 --- /dev/null +++ b/src/test/contracts/timelock_repeat.mligo @@ -0,0 +1,20 @@ +type storage = { + last_use: timestamp; + interval: int; + execute: unit -> operation list; +} + +let main (p,s: unit * storage) : operation list * storage = + if Current.time > (s.last_use + s.interval) + then + let s: storage = { + last_use = Current.time; + interval = s.interval; + execute = s.execute; + } + in + (s.execute (), s) + else + (* TODO: Add the time until next use to this message *) + (failwith "You have to wait before you can execute this contract again.": + operation list * storage)