JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
[
"autonomous agent",
{
"init": "{
$nom_AA = 'Portal';
$versio = '0.6';
$_AUT_000 = 'C4KIJSUWVM7BGWTLXKX3K4PNRXV7OY4W';
$adr__ = trigger.address;
$args = trigger.data;
// Funcions auxiliars
$__bota = $txt => bounce ( $nom_AA || ' >>> ' || $txt );
// Si no s'ha lliurat l'argument especificat bota l'accés
$__arg = $arg =>
$args[ $arg ] ?
$args[ $arg ] :
$__bota( 'Cal proporcionar el valor de: ' || $arg );
$__autoritzada = ( $x ) => {
$aut = var[ '_AUT_' || $x ];
$aut AND $aut == $adr__
};
if ( ! $args ) { $__bota( ': Cal proporcionar-ne els arguments' ); }
$args._Portal = this_address;
$args._FOP = var[ '_FOP' ];
$args._Estels = var[ '_Estels' ];
$args.geto = trigger.output[[ asset != base ]].asset;
$args.qt = trigger.output[[ asset = $args.geto ]];
if ( !! $args.admin ) {
$_a = $__arg( 'ref' );
$_b = $__arg( 'val' );
if ( $adr__ != $_AUT_000
AND ! $__autoritzada( '0' )
AND ! $__autoritzada( 'A' )
AND ! $__autoritzada( 'B' )
AND ! $__autoritzada( 'C' )
) { $__bota( 'No autoritzada' ); }
// _AUT_000 pot saltar-se el tràmit mentre no existeixi _AUT_0
$es_AUT_000 = $adr__ == $_AUT_000;
if ( ! $es_AUT_000 OR ( !! $es_AUT_000 AND !! var[ '_AUT_0' ] ) ) {
// Es tracta com a confirmació si s'hi proporciona la id de la proposta
if ( $args.ref == 'id_proposta' ) {
$proposta = var[ $args.val ];
// La proposta existeix
if ( ! $proposta )
{ $__bota( 'No hi ha cap proposta amb aquesta id' ); }
// El valor actual i el de la proposta no coincideixen
if ( var[ $proposta.ref ] == $proposta.val )
{ $__bota( 'El valor actual coincideix amb el de la proposta' ); }
// L'ordinal de la proposta ha de coincidir amb el de la darrera
if ( $proposta.ordinal != var[ 'ordinal_proposta_' || $proposta.ref ] )
{ $__bota( 'Ref incorrecta' ); }
// La confirmació l'ha de fer una AUT diferent a la proposant
if ( $proposta.proposant == $adr__ )
{ $__bota( 'Ja hi consta la teva proposta' ); }
// La confirmació només es pot fer quan ha transcorregut el lapse especificat
if ( timestamp - $proposta.temps > var[ 'Lapse' ] )
{ $__bota( 'Encara no es pot confirmar la proposta' ); }
// La proposta ha de constar com a validada a _Validacions
if ( ! var[ $args._Validacions ][ $args.val ] )
{ $__bota( 'Encara no ha estat validada' ); }
$acc = 'confirmacio';
} else { $acc = 'proposta'; }
} else { $acc = 'confirmacio'; }
} else { $acc = 'acces'; }
}",
"messages": [
{
"app": "data",
"payload": "{ $args }"
},
{
"if": "{ ! $args.admin }",
"app": "payment",
"payload": {
"asset": "{ $args.geto }",
"outputs": [
{
"address": "{ var[ '_Acces' ] }",
"amount": "{ $args.qt }"
}
]
}
},
{
"if": "{ !! $args.admin }",
"app": "state",
"state": "{
if ( $acc == 'confirmacio' ) {
var[ $args.ref ] = $args.val;
response[ 'ref' ] = $args.ref;
response[ 'val' ] = $args.val;
}
if ( $acc == 'proposta' ) {
$ref_ordinal = 'ordinal_proposta_' || $args.ref;
$ordinal = var[ $ref_ordinal ];
$nou_ordinal = ! $ordinal ? 1 : $ordinal + 1;
var[ $ref_ordinal ] = $nou_ordinal;
$id_proposta = 'proposta_' || $args.ref || '_' || $nou_ordinal;
var[ $id_proposta ] =
{
ref: $args.ref,
val: $args.val,
ordinal: $nou_ordinal,
proposant: $adr__,
temps: timestamp,
};
response[ 'proposta' ] = $id_proposta;
response[ 'proposta ref' ] = $args.ref;
response[ 'proposta val' ] = $args.val;
response[ 'timestamp' ] = timestamp;
response[ 'lapse' ] = var[ 'Lapse' ];
response[ 'suma' ] = timestamp + var[ 'Lapse' ];
response[ 'data' ] = timestamp_to_string( timestamp );
response[ 'data per a la confirmació'] =
timestamp_to_string( timestamp + var[ 'Lapse' ] );
}
response[ 'acc' ] = $acc;
}"
}
]
}
]
- MCI: 1777786
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"proposta": "proposta_Lapse_1",
"proposta ref": "Lapse",
"proposta val": 33000,
"timestamp": 1606933399,
"lapse": 2000,
"suma": 1606935399,
"data": "2020-12-02T18:23:19Z",
"data per a la confirmació": "2020-12-02T18:56:39Z",
"acc": "proposta"
}
}
- MCI: 1777744
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"ref": "_Validacions",
"val": "3SBX5IZMQAQQYHAD4EH2XWY5GVFG7Y6C",
"acc": "confirmacio"
}
}
- MCI: 1777358
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"ref": "_Validacions",
"val": "P3FDSWMIH6BXDNZLKDW5WOQDMQ7NX4WT",
"acc": "confirmacio"
}
}
- MCI: 1777154
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"proposta": "proposta__AA_Acces_1",
"proposta ref": "_AA_Acces",
"proposta val": "BBCXVYRDHZH2MDFYMUD6BYM6A2WRYID6",
"timestamp": 1606903332,
"lapse": 2000,
"suma": 1606905332,
"data": "2020-12-02T10:02:12Z",
"data per a la confirmació": "2020-12-02T10:35:32Z",
"acc": "proposta"
}
}
- MCI: 1775880
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"ref": "Lapse",
"val": 2000,
"acc": "confirmacio"
}
}
- MCI: 1775878
- Not bounced
- Response unit:
- Response: {
"responseVars": {
"ref": "_AUT_A",
"val": "GIIYFJXPZW3KH5MPQKRLZTWO4LIXX25R",
"acc": "confirmacio"
}
}
Show transactions in assets:
No transactions found, it may be worth changing the filter
Unit ID
Date
From
Direction
To
Amount
02.12.2020 18:23:19
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
out
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
02.12.2020 18:23:19
in
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
02.12.2020 18:23:19
in
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
02.12.2020 18:05:20
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
out
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
02.12.2020 18:05:20
in
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
02.12.2020 18:05:20
in
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
02.12.2020 12:05:31
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S
out
JM6HQKOFB2JNNEMIILKV6QOXLCGCRZ6S