| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "getters": "{ |
| 5 | $is_unlocked = () => timestamp_to_string(timestamp, 'date') >= params.unlock_date; |
| 6 | }", |
| 7 | "messages": { |
| 8 | "cases": [ |
| 9 | { |
| 10 | "if": "{ trigger.data.withdraw }", |
| 11 | "init": "{ |
| 12 | require(trigger.address == params.owner, "only owner can withdraw"); |
| 13 | require($is_unlocked(), "balance unlocks on " || params.unlock_date); |
| 14 | |
| 15 | $asset = trigger.data.asset OTHERWISE 'base'; |
| 16 | $amount = trigger.data.amount OTHERWISE 0; |
| 17 | require($amount > 0, "invalid amount"); |
| 18 | require(balance[$asset] >= $amount, "insufficient balance"); |
| 19 | }", |
| 20 | "messages": [ |
| 21 | { |
| 22 | "app": "payment", |
| 23 | "payload": { |
| 24 | "asset": "{ $asset }", |
| 25 | "outputs": [ |
| 26 | { |
| 27 | "address": "{ params.owner }", |
| 28 | "amount": "{ trigger.data.amount }" |
| 29 | } |
| 30 | ] |
| 31 | } |
| 32 | }, |
| 33 | { |
| 34 | "app": "state", |
| 35 | "state": "{ response['message'] = 'withdrawn'; }" |
| 36 | } |
| 37 | ] |
| 38 | }, |
| 39 | { |
| 40 | "messages": [ |
| 41 | { |
| 42 | "app": "state", |
| 43 | "state": "{ response['message'] = 'deposit accepted'; }" |
| 44 | } |
| 45 | ] |
| 46 | } |
| 47 | ] |
| 48 | } |
| 49 | } |
| 50 | ] |