Unit ID
oo3W23PDalNtv54rHmKRyjvXbUOcDqQqubYXvJZ5BHM=
Received
22.09.2019 12:30:10
Confirmation delay (full node)
3 minutes 21 seconds
Messages
Definition
Definition: [ "autonomous agent", { "init": "{ $AA_NAME= "HOLAAAA"; // Dynamic Asset Names Autonomous Agent; $AA_OWNER = "O7NYCFUL5XIJTYE3O4MKGMGMTN6ATQAJ"; // could withdraw the dust is calculable. $INSTRUCTIONS = "To add an element at the end of the use 'list_name = <list name>'', 'add = <item name>' + 'value = <itemvalue>'"; // get info from state or input data $list_name = trigger.data.list_name otherwise bounce ("Need 'list = <list_name>'!"); $list_owner = var[$list_name||"_owner"] otherwise trigger.address; $list_count = var[$list_name||"_count"] otherwise 0; $list_public = var[$list_name||"_public"] otherwise $i.public; if (!$list_public) if (trigger.address != $list_owner) bounce ("You don't own this private list"); }", "messages": { "cases": [ { "if": "{ !!trigger.data.add }", "init": "{ $item_key = $list_name||"_"||trigger.data.add; }", "messages": [ { "app": "state", "state": "{ // update list state var[$list_name||"_owner"] = $list_owner; var[$list_name||"_count"] = $list_count + 1; var[$list_name||"_public"] = $list_public; // update last item $last_item = var[$list_name||"_last"]; if (!!$last_item) var[$last_item||"_next"] = $item_key; var[$list_name||"_last"] = $item_key; if ($list_count == 1 ) var[$list_name||"_first"] = $item_key; // add new item at the end of the linked list var[$item_key] = trigger.data.value; var[$item_key||"_previous"] = $last_item; var[$item_key||"_next"] = false; response['message']= $item_key||" added ^^."; }" } ] }, { "if": "{ !!trigger.data.remove }", "init": "{ if (!(var[$list_name])) bounce ("'"||$list_name||"' did not exist !"); $item_key = $list_name||"_"||trigger.data.remove; }", "messages": [ { "app": "state", "state": "{ // update list state var[$list_name||"_count"] = $list_count - 1; // update link in previous item $previous_item = var[$item_key||"_previous"]; var[$previous_item||"_next"] = $next_item; // update link in next item $next_item = var[$item_key||"_next"]; var[$next_item||"_previous"] = $previous_item; // remove item var[$item_key] = false; var[$item_key||"_previous"] = false; var[$item_key||"_next"] = false; response['message']= $item_key||" removed ^^."; }" } ] }, { "if": "{ trigger.data.remove_last }", "init": "{ if (!(var[$list_name])) bounce ("'"||$list_name||"' did not exist !"); if (var[$list_name||"_count"] == 0) bounce ("List is empty!"); }", "messages": [ { "app": "state", "state": "{ // update previous item link $last_item = var[$list_name||"_last"]; $previous_item = var[$last_item||"_previous"]; var[$previous_item||"_next"] = false; // update list state var[$list_name||"_count"] = $list_count - 1; var[$list_name||"_last"] = $previous_item; // remove item var[$last_item||"_previous"] = false; var[$last_item] = false; var[$last_item||"_next"] = false; response['message']= $last_item||" removed ^^."; }" } ] }, { "if": "{ !!trigger.data.insert_first }", "init": "{ $item_key = $list_name||"_"||trigger.data.insert_first; }", "messages": [ { "app": "state", "state": "{ // update list state var[$list_name||"_owner"] = $list_owner; var[$list_name||"_count"] = $list_count + 1; var[$list_name||"_public"] = $list_public; // update first item $first_item = var[$list_name||"_first"]; if (!!$first_item) var[$first_item||"_previous"] = $item_key; var[$list_name||"_first"] = $item_key; // add new item at the beginning of the linked list var[$item_key] = trigger.data.value; var[$item_key||"_previous"] = false; var[$item_key||"_next"] = $first_item; response['message']= $item_key||" added ^^."; }" } ] }, { "if": "{ !!trigger.data.insert }", "init": "{ $item_key = $list_name||"_"||trigger.data.insert; // identify previosu and next items if (!!trigger.data.after) { $previous_item = $list_name||"_"||trigger.data.after; if (!var[$previous_item]) bounce ($previous_item||" do NOT exist !"); $next_item = var[$previous_item||"_next"]; } else { if (!!trigger.data.before) { $next_item = $list_name||"_"||trigger.data.before; if (!var[$next_item]) bounce ($next_item||" do NOT exist !"); $previous_item = var[$next_item||"_previous"]; } else { bounce ("Please, specify 'after' or 'before'"); } } }", "messages": [ { "app": "state", "state": "{ // update list state var[$list_name||"_count"] = $list_count + 1; // update first item $first_item = var[$list_name||"_first"]; if (!!$first_item) var[$first_item||"_previous"] = $item_key; var[$list_name||"_first"] = $item_key; // add new item at the beginning of the linked list var[$item_key] = trigger.data.value; var[$item_key||"_previous"] = false; var[$item_key||"_next"] = $first_item; response['message']= $item_key||" added ^^."; }" } ] }, { "if": "{ trigger.data.delete }", "init": "{ if (!var[$list_name]) bounce ("'"||$i.list_name||"' did not exist at the first place!"); if (var[$list_name||"_count"] > 0) bounce ("List must be empty to be deleted, use 'remove_last' as much as needed"); }", "messages": [ { "app": "state", "state": "{ var[$list_name||"_owner"] = false; var[$list_name||"_count"] = false; var[$list_name||"_public"] = false; response['message']= $list_name||" delete ^^."; }" } ] }, { "messages": [ { "app": "state", "state": "{ bounce ($INSTRUCTIONS);}" } ] } ] } } ]
Technical information
Fees:
8,544 bytes
(353 headers, 8191 payload)
Level:1070480
Witnessed level:1070473
Main chain index:1069246
Latest included mc index:1069244
Status:stable/confirmed/final