| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Portal'; |
| 6 | $versio = '0.1.2'; |
| 7 | |
| 8 | $_AUT_000 = 'C4KIJSUWVM7BGWTLXKX3K4PNRXV7OY4W'; |
| 9 | |
| 10 | $adr__ = trigger.address; |
| 11 | $args = trigger.data; |
| 12 | |
| 13 | $generics = var[ 'Generics' ]; |
| 14 | |
| 15 | $__bota = $txt => bounce ( $nom_AA || ' >>> ' || $txt ); |
| 16 | |
| 17 | if ( $args.admin ) { |
| 18 | $propostes = var[ 'Propostes' ]; |
| 19 | $validacions = var[ 'Validacions' ]; |
| 20 | $ordinals = var[ 'Ordinals' ]; |
| 21 | |
| 22 | |
| 23 | |
| 24 | $__arg = $arg => |
| 25 | $args[ $arg ] ? |
| 26 | $args[ $arg ] : |
| 27 | $__bota( "Cal proporcionar el valor de: " || $arg ); |
| 28 | |
| 29 | |
| 30 | $__autoritzada = ( $x ) => { |
| 31 | $aut = $generics[ '_AUT_' || $x ]; |
| 32 | $aut AND $aut == $adr__ |
| 33 | }; |
| 34 | |
| 35 | |
| 36 | if ( $adr__ != $_AUT_000 |
| 37 | AND ! $__autoritzada( '0' ) |
| 38 | AND ! $__autoritzada( 'A' ) |
| 39 | AND ! $__autoritzada( 'B' ) |
| 40 | AND ! $__autoritzada( 'C' ) |
| 41 | ) { $__bota( 'No autoritzada' ); } |
| 42 | |
| 43 | |
| 44 | $es_AUT_000 = $adr__ == $_AUT_000; |
| 45 | if ( ! $es_AUT_000 OR ( $es_AUT_000 AND $__autoritzada( '0' ) ) ) { |
| 46 | |
| 47 | if ( $args.tasca == 'confirmacio' ) { |
| 48 | $proposta = $propostes[ $args.idprop ]; |
| 49 | |
| 50 | |
| 51 | if ( ! $proposta ) |
| 52 | { $__bota( "No hi ha cap proposta de nou getó amb aquesta ref" ); } |
| 53 | |
| 54 | |
| 55 | if ( $proposta.proposant == $adr__ ) |
| 56 | { $__bota( "El procés de confirmació l'ha d'endegar una altra AUT" ); } |
| 57 | |
| 58 | |
| 59 | if ( $generics.Lapse > timestamp - $proposta.temps ) |
| 60 | { $__bota( "Encara no es pot confirmar la proposta" ); } |
| 61 | |
| 62 | |
| 63 | if ( ! $validacions[ $args.idprop ] ) |
| 64 | { $__bota( "La proposta encara no ha estat validada" ); } |
| 65 | |
| 66 | $tasca = 'confirmacio'; |
| 67 | |
| 68 | } else { |
| 69 | |
| 70 | $ref = $__arg( 'ref' ); |
| 71 | $val = $__arg( 'val' ); |
| 72 | |
| 73 | |
| 74 | |
| 75 | if ( $ref != 'nou_geto' AND $generics[ $ref ] AND $generics[ $ref ] == $val ) |
| 76 | { $__bota( "El valor proposat coincideix amb l'actual" ); } |
| 77 | |
| 78 | |
| 79 | $darrera_prop = $propostes[ $ref || '_' || $ordinals[ $ref ] ]; |
| 80 | |
| 81 | if ( $darrera_prop AND $darrera_prop.val == $val ) |
| 82 | { $__bota( "El valor proposat coincideix amb el de la darrera proposta" ); } |
| 83 | |
| 84 | $nou_ordinal = $ordinals[ $ref ] ? $ordinals[ $ref ] + 1 : 1; |
| 85 | |
| 86 | $tasca = 'proposta'; |
| 87 | } |
| 88 | } else { |
| 89 | $ref = $__arg( 'ref' ); |
| 90 | $val = $__arg( 'val' ); |
| 91 | $tasca = 'drecera'; } |
| 92 | } |
| 93 | }", |
| 94 | "messages": { |
| 95 | "cases": [ |
| 96 | { |
| 97 | "if": "{ $args.proces == 'acces' }", |
| 98 | "init": "{ |
| 99 | $args._Portal = this_address; |
| 100 | $args._FOP = $generics._FOP; |
| 101 | $args._Estels = $generics._Estels; |
| 102 | |
| 103 | $args.geto = trigger.output[[ asset != base ]].asset; |
| 104 | $args.qt = trigger.output[[ asset = $args.geto ]]; |
| 105 | }", |
| 106 | "messages": [ |
| 107 | { |
| 108 | "app": "data", |
| 109 | "payload": "{ $args }" |
| 110 | }, |
| 111 | { |
| 112 | "app": "payment", |
| 113 | "payload": { |
| 114 | "asset": "{ $args.geto }", |
| 115 | "outputs": [ |
| 116 | { |
| 117 | "address": "{ $generics._Acces }", |
| 118 | "amount": "{ $args.qt }" |
| 119 | } |
| 120 | ] |
| 121 | } |
| 122 | } |
| 123 | ] |
| 124 | }, |
| 125 | { |
| 126 | "if": "{ $args.proces == 'esmena_generics' }", |
| 127 | "messages": [ |
| 128 | { |
| 129 | "app": "state", |
| 130 | "state": "{ |
| 131 | |
| 132 | if ( $tasca == 'drecera' ) { |
| 133 | if ( $ref == 'multiple' ) { |
| 134 | |
| 135 | $__valvar = $refvar => |
| 136 | $args[ $refvar ] ? |
| 137 | $args[ $refvar ] : |
| 138 | $generics[ $refvar ]; |
| 139 | |
| 140 | var[ 'Generics' ] = { |
| 141 | _Acces: $__valvar( '_Acces' ), |
| 142 | _Getons: $__valvar( '_Getons' ), |
| 143 | _FRO: $__valvar( '_FRO' ), |
| 144 | _FOP: $__valvar( '_FOP' ), |
| 145 | _FDIP: $__valvar( '_FDIP' ), |
| 146 | _Estels: $__valvar( '_Estels' ), |
| 147 | Interval: $__valvar( 'Interval' ), |
| 148 | Lapse: $__valvar( 'Lapse' ), |
| 149 | _Transfer: $__valvar( '_Transfer' ), |
| 150 | _Capacitacio: $__valvar( '_Capacitacio' ), |
| 151 | _Avis: $__valvar( '_Avis' ), |
| 152 | Import_Activacio: $__valvar( 'Import_Activacio' ), |
| 153 | Import_Subscripcio: $__valvar( 'Import_Subscripcio' ), |
| 154 | Import_Renovacio: $__valvar( 'Import_Renovacio' ), |
| 155 | Taxa_Conversio: $__valvar( 'Taxa_Conversio' ), |
| 156 | Factor_Conversio: $__valvar( 'Factor_Conversio' ), |
| 157 | Cicles_Latencia: $__valvar( 'Cicles_Latencia' ), |
| 158 | _AUT_0: $__valvar( '_AUT_0' ), |
| 159 | _AUT_A: $__valvar( '_AUT_A' ), |
| 160 | _AUT_B: $__valvar( '_AUT_B' ), |
| 161 | _AUT_C: $__valvar( '_AUT_C' ), |
| 162 | }; |
| 163 | |
| 164 | response[ '_Acces' ] = $__valvar( '_Acces' ); |
| 165 | response[ '_Getons' ] = $__valvar( '_Getons' ); |
| 166 | response[ '_Validacions' ] = $__valvar( '_Validacions' ); |
| 167 | response[ '_FRO' ] = $__valvar( '_FRO' ); |
| 168 | response[ '_FOP' ] = $__valvar( '_FOP' ); |
| 169 | response[ '_FDIP' ] = $__valvar( '_FDIP' ); |
| 170 | response[ '_Estels' ] = $__valvar( 'id_Estels' ); |
| 171 | response[ 'Interval' ] = $__valvar( 'Interval' ); |
| 172 | response[ 'Lapse' ] = $__valvar( 'Lapse' ); |
| 173 | response[ '_Transfer' ] = $__valvar( '_Transfer' ); |
| 174 | response[ '_Capacitacio' ] = $__valvar( '_Capacitacio' ); |
| 175 | response[ '_Avis' ] = $__valvar( '_Avis' ); |
| 176 | response[ 'Import_Activacio' ] = $__valvar( 'Import_Activacio' ); |
| 177 | response[ 'Import_Subscripcio' ] = $__valvar( 'Import_Subscripcio' ); |
| 178 | response[ 'Import_Renovacio' ] = $__valvar( 'Import_Activacio' ); |
| 179 | response[ 'Taxa_Conversio' ] = $__valvar( 'Taxa_Conversio' ); |
| 180 | response[ 'Factor_Conversio' ] = $__valvar( 'Factor_Conversio' ); |
| 181 | response[ 'Cicles_Latencia' ] = $__valvar( 'Cicles_Latencia' ); |
| 182 | response[ '_AUT_0' ] = $__valvar( '_AUT_0' ); |
| 183 | response[ '_AUT_A' ] = $__valvar( '_AUT_A' ); |
| 184 | response[ '_AUT_B' ] = $__valvar( '_AUT_B' ); |
| 185 | response[ '_AUT_C' ] = $__valvar( '_AUT_C' ); |
| 186 | |
| 187 | $__valvar2 = $refvar => |
| 188 | var[ $refvar ] ? |
| 189 | var[ $refvar ] : |
| 190 | {}; |
| 191 | |
| 192 | var[ 'Getons' ] = $__valvar2( 'Getons' ); |
| 193 | var[ 'Propostes' ] = $__valvar2( 'Propostes' ); |
| 194 | var[ 'Validacions' ] = $__valvar2( 'Validacions' ); |
| 195 | var[ 'Ordinals' ] = $__valvar2( 'Ordinals' ); |
| 196 | |
| 197 | } else { |
| 198 | $generics[ $ref ] = $val; |
| 199 | var[ 'Generics' ] = $generics; |
| 200 | response[ 'nova ref' ] = $ref; |
| 201 | response[ 'nou val' ] = $val; |
| 202 | } |
| 203 | } else if ( $tasca == 'confirmacio' ) { |
| 204 | $generics[ $proposta.ref ] = $proposta.val; |
| 205 | response[ 'proposta' ] = $args.idprop; |
| 206 | response[ 'nova ref' ] = $proposta.ref; |
| 207 | response[ 'nou val' ] = $proposta.val; |
| 208 | } else { |
| 209 | $ordinals[ $ref ] = $nou_ordinal; |
| 210 | var[ 'Ordinals' ] = $ordinals; |
| 211 | |
| 212 | $id_proposta = $ref || '_' || $nou_ordinal; |
| 213 | $propostes[ $id_proposta ] = |
| 214 | { |
| 215 | ref: $ref, |
| 216 | val: $val, |
| 217 | proposant: $adr__, |
| 218 | temps: timestamp, |
| 219 | }; |
| 220 | var[ 'Propostes' ] = $propostes; |
| 221 | response[ 'proposta' ] = $id_proposta; |
| 222 | response[ 'nova ref' ] = $ref; |
| 223 | response[ 'nou val' ] = $val; |
| 224 | response[ 'data proposta' ] = timestamp_to_string( timestamp ); |
| 225 | response[ 'data inici confirmació'] = |
| 226 | timestamp_to_string( timestamp + $generics.Lapse ); |
| 227 | } |
| 228 | }" |
| 229 | } |
| 230 | ] |
| 231 | }, |
| 232 | { |
| 233 | "if": "{ $args.proces == 'definicio_geto' }", |
| 234 | "messages": [ |
| 235 | { |
| 236 | "if": "{ $tasca != 'proposta' }", |
| 237 | "app": "asset", |
| 238 | "payload": { |
| 239 | "cap": "{ $args.cap otherwise 1e9 }", |
| 240 | "is_private": false, |
| 241 | "is_transferrable": true, |
| 242 | "auto_destroy": "{ !! $args.auto_destroy }", |
| 243 | "fixed_denominations": false, |
| 244 | "issued_by_definer_only": true, |
| 245 | "cosigned_by_definer": false, |
| 246 | "spender_attested": false |
| 247 | } |
| 248 | }, |
| 249 | { |
| 250 | "app": "state", |
| 251 | "state": "{ |
| 252 | if ( $tasca != 'confirmacio' ) { |
| 253 | $perfil = { |
| 254 | id : response_unit, |
| 255 | _FOG : $__arg( '_FOG' ), |
| 256 | _AUT_A : $__arg( '_AUT_A' ), |
| 257 | factor_conversio : $__arg( 'factor_conversio' ), |
| 258 | import_activacio : $__arg( 'import_activacio' ), |
| 259 | import_subscripcio : $__arg( 'import_subscripcio' ), |
| 260 | import_renovacio : $__arg( 'import_renovacio' ), |
| 261 | taxa_conversio : $__arg( 'taxa_conversio' ), |
| 262 | derivacio_aFOG : $__arg( 'derivacio_aFOG' ), |
| 263 | activacions_restringides : $__arg( 'activacions_restringides' ), |
| 264 | subscripcions_restringides : $__arg( 'subscripcions_restringides' ), |
| 265 | recepcions_restringides : $__arg( 'recepcions_restringides' ), |
| 266 | conversions_restringides : $__arg( 'conversions_restringides' ), |
| 267 | valors_esmenables : $__arg( 'valors_esmenables' ), |
| 268 | llistats_editables : $__arg( 'llistats_editables' ), |
| 269 | bloqueig_possible : $__arg( 'bloqueig_possible' ), |
| 270 | }; |
| 271 | } |
| 272 | if ( $tasca == 'drecera' ) { |
| 273 | $getons = var[ 'Getons' ]; |
| 274 | |
| 275 | $getons[ response_unit ] = |
| 276 | { |
| 277 | proposant: $adr__, |
| 278 | confirmant: $adr__, |
| 279 | temps: timestamp, |
| 280 | perfil: $perfil |
| 281 | }; |
| 282 | var[ 'Getons' ] = $getons; |
| 283 | response[ 'Getó operatiu' ] = response_unit; |
| 284 | } |
| 285 | if ( $tasca == 'confirmacio' ) { |
| 286 | $prop = $propostes[ $args.idprop ]; |
| 287 | $getons = var[ 'Getons' ]; |
| 288 | |
| 289 | $getons[ response_unit ] = |
| 290 | { |
| 291 | proposant: $prop.proposant, |
| 292 | confirmant: $adr__, |
| 293 | temps: timestamp, |
| 294 | perfil: $prop.perfil |
| 295 | }; |
| 296 | var[ 'Getons' ] = $getons; |
| 297 | response[ 'Getó operatiu' ] = $args.idprop; |
| 298 | } |
| 299 | if ( $tasca == 'proposta' ) { |
| 300 | $id_proposta = 'nou_geto_' || $nou_ordinal; |
| 301 | $propostes[ $id_proposta ] = |
| 302 | { |
| 303 | proposant: $adr__, |
| 304 | temps: timestamp, |
| 305 | perfil: $perfil |
| 306 | }; |
| 307 | var[ 'Propostes' ] = $propostes; |
| 308 | response[ 'proposta' ] = $id_proposta; |
| 309 | response[ 'data inici confirmació'] = |
| 310 | timestamp_to_string( timestamp + $args.lapse ); |
| 311 | } |
| 312 | response[ 'tasca' ] = $tasca; |
| 313 | }" |
| 314 | } |
| 315 | ] |
| 316 | }, |
| 317 | { |
| 318 | "if": "{ $args.proces == 'validacio' }", |
| 319 | "init": "{ |
| 320 | $id_geto = trigger.output[[ asset != base ]].asset; |
| 321 | $getons = var[ 'Getons' ]; |
| 322 | if( $id_geto != $generics._Estels ) { |
| 323 | $geto_ini = $getons[ $id_geto ]; |
| 324 | $perfil_geto = $generics._Getons[ $id_geto ]; |
| 325 | |
| 326 | if( $adr__ != $geto_ini.perfil._AUT_A |
| 327 | AND $adr__ != $perfil_geto._AUT_B |
| 328 | AND $adr__ != $perfil_geto._AUT_C |
| 329 | ) |
| 330 | { $__bota( "No autoritzada per a aquest getó" ); } |
| 331 | } |
| 332 | |
| 333 | |
| 334 | |
| 335 | |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | }", |
| 341 | "messages": [ |
| 342 | { |
| 343 | "app": "data", |
| 344 | "payload": "{ $args.idprop }" |
| 345 | }, |
| 346 | { |
| 347 | "if": "{ $id_geto != $generics._Estels }", |
| 348 | "app": "payment", |
| 349 | "payload": { |
| 350 | "asset": "{ $id_geto }", |
| 351 | "outputs": [ |
| 352 | { |
| 353 | "address": "{ $generics._Getons }", |
| 354 | "amount": "{ 10 }" |
| 355 | } |
| 356 | ] |
| 357 | } |
| 358 | }, |
| 359 | { |
| 360 | "app": "state", |
| 361 | "state": "{ |
| 362 | $validacions[ $args.idprop ] = timestamp; |
| 363 | var[ 'Validacions' ] = $validacions; |
| 364 | response[ 'Ref proposta validada' ] = $args.idprop; |
| 365 | }" |
| 366 | } |
| 367 | ] |
| 368 | }, |
| 369 | { |
| 370 | "messages": [ |
| 371 | { |
| 372 | "app": "state", |
| 373 | "state": "{ |
| 374 | var[ 'Generics' ] = { |
| 375 | _FRO: 'K5XXDVOHMEW45LSGTXGU5DK3VG75ZSHV', |
| 376 | _FOP: 'BXYGHGW5K62P32UHHBNVFN4NPOJZAPNY', |
| 377 | _FDIP: '5ZDQQ5ADCG7ETR74VSHJEAGIERBHE3K4', |
| 378 | _Estels: 'yfIMR3MMcTWchE7BaPFoohOpbe8H71vNrIRESmPPzCw', |
| 379 | Interval: 1000, |
| 380 | Lapse: 1200, |
| 381 | Import_Activacio: 20, |
| 382 | Import_Subscripcio: 50, |
| 383 | Import_Renovacio: 25, |
| 384 | Taxa_Conversio: 4, |
| 385 | Factor_Conversio: 10, |
| 386 | Cicles_Latencia: 3, |
| 387 | _AUT_A: 'GIIYFJXPZW3KH5MPQKRLZTWO4LIXX25R', |
| 388 | _AUT_B: 'AMJMY4TSHN7WAMDDNBDJHOVGTL3SG7LN', |
| 389 | }; |
| 390 | }" |
| 391 | } |
| 392 | ] |
| 393 | } |
| 394 | ] |
| 395 | } |
| 396 | } |
| 397 | ] |