Can we use stored object id's as a function parameter to access those objects?

In my nft contract I have two shared list objects. like →

struct ListA has key{
id: UID,
list: Table<String, bool>
}

struct ListB has key{
id: UID,
list: Table<String, bool>
}

I have another shared object to store the id’s of listA and listB. like →

struct ListId has key {
id: UID,
list_A: ID,
list_B: ID,
}

now in the mint function I want to access the listA and ListB objects from the stored Id’s and update values of those objects .
fun mint( list_id: &mut ListID){
//Update table of ListA objects using the ListA object Id’s stored in list_id


}

Is it possible to do something like this in SUI or what is the correct approach or syntax ?

3 Likes

Hey @afridi099, direct access to objects by ID is not supported in the current version of the Sui Move.
After obtaining the ID of the list_A held in the ListId, pass the ListA object.

    public fun listA(list_id: &ListId): ID {
        list_id.list_A
    }
    
    public fun mint(listA: &mut ListA, key: String, value: bool) {
        table::add(&mut listA.list, key, value);
    }