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