| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $aa_name = "DANAA"; |
| 6 | $owner = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; |
| 7 | |
| 8 | $unit_id = trigger.data.unit_id otherwise false; |
| 9 | $short_name = trigger.data.short_name otherwise false; |
| 10 | $ticker = trigger.data.ticker otherwise false; |
| 11 | $decimals = trigger.data.decimals otherwise false; |
| 12 | |
| 13 | $issuer = trigger.address; |
| 14 | $name = trigger.data.name otherwise $shortName||" by "||$author; |
| 15 | $description = trigger.data.description otherwise "Asset called "||$shortName||" issued by "||$issuer||", with "||$decimals||" decimals available. Its ticker is "||$ticker||" and it is defined by the unit '"||$unit_id||"'."; |
| 16 | }", |
| 17 | "messages": { |
| 18 | "cases": [ |
| 19 | { |
| 20 | "if": "{ $unit_id and $short_name and $ticker and $decimals }", |
| 21 | "init": "{ |
| 22 | |
| 23 | if (var[$unit_id]) |
| 24 | if (trigger.address != var[$unit_id||"_issuer"]) |
| 25 | bounce ("Already registered and not by you!"); |
| 26 | }", |
| 27 | "messages": [ |
| 28 | { |
| 29 | "app": "data", |
| 30 | "payload": { |
| 31 | "unit_id": "{$unit_id}", |
| 32 | "name": "{$name}", |
| 33 | "short_name": "{$short_name}", |
| 34 | "issuer": "{$issuer}", |
| 35 | "ticker": "{$ticker}", |
| 36 | "decimals": "{$decimals}", |
| 37 | "description": "{$description}" |
| 38 | } |
| 39 | }, |
| 40 | { |
| 41 | "app": "payment", |
| 42 | "payload": { |
| 43 | "asset": "{'base'}", |
| 44 | "outputs": [ |
| 45 | { |
| 46 | "address": "{$author}", |
| 47 | "amount": "{trigger.output[[asset=base]] - 1000}" |
| 48 | } |
| 49 | ] |
| 50 | } |
| 51 | }, |
| 52 | { |
| 53 | "app": "state", |
| 54 | "state": "{ |
| 55 | var[$unit_id||"_shortName"] = $short_name; |
| 56 | var[$unit_id||"_issuer"] = $issuer; |
| 57 | var[$unit_id||"_name"] = $name; |
| 58 | var[$unit_id||"_ticker"] = $ticker; |
| 59 | var[$unit_id||"_decimals"] = $decimals; |
| 60 | var[$unit_id||"_description"] = $description; |
| 61 | }" |
| 62 | } |
| 63 | ] |
| 64 | }, |
| 65 | { |
| 66 | "messages": [ |
| 67 | { |
| 68 | "app": "state", |
| 69 | "state": "{ |
| 70 | bounce ("Specify the following fields: 'unit_id', 'shortname', 'ticker', 'decimal' and optionaly 'name, and description' that can be by default built from the previous fields."); |
| 71 | }" |
| 72 | } |
| 73 | ] |
| 74 | } |
| 75 | ] |
| 76 | } |
| 77 | } |
| 78 | ] |