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