| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{\r |
| 5 | $nom_AA = 'Getons';\r |
| 6 | |
| 7 | |
| 8 | $_Portal = trigger.address; |
| 9 | if ( $_Portal != trigger.address ) bounce ( 'Portal no reconegut' );\r |
| 10 | \r |
| 11 | |
| 12 | $args = trigger.data;\r |
| 13 | $adr__ = trigger.initial_address;\r |
| 14 | $idgeto = trigger.output[[ asset != base ]].asset;\r |
| 15 | $dades = $args.dades otherwise {};\r |
| 16 | \r |
| 17 | $__dada = $refval => {\r |
| 18 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]\r |
| 19 | };\r |
| 20 | \r |
| 21 | |
| 22 | $proces = $args.proces;\r |
| 23 | $operacio = $args.operacio;\r |
| 24 | $idprop = $args.idprop;\r |
| 25 | $nougeto = $args.nougeto;\r |
| 26 | $ref = $args.ref;\r |
| 27 | $val = $args.val;\r |
| 28 | \r |
| 29 | |
| 30 | $__arg = $arg =>\r |
| 31 | $args[ $arg ] otherwise \r |
| 32 | bounce( "Cal proporcionar el valor de: " || $arg );\r |
| 33 | \r |
| 34 | $refgeto = $__arg( 'ref_geto' );\r |
| 35 | \r |
| 36 | |
| 37 | if ( ! $__dada( $refgeto ) OR $__dada( $refgeto || '_estat' ) != 'operatiu' )\r |
| 38 | bounce( 'Getó inexistent o no operatiu' );\r |
| 39 | \r |
| 40 | |
| 41 | $_AUT_A = $__dada( $refgeto || '_AUT_A' ) otherwise '';\r |
| 42 | $_AUT_B = $__dada( $refgeto || '_AUT_B' ) otherwise '';\r |
| 43 | $_AUT_C = $__dada( $refgeto || '_AUT_C' ) otherwise '';\r |
| 44 | if ( $_AUT_A != $adr__ AND $_AUT_B != $adr__ AND $_AUT_C != $adr__ )\r |
| 45 | bounce ( 'No autoritzada per administrar el getó' );\r |
| 46 | \r |
| 47 | if ( $proces == 'emissio_getons' ) {\r |
| 48 | $dades[ $refgeto || '_aportacio' ] = $args.total_aportat;\r |
| 49 | }\r |
| 50 | \r |
| 51 | if ( $proces == 'esmena_geto' ) {\r |
| 52 | if ( $operacio == 'proposta' ) {\r |
| 53 | $dades[ $idprop ] = timestamp;\r |
| 54 | $dades[ $idprop || '_proposant' ] = $adr__;\r |
| 55 | $dades[ $idprop || '_refgeto' ] = $refgeto;\r |
| 56 | $dades[ $idprop || '_ref' ] = $__arg( '_ref' );\r |
| 57 | $dades[ $idprop || '_val' ] = $__arg( '_val' );\r |
| 58 | }\r |
| 59 | if ( $operacio == 'confirmacio' ) {\r |
| 60 | $refg = $__dada( $idprop || '_refgeto' );\r |
| 61 | $refval = $__dada( $idprop || '_ref' );\r |
| 62 | $dades[ $refg || '_' || $refval ] = $__dada( $idprop || '_val' );\r |
| 63 | }\r |
| 64 | }\r |
| 65 | \r |
| 66 | if ( $proces == 'capacitacio' ) {\r |
| 67 | if ( ! $__dada( $refgeto || '_' || $__arg( 'accio' ) || 'ns_restringides') )\r |
| 68 | bounce( 'Acció no restringible per a aquest getó' );\r |
| 69 | \r |
| 70 | if ( $operacio == 'proposta' ) {\r |
| 71 | $dades[ $idprop ] = timestamp;\r |
| 72 | $dades[ $idprop || '_capacitadora' ] = $adr__;\r |
| 73 | $dades[ $idprop || '_geto' ] = $refgeto;\r |
| 74 | $dades[ $idprop || '_accio' ] = $__arg( 'accio' );\r |
| 75 | $dades[ $idprop || '_capacitada' ] = $__arg( 'adr' );\r |
| 76 | $dades[ $idprop || '_estat' ] = $__arg( 'estat' );\r |
| 77 | }\r |
| 78 | if ( $operacio == 'confirmacio' ) {\r |
| 79 | $get = $__dada( $idprop || '_refgeto' );\r |
| 80 | $acc = $__dada( $idprop || '_accio' );\r |
| 81 | $adr = $__dada( $idprop || '_capacitada' );\r |
| 82 | $ref_capacitacio = 'capacitacio_' || $get || '_' || $acc || '_' || $adr;\r |
| 83 | $dades[ $ref_capacitacio ] = $__dada( $idprop || '_estat' );\r |
| 84 | }\r |
| 85 | }\r |
| 86 | \r |
| 87 | if ( $proces == 'avis' ) {\r |
| 88 | $rebot =\r |
| 89 | $__dada( $refgeto || '_bloqueig_possible' ) ?\r |
| 90 | $__arg( 'rebot' ) :\r |
| 91 | false;\r |
| 92 | \r |
| 93 | if ( $operacio == 'proposta' ) {\r |
| 94 | $dades[ $idprop ] = timestamp;\r |
| 95 | $dades[ $idprop || '_redactora' ] = $adr__;\r |
| 96 | $dades[ $idprop || '_geto' ] = $refgeto;\r |
| 97 | $dades[ $idprop || '_destinataria' ] = $__arg( 'adr' );\r |
| 98 | $dades[ $idprop || '_rebot' ] = $__arg( 'rebot' );\r |
| 99 | $dades[ $idprop || '_text' ] = $__arg( 'text' );\r |
| 100 | }\r |
| 101 | if ( $operacio == 'confirmacio' ) {\r |
| 102 | $get = $__dada( $idprop || '_refgeto' );\r |
| 103 | $adr = $__dada( $idprop || '_destinataria' );\r |
| 104 | $refavis = 'avis_' || $get || '_' || $adr;\r |
| 105 | $dades[ $refavis ] = timestamp;\r |
| 106 | $dades[ $refavis || '_rebot' ] = $__dada( $idprop || '_rebot' );\r |
| 107 | $dades[ $refavis || '_text' ] = $__dada( $idprop || '_text' );\r |
| 108 | }\r |
| 109 | }\r |
| 110 | \r |
| 111 | $registre = {};\r |
| 112 | $registre.dades = $dades;\r |
| 113 | }", |
| 114 | "messages": [ |
| 115 | { |
| 116 | "app": "data", |
| 117 | "payload": "{ $registre }" |
| 118 | }, |
| 119 | { |
| 120 | "app": "payment", |
| 121 | "payload": { |
| 122 | "asset": "base", |
| 123 | "outputs": [ |
| 124 | { |
| 125 | "address": "{ $args._Registre }", |
| 126 | "amount": "{ $__dada( 'Provisio' ) }" |
| 127 | } |
| 128 | ] |
| 129 | } |
| 130 | }, |
| 131 | { |
| 132 | "app": "state", |
| 133 | "state": "{\r |
| 134 | response[ 'Romanent Getons' ] = balance[ base ] || ' bytes';\r |
| 135 | response[ 'proces' ] = $proces;\r |
| 136 | response[ 'operacio' ] = $operacio;\r |
| 137 | }" |
| 138 | } |
| 139 | ] |
| 140 | } |
| 141 | ] |