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