| 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(trigger.data.timestamp); |
| 25 | if(!is_integer(trigger.data.timestamp )) bounce("invalid timestamp"); |
| 26 | |
| 27 | $first_timestamp = unit[trigger.data.first_unit_id].timestamp; |
| 28 | |
| 29 | response['nts'] = 'kGQZkIj3gRclCp2vw9LMg0jVnPKYCebXHxm8XYPxbQ4='; |
| 30 | response['ts'] = unit['kGQZkIj3gRclCp2vw9LMg0jVnPKYCebXHxm8XYPxbQ4='].timestamp; |
| 31 | response['mts'] = trigger.data.first_unit_id; |
| 32 | response['mts'] = unit[trigger.data.first_unit_id].timestamp; |
| 33 | |
| 34 | if(!$first_timestamp) bounce ('first unit not existing'); |
| 35 | if($first_timestamp>trigger.data.timestamp) bounce("first unit should be earlier than "||$date_and_time||"("||$first_timestamp||")"); |
| 36 | |
| 37 | $second_timestamp = unit[trigger.data.second_unit_id].timestamp; |
| 38 | if(!$second_timestamp) bounce ('second unit not existing'); |
| 39 | if(trigger.data.timestamp>$second_timestamp) bounce("second unit should be older than "||$date_and_time||"("||$second_timestamp||")"); |
| 40 | |
| 41 | $amount_from_first = unit[trigger.data.first_unit_id].messages[[.app='payment']].payload.outputs[[.address=$address, .asset=$asset]].amount; |
| 42 | if(!$amount_from_first)bounce("asset not existing in first unit"); |
| 43 | |
| 44 | $amount_from_second= unit[trigger.data.second_unit_id].messages[[.app='payment']].payload.outputs[[.address=$address, .asset=$asset] ].amount; |
| 45 | if(!$amount_from_second)bounce("asset not existing in second unit"); |
| 46 | |
| 47 | $prooven_amount = ($amount_from_first<$amount_from_second) ? $amount_from_first : $amount_from_second; |
| 48 | |
| 49 | $id = sha256($address||$asset||trigger.data.timestamp); |
| 50 | if (!!var[$id]) bounce ("proof already existing for "||var[$id]||' '||$asset); |
| 51 | }", |
| 52 | "messages": [ |
| 53 | { |
| 54 | "app": "state", |
| 55 | "state": "{ |
| 56 | var[$id] = $prooven_amount; |
| 57 | response["message"] = $prooven_amount||' '||$asset||" proof stored"; |
| 58 | }" |
| 59 | } |
| 60 | ] |
| 61 | }, |
| 62 | { |
| 63 | "messages": [ |
| 64 | { |
| 65 | "app": "state", |
| 66 | "state": "{ |
| 67 | bounce ("I want to create for you a proof that your actual address was hodling some bytes at a given time. For that, I need a 'first_unit_id', 'second_unit_id' showing your actual address with bytes and the 'timestamp', to store the 'hodling amount proof', the timestamp must be included betwwen the timestamp of the first and the second unit."); |
| 68 | }" |
| 69 | } |
| 70 | ] |
| 71 | } |
| 72 | ] |
| 73 | } |
| 74 | } |
| 75 | ] |