Unit ID
0JWPDR2tew5BCPJLM8TIt9p2/KxbCuIQriiW1Ns3Bdk=
Received
03.02.2021 18:39:18
Confirmation delay (full node)
3 minutes 16 seconds
Confirmation delay (light node)
4 minutes 58 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $nom_AA = 'Portal'; $versio = '0.1.2'; $_AUT_000 = 'C4KIJSUWVM7BGWTLXKX3K4PNRXV7OY4W'; // Principals $adr__ = trigger.address; $args = trigger.data; $_unitat = trigger.output[[ asset != base ]].asset; $qt = trigger.output[[ asset = $_unitat ]]; $generics = var[ 'generics' ] otherwise {}; $ordinals = var[ 'ordinals' ] otherwise {}; $refs_getons = var[ 'refs_getons' ] otherwise {}; $ids_getons = var[ 'ids_getons' ] otherwise {}; $versions = []; $versions.portal = var[ 'versions' ] otherwise this_address; $versions.getons = var[ 'versions_getons' ] otherwise $generics._Getons; $versions.accions = var[ 'versions_accions' ] otherwise $generics._Accions; $versions.validacions = var[ 'versions_validacions' ] otherwise $generics._Validacions; $versions.validadores = var[ 'versions_validadores' ] otherwise $generics._Validadores; $qt_registre_DAG = 3000; $_estels = $generics._Estels; $escala_actual = $generics._Accions ? var[ $generics._Accions ][ 'escala_actual' ] : 1; // Abreviacions $admin = $args.admin; $proces = $args.proces; $ref = $args.ref; $idprop = $args.idprop; // Identificacions $_actuant_es_AUT_000 = $adr__ == $_AUT_000; $_actuant_es_AUT = ! $generics OR ( $generics._AUT_A AND $generics._AUT_A == $adr__ ) OR ( $generics._AUT_B AND $generics._AUT_B == $adr__ ) OR ( $generics._AUT_C AND $generics._AUT_C == $adr__ ) OR ( $generics._AUT_0 AND $adr__ == $generics._AUT_0 ) OR ( $_actuant_es_AUT_000 AND ! is_valid_address( $generics._AUT_0 ) ); // Funcions auxiliars // Retorna valor argument lliurat si el troba. Altrament, s'atura $__arg = $arg => $args[ $arg ] otherwise bounce( "Cal proporcionar el valor de: " || $arg ); $__dada = $refval => { data_feed[[ oracles = $versions.portal, feed_name = $refval, ifnone = false ]] }; $__dada_AA = $refval, $vers => { data_feed[[ oracles = $vers, feed_name = $refval, ifnone = false ]] }; $__ordinal = $rf => $ordinals[ $rf ] ? $ordinals[ $rf ] + 1 : 1; // Admin if ( $admin ) { // Autorització if ( $args.admin_geto ) { $ref_geto = $__arg( 'ref_geto' ); // El getó ha de constar com a operatiu if ( ! $refs_getons[ $ref_geto ] ) { bounce( 'Getó inexistent' ); } // Determina si adr__ actuant consta com autoritzada per al getó $_AUT_0 = $__dada( $ref_geto || '_AUT_0' ); $_actuant_es_AUT_geto = $_actuant_es_AUT AND ! $_AUT_0 OR $_actuant_es_AUT AND ! $proces == 'nou_geto' OR $adr__ == $_AUT_0 OR $adr__ == $__dada( $ref_geto || '_AUT_A' ) OR $adr__ == $__dada( $ref_geto || '_AUT_B' ) OR $adr__ == $__dada( $ref_geto || '_AUT_C' ); if ( ! $_actuant_es_AUT_geto ) { bounce( 'No autoritzada per administrar el getó' ); } } else { if ( ! $_actuant_es_AUT ) { bounce( 'No autoritzada' ); } // Excepcionalment per als TESTS if ( $args.ref AND $args.ref == 'multiple' AND ! $_actuant_es_AUT_000 ) { bounce( 'No autoritzada per a esmena múltiple' ); } // _AUT_000 pot saltar-se procés validació mentre no existeixi _AUT_0 $_AUT_0_no_operatiu = ! $generics._AUT_0 OR $generics._AUT_0 == '...'; $excepcio_inicial = $_actuant_es_AUT_000 AND $_AUT_0_no_operatiu; $validacio_requerida = ! $excepcio_inicial AND $proces != 'copia_dades_portal' AND $proces != 'copia_dades_accions' AND $proces != 'generacio_getons'; if ( $validacio_requerida ) { if ( $args.operacio AND $args.operacio == 'confirmacio' ) { // La proposta ha d'existir $temps_idprop = $__dada( $idprop ); if ( ! $temps_idprop ) { bounce( "No hi ha cap proposta amb aquesta ref" ); } // La confirmació l'ha de fer una AUT diferent a la proposant if ( $__dada( $idprop || '_proposant' ) == $adr__ ) { bounce( "El procés de confirmació l'ha d'endegar una altra AUT" ); } // La confirmació només es pot fer quan ha transcorregut el lapse especificat if ( $generics.Lapse > timestamp - $temps_idprop ) { bounce( "Encara no es pot confirmar la proposta" ); } // La proposta ha de constar com a validada if ( ! $__dada_AA( 'validacio_' || $idprop, $versions.validacions ) ) { bounce( "La proposta encara no ha estat validada" ); } $operacio = 'confirmacio'; } else { $nou_ordinal = $__ordinal( $proces ); $ordinals[ $proces ] = $nou_ordinal; $nova_idprop = $proces || '_' || $nou_ordinal; $operacio = 'proposta'; } } else { $operacio = 'drecera'; } } } }", "messages": { "cases": [ { "if": "{ $proces == 'acces_accions' }", "init": "{ $unitat_es_geto = $ids_getons[ $_unitat ]; if ( $_unitat != $_estels AND ( ! $unitat_es_geto OR $unitat_es_geto.estat != 'actiu' ) ) { bounce( 'Getó inexistent o inactiu' ); } $refgeto = $_unitat == $_estels ? 'estels' : $refs_getons[ $_unitat ]; if ( $__arg( 'accio' ) == 'Transfer' ) { $args._receptora = $__arg( 'receptora' ); if ( $__dada_AA( 'subscripcio_' || $args.receptora || '_en_' || $refgeto, $versions.accions ) ) { $percent_derivacio = $__dada_AA( 'subscripcio_' || $adr__ || '_en_' || $refgeto || '_derivacio', $versions.accions ); $derivacio = $qt * $percent_derivacio / 100; $total_particular = $__dada( 'total_derivacions_' || $args.receptora || '_en_' || $refgeto ) + $derivacio; $total_derivacions = $__dada( 'total_derivacions_' || '_en_' || $refgeto ) + $derivacio; $total_FOP = $__dada( 'total_FOP_en_' || $refgeto ) + $derivacio; $args.qt_accio = $qt - $derivacio; } else { $args.qt_accio = $qt; $derivacio = 0; } } else { $total_FOP = $__dada( 'total_FOP_en_' || $refgeto ) + $qt; $args.qt_accio = $qt; } $total_unitat = $__dada( 'total_' || $refgeto ) + $qt; }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt_registre_DAG }" } ] } }, { "if": "{ $args._receptora }", "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $args._receptora }", "amount": "{ $qt - $derivacio }" } ] } }, { "if": "{ $derivacio }", "app": "data_feed", "payload": { "{ 'total_derivacions_' || $args.receptora || '_en_' || $refgeto }": "{ $total_particular }", "{ 'total_derivacions_en_' || $refgeto }": "{ $total_derivacions }", "{ 'total_FOP_en_' || $refgeto }": "{ $total_FOP }", "{ 'total_en_' || $refgeto }": "{ $total_unitat }" } }, { "if": "{ ! $args.receptora }", "app": "data_feed", "payload": { "{ 'total_FOP_en_' || $refgeto }": "{ $total_FOP }", "{ 'total_en_' || $refgeto }": "{ $total_unitat }" } }, { "app": "state", "state": "{ if ( $derivacio ) { response[ 'Total Derivacions en: ' || $refgeto ] = $total_derivacions; response[ 'Total Derivacions de ' || $args.receptora || '_en_' || $refgeto ] = $total_particular; } response[ 'Total en ' || $refgeto ] = $total_unitat; response[ 'procés' ] = $proces; }" } ] }, { "if": "{ $admin AND $proces == 'copia_dades_portal' }", "messages": [ { "app": "state", "state": "{ $versions.portal = var[ $__arg( 'val' )][ 'versions' ]; $nou_versions = $versions.portal ? this_address || ':' || $versions.portal : this_address || ':' || $args.val; $__copia_dades = $r => { var[ $r ] = var[ $args.val ][ $r ] otherwise {}; }; $blocs_dades = [ 'generics', 'ordinals', 'entitats', 'refs_getons', 'ids_getons' ]; $m = map( $blocs_dades, 5, $__copia_dades ); var[ 'versions' ] = $nou_versions; response[ 'procés' ] = $proces; }" } ] }, { "if": "{ $admin AND $proces == 'copia_dades_accions' }", "init": "{ $args.copia_dades = $operacio == 'proposta' ? false : true; }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "if": "{ $operacio != 'proposta' }", "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt_registre_DAG }" } ] } }, { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_nom_aa' }": "{ $__arg( 'nom_aa' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }" } }, { "app": "state", "state": "{ response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; var[ 'ordinals' ] = $ordinals; }" } ] }, { "if": "{ $admin AND $proces == 'nova_versio' }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_nom_aa' }": "{ $__arg( 'nom_aa' ) }", "{ $nova_idprop || '_nova_adr' }": "{ $__arg( '_nova_adr' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }" } }, { "app": "state", "state": "{ if ( $operacio != 'proposta' ) { $nova_adr = $__dada ( $idprop || '_nova_adr' ) otherwise $args.adr; $nom_aa = $__dada ( $idprop || '_nom_aa' ) otherwise $args.nom_aa; $versions[ $nom_aa ] = $nova_adr || ':' || $versions[ $nom_aa ]; var[ 'versions_' || $nom_aa ] = $versions[ $nom_aa ]; response[ 'versions' || $nom_aa ] = $versions[ $nom_aa ]; } response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; var[ 'ordinals' ] = $ordinals; }" } ] }, { "if": "{ $admin AND $proces == 'esmena_generics' }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_ref' }": "{ $__arg( 'ref' ) }", "{ $nova_idprop || '_val' }": "{ $__arg( 'val' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }" } }, { "app": "state", "state": "{ if ( $operacio == 'drecera' ) { if ( $ref == 'multiple' ) { $__resp = $r => { $generics[ $r ] = $args[ $r ] otherwise $generics[ $r ] otherwise '...'; //response[ $r ] = $generics[ $r ]; }; $refs_generics = [ '_Accions', '_Getons', '_Validacions', '_Validadores', '_FRO', '_Estels', 'Interval', 'Lapse', 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', '_AUT_0', '_AUT_A', '_AUT_B', '_AUT_C' ]; $m = map( $refs_generics, 22, $__resp ); } else { $generics[ $__arg( 'ref' ) ] = $__arg( 'val' ); $nova_ref = $ref; $nou_val = $args.val; } } else if ( $operacio == 'confirmacio' ) { $nova_ref = $__dada( $idprop || '_ref' ); $nou_val = $__dada( $idprop || '_val' ); $generics[ $nova_ref ] = $nou_val; response[ 'proposta' ] = $idprop; } if( $nova_ref ) { response[ 'nova ref' ] = $nova_ref; response[ 'nou val' ] = $nou_val; } response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; var[ 'generics' ] = $generics; var[ 'ordinals' ] = $ordinals; }" } ] }, { "if": "{ $admin AND $proces == 'assignacio' }", "init": "{ $unitat = $__dada( $idprop || '_unitat' ) otherwise $args.unitat; $qt_assignacio = $__dada( $idprop || '_qt' ) otherwise $args.qt; $receptora = $__dada( $idprop || '_receptora' ) otherwise $args.receptora; }", "messages": [ { "if": "{ $operacio != 'proposta' }", "app": "payment", "payload": { "asset": "{ $unitat }", "outputs": [ { "address": "{ $receptora }", "amount": "{ $args.qt }" } ] } }, { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ 'proposta_' || $nova_idprop }": "{ timestamp }" } }, { "if": "{ $operacio != 'confirmacio' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_ref' }": "{ $__arg( 'ref' ) }", "{ $nova_idprop || '_val' }": "{ $__arg( 'val' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }", "{ $nova_idprop || '_receptora' }": "{ $__arg( 'receptora' ) }", "{ $nova_idprop || '_resolucio' }": "{ $__arg( 'resolucio' ) }", "{ $nova_idprop || '_requeriment' }": "{ $__arg( 'requeriment' ) }", "{ $nova_idprop || '_qt' }": "{ $__arg( 'qt' ) }", "{ $nova_idprop || '_unitat' }": "{ $__arg( 'unitat' ) }" } }, { "if": "{ $operacio == 'confirmacio' OR $operacio == 'drecera' }", "app": "data_feed", "payload": { "{ 'confirmacio_' || $nova_idprop }": "{ timestamp }" } }, { "app": "state", "state": "{ response[ 'proposta' ] = $nova_idprop; response[ 'qt' ] = $qt_assignacio; response[ 'receptora' ] = $receptora; response[ 'unitat' ] = $unitat; response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; var[ 'ordinals' ] = $ordinals; }" } ] }, { "if": "{ $proces == 'conversio' }", "init": "{ $import = $__dada_AA( $__arg( 'ref' ) || '_qt', $versions.accions ); if ( ! $__dada_AA( $ref, $versions.accions ) ) { bounce( ': Dipòsit inexistent' ); } if ( $adr__ != $__dada_AA( $ref || '_dipositant', $versions.accions ) ) { bounce( ": L'adreça receptora ha de ser la dipositant" ); } if ( $__dada( 'conversio_' || $ref ) ) { bounce( ': aquest dipòsit ja ha estat convertit' ); } $cicle_conversio = $__dada_AA( $ref || '_cicle_conversio', $versions.accions ); $cicle_actual = var[ $generics._Accions ][ 'cicle_actual' ]; if ( $cicle_conversio > $cicle_actual ) { bounce( ": Encara no és l'hora" ); } $unitat = $__dada_AA( $ref || '_geto_diposit', $versions.accions ) == $_estels ? "base" : $_estels; }", "messages": [ { "app": "payment", "payload": { "asset": "{ $unitat }", "outputs": [ { "address": "{ $adr__ }", "amount": "{ $__dada_AA( $ref || 'qt_conversio', $versions.accions ) }" } ] } }, { "app": "data_feed", "payload": { "{ 'conversio_' || $ref || '_qt' }": "{ $qt }", "{ 'conversio_' || $ref || '_unitat' }": "{ $unitat }" } }, { "app": "state", "state": "{ //response[ 'Conversió realitzada' ] = $ref; response[ 'procés' ] = $proces; }" } ] }, { "if": "{ $proces == 'retribucio' }", "init": "{ if ( $__arg( 'ref' ) == 'aportacio_activacio' ) { $ref_causa = 'activacio_' || $adr__ || '_en_estels'; } else { if ( ! $__dada_AA( $ref, $versions.accions ) ) { bounce( ': Contribucio inexistent' ); } if ( $adr__ != $__dada_AA( $ref || '_contribuidora', $versions.accions ) ) { bounce( ": L'adreça receptora ha de ser la contribuidora" ); } $ref_causa = $ref; } $import = $__dada_AA( $ref_causa || '_qt', $versions.accions ); $escala = $__dada_AA( $ref_causa || '_escala', $versions.accions ); $ref_retribucio = $ref || '_' || $escala_actual; if ( $__dada( 'retribucio_' || $ref_retribucio ) ) { bounce( ": aquesta ja ha estat retribuïda per a l'escala actual" ); } // Cal que s'hagi produït un salt d'escala if ( $escala_actual == $escala ) { bounce ( $nom_AA || ": Encara no és l'hora" ); } // Determina la qt de la retribucio $qt_retribucio = $import * ( $escala_actual - $escala ); }", "messages": [ { "app": "payment", "payload": { "asset": "{ $_estels }", "outputs": [ { "address": "{ $adr__ }", "amount": "{ $qt_retribucio }" } ] } }, { "app": "data_feed", "payload": { "{ 'retribucio_' || $ref || '_qt' }": "{ $qt_retribucio }", "{ 'retribucio_' || $ref || '_receptora' }": "{ $adr__ }" } }, { "app": "state", "state": "{ //response[ 'Retribució realitzada' ] = $ref_retribucio; response[ 'procés' ] = $proces; }" } ] }, { "if": "{ $admin AND $proces == 'convocatoria_validadores' }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt_registre_DAG }" } ] } } ] }, { "if": "{ $proces == 'decisio_validacio' }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt_registre_DAG }" } ] } } ] }, { "if": "{ $proces == 'validacio_directa_TEST' AND $_actuant_es_AUT }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt_registre_DAG }" } ] } } ] }, { "if": "{ $admin AND $args.admin_entitats }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_adr' }": "{ $__arg( 'adr' ) }", "{ $nova_idprop || '_nom' }": "{ $__arg( 'nom' ) }", "{ $nova_idprop || '_estat' }": "{ $__arg( 'estat' ) }" } }, { "app": "state", "state": "{ $entitats = var[ 'entitats' ] otherwise {}; $estat_prop = $__dada( $idprop || '_estat' ); if ( $proces == 'nova_entitat' ) { if ( $entitats[ $args.adr ] ) { bounce( "Ja hi ha una entitat amb aquesta adreça" ); } if ( $entitats[ $args.adr ].nom == $__arg( 'nom' ) ) { bounce( "Ja hi ha una entitat amb aquest nom" ); } if ( $operacio != 'proposta' ) { $adr_entitat = $args.adr otherwise $__dada( $idprop || '_adr' ); $entitats[ $adr_entitat ] = { nom: $args.nom otherwise $__dada( $idprop || '_nom' ), estat: $args.estat otherwise $estat_prop, }; } } if ( $proces == 'nou_estat_entitat' ) { if ( ! $entitats[ $args.adr ] ) { bounce( "No hi ha cap entitat amb aquesta adreça" ); } if ( $operacio != 'proposta' ) { $entitats[ $args.adr ].estat = $args.estat otherwise $estat_prop; } } var[ 'entitats' ] = $entitats; var[ 'ordinals' ] = $ordinals; response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; }" } ] }, { "if": "{ $admin AND $proces == 'implementacio_geto' }", "init": "{ // La proposta del nou getó ha d'estar confirmada if ( $__dada_AA( $ref_geto || '_confirmant', $versions.getons ) ) { bounce( 'Proposta pendent de confirmació' ); } }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_ref' }": "{ $ref_geto }" } }, { "if": "{ $operacio != 'proposta' }", "app": "asset", "payload": { "cap": "{ $args.cap otherwise 1e9 }", "is_private": false, "is_transferrable": true, "auto_destroy": "{ !! $args.auto_destroy }", "fixed_denominations": false, "issued_by_definer_only": true, "cosigned_by_definer": false, "spender_attested": false } }, { "if": "{ $operacio != 'proposta' }", "app": "state", "state": "{ $refs_getons[ response_unit ] = $ref_geto; $ids_getons[ $ref_geto ] = response_unit; var[ 'ids_getons' ] = $ids_getons; var[ 'refs_getons' ] = $refs_getons; response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; }" } ] }, { "if": "{ $admin AND $proces == 'baixa_geto' }", "init": "{ // El getó ha d'existir if ( ! $refs_getons[ $__arg( 'ref_geto' ) ] ) { bounce( 'Getó inexistent' ); } }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_geto' }": "{ $ref_geto }" } }, { "if": "{ $operacio != 'proposta' }", "app": "state", "state": "{ delete( $ids_getons, $ref_geto ); delete( $refs_getons, $refs_getons[ $ref_geto ] ); var[ 'refs_getons' ] = $refs_getons; var[ 'ids_getons' ] = $ids_getons; response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; }" } ] }, { "if": "{ $args.admin_geto }", "init": "{ $args.operacio = $operacio; $args.idprop = $nova_idprop; $args.nougeto = $proces == 'nou_geto' ? 'geto_' || $__ordinal( 'geto' ) : ''; }", "messages": [ { "if": "{ $proces == 'emissio_getons' }", "init": "{ if ( $_unitat != $_estels ) { bounce( 'Cal aportar-hi estels' ); } if ( $qt < $generics.Generacio_Minima ) { bounce( 'Cal aportar-hi si més no ' || $generics.Generacio_Minima || ' estels' ); } }", "app": "payment", "payload": { "asset": "{ $ids_getons[ $ref_geto ] }", "outputs": [ { "address": "{ $__dada_AA( $ref_geto || '_FOP', $versions.getons ) }", "amount": "{ $qt * $__dada_AA( $ref_geto || 'factor_conversio', $versions.getons ) }" } ] } }, { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Getons }", "amount": "{ $qt_registre_DAG }" } ] } } ] } ] } } ]
Technical information
Fees:
25,223 bytes
(452 headers, 24771 payload)
Level:1871883
Witnessed level:1871876
Main chain index:1863972
Latest included mc index:1863971
Status:stable/confirmed/final