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