| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{\r |
| 5 | $nom_AA = 'Getons';\r |
| 6 | |
| 7 | |
| 8 | $_Portal = trigger.address; |
| 9 | if ( $_Portal != trigger.address ) bounce( 'Portal no reconegut' );\r |
| 10 | \r |
| 11 | |
| 12 | $args = trigger.data;\r |
| 13 | $adr__ = trigger.initial_address;\r |
| 14 | $idgeto = trigger.output[[ asset != base ]].asset;\r |
| 15 | $dades = $args.dades otherwise {};\r |
| 16 | \r |
| 17 | $__dada = $refval => {\r |
| 18 | data_feed[[ oracles = $args._Registre, feed_name = $refval, ifnone = false ]]\r |
| 19 | };\r |
| 20 | \r |
| 21 | |
| 22 | $proces = $args.proces;\r |
| 23 | $operacio = $args.operacio;\r |
| 24 | $idprop = $args.idprop;\r |
| 25 | $nova_idprop = $args.nova_idprop;\r |
| 26 | $ref = $args.ref;\r |
| 27 | $val = $args.val;\r |
| 28 | \r |
| 29 | |
| 30 | $__arg = $arg =>\r |
| 31 | $args[ $arg ] otherwise\r |
| 32 | bounce( "Cal proporcionar el valor de: " || $arg );\r |
| 33 | \r |
| 34 | $geto = $__arg( 'geto' );\r |
| 35 | \r |
| 36 | if ( $proces == 'nou_definidor_geto' ) {\r |
| 37 | $definidors_esmenables = \r |
| 38 | 'taxa_conversio, derivacio, import_activacio, ' ||\r |
| 39 | 'import_subscripcio, import_renovacio, ' ||\r |
| 40 | 'cicles_diposit, _AUT_A, _AUT_B, _AUT_C';\r |
| 41 | \r |
| 42 | if ( $operacio == 'proposta' ) {\r |
| 43 | $refdef = $ref otherwise 'cap';\r |
| 44 | if ( ! contains( $definidors_esmenables, $refdef ) )\r |
| 45 | bounce( 'Definidor inexistent o no esmenable' );\r |
| 46 | \r |
| 47 | if ( $__dada( $geto || '_redefinible') < 1 )\r |
| 48 | bounce( "Els valors definidors d'aquest getó no són esmenables" );\r |
| 49 | \r |
| 50 | $dades[ $nova_idprop || '_geto' ] = $geto;\r |
| 51 | $dades[ $nova_idprop || '_ref' ] = $__arg( 'ref' );\r |
| 52 | $dades[ $nova_idprop || '_val' ] = $__arg( 'val' );\r |
| 53 | }\r |
| 54 | if ( $operacio == 'confirmacio' ) {\r |
| 55 | $refg = $__dada( $idprop || '_geto' );\r |
| 56 | $refval = $__dada( $idprop || '_ref' );\r |
| 57 | $dades[ $refg || '_' || $refval ] = $__dada( $idprop || '_val' );\r |
| 58 | }\r |
| 59 | if ( $operacio == 'drecera' ) {\r |
| 60 | $dades[ $geto || '_' || $__arg( 'ref' ) ] = $__arg( 'val' );\r |
| 61 | }\r |
| 62 | }\r |
| 63 | \r |
| 64 | if ( $proces == 'capacitacio' ) {\r |
| 65 | $accio_restringida =\r |
| 66 | $__dada( $geto || '_' || to_lower ( $__arg( 'accio' ) ) || 'ns_restringides') otherwise -1;\r |
| 67 | \r |
| 68 | if ( $accio_restringida < 1 )\r |
| 69 | bounce( 'Acció no restringible per a aquest getó' );\r |
| 70 | \r |
| 71 | $ord_capacitacio = 'capacitacio_' || $args.ordinal_proces;\r |
| 72 | \r |
| 73 | if ( $operacio == 'proposta' ) {\r |
| 74 | $dades[ $nova_idprop || '_geto' ] = $geto;\r |
| 75 | $dades[ $nova_idprop || '_accio' ] = $__arg( 'accio' );\r |
| 76 | $dades[ $nova_idprop || '_capacitada' ] = $__arg( 'adr' );\r |
| 77 | $dades[ $nova_idprop || '_estat' ] = $__arg( 'estat' );\r |
| 78 | }\r |
| 79 | if ( $operacio == 'confirmacio' ) {\r |
| 80 | $get = $__dada( $idprop || '_geto' );\r |
| 81 | $acc = $__dada( $idprop || '_accio' );\r |
| 82 | $adr = $__dada( $idprop || '_capacitada' );\r |
| 83 | $ref_capacitacio = $get || '_' || $acc || '_' || $adr;\r |
| 84 | $dades[ $ref_capacitacio ] = $ord_capacitacio;\r |
| 85 | $dades[ $ord_capacitacio || '_estat' ] = $__dada( $idprop || '_estat' );\r |
| 86 | }\r |
| 87 | if ( $operacio == 'drecera' ) {\r |
| 88 | $ref_capacitacio =\r |
| 89 | $geto || '_' || $__arg( 'accio' ) || '_' || $__arg( 'adr' );\r |
| 90 | $dades[ $ref_capacitacio ] = $ord_capacitacio;\r |
| 91 | $dades[ $ord_capacitacio || '_estat' ] = $__arg( 'estat' );\r |
| 92 | }\r |
| 93 | }\r |
| 94 | \r |
| 95 | $registre = {};\r |
| 96 | $registre.dades = $dades;\r |
| 97 | }", |
| 98 | "messages": [ |
| 99 | { |
| 100 | "app": "data", |
| 101 | "payload": "{ $registre || $args }" |
| 102 | }, |
| 103 | { |
| 104 | "app": "payment", |
| 105 | "payload": { |
| 106 | "asset": "base", |
| 107 | "outputs": [ |
| 108 | { |
| 109 | "address": "{ $args._Registre }", |
| 110 | "amount": "{ $__dada( 'Provisio' ) }" |
| 111 | } |
| 112 | ] |
| 113 | } |
| 114 | }, |
| 115 | { |
| 116 | "app": "state", |
| 117 | "state": "{\r |
| 118 | response[ 'proces' ] = $proces;\r |
| 119 | response[ 'operacio' ] = $operacio;\r |
| 120 | }" |
| 121 | } |
| 122 | ] |
| 123 | } |
| 124 | ] |