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