-
Notifications
You must be signed in to change notification settings - Fork 10
/
legacy_slashing_querier.go
59 lines (51 loc) · 2.09 KB
/
legacy_slashing_querier.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var _ slashingtypes.QueryServer = &LegacySlashingGRPCQuerier{}
type LegacySlashingGRPCQuerier struct {
keeper ContractSource
}
func NewLegacySlashingGRPCQuerier(keeper ContractSource) *LegacySlashingGRPCQuerier { //nolint:golint
return &LegacySlashingGRPCQuerier{keeper: keeper}
}
// SigningInfo legacy support for cosmos-sdk signing info. Note that not all field are available on tgrade
func (g LegacySlashingGRPCQuerier) SigningInfo(c context.Context, req *slashingtypes.QuerySigningInfoRequest) (*slashingtypes.QuerySigningInfoResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}
valAddr, err := sdk.AccAddressFromBech32(req.ConsAddress)
if err != nil {
return nil, status.Error(codes.InvalidArgument, "validator address")
}
return &slashingtypes.QuerySigningInfoResponse{
ValSigningInfo: slashingtypes.ValidatorSigningInfo{
Address: valAddr.String(),
StartHeight: 0,
IndexOffset: 0,
Tombstoned: false,
MissedBlocksCounter: 0,
},
}, nil
}
// SigningInfos is not supported and will return unimplemented error
func (g LegacySlashingGRPCQuerier) SigningInfos(c context.Context, req *slashingtypes.QuerySigningInfosRequest) (*slashingtypes.QuerySigningInfosResponse, error) {
logNotImplemented(sdk.UnwrapSDKContext(c), "SigningInfos")
return nil, status.Error(codes.Unimplemented, "not available, yet")
}
// Params is not supported. Method returns default slashing module params.
func (g LegacySlashingGRPCQuerier) Params(c context.Context, req *slashingtypes.QueryParamsRequest) (*slashingtypes.QueryParamsResponse, error) {
return &slashingtypes.QueryParamsResponse{
Params: slashingtypes.Params{
SignedBlocksWindow: 0,
MinSignedPerWindow: sdk.ZeroDec(),
DowntimeJailDuration: 0,
SlashFractionDoubleSign: sdk.ZeroDec(),
SlashFractionDowntime: sdk.ZeroDec(),
},
}, nil
}