0

pub fun getAddresses(): {Address: Bool} {
    return Contract.account.borrow<&{Address: Bool}>(from: storage/dict) as! {Address: Bool}

}

In other words, I don’t want to pass back to the caller the reference to the dictionary because then they will be able to modify the actual dictionary object in storage. I just want a copy of the dictionary object returned, but don’t want to create a copy through looping over the address dictionary as that will be computationally expensive… Is there any way to remove the reference?

pho_pho
  • 672
  • 11
  • 30

1 Answers1

1

Have you consider storing a struct in your storage that has this as a field? Then you can get a reference to the struct and then send this field back?

bjartek
  • 929
  • 1
  • 5
  • 11
  • I realised that I was thinking about my data structure wrong, hence why i was having this problem. I re-thought it and this was the solution that I came up with - glad to have it confirmed by the GOAT - thanks Bjarte! – pho_pho Sep 12 '22 at 15:25