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