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