From b0413b65ccd26276824bd694a3325edd28f9b02d Mon Sep 17 00:00:00 2001 From: Sai Kumar <17549398+gsk967@users.noreply.github.com> Date: Wed, 17 Apr 2024 20:36:35 +0530 Subject: [PATCH] removed custom msgs and queries for cosmwasm (#2492) --- app/app.go | 3 - app/wasm/custom_plugins.go | 25 --- app/wasm/msg/handler_leverage.go | 106 ----------- app/wasm/msg/plugin.go | 82 --------- app/wasm/msg/types.go | 30 ---- app/wasm/query/handle_incentive.go | 107 ------------ app/wasm/query/handle_leverage.go | 91 ---------- app/wasm/query/handle_metoken.go | 61 ------- app/wasm/query/handle_oracle.go | 110 ------------ app/wasm/query/plugin.go | 151 ---------------- app/wasm/test/cosmwasm_test.go | 6 - app/wasm/test/cw20_base_test.go | 19 -- app/wasm/test/umee_cw_test.go | 270 ----------------------------- 13 files changed, 1061 deletions(-) delete mode 100644 app/wasm/msg/handler_leverage.go delete mode 100644 app/wasm/msg/plugin.go delete mode 100644 app/wasm/msg/types.go delete mode 100644 app/wasm/query/handle_incentive.go delete mode 100644 app/wasm/query/handle_leverage.go delete mode 100644 app/wasm/query/handle_metoken.go delete mode 100644 app/wasm/query/handle_oracle.go delete mode 100644 app/wasm/query/plugin.go diff --git a/app/app.go b/app/app.go index 5351dff11f..ce63f3c150 100644 --- a/app/app.go +++ b/app/app.go @@ -669,9 +669,6 @@ func New( panic(fmt.Sprintf("error while reading wasm config: %s", err)) } - // Register umee custom plugin to wasm - wasmOpts = append(uwasm.RegisterCustomPlugins(app.LeverageKeeper, app.OracleKeeper, app.IncentiveKeeper, - app.MetokenKeeperB), wasmOpts...) // Register stargate queries wasmOpts = append(wasmOpts, uwasm.RegisterStargateQueries(*bApp.GRPCQueryRouter(), appCodec)...) availableCapabilities := strings.Join(AllCapabilities(), ",") diff --git a/app/wasm/custom_plugins.go b/app/wasm/custom_plugins.go index ab753b76fc..cc04ad51e9 100644 --- a/app/wasm/custom_plugins.go +++ b/app/wasm/custom_plugins.go @@ -5,34 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - "github.com/umee-network/umee/v6/app/wasm/msg" "github.com/umee-network/umee/v6/app/wasm/query" - inckeeper "github.com/umee-network/umee/v6/x/incentive/keeper" - leveragekeeper "github.com/umee-network/umee/v6/x/leverage/keeper" - metokenkeeper "github.com/umee-network/umee/v6/x/metoken/keeper" - oraclekeeper "github.com/umee-network/umee/v6/x/oracle/keeper" ) -// RegisterCustomPlugins expose the queries and msgs of native modules to wasm. -func RegisterCustomPlugins( - leverageKeeper leveragekeeper.Keeper, - oracleKeeper oraclekeeper.Keeper, - incentiveKeeper inckeeper.Keeper, - metokenBuilder metokenkeeper.Builder, -) []wasmkeeper.Option { - wasmQueryPlugin := query.NewQueryPlugin(leverageKeeper, oracleKeeper, incentiveKeeper, metokenBuilder) - queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ - Custom: wasmQueryPlugin.CustomQuerier(), - }) - - messagePluginOpt := wasmkeeper.WithMessageHandlerDecorator(msg.NewMessagePlugin(leverageKeeper)) - - return []wasmkeeper.Option{ - queryPluginOpt, - messagePluginOpt, - } -} - // RegisterStargateQueries expose the stargate queries func RegisterStargateQueries(queryRouter baseapp.GRPCQueryRouter, codec codec.Codec) []wasmkeeper.Option { queryPluginOpt := wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{ diff --git a/app/wasm/msg/handler_leverage.go b/app/wasm/msg/handler_leverage.go deleted file mode 100644 index 5ccea90275..0000000000 --- a/app/wasm/msg/handler_leverage.go +++ /dev/null @@ -1,106 +0,0 @@ -package msg - -import ( - "context" - - "github.com/cosmos/gogoproto/proto" - - lvtypes "github.com/umee-network/umee/v6/x/leverage/types" -) - -// HandleSupply handles the Supply value of an address. -func (m UmeeMsg) HandleSupply( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgSupply{Supplier: sender, Asset: m.Supply.Asset} - return s.Supply(ctx, req) -} - -// HandleWithdraw handles the Withdraw value of an address. -func (m UmeeMsg) HandleWithdraw( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgWithdraw{Supplier: sender, Asset: m.Withdraw.Asset} - return s.Withdraw(ctx, req) -} - -// HandleMaxWithdraw handles the maximum withdraw value of an address. -func (m UmeeMsg) HandleMaxWithdraw( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgMaxWithdraw{Supplier: sender, Denom: m.MaxWithdraw.Denom} - return s.MaxWithdraw(ctx, req) -} - -// HandleCollateralize handles the enable selected uTokens as collateral. -func (m UmeeMsg) HandleCollateralize( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgCollateralize{Borrower: sender, Asset: m.Collateralize.Asset} - return s.Collateralize(ctx, req) -} - -// HandleDecollateralize handles the disable amount of an selected uTokens -// as collateral. -func (m UmeeMsg) HandleDecollateralize( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgDecollateralize{Borrower: sender, Asset: m.Decollateralize.Asset} - return s.Decollateralize(ctx, req) -} - -// HandleBorrow handles the borrowing coins from the capital facility. -func (m UmeeMsg) HandleBorrow( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgBorrow{Borrower: sender, Asset: m.Borrow.Asset} - return s.Borrow(ctx, req) -} - -// HandleMaxBorrow handles the borrowing maximum coins from the capital facility. -func (m UmeeMsg) HandleMaxBorrow( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgMaxBorrow{Borrower: sender, Denom: m.MaxBorrow.Denom} - return s.MaxBorrow(ctx, req) -} - -// HandleRepay handles repaying borrowed coins to the capital facility. -func (m UmeeMsg) HandleRepay( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgRepay{Borrower: sender, Asset: m.Repay.Asset} - return s.Repay(ctx, req) -} - -// HandleLiquidate handles the repaying a different user's borrowed coins -// to the capital facility in exchange for some of their collateral. -func (m UmeeMsg) HandleLiquidate( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgLiquidate{ - Liquidator: sender, - Borrower: m.Liquidate.Borrower, - Repayment: m.Liquidate.Repayment, - RewardDenom: m.Liquidate.RewardDenom, - } - return s.Liquidate(ctx, req) -} - -// HandleSupplyCollateral handles the supply the assets and collateral their assets. -func (m UmeeMsg) HandleSupplyCollateral( - ctx context.Context, sender string, - s lvtypes.MsgServer, -) (proto.Message, error) { - req := &lvtypes.MsgSupplyCollateral{Supplier: sender, Asset: m.SupplyCollateral.Asset} - return s.SupplyCollateral(ctx, req) -} diff --git a/app/wasm/msg/plugin.go b/app/wasm/msg/plugin.go deleted file mode 100644 index 11e2a20859..0000000000 --- a/app/wasm/msg/plugin.go +++ /dev/null @@ -1,82 +0,0 @@ -package msg - -import ( - "encoding/json" - - sdkerrors "cosmossdk.io/errors" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - lvkeeper "github.com/umee-network/umee/v6/x/leverage/keeper" - lvtypes "github.com/umee-network/umee/v6/x/leverage/types" -) - -// Plugin wraps the msg plugin with Messengers. -type Plugin struct { - lvMsgServer lvtypes.MsgServer - wrapped wasmkeeper.Messenger -} - -var _ wasmkeeper.Messenger = (*Plugin)(nil) - -// CustomMessageDecorator returns decorator for custom CosmWasm bindings messages -func NewMessagePlugin(leverageKeeper lvkeeper.Keeper) func(wasmkeeper.Messenger) wasmkeeper.Messenger { - return func(old wasmkeeper.Messenger) wasmkeeper.Messenger { - return &Plugin{ - wrapped: old, - lvMsgServer: lvkeeper.NewMsgServerImpl(leverageKeeper), - } - } -} - -// DispatchCustomMsg responsible for handling custom messages (umee native messages). -func (plugin *Plugin) DispatchCustomMsg(ctx sdk.Context, contractAddr sdk.AccAddress, rawMsg json.RawMessage) error { - var smartcontractMessage UmeeMsg - if err := json.Unmarshal(rawMsg, &smartcontractMessage); err != nil { - return sdkerrors.Wrap(err, "invalid umee custom msg") - } - - sender := contractAddr.String() - var err error - sdkCtx := sdk.WrapSDKContext(ctx) - switch { - case smartcontractMessage.Supply != nil: - _, err = smartcontractMessage.HandleSupply(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.Withdraw != nil: - _, err = smartcontractMessage.HandleWithdraw(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.MaxWithdraw != nil: - _, err = smartcontractMessage.HandleMaxWithdraw(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.Collateralize != nil: - _, err = smartcontractMessage.HandleCollateralize(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.Decollateralize != nil: - _, err = smartcontractMessage.HandleDecollateralize(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.Borrow != nil: - _, err = smartcontractMessage.HandleBorrow(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.MaxBorrow != nil: - _, err = smartcontractMessage.HandleMaxBorrow(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.Repay != nil: - _, err = smartcontractMessage.HandleRepay(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.Liquidate != nil: - _, err = smartcontractMessage.HandleLiquidate(sdkCtx, sender, plugin.lvMsgServer) - case smartcontractMessage.SupplyCollateral != nil: - _, err = smartcontractMessage.HandleSupplyCollateral(sdkCtx, sender, plugin.lvMsgServer) - default: - err = wasmvmtypes.UnsupportedRequest{Kind: "invalid assigned umee msg"} - } - - return err -} - -// DispatchMsg encodes the wasmVM message and dispatches it. -func (plugin *Plugin) DispatchMsg( - ctx sdk.Context, - contractAddr sdk.AccAddress, - contractIBCPortID string, - msg wasmvmtypes.CosmosMsg, -) (events []sdk.Event, data [][]byte, err error) { - if msg.Custom != nil { - return nil, nil, plugin.DispatchCustomMsg(ctx, contractAddr, msg.Custom) - } - return plugin.wrapped.DispatchMsg(ctx, contractAddr, contractIBCPortID, msg) -} diff --git a/app/wasm/msg/types.go b/app/wasm/msg/types.go deleted file mode 100644 index 92e0e0eef4..0000000000 --- a/app/wasm/msg/types.go +++ /dev/null @@ -1,30 +0,0 @@ -package msg - -import ( - lvtypes "github.com/umee-network/umee/v6/x/leverage/types" -) - -// UmeeMsg wraps all the messages availables for cosmwasm smartcontracts. -type UmeeMsg struct { - // Used to supply coins to the capital facility. - Supply *lvtypes.MsgSupply `json:"supply,omitempty"` - // Used to withdraw previously loaned coins from the capital facility. - Withdraw *lvtypes.MsgWithdraw `json:"withdraw,omitempty"` - // Used to do withdraw maximum assets by supplier. - MaxWithdraw *lvtypes.MsgMaxWithdraw `json:"max_withdraw,omitempty"` - // Used to enable an amount of selected uTokens as collateral. - Collateralize *lvtypes.MsgCollateralize `json:"collateralize,omitempty"` - // Used to disable amount of an selected uTokens as collateral. - Decollateralize *lvtypes.MsgDecollateralize `json:"decollateralize,omitempty"` - // Used to borrowing coins from the capital facility. - Borrow *lvtypes.MsgBorrow `json:"borrow,omitempty"` - // Used to borrowing coins from the capital facility. - MaxBorrow *lvtypes.MsgMaxBorrow `json:"max_borrow,omitempty"` - // Used to repaying borrowed coins to the capital facility. - Repay *lvtypes.MsgRepay `json:"repay,omitempty"` - // Used to repaying a different user's borrowed coins - // to the capital facility in exchange for some of their collateral. - Liquidate *lvtypes.MsgLiquidate `json:"liquidate,omitempty"` - // Used to do supply and collateralize their assets. - SupplyCollateral *lvtypes.MsgSupplyCollateral `json:"supply_collateral,omitempty"` -} diff --git a/app/wasm/query/handle_incentive.go b/app/wasm/query/handle_incentive.go deleted file mode 100644 index e02b10c050..0000000000 --- a/app/wasm/query/handle_incentive.go +++ /dev/null @@ -1,107 +0,0 @@ -package query - -import ( - "context" - - "github.com/cosmos/gogoproto/proto" - "github.com/umee-network/umee/v6/x/incentive" -) - -// HandleLeverageParams handles the get the x/leverage module's parameters. -func (q UmeeQuery) HandleIncentiveParams( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.Params(ctx, &incentive.QueryParams{}) -} - -// HandleTotalBonded handles the get the sum of all bonded collateral uTokens. -func (q UmeeQuery) HandleTotalBonded( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.TotalBonded(ctx, &incentive.QueryTotalBonded{Denom: q.TotalBonded.Denom}) -} - -// HandleTotalUnbonding handles the get the sum of all unbonding collateral uTokens. -func (q UmeeQuery) HandleTotalUnbonding( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.TotalUnbonding(ctx, &incentive.QueryTotalUnbonding{Denom: q.TotalUnbonding.Denom}) -} - -// HandleAccountBonds handles the get all bonded collateral and unbondings associated with an account. -func (q UmeeQuery) HandleAccountBonds( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.AccountBonds(ctx, &incentive.QueryAccountBonds{Address: q.AccountBonds.Address}) -} - -// HandlePendingRewards handles the gets all unclaimed incentive rewards associated with an account. -func (q UmeeQuery) HandlePendingRewards( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.PendingRewards(ctx, &incentive.QueryPendingRewards{Address: q.PendingRewards.Address}) -} - -// HandleCompletedIncentivePrograms handles the get all incentives programs that have been passed -// by governance, -func (q UmeeQuery) HandleCompletedIncentivePrograms( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.CompletedIncentivePrograms(ctx, &incentive.QueryCompletedIncentivePrograms{}) -} - -// HandleOngoingIncentivePrograms handles the get all incentives programs that have been passed -// by governance, funded, and started but not yet completed. -func (q UmeeQuery) HandleOngoingIncentivePrograms( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.OngoingIncentivePrograms(ctx, &incentive.QueryOngoingIncentivePrograms{}) -} - -// HandleUpcomingIncentivePrograms handles the get all incentives programs that have been passed -// by governance, but not yet started. They may or may not have been funded. -func (q UmeeQuery) HandleUpcomingIncentivePrograms( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.UpcomingIncentivePrograms(ctx, &incentive.QueryUpcomingIncentivePrograms{}) -} - -// HandleIncentiveProgram handles the get a single incentive program by ID. -func (q UmeeQuery) HandleIncentiveProgram( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.IncentiveProgram(ctx, &incentive.QueryIncentiveProgram{Id: q.IncentiveProgram.Id}) -} - -// HandleCurrentRates handles the get current rates of given denom -func (q UmeeQuery) HandleCurrentRates( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.CurrentRates(ctx, &incentive.QueryCurrentRates{UToken: q.CurrentRates.UToken}) -} - -// HandleActualRates handles the get the actutal rates of given denom -func (q UmeeQuery) HandleActualRates( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.ActualRates(ctx, &incentive.QueryActualRates{UToken: q.CurrentRates.UToken}) -} - -// HandleLastRewardTime handles the get last block time at which incentive rewards were calculated. -func (q UmeeQuery) HandleLastRewardTime( - ctx context.Context, - qs incentive.QueryServer, -) (proto.Message, error) { - return qs.LastRewardTime(ctx, &incentive.QueryLastRewardTime{}) -} diff --git a/app/wasm/query/handle_leverage.go b/app/wasm/query/handle_leverage.go deleted file mode 100644 index c196bca16e..0000000000 --- a/app/wasm/query/handle_leverage.go +++ /dev/null @@ -1,91 +0,0 @@ -package query - -import ( - "context" - - "github.com/cosmos/gogoproto/proto" - - lvtypes "github.com/umee-network/umee/v6/x/leverage/types" -) - -// HandleLeverageParams handles the get the x/leverage module's parameters. -func (q UmeeQuery) HandleLeverageParams( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - return qs.Params(ctx, &lvtypes.QueryParams{}) -} - -// HandleRegisteredTokens handles the get all registered tokens query and response. -func (q UmeeQuery) HandleRegisteredTokens( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - if len(q.RegisteredTokens.BaseDenom) != 0 { - return qs.RegisteredTokens(ctx, &lvtypes.QueryRegisteredTokens{ - BaseDenom: q.RegisteredTokens.BaseDenom, - }) - } - return qs.RegisteredTokens(ctx, &lvtypes.QueryRegisteredTokens{}) -} - -// HandleMarketSummary queries a base asset's current borrowing and supplying conditions. -func (q UmeeQuery) HandleMarketSummary( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - return qs.MarketSummary(ctx, &lvtypes.QueryMarketSummary{Denom: q.MarketSummary.Denom}) -} - -// HandleAccountBalances queries an account's current supply, collateral, and borrow positions. -func (q UmeeQuery) HandleAccountBalances( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - req := &lvtypes.QueryAccountBalances{Address: q.AccountBalances.Address} - return qs.AccountBalances(ctx, req) -} - -// HandleAccountSummary queries USD values representing an account's total -// positions and borrowing limits. It requires oracle prices to return successfully. -func (q UmeeQuery) HandleAccountSummary( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - req := &lvtypes.QueryAccountSummary{Address: q.AccountSummary.Address} - return qs.AccountSummary(ctx, req) -} - -// HandleLiquidationTargets queries a list of all borrower account addresses eligible for liquidation. -func (q UmeeQuery) HandleLiquidationTargets( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - return qs.LiquidationTargets(ctx, &lvtypes.QueryLiquidationTargets{}) -} - -// HandleBadDebts queries bad debts. -func (q UmeeQuery) HandleBadDebts( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - return qs.BadDebts(ctx, &lvtypes.QueryBadDebts{}) -} - -// HandleBadDebts queries bad debts. -func (q UmeeQuery) HandleMaxWithdraw( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - req := &lvtypes.QueryMaxWithdraw{Address: q.MaxWithdraw.Address, Denom: q.MaxWithdraw.Denom} - return qs.MaxWithdraw(ctx, req) -} - -// HandleMaxBorrow queries max borrow. -func (q UmeeQuery) HandleMaxBorrow( - ctx context.Context, - qs lvtypes.QueryServer, -) (proto.Message, error) { - req := &lvtypes.QueryMaxBorrow{Address: q.MaxBorrow.Address, Denom: q.MaxBorrow.Denom} - return qs.MaxBorrow(ctx, req) -} diff --git a/app/wasm/query/handle_metoken.go b/app/wasm/query/handle_metoken.go deleted file mode 100644 index 39278a798d..0000000000 --- a/app/wasm/query/handle_metoken.go +++ /dev/null @@ -1,61 +0,0 @@ -package query - -import ( - "context" - - "github.com/cosmos/gogoproto/proto" - "github.com/umee-network/umee/v6/x/metoken" -) - -// HandleMeTokenParams handles the get for x/metoken module's parameters. -func (q UmeeQuery) HandleMeTokenParams( - ctx context.Context, - qs metoken.QueryServer, -) (proto.Message, error) { - return qs.Params(ctx, &metoken.QueryParams{}) -} - -// HandleMeTokenIndexes handles the get for x/metoken indexes. -func (q UmeeQuery) HandleMeTokenIndexes( - ctx context.Context, - qs metoken.QueryServer, -) (proto.Message, error) { - req := metoken.QueryIndexes{MetokenDenom: q.Indexes.MetokenDenom} - return qs.Indexes(ctx, &req) -} - -// HandleMeTokenSwapFee handles the get for x/metoken swap fee. -func (q UmeeQuery) HandleMeTokenSwapFee( - ctx context.Context, - qs metoken.QueryServer, -) (proto.Message, error) { - req := metoken.QuerySwapFee{Asset: q.SwapFee.Asset, MetokenDenom: q.SwapFee.MetokenDenom} - return qs.SwapFee(ctx, &req) -} - -// HandleMeTokenRedeemFee handles the get for x/metoken redeem fee. -func (q UmeeQuery) HandleMeTokenRedeemFee( - ctx context.Context, - qs metoken.QueryServer, -) (proto.Message, error) { - req := metoken.QueryRedeemFee{AssetDenom: q.RedeemFee.AssetDenom, Metoken: q.RedeemFee.Metoken} - return qs.RedeemFee(ctx, &req) -} - -// HandleMeTokenIndexBalances handles the get for x/metoken indexes balances. -func (q UmeeQuery) HandleMeTokenIndexBalances( - ctx context.Context, - qs metoken.QueryServer, -) (proto.Message, error) { - req := metoken.QueryIndexBalances{MetokenDenom: q.IndexBalances.MetokenDenom} - return qs.IndexBalances(ctx, &req) -} - -// HandleMeTokenIndexPrices handles the get for x/metoken indexe price. -func (q UmeeQuery) HandleMeTokenIndexPrices( - ctx context.Context, - qs metoken.QueryServer, -) (proto.Message, error) { - req := metoken.QueryIndexPrices{MetokenDenom: q.IndexPrices.MetokenDenom} - return qs.IndexPrices(ctx, &req) -} diff --git a/app/wasm/query/handle_oracle.go b/app/wasm/query/handle_oracle.go deleted file mode 100644 index ef3353ecf6..0000000000 --- a/app/wasm/query/handle_oracle.go +++ /dev/null @@ -1,110 +0,0 @@ -package query - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/gogoproto/proto" - - octypes "github.com/umee-network/umee/v6/x/oracle/types" -) - -// HandleFeederDelegation gets all the feeder delegation of a validator. -func (q UmeeQuery) HandleFeederDelegation( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - req := &octypes.QueryFeederDelegation{ValidatorAddr: q.FeederDelegation.ValidatorAddr} - return qs.FeederDelegation(sdk.WrapSDKContext(ctx), req) -} - -// HandleMissCounter gets all the oracle miss counter of a validator. -func (q UmeeQuery) HandleMissCounter( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - req := &octypes.QueryMissCounter{ValidatorAddr: q.MissCounter.ValidatorAddr} - return qs.MissCounter(sdk.WrapSDKContext(ctx), req) -} - -// HandleSlashWindow gets slash window information. -func (q UmeeQuery) HandleSlashWindow( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - return qs.SlashWindow(sdk.WrapSDKContext(ctx), &octypes.QuerySlashWindow{}) -} - -// HandleAggregatePrevote gets an aggregate prevote of a validator. -func (q UmeeQuery) HandleAggregatePrevote( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - req := &octypes.QueryAggregatePrevote{ValidatorAddr: q.AggregatePrevote.ValidatorAddr} - return qs.AggregatePrevote(sdk.WrapSDKContext(ctx), req) -} - -// HandleAggregatePrevotes gets an aggregate prevote of all validators. -func (q UmeeQuery) HandleAggregatePrevotes( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - return qs.AggregatePrevotes(sdk.WrapSDKContext(ctx), &octypes.QueryAggregatePrevotes{}) -} - -// HandleAggregateVote gets an aggregate vote of a validator. -func (q UmeeQuery) HandleAggregateVote( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - req := &octypes.QueryAggregateVote{ValidatorAddr: q.AggregateVote.ValidatorAddr} - return qs.AggregateVote(sdk.WrapSDKContext(ctx), req) -} - -// HandleAggregateVotes gets an aggregate vote of all validators. -func (q UmeeQuery) HandleAggregateVotes( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - return qs.AggregateVotes(sdk.WrapSDKContext(ctx), &octypes.QueryAggregateVotes{}) -} - -// HandleOracleParams gets the x/oracle module's parameters. -func (q UmeeQuery) HandleOracleParams( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - return qs.Params(sdk.WrapSDKContext(ctx), &octypes.QueryParams{}) -} - -// HandleExchangeRates gets the exchange rates of all denoms. -func (q UmeeQuery) HandleExchangeRates( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - return qs.ExchangeRates(sdk.WrapSDKContext(ctx), &octypes.QueryExchangeRates{Denom: q.ExchangeRates.Denom}) -} - -// HandleActiveExchangeRates gets all active denoms. -func (q UmeeQuery) HandleActiveExchangeRates( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - return qs.ActiveExchangeRates(sdk.WrapSDKContext(ctx), &octypes.QueryActiveExchangeRates{}) -} - -// HandleMedians gets medians. -func (q UmeeQuery) HandleMedians( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - req := &octypes.QueryMedians{Denom: q.Medians.Denom, NumStamps: q.Medians.NumStamps} - return qs.Medians(sdk.WrapSDKContext(ctx), req) -} - -// HandleMedians gets median deviations. -func (q UmeeQuery) HandleMedianDeviations( - ctx sdk.Context, - qs octypes.QueryServer, -) (proto.Message, error) { - req := &octypes.QueryMedianDeviations{Denom: q.MedianDeviations.Denom} - return qs.MedianDeviations(sdk.WrapSDKContext(ctx), req) -} diff --git a/app/wasm/query/plugin.go b/app/wasm/query/plugin.go deleted file mode 100644 index c14b297f2e..0000000000 --- a/app/wasm/query/plugin.go +++ /dev/null @@ -1,151 +0,0 @@ -package query - -import ( - "encoding/json" - "fmt" - - sdkerrors "cosmossdk.io/errors" - wasmvmtypes "github.com/CosmWasm/wasmvm/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/gogoproto/proto" - - "github.com/umee-network/umee/v6/x/incentive" - inckeeper "github.com/umee-network/umee/v6/x/incentive/keeper" - lvkeeper "github.com/umee-network/umee/v6/x/leverage/keeper" - lvtypes "github.com/umee-network/umee/v6/x/leverage/types" - "github.com/umee-network/umee/v6/x/metoken" - metokenkeeper "github.com/umee-network/umee/v6/x/metoken/keeper" - ockeeper "github.com/umee-network/umee/v6/x/oracle/keeper" - ocpes "github.com/umee-network/umee/v6/x/oracle/types" -) - -// Plugin wraps the query plugin with queriers. -type Plugin struct { - lvQueryServer lvtypes.QueryServer - ocQueryServer ocpes.QueryServer - incQueryServer incentive.QueryServer - metokenQueryServer metoken.QueryServer -} - -// NewQueryPlugin creates a plugin to query native modules. -func NewQueryPlugin( - leverageKeeper lvkeeper.Keeper, - oracleKeeper ockeeper.Keeper, - incentiveKeeper inckeeper.Keeper, - metokenBuilder metokenkeeper.Builder, -) *Plugin { - return &Plugin{ - lvQueryServer: lvkeeper.NewQuerier(leverageKeeper), - ocQueryServer: ockeeper.NewQuerier(oracleKeeper), - incQueryServer: inckeeper.NewQuerier(incentiveKeeper), - metokenQueryServer: metokenkeeper.NewQuerier(metokenBuilder), - } -} - -// CustomQuerier implements custom querier for wasm smartcontracts acess umee native modules. -func (plugin *Plugin) CustomQuerier() func(ctx sdk.Context, request json.RawMessage) ([]byte, error) { - return func(ctx sdk.Context, request json.RawMessage) ([]byte, error) { - var smartcontractQuery UmeeQuery - if err := json.Unmarshal(request, &smartcontractQuery); err != nil { - return nil, sdkerrors.Wrap(err, "umee query") - } - - var resp proto.Message - var err error - - switch { - case smartcontractQuery.LeverageParameters != nil: - resp, err = smartcontractQuery.HandleLeverageParams(ctx, plugin.lvQueryServer) - case smartcontractQuery.RegisteredTokens != nil: - resp, err = smartcontractQuery.HandleRegisteredTokens(ctx, plugin.lvQueryServer) - case smartcontractQuery.MarketSummary != nil: - resp, err = smartcontractQuery.HandleMarketSummary(ctx, plugin.lvQueryServer) - case smartcontractQuery.AccountBalances != nil: - resp, err = smartcontractQuery.HandleAccountBalances(ctx, plugin.lvQueryServer) - case smartcontractQuery.AccountSummary != nil: - resp, err = smartcontractQuery.HandleAccountSummary(ctx, plugin.lvQueryServer) - case smartcontractQuery.LiquidationTargets != nil: - resp, err = smartcontractQuery.HandleLiquidationTargets(ctx, plugin.lvQueryServer) - case smartcontractQuery.BadDebts != nil: - resp, err = smartcontractQuery.HandleBadDebts(ctx, plugin.lvQueryServer) - case smartcontractQuery.MaxWithdraw != nil: - resp, err = smartcontractQuery.HandleMaxWithdraw(ctx, plugin.lvQueryServer) - case smartcontractQuery.MaxBorrow != nil: - resp, err = smartcontractQuery.HandleMaxBorrow(ctx, plugin.lvQueryServer) - - case smartcontractQuery.FeederDelegation != nil: - resp, err = smartcontractQuery.HandleFeederDelegation(ctx, plugin.ocQueryServer) - case smartcontractQuery.MissCounter != nil: - resp, err = smartcontractQuery.HandleMissCounter(ctx, plugin.ocQueryServer) - case smartcontractQuery.SlashWindow != nil: - resp, err = smartcontractQuery.HandleSlashWindow(ctx, plugin.ocQueryServer) - case smartcontractQuery.AggregatePrevote != nil: - resp, err = smartcontractQuery.HandleAggregatePrevote(ctx, plugin.ocQueryServer) - case smartcontractQuery.AggregatePrevotes != nil: - resp, err = smartcontractQuery.HandleAggregatePrevotes(ctx, plugin.ocQueryServer) - case smartcontractQuery.AggregateVote != nil: - resp, err = smartcontractQuery.HandleAggregateVote(ctx, plugin.ocQueryServer) - case smartcontractQuery.AggregateVotes != nil: - resp, err = smartcontractQuery.HandleAggregateVotes(ctx, plugin.ocQueryServer) - case smartcontractQuery.OracleParams != nil: - resp, err = smartcontractQuery.HandleOracleParams(ctx, plugin.ocQueryServer) - case smartcontractQuery.ExchangeRates != nil: - resp, err = smartcontractQuery.HandleExchangeRates(ctx, plugin.ocQueryServer) - case smartcontractQuery.ActiveExchangeRates != nil: - resp, err = smartcontractQuery.HandleActiveExchangeRates(ctx, plugin.ocQueryServer) - case smartcontractQuery.Medians != nil: - resp, err = smartcontractQuery.HandleMedians(ctx, plugin.ocQueryServer) - case smartcontractQuery.MedianDeviations != nil: - resp, err = smartcontractQuery.HandleMedianDeviations(ctx, plugin.ocQueryServer) - - // incentive - case smartcontractQuery.IncentiveParameters != nil: - resp, err = smartcontractQuery.HandleIncentiveParams(ctx, plugin.incQueryServer) - case smartcontractQuery.TotalBonded != nil: - resp, err = smartcontractQuery.HandleTotalBonded(ctx, plugin.incQueryServer) - case smartcontractQuery.TotalUnbonding != nil: - resp, err = smartcontractQuery.HandleTotalUnbonding(ctx, plugin.incQueryServer) - case smartcontractQuery.AccountBonds != nil: - resp, err = smartcontractQuery.HandleAccountBonds(ctx, plugin.incQueryServer) - case smartcontractQuery.PendingRewards != nil: - resp, err = smartcontractQuery.HandlePendingRewards(ctx, plugin.incQueryServer) - case smartcontractQuery.CompletedIncentivePrograms != nil: - resp, err = smartcontractQuery.HandleCompletedIncentivePrograms(ctx, plugin.incQueryServer) - case smartcontractQuery.UpcomingIncentivePrograms != nil: - resp, err = smartcontractQuery.HandleUpcomingIncentivePrograms(ctx, plugin.incQueryServer) - case smartcontractQuery.OngoingIncentivePrograms != nil: - resp, err = smartcontractQuery.HandleOngoingIncentivePrograms(ctx, plugin.incQueryServer) - case smartcontractQuery.IncentiveProgram != nil: - resp, err = smartcontractQuery.HandleIncentiveParams(ctx, plugin.incQueryServer) - case smartcontractQuery.CurrentRates != nil: - resp, err = smartcontractQuery.HandleCurrentRates(ctx, plugin.incQueryServer) - case smartcontractQuery.ActualRates != nil: - resp, err = smartcontractQuery.HandleActualRates(ctx, plugin.incQueryServer) - case smartcontractQuery.LastRewardTime != nil: - resp, err = smartcontractQuery.HandleLastRewardTime(ctx, plugin.incQueryServer) - - // metoken - case smartcontractQuery.MeTokenParameters != nil: - resp, err = smartcontractQuery.HandleMeTokenParams(ctx, plugin.metokenQueryServer) - case smartcontractQuery.Indexes != nil: - resp, err = smartcontractQuery.HandleMeTokenIndexes(ctx, plugin.metokenQueryServer) - case smartcontractQuery.SwapFee != nil: - resp, err = smartcontractQuery.HandleMeTokenSwapFee(ctx, plugin.metokenQueryServer) - case smartcontractQuery.RedeemFee != nil: - resp, err = smartcontractQuery.HandleMeTokenRedeemFee(ctx, plugin.metokenQueryServer) - case smartcontractQuery.IndexBalances != nil: - resp, err = smartcontractQuery.HandleMeTokenIndexBalances(ctx, plugin.metokenQueryServer) - case smartcontractQuery.IndexPrices != nil: - resp, err = smartcontractQuery.HandleMeTokenIndexPrices(ctx, plugin.metokenQueryServer) - - default: - return nil, wasmvmtypes.UnsupportedRequest{Kind: "invalid umee query"} - } - - if err != nil { - return nil, wasmvmtypes.UnsupportedRequest{Kind: fmt.Sprintf("error %+v while query the assigned query ", err)} - } - - return MarshalResponse(resp) - } -} diff --git a/app/wasm/test/cosmwasm_test.go b/app/wasm/test/cosmwasm_test.go index 590f86ebf6..486f6d2d0c 100644 --- a/app/wasm/test/cosmwasm_test.go +++ b/app/wasm/test/cosmwasm_test.go @@ -18,12 +18,6 @@ func TestCosmwasm(t *testing.T) { // testing the umee cosmwasm queries its.InitiateUmeeCosmwasm() - its.TestLeverageQueries() - its.TestOracleQueries() - its.TestLeverageTxs() - its.TestIncentiveQueries() - its.TestMetokenQueries() - // stargate queries its.TestStargateQueries() } diff --git a/app/wasm/test/cw20_base_test.go b/app/wasm/test/cw20_base_test.go index b684bfdcb5..8d6da31153 100644 --- a/app/wasm/test/cw20_base_test.go +++ b/app/wasm/test/cw20_base_test.go @@ -26,7 +26,6 @@ import ( umeeapp "github.com/umee-network/umee/v6/app" appparams "github.com/umee-network/umee/v6/app/params" - wm "github.com/umee-network/umee/v6/app/wasm/msg" wq "github.com/umee-network/umee/v6/app/wasm/query" "github.com/umee-network/umee/v6/x/oracle/types" ) @@ -105,24 +104,12 @@ type StargateQuery struct { } `json:"chain"` } -type ExecuteMsg struct { - Umee struct { - Leverage wm.UmeeMsg `json:"leverage"` - } `json:"umee"` -} - func UmeeCwCustomQuery(umeeCWQuery wq.UmeeQuery) CustomQuery { c := CustomQuery{} c.Chain.Custom = umeeCWQuery return c } -func UmeeCwCustomTx(customMsg wm.UmeeMsg) ExecuteMsg { - c := ExecuteMsg{} - c.Umee.Leverage = customMsg - return c -} - type IntegrationTestSuite struct { T *testing.T ctx sdk.Context @@ -345,9 +332,3 @@ func (s *IntegrationTestSuite) genCustomQuery(umeeQuery wq.UmeeQuery) []byte { assert.NilError(s.T, err) return cq } - -func (s *IntegrationTestSuite) genCustomTx(msg wm.UmeeMsg) []byte { - cq, err := json.Marshal(UmeeCwCustomTx(msg)) - assert.NilError(s.T, err) - return cq -} diff --git a/app/wasm/test/umee_cw_test.go b/app/wasm/test/umee_cw_test.go index f319bd108a..0e2430c86e 100644 --- a/app/wasm/test/umee_cw_test.go +++ b/app/wasm/test/umee_cw_test.go @@ -7,172 +7,13 @@ import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" wasmvmtypes "github.com/CosmWasm/wasmvm/types" sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "gotest.tools/v3/assert" appparams "github.com/umee-network/umee/v6/app/params" - wm "github.com/umee-network/umee/v6/app/wasm/msg" - wq "github.com/umee-network/umee/v6/app/wasm/query" - "github.com/umee-network/umee/v6/x/incentive" lvtypes "github.com/umee-network/umee/v6/x/leverage/types" "github.com/umee-network/umee/v6/x/metoken" - "github.com/umee-network/umee/v6/x/oracle/types" ) -func (s *IntegrationTestSuite) TestLeverageQueries() { - tests := []struct { - Name string - CQ []byte - ResponseCheck func(data []byte) - }{ - { - Name: "leverage query params", - CQ: s.genCustomQuery(wq.UmeeQuery{ - LeverageParameters: &lvtypes.QueryParams{}, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryParamsResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.DeepEqual(s.T, rr.Params, lvtypes.DefaultParams()) - }, - }, - { - Name: "query all registered tokens", - CQ: s.genCustomQuery(wq.UmeeQuery{ - RegisteredTokens: &lvtypes.QueryRegisteredTokens{}, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryRegisteredTokensResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.Equal(s.T, true, len(rr.Registry) > 0) - }, - }, - { - Name: "query registered token", - CQ: s.genCustomQuery(wq.UmeeQuery{ - RegisteredTokens: &lvtypes.QueryRegisteredTokens{ - BaseDenom: appparams.BondDenom, - }, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryRegisteredTokensResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.Equal(s.T, true, len(rr.Registry) > 0) - assert.Equal(s.T, appparams.BondDenom, rr.Registry[0].BaseDenom) - }, - }, - { - Name: "market summary", - CQ: s.genCustomQuery(wq.UmeeQuery{ - MarketSummary: &lvtypes.QueryMarketSummary{ - Denom: appparams.BondDenom, - }, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryMarketSummaryResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.Equal(s.T, "UMEE", rr.SymbolDenom) - }, - }, - { - Name: "query bad debts", - CQ: s.genCustomQuery(wq.UmeeQuery{ - BadDebts: &lvtypes.QueryBadDebts{}, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryBadDebtsResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.Equal(s.T, true, len(rr.Targets) == 0) - }, - }, - { - Name: "query max withdraw (zero)", - CQ: s.genCustomQuery(wq.UmeeQuery{ - MaxWithdraw: &lvtypes.QueryMaxWithdraw{ - Address: addr.String(), - Denom: appparams.BondDenom, - }, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryMaxWithdrawResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.Equal(s.T, true, len(rr.Tokens) == 0) - assert.Equal(s.T, true, len(rr.UTokens) == 0) - }, - }, - { - Name: "query max borrow (zero)", - CQ: s.genCustomQuery(wq.UmeeQuery{ - MaxBorrow: &lvtypes.QueryMaxBorrow{ - Address: addr.String(), - Denom: appparams.BondDenom, - }, - }), - ResponseCheck: func(data []byte) { - var rr lvtypes.QueryMaxBorrowResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.Equal(s.T, true, len(rr.Tokens) == 0) - }, - }, - } - - for _, tc := range tests { - s.T.Run(tc.Name, func(t *testing.T) { - resp, err := s.wasmQueryClient.SmartContractState(sdk.WrapSDKContext(s.ctx), &wasmtypes.QuerySmartContractStateRequest{ - Address: s.contractAddr, QueryData: tc.CQ, - }) - assert.NilError(s.T, err) - tc.ResponseCheck(resp.Data) - }) - } -} - -func (s *IntegrationTestSuite) TestOracleQueries() { - tests := []struct { - Name string - CQ []byte - ResponseCheck func(data []byte) - }{ - { - Name: "oracle query params", - CQ: s.genCustomQuery(wq.UmeeQuery{ - OracleParams: &types.QueryParams{}, - }), - ResponseCheck: func(data []byte) { - var rr types.QueryParamsResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.DeepEqual(s.T, rr.Params, types.DefaultParams()) - }, - }, - { - Name: "oracle slash window", - CQ: s.genCustomQuery(wq.UmeeQuery{ - SlashWindow: &types.QuerySlashWindow{}, - }), - ResponseCheck: func(data []byte) { - var rr types.QuerySlashWindowResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - }, - }, - } - - for _, tc := range tests { - s.T.Run(tc.Name, func(t *testing.T) { - resp := s.queryContract(tc.CQ) - tc.ResponseCheck(resp.Data) - }) - } -} - func (s *IntegrationTestSuite) TestStargateQueries() { tests := []struct { name string @@ -255,114 +96,3 @@ func (s *IntegrationTestSuite) TestStargateQueries() { }) } } - -func (s *IntegrationTestSuite) TestLeverageTxs() { - accAddr := sdk.MustAccAddressFromBech32(s.contractAddr) - err := s.app.BankKeeper.SendCoinsFromModuleToAccount(s.ctx, minttypes.ModuleName, accAddr, sdk.NewCoins(sdk.NewCoin(appparams.BondDenom, sdk.NewInt(100000)))) - assert.NilError(s.T, err) - txTests := []struct { - Name string - Msg []byte - }{ - { - Name: "supply", - Msg: s.genCustomTx(wm.UmeeMsg{ - Supply: &lvtypes.MsgSupply{ - Supplier: s.contractAddr, - Asset: sdk.NewCoin(appparams.BondDenom, sdk.NewInt(700)), - }, - }), - }, - { - Name: "add collateral", - Msg: s.genCustomTx(wm.UmeeMsg{ - Collateralize: &lvtypes.MsgCollateralize{ - Borrower: s.contractAddr, - Asset: sdk.NewCoin("u/uumee", sdk.NewInt(700)), - }, - }), - }, - // { - // Name: "borrow", - // Msg: s.genCustomTx(wm.UmeeMsg{ - // Borrow: &lvtypes.MsgBorrow{ - // Borrower: addr2.String(), - // Asset: sdk.NewCoin(appparams.BondDenom, sdk.NewInt(150)), - // }, - // }), - // }, - } - - for _, tc := range txTests { - s.T.Run(tc.Name, func(t *testing.T) { - s.execContract(addr2, tc.Msg) - }) - } - - query := s.genCustomQuery(wq.UmeeQuery{ - AccountSummary: &lvtypes.QueryAccountSummary{ - Address: addr2.String(), - }, - }) - - resp := s.queryContract(query) - var rr lvtypes.QueryAccountSummaryResponse - err = json.Unmarshal(resp.Data, &rr) - assert.NilError(s.T, err) -} - -func (s *IntegrationTestSuite) TestIncentiveQueries() { - tests := []struct { - Name string - CQ []byte - ResponseCheck func(data []byte) - }{ - { - Name: "incentive query params", - CQ: s.genCustomQuery(wq.UmeeQuery{ - IncentiveParameters: &incentive.QueryParams{}, - }), - ResponseCheck: func(data []byte) { - var rr incentive.QueryParamsResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.DeepEqual(s.T, rr.Params, incentive.DefaultParams()) - }, - }, - } - - for _, tc := range tests { - s.T.Run(tc.Name, func(t *testing.T) { - resp := s.queryContract(tc.CQ) - tc.ResponseCheck(resp.Data) - }) - } -} - -func (s *IntegrationTestSuite) TestMetokenQueries() { - tests := []struct { - Name string - CQ []byte - ResponseCheck func(data []byte) - }{ - { - Name: "metoken query params", - CQ: s.genCustomQuery(wq.UmeeQuery{ - MeTokenParameters: &metoken.QueryParams{}, - }), - ResponseCheck: func(data []byte) { - var rr metoken.QueryParamsResponse - err := json.Unmarshal(data, &rr) - assert.NilError(s.T, err) - assert.DeepEqual(s.T, rr.Params, metoken.DefaultParams()) - }, - }, - } - - for _, tc := range tests { - s.T.Run(tc.Name, func(t *testing.T) { - resp := s.queryContract(tc.CQ) - tc.ResponseCheck(resp.Data) - }) - } -}