1

I'm using CameLIGO and want to add a record to a map. I keep getting this error:

Error: ligo: : Parse error in file "tmp-1lMUlWlg5fktI.ligo", line 21, characters 45-46, after "{" and before "}":
      8: <syntax error> {}

I can't figure out the correct structure for a record?

type ipfsHash = string
type artist = address
type artworkId = string

type artists_storage = (artist, ipfsHash) map
type artwork = {
  artist: artist;
  owner : address;
  ipfsArtworkAddress: string;
}

type artwork_storage = (artworkId, artwork) map

type action =
| Register of ipfsHash

let registerArtist (store, ipfsHash : artists_storage * ipfsHash) : artists_storage = 
  Map.update(Tezos.self_address : artist) (Some (ipfsHash)) store

// errors ->
let createArtwork (store, id, ihash : artwork_storage * artworkId * ipfsHash) : artwork_storage =
  Map.update(id: artworkId) (Some (artwork: {
    artist = Tezos.self_address;
    owner = Tezos.self_address;
    ipfsArtworkAddress = ihash;
  }) store

let main (p, artists: action * artists_storage) =
 let storage =
   match p with
   | Register h -> registerArtist (artists, h)
 in ([] : operation list), artists

1 Answer 1

2

Here is the corrected version of createArtwork:

let createArtwork (store, id, ihash : artwork_storage * artworkId * ipfsHash) : artwork_storage =
  Map.update (id : artworkId) (Some ({
    artist = Tezos.self_address;
    owner = Tezos.self_address;
    ipfsArtworkAddress = ihash;
  } : artwork)) store

You had switched place on the actual record and the type annotation (: artwork), and a parenthesis was missing. Also, in this case the type annotation on the record is not necessary: it is only necessary for empty lists, sets and maps AFAIK.

1
  • Yesss!! Thank you. I see now! Mar 20, 2020 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.