-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path18-timestamps.jsligo
36 lines (30 loc) · 1.17 KB
/
18-timestamps.jsligo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Chapter 18 : Timestamps
* https://academy.ligolang.org/js/chapter-timestamps
*
* 1- Transfer the purchase_price to the vendor_contract
* 2- Don't forget to return your operation.
*
* cli test command
* - incorrect source:
* `ligo run dry-run 18-transactions.jsligo -e main 'Pay({ item: 0 as nat, price: 10 as tez })' 'unit' --source "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" --amount 10`
* - incorrect amount:
* `ligo run dry-run 18-transactions.jsligo -e main 'Pay({ item: 0 as nat, price: 10 as tez })' 'unit' --source "tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV" --amount 2`
* - pass:
* `ligo run dry-run 18-transactions.jsligo -e main 'Pay({ item: 0 as nat, price: 10 as tez })' 'unit' --source "tz1TGu6TN5GSez2ndXXeDX6LgUDvLzPLqgYV" --amount 10`
*/
type mainAction =
| ["GetEta"];
type storage = {
eta: timestamp
};
type return_ = [list<operation>, storage];
const one_day: int = 86_400;
const getEta = (_store: storage): return_ => {
const eta: timestamp = Tezos.get_now() + one_day * 6;
return [list([]), { eta }];
};
const main = (action: mainAction, store: storage): return_ =>
match (action, {
GetEta: () => getEta(store),
});