| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "messages": { |
| 8 | "cases": [ |
| 9 | { |
| 10 | "if": "{ trigger.data.action == 'deploy' }", |
| 11 | "init": "{ |
| 12 | $base = 'I6NZZIIMLZQMKGNEGELSCVA5WEHC2GEG'; |
| 13 | require(trigger.data.unlock_date, "unlock_date required"); |
| 14 | |
| 15 | $ud_ts = parse_date(trigger.data.unlock_date); |
| 16 | require($ud_ts, "invalid unlock_date"); |
| 17 | $ud = timestamp_to_string($ud_ts, 'date'); |
| 18 | |
| 19 | $owner = trigger.address; |
| 20 | |
| 21 | |
| 22 | $name = trigger.data.name OTHERWISE ''; |
| 23 | |
| 24 | $params = { owner: $owner, unlock_date: $ud }; |
| 25 | if ($name) $params.name = $name; |
| 26 | |
| 27 | $def = ["autonomous agent", { base_aa: $base, params: $params }]; |
| 28 | $new_aa = chash160($def); |
| 29 | }", |
| 30 | "messages": [ |
| 31 | { |
| 32 | "app": "definition", |
| 33 | "payload": { |
| 34 | "definition": "{ $def }" |
| 35 | } |
| 36 | }, |
| 37 | { |
| 38 | "app": "state", |
| 39 | "state": "{ |
| 40 | response['message'] = 'instance deployed'; |
| 41 | response['new_aa'] = $new_aa; |
| 42 | response['owner'] = $owner; |
| 43 | response['unlock_date'] = $ud; |
| 44 | if ($name) response['name'] = $name; |
| 45 | }" |
| 46 | } |
| 47 | ] |
| 48 | }, |
| 49 | { |
| 50 | "messages": [ |
| 51 | { |
| 52 | "app": "state", |
| 53 | "state": "{ response['error'] = 'send action=deploy & unlock_date'; }" |
| 54 | } |
| 55 | ] |
| 56 | } |
| 57 | ] |
| 58 | } |
| 59 | } |
| 60 | ] |