Skip to content

Commit

Permalink
Merge pull request #141 from White-Whale-Defi-Platform/use-osmo-proto…
Browse files Browse the repository at this point in the history
…-domain

queries: osmosis proto domain and stargate queries
  • Loading branch information
faddat authored May 10, 2023
2 parents 1d7c7f6 + b60bf4c commit debdecc
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
Expand Down Expand Up @@ -98,6 +99,7 @@ import (
ibcclient "github.com/cosmos/ibc-go/v7/modules/core/02-client"
ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types"
ibcporttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
Expand Down Expand Up @@ -602,17 +604,49 @@ func NewMigalooApp(
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}

// Stargate Queries
// recommended by @larry0x. using the same values as Juno
// ref: https://github.com/CosmosContracts/juno/blob/9885a8cd4ffc8d19546bd42b2da139ec5d224c25/app/keepers/keepers.go#L375-L399
// these are the exact settings from Juno except that we're using govv1 instead of govv1beta1 (which Juno would reference as govtypes)
accepted := wasmkeeper.AcceptedStargateQueries{
// ibc
"/ibc.core.client.v1.Query/ClientState": &ibcclienttypes.QueryClientStateResponse{},
"/ibc.core.client.v1.Query/ConsensusState": &ibcclienttypes.QueryConsensusStateResponse{},
"/ibc.core.connection.v1.Query/Connection": &ibcconnectiontypes.QueryConnectionResponse{},

// governance
"/cosmos.gov.v1beta1.Query/Vote": &govv1.QueryVoteResponse{},

// staking
"/cosmos.staking.v1beta1.Query/Delegation": &stakingtypes.QueryDelegationResponse{},
"/cosmos.staking.v1beta1.Query/Redelegations": &stakingtypes.QueryRedelegationsResponse{},
"/cosmos.staking.v1beta1.Query/UnbondingDelegation": &stakingtypes.QueryUnbondingDelegationResponse{},
"/cosmos.staking.v1beta1.Query/Validator": &stakingtypes.QueryValidatorResponse{},

// token factory
"/osmosis.tokenfactory.v1beta1.Query/Params": &tokenfactorytypes.QueryParamsResponse{},
"/osmosis.tokenfactory.v1beta1.Query/DenomAuthorityMetadata": &tokenfactorytypes.QueryDenomAuthorityMetadataResponse{},
"/osmosis.tokenfactory.v1beta1.Query/DenomsFromCreator": &tokenfactorytypes.QueryDenomsFromCreatorResponse{},
}

querierOpts := wasmkeeper.WithQueryPlugins(
&wasmkeeper.QueryPlugins{
Stargate: wasmkeeper.AcceptListStargateQuerier(accepted, bApp.GRPCQueryRouter(), appCodec),
})

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,token_factory"
wasmOpts = append(bindings.RegisterCustomPlugins(&app.BankKeeper.BaseKeeper, &app.TokenFactoryKeeper), wasmOpts...)
wasmOpts = append(bindings.RegisterCustomPlugins(&app.BankKeeper.BaseKeeper, &app.TokenFactoryKeeper), wasmOpts...) // add token factory options to x/wasm
wasmOpts = append(wasmOpts, querierOpts) // add the querier options to x/wasm // not in the first append for clarity
app.WasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
app.AccountKeeper,
app.BankKeeper,
app.StakingKeeper,
distrkeeper.NewQuerier(app.DistrKeeper),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
Expand Down

0 comments on commit debdecc

Please sign in to comment.