Hello! I’m trying to run a command in a function that looks something like this:
(Correct keys are generated but I’m replacing in the example with *_id just for simplicity.)
decimal_values <- forA object.child_ids
\child_id -> do
(_, child) <- fetchByKey @ChildContract child_id
DA.Optional.whenSome(DA.List.elemIndex resource_id child.resource_ids)
\_ -> do
(_, resource) <- fetchByKey @ResourceContract resource_id
return resource.decimal_value
return 0.0
return (sum decimal_values)
I get the error:
• Couldn't match type ‘Numeric 10’ with ‘()’
arising from a functional dependency between:
constraint ‘DA.Internal.Record.HasField
"decimal_value" ResourceContract ()’
arising from a use of ‘getField’
instance ‘DA.Internal.Record.HasField
"decimal_value" ResourceContract Decimal’
at <no location info>
I’ve been stuck at this for a little while and I’m unsure what is going on. Can I ask for some guidance on this please? Thank you!
Basically what I’m trying to do is to query a few levels down and check whether certain resource exists, and if it does, get a decimal value from it and aggregate those decimal values across all the resources we find.