Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Oct 18, 2023
1 parent 25cd767 commit e7dd485
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// <%= queryName.UpperCamel %>Result returns the <%= queryName.UpperCamel %> result by RequestId
func (k Keeper) <%= queryName.UpperCamel %>Result(c context.Context, req *types.Query<%= queryName.UpperCamel %>Request) (*types.Query<%= queryName.UpperCamel %>Response, error) {
func (q queryServer) <%= queryName.UpperCamel %>Result(c context.Context, req *types.Query<%= queryName.UpperCamel %>Request) (*types.Query<%= queryName.UpperCamel %>Response, error) {
ctx := sdk.UnwrapSDKContext(c)
result, err := k.Get<%= queryName.UpperCamel %>Result(ctx, types.OracleRequestID(req.RequestId))
if err != nil {
Expand All @@ -18,7 +18,7 @@ func (k Keeper) <%= queryName.UpperCamel %>Result(c context.Context, req *types.
}

// Last<%= queryName.UpperCamel %>Id returns the last <%= queryName.UpperCamel %> request Id
func (k Keeper) Last<%= queryName.UpperCamel %>Id(c context.Context, req *types.QueryLast<%= queryName.UpperCamel %>IdRequest) (*types.QueryLast<%= queryName.UpperCamel %>IdResponse, error) {
func (q queryServer) Last<%= queryName.UpperCamel %>Id(c context.Context, req *types.QueryLast<%= queryName.UpperCamel %>IdRequest) (*types.QueryLast<%= queryName.UpperCamel %>IdResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
id := k.GetLast<%= queryName.UpperCamel %>ID(ctx)
return &types.QueryLast<%= queryName.UpperCamel %>IdResponse{RequestId: id}, nil
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

var _ types.QueryServer = queryServer{}

// NewQueryServerImpl returns an implementation of the QueryServer interface
// for the provided Keeper.
func NewQueryServerImpl(k Keeper) types.QueryServer {
return queryServer{k}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import (
"context"

"<%= ModulePath %>/x/<%= ModuleName %>/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

func (k Keeper) <%= QueryName.UpperCamel %>(ctx context.Context, req *types.Query<%= QueryName.UpperCamel %>Request) (*types.Query<%= QueryName.UpperCamel %>Response, error) {
func (q queryServer) <%= QueryName.UpperCamel %>(ctx context.Context, req *types.Query<%= QueryName.UpperCamel %>Request) (*types.Query<%= QueryName.UpperCamel %>Response, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions ignite/templates/typed/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ func typesKeyModify(opts *typed.Options) genny.RunFn {
}
content := f.String() + fmt.Sprintf(`
const (
%[1]vKey= "%[1]v/value/"
%[1]vCountKey= "%[1]v/count/"
%[1]vKey= collections.NewPrefix("%[1]v/value/")
%[1]vCountKey= collections.NewPrefix("%[1]v/count/")

Check warning on line 276 in ignite/templates/typed/list/list.go

View check run for this annotation

Codecov / codecov/patch

ignite/templates/typed/list/list.go#L275-L276

Added lines #L275 - L276 were not covered by tests
)
`, opts.TypeName.UpperCamel)
newFile := genny.NewFileS(path, content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ import (
"google.golang.org/grpc/status"
)

func (k Keeper) <%= TypeName.UpperCamel %>All(ctx context.Context, req *types.QueryAll<%= TypeName.UpperCamel %>Request) (*types.QueryAll<%= TypeName.UpperCamel %>Response, error) {
func (q queryServer) <%= TypeName.UpperCamel %>All(ctx context.Context, req *types.QueryAll<%= TypeName.UpperCamel %>Request) (*types.QueryAll<%= TypeName.UpperCamel %>Response, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

var <%= TypeName.LowerCamel %>s []types.<%= TypeName.UpperCamel %>

store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
// TODO use collections

store := runtime.KVStoreAdapter(q.k.storeService.OpenKVStore(ctx))
<%= TypeName.LowerCamel %>Store := prefix.NewStore(store, types.KeyPrefix(types.<%= TypeName.UpperCamel %>KeyPrefix))

pageRes, err := query.Paginate(<%= TypeName.LowerCamel %>Store, req.Pagination, func(key []byte, value []byte) error {
var <%= TypeName.LowerCamel %> types.<%= TypeName.UpperCamel %>
if err := k.cdc.Unmarshal(value, &<%= TypeName.LowerCamel %>); err != nil {
if err := q.k.cdc.Unmarshal(value, &<%= TypeName.LowerCamel %>); err != nil {
return err
}

Expand All @@ -38,16 +40,16 @@ func (k Keeper) <%= TypeName.UpperCamel %>All(ctx context.Context, req *types.Qu
return &types.QueryAll<%= TypeName.UpperCamel %>Response{<%= TypeName.UpperCamel %>: <%= TypeName.LowerCamel %>s, Pagination: pageRes}, nil
}

func (k Keeper) <%= TypeName.UpperCamel %>(ctx context.Context, req *types.QueryGet<%= TypeName.UpperCamel %>Request) (*types.QueryGet<%= TypeName.UpperCamel %>Response, error) {
func (q queryServer) <%= TypeName.UpperCamel %>(ctx context.Context, req *types.QueryGet<%= TypeName.UpperCamel %>Request) (*types.QueryGet<%= TypeName.UpperCamel %>Response, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

val, found := k.Get<%= TypeName.UpperCamel %>(
val, err := q.k.<%= TypeName.UpperCamel %>.Get(
ctx,
<%= for (i, index) in Indexes { %>req.<%= index.Name.UpperCamel %>,
<% } %>)
if !found {
if err != nil {
return nil, status.Error(codes.NotFound, "not found")
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (q queryServer) <%= TypeName.UpperCamel %>(ctx context.Context, req *types.
val, err := q.k.<%= TypeName.UpperCamel %>.Get(ctx)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return nil, status.Error(codes.NotFound, "not found")
return nil, status.Error(codes.NotFound, "not found")
}

return nil, status.Error(codes.Internal, "internal error")
Expand Down
Loading

0 comments on commit e7dd485

Please sign in to comment.