You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently query.FilteredPaginate creates a silly developer overhead for callers, as they have to maintain the entire slice to return at the end. (and handle the complexity for the accumulate parameter.
Ideally this is instead handled by generic routines, and not the developer writing the query. This previously wasn't cleanly doable, due to needing to maintain the return type callee side. But now that generics have landed, the filtered paginate queries can easily use a generic type parameter for the slice type. Furthermore lets make this parameter a proto.message, so the serialization / deserialization can be handled for the caller.
Problem Definition
Reduce the developer overhead of writing a filtered paginate query. Currently even the simplest ones, net around 40 lines for the caller.
Proposal
Change filtered paginate from having the caller have to define the list of whats accumulated.
returnquery.FilteredPaginate[Authorization](grantsStore, req.Pagination, k.cdc, func(key []byte, authAuthorization) (Authorization, error) {
auth1, err:=auth.GetAuthorization()
iferr!=nil {
returnfalse, err
}
// (This ok check seems useless even in he original code) msg, ok:=auth1.(proto.Message)
if!ok {
returnfalse, status.Errorf(codes.Internal, "can't protomarshal %T", msg)
}
authorizationAny, err:=codectypes.NewAnyWithValue(msg)
iferr!=nil {
returnfalse, status.Errorf(codes.Internal, err.Error())
}
returnauthorizationAny, nil
})
Perhaps the new function needs a new name for backwards API compatibility? I'm not too sure though, I feel like this is a code reduction that should be universally accepted here.
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate contributors tagged
Contributor assigned/self-assigned
The text was updated successfully, but these errors were encountered:
Summary
Currently query.FilteredPaginate creates a silly developer overhead for callers, as they have to maintain the entire slice to return at the end. (and handle the complexity for the
accumulate
parameter.Ideally this is instead handled by generic routines, and not the developer writing the query. This previously wasn't cleanly doable, due to needing to maintain the return type callee side. But now that generics have landed, the filtered paginate queries can easily use a generic type parameter for the slice type. Furthermore lets make this parameter a proto.message, so the serialization / deserialization can be handled for the caller.
Problem Definition
Reduce the developer overhead of writing a filtered paginate query. Currently even the simplest ones, net around 40 lines for the caller.
Proposal
Change filtered paginate from having the caller have to define the list of whats accumulated.
This should change the following API
cosmos-sdk/x/authz/keeper/grpc_query.go
Lines 67 to 103 in 5505428
Perhaps the new function needs a new name for backwards API compatibility? I'm not too sure though, I feel like this is a code reduction that should be universally accepted here.
For Admin Use
The text was updated successfully, but these errors were encountered: