5N7DMMFAVGJF5NBZEUU3ZHJPVJT3QR5H
[
"autonomous agent",
{
"init": "{
$nom_AA = 'Portal';
$versio = '0.5';
$AUT_0 = 'C4KIJSUWVM7BGWTLXKX3K4PNRXV7OY4W';
$adr__ = trigger.address;
$args = trigger.data;
$__bota = $txt => bounce ( $nom_AA || ' >>> ' || $txt );
$__autoritzada = ( $x ) => {
$aut = var[ '_AUT_' || $x ];
$aut AND $aut == $adr__
};
if ( ! $args ) { $__bota( ': Cal proporcionar-ne els arguments' ); }
if ( !! $args.ref ) {
if ( ! $args.val )
{ $__bota( ': Cal proporcionar el valor de "val"' ); }
if ( $adr__ != $AUT_0
AND ! $__autoritzada( 'A' )
AND ! $__autoritzada( 'B' )
AND ! $__autoritzada( 'C' )
) { $__bota( 'No autoritzada' ); }
}
// Si existeix una var d'estat amb un valor diferent, es tracta com a proposta
// Es tracta com a confirmació si ja ha estat desada abans com a proposta
// per un AUT diferent a l'actuant i ha transcorregut el lapse de temps establert
if ( !! var[ $args.ref ] AND var[ $args.ref ] != $args.val AND $adr__ != $AUT_0 ) {
$proposta = var[ 'proposta_' || $args.ref ];
if ( !! $proposta AND $proposta.val == $args.val ) {
if ( $proposta.proposant == $adr__ )
{ $__bota( 'Ja hi consta la teva proposta' ); }
if ( timestamp - $proposta.temps > var[ 'lapse_confirmacio' ] )
{ $__bota( 'Encara no es pot confirmar la proposta' ); }
$acc = 'confirmacio';
} else { $acc = 'proposta'; }
} else { $acc = 'acces'; }
$args._Operatius = var[ '_Operatius' ];
$args._Getons = var[ '_Getons' ];
$args._FRO = var[ '_FRO' ];
$args._FOP = var[ '_FOP' ];
$args._FDIP = var[ '_FDIP' ];
$args.id_Estels = var[ 'id_Estels' ];
$args.interval_Cicles = var[ 'interval_Cicles' ];
$args.geto = trigger.output[[ asset != base ]].asset;
$args.qt = trigger.output[[ asset = $args.geto ]];
}",
"messages": [
{
"app": "data",
"payload": "{ $args }"
},
{
"if": "{ $acc == 'acces' }",
"app": "payment",
"payload": {
"asset": "{ $args.geto }",
"outputs": [
{
"address": "{ var[ '_AA_Acces' ] }",
"amount": "{ $args.qt }"
}
]
}
},
{
"if": "{ $acc != 'acces' }",
"app": "state",
"state": "{
if ( $acc == 'confirmacio' ) {
var[ $args.ref ] = $args.val;
response[ 'ref' ] = $args.ref;
response[ 'val' ] = $args.val;
}
if ( $acc == 'proposta' ) {
var[ 'proposta_' || $args.ref ] =
{
val: $args.val,
proposant: $adr__,
temps: timestamp,
};
response[ 'proposta ref' ] = $args.ref;
response[ 'proposta val' ] = $args.val;
response[ 'data mínima per a la confirmació'] =
timestamp_to_string( timestamp + var[ 'lapse_confirmacio' ] , 'datetime' );
}
}"
}
]
}
]
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount