| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Validacions'; |
| 6 | $darrera_versio = '0000000000'; |
| 7 | |
| 8 | $_Portal_original = trigger.address; |
| 9 | |
| 10 | $_Portal_actual = var[ 'nou_portal' ] otherwise $_Portal_original; |
| 11 | |
| 12 | if ( $_Portal_actual != trigger.address ) |
| 13 | { |
| 14 | $_Portal = substring( var[ $_Portal_actual ][ 'versions' ], 0, 32 ); |
| 15 | if( $_Portal != trigger.address ) |
| 16 | { bounce ( 'Portal no reconegut' ); } |
| 17 | } else { |
| 18 | $_Portal = $_Portal_actual; |
| 19 | } |
| 20 | |
| 21 | |
| 22 | |
| 23 | $args = trigger.data; |
| 24 | $adr__ = trigger.initial_address; |
| 25 | $_unitat = trigger.output[[ asset != base ]].asset; |
| 26 | $qt = 10; |
| 27 | |
| 28 | $proces = $args.proces; |
| 29 | $idprop = $args.idprop; |
| 30 | |
| 31 | $generics = var[ $_Portal ][ 'generics' ]; |
| 32 | $entitats = var[ $_Portal ][ 'entitats' ]; |
| 33 | $versions_portal = var[ $_Portal ][ 'versions' ] otherwise $_Portal; |
| 34 | $versions_validacions = var[ $_Portal ][ 'versions_validacions' ] otherwise this_address; |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | $__arg = $arg => |
| 40 | $args[ $arg ] otherwise |
| 41 | bounce( "Cal proporcionar el valor de: " || $arg ); |
| 42 | |
| 43 | $__dada = $refval => { |
| 44 | data_feed[[ oracles = $versions_validacions, feed_name = $refval, ifnone = false ]] |
| 45 | }; |
| 46 | |
| 47 | $__dada_proposta = $refval => { |
| 48 | data_feed[[ oracles = $versions_portal, feed_name = $refval, ifnone = false ]] |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | if ( $__dada_proposta( 'validacio_' || $idprop ) ) |
| 55 | { bounce( 'Ja validada' ); } |
| 56 | |
| 57 | |
| 58 | if ( ! $__dada_proposta( $idprop ) ) |
| 59 | { bounce( 'No hi ha cap proposta amb aquesta id' ); } |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | if ( $proces == 'validacio_directa_TEST' ) { |
| 66 | $validacio_aprovada = true; |
| 67 | } |
| 68 | |
| 69 | }", |
| 70 | "messages": [ |
| 71 | { |
| 72 | "if": "{ $validacio_aprovada }", |
| 73 | "app": "data_feed", |
| 74 | "payload": { |
| 75 | "{ 'validacio_' || $idprop }": "{ timestamp }" |
| 76 | } |
| 77 | }, |
| 78 | { |
| 79 | "app": "state", |
| 80 | "state": "{ |
| 81 | response[ 'Procés' ] = $proces; |
| 82 | response[ 'Proposta' ] = $idprop; |
| 83 | |
| 84 | |
| 85 | if ( $_Portal != $_Portal_actual ) { |
| 86 | var[ 'anterior_portal' ] = var[ 'nou_portal' ]; |
| 87 | var[ 'nou_portal' ] = $_Portal; |
| 88 | response[ 'Nou portal' ] = $_Portal; |
| 89 | } |
| 90 | }" |
| 91 | } |
| 92 | ] |
| 93 | } |
| 94 | ] |