2021-08-26 10:08:11 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-10-10 10:38:33 +00:00
|
|
|
sdkmath "cosmossdk.io/math"
|
2021-08-26 10:08:11 +00:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
2022-09-07 06:36:11 +00:00
|
|
|
"github.com/cerc-io/laconicd/x/feemarket/types"
|
2021-08-26 10:08:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ types.QueryServer = Keeper{}
|
|
|
|
|
|
|
|
// Params implements the Query/Params gRPC method
|
|
|
|
func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
|
|
|
|
ctx := sdk.UnwrapSDKContext(c)
|
|
|
|
params := k.GetParams(ctx)
|
|
|
|
|
|
|
|
return &types.QueryParamsResponse{
|
|
|
|
Params: params,
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// BaseFee implements the Query/BaseFee gRPC method
|
|
|
|
func (k Keeper) BaseFee(c context.Context, _ *types.QueryBaseFeeRequest) (*types.QueryBaseFeeResponse, error) {
|
|
|
|
ctx := sdk.UnwrapSDKContext(c)
|
|
|
|
|
2021-10-06 11:22:32 +00:00
|
|
|
res := &types.QueryBaseFeeResponse{}
|
2021-08-26 10:08:11 +00:00
|
|
|
baseFee := k.GetBaseFee(ctx)
|
2021-10-06 11:22:32 +00:00
|
|
|
|
|
|
|
if baseFee != nil {
|
2022-10-10 10:38:33 +00:00
|
|
|
aux := sdkmath.NewIntFromBigInt(baseFee)
|
2021-10-06 11:22:32 +00:00
|
|
|
res.BaseFee = &aux
|
2021-08-26 10:08:11 +00:00
|
|
|
}
|
|
|
|
|
2021-10-06 11:22:32 +00:00
|
|
|
return res, nil
|
2021-08-26 10:08:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// BlockGas implements the Query/BlockGas gRPC method
|
|
|
|
func (k Keeper) BlockGas(c context.Context, _ *types.QueryBlockGasRequest) (*types.QueryBlockGasResponse, error) {
|
|
|
|
ctx := sdk.UnwrapSDKContext(c)
|
2022-10-10 10:38:33 +00:00
|
|
|
gas := k.GetBlockGasWanted(ctx)
|
2021-08-26 10:08:11 +00:00
|
|
|
|
|
|
|
return &types.QueryBlockGasResponse{
|
|
|
|
Gas: int64(gas),
|
|
|
|
}, nil
|
|
|
|
}
|