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