| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "bounce_fees": { |
| 5 | "base": 25000 |
| 6 | }, |
| 7 | "init": "{ |
| 8 | $nom_AA = 'Portal'; |
| 9 | $_AUT_000 = 'XD7FVUM442NPIIMLRIT2FYWJEDQ4ILLJ'; |
| 10 | |
| 11 | $_Registre = trigger.data[ '_Registre' ]; |
| 12 | |
| 13 | |
| 14 | $adr__ = trigger.address; |
| 15 | $args = trigger.data; |
| 16 | $unitat = trigger.output[[ asset != base ]].asset; |
| 17 | $resp_unit = trigger.data.resp_unit; |
| 18 | $qt = trigger.output[[ asset = $unitat ]]; |
| 19 | $dades = {}; |
| 20 | $registre = {}; |
| 21 | |
| 22 | |
| 23 | $admin = $args.admin; |
| 24 | $proces = $args.proces; |
| 25 | $ref = $args.ref; |
| 26 | $val = $args.val; |
| 27 | $idprop = $args.idprop; |
| 28 | $adr = $args.adr; |
| 29 | $estat = $args.estat; |
| 30 | $qt_args = $args.qt; |
| 31 | |
| 32 | |
| 33 | $__dada = $refval => |
| 34 | data_feed[[ oracles = $_Registre, feed_name = $refval, ifnone = false ]]; |
| 35 | |
| 36 | |
| 37 | $__arg = $arg => |
| 38 | $args[ $arg ] otherwise |
| 39 | bounce ( "Cal proporcionar el valor de: " || $arg ); |
| 40 | |
| 41 | |
| 42 | $__ordinal = $rf => { |
| 43 | $ord = $__dada( 'ordinal_' || $rf ); |
| 44 | $ord ? $ord + 1 : 1 |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | $prov = $__dada( 'Provisio' ) otherwise 2000; |
| 49 | $romanent_minim = $__dada( 'Romanent_Minim' ) otherwise 10000; |
| 50 | $__provisio = $rf => { |
| 51 | $romanent = balance[ $rf ][ base ]; |
| 52 | $romanent > $romanent_minim ? |
| 53 | $prov : |
| 54 | $prov * 10 |
| 55 | }; |
| 56 | |
| 57 | |
| 58 | |
| 59 | $actuant_es_AUT_000 = $adr__ == $_AUT_000; |
| 60 | $_AUT_0 = $__dada( '_AUT_0' ) otherwise ''; |
| 61 | $_AUT_A = $__dada( '_AUT_A' ) otherwise ''; |
| 62 | $_AUT_B = $__dada( '_AUT_B' ) otherwise ''; |
| 63 | $_AUT_C = $__dada( '_AUT_C' ) otherwise ''; |
| 64 | $actuant_es_AUT = |
| 65 | ( $actuant_es_AUT_000 AND $_AUT_0 == '' ) |
| 66 | OR $adr__ == $_AUT_0 |
| 67 | OR $adr__ == $_AUT_A |
| 68 | OR $adr__ == $_AUT_B |
| 69 | OR $adr__ == $_AUT_C; |
| 70 | |
| 71 | |
| 72 | |
| 73 | if ( $admin ) { |
| 74 | |
| 75 | if ( ! $actuant_es_AUT ) bounce ( 'No autoritzada' ); |
| 76 | |
| 77 | |
| 78 | $excepcio_inicial = |
| 79 | ( $actuant_es_AUT_000 AND ! $_AUT_0 ) OR |
| 80 | $proces == 'generacio_geto' OR |
| 81 | $proces == 'inscripcio'; |
| 82 | |
| 83 | if ( ! $excepcio_inicial ) { |
| 84 | if ( !! $args.operacio AND $args.operacio == 'confirmacio' ) { |
| 85 | |
| 86 | $temps_idprop = $__dada( $idprop ) |
| 87 | otherwise bounce ( "No hi ha cap proposta amb aquesta ref" ); |
| 88 | |
| 89 | |
| 90 | if ( $__dada( $idprop || '_proposant' ) == $adr__ ) |
| 91 | bounce ( "El procés de confirmació l'ha d'endegar una altra AUT" ); |
| 92 | |
| 93 | |
| 94 | if ( $__dada( 'Lapse' ) > timestamp - $temps_idprop ) |
| 95 | bounce ( "Encara no es pot confirmar la proposta" ); |
| 96 | |
| 97 | |
| 98 | if ( !! $__dada( 'refus_' || $idprop ) ) |
| 99 | bounce ( "La proposta ha estat refusada" ); |
| 100 | |
| 101 | |
| 102 | if ( ! $__dada( 'validacio_' || $idprop )) |
| 103 | bounce ( "La proposta encara no ha estat validada" ); |
| 104 | |
| 105 | $dades[ 'confirmacio_' || $idprop ] = timestamp; |
| 106 | $dades[ 'confirmacio_' || $idprop || '_confirmant' ] = $adr__; |
| 107 | $operacio = 'confirmacio'; |
| 108 | } else { |
| 109 | $ord_prop = $__ordinal( $proces ); |
| 110 | $nova_idprop = 'prop_' || $proces || '_' || $ord_prop; |
| 111 | $dades[ 'ordinal_' || $proces ] = $ord_prop; |
| 112 | $dades[ $nova_idprop ] = timestamp; |
| 113 | $dades[ $nova_idprop || '_proposant' ] = $adr__; |
| 114 | $operacio = 'proposta'; |
| 115 | } |
| 116 | } else { |
| 117 | $ord_prop = $__ordinal( $proces ); |
| 118 | $nova_iddrec = 'drecera_' || $proces || '_' || $ord_prop; |
| 119 | $dades[ 'ordinal_' || $proces ] = $ord_prop; |
| 120 | $dades[ $nova_iddrec ] = timestamp; |
| 121 | $dades[ $nova_iddrec || '_actuant' ] = $adr__; |
| 122 | $operacio = 'drecera'; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | |
| 127 | |
| 128 | $_Accions = $__dada( '_Accions' ); |
| 129 | $_Validadores = $__dada( '_Validadores' ); |
| 130 | $_Convocatories = $__dada( '_Convocatories' ); |
| 131 | $_Pronunciaments = $__dada( '_Pronunciaments' ); |
| 132 | $_Validacio_TEST = $__dada( '_Validacio_TEST' ); |
| 133 | $_Getons = $__dada( '_Getons' ); |
| 134 | $_Definicions = $__dada( '_Definicions' ); |
| 135 | $_Emissions = $__dada( '_Emissions' ); |
| 136 | $id_estels = $__dada( '_Estels' ); |
| 137 | $escala_actual = $__dada( 'escala_actual' ); |
| 138 | $cicle_actual = $__dada( 'cicle_actual' ); |
| 139 | $provisio_registre = $__provisio( $_Registre ); |
| 140 | $nomgeto = $args.nom_geto; |
| 141 | $refgeto = !! $nomgeto ? 'geto_' || $nomgeto : 'estels'; |
| 142 | $estat_geto = $__dada( $refgeto || '_estat' ) otherwise ''; |
| 143 | |
| 144 | |
| 145 | if( $refgeto != 'estels' AND |
| 146 | ( $estat_geto != 'operatiu' AND |
| 147 | $proces != 'definicio_geto' AND |
| 148 | $proces != 'dotacio' AND |
| 149 | $proces != 'inscripcio' |
| 150 | ) ) |
| 151 | bounce ( 'Getó inexistent o no operatiu' ); |
| 152 | }", |
| 153 | "messages": { |
| 154 | "cases": [ |
| 155 | { |
| 156 | "if": "{ $admin AND $proces == 'inicialitzacio' }", |
| 157 | "init": "{ $args[ 'isox_000' ] = $_AUT_000; }", |
| 158 | "messages": [ |
| 159 | { |
| 160 | "app": "data", |
| 161 | "payload": "{ $args }" |
| 162 | }, |
| 163 | { |
| 164 | "app": "payment", |
| 165 | "payload": { |
| 166 | "asset": "base", |
| 167 | "outputs": [ |
| 168 | { |
| 169 | "address": "{ $_Definicions }", |
| 170 | "amount": "{ $__provisio( $_Definicions ) }" |
| 171 | } |
| 172 | ] |
| 173 | } |
| 174 | }, |
| 175 | { |
| 176 | "app": "state", |
| 177 | "state": "{ |
| 178 | response[ 'Procés' ] = $proces; |
| 179 | response[ 'Operació' ] = $operacio; |
| 180 | }" |
| 181 | } |
| 182 | ] |
| 183 | }, |
| 184 | { |
| 185 | "if": "{ $admin AND $proces == 'definicio' }", |
| 186 | "init": "{ |
| 187 | if ( $operacio == 'proposta' ) { |
| 188 | $dades[ $nova_idprop || '_ref' ] = $ref; |
| 189 | $dades[ $nova_idprop || '_val' ] = $val; |
| 190 | } else { |
| 191 | $nova_ref = $__dada( $idprop || '_ref' ) otherwise $ref; |
| 192 | $nou_val = $__dada( $idprop || '_val' ) otherwise $val; |
| 193 | $dades[ $nova_ref ] = $nou_val; |
| 194 | } |
| 195 | |
| 196 | $registre.dades = $dades; |
| 197 | }", |
| 198 | "messages": [ |
| 199 | { |
| 200 | "app": "data", |
| 201 | "payload": "{ $registre }" |
| 202 | }, |
| 203 | { |
| 204 | "app": "payment", |
| 205 | "payload": { |
| 206 | "asset": "base", |
| 207 | "outputs": [ |
| 208 | { |
| 209 | "address": "{ $_Registre }", |
| 210 | "amount": "{ $provisio_registre }" |
| 211 | } |
| 212 | ] |
| 213 | } |
| 214 | }, |
| 215 | { |
| 216 | "app": "state", |
| 217 | "state": "{ |
| 218 | response[ 'Nova ref' ] = $nova_ref otherwise $ref; |
| 219 | response[ 'Nou valor' ] = $nou_val otherwise $val; |
| 220 | response[ 'Proposta' ] = $nova_idprop otherwise $idprop otherwise 'drecera'; |
| 221 | response[ 'Procés' ] = $proces; |
| 222 | response[ 'Operació' ] = $operacio; |
| 223 | }" |
| 224 | } |
| 225 | ] |
| 226 | }, |
| 227 | { |
| 228 | "if": "{ $proces == 'acces_accions' }", |
| 229 | "init": "{ |
| 230 | $ACC = $__arg( 'accio' ); |
| 231 | |
| 232 | $ref_unitat = |
| 233 | $unitat == $id_estels ? |
| 234 | 'estels' : |
| 235 | $__dada( 'refgeto_' || $unitat ); |
| 236 | |
| 237 | $estat_unitat = |
| 238 | $unitat == $id_estels ? |
| 239 | 'operatiu' : |
| 240 | $__dada( $ref_unitat || '_estat' ) == 'operatiu' ? |
| 241 | 'operatiu' : |
| 242 | bounce ( 'Getó inexistent o no operatiu' ); |
| 243 | |
| 244 | |
| 245 | $__activada = ( $adre, $refe ) => |
| 246 | !! $__dada( 'activacio_' || $adre || '_en_' || $refe ) ? |
| 247 | true : |
| 248 | bounce ( 'Adreça no activada per a ' || $refe ); |
| 249 | |
| 250 | |
| 251 | if ( $ACC == 'Activacio') { |
| 252 | if ( $refgeto != 'estels' ) |
| 253 | $activa_x_estels = $__activada( $adr__, 'estels' ); |
| 254 | } else { |
| 255 | $activa_x_estels = $__activada( $adr__, 'estels' ); |
| 256 | if ( $refgeto != 'estels' ) |
| 257 | $activa_x_geto = $__activada( $adr__, $refgeto ); |
| 258 | } |
| 259 | |
| 260 | |
| 261 | $__accRestringida = $ac => { |
| 262 | $refgeto == 'estels' ? |
| 263 | false : |
| 264 | $__dada( $refgeto || '_' || $ac || 'ns_restringides' ) |
| 265 | }; |
| 266 | |
| 267 | |
| 268 | $__capacitada = ( $ac, $ad ) => { |
| 269 | $capacitacio = |
| 270 | $__dada( 'capacitacio_' || $refgeto || '_' || $ac || '_' || $ad ) otherwise ''; |
| 271 | $__accRestringida( $ac ) AND $capacitacio != 'capacitada' ? |
| 272 | bounce ( 'Acció restringida i adreça no capacitada' ) : |
| 273 | true |
| 274 | }; |
| 275 | |
| 276 | $adr__capacitada = $__capacitada( $ACC, $adr__ ); |
| 277 | |
| 278 | |
| 279 | if ( $ACC == 'Contribucio' AND $refgeto != 'estels' ) |
| 280 | bounce ( 'Les contribucions només es poden fer en estels' ); |
| 281 | |
| 282 | |
| 283 | if ( $ACC == 'Transfer' ) { |
| 284 | $receptora = $__arg( 'receptora' ); |
| 285 | $receptora_activada = |
| 286 | $__activada( $receptora, 'estels' ) |
| 287 | AND $__activada( $receptora, $refgeto ); |
| 288 | $receptora_capacitada = $__capacitada( 'recepcio', $receptora ); |
| 289 | $ref_subscripcio = 'subscripcio_' || $receptora || '_en_' || $refgeto; |
| 290 | $receptora_subscrita = !! $__dada( $ref_subscripcio ); |
| 291 | $ref_renovacio = 'renovacio_' || $receptora || '_en_' || $refgeto; |
| 292 | $cicle_renovacio = $__dada( $ref_renovacio || '_cicle' ); |
| 293 | $receptora_renovada = |
| 294 | !! $cicle_renovacio |
| 295 | AND $cicle_renovacio == $cicle_actual; |
| 296 | if ( $receptora_subscrita AND $receptora_renovada ) { |
| 297 | $percent_derivacio = $__dada( $ref_subscripcio || '_derivacio' ); |
| 298 | $args.qt_derivacio = floor( $qt * $percent_derivacio / 100 ); |
| 299 | $qt_accio = $qt - $args.qt_derivacio; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | |
| 304 | $args.dades = $dades; |
| 305 | $args._Registre = $_Registre; |
| 306 | $args.refgeto = $refgeto; |
| 307 | $args.qt_accio = $qt_accio otherwise $qt; |
| 308 | }", |
| 309 | "messages": [ |
| 310 | { |
| 311 | "app": "data", |
| 312 | "payload": "{ $args }" |
| 313 | }, |
| 314 | { |
| 315 | "app": "payment", |
| 316 | "payload": { |
| 317 | "asset": "base", |
| 318 | "outputs": [ |
| 319 | { |
| 320 | "address": "{ $_Accions }", |
| 321 | "amount": "{ $__provisio( $_Accions ) }" |
| 322 | } |
| 323 | ] |
| 324 | } |
| 325 | }, |
| 326 | { |
| 327 | "if": "{ $ACC == 'Transfer' }", |
| 328 | "app": "payment", |
| 329 | "payload": { |
| 330 | "asset": "{ $unitat }", |
| 331 | "outputs": [ |
| 332 | { |
| 333 | "address": "{ $receptora }", |
| 334 | "amount": "{ $args.qt_accio }" |
| 335 | } |
| 336 | ] |
| 337 | } |
| 338 | }, |
| 339 | { |
| 340 | "app": "state", |
| 341 | "state": "{ |
| 342 | if ( !! $receptora ) |
| 343 | response[ 'Transfer a' ] = |
| 344 | $receptora || " de " || $args.qt_accio || " " || $refgeto; |
| 345 | response[ 'Procés' ] = $proces; |
| 346 | response[ 'Romanent en bytes' ] = balance[ base ] || ' bytes'; |
| 347 | response[ 'Romanent en estels' ] = balance[ $id_estels ] || ' estels'; |
| 348 | }" |
| 349 | } |
| 350 | ] |
| 351 | }, |
| 352 | { |
| 353 | "if": "{ |
| 354 | $proces == 'assignacio' OR |
| 355 | $proces == 'conversio' OR |
| 356 | $proces == 'retribucio' |
| 357 | }", |
| 358 | "init": "{ |
| 359 | if ( $admin AND $proces == 'assignacio' ) { |
| 360 | |
| 361 | $ref_assignacio = 'assignacio_' || $args.requeriment; |
| 362 | $destinataria = $args.destinataria; |
| 363 | $qt_assignacio = $__dada( $idprop || '_qt' ) otherwise $qt_args; |
| 364 | |
| 365 | if ( $operacio == 'proposta' ) { |
| 366 | $dades[ $nova_idprop || '_destinataria' ] = $destinataria; |
| 367 | $dades[ $nova_idprop || '_resolucio' ] = $args.resolucio; |
| 368 | $dades[ $nova_idprop || '_requeriment' ] = $args.requeriment; |
| 369 | $dades[ $nova_idprop || '_qt' ] = $qt_args; |
| 370 | $dades[ $nova_idprop || '_unitat' ] = $args.unitat; |
| 371 | } else { |
| 372 | $id_unitat = $__dada( $idprop || '_unitat' ) otherwise $args.unitat; |
| 373 | $dades[ $ref_assignacio || '_unitat' ] = $id_unitat; |
| 374 | $dades[ $ref_assignacio || '_destinataria' ] = |
| 375 | $__dada( $idprop || '_destinataria' ) otherwise $destinataria; |
| 376 | $dades[ $ref_assignacio || '_resolucio' ] = |
| 377 | $__dada( $idprop || '_resolucio' ) otherwise $args.resolucio; |
| 378 | $dades[ $ref_assignacio || '_requeriment' ] = |
| 379 | $__dada( $idprop || '_requeriment' ) otherwise $args.requeriment; |
| 380 | $dades[ $ref_assignacio || '_qt' ] = $qt_assignacio; |
| 381 | |
| 382 | $total_assignacions = $__dada( 'total_assignacions' ) otherwise 0; |
| 383 | $dades[ 'total_assignacions' ] = $total_assignacions + $qt_assignacio; |
| 384 | } |
| 385 | $payment = [ $id_unitat, $destinataria, $qt_args ]; |
| 386 | $realitzable = $operacio != 'proposta'; |
| 387 | } |
| 388 | |
| 389 | if ( $proces == 'conversio' ) { |
| 390 | $qt_dipositada = $__dada( $__arg( 'ref' )) |
| 391 | otherwise bounce ( 'Dipòsit inexistent' ); |
| 392 | $qt_conversio = $__dada( $ref || '_qt_conversio' ); |
| 393 | $geto_diposit = $__dada( $ref || '_geto_diposit' ); |
| 394 | $cicle_conversio = $__dada( $ref || '_cicle_conversio' ); |
| 395 | $cicle_renovat = $__dada( 'renovacio_' || $adr__ || '_en_' || $geto_diposit || '_cicle' ); |
| 396 | $id_unitat = $geto_diposit == $id_estels ? "base" : $id_estels; |
| 397 | $ref_conversio = 'conversio_' || $ref; |
| 398 | |
| 399 | if ( $adr__ != $__dada( $ref || '_dipositant' )) |
| 400 | bounce ( "L'adreça receptora ha de ser la dipositant" ); |
| 401 | |
| 402 | if ( !! $__dada( $ref_conversio || '_data' )) |
| 403 | bounce ( 'Aquest dipòsit ja ha estat convertit' ); |
| 404 | |
| 405 | if ( $cicle_conversio > $cicle_actual ) |
| 406 | bounce ( "Encara no és l'hora" ); |
| 407 | |
| 408 | if ( $cicle_renovat < $cicle_actual ) |
| 409 | bounce ( "No renovada en " || $geto_diposit || " per al cicle actual: " || $cicle_actual ); |
| 410 | |
| 411 | $dades[ $ref_conversio || '_data' ] = timestamp; |
| 412 | $dades[ $ref_conversio || '_qt' ] = $qt_conversio; |
| 413 | $dades[ $ref_conversio || '_unitat' ] = $id_unitat; |
| 414 | $dades[ $ref_conversio || '_destinataria' ] = $adr__; |
| 415 | |
| 416 | $ref_total_conversions = 'total_conversions_de_' || $geto_diposit; |
| 417 | $total_conversions = $__dada( $ref_total_conversions ) otherwise 0; |
| 418 | $dades[ $ref_total_conversions ] = $total_conversions + $qt_dipositada; |
| 419 | |
| 420 | $ref_total_taxes = 'total_taxes_de_' || $geto_diposit; |
| 421 | $total_taxes = $__dada( $ref_total_taxes ) otherwise 0; |
| 422 | $dades[ $ref_total_taxes ] = $total_taxes + $qt_dipositada - $qt_conversio; |
| 423 | |
| 424 | $payment = [ $id_unitat, $adr__, $qt_conversio ]; |
| 425 | $realitzable = true; |
| 426 | } |
| 427 | |
| 428 | if ( $proces == 'retribucio' ) { |
| 429 | if ( $ref == 'aportacio_activacio' ) { |
| 430 | $import = $__dada( 'activacio_' || $adr__ || '_en_estels_qt' ) |
| 431 | otherwise bounce ( 'Activació inexistent' ); |
| 432 | $escala = $__dada( 'activacio_' || $adr__ || '_en_estels_escala' ); |
| 433 | $interval = $__dada( 'activacio_' || $adr__ || '_en_estels_interval' ); |
| 434 | $ref_retribucio = 'retribucio_activacio_' || $adr__ || '_escala_' || $escala_actual; |
| 435 | |
| 436 | } else { |
| 437 | $import = $__dada( $ref ) otherwise bounce ( 'Contribució inexistent' ); |
| 438 | $escala = $__dada( $ref || '_escala' ); |
| 439 | $interval = $__dada( $ref || '_interval' ); |
| 440 | |
| 441 | if ( $adr__ != $__dada( $ref || '_contribuidora' )) |
| 442 | bounce ( "Només l'adreça contribuïdora pot rebre la retribució" ); |
| 443 | |
| 444 | $ref_retribucio = 'retribucio_' || $ref || '_escala_' || $escala_actual; |
| 445 | } |
| 446 | |
| 447 | |
| 448 | $ref_retribucio = 'retribucio_' || $ref || '_escala_' || $escala_actual; |
| 449 | if ( !! $__dada( $ref_retribucio || '_data' ) ) |
| 450 | bounce ( "Ja ha estat retribuïda per a l'escala actual" ); |
| 451 | |
| 452 | |
| 453 | if ( $escala_actual == $escala ) |
| 454 | bounce ( "Cal que es produeixi un salt d'escala" ); |
| 455 | |
| 456 | |
| 457 | |
| 458 | $diferencia_intervals = $__dada( 'interval_escala' ) - $interval; |
| 459 | if ( $diferencia_intervals < 0 ) |
| 460 | bounce ( "Encara no és l'hora. Falten: " || $diferencia_intervals || ' segons' ); |
| 461 | |
| 462 | |
| 463 | $qt_retribucio = $import * ( $escala_actual - $escala ); |
| 464 | |
| 465 | |
| 466 | $dades[ $ref_retribucio || '_data' ] = timestamp; |
| 467 | $dades[ $ref_retribucio || '_qt' ] = $qt_retribucio; |
| 468 | $dades[ $ref_retribucio || '_destinataria' ] = $adr__; |
| 469 | |
| 470 | $total_retribucions = $__dada( 'total_retribucions' ) otherwise 0; |
| 471 | $dades[ 'total_retribucions' ] = $total_retribucions + $qt_retribucio; |
| 472 | |
| 473 | $payment = [ $id_estels, $adr__, $qt_retribucio ]; |
| 474 | $realitzable = true; |
| 475 | } |
| 476 | |
| 477 | $registre.dades = $dades; |
| 478 | }", |
| 479 | "messages": [ |
| 480 | { |
| 481 | "if": "{ $realitzable }", |
| 482 | "app": "payment", |
| 483 | "payload": { |
| 484 | "asset": "{ $payment[0] }", |
| 485 | "outputs": [ |
| 486 | { |
| 487 | "address": "{ $payment[1] }", |
| 488 | "amount": "{ $payment[2] }" |
| 489 | } |
| 490 | ] |
| 491 | } |
| 492 | }, |
| 493 | { |
| 494 | "app": "data", |
| 495 | "payload": "{ $registre }" |
| 496 | }, |
| 497 | { |
| 498 | "app": "payment", |
| 499 | "payload": { |
| 500 | "asset": "base", |
| 501 | "outputs": [ |
| 502 | { |
| 503 | "address": "{ $_Registre }", |
| 504 | "amount": "{ $provisio_registre }" |
| 505 | } |
| 506 | ] |
| 507 | } |
| 508 | }, |
| 509 | { |
| 510 | "app": "state", |
| 511 | "state": "{ |
| 512 | if ( $proces == 'assignacio' ) { |
| 513 | response[ 'Proposta' ] = |
| 514 | $nova_idprop otherwise $ref otherwise 'drecera'; |
| 515 | response[ 'Quantitat' ] = $qt_args; |
| 516 | response[ 'Operació' ] = $operacio; |
| 517 | } |
| 518 | if ( $proces == 'retribucio' ) { |
| 519 | response[ 'Escala Actual' ] = $escala_actual; |
| 520 | } |
| 521 | response[ 'Destinataria' ] = $destinataria otherwise $adr__; |
| 522 | response[ 'Unitat' ] = $id_unitat otherwise $payment[0]; |
| 523 | response[ 'Ref procés' ] = |
| 524 | $ref_assignacio otherwise $ref_conversio otherwise $ref_retribucio; |
| 525 | response[ 'Procés' ] = $proces; |
| 526 | }" |
| 527 | } |
| 528 | ] |
| 529 | }, |
| 530 | { |
| 531 | "if": "{ |
| 532 | ( $admin AND $proces == 'estat_isox' ) OR |
| 533 | $proces == 'nou_isox' OR |
| 534 | $proces == 'nova_delegacio' OR |
| 535 | $proces == 'final_delegacio' |
| 536 | }", |
| 537 | "messages": [ |
| 538 | { |
| 539 | "app": "data", |
| 540 | "payload": "{ $args }" |
| 541 | }, |
| 542 | { |
| 543 | "app": "payment", |
| 544 | "payload": { |
| 545 | "asset": "base", |
| 546 | "outputs": [ |
| 547 | { |
| 548 | "address": "{ $_Validadores }", |
| 549 | "amount": "{ $__provisio( $_Validadores ) }" |
| 550 | } |
| 551 | ] |
| 552 | } |
| 553 | } |
| 554 | ] |
| 555 | }, |
| 556 | { |
| 557 | "if": "{ |
| 558 | ( $proces == 'validacio_directa_TEST' AND $actuant_es_AUT ) |
| 559 | OR ( $admin AND $proces == 'convocatoria' ) |
| 560 | OR $proces == 'pronunciament' |
| 561 | }", |
| 562 | "init": "{ |
| 563 | $args._Registre = $_Registre; |
| 564 | if ( $proces == 'pronunciament' ) $adr_aa = $_Pronunciaments; |
| 565 | if ( $proces == 'convocatoria' ) $adr_aa = $_Convocatories; |
| 566 | if ( $proces == 'validacio_directa_TEST' ) $adr_aa = $_Validacio_TEST; |
| 567 | |
| 568 | }", |
| 569 | "messages": [ |
| 570 | { |
| 571 | "app": "data", |
| 572 | "payload": "{ $args }" |
| 573 | }, |
| 574 | { |
| 575 | "app": "payment", |
| 576 | "payload": { |
| 577 | "asset": "base", |
| 578 | "outputs": [ |
| 579 | { |
| 580 | "address": "{ $adr_aa }", |
| 581 | "amount": "{ $__provisio( $adr_aa ) }" |
| 582 | } |
| 583 | ] |
| 584 | } |
| 585 | }, |
| 586 | { |
| 587 | "if": "{ $proces == 'convocatoria' }", |
| 588 | "app": "payment", |
| 589 | "payload": { |
| 590 | "asset": "{ $id_estels }", |
| 591 | "outputs": [ |
| 592 | { |
| 593 | "address": "{ $_Convocatories }", |
| 594 | "amount": "{ 20 }" |
| 595 | } |
| 596 | ] |
| 597 | } |
| 598 | } |
| 599 | ] |
| 600 | }, |
| 601 | { |
| 602 | "if": "{ $admin AND $args.admin_vincles }", |
| 603 | "init": "{ |
| 604 | $tipus_vincle = $__dada( $idprop || '_tipus' ) otherwise $__arg( 'tipus' ); |
| 605 | $_vincle = $__dada( $idprop || '_adr' ) otherwise $__arg( 'adr' ); |
| 606 | $nom_vincle = $__dada( $idprop || '_nom' ) otherwise $__arg( 'nom' ); |
| 607 | $ref_vincle = $tipus_vincle || '_' || $_vincle; |
| 608 | $registrat = !! $__dada( $ref_vincle ); |
| 609 | |
| 610 | if ( $proces == 'nou_vincle' ) { |
| 611 | |
| 612 | if ( $registrat ) |
| 613 | bounce ( "Ja n'hi ha un amb aquesta adreça" ); |
| 614 | |
| 615 | |
| 616 | $nom_registrat = $__dada( $tipus_vincle || '_' || $nom_vincle ); |
| 617 | if ( !! $nom_registrat AND $nom_registrat != '---' ) |
| 618 | bounce ( "Ja n'hi ha un amb aquest nom" ); |
| 619 | |
| 620 | |
| 621 | if ( $operacio == 'proposta' ) { |
| 622 | $dades[ $nova_idprop || '_adr' ] = $adr; |
| 623 | $dades[ $nova_idprop || '_nom' ] = $args.nom; |
| 624 | } else { |
| 625 | $ord_vincle = $__ordinal( $tipus_vincle ); |
| 626 | $dades[ $ref_vincle || '_ordinal' ] = $ord_vincle; |
| 627 | $dades[ $ref_vincle || '_adr' ] = $_vincle; |
| 628 | $dades[ $ref_vincle || '_nom' ] = $nom_vincle; |
| 629 | $dades[ $ref_vincle || '_estat' ] = 'operatiu'; |
| 630 | $dades[ $tipus_vincle || '_' || $nom_vincle ] = $ref_vincle; |
| 631 | $dades[ $tipus_vincle || '_' || $ord_vincle ] = $ref_vincle; |
| 632 | $dades[ 'ordinal_' || $tipus_vincle ] = $ord_vincle; |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | if ( $proces == 'estat_vincle' ) { |
| 637 | |
| 638 | if ( ! $registrat ) |
| 639 | bounce ( "No n'hi ha cap amb aquesta adreça" ); |
| 640 | |
| 641 | |
| 642 | if ( $operacio == 'proposta' ) { |
| 643 | $dades[ $nova_idprop || '_adr' ] = $adr; |
| 644 | $dades[ $nova_idprop || '_estat' ] = $estat; |
| 645 | } else { |
| 646 | $nou_estat = $__dada( $idprop || '_estat' ) otherwise $estat; |
| 647 | $dades[ $ref_vincle || '_estat' ] = $nou_estat; |
| 648 | $dades[ $tipus_vincle || '_' || $nom_vincle ] = |
| 649 | $nou_estat == 'opereatiu' ? $ref_vincle : '---'; |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | $registre.dades = $dades; |
| 654 | }", |
| 655 | "messages": [ |
| 656 | { |
| 657 | "app": "data", |
| 658 | "payload": "{ $registre }" |
| 659 | }, |
| 660 | { |
| 661 | "app": "payment", |
| 662 | "payload": { |
| 663 | "asset": "base", |
| 664 | "outputs": [ |
| 665 | { |
| 666 | "address": "{ $_Registre }", |
| 667 | "amount": "{ $provisio_registre }" |
| 668 | } |
| 669 | ] |
| 670 | } |
| 671 | }, |
| 672 | { |
| 673 | "app": "state", |
| 674 | "state": "{ |
| 675 | if ( !! $nou_estat ) |
| 676 | response[ 'Nou estat ' || $ref_vincle ] = $nou_estat; |
| 677 | response[ 'Proposta' ] = $nova_idprop otherwise $ref otherwise 'drecera'; |
| 678 | response[ 'Procés' ] = $proces; |
| 679 | response[ 'Operació' ] = $operacio; |
| 680 | }" |
| 681 | } |
| 682 | ] |
| 683 | }, |
| 684 | { |
| 685 | "if": "{ $admin AND $proces == 'definicio_geto' }", |
| 686 | "init": "{ |
| 687 | |
| 688 | if ( $estat_geto == 'pendent_dotacio' ) |
| 689 | bounce( 'Aquest getó consta com a pendent de dotació' ); |
| 690 | |
| 691 | |
| 692 | if ( $estat_geto == 'pendent_inscripcio' ) |
| 693 | bounce( "Aquest getó consta com a pendent d'inscripció" ); |
| 694 | |
| 695 | |
| 696 | if ( $estat_geto == 'operatiu' ) |
| 697 | bounce( 'Aquest getó consta com a operatiu' ); |
| 698 | |
| 699 | $topall = $args.topall otherwise 1e9; |
| 700 | $args.operacio = $operacio; |
| 701 | $args.topall = $topall; |
| 702 | }", |
| 703 | "messages": [ |
| 704 | { |
| 705 | "app": "asset", |
| 706 | "payload": { |
| 707 | "cap": "{ $topall }", |
| 708 | "is_private": false, |
| 709 | "is_transferrable": true, |
| 710 | "auto_destroy": false, |
| 711 | "fixed_denominations": false, |
| 712 | "issued_by_definer_only": true, |
| 713 | "cosigned_by_definer": false, |
| 714 | "spender_attested": false |
| 715 | } |
| 716 | }, |
| 717 | { |
| 718 | "app": "data", |
| 719 | "payload": "{ $args }" |
| 720 | }, |
| 721 | { |
| 722 | "app": "payment", |
| 723 | "payload": { |
| 724 | "asset": "base", |
| 725 | "outputs": [ |
| 726 | { |
| 727 | "address": "{ $_Definicions }", |
| 728 | "amount": "{ $__provisio( $_Definicions ) }" |
| 729 | } |
| 730 | ] |
| 731 | } |
| 732 | }, |
| 733 | { |
| 734 | "app": "state", |
| 735 | "state": "{ |
| 736 | $idgeto = response_unit; |
| 737 | var[ $idgeto ] = trigger.address; |
| 738 | var[ $refgeto || '_pendent'] = $idgeto; |
| 739 | response[ 'Adreça definidora' ] = trigger.address; |
| 740 | response[ 'Id ' || $refgeto ] = $idgeto; |
| 741 | response[ 'Topall' ] = $topall; |
| 742 | response[ 'Operació' ] = $operacio; |
| 743 | }" |
| 744 | } |
| 745 | ] |
| 746 | }, |
| 747 | { |
| 748 | "if": "{ $proces == 'dotacio' }", |
| 749 | "init": "{ |
| 750 | |
| 751 | if ( ! $__dada( $refgeto || '__confirmant' ) ) |
| 752 | bounce( 'Getó desconegut' ); |
| 753 | |
| 754 | |
| 755 | if ( $estat_geto != 'pendent_dotacio' ) |
| 756 | bounce( 'Aquest getó no consta com a pendent de dotació' ); |
| 757 | |
| 758 | $idgeto = var[ $refgeto || '_pendent']; |
| 759 | |
| 760 | |
| 761 | if ( var[ $idgeto ] != $adr__ ) |
| 762 | bounce( "La dotació l'ha de fer l'adreça definidora del getó" ); |
| 763 | |
| 764 | $topall = $__dada( $refgeto || '_topall' ); |
| 765 | |
| 766 | $dades[ $refgeto || '_estat' ] = 'pendent_inscripcio'; |
| 767 | $registre.dades = $dades; |
| 768 | }", |
| 769 | "messages": [ |
| 770 | { |
| 771 | "app": "payment", |
| 772 | "payload": { |
| 773 | "asset": "{ $idgeto }", |
| 774 | "outputs": [ |
| 775 | { |
| 776 | "address": "{ $_Emissions }", |
| 777 | "amount": "{ $topall }" |
| 778 | } |
| 779 | ] |
| 780 | } |
| 781 | }, |
| 782 | { |
| 783 | "app": "data", |
| 784 | "payload": "{ $registre }" |
| 785 | }, |
| 786 | { |
| 787 | "app": "payment", |
| 788 | "payload": { |
| 789 | "asset": "base", |
| 790 | "outputs": [ |
| 791 | { |
| 792 | "address": "{ $_Registre }", |
| 793 | "amount": "{ $__dada( 'Provisio' ) }" |
| 794 | } |
| 795 | ] |
| 796 | } |
| 797 | }, |
| 798 | { |
| 799 | "app": "state", |
| 800 | "state": "{ |
| 801 | var[ $refgeto || '_pendent'] = false; |
| 802 | response[ 'Id ' || $refgeto ] = $idgeto; |
| 803 | }" |
| 804 | } |
| 805 | ] |
| 806 | }, |
| 807 | { |
| 808 | "if": "{ $admin AND $proces == 'inscripcio' }", |
| 809 | "init": "{ |
| 810 | |
| 811 | if ( $estat_geto != 'pendent_inscripcio' ) |
| 812 | bounce( "Aquest getó no consta com a pendent d'inscrpció" ); |
| 813 | |
| 814 | if ( $operacio == 'proposta' ) |
| 815 | $dades[ $nova_idprop || '_estat' ] = 'operatiu'; |
| 816 | else |
| 817 | $dades[ $refgeto || '_estat' ] = 'operatiu'; |
| 818 | |
| 819 | $registre.dades = $dades; |
| 820 | }", |
| 821 | "messages": [ |
| 822 | { |
| 823 | "app": "data", |
| 824 | "payload": "{ $registre }" |
| 825 | }, |
| 826 | { |
| 827 | "app": "payment", |
| 828 | "payload": { |
| 829 | "asset": "base", |
| 830 | "outputs": [ |
| 831 | { |
| 832 | "address": "{ $_Registre }", |
| 833 | "amount": "{ $__dada( 'Provisio' ) }" |
| 834 | } |
| 835 | ] |
| 836 | } |
| 837 | }, |
| 838 | { |
| 839 | "app": "state", |
| 840 | "state": "{ |
| 841 | var[ $refgeto || '_pendent'] = false; |
| 842 | response[ 'Nou estat ' || $refgeto ] = 'operatiu'; |
| 843 | response[ 'Procés' ] = $proces; |
| 844 | response[ 'Operació' ] = $operacio; |
| 845 | }" |
| 846 | } |
| 847 | ] |
| 848 | }, |
| 849 | { |
| 850 | "if": "{ $admin AND $proces == 'estat_geto' }", |
| 851 | "init": "{ |
| 852 | |
| 853 | if ( ! $__dada( $refgeto || '_id' )) |
| 854 | bounce ( 'Getó inexistent' ); |
| 855 | |
| 856 | |
| 857 | if ( $operacio == 'proposta' ) { |
| 858 | $dades[ $nova_idprop || '_nom' ] = $args.nom; |
| 859 | $dades[ $nova_idprop || '_estat' ] = $estat; |
| 860 | } else { |
| 861 | $nou_estat = $__dada( $idprop || '_estat' ) otherwise $estat; |
| 862 | $dades[ $refgeto || '_estat' ] = $nou_estat; |
| 863 | } |
| 864 | |
| 865 | $registre.dades = $dades; |
| 866 | }", |
| 867 | "messages": [ |
| 868 | { |
| 869 | "app": "data", |
| 870 | "payload": "{ $registre }" |
| 871 | }, |
| 872 | { |
| 873 | "app": "payment", |
| 874 | "payload": { |
| 875 | "asset": "base", |
| 876 | "outputs": [ |
| 877 | { |
| 878 | "address": "{ $_Registre }", |
| 879 | "amount": "{ $provisio_registre }" |
| 880 | } |
| 881 | ] |
| 882 | } |
| 883 | }, |
| 884 | { |
| 885 | "app": "state", |
| 886 | "state": "{ |
| 887 | response[ 'Nou estat' || $refgeto ] = $nou_estat otherwise $estat; |
| 888 | response[ 'Proposta' ] = $nova_idprop otherwise $ref otherwise 'drecera'; |
| 889 | response[ 'Procés' ] = $proces; |
| 890 | response[ 'Operació' ] = $operacio; |
| 891 | }" |
| 892 | } |
| 893 | ] |
| 894 | }, |
| 895 | { |
| 896 | "if": "{ $admin AND $proces == 'emissio' }", |
| 897 | "init": "{ |
| 898 | |
| 899 | if ( $estat_geto != 'operatiu' ) |
| 900 | bounce( 'No hi consta cap getó operatiu amb aquesta adreça' ); |
| 901 | |
| 902 | $args.ordinal = $__ordinal( 'emissio' ); |
| 903 | $args.id_estels = $id_estels; |
| 904 | $args._Registre = $_Registre; |
| 905 | }", |
| 906 | "messages": [ |
| 907 | { |
| 908 | "app": "data", |
| 909 | "payload": "{ $args }" |
| 910 | }, |
| 911 | { |
| 912 | "app": "payment", |
| 913 | "payload": { |
| 914 | "asset": "base", |
| 915 | "outputs": [ |
| 916 | { |
| 917 | "address": "{ $_Emissions }", |
| 918 | "amount": "{ $__provisio( $_Emissions ) }" |
| 919 | } |
| 920 | ] |
| 921 | } |
| 922 | }, |
| 923 | { |
| 924 | "app": "state", |
| 925 | "state": "{ |
| 926 | response[ 'Procés' ] = $proces; |
| 927 | response[ 'Operació' ] = $operacio; |
| 928 | }" |
| 929 | } |
| 930 | ] |
| 931 | }, |
| 932 | { |
| 933 | "if": "{ $admin AND $args.admin_geto }", |
| 934 | "init": "{ |
| 935 | $args.operacio = $operacio; |
| 936 | $args.idprop = $nova_idprop; |
| 937 | }", |
| 938 | "messages": [ |
| 939 | { |
| 940 | "app": "data", |
| 941 | "payload": "{ $args }" |
| 942 | }, |
| 943 | { |
| 944 | "app": "payment", |
| 945 | "payload": { |
| 946 | "asset": "base", |
| 947 | "outputs": [ |
| 948 | { |
| 949 | "address": "{ $_Getons }", |
| 950 | "amount": "{ $__provisio( $_Getons ) }" |
| 951 | } |
| 952 | ] |
| 953 | } |
| 954 | } |
| 955 | ] |
| 956 | } |
| 957 | ] |
| 958 | } |
| 959 | } |
| 960 | ] |