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