Unit ID
V5SrzzWZBTfoCT4QoXc1qSwWCPd7wlD3n3CWxnYR4Yo=
Received
02.02.2021 19:30:23
Confirmation delay (full node)
4 minutes 54 seconds
Confirmation delay (light node)
7 minutes 11 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ó $_actuant_es_AUT_geto = $_actuant_es_AUT AND ! $__dada( $ref_geto || '_AUT_0' ) OR $_actuant_es_AUT AND ! $proces == 'nou_geto' OR $adr__ == $__dada( $ref_geto || '_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 if ( ! $__dada( $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 - $__dada( $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' ); } }", "messages": [ { "app": "payment", "payload": { "asset": "base", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt_registre_DAG }" } ] } }, { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt }" } ] } } ] }, { "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[ $__arg( 'val' )][ $r ] otherwise {}; }; $blocs_dades = [ 'generics', 'ordinals', 'entitats', 'refs_getons', 'ids_getons' ]; $m = map( $blocs_dades, 5, $__copia_dades ); var[ 'versions' ] = $nou_versions; response[ '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( 'nom_aa' ) }", "{ $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 => { $valvar = $args[ $r ] otherwise $generics[ $r ] otherwise '...'; $generics[ $r ] = $valvar; response[ $r ] = $valvar; }; $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( $__arg( '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_activacio = 'activacio_' || $adr__ || '_en_estels'; $import = $__dada_AA( $ref_activacio || '_qt', $versions.accions ); $escala = $__dada_AA( $ref_activacio || '_escala', $versions.accions ); } 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" ); } $import = $__dada_AA( $ref || '_qt', $versions.accions ); $escala = $__dada_AA( $ref || '_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 {}; 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 $__dada( $idprop || 'estat' ), }; } } 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 $__dada( $idprop || 'estat' ); } } 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; }" } ] }, { "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; }" } ] }, { "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:
22,806 bytes
(452 headers, 22354 payload)
Level:1870890
Witnessed level:1870883
Main chain index:1862979
Latest included mc index:1862978
Status:stable/confirmed/final