diff --git a/app/app.go b/app/app.go index f6569b9a9b..1fc877d835 100644 --- a/app/app.go +++ b/app/app.go @@ -541,6 +541,7 @@ func New( app.UIbcQuotaKeeperB = uibcquota.NewKeeperBuilder( appCodec, keys[uibc.StoreKey], app.LeverageKeeper, uibcoracle.FromUmeeAvgPriceOracle(app.OracleKeeper), app.UGovKeeperB.EmergencyGroup, + app.BankKeeper, ) /********** diff --git a/proto/umee/uibc/v1/query.proto b/proto/umee/uibc/v1/query.proto index 901ad7efdd..9a1b4ef85c 100644 --- a/proto/umee/uibc/v1/query.proto +++ b/proto/umee/uibc/v1/query.proto @@ -5,6 +5,8 @@ import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "google/protobuf/timestamp.proto"; +import "cosmos/bank/v1beta1/query.proto"; + import "umee/uibc/v1/quota.proto"; import "umee/uibc/v1/uibc.proto"; @@ -40,6 +42,14 @@ service Query { rpc QuotaExpires(QueryQuotaExpires) returns (QueryQuotaExpiresResponse) { option (google.api.http).get = "/umee/uibc/v1/quota_expires"; } + + // DenomOwners queries for all account addresses that own a particular token + // denomination. + // For historical state data, height have to pass as a grpc headers request here + // check here: https://docs.cosmos.network/v0.50/user/run-node/interact-node#query-for-historical-state-using-grpcurl + rpc DenomOwners(cosmos.bank.v1beta1.QueryDenomOwnersRequest) returns (cosmos.bank.v1beta1.QueryDenomOwnersResponse){ + option (google.api.http).get = "/umee/uibc/v1/denom_owners"; + } } // QueryAllInflows defines request type for query the inflow quota of registered denoms. diff --git a/x/oracle/keeper/historic_price.go b/x/oracle/keeper/historic_price.go index 0ddde0db2e..c09903dc0b 100644 --- a/x/oracle/keeper/historic_price.go +++ b/x/oracle/keeper/historic_price.go @@ -45,7 +45,7 @@ func (k Keeper) CalcAndSetHistoricMedian( median, err := decmath.Median(historicPrices) if err != nil { - return errors.Wrap(err, "denom: "+denom) //nolint: goconst + return errors.Wrap(err, "denom: "+denom) } block := uint64(ctx.BlockHeight()) diff --git a/x/uibc/client/cli/query.go b/x/uibc/client/cli/query.go index 183d3b4f88..39c266e268 100644 --- a/x/uibc/client/cli/query.go +++ b/x/uibc/client/cli/query.go @@ -5,7 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/spf13/cobra" + "github.com/umee-network/umee/v6/util/cli" "github.com/umee-network/umee/v6/x/uibc" ) @@ -25,6 +27,7 @@ func GetQueryCmd() *cobra.Command { GetOutflows(), GetInflows(), GetQuotaExpireTime(), + QueryDenomOwners(), ) return cmd @@ -130,3 +133,33 @@ func GetOutflows() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + +// QueryDenomOwners creates the Query/DenomOwners CLI. +func QueryDenomOwners() *cobra.Command { + cmd := &cobra.Command{ + Use: "denom-owners [denom]", + Args: cobra.ExactArgs(1), + Short: "Queries for all account addresses that own a particular token denomination.", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + queryClient := uibc.NewQueryClient(clientCtx) + resp, err := queryClient.DenomOwners(cmd.Context(), &banktypes.QueryDenomOwnersRequest{ + Denom: args[0], + Pagination: pageReq, + }) + return cli.PrintOrErr(resp, err, clientCtx) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "denom-owners") + + return cmd +} diff --git a/x/uibc/expected_keepers.go b/x/uibc/expected_keepers.go index 34b90b517f..c666cdd13a 100644 --- a/x/uibc/expected_keepers.go +++ b/x/uibc/expected_keepers.go @@ -1,6 +1,8 @@ package uibc import ( + context "context" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -12,6 +14,10 @@ type BankKeeper interface { GetDenomMetaData(ctx sdk.Context, denom string) (types.Metadata, bool) SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metadata) IterateAllDenomMetaData(ctx sdk.Context, cb func(types.Metadata) bool) + DenomOwners( + goCtx context.Context, + req *types.QueryDenomOwnersRequest, + ) (*types.QueryDenomOwnersResponse, error) } type Leverage interface { diff --git a/x/uibc/query.pb.go b/x/uibc/query.pb.go index 4144fec82b..1ad3d6fe88 100644 --- a/x/uibc/query.pb.go +++ b/x/uibc/query.pb.go @@ -8,6 +8,7 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/x/bank/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -431,50 +432,54 @@ func init() { func init() { proto.RegisterFile("umee/uibc/v1/query.proto", fileDescriptor_2ca7e17b0958935d) } var fileDescriptor_2ca7e17b0958935d = []byte{ - // 685 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x3f, 0x53, 0xd4, 0x4e, - 0x18, 0xbe, 0xf0, 0xe7, 0xe0, 0xb7, 0x07, 0xf3, 0xd3, 0xe5, 0x80, 0x10, 0x20, 0xc1, 0x45, 0x91, - 0x42, 0x92, 0xe1, 0x9c, 0xb1, 0xf0, 0x4f, 0xe1, 0x89, 0x05, 0x8d, 0xca, 0x49, 0xa3, 0xcd, 0x4d, - 0xee, 0x6e, 0x39, 0x32, 0x64, 0xb3, 0xf1, 0xb2, 0x01, 0x52, 0xd8, 0x38, 0x63, 0xcf, 0x8c, 0x1f, - 0xc1, 0xaf, 0x60, 0x6f, 0x4b, 0xc9, 0x68, 0xe3, 0x58, 0x9c, 0xca, 0x59, 0x59, 0xfa, 0x09, 0x9c, - 0xdd, 0x6c, 0x62, 0x02, 0xc7, 0x69, 0x61, 0x75, 0xb7, 0xef, 0x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0x38, - 0xe9, 0xe9, 0x85, 0x4f, 0x3d, 0xbd, 0xf0, 0x3c, 0xbb, 0x0c, 0x5c, 0x64, 0xcd, 0xc3, 0xec, 0x80, - 0x76, 0xf6, 0x62, 0xc5, 0xfd, 0x5b, 0xd6, 0xa1, 0x90, 0x6d, 0x14, 0xc5, 0x13, 0x78, 0xf3, 0x57, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xe3, 0xd1, 0x47, 0x08, 0x23, 0x06, 0x00, 0x00, + // 744 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xbd, 0x52, 0xdb, 0x4a, + 0x18, 0xb5, 0xf8, 0x31, 0xdc, 0x35, 0xcc, 0xbd, 0x77, 0x31, 0x20, 0x04, 0x48, 0xdc, 0xe5, 0x86, + 0x50, 0x60, 0x69, 0xec, 0xcc, 0xa4, 0xc8, 0x4f, 0x11, 0xc7, 0x29, 0x68, 0x42, 0x70, 0x68, 0x92, + 0xc6, 0x23, 0xd9, 0x8b, 0xd1, 0x20, 0x69, 0x85, 0xb5, 0x32, 0xb8, 0x48, 0x93, 0x99, 0xb4, 0x19, + 0x66, 0xf2, 0x08, 0x79, 0x85, 0x3c, 0x04, 0x25, 0x93, 0x34, 0x99, 0x14, 0x4e, 0x02, 0xa9, 0x52, + 0xe6, 0x09, 0x32, 0xbb, 0x5a, 0x29, 0x12, 0x18, 0x87, 0x22, 0x95, 0xbd, 0xdf, 0x39, 0x7b, 0xce, + 0xd1, 0x27, 0x7d, 0x1f, 0x90, 0x43, 0x17, 0x63, 0x23, 0xb4, 0xad, 0xa6, 0xd1, 0x2d, 0x1b, 0x07, + 0x21, 0xee, 0xf4, 0x74, 0xbf, 0x43, 0x28, 0x81, 0x53, 0x0c, 0xd1, 0x19, 0xa2, 0x77, 0xcb, 0xca, + 0x42, 0x93, 0x04, 0x2e, 0x09, 0x1a, 0x1c, 0x33, 0xa2,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x77, 0x72, 0xa6, 0x4a, + 0xa7, 0x67, 0xaa, 0xf4, 0xe5, 0x4c, 0x95, 0x8e, 0xcf, 0xd5, 0xdc, 0xe9, 0xb9, 0x9a, 0xfb, 0x78, + 0xae, 0xe6, 0x9e, 0xa7, 0xa7, 0x93, 0x69, 0x94, 0x3c, 0x4c, 0x0f, 0x49, 0x67, 0x3f, 0x12, 0xec, + 0xde, 0x36, 0x8e, 0xb8, 0xaa, 0x95, 0xe7, 0x3b, 0xf9, 0xd6, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xcd, 0xf6, 0x7e, 0xec, 0xd5, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -501,6 +506,11 @@ type QueryClient interface { Inflows(ctx context.Context, in *QueryInflows, opts ...grpc.CallOption) (*QueryInflowsResponse, error) // QuotaExpires returns when current ibc quota will end. QuotaExpires(ctx context.Context, in *QueryQuotaExpires, opts ...grpc.CallOption) (*QueryQuotaExpiresResponse, error) + // DenomOwners queries for all account addresses that own a particular token + // denomination. + // For historical state data, height have to pass as a grpc headers request here + // check here: https://docs.cosmos.network/v0.50/user/run-node/interact-node#query-for-historical-state-using-grpcurl + DenomOwners(ctx context.Context, in *types.QueryDenomOwnersRequest, opts ...grpc.CallOption) (*types.QueryDenomOwnersResponse, error) } type queryClient struct { @@ -556,6 +566,15 @@ func (c *queryClient) QuotaExpires(ctx context.Context, in *QueryQuotaExpires, o return out, nil } +func (c *queryClient) DenomOwners(ctx context.Context, in *types.QueryDenomOwnersRequest, opts ...grpc.CallOption) (*types.QueryDenomOwnersResponse, error) { + out := new(types.QueryDenomOwnersResponse) + err := c.cc.Invoke(ctx, "/umee.uibc.v1.Query/DenomOwners", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Params queries the parameters of the x/uibc module. @@ -570,6 +589,11 @@ type QueryServer interface { Inflows(context.Context, *QueryInflows) (*QueryInflowsResponse, error) // QuotaExpires returns when current ibc quota will end. QuotaExpires(context.Context, *QueryQuotaExpires) (*QueryQuotaExpiresResponse, error) + // DenomOwners queries for all account addresses that own a particular token + // denomination. + // For historical state data, height have to pass as a grpc headers request here + // check here: https://docs.cosmos.network/v0.50/user/run-node/interact-node#query-for-historical-state-using-grpcurl + DenomOwners(context.Context, *types.QueryDenomOwnersRequest) (*types.QueryDenomOwnersResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -591,6 +615,9 @@ func (*UnimplementedQueryServer) Inflows(ctx context.Context, req *QueryInflows) func (*UnimplementedQueryServer) QuotaExpires(ctx context.Context, req *QueryQuotaExpires) (*QueryQuotaExpiresResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QuotaExpires not implemented") } +func (*UnimplementedQueryServer) DenomOwners(ctx context.Context, req *types.QueryDenomOwnersRequest) (*types.QueryDenomOwnersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DenomOwners not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -686,6 +713,24 @@ func _Query_QuotaExpires_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Query_DenomOwners_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(types.QueryDenomOwnersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).DenomOwners(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/umee.uibc.v1.Query/DenomOwners", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).DenomOwners(ctx, req.(*types.QueryDenomOwnersRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "umee.uibc.v1.Query", HandlerType: (*QueryServer)(nil), @@ -710,6 +755,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QuotaExpires", Handler: _Query_QuotaExpires_Handler, }, + { + MethodName: "DenomOwners", + Handler: _Query_DenomOwners_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "umee/uibc/v1/query.proto", diff --git a/x/uibc/query.pb.gw.go b/x/uibc/query.pb.gw.go index a97ad32e6b..5a7a9a5fb2 100644 --- a/x/uibc/query.pb.gw.go +++ b/x/uibc/query.pb.gw.go @@ -13,6 +13,7 @@ import ( "io" "net/http" + types_0 "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/golang/protobuf/descriptor" "github.com/golang/protobuf/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -159,6 +160,42 @@ func local_request_Query_QuotaExpires_0(ctx context.Context, marshaler runtime.M } +var ( + filter_Query_DenomOwners_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq types_0.QueryDenomOwnersRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DenomOwners_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.DenomOwners(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_DenomOwners_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq types_0.QueryDenomOwnersRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DenomOwners_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.DenomOwners(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -280,6 +317,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_DenomOwners_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_DenomOwners_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomOwners_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -421,6 +481,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_DenomOwners_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_DenomOwners_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_DenomOwners_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -434,6 +514,8 @@ var ( pattern_Query_Inflows_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"umee", "uibc", "v1", "inflows"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QuotaExpires_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"umee", "uibc", "v1", "quota_expires"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_DenomOwners_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"umee", "uibc", "v1", "denom_owners"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -446,4 +528,6 @@ var ( forward_Query_Inflows_0 = runtime.ForwardResponseMessage forward_Query_QuotaExpires_0 = runtime.ForwardResponseMessage + + forward_Query_DenomOwners_0 = runtime.ForwardResponseMessage ) diff --git a/x/uibc/quota/grpc_query.go b/x/uibc/quota/grpc_query.go index 22fe8b49c1..57a9df2af7 100644 --- a/x/uibc/quota/grpc_query.go +++ b/x/uibc/quota/grpc_query.go @@ -4,6 +4,8 @@ import ( context "context" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/umee-network/umee/v6/x/uibc" ) @@ -94,3 +96,13 @@ func (q Querier) QuotaExpires(goCtx context.Context, _ *uibc.QueryQuotaExpires) return &uibc.QueryQuotaExpiresResponse{EndTime: *quotaExpireTime}, nil } + +// DenomOwners implements uibc.QueryServer. +func (q Querier) DenomOwners(ctx context.Context, req *banktypes.QueryDenomOwnersRequest) ( + *banktypes.QueryDenomOwnersResponse, + error) { + return q.bank.DenomOwners(ctx, &banktypes.QueryDenomOwnersRequest{ + Denom: req.Denom, + Pagination: req.Pagination, + }) +} diff --git a/x/uibc/quota/intest/suite_test.go b/x/uibc/quota/intest/suite_test.go index 0c7cfc9e78..e4cbf93896 100644 --- a/x/uibc/quota/intest/suite_test.go +++ b/x/uibc/quota/intest/suite_test.go @@ -4,20 +4,19 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - "github.com/cometbft/cometbft/crypto/secp256k1" tmrand "github.com/cometbft/cometbft/libs/rand" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - "gotest.tools/v3/assert" - "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + bkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking/testutil" + "gotest.tools/v3/assert" umeeapp "github.com/umee-network/umee/v6/app" appparams "github.com/umee-network/umee/v6/app/params" @@ -107,6 +106,6 @@ func initKeeper( storeKey := storetypes.NewMemoryStoreKey("quota") ctx, _ := tsdk.NewCtxOneStore(t, storeKey) eg := ugovmocks.NewSimpleEmergencyGroupBuilder() - kb := quota.NewKeeperBuilder(cdc, storeKey, leverage, oracle, eg) + kb := quota.NewKeeperBuilder(cdc, storeKey, leverage, oracle, eg, bkeeper.BaseKeeper{}) return ctx, kb.Keeper(&ctx) } diff --git a/x/uibc/quota/keeper.go b/x/uibc/quota/keeper.go index 05982d871e..a7fb08ca90 100644 --- a/x/uibc/quota/keeper.go +++ b/x/uibc/quota/keeper.go @@ -20,11 +20,12 @@ type KeeperBuilder struct { leverage uibc.Leverage oracle uibc.Oracle ugov ugov.EmergencyGroupBuilder + bank uibc.BankKeeper } func NewKeeperBuilder( cdc codec.BinaryCodec, key storetypes.StoreKey, - leverage uibc.Leverage, oracle uibc.Oracle, ugov ugov.EmergencyGroupBuilder, + leverage uibc.Leverage, oracle uibc.Oracle, ugov ugov.EmergencyGroupBuilder, bk uibc.BankKeeper, ) KeeperBuilder { return KeeperBuilder{ cdc: cdc, @@ -32,6 +33,7 @@ func NewKeeperBuilder( leverage: leverage, oracle: oracle, ugov: ugov, + bank: bk, } } diff --git a/x/uibc/quota/unit_test.go b/x/uibc/quota/unit_test.go index 4c84969392..7f693d0bb4 100644 --- a/x/uibc/quota/unit_test.go +++ b/x/uibc/quota/unit_test.go @@ -7,6 +7,8 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + bkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/stretchr/testify/require" "github.com/umee-network/umee/v6/tests/tsdk" @@ -25,7 +27,7 @@ func initKeeper(t *testing.T, l uibc.Leverage, o uibc.Oracle) TestKeeper { ir := cdctypes.NewInterfaceRegistry() cdc := codec.NewProtoCodec(ir) storeKey := storetypes.NewMemoryStoreKey("quota") - kb := NewKeeperBuilder(cdc, storeKey, l, o, eg) + kb := NewKeeperBuilder(cdc, storeKey, l, o, eg, bkeeper.BaseKeeper{}) ctx, _ := tsdk.NewCtxOneStore(t, storeKey) return TestKeeper{kb.Keeper(&ctx), t, &ctx} } diff --git a/x/uibc/uics20/ibc_module_test.go b/x/uibc/uics20/ibc_module_test.go index 1318226a98..0577a3f8e5 100644 --- a/x/uibc/uics20/ibc_module_test.go +++ b/x/uibc/uics20/ibc_module_test.go @@ -8,6 +8,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + bkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" ics20types "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" "github.com/golang/mock/gomock" @@ -62,7 +63,7 @@ func TestIBCOnRecvPacket(t *testing.T) { storeKey := storetypes.NewMemoryStoreKey("quota") ctx, _ := tsdk.NewCtxOneStore(t, storeKey) eg := ugovmocks.NewSimpleEmergencyGroupBuilder() - kb := quota.NewKeeperBuilder(cdc, storeKey, leverageMock, oracleMock, eg) + kb := quota.NewKeeperBuilder(cdc, storeKey, leverageMock, oracleMock, eg, bkeeper.BaseKeeper{}) ics20Module := NewICS20Module(mockIBCModule, cdc, kb, mockLeverageMsgServer) validMemoMsgs := func(noOfMsgs int, fallbackAddr string) string { diff --git a/x/uibc/uics20/ics4_wrapper_test.go b/x/uibc/uics20/ics4_wrapper_test.go index ffdc194289..abb8bf9835 100644 --- a/x/uibc/uics20/ics4_wrapper_test.go +++ b/x/uibc/uics20/ics4_wrapper_test.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + bkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ics20types "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -52,7 +53,7 @@ func TestSendPacket(t *testing.T) { storeKey := storetypes.NewMemoryStoreKey("quota") ctx, _ := tsdk.NewCtxOneStore(t, storeKey) - kb := quota.NewKeeperBuilder(codec.NewProtoCodec(nil), storeKey, leverageMock, oracleMock, eg) + kb := quota.NewKeeperBuilder(codec.NewProtoCodec(nil), storeKey, leverageMock, oracleMock, eg, bkeeper.BaseKeeper{}) dp := uibc.DefaultParams() keeper := kb.Keeper(&ctx) keeper.SetParams(dp)