This is unrelated to keys, the issue is the _1
selector which is only defined for tuples up to length 5. If you need more, you have 3 main options:
- Define your own record type instead of using tuples. This can be a lot easier to understand since you can give sensible names to the fields instead of just relying on numbers. So this is the option I’d usually recommend. For this simple example you don’t actually need a separate key type since your key includes all fields from
Example
but given that’s usually not the case, I’ve defined a separate type in the example to see how it works in general.
Full example:
data ExampleKey = ExampleKey with
party1 : Party
party2 : Party
party3 : Party
id1 : Text
id2 : Text
id3 : Text
template Example
with
party1: Party
party2: Party
party3: Party
id1: Text
id2: Text
id3: Text
where
signatory party1
key ExampleKey party1 party2 party3 id1 id2 id3 : ExampleKey
maintainer key.party1
- Group your tuple into smaller tuples, e.g., one for parties and one for the text fields.
template Example
with
party1: Party
party2: Party
party3: Party
id1: Text
id2: Text
id3: Text
where
signatory party1
key ((party1, party2, party3), (id1, id2, id3)) : ((Party, Party, Party), (Text, Text, Text))
maintainer key._1._1
- Use pattern matching instead of selecting via
_1
template Example
with
party1: Party
party2: Party
party3: Party
id1: Text
id2: Text
id3: Text
where
signatory party1
key (party1, party2, party3, id1, id2, id3) : (Party, Party, Party, Text, Text, Text)
maintainer case key of (p, _, _, _, _, _) -> p
Hope that helps!