Unit ID
NSu6flis9Lxr/gjI6zLlqYjAPoHkhfbYTwGBl3tAMTM=
Received
16.01.2021 12:17:54
Confirmation delay (full node)
3 minutes 52 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $nom_AA = 'Validacions'; $darrera_versio = '0000000000'; //$_Portal_original = '0000000000'; $_Portal_original = trigger.address; //Hauria de ser fix amb adr darrer Portal $_Portal = var[ 'nou_portal' ] otherwise $_Portal_original; if ( $_Portal != trigger.address ) { bounce ( 'Portal no habilitat' ); } // Principals $args = trigger.data; $adr__ = trigger.initial_address; $_unitat = trigger.output[[ asset != base ]].asset; $qt = 10; // Pendent de definició!!! $proces = $args.proces; $idprop = $args.idprop; $generics = var[ $_Portal ][ 'generics' ]; $propostes = var[ $_Portal ][ 'propostes' ]; $entitats = var[ $_Portal ][ 'entitats' ]; $validacions = var[ 'validacions' ] otherwise {}; $convocatories = var[ 'convocatories' ] otherwise {}; $deliberacions = var[ 'deliberacions' ] otherwise {}; $refusos = var[ 'refusos' ] otherwise {}; $_validadores = $generics._Validadores; $validadores = var[ $_validadores ][ 'Validadores' ]; $isox = $validadores.isox; $delegades = $validadores.delegades; // Funcions // Si no s'ha lliurat l'argument especificat bota l'accés $__arg = $arg => $args[ $arg ] otherwise bounce( "Cal proporcionar el valor de: " || $arg ); // Comprovacions // La proposta encara no pot estar validada if ( $validacions[ $idprop ] ) { bounce( 'Ja validada' ); } // La proposta ha d'existir $proposta = $propostes[ $idprop ]; if ( ! $proposta ) { bounce( 'No hi ha cap proposta amb aquesta id' ); } // Processos if ( $proces == 'convocatoria_validadores' ) { $convocs = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; $__isox_aleatori = $x => { $ord_isox_aleatori = number_from_seed( timestamp, array_length( $isox ) ); $isox_seleccionat = $isox[ $ord_isox_aleatori ]; $isox_seleccionat AND $isox_seleccionat.estat == 'habilitat' ? $isox_seleccionat : '' }; $preseleccio_isox = map( $convocs, 12, $__isox_aleatori ); $seleccio_isox = array_length( $preseleccio_isox ) >= 10 ? $preseleccio_isox : $preseleccio_isox || map( $convocs, 12, $__isox_aleatori ); $nombre_entitats = array_length( $delegades ); $__entitat_aleatoria = $x => { $ord_entitat_aleatoria = number_from_seed( timestamp, $nombre_entitats ); $entitat_seleccionada = $delegades[ $ord_entitat_aleatoria ]; $entitat_seleccionada_habilitada = $entitats[ $entitat_seleccionada ] AND $entitats[ $entitat_seleccionada ].estat == 'habilitada'; $entitat_seleccionada_habilitada ? $entitat_seleccionada : '' }; $preseleccio_entitats = map( $convocs, 12, $__entitat_aleatoria ); $seleccio_entitats = array_length( $preseleccio_entitats ) >= 10 ? $preseleccio_entitats : $preseleccio_entitats || map( $convocs, 12, $__entitat_aleatoria ); $__delegada_aleatoria = $x => { $ord_delegada_aleatoria = number_from_seed( timestamp, $generics.Nombre_Delegades ); $seleccio_entitats[ $ord_delegada_aleatoria ] }; $seleccio_delegades = map( $seleccio_entitats, 12, $__delegada_aleatoria ); $nova_convocatoria = { isox: $seleccio_isox, delegades: $seleccio_delegades, temps: timestamp }; $convocatories[ $idprop ] = $nova_convocatoria; } if ( $proces == 'decisio_validacio' ) { $convocatoria = $convocatories[ $idprop ]; $validacio = $validacions[ $idprop ]; $deliberacio = $deliberacions[ $idprop ]; $refus = $refusos[ $idprop ]; // La convocatoria ha d'existir if ( ! $convocatoria ) { bounce( 'No hi ha cap convocatoria amb aquesta id' ); } // Tractament proposta encara pendent if ( $validacio OR $refus ) { bounce( 'Aquesta proposta ja ha estat tractada' ); } $_isox = $convocatoria.isox[ $adr__ ] ? $adr__ : false; $_delegada = $convocatoria.delegades[ $adr__ ] ? $adr__ : false; // adr__ actuant ha estat convocada if ( ! $_isox AND ! $_delegada ) { bounce( 'Adreça no convocada' ); } // adr__ actuant pendent decisió if ( $deliberacio.isox.aprovacions[ $adr__ ] OR $deliberacio.delegades.aprovacions[ $adr__ ] ) { bounce( "Ja hi consta una decisió d'aquesta adreça per a aquesta proposta" ); } $grup = $_isox ? 'isox' : $_delegada ? 'delegades' : bounce( 'error' ); // Deliberació pendent if ( $deliberacio[ $grup ].refusada OR $deliberacio[ $grup ].aprovada ) { bounce( 'Deliberacio de ' || $grup || ' ja enllestida' ); } } }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "if": "{ $proces == 'convocatoria_validadores' }", "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "if": "{ $seleccio_isox[0] }", "address": "{ $seleccio_isox[0] }", "amount": "{ $qt }" }, { "if": "{ $seleccio_isox[1] }", "address": "{ $seleccio_isox[0] }", "amount": "{ $qt }" } ] } }, { "app": "state", "state": "{ response[ 'Procés' ] = $proces; response[ 'Proposta' ] = $idprop; // Registre if ( $proces == 'decisio' ) { if ( $__arg( 'decisio' ) == 'refusada' ) { $deliberacio[ $grup ].refus = $adr__; $deliberacio[ $grup ].refusada = timestamp; $refusos[ $idprop ] = timestamp; response[ 'Validació' ] = 'refusada'; } if ( $__arg( 'decisio' ) == 'aprovada' ) { $deliberacio[ $grup ].aprovacions[] = $adr__; response[ 'Validació de la proposta aprovada per' ] = $adr__; $nombre_aprovacions = $deliberacio[ $grup ].aprovacions; if ( array_length( $nombre_aprovacions == $generics.Nombre_Aprovacions ) ) { $deliberacio[ $grup ].aprovada = timestamp; response[ 'Validació de la proposta aprovada per' ] = $grup; } } if ( $deliberacio.isox.aprovada AND $deliberacio.delegades.aprovada ) { $validacions[ $idprop ] = timestamp; response[ 'Validació' ] = 'aprovada'; } } // Temporalment, per als TESTS!!!............................... if ( $proces == 'validacio_directa_TEST' ) { $validacions[ $idprop ] = timestamp; response[ 'Validació' ] = 'aprovada'; } // -- Nou Portal if ( $args.nou_portal ) { var[ 'anterior_portal' ] = var[ 'nou_portal' ]; var[ 'nou_portal' ] = $args.nou_portal; response[ 'Nou portal de _Validacions ' ] = $args.nou_portal; } // -- Actualització dades if ( $args.copia_dades ) { if ( ! $args.totes ) { $__valvar = $refvar => { var[ $refvar ] = $args[ $refvar ] ? var[ $darrera_versio ][ $refvar ] : {}; }; $refs = [ 'validacions', 'convocatories', 'deliberacions', 'refusos' ]; $valora = map( $refs, 8, $__valvar ); } } else { var[ 'validacions' ] = $validacions; var[ 'convocatories' ] = $convocatories; var[ 'deliberacions' ] = $deliberacions; var[ 'refusos' ] = $refusos; } }" } ] } ]
Technical information
Fees:
9,485 bytes
(452 headers, 9033 payload)
Level:1847586
Witnessed level:1847578
Main chain index:1839687
Latest included mc index:1839686
Status:stable/confirmed/final