| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 10000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | $this = { |
| 9 | dust_collector : "B2UMBICLZSBVDHRC7BYM6BBU4AQEXL2F", |
| 10 | }; |
| 11 | }", |
| 12 | "messages": { |
| 13 | "cases": [ |
| 14 | { |
| 15 | "if": "{ !!var["refunded"] or !!var["withdrawn"]}", |
| 16 | "messages": [ |
| 17 | { |
| 18 | "if": "{trigger.initial_address == $this.dust_collector}", |
| 19 | "app": "payment", |
| 20 | "payload": { |
| 21 | "asset": "{"base"}", |
| 22 | "outputs": [ |
| 23 | { |
| 24 | "address": "{$this.dust_collector}", |
| 25 | "amount": "{balance[base]-1000}" |
| 26 | } |
| 27 | ] |
| 28 | } |
| 29 | }, |
| 30 | { |
| 31 | "app": "state", |
| 32 | "state": "{ response['message'] = 'Thank you for this donation!'; }" |
| 33 | } |
| 34 | ] |
| 35 | }, |
| 36 | { |
| 37 | "if": "{ timestamp > json_parse(params.deadline) }", |
| 38 | "messages": [ |
| 39 | { |
| 40 | "app": "payment", |
| 41 | "payload": { |
| 42 | "asset": "{var[trigger.initial_address||"_asset"]}", |
| 43 | "outputs": [ |
| 44 | { |
| 45 | "address": "{trigger.initial_address}", |
| 46 | "amount": "{json_parse(var[trigger.initial_address||"_amount"])}" |
| 47 | } |
| 48 | ] |
| 49 | } |
| 50 | }, |
| 51 | { |
| 52 | "app": "state", |
| 53 | "state": "{ |
| 54 | var["refunded"] = true; |
| 55 | response['message'] = 'Time out, bytes sent back to owner.'; |
| 56 | }" |
| 57 | } |
| 58 | ] |
| 59 | }, |
| 60 | { |
| 61 | "if": "{ trigger.initial_address == params.destination_address }", |
| 62 | "init": "{ |
| 63 | $message = "You have been recognized but "; |
| 64 | if (!trigger.data.secret) bounce ($message||"you have to provide the 'secret' revealed on the other chain"); |
| 65 | if (sha256(trigger.data.secret) != params.hash_of_secret) bounce ($message||"the secret is not good."); |
| 66 | }", |
| 67 | "messages": [ |
| 68 | { |
| 69 | "app": "payment", |
| 70 | "payload": { |
| 71 | "asset": "base", |
| 72 | "outputs": [ |
| 73 | { |
| 74 | "address": "{params.destination_address}", |
| 75 | "amount": "{balance[params.asset_id]-1000}" |
| 76 | } |
| 77 | ] |
| 78 | } |
| 79 | }, |
| 80 | { |
| 81 | "app": "state", |
| 82 | "state": "{ |
| 83 | var["withdrawn"] = true; |
| 84 | response['message'] = 'Transfer successfull! Please donate by sending Gbytes to this address to support developpers'; |
| 85 | }" |
| 86 | } |
| 87 | ] |
| 88 | }, |
| 89 | { |
| 90 | "messages": [ |
| 91 | { |
| 92 | "app": "state", |
| 93 | "state": "{ |
| 94 | $other_asset = trigger.output[[asset!=base]].asset; |
| 95 | $asset = $other_asset != "none" ? $other_asset : "base"; |
| 96 | if (params.asset_id != $asset) |
| 97 | bounce ("Wrong asset, "||params.asset_id||" wanted (not "||$asset||")."); |
| 98 | if (params.amount != 0) |
| 99 | if (trigger.output[[asset=$asset]].amount != params.amount) |
| 100 | bounce ("Wrong amount, "||params.amount||" wanted (not "||trigger.output[[asset=$asset]].amount||")."); |
| 101 | response['message'] = 'Filled with '||trigger.output[[asset=$asset]].amount; |
| 102 | }" |
| 103 | } |
| 104 | ] |
| 105 | } |
| 106 | ] |
| 107 | } |
| 108 | } |
| 109 | ] |