I'm having problems with liquidity syntax... (I'm using the online liquidity-lang editor).
I'm trying to make a simple smart contract that adds items with history, think of it as a maintenance log for vehicles.
I'd like to add a ton of different features, like transferability, ownership, security, I'm even considering saving small pics of the items as Byte64 strings.... but I'm stuck.
What am I missing? I get an unexplained "Syntax error" on the last line.
Here's the code that's bugging me right now...
type event = {
date: timestamp;
value_str: string option;
value_int: int option;
}
type item = {
itemName: string;
history: event list;
}
type archive = (string, item) big_map
(*type owner = {
ownerName: string;
address: address;(* To be compared with Current.source *)
ownedItems: (string, timestamp) map;
}*)
type storage = {
archive: archive;
}
let%init storage = {
archive = BigMap [];
}
let%entry main
(item_id, item)
storage =
let arch = Map.add item_id item storage.archive in
let storage = storage.archive <- arch in
[], storage
let%entry addEvent
(item_id, event)
storage =
let storage = match Map.find item_id storage.archive with
| None ->
failwith("Item not found", item_id)
| Some found_id ->
let new_history = event :: found_id.history in
let new_item = found_id.history <- new_history in
let new_archive = Map.update item_id new_item storage.archive in
let storage = storage.archive <- new_archive in
[], storage