| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $origin = definition[trigger.address][1].base_aa otherwise trigger.address; |
| 6 | $oracle = trigger.data.oracle; |
| 7 | $asset_symbol = to_upper(trigger.data.asset_symbol); |
| 8 | $decimals = trigger.data.decimals OTHERWISE 9; |
| 9 | if (!$oracle) |
| 10 | bounce("no oracle specified"); |
| 11 | if (!is_valid_address($oracle)) |
| 12 | bounce("oracle is not a valid address"); |
| 13 | if ($asset_symbol){ |
| 14 | if (typeof($asset_symbol) != "string") |
| 15 | bounce("asset symbol must be a string"); |
| 16 | if(contains($asset_symbol,"|")) |
| 17 | bounce("asset symbol cannot contain '|'"); |
| 18 | if (length($asset_symbol) > 50) |
| 19 | bounce("asset symbol cannot be longer than 50 chars"); |
| 20 | if (var['s2a_' || $asset_symbol || '|' || $origin || '|' || $oracle]) |
| 21 | bounce("This symbol is already registered"); |
| 22 | if (trigger.output[[asset=base]] < length($asset_symbol)*2 + 348) |
| 23 | bounce("Payment received doesn't cover storage fees"); |
| 24 | if (!is_integer($decimals)) |
| 25 | bounce("Decimals must be integer"); |
| 26 | } |
| 27 | |
| 28 | }", |
| 29 | "messages": [ |
| 30 | { |
| 31 | "if": "{exists(trigger.data.next_asset_step)}", |
| 32 | "app": "payment", |
| 33 | "payload": { |
| 34 | "asset": "base", |
| 35 | "outputs": [ |
| 36 | { |
| 37 | "address": "{trigger.address}", |
| 38 | "amount": 1 |
| 39 | } |
| 40 | ] |
| 41 | } |
| 42 | }, |
| 43 | { |
| 44 | "if": "{exists(trigger.data.next_asset_step)}", |
| 45 | "app": "data", |
| 46 | "payload": { |
| 47 | "asset_step": "{trigger.data.next_asset_step}" |
| 48 | } |
| 49 | }, |
| 50 | { |
| 51 | "if": "{$asset_symbol}", |
| 52 | "init": "{ |
| 53 | $asset = trigger.unit; |
| 54 | }", |
| 55 | "app": "state", |
| 56 | "state": "{ |
| 57 | var['s2a_' || $asset_symbol || '|' || $origin || '|' || $oracle] = $asset; |
| 58 | var['a2s_' || $asset || '|' || $origin || '|' || $oracle] = $asset_symbol; |
| 59 | var['decimals_'|| $asset || '|' || $origin || '|' || $oracle] = $decimals; |
| 60 | }" |
| 61 | } |
| 62 | ] |
| 63 | } |
| 64 | ] |