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