Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Sep 19, 2024
1 parent 8188c7e commit d166306
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion core/services/relay/evm/chain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,35 @@ func (cr *chainReader) QueryKey(
return nil, err
}

return binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, sequenceDataType)
_, isValue := sequenceDataType.(*values.Value)
if !isValue {
return binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, sequenceDataType)
} else {
dataTypeFromReadIdentifier, err := cr.CreateContractType(contract.ReadIdentifier(filter.Key), false)
if err != nil {
return nil, err
}

sequence, err := binding.QueryKey(ctx, common.HexToAddress(address), filter, limitAndSort, dataTypeFromReadIdentifier)
if err != nil {
return nil, err
}

sequenceOfValues := make([]commontypes.Sequence, len(sequence))
for idx, entry := range sequence {
value, err := values.Wrap(entry.Data)
if err != nil {
return nil, err
}
sequenceOfValues[idx] = commontypes.Sequence{
Cursor: entry.Cursor,
Head: entry.Head,
Data: value,
}
}

return sequenceOfValues, nil
}
}

func (cr *chainReader) CreateContractType(readIdentifier string, forEncoding bool) (any, error) {
Expand Down

0 comments on commit d166306

Please sign in to comment.