1

When using Ink to store data in a Mapping with a tuple Key, how do you iterate through all the elements in a tuple?

thanks,

3
  • Can you provide an example?
    – Bruno
    Sep 6, 2022 at 19:35
  • yes. as in the erc721 example. operator_approvals: Mapping<(AccountId, AccountId), ()> Sep 6, 2022 at 21:24
  • so for each account there are many operators accounts. how to iterate through the operators for each main account. Sep 6, 2022 at 21:36

2 Answers 2

1

Looping through tuples is not ideal (to put it lightly) since they are not heterogeneous.

You could tackle this in two ways:

0

As per this issue, right now it can't possible to iterate over storage.

1
  • so would you need to store another mapping of tuples that maps to an array of Ids for each element in the tuple? Sep 26, 2022 at 2:44

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.