0

I am trying to write a simple contract in which I am using set of records as storage.

type data = {
    message : string,
    did: address
};

type parameter =
| ["Published"]
| ["Revoked"];

type storage = set<data>;
type return_ = [list <operation>, storage];
let store: storage = Set.empty;

/* Two entrypoints */
const published = ([store] : [storage]) : storage => {
    const entry = {message: "Credentials for has been published to the blockchain", did: Tezos.get_source()};
    Set.add(entry, store);
    return store;
};
const revoked = ([store] : [storage]) : storage => {
    const entry = {message: "Credentials for has been revoked", did: Tezos.get_source()};
    Set.add(entry, store);
    return store;
};

But I am getting the below error in line

Set.add(entry, store)

Does anyone know what is issue here ?

Invalid type(s) Cannot unify set (record[did -> address , message -> string]) with unit.

2
  • Is it JsLigo syntax? Maybe Set.add returns a new modified set (ie. store) like in functional programming, not modifying the provided store in place?
    – iguerNL
    Oct 5, 2022 at 18:56
  • Yes, It was resolved. Set.add returns a new modified set and doesn't modify in place, so i had to create a new set and return that. Oct 6, 2022 at 12:44

0

Your Answer

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

Browse other questions tagged or ask your own question.