mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-15 04:25:27 +00:00
3853e276a6
Add query service to precisebank, mostly for e2e test purposes in #1966 Also fix client grpc codec
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/x/precisebank/types"
|
|
)
|
|
|
|
type queryServer struct {
|
|
keeper Keeper
|
|
}
|
|
|
|
// NewQueryServerImpl creates a new server for handling gRPC queries.
|
|
func NewQueryServerImpl(k Keeper) types.QueryServer {
|
|
return &queryServer{keeper: k}
|
|
}
|
|
|
|
var _ types.QueryServer = queryServer{}
|
|
|
|
// TotalFractionalBalances returns the total sum of all fractional balances.
|
|
// This is mostly for external verification of the total fractional balances,
|
|
// being a multiple of the conversion factor and backed by the reserve.
|
|
func (s queryServer) TotalFractionalBalances(
|
|
goCtx context.Context,
|
|
req *types.QueryTotalFractionalBalancesRequest,
|
|
) (*types.QueryTotalFractionalBalancesResponse, error) {
|
|
ctx := sdk.UnwrapSDKContext(goCtx)
|
|
|
|
totalAmount := s.keeper.GetTotalSumFractionalBalances(ctx)
|
|
|
|
totalCoin := sdk.NewCoin(types.ExtendedCoinDenom, totalAmount)
|
|
|
|
return &types.QueryTotalFractionalBalancesResponse{
|
|
Total: totalCoin,
|
|
}, nil
|
|
}
|