-
Notifications
You must be signed in to change notification settings - Fork 12
/
query.go
27 lines (23 loc) · 879 Bytes
/
query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package keeper
import (
// this line is used by starport scaffolding # 1
"github.com/functionx/fx-core/x/other/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
abci "github.com/tendermint/tendermint/abci/types"
)
func NewQuerier(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) {
switch path[0] {
case types.QueryGasPrice:
var gasPrices sdk.Coins
for _, coin := range ctx.MinGasPrices() {
gasPrices = append(gasPrices, sdk.NewCoin(coin.Denom, coin.Amount.TruncateInt()))
}
return codec.MarshalJSONIndent(legacyQuerierCdc, gasPrices)
default:
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0])
}
}
}