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