| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | |
| 9 | $name = "DAG Snapshot for AA"; |
| 10 | |
| 11 | |
| 12 | |
| 13 | }", |
| 14 | "messages": { |
| 15 | "cases": [ |
| 16 | { |
| 17 | "if": "{ !!trigger.data.first_unit_id and !!trigger.data.second_unit_id and !!trigger.data.timestamp }", |
| 18 | "init": "{ |
| 19 | $address = trigger.data.address otherwise trigger.address; |
| 20 | if(!is_valid_address($address)) bounce ("invalid address"); |
| 21 | |
| 22 | $asset = trigger.data.asset otherwise "base"; |
| 23 | |
| 24 | $date_and_time = timestamp_to_string(timestamp); |
| 25 | if(!is_integer(trigger.data.timestamp )) bounce("invalid timestamp"); |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | $amount_from_first = unit[trigger.data.first_unit_id].messages[[.app='payment', .asset=$asset]].payload.outputs[[.address=$address] ].amount; |
| 36 | if(!$amount_from_first)bounce("asset not existing in first unit"); |
| 37 | |
| 38 | $amount_from_second= unit[trigger.data.second_unit_id].messages[[.app='payment', .asset=$asset]].payload.outputs[[.address=$address] ].amount; |
| 39 | if(!$amount_from_second)bounce("asset not existing in second unit"); |
| 40 | |
| 41 | $prooven_amount = ($amount_from_first<$amount_from_second) ? $amount_from_first : $amount_from_second; |
| 42 | |
| 43 | $id = sha256($address||$asset||trigger.data.timestamp); |
| 44 | if (!!var[$id]) bounce ("proof already existing for "||var[$id]||' '||$asset); |
| 45 | }", |
| 46 | "messages": [ |
| 47 | { |
| 48 | "app": "state", |
| 49 | "state": "{ |
| 50 | var[$id] = $amount; |
| 51 | response["message"] = $amount||' '||$asset||" proof stored"; |
| 52 | }" |
| 53 | } |
| 54 | ] |
| 55 | }, |
| 56 | { |
| 57 | "messages": [ |
| 58 | { |
| 59 | "app": "state", |
| 60 | "state": "{ |
| 61 | bounce ("I need a 'first_unit_id', 'second_unit_id' and 'timestamp', to store the 'hodling amount proof', the timestamp must be include betwwen the timestamp of the first and the second unit."); |
| 62 | }" |
| 63 | } |
| 64 | ] |
| 65 | } |
| 66 | ] |
| 67 | } |
| 68 | } |
| 69 | ] |