-
Notifications
You must be signed in to change notification settings - Fork 199
/
query_sdk_pairing.go
43 lines (33 loc) · 1.15 KB
/
query_sdk_pairing.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
package keeper
import (
"context"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/lavanet/lava/x/pairing/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (k Keeper) SdkPairing(goCtx context.Context, req *types.QueryGetPairingRequest) (*types.QuerySdkPairingResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(goCtx)
pairing, spec, err := k.getPairing(ctx, req)
if err != nil {
return nil, err
}
clientAddr, err := sdk.AccAddressFromBech32(req.Client)
if err != nil {
return nil, fmt.Errorf("invalid creator address %s error: %s", req.Client, err)
}
project, err := k.GetProjectData(ctx, clientAddr, req.ChainID, uint64(ctx.BlockHeight()))
if err != nil {
return nil, err
}
strictestPolicy, _, err := k.GetProjectStrictestPolicy(ctx, project, req.ChainID, uint64(ctx.BlockHeight()))
if err != nil {
return nil, err
}
downtimeParams := k.downtimeKeeper.GetParams(ctx)
return &types.QuerySdkPairingResponse{Pairing: pairing, Spec: spec, MaxCu: strictestPolicy.EpochCuLimit, DowntimeParams: &downtimeParams}, err
}