Unit ID
5jPfD4GomBfag4UOs3Ait+WiA4SD2A7YIcFwPXUTcvE=
Received
26.01.2021 18:46:59
Confirmation delay (full node)
3 minutes 44 seconds
Confirmation delay (light node)
5 minutes 52 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 {}; $_estels = $generics._Estels; $dades_accions = $generics._Accions ? var[ $generics._Accions ]: {}; $escala_actual = $dades_accions.escala_actual; // 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._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 = var[ 'portals' ], feed_name = $refval ]] //data_feed[[ oracles = this_address, feed_name = $refval ]] }; $__ordinal = $rf => $ordinals[ $rf ] ? $ordinals[ $rf ] + 1 : 1; // Admin if ( $admin ) { // Autorització if ( $args.admin_geto ) { $ref_geto = $__arg( 'ref_geto' ); // El getó ha d'existir 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 $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 ( ( $__arg( 'ref' ) ) == 'multiple' AND ! $_actuant_es_AUT_000 ) { bounce( 'No autoritzada per a esmena múltiple' ); } } // Validació $validacio_requerida = // _AUT_000 pot saltar-se procés validació mentre no existeixi _AUT_0 ! $_actuant_es_AUT_000 OR ( $_actuant_es_AUT_000 AND $generics._AUT_0 ) // Processos exclosos AND $proces != 'copia_llistat_portals' AND $proces != 'decisio_validacio' 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 || '_temps' ) ) { bounce( "Encara no es pot confirmar la proposta" ); } // La proposta ha de constar com a validada if ( ! $__dada( 'validacio_' || $idprop ) ) { 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": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt }" } ] } } ] }, { "if": "{ $admin AND $proces == 'renovacio_adrs_portal' }", "init": "{ $args.nou_portal = $operacio == 'proposta' ? false : true; }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt }" } ] } }, { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Getons }", "amount": "{ $qt }" } ] } }, { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Validadores }", "amount": "{ $qt }" } ] } }, { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt }" } ] } }, { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ timestamp }", "{ $nova_idprop || '_temps' }": "{ timestamp }" } }, { "app": "state", "state": "{ response[ 'procés' ] = $proces; response[ 'operació' ] = $operacio; var[ 'ordinals' ] = $ordinals; }" } ] }, { "if": "{ $admin AND $proces == 'copia_dades_portal' }", "messages": [ { "app": "state", "state": "{ $portals = var[ $__arg( 'val' )][ 'portals' ]; var[ 'portals' ] = $portals ? $portals || ':' || this_address : this_address; $__copia_dades = $r => { var[ $r ] = var[ $__arg( 'val' )][ $r ] otherwise []; }; $blocs_dades = [ 'generics', 'ordinals', 'entitats', 'refs_getons', 'ids_getons' ]; 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": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Accions }", "amount": "{ $qt }" } ] } }, { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop || '_nom_aa' }": "{ $__arg( 'nom_aa' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }", "{ $nova_idprop || '_temps' }": "{ timestamp }" } }, { "app": "state", "state": "{ 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 || '_ref' }": "{ $__arg( 'ref' ) }", "{ $nova_idprop || '_val' }": "{ $__arg( 'val' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }", "{ $nova_idprop || '_temps' }": "{ timestamp }" } }, { "if": "{ $operacio != 'proposta' }", "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' ]; $valora = 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[ '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": { "{ 'ordinal_' || $proces }": "{ $nou_ordinal }", "{ 'proposta_' || $nova_idprop }": "{ timestamp }" } }, { "if": "{ $operacio != 'confirmacio' }", "app": "data_feed", "payload": { "{ $nova_idprop || '_ref' }": "{ $__arg( 'ref' ) }", "{ $nova_idprop || '_val' }": "{ $__arg( 'val' ) }", "{ $nova_idprop || '_proposant' }": "{ $adr__ }", "{ $nova_idprop || '_receptora' }": "{ $__arg( 'receptora' ) }", "{ $nova_idprop || '_temps' }": "{ timestamp }", "{ $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": "{ $diposit = $dades_accions.diposits[ $__arg( 'ref' ) ]; if ( ! $diposit ) { bounce( ': Dipòsit inexistent' ); } if ( $adr__ != $diposit.dipositant ) { bounce( ": L'adreça receptora ha de ser la dipositant" ); } if ( $__dada( 'conversio_' || $ref ) ) { bounce( ': aquest dipòsit ja ha estat convertit' ); } if ( $diposit.cicle_conversio > $dades_accions.cicle_actual ) { bounce( ": Encara no és l'hora" ); } $unitat = $diposit.geto_diposit == $_estels ? "base" : $_estels; }", "messages": [ { "app": "payment", "payload": { "asset": "{ $unitat }", "outputs": [ { "address": "{ $adr__ }", "amount": "{ $diposit.qt_conversio }" } ] } }, { "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": "{ $retribucions = var[ 'retribucions' ] otherwise {}; if ( $__arg( 'ref' ) == 'aportacio_activacio' ) { $ref_activacio = 'activacio_' || $adr__ || '_en_' || $_estels; $activacio = $dades_accions.activacions[ $ref_activacio ]; $import = $activacio.qt; $escala = $activacio.escala; } else { $contribucio = $dades_accions.contribucions[ $ref ]; if ( ! $contribucio ) { bounce( ': Contribucio inexistent' ); } if ( $adr__ != $contribucio.contribuidora ) { bounce( ": L'adreça receptora ha de ser la contribuidora" ); } $import = $contribucio.qt; $escala = $contribucio.escala; } $ref_retribucio = $args.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": "{ $operacio AND $operacio == 'proposta' }", "init": "{ $args.proces = 'convocatoria_validadores'; }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt }" } ] } } ] }, { "if": "{ $proces == 'decisio_validacio' }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt }" } ] } } ] }, { "if": "{ $proces == 'validacio_directa_TEST' AND $_actuant_es_AUT }", "messages": [ { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Validacions }", "amount": "{ $qt }" } ] } } ] }, { "if": "{ $args.admin.entitats }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop || '_adr' }": "{ $__arg( 'adr' ) }", "{ $nova_idprop || '_nom' }": "{ $__arg( 'nom' ) }", "{ $nova_idprop || '_estat' }": "{ $__arg( 'estat' ) }" } }, { "if": "{ $operacio != 'proposta' }", "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 == 'nou_geto' }", "init": "{ $novaref = 'geto_' || $__ordinal( 'geto' ); }", "messages": [ { "if": "{ $operacio != 'confirmacio' }", "app": "data_feed", "payload": { "{ $novaref || '_proposant' }": "{ $adr__ }", "{ $novaref || '_confirmant' }": "{ $operacio == 'proposta' ? '' : $adr__ }", "{ $novaref || '__FOP' }": "{ $__arg( '_FOP' ) }", "{ $novaref || '__AUT_A' }": "{ $__arg( '_AUT_A' ) }", "{ $novaref || '_factor_conversio' }": "{ $__arg( 'factor_conversio' ) }", "{ $novaref || '_valors_esmenables' }": "{ $__arg( 'valors_esmenables' ) }", "{ $novaref || '_llistats_editables' }": "{ $__arg( 'llistats_editables' ) }", "{ $novaref || '_bloqueig_possible' }": "{ $__arg( 'bloqueig_possible' ) }", "{ $novaref || '_activacions_restringides' }": "{ $__arg( 'activacions_restringides' ) }", "{ $novaref || '_subscripcions_restringides' }": "{ $__arg( 'subscripcions_restringides' ) }", "{ $novaref || '_recepcions_restringides' }": "{ $__arg( 'recepcions_restringides' ) }", "{ $novaref || '_conversions_restringides' }": "{ $__arg( 'conversions_restringides' ) }", "{ $novaref || '_import_activacio' }": "{ $__arg( 'import_activacio' ) }", "{ $novaref || '_import_subscripcio' }": "{ $__arg( 'import_subscripcio' ) }", "{ $novaref || '_import_renovacio' }": "{ $__arg( 'import_renovacio' ) }", "{ $novaref || '_taxa_conversio' }": "{ $__arg( 'taxa_conversio' ) }", "{ $novaref || '_cicles_diposit' }": "{ $__arg( 'cicles_diposit' ) }", "{ $novaref || '_derivacio' }": "{ $__arg( 'derivacio' ) }", "{ $novaref || '_AUT_B' }": "{ $args._AUT_B }", "{ $novaref || '_AUT_C' }": "{ $args._AUT_C }" } }, { "if": "{ $operacio == 'confirmacio' }", "app": "data_feed", "payload": { "{ $__arg( 'ref_geto' ) || '_confirmant' }": "{ $adr__ }" } } ] }, { "if": "{ $admin AND $proces == 'implementacio' }", "init": "{ // La proposta del nou getó ha d'estar confirmada if ( $__dada( $ref_geto || '_confirmant' ) ) { bounce( 'Proposta pendent de confirmació' ); } }", "messages": [ { "if": "{ $operacio == 'proposta' }", "app": "data_feed", "payload": { "{ $nova_idprop }": "{ $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; }" } ] }, { "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 || '_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; }" } ] }, { "if": "{ $args.admin_geto }", "init": "{ $args.operacio = $operacio; $args.idprop = $nova_idprop; }", "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( $ref_geto || '_FOP' ) }", "amount": "{ $qt * $__dada( $ref_geto || 'factor_conversio' ) }" } ] } }, { "app": "data", "payload": "{ $args }" }, { "app": "payment", "payload": { "asset": "{ $_unitat }", "outputs": [ { "address": "{ $generics._Getons }", "amount": "{ $qt }" } ] } } ] } ] } } ]
Technical information
Fees:
22,458 bytes
(452 headers, 22006 payload)
Level:1863973
Witnessed level:1863965
Main chain index:1856063
Latest included mc index:1856062
Status:stable/confirmed/final