| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Portal'; |
| 6 | $versio = '0.1.2'; |
| 7 | |
| 8 | $_AUT_000 = 'C4KIJSUWVM7BGWTLXKX3K4PNRXV7OY4W'; |
| 9 | |
| 10 | |
| 11 | $adr__ = trigger.address; |
| 12 | $args = trigger.data; |
| 13 | $_unitat = trigger.output[[ asset != base ]].asset; |
| 14 | $qt = trigger.output[[ asset = $_unitat ]]; |
| 15 | |
| 16 | $generics = var[ 'generics' ] otherwise {}; |
| 17 | $ordinals = var[ 'ordinals' ] otherwise {}; |
| 18 | $refs_getons = var[ 'refs_getons' ] otherwise {}; |
| 19 | $ids_getons = var[ 'ids_getons' ] otherwise {}; |
| 20 | |
| 21 | $_estels = $generics._Estels; |
| 22 | $dades_accions = |
| 23 | $generics._Accions ? |
| 24 | var[ $generics._Accions ]: |
| 25 | {}; |
| 26 | |
| 27 | $escala_actual = $dades_accions.escala_actual; |
| 28 | |
| 29 | |
| 30 | |
| 31 | $admin = $args.admin; |
| 32 | $proces = $args.proces; |
| 33 | $ref = $args.ref; |
| 34 | $idprop = $args.idprop; |
| 35 | |
| 36 | |
| 37 | |
| 38 | $_actuant_es_AUT_000 = $adr__ == $_AUT_000; |
| 39 | |
| 40 | $_actuant_es_AUT = |
| 41 | ( $generics._AUT_A AND $generics._AUT_A == $adr__ ) |
| 42 | OR ( $generics._AUT_B AND $generics._AUT_B == $adr__ ) |
| 43 | OR ( $generics._AUT_C AND $generics._AUT_C == $adr__ ) |
| 44 | OR ( $generics._AUT_0 AND $adr__ == $generics._AUT_0 ) |
| 45 | OR ( $_actuant_es_AUT_000 AND ! is_valid_address( $generics._AUT_0 ) ); |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | $__arg = $arg => |
| 51 | $args[ $arg ] otherwise |
| 52 | bounce( "Cal proporcionar el valor de: " || $arg ); |
| 53 | |
| 54 | $__dada = $refval => { |
| 55 | data_feed[[ oracles = var[ 'portals' ], feed_name = $refval ]] |
| 56 | |
| 57 | }; |
| 58 | |
| 59 | $__ordinal = $rf => $ordinals[ $rf ] ? $ordinals[ $rf ] + 1 : 1; |
| 60 | |
| 61 | |
| 62 | |
| 63 | if ( $admin ) { |
| 64 | |
| 65 | if ( $args.admin_geto ) { |
| 66 | |
| 67 | $ref_geto = $__arg( 'ref_geto' ); |
| 68 | |
| 69 | |
| 70 | if ( ! $refs_getons[ $ref_geto ] ) |
| 71 | { bounce( 'Getó inexistent' ); } |
| 72 | |
| 73 | |
| 74 | $_actuant_es_AUT_geto = |
| 75 | $_actuant_es_AUT AND ! $__dada( $ref_geto || '_AUT_0' ) |
| 76 | OR $adr__ == $__dada( $ref_geto || '_AUT_0' ) |
| 77 | OR $adr__ == $__dada( $ref_geto || '_AUT_A' ) |
| 78 | OR $adr__ == $__dada( $ref_geto || '_AUT_B' ) |
| 79 | OR $adr__ == $__dada( $ref_geto || '_AUT_C' ); |
| 80 | |
| 81 | if ( ! $_actuant_es_AUT_geto ) |
| 82 | { bounce( 'No autoritzada per administrar el getó' ); } |
| 83 | |
| 84 | } else { |
| 85 | |
| 86 | if ( ! $_actuant_es_AUT ) |
| 87 | { bounce( 'No autoritzada' ); } |
| 88 | |
| 89 | |
| 90 | if ( ( $__arg( 'ref' ) ) == 'multiple' AND ! $_actuant_es_AUT_000 ) |
| 91 | { bounce( 'No autoritzada per a esmena múltiple' ); } |
| 92 | } |
| 93 | |
| 94 | |
| 95 | $validacio_requerida = |
| 96 | |
| 97 | ! $_actuant_es_AUT_000 OR ( $_actuant_es_AUT_000 AND $generics._AUT_0 ) |
| 98 | |
| 99 | AND $proces != 'copia_llistat_portals' |
| 100 | AND $proces != 'decisio_validacio' |
| 101 | AND $proces != 'generacio_getons'; |
| 102 | |
| 103 | if ( $validacio_requerida ) { |
| 104 | |
| 105 | if ( $args.operacio AND $args.operacio == 'confirmacio' ) { |
| 106 | |
| 107 | if ( ! $__dada( $idprop ) ) |
| 108 | { bounce( "No hi ha cap proposta amb aquesta ref" ); } |
| 109 | |
| 110 | |
| 111 | if ( $__dada( $idprop || '_proposant' ) == $adr__ ) |
| 112 | { bounce( "El procés de confirmació l'ha d'endegar una altra AUT" ); } |
| 113 | |
| 114 | |
| 115 | if ( $generics.Lapse > timestamp - $__dada( $idprop || '_temps' ) ) |
| 116 | { bounce( "Encara no es pot confirmar la proposta" ); } |
| 117 | |
| 118 | |
| 119 | if ( ! $__dada( 'validacio_' || $idprop ) ) |
| 120 | { bounce( "La proposta encara no ha estat validada" ); } |
| 121 | |
| 122 | $operacio = 'confirmacio'; |
| 123 | |
| 124 | } else { |
| 125 | |
| 126 | $nou_ordinal = $__ordinal( $proces ); |
| 127 | $ordinals[ $proces ] = $nou_ordinal; |
| 128 | $nova_idprop = $proces || '_' || $nou_ordinal; |
| 129 | |
| 130 | $operacio = 'proposta'; |
| 131 | } |
| 132 | } else { $operacio = 'drecera'; } |
| 133 | } |
| 134 | }", |
| 135 | "messages": { |
| 136 | "cases": [ |
| 137 | { |
| 138 | "if": "{ $proces == 'acces_accions' }", |
| 139 | "init": "{ |
| 140 | $unitat_es_geto = $ids_getons[ $_unitat ]; |
| 141 | if ( $_unitat != $_estels |
| 142 | AND ( ! $unitat_es_geto OR $unitat_es_geto.estat != 'actiu' ) ) |
| 143 | { bounce( 'Getó inexistent o inactiu' ); } |
| 144 | }", |
| 145 | "messages": [ |
| 146 | { |
| 147 | "app": "data", |
| 148 | "payload": "{ $args }" |
| 149 | }, |
| 150 | { |
| 151 | "app": "payment", |
| 152 | "payload": { |
| 153 | "asset": "{ $_unitat }", |
| 154 | "outputs": [ |
| 155 | { |
| 156 | "address": "{ $generics._Accions }", |
| 157 | "amount": "{ $qt }" |
| 158 | } |
| 159 | ] |
| 160 | } |
| 161 | } |
| 162 | ] |
| 163 | }, |
| 164 | { |
| 165 | "if": "{ $admin AND $proces == 'renovacio_adrs_portal' }", |
| 166 | "init": "{ |
| 167 | $args.nou_portal = |
| 168 | $operacio == 'proposta' ? |
| 169 | false : true; |
| 170 | }", |
| 171 | "messages": [ |
| 172 | { |
| 173 | "app": "data", |
| 174 | "payload": "{ $args }" |
| 175 | }, |
| 176 | { |
| 177 | "app": "payment", |
| 178 | "payload": { |
| 179 | "asset": "{ $_unitat }", |
| 180 | "outputs": [ |
| 181 | { |
| 182 | "address": "{ $generics._Accions }", |
| 183 | "amount": "{ $qt }" |
| 184 | } |
| 185 | ] |
| 186 | } |
| 187 | }, |
| 188 | { |
| 189 | "app": "data", |
| 190 | "payload": "{ $args }" |
| 191 | }, |
| 192 | { |
| 193 | "app": "payment", |
| 194 | "payload": { |
| 195 | "asset": "{ $_unitat }", |
| 196 | "outputs": [ |
| 197 | { |
| 198 | "address": "{ $generics._Getons }", |
| 199 | "amount": "{ $qt }" |
| 200 | } |
| 201 | ] |
| 202 | } |
| 203 | }, |
| 204 | { |
| 205 | "app": "data", |
| 206 | "payload": "{ $args }" |
| 207 | }, |
| 208 | { |
| 209 | "app": "payment", |
| 210 | "payload": { |
| 211 | "asset": "{ $_unitat }", |
| 212 | "outputs": [ |
| 213 | { |
| 214 | "address": "{ $generics._Validadores }", |
| 215 | "amount": "{ $qt }" |
| 216 | } |
| 217 | ] |
| 218 | } |
| 219 | }, |
| 220 | { |
| 221 | "app": "data", |
| 222 | "payload": "{ $args }" |
| 223 | }, |
| 224 | { |
| 225 | "app": "payment", |
| 226 | "payload": { |
| 227 | "asset": "{ $_unitat }", |
| 228 | "outputs": [ |
| 229 | { |
| 230 | "address": "{ $generics._Validacions }", |
| 231 | "amount": "{ $qt }" |
| 232 | } |
| 233 | ] |
| 234 | } |
| 235 | }, |
| 236 | { |
| 237 | "if": "{ $operacio == 'proposta' }", |
| 238 | "app": "data_feed", |
| 239 | "payload": { |
| 240 | "{ $nova_idprop }": "{ timestamp }", |
| 241 | "{ $nova_idprop || '_temps' }": "{ timestamp }" |
| 242 | } |
| 243 | }, |
| 244 | { |
| 245 | "app": "state", |
| 246 | "state": "{ |
| 247 | response[ 'procés' ] = $proces; |
| 248 | response[ 'operació' ] = $operacio; |
| 249 | var[ 'ordinals' ] = $ordinals; |
| 250 | }" |
| 251 | } |
| 252 | ] |
| 253 | }, |
| 254 | { |
| 255 | "if": "{ $admin AND $proces == 'copia_dades_portal' }", |
| 256 | "messages": [ |
| 257 | { |
| 258 | "app": "state", |
| 259 | "state": "{ |
| 260 | $portals = var[ $__arg( 'val' )][ 'portals' ]; |
| 261 | var[ 'portals' ] = |
| 262 | $portals ? |
| 263 | $portals || ':' || this_address : |
| 264 | this_address; |
| 265 | |
| 266 | $__copia_dades = $r => { |
| 267 | var[ $r ] = var[ $__arg( 'val' )][ $r ] otherwise []; }; |
| 268 | |
| 269 | $blocs_dades = [ 'generics', 'ordinals', 'entitats', |
| 270 | 'refs_getons', 'ids_getons' ]; |
| 271 | |
| 272 | response[ 'procés' ] = $proces; |
| 273 | }" |
| 274 | } |
| 275 | ] |
| 276 | }, |
| 277 | { |
| 278 | "if": "{ $admin AND $proces == 'copia_dades_accions' }", |
| 279 | "init": "{ |
| 280 | $args.copia_dades = |
| 281 | $operacio == 'proposta' ? false : true; |
| 282 | }", |
| 283 | "messages": [ |
| 284 | { |
| 285 | "app": "data", |
| 286 | "payload": "{ $args }" |
| 287 | }, |
| 288 | { |
| 289 | "if": "{ $operacio != 'proposta' }", |
| 290 | "app": "payment", |
| 291 | "payload": { |
| 292 | "asset": "{ $_unitat }", |
| 293 | "outputs": [ |
| 294 | { |
| 295 | "address": "{ $generics._Accions }", |
| 296 | "amount": "{ $qt }" |
| 297 | } |
| 298 | ] |
| 299 | } |
| 300 | }, |
| 301 | { |
| 302 | "if": "{ $operacio == 'proposta' }", |
| 303 | "app": "data_feed", |
| 304 | "payload": { |
| 305 | "{ $nova_idprop || '_nom_aa' }": "{ $__arg( 'nom_aa' ) }", |
| 306 | "{ $nova_idprop || '_proposant' }": "{ $adr__ }", |
| 307 | "{ $nova_idprop || '_temps' }": "{ timestamp }" |
| 308 | } |
| 309 | }, |
| 310 | { |
| 311 | "app": "state", |
| 312 | "state": "{ |
| 313 | response[ 'procés' ] = $proces; |
| 314 | response[ 'operació' ] = $operacio; |
| 315 | var[ 'ordinals' ] = $ordinals; |
| 316 | }" |
| 317 | } |
| 318 | ] |
| 319 | }, |
| 320 | { |
| 321 | "if": "{ $admin AND $proces == 'esmena_generics' }", |
| 322 | "messages": [ |
| 323 | { |
| 324 | "if": "{ $operacio == 'proposta' }", |
| 325 | "app": "data_feed", |
| 326 | "payload": { |
| 327 | "{ $nova_idprop || '_ref' }": "{ $__arg( 'ref' ) }", |
| 328 | "{ $nova_idprop || '_val' }": "{ $__arg( 'val' ) }", |
| 329 | "{ $nova_idprop || '_proposant' }": "{ $adr__ }", |
| 330 | "{ $nova_idprop || '_temps' }": "{ timestamp }" |
| 331 | } |
| 332 | }, |
| 333 | { |
| 334 | "if": "{ $operacio != 'proposta' }", |
| 335 | "app": "state", |
| 336 | "state": "{ |
| 337 | if ( $operacio == 'drecera' ) { |
| 338 | if ( $ref == 'multiple' ) { |
| 339 | $__resp = $r => { |
| 340 | $valvar = |
| 341 | $args[ $r ] otherwise $generics[ $r ] otherwise '...'; |
| 342 | $generics[ $r ] = $valvar; |
| 343 | response[ $r ] = $valvar; |
| 344 | }; |
| 345 | |
| 346 | $refs_generics = [ |
| 347 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 348 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 349 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 350 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 351 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 352 | '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' |
| 353 | ]; |
| 354 | |
| 355 | $valora = map( $refs_generics, 22, $__resp ); |
| 356 | |
| 357 | } else { |
| 358 | $generics[ $__arg( 'ref' ) ] = $__arg( 'val' ); |
| 359 | $nova_ref = $ref; |
| 360 | $nou_val = $args.val; |
| 361 | } |
| 362 | } else if ( $operacio == 'confirmacio' ) { |
| 363 | $nova_ref = $__dada( $idprop || '_ref' ); |
| 364 | $nou_val = $__dada( $idprop || '_val' ); |
| 365 | $generics[ $nova_ref ] = $nou_val; |
| 366 | response[ 'proposta' ] = $idprop; |
| 367 | } |
| 368 | if( $nova_ref ) { |
| 369 | response[ 'nova ref' ] = $nova_ref; |
| 370 | response[ 'nou val' ] = $nou_val; |
| 371 | } |
| 372 | response[ 'procés' ] = $proces; |
| 373 | response[ 'operació' ] = $operacio; |
| 374 | var[ 'generics' ] = $generics; |
| 375 | var[ 'ordinals' ] = $ordinals; |
| 376 | }" |
| 377 | } |
| 378 | ] |
| 379 | }, |
| 380 | { |
| 381 | "if": "{ $admin AND $proces == 'assignacio' }", |
| 382 | "init": "{ |
| 383 | $unitat = $__dada( $idprop || '_unitat' ) otherwise $args.unitat; |
| 384 | $qt_assignacio = $__dada( $idprop || '_qt' ) otherwise $args.qt; |
| 385 | $receptora = $__dada( $idprop || '_receptora' ) otherwise $args.receptora; |
| 386 | }", |
| 387 | "messages": [ |
| 388 | { |
| 389 | "if": "{ $operacio != 'proposta' }", |
| 390 | "app": "payment", |
| 391 | "payload": { |
| 392 | "asset": "{ $unitat }", |
| 393 | "outputs": [ |
| 394 | { |
| 395 | "address": "{ $receptora }", |
| 396 | "amount": "{ $args.qt }" |
| 397 | } |
| 398 | ] |
| 399 | } |
| 400 | }, |
| 401 | { |
| 402 | "if": "{ $operacio == 'proposta' }", |
| 403 | "app": "data_feed", |
| 404 | "payload": { |
| 405 | "{ 'ordinal_' || $proces }": "{ $nou_ordinal }", |
| 406 | "{ 'proposta_' || $nova_idprop }": "{ timestamp }" |
| 407 | } |
| 408 | }, |
| 409 | { |
| 410 | "if": "{ $operacio != 'confirmacio' }", |
| 411 | "app": "data_feed", |
| 412 | "payload": { |
| 413 | "{ $nova_idprop || '_ref' }": "{ $__arg( 'ref' ) }", |
| 414 | "{ $nova_idprop || '_val' }": "{ $__arg( 'val' ) }", |
| 415 | "{ $nova_idprop || '_proposant' }": "{ $adr__ }", |
| 416 | "{ $nova_idprop || '_receptora' }": "{ $__arg( 'receptora' ) }", |
| 417 | "{ $nova_idprop || '_temps' }": "{ timestamp }", |
| 418 | "{ $nova_idprop || '_resolucio' }": "{ $__arg( 'resolucio' ) }", |
| 419 | "{ $nova_idprop || '_requeriment' }": "{ $__arg( 'requeriment' ) }", |
| 420 | "{ $nova_idprop || '_qt' }": "{ $__arg( 'qt' ) }", |
| 421 | "{ $nova_idprop || '_unitat' }": "{ $__arg( 'unitat' ) }" |
| 422 | } |
| 423 | }, |
| 424 | { |
| 425 | "if": "{ $operacio == 'confirmacio' OR $operacio == 'drecera' }", |
| 426 | "app": "data_feed", |
| 427 | "payload": { |
| 428 | "{ 'confirmacio_' || $nova_idprop }": "{ timestamp }" |
| 429 | } |
| 430 | }, |
| 431 | { |
| 432 | "app": "state", |
| 433 | "state": "{ |
| 434 | response[ 'proposta' ] = $nova_idprop; |
| 435 | response[ 'qt' ] = $qt_assignacio; |
| 436 | response[ 'receptora' ] = $receptora; |
| 437 | response[ 'unitat' ] = $unitat; |
| 438 | response[ 'procés' ] = $proces; |
| 439 | response[ 'operació' ] = $operacio; |
| 440 | var[ 'ordinals' ] = $ordinals; |
| 441 | }" |
| 442 | } |
| 443 | ] |
| 444 | }, |
| 445 | { |
| 446 | "if": "{ $proces == 'conversio' }", |
| 447 | "init": "{ |
| 448 | $diposit = $dades_accions.diposits[ $__arg( 'ref' ) ]; |
| 449 | if ( ! $diposit ) { bounce( ': Dipòsit inexistent' ); } |
| 450 | |
| 451 | if ( $adr__ != $diposit.dipositant ) |
| 452 | { bounce( ": L'adreça receptora ha de ser la dipositant" ); } |
| 453 | |
| 454 | if ( $__dada( 'conversio_' || $ref ) ) |
| 455 | { bounce( ': aquest dipòsit ja ha estat convertit' ); } |
| 456 | |
| 457 | if ( $diposit.cicle_conversio > $dades_accions.cicle_actual ) |
| 458 | { bounce( ": Encara no és l'hora" ); } |
| 459 | |
| 460 | $unitat = |
| 461 | $diposit.geto_diposit == $_estels ? |
| 462 | "base" : |
| 463 | $_estels; |
| 464 | }", |
| 465 | "messages": [ |
| 466 | { |
| 467 | "app": "payment", |
| 468 | "payload": { |
| 469 | "asset": "{ $unitat }", |
| 470 | "outputs": [ |
| 471 | { |
| 472 | "address": "{ $adr__ }", |
| 473 | "amount": "{ $diposit.qt_conversio }" |
| 474 | } |
| 475 | ] |
| 476 | } |
| 477 | }, |
| 478 | { |
| 479 | "app": "data_feed", |
| 480 | "payload": { |
| 481 | "{ 'conversio_' || $ref || '_qt' }": "{ $qt }", |
| 482 | "{ 'conversio_' || $ref || '_unitat' }": "{ $unitat }" |
| 483 | } |
| 484 | }, |
| 485 | { |
| 486 | "app": "state", |
| 487 | "state": "{ |
| 488 | response[ 'Conversió realitzada' ] = $ref; |
| 489 | response[ 'procés' ] = $proces; |
| 490 | }" |
| 491 | } |
| 492 | ] |
| 493 | }, |
| 494 | { |
| 495 | "if": "{ $proces == 'retribucio' }", |
| 496 | "init": "{ |
| 497 | $retribucions = var[ 'retribucions' ] otherwise {}; |
| 498 | |
| 499 | if ( $__arg( 'ref' ) == 'aportacio_activacio' ) { |
| 500 | $ref_activacio = 'activacio_' || $adr__ || '_en_' || $_estels; |
| 501 | $activacio = $dades_accions.activacions[ $ref_activacio ]; |
| 502 | $import = $activacio.qt; |
| 503 | $escala = $activacio.escala; |
| 504 | } else { |
| 505 | $contribucio = $dades_accions.contribucions[ $ref ]; |
| 506 | |
| 507 | if ( ! $contribucio ) { bounce( ': Contribucio inexistent' ); } |
| 508 | |
| 509 | if ( $adr__ != $contribucio.contribuidora ) |
| 510 | { bounce( ": L'adreça receptora ha de ser la contribuidora" ); } |
| 511 | |
| 512 | $import = $contribucio.qt; |
| 513 | $escala = $contribucio.escala; |
| 514 | } |
| 515 | |
| 516 | $ref_retribucio = $args.ref || '_' || $escala_actual; |
| 517 | |
| 518 | if ( $__dada( 'retribucio_' || $ref_retribucio ) ) |
| 519 | { bounce( ": aquesta ja ha estat retribuïda per a l'escala actual" ); } |
| 520 | |
| 521 | |
| 522 | if ( $escala_actual == $escala ) { bounce ( $nom_AA || ": Encara no és l'hora" ); } |
| 523 | |
| 524 | |
| 525 | $qt_retribucio = $import * ( $escala_actual - $escala ); |
| 526 | }", |
| 527 | "messages": [ |
| 528 | { |
| 529 | "app": "payment", |
| 530 | "payload": { |
| 531 | "asset": "{ $_estels }", |
| 532 | "outputs": [ |
| 533 | { |
| 534 | "address": "{ $adr__ }", |
| 535 | "amount": "{ $qt_retribucio }" |
| 536 | } |
| 537 | ] |
| 538 | } |
| 539 | }, |
| 540 | { |
| 541 | "app": "data_feed", |
| 542 | "payload": { |
| 543 | "{ 'retribucio_' || $ref || '_qt' }": "{ $qt_retribucio }", |
| 544 | "{ 'retribucio_' || $ref || '_receptora' }": "{ $adr__ }" |
| 545 | } |
| 546 | }, |
| 547 | { |
| 548 | "app": "state", |
| 549 | "state": "{ |
| 550 | response[ 'Retribució realitzada' ] = $ref_retribucio; |
| 551 | response[ 'procés' ] = $proces; |
| 552 | }" |
| 553 | } |
| 554 | ] |
| 555 | }, |
| 556 | { |
| 557 | "if": "{ $operacio AND $operacio == 'proposta' }", |
| 558 | "init": "{ |
| 559 | $args.proces = 'convocatoria_validadores'; |
| 560 | }", |
| 561 | "messages": [ |
| 562 | { |
| 563 | "app": "data", |
| 564 | "payload": "{ $args }" |
| 565 | }, |
| 566 | { |
| 567 | "app": "payment", |
| 568 | "payload": { |
| 569 | "asset": "{ $_unitat }", |
| 570 | "outputs": [ |
| 571 | { |
| 572 | "address": "{ $generics._Validacions }", |
| 573 | "amount": "{ $qt }" |
| 574 | } |
| 575 | ] |
| 576 | } |
| 577 | } |
| 578 | ] |
| 579 | }, |
| 580 | { |
| 581 | "if": "{ $proces == 'decisio_validacio' }", |
| 582 | "messages": [ |
| 583 | { |
| 584 | "app": "data", |
| 585 | "payload": "{ $args }" |
| 586 | }, |
| 587 | { |
| 588 | "app": "payment", |
| 589 | "payload": { |
| 590 | "asset": "{ $_unitat }", |
| 591 | "outputs": [ |
| 592 | { |
| 593 | "address": "{ $generics._Validacions }", |
| 594 | "amount": "{ $qt }" |
| 595 | } |
| 596 | ] |
| 597 | } |
| 598 | } |
| 599 | ] |
| 600 | }, |
| 601 | { |
| 602 | "if": "{ $proces == 'validacio_directa_TEST' AND $_actuant_es_AUT }", |
| 603 | "messages": [ |
| 604 | { |
| 605 | "app": "data", |
| 606 | "payload": "{ $args }" |
| 607 | }, |
| 608 | { |
| 609 | "app": "payment", |
| 610 | "payload": { |
| 611 | "asset": "{ $_unitat }", |
| 612 | "outputs": [ |
| 613 | { |
| 614 | "address": "{ $generics._Validacions }", |
| 615 | "amount": "{ $qt }" |
| 616 | } |
| 617 | ] |
| 618 | } |
| 619 | } |
| 620 | ] |
| 621 | }, |
| 622 | { |
| 623 | "if": "{ $args.admin.entitats }", |
| 624 | "messages": [ |
| 625 | { |
| 626 | "if": "{ $operacio == 'proposta' }", |
| 627 | "app": "data_feed", |
| 628 | "payload": { |
| 629 | "{ $nova_idprop || '_adr' }": "{ $__arg( 'adr' ) }", |
| 630 | "{ $nova_idprop || '_nom' }": "{ $__arg( 'nom' ) }", |
| 631 | "{ $nova_idprop || '_estat' }": "{ $__arg( 'estat' ) }" |
| 632 | } |
| 633 | }, |
| 634 | { |
| 635 | "if": "{ $operacio != 'proposta' }", |
| 636 | "app": "state", |
| 637 | "state": "{ |
| 638 | $entitats = var[ 'entitats' ] otherwise {}; |
| 639 | |
| 640 | if ( $proces == 'nova_entitat' ) { |
| 641 | if ( $entitats[ $args.adr ] ) |
| 642 | { bounce( "Ja hi ha una entitat amb aquesta adreça" ); } |
| 643 | |
| 644 | if ( $entitats[ $args.adr ].nom == $__arg( 'nom' ) ) |
| 645 | { bounce( "Ja hi ha una entitat amb aquest nom" ); } |
| 646 | |
| 647 | if ( $operacio != 'proposta' ) { |
| 648 | $adr_entitat = $args.adr otherwise $__dada( $idprop || 'adr' ); |
| 649 | $entitats[ $adr_entitat ] = { |
| 650 | nom: $args.nom otherwise $__dada( $idprop || 'nom' ), |
| 651 | estat: $args.estat otherwise $__dada( $idprop || 'estat' ), |
| 652 | }; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | if ( $proces == 'nou_estat_entitat' ) { |
| 657 | if ( ! $entitats[ $args.adr ] ) |
| 658 | { bounce( "No hi ha cap entitat amb aquesta adreça" ); } |
| 659 | |
| 660 | if ( $operacio != 'proposta' ) { |
| 661 | $entitats[ $args.adr ].estat = |
| 662 | $args.estat otherwise $__dada( $idprop || 'estat' ); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | var[ 'entitats' ] = $entitats; |
| 667 | var[ 'ordinals' ] = $ordinals; |
| 668 | response[ 'procés' ] = $proces; |
| 669 | response[ 'operació' ] = $operacio; |
| 670 | }" |
| 671 | } |
| 672 | ] |
| 673 | }, |
| 674 | { |
| 675 | "if": "{ $admin AND $proces == 'nou_geto' }", |
| 676 | "init": "{ $novaref = 'geto_' || $__ordinal( 'geto' ); }", |
| 677 | "messages": [ |
| 678 | { |
| 679 | "if": "{ $operacio != 'confirmacio' }", |
| 680 | "app": "data_feed", |
| 681 | "payload": { |
| 682 | "{ $novaref || '_proposant' }": "{ $adr__ }", |
| 683 | "{ $novaref || '_confirmant' }": "{ $operacio == 'proposta' ? '' : $adr__ }", |
| 684 | "{ $novaref || '__FOP' }": "{ $__arg( '_FOP' ) }", |
| 685 | "{ $novaref || '__AUT_A' }": "{ $__arg( '_AUT_A' ) }", |
| 686 | "{ $novaref || '_factor_conversio' }": "{ $__arg( 'factor_conversio' ) }", |
| 687 | "{ $novaref || '_valors_esmenables' }": "{ $__arg( 'valors_esmenables' ) }", |
| 688 | "{ $novaref || '_llistats_editables' }": "{ $__arg( 'llistats_editables' ) }", |
| 689 | "{ $novaref || '_bloqueig_possible' }": "{ $__arg( 'bloqueig_possible' ) }", |
| 690 | "{ $novaref || '_activacions_restringides' }": "{ $__arg( 'activacions_restringides' ) }", |
| 691 | "{ $novaref || '_subscripcions_restringides' }": "{ $__arg( 'subscripcions_restringides' ) }", |
| 692 | "{ $novaref || '_recepcions_restringides' }": "{ $__arg( 'recepcions_restringides' ) }", |
| 693 | "{ $novaref || '_conversions_restringides' }": "{ $__arg( 'conversions_restringides' ) }", |
| 694 | "{ $novaref || '_import_activacio' }": "{ $__arg( 'import_activacio' ) }", |
| 695 | "{ $novaref || '_import_subscripcio' }": "{ $__arg( 'import_subscripcio' ) }", |
| 696 | "{ $novaref || '_import_renovacio' }": "{ $__arg( 'import_renovacio' ) }", |
| 697 | "{ $novaref || '_taxa_conversio' }": "{ $__arg( 'taxa_conversio' ) }", |
| 698 | "{ $novaref || '_cicles_diposit' }": "{ $__arg( 'cicles_diposit' ) }", |
| 699 | "{ $novaref || '_derivacio' }": "{ $__arg( 'derivacio' ) }", |
| 700 | "{ $novaref || '_AUT_B' }": "{ $args._AUT_B }", |
| 701 | "{ $novaref || '_AUT_C' }": "{ $args._AUT_C }" |
| 702 | } |
| 703 | }, |
| 704 | { |
| 705 | "if": "{ $operacio == 'confirmacio' }", |
| 706 | "app": "data_feed", |
| 707 | "payload": { |
| 708 | "{ $__arg( 'ref_geto' ) || '_confirmant' }": "{ $adr__ }" |
| 709 | } |
| 710 | } |
| 711 | ] |
| 712 | }, |
| 713 | { |
| 714 | "if": "{ $admin AND $proces == 'implementacio' }", |
| 715 | "init": "{ |
| 716 | |
| 717 | |
| 718 | if ( $__dada( $ref_geto || '_confirmant' ) ) |
| 719 | { bounce( 'Proposta pendent de confirmació' ); } |
| 720 | |
| 721 | }", |
| 722 | "messages": [ |
| 723 | { |
| 724 | "if": "{ $operacio == 'proposta' }", |
| 725 | "app": "data_feed", |
| 726 | "payload": { |
| 727 | "{ $nova_idprop }": "{ $ref_geto }" |
| 728 | } |
| 729 | }, |
| 730 | { |
| 731 | "if": "{ $operacio != 'proposta' }", |
| 732 | "app": "asset", |
| 733 | "payload": { |
| 734 | "cap": "{ $args.cap otherwise 1e9 }", |
| 735 | "is_private": false, |
| 736 | "is_transferrable": true, |
| 737 | "auto_destroy": "{ !! $args.auto_destroy }", |
| 738 | "fixed_denominations": false, |
| 739 | "issued_by_definer_only": true, |
| 740 | "cosigned_by_definer": false, |
| 741 | "spender_attested": false |
| 742 | } |
| 743 | }, |
| 744 | { |
| 745 | "if": "{ $operacio != 'proposta' }", |
| 746 | "app": "state", |
| 747 | "state": "{ |
| 748 | $refs_getons[ response_unit ] = $ref_geto; |
| 749 | $ids_getons[ $ref_geto ] = response_unit; |
| 750 | var[ 'ids_getons' ] = $ids_getons; |
| 751 | var[ 'refs_getons' ] = $refs_getons; |
| 752 | }" |
| 753 | } |
| 754 | ] |
| 755 | }, |
| 756 | { |
| 757 | "if": "{ $admin AND $proces == 'baixa_geto' }", |
| 758 | "init": "{ |
| 759 | |
| 760 | if ( ! $refs_getons[ $__arg( 'ref_geto' ) ] ) |
| 761 | { bounce( 'Getó inexistent' ); } |
| 762 | }", |
| 763 | "messages": [ |
| 764 | { |
| 765 | "if": "{ $operacio == 'proposta' }", |
| 766 | "app": "data_feed", |
| 767 | "payload": { |
| 768 | "{ $nova_idprop || '_geto' }": "{ $ref_geto }" |
| 769 | } |
| 770 | }, |
| 771 | { |
| 772 | "if": "{ $operacio != 'proposta' }", |
| 773 | "app": "state", |
| 774 | "state": "{ |
| 775 | delete( $ids_getons, $ref_geto ); |
| 776 | delete( $refs_getons, $refs_getons[ $ref_geto ] ); |
| 777 | var[ 'refs_getons' ] = $refs_getons; |
| 778 | var[ 'ids_getons' ] = $ids_getons; |
| 779 | }" |
| 780 | } |
| 781 | ] |
| 782 | }, |
| 783 | { |
| 784 | "if": "{ $args.admin_geto }", |
| 785 | "init": "{ |
| 786 | $args.operacio = $operacio; |
| 787 | $args.idprop = $nova_idprop; |
| 788 | }", |
| 789 | "messages": [ |
| 790 | { |
| 791 | "if": "{ $proces == 'emissio_getons' }", |
| 792 | "init": "{ |
| 793 | if ( $_unitat != $_estels ) |
| 794 | { bounce( 'Cal aportar-hi estels' ); } |
| 795 | |
| 796 | if ( $qt < $generics.Generacio_Minima ) |
| 797 | { bounce( 'Cal aportar-hi si més no ' |
| 798 | || $generics.Generacio_Minima || ' estels' ); } |
| 799 | }", |
| 800 | "app": "payment", |
| 801 | "payload": { |
| 802 | "asset": "{ $ids_getons[ $ref_geto ] }", |
| 803 | "outputs": [ |
| 804 | { |
| 805 | "address": "{ $__dada( $ref_geto || '_FOP' ) }", |
| 806 | "amount": "{ $qt * $__dada( $ref_geto || 'factor_conversio' ) }" |
| 807 | } |
| 808 | ] |
| 809 | } |
| 810 | }, |
| 811 | { |
| 812 | "app": "data", |
| 813 | "payload": "{ $args }" |
| 814 | }, |
| 815 | { |
| 816 | "app": "payment", |
| 817 | "payload": { |
| 818 | "asset": "{ $_unitat }", |
| 819 | "outputs": [ |
| 820 | { |
| 821 | "address": "{ $generics._Getons }", |
| 822 | "amount": "{ $qt }" |
| 823 | } |
| 824 | ] |
| 825 | } |
| 826 | } |
| 827 | ] |
| 828 | } |
| 829 | ] |
| 830 | } |
| 831 | } |
| 832 | ] |